[clang] df82fa8 - [AST] Update tests to query for introspection support

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 23 09:52:06 PDT 2021


Author: Stephen Kelly
Date: 2021-04-23T17:51:10+01:00
New Revision: df82fa8d9ba6891c0ad1061fc452ea9f271d8ad4

URL: https://github.com/llvm/llvm-project/commit/df82fa8d9ba6891c0ad1061fc452ea9f271d8ad4
DIFF: https://github.com/llvm/llvm-project/commit/df82fa8d9ba6891c0ad1061fc452ea9f271d8ad4.diff

LOG: [AST] Update tests to query for introspection support

Added: 
    

Modified: 
    clang/unittests/Introspection/IntrospectionTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Introspection/IntrospectionTest.cpp b/clang/unittests/Introspection/IntrospectionTest.cpp
index 0abfe983fd13f..62198f56ac7da 100644
--- a/clang/unittests/Introspection/IntrospectionTest.cpp
+++ b/clang/unittests/Introspection/IntrospectionTest.cpp
@@ -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);
 


        


More information about the cfe-commits mailing list