File tree 3 files changed +10
-1
lines changed
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) {
27
27
return normalizeFolder (ret) ? ret : realPath (ret);
28
28
}
29
29
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
+
30
37
static Pos decomposed2LineAndCol (const SourceManager &sm,
31
38
std::pair<FileID, unsigned > i) {
32
39
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;
20
20
namespace ccls {
21
21
std::string pathFromFileEntry (const clang::FileEntry &file);
22
22
23
+ bool isInsideMainFile (const clang::SourceManager &sm, clang::SourceLocation sl);
24
+
23
25
Range fromCharSourceRange (const clang::SourceManager &sm,
24
26
const clang::LangOptions &lang,
25
27
clang::CharSourceRange csr,
Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ class StoreDiags : public DiagnosticConsumer {
243
243
return ;
244
244
const SourceManager &sm = info.getSourceManager ();
245
245
StringRef filename = sm.getFilename (info.getLocation ());
246
- bool concerned = sm. isWrittenInMainFile ( l);
246
+ bool concerned = isInsideMainFile (sm, l);
247
247
auto fillDiagBase = [&](DiagBase &d) {
248
248
llvm::SmallString<64 > message;
249
249
info.FormatDiagnostic (message);
You can’t perform that action at this time.
0 commit comments