File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ std::string pathFromFileEntry(const FileEntry &file) {
2727 return normalizeFolder (ret) ? ret : realPath (ret);
2828}
2929
30+ bool isInsideMainFile (const SourceManager &sm, SourceLocation sl) {
31+ if (!sl.isValid ())
32+ return false ;
33+ FileID fid = sm.getFileID (sm.getExpansionLoc (sl));
34+ return fid == sm.getMainFileID () || fid == sm.getPreambleFileID ();
35+ }
36+
3037static Pos decomposed2LineAndCol (const SourceManager &sm,
3138 std::pair<FileID, unsigned > i) {
3239 int l = (int )sm.getLineNumber (i.first , i.second ) - 1 ,
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ namespace vfs = clang::vfs;
2020namespace ccls {
2121std::string pathFromFileEntry (const clang::FileEntry &file);
2222
23+ bool isInsideMainFile (const clang::SourceManager &sm, clang::SourceLocation sl);
24+
2325Range fromCharSourceRange (const clang::SourceManager &sm,
2426 const clang::LangOptions &lang,
2527 clang::CharSourceRange csr,
Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ class StoreDiags : public DiagnosticConsumer {
243243 return ;
244244 const SourceManager &sm = info.getSourceManager ();
245245 StringRef filename = sm.getFilename (info.getLocation ());
246- bool concerned = sm. isWrittenInMainFile ( l);
246+ bool concerned = isInsideMainFile (sm, l);
247247 auto fillDiagBase = [&](DiagBase &d) {
248248 llvm::SmallString<64 > message;
249249 info.FormatDiagnostic (message);
You can’t perform that action at this time.
0 commit comments