[AST] Update tests to query for introspection support
authorStephen Kelly <steveire@gmail.com>
Fri, 23 Apr 2021 15:24:14 +0000 (16:24 +0100)
committerStephen Kelly <steveire@gmail.com>
Fri, 23 Apr 2021 16:51:10 +0000 (17:51 +0100)
clang/unittests/Introspection/IntrospectionTest.cpp

index 0abfe98..62198f5 100644 (file)
@@ -1226,6 +1226,8 @@ STRING_LOCATION_PAIR(Base, getTypeSourceInfo()->getTypeLoc().getLocalSourceRange
 }
 
 TEST(Introspection, SourceLocations_FunctionProtoTypeLoc) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+    return;
   auto AST =
       buildASTFromCode(R"cpp(
 int foo();
@@ -1242,10 +1244,6 @@ int foo();
   const auto *TL = BoundNodes[0].getNodeAs<TypeLoc>("tl");
   auto Result = NodeIntrospection::GetLocations(*TL);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-    return;
-  }
-
   auto ExpectedLocations =
       FormatExpected<SourceLocation>(Result.LocationAccessors);
 
@@ -1290,6 +1288,8 @@ STRING_LOCATION_PAIR(TL, getSourceRange())
 }
 
 TEST(Introspection, SourceLocations_PointerTypeLoc) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+    return;
   auto AST =
       buildASTFromCode(R"cpp(
 int* i;
@@ -1308,10 +1308,6 @@ int* i;
   const auto *TL = BoundNodes[0].getNodeAs<TypeLoc>("tl");
   auto Result = NodeIntrospection::GetLocations(*TL);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-    return;
-  }
-
   auto ExpectedLocations =
       FormatExpected<SourceLocation>(Result.LocationAccessors);
 
@@ -1355,6 +1351,8 @@ STRING_LOCATION_PAIR(TL, getSourceRange())
 #ifndef _WIN32
 // This test doesn't work on windows due to use of the typeof extension.
 TEST(Introspection, SourceLocations_TypeOfTypeLoc) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+    return;
   auto AST =
       buildASTFromCode(R"cpp(
 typeof (static_cast<void *>(0)) i;
@@ -1373,10 +1371,6 @@ typeof (static_cast<void *>(0)) i;
   const auto *TL = BoundNodes[0].getNodeAs<TypeLoc>("tl");
   auto Result = NodeIntrospection::GetLocations(*TL);
 
-  if (Result.LocationAccessors.empty() && Result.RangeAccessors.empty()) {
-    return;
-  }
-
   auto ExpectedLocations =
       FormatExpected<SourceLocation>(Result.LocationAccessors);