diff options
Diffstat (limited to 'clang/lib/Analysis/PathDiagnostic.cpp')
-rw-r--r-- | clang/lib/Analysis/PathDiagnostic.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Analysis/PathDiagnostic.cpp b/clang/lib/Analysis/PathDiagnostic.cpp index da007c16ec4..1d00727d0a2 100644 --- a/clang/lib/Analysis/PathDiagnostic.cpp +++ b/clang/lib/Analysis/PathDiagnostic.cpp @@ -171,8 +171,13 @@ SourceRange PathDiagnosticLocation::asRange() const { case DeclK: if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) return MD->getSourceRange(); - if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) - return FD->getBody()->getSourceRange(); + if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { + // FIXME: We would like to always get the function body, even + // when it needs to be de-serialized, but getting the + // ASTContext here requires significant changes. + if (CompoundStmt *Body = FD->getBodyIfAvailable()) + return Body->getSourceRange(); + } else { SourceLocation L = D->getLocation(); return SourceRange(L, L); |