[clang] [clang][Preprocessor] Fix expansion locations for feature-like builtin macros (PR #207130)

Macro Terra via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 9 02:31:52 PDT 2026


================
@@ -552,6 +552,19 @@ file './input.cpp'
   }
 }
 
+TEST_F(TokenCollectorTest, FeatureLikeBuiltinMacros) {
----------------
hongtaihu wrote:



> Is this test actually validating the source location information?
> 
> I was trying to think of a way to validate this via lit testing and I don't think this can be observed, but maybe we can get sufficiently creative with testing the location a diagnostic appears at?

Thanks, good point. I updated the test to check the source location metadata directly.

  It now checks the expansion range of the synthesized `1` token with
  `SourceManager::getExpansionRange()`, and verifies that the range starts at
  `__has_builtin` and ends at the closing paren of the builtin macro invocation.



https://github.com/llvm/llvm-project/pull/207130


More information about the cfe-commits mailing list