aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/ResolveLocation.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-05 22:21:17 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-05 22:21:17 +0000
commit685477f910901e57b2441981c3bd3d5b9c0f228d (patch)
tree7bbd5407ec6757a230dca49c1cee6299a29ff580 /lib/Frontend/ResolveLocation.cpp
parent624c1467809b409dcfa596b176ef45943442296b (diff)
Do an early check for function definition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74796 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ResolveLocation.cpp')
-rw-r--r--lib/Frontend/ResolveLocation.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/Frontend/ResolveLocation.cpp b/lib/Frontend/ResolveLocation.cpp
index d7a9b4852a..fd5cacf127 100644
--- a/lib/Frontend/ResolveLocation.cpp
+++ b/lib/Frontend/ResolveLocation.cpp
@@ -197,6 +197,9 @@ void DeclLocResolver::VisitFunctionDecl(FunctionDecl *D) {
// We didn't found the location in the parameters and we didn't get passed it.
+ if (!D->isThisDeclarationADefinition())
+ return;
+
// Second, search through the declarations that are part of the function.
// If we find he location there, we won't have to search through its body.
DeclLocResolver DLR(Ctx, Loc);
@@ -209,16 +212,15 @@ void DeclLocResolver::VisitFunctionDecl(FunctionDecl *D) {
// We didn't find a declaration that corresponds to the source location.
// Finally, search through the body of the function.
- if (D->isThisDeclarationADefinition()) {
- StmtLocResolver SLR(Ctx, Loc);
- SLR.Visit(D->getBody());
- if (SLR.FoundIt()) {
- llvm::tie(Dcl, Stm) = SLR.getResult();
- // If we didn't find a more immediate 'parent' declaration for the
- // statement, set the function as the parent.
- if (Dcl == 0)
- Dcl = D;
- }
+ assert(D->getBody() && "Expected definition");
+ StmtLocResolver SLR(Ctx, Loc);
+ SLR.Visit(D->getBody());
+ if (SLR.FoundIt()) {
+ llvm::tie(Dcl, Stm) = SLR.getResult();
+ // If we didn't find a more immediate 'parent' declaration for the
+ // statement, set the function as the parent.
+ if (Dcl == 0)
+ Dcl = D;
}
}