Skip to content

Commit

Permalink
[AST][Introspection] Add a check to detect if introspection is suppor…
Browse files Browse the repository at this point in the history
…ted.

This could probably be made into a compile time constant, but that would involve generating a second inc file.

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D100530
  • Loading branch information
njames93 committed Apr 15, 2021
1 parent 542e780 commit f019e5f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 81 deletions.
1 change: 1 addition & 0 deletions clang/include/clang/Tooling/NodeIntrospection.h
Expand Up @@ -85,6 +85,7 @@ struct NodeLocationAccessors {
};

namespace NodeIntrospection {
bool hasIntrospectionSupport();
NodeLocationAccessors GetLocations(clang::Stmt const *Object);
NodeLocationAccessors GetLocations(clang::Decl const *Object);
NodeLocationAccessors GetLocations(clang::CXXCtorInitializer const *Object);
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Tooling/CMakeLists.txt
Expand Up @@ -35,6 +35,8 @@ if (NOT Python3_EXECUTABLE
namespace clang {
namespace tooling {
bool NodeIntrospection::hasIntrospectionSupport() { return false; }
NodeLocationAccessors NodeIntrospection::GetLocations(clang::Stmt const *) {
return {};
}
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
Expand Up @@ -28,6 +28,8 @@ def GeneratePrologue(self):
using LocationAndString = SourceLocationMap::value_type;
using RangeAndString = SourceRangeMap::value_type;
bool NodeIntrospection::hasIntrospectionSupport() { return true; }
"""

def GenerateBaseGetLocationsDeclaration(self, CladeName):
Expand Down Expand Up @@ -174,6 +176,8 @@ def main():
namespace clang {
namespace tooling {
bool NodeIntrospection::hasIntrospectionSupport() { return false; }
NodeLocationAccessors NodeIntrospection::GetLocations(clang::Stmt const *) {
return {};
}
Expand Down

0 comments on commit f019e5f

Please sign in to comment.