forked from OSchip/llvm-project
[clangd] Stop isSpelledInSource from printing source locations.
It shows up on profiles, albeit only at 0.1% or so.
This commit is contained in:
parent
e18736149c
commit
0a50eafd1d
|
@ -228,12 +228,16 @@ Position sourceLocToPosition(const SourceManager &SM, SourceLocation Loc) {
|
|||
}
|
||||
|
||||
bool isSpelledInSource(SourceLocation Loc, const SourceManager &SM) {
|
||||
if (Loc.isMacroID()) {
|
||||
std::string PrintLoc = SM.getSpellingLoc(Loc).printToString(SM);
|
||||
if (llvm::StringRef(PrintLoc).startswith("<scratch") ||
|
||||
llvm::StringRef(PrintLoc).startswith("<command line>"))
|
||||
return false;
|
||||
}
|
||||
if (Loc.isFileID())
|
||||
return true;
|
||||
auto Spelling = SM.getDecomposedSpellingLoc(Loc);
|
||||
StringRef SpellingFile = SM.getSLocEntry(Spelling.first).getFile().getName();
|
||||
if (SpellingFile == "<scratch space>")
|
||||
return false;
|
||||
if (SpellingFile == "<built-in>")
|
||||
// __STDC__ etc are considered spelled, but BAR in arg -DFOO=BAR is not.
|
||||
return !SM.isWrittenInCommandLineFile(
|
||||
SM.getComposedLoc(Spelling.first, Spelling.second));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue