diff --git a/clang/include/clang/Tooling/NodeIntrospection.h b/clang/include/clang/Tooling/NodeIntrospection.h index dd7ffe39912078..a04c08823339d5 100644 --- a/clang/include/clang/Tooling/NodeIntrospection.h +++ b/clang/include/clang/Tooling/NodeIntrospection.h @@ -83,8 +83,8 @@ bool hasIntrospectionSupport(); NodeLocationAccessors GetLocations(clang::Stmt const *Object); NodeLocationAccessors GetLocations(clang::Decl const *Object); NodeLocationAccessors GetLocations(clang::CXXCtorInitializer const *Object); -NodeLocationAccessors GetLocations(clang::NestedNameSpecifierLoc const *); -NodeLocationAccessors GetLocations(clang::TemplateArgumentLoc const *); +NodeLocationAccessors GetLocations(clang::NestedNameSpecifierLoc const &); +NodeLocationAccessors GetLocations(clang::TemplateArgumentLoc const &); NodeLocationAccessors GetLocations(clang::CXXBaseSpecifier const *); NodeLocationAccessors GetLocations(clang::TypeLoc const &); NodeLocationAccessors GetLocations(clang::DynTypedNode const &Node); diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt index a0bb108a2b6c43..2baea134271e52 100644 --- a/clang/lib/Tooling/CMakeLists.txt +++ b/clang/lib/Tooling/CMakeLists.txt @@ -48,11 +48,11 @@ NodeLocationAccessors NodeIntrospection::GetLocations( return {}; } NodeLocationAccessors NodeIntrospection::GetLocations( - clang::NestedNameSpecifierLoc const*) { + clang::NestedNameSpecifierLoc const&) { return {}; } NodeLocationAccessors NodeIntrospection::GetLocations( - clang::TemplateArgumentLoc const*) { + clang::TemplateArgumentLoc const&) { return {}; } NodeLocationAccessors NodeIntrospection::GetLocations( diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py index 3664f521e27b70..fdf586e7e11502 100755 --- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py +++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py @@ -11,6 +11,8 @@ class Generator(object): implementationContent = '' + RefClades = {"NestedNameSpecifierLoc", "TemplateArgumentLoc", "TypeLoc"} + def __init__(self, templateClasses): self.templateClasses = templateClasses @@ -54,7 +56,7 @@ def GeneratePrologue(self): def GenerateBaseGetLocationsDeclaration(self, CladeName): InstanceDecoration = "*" - if CladeName == "TypeLoc": + if CladeName in self.RefClades: InstanceDecoration = "&" self.implementationContent += \ @@ -164,7 +166,7 @@ def GenerateBaseGetLocationsFunction(self, ASTClassNames, MethodReturnType = 'NodeLocationAccessors' InstanceDecoration = "*" - if CladeName == "TypeLoc": + if CladeName in self.RefClades: InstanceDecoration = "&" Signature = \ @@ -196,7 +198,7 @@ def GenerateBaseGetLocationsFunction(self, ASTClassNames, RecursionGuardParam = ', TypeLocRecursionGuard' ArgPrefix = '*' - if CladeName == "TypeLoc": + if CladeName in self.RefClades: ArgPrefix = '' self.implementationContent += \ 'GetLocations{0}(Prefix, {1}Object, Locs, Rngs {2});'.format( @@ -290,7 +292,7 @@ def GenerateDynNodeVisitor(self, CladeNames): if (const auto *N = Node.get<{0}>()) """.format(CladeName) ArgPrefix = "" - if CladeName == "TypeLoc": + if CladeName in self.RefClades: ArgPrefix = "*" self.implementationContent += \ """ @@ -351,11 +353,11 @@ def main(): return {}; } NodeLocationAccessors NodeIntrospection::GetLocations( - clang::NestedNameSpecifierLoc const*) { + clang::NestedNameSpecifierLoc const&) { return {}; } NodeLocationAccessors NodeIntrospection::GetLocations( - clang::TemplateArgumentLoc const*) { + clang::TemplateArgumentLoc const&) { return {}; } NodeLocationAccessors NodeIntrospection::GetLocations( diff --git a/clang/unittests/Introspection/IntrospectionTest.cpp b/clang/unittests/Introspection/IntrospectionTest.cpp index 57431668a19f43..1db3e6a8e6d65f 100644 --- a/clang/unittests/Introspection/IntrospectionTest.cpp +++ b/clang/unittests/Introspection/IntrospectionTest.cpp @@ -298,7 +298,7 @@ void ns::A::foo() {} const auto *NNS = BoundNodes[0].getNodeAs("nns"); - auto Result = NodeIntrospection::GetLocations(NNS); + auto Result = NodeIntrospection::GetLocations(*NNS); auto ExpectedLocations = FormatExpected(Result.LocationAccessors); @@ -352,7 +352,7 @@ void foo() const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors); @@ -407,7 +407,7 @@ void test() { const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors); @@ -444,7 +444,7 @@ void test() { const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors); @@ -480,7 +480,7 @@ void test() { const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors); @@ -517,7 +517,7 @@ void bar() const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors); @@ -555,7 +555,7 @@ template class ...> class B { }; const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors); @@ -591,7 +591,7 @@ template class testExpr { }; const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors); @@ -628,7 +628,7 @@ void foo() const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors);