================ @@ -813,6 +813,18 @@ TEST(SourceCodeTests, isKeywords) { EXPECT_FALSE(isKeyword("override", LangOpts)); } +TEST(SourceCodeTests, isSpelledInSource) { + Annotations Test(""); + ParsedAST AST = TestTU::withCode(Test.code()).build(); + const SourceManager &SM = AST.getSourceManager(); + + EXPECT_TRUE( + isSpelledInSource(SM.getLocForStartOfFile(SM.getMainFileID()), SM)); + EXPECT_TRUE(isSpelledInSource(SourceLocation(), SM)); ---------------- HighCommander4 wrote:
I think it's worth adding a couple of comments here. First: ```c++ // Check that isSpelledInSource() handles various invalid source locations gracefully. ``` But also, a slightly more subtle point: ```c++ // Returning true for SourceLocation() is a behavior that falls out of the current // implementation, which has an early exit for isFileID(). // FIXME: Should it return false on SourceLocation()? Does it matter? ``` https://github.com/llvm/llvm-project/pull/76668 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits