Changeset View
Changeset View
Standalone View
Standalone View
clang-tools-extra/trunk/clangd/Diagnostics.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | bool adjustDiagFromHeader(Diag &D, const clang::Diagnostic &Info, | ||||
const SourceLocation &DiagLoc = Info.getLocation(); | const SourceLocation &DiagLoc = Info.getLocation(); | ||||
const SourceManager &SM = Info.getSourceManager(); | const SourceManager &SM = Info.getSourceManager(); | ||||
SourceLocation IncludeInMainFile; | SourceLocation IncludeInMainFile; | ||||
auto GetIncludeLoc = [&SM](SourceLocation SLoc) { | auto GetIncludeLoc = [&SM](SourceLocation SLoc) { | ||||
return SM.getIncludeLoc(SM.getFileID(SLoc)); | return SM.getIncludeLoc(SM.getFileID(SLoc)); | ||||
}; | }; | ||||
for (auto IncludeLocation = GetIncludeLoc(DiagLoc); IncludeLocation.isValid(); | for (auto IncludeLocation = GetIncludeLoc(DiagLoc); IncludeLocation.isValid(); | ||||
IncludeLocation = GetIncludeLoc(IncludeLocation)) | IncludeLocation = GetIncludeLoc(IncludeLocation)) { | ||||
if (clangd::isInsideMainFile(IncludeLocation, SM)) { | |||||
IncludeInMainFile = IncludeLocation; | IncludeInMainFile = IncludeLocation; | ||||
break; | |||||
} | |||||
} | |||||
if (IncludeInMainFile.isInvalid()) | if (IncludeInMainFile.isInvalid()) | ||||
return false; | return false; | ||||
// Update diag to point at include inside main file. | // Update diag to point at include inside main file. | ||||
D.File = SM.getFileEntryForID(SM.getMainFileID())->getName().str(); | D.File = SM.getFileEntryForID(SM.getMainFileID())->getName().str(); | ||||
D.Range.start = sourceLocToPosition(SM, IncludeInMainFile); | D.Range.start = sourceLocToPosition(SM, IncludeInMainFile); | ||||
D.Range.end = sourceLocToPosition( | D.Range.end = sourceLocToPosition( | ||||
SM, Lexer::getLocForEndOfToken(IncludeInMainFile, 0, SM, LangOpts)); | SM, Lexer::getLocForEndOfToken(IncludeInMainFile, 0, SM, LangOpts)); | ||||
▲ Show 20 Lines • Show All 485 Lines • Show Last 20 Lines |