diff options
Diffstat (limited to 'clang/lib/Index/USRGeneration.cpp')
| -rw-r--r-- | clang/lib/Index/USRGeneration.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp index 6a114f934a9..bec777ddf4f 100644 --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/lib/Index/USRGeneration.cpp @@ -173,8 +173,11 @@ bool USRGenerator::ShouldGenerateLocation(const NamedDecl *D) { return false; if (D->getParentFunctionOrMethod()) return true; + SourceLocation Loc = D->getLocation(); + if (Loc.isInvalid()) + return false; const SourceManager &SM = Context->getSourceManager(); - return !SM.isInSystemHeader(D->getLocation()); + return !SM.isInSystemHeader(Loc); } void USRGenerator::VisitDeclContext(const DeclContext *DC) { @@ -874,9 +877,11 @@ void clang::index::generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS) { bool clang::index::generateUSRForDecl(const Decl *D, SmallVectorImpl<char> &Buf) { - // Don't generate USRs for things with invalid locations. - if (!D || D->getLocStart().isInvalid()) + if (!D) return true; + // We don't ignore decls with invalid source locations. Implicit decls, like + // C++'s operator new function, can have invalid locations but it is fine to + // create USRs that can identify them. USRGenerator UG(&D->getASTContext(), Buf); UG.Visit(D); |

