diff --git a/clang/include/clang/Tooling/NodeIntrospection.h b/clang/include/clang/Tooling/NodeIntrospection.h --- a/clang/include/clang/Tooling/NodeIntrospection.h +++ b/clang/include/clang/Tooling/NodeIntrospection.h @@ -83,8 +83,8 @@ 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 --- a/clang/lib/Tooling/CMakeLists.txt +++ b/clang/lib/Tooling/CMakeLists.txt @@ -48,11 +48,11 @@ 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 --- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py +++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py @@ -11,6 +11,8 @@ implementationContent = '' + RefClades = {"NestedNameSpecifierLoc", "TemplateArgumentLoc", "TypeLoc"} + def __init__(self, templateClasses): self.templateClasses = templateClasses @@ -54,7 +56,7 @@ def GenerateBaseGetLocationsDeclaration(self, CladeName): InstanceDecoration = "*" - if CladeName == "TypeLoc": + if CladeName in self.RefClades: InstanceDecoration = "&" self.implementationContent += \ @@ -164,7 +166,7 @@ MethodReturnType = 'NodeLocationAccessors' InstanceDecoration = "*" - if CladeName == "TypeLoc": + if CladeName in self.RefClades: InstanceDecoration = "&" Signature = \ @@ -196,7 +198,7 @@ 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 @@ 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 @@ 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 --- a/clang/unittests/Introspection/IntrospectionTest.cpp +++ b/clang/unittests/Introspection/IntrospectionTest.cpp @@ -298,7 +298,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ const auto *TA = BoundNodes[0].getNodeAs("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected(Result.LocationAccessors);