steveire created this revision. steveire added a reviewer: njames93. Herald added a subscriber: mgorny. steveire requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D100720 Files: clang/include/clang/Tooling/NodeIntrospection.h clang/lib/Tooling/CMakeLists.txt clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py clang/unittests/Introspection/IntrospectionTest.cpp
Index: clang/unittests/Introspection/IntrospectionTest.cpp =================================================================== --- clang/unittests/Introspection/IntrospectionTest.cpp +++ clang/unittests/Introspection/IntrospectionTest.cpp @@ -298,7 +298,7 @@ const auto *NNS = BoundNodes[0].getNodeAs<NestedNameSpecifierLoc>("nns"); - auto Result = NodeIntrospection::GetLocations(NNS); + auto Result = NodeIntrospection::GetLocations(*NNS); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); @@ -352,7 +352,7 @@ const auto *TA = BoundNodes[0].getNodeAs<TemplateArgumentLoc>("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); @@ -407,7 +407,7 @@ const auto *TA = BoundNodes[0].getNodeAs<TemplateArgumentLoc>("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); @@ -444,7 +444,7 @@ const auto *TA = BoundNodes[0].getNodeAs<TemplateArgumentLoc>("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); @@ -480,7 +480,7 @@ const auto *TA = BoundNodes[0].getNodeAs<TemplateArgumentLoc>("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); @@ -517,7 +517,7 @@ const auto *TA = BoundNodes[0].getNodeAs<TemplateArgumentLoc>("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); @@ -555,7 +555,7 @@ const auto *TA = BoundNodes[0].getNodeAs<TemplateArgumentLoc>("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); @@ -591,7 +591,7 @@ const auto *TA = BoundNodes[0].getNodeAs<TemplateArgumentLoc>("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); @@ -628,7 +628,7 @@ const auto *TA = BoundNodes[0].getNodeAs<TemplateArgumentLoc>("ta"); - auto Result = NodeIntrospection::GetLocations(TA); + auto Result = NodeIntrospection::GetLocations(*TA); auto ExpectedLocations = FormatExpected<SourceLocation>(Result.LocationAccessors); Index: clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py =================================================================== --- clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py +++ 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( Index: clang/lib/Tooling/CMakeLists.txt =================================================================== --- clang/lib/Tooling/CMakeLists.txt +++ clang/lib/Tooling/CMakeLists.txt @@ -47,11 +47,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( Index: clang/include/clang/Tooling/NodeIntrospection.h =================================================================== --- clang/include/clang/Tooling/NodeIntrospection.h +++ 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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits