[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback
Argyrios Kyrtzidis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 30 16:32:21 PDT 2022
akyrtzi added inline comments.
================
Comment at: clang/lib/Basic/SourceManager.cpp:1016
+ return *Name;
return StringRef();
}
----------------
benlangmuir wrote:
> Just a suggestion: `value_or` can be a nice way to express simple cases like this:
>
> ```
> getFilename(getFileID(SpellingLoc)).value_or(StringRef());
> ```
Thank you for the tip!
================
Comment at: clang/lib/Lex/PPLexerChange.cpp:136
PPCallbacks::EnterFile, FileType);
+ FileID PrevFID;
+ SourceLocation EnterLoc;
----------------
benlangmuir wrote:
> Why does `LexedFileChanged` have `PrevFID` set, but `FileChanged` does not (it has a default argument of `FileID()`? I would have expected that when you call both `FileChanged` and `LexedFileChanged` for the same event this would match.
I didn't want to change the "contract" of `FileChanged()` as part of these changes but it's probably unlikely that someone depends on `FileID` being invalid, I'll give it a try.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128947/new/
https://reviews.llvm.org/D128947
More information about the cfe-commits
mailing list