Author: Stephen Kelly
Date: 2021-03-17T12:08:55Z
New Revision: b90e7bf25dc3cc056331dfe5fca21b3ea1713299

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

LOG: NFC: Use a simple macro to test AST node introspection

Added: 
    

Modified: 
    clang/unittests/Introspection/IntrospectionTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Introspection/IntrospectionTest.cpp 
b/clang/unittests/Introspection/IntrospectionTest.cpp
index 7977e870101f..a1280d9da535 100644
--- a/clang/unittests/Introspection/IntrospectionTest.cpp
+++ b/clang/unittests/Introspection/IntrospectionTest.cpp
@@ -40,6 +40,8 @@ FormatExpected(const MapType &Accessors) {
   return Result;
 }
 
+#define STRING_LOCATION_PAIR(INSTANCE, LOC) Pair(#LOC, INSTANCE->LOC)
+
 TEST(Introspection, SourceLocations) {
   auto AST = buildASTFromCode("void foo() {} void bar() { foo(); }", "foo.cpp",
                               std::make_shared<PCHContainerOperations>());
@@ -67,14 +69,13 @@ TEST(Introspection, SourceLocations) {
 
   EXPECT_THAT(
       ExpectedLocations,
-      UnorderedElementsAre(Pair("getBeginLoc()", FooCall->getBeginLoc()),
-                           Pair("getEndLoc()", FooCall->getEndLoc()),
-                           Pair("getExprLoc()", FooCall->getExprLoc()),
-                           Pair("getRParenLoc()", FooCall->getRParenLoc())));
+      UnorderedElementsAre(STRING_LOCATION_PAIR(FooCall, getBeginLoc()),
+                           STRING_LOCATION_PAIR(FooCall, getEndLoc()),
+                           STRING_LOCATION_PAIR(FooCall, getExprLoc()),
+                           STRING_LOCATION_PAIR(FooCall, getRParenLoc())));
 
   auto ExpectedRanges = FormatExpected<SourceRange>(Result.RangeAccessors);
 
-  EXPECT_THAT(ExpectedRanges,
-              UnorderedElementsAre(
-                  Pair("getSourceRange()", FooCall->getSourceRange())));
+  EXPECT_THAT(ExpectedRanges, UnorderedElementsAre(STRING_LOCATION_PAIR(
+                                  FooCall, getSourceRange())));
 }


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to