[llvm] [clang] [clang-tools-extra] [clangd] Fix is spelled in source bug (PR #76668)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 1 00:20:50 PST 2024


================
@@ -232,7 +232,12 @@ bool isSpelledInSource(SourceLocation Loc, const SourceManager &SM) {
   if (Loc.isFileID())
     return true;
   auto Spelling = SM.getDecomposedSpellingLoc(Loc);
-  StringRef SpellingFile = SM.getSLocEntry(Spelling.first).getFile().getName();
+  bool InvalidSLocEntry = false;
+  const auto SLocEntry = SM.getSLocEntry(Spelling.first, &InvalidSLocEntry);
+  if (InvalidSLocEntry) {
+    return false;
+  }
+  const StringRef SpellingFile = SLocEntry.getFile().getName();
----------------
zyn0217 wrote:

The const qualifier looks unnecessary to me. Could you please leave it out?

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


More information about the cfe-commits mailing list