================
@@ -552,6 +552,25 @@ file './input.cpp'
}
}
+TEST_F(TokenCollectorTest, FeatureLikeBuiltinMacros) {
+ recordTokens("__has_builtin(__builtin_allow_runtime_check)\n");
+ EXPECT_THAT(Buffer.expandedTokens(),
+ ElementsAre(AllOf(Kind(tok::numeric_constant), HasText("1")),
+ Kind(tok::eof)));
+ auto ExpansionRange =
+ SourceMgr->getExpansionRange(findExpanded("1").front().location());
+ auto MacroInvocation =
+ findSpelled("__has_builtin ( __builtin_allow_runtime_check )");
+ EXPECT_EQ(MacroInvocation.front().location(), ExpansionRange.getBegin());
+ EXPECT_EQ(MacroInvocation.back().location(), ExpansionRange.getEnd());
+
+ AllowErrors = true;
+ recordTokens("__is_identifier;\n");
+ EXPECT_THAT(Buffer.expandedTokens(),
+ ElementsAre(AllOf(Kind(tok::numeric_constant), HasText("0")),
+ Kind(tok::eof)));
----------------
AaronBallman wrote:
I think this test can likely be removed given that it's not testing locations
(it's just a "demonstrate we don't crash" test I believe, but the other test
also covers that need).
https://github.com/llvm/llvm-project/pull/207130
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits