From: Argyrios Kyrtzidis Date: Sun, 5 Jul 2009 22:21:17 +0000 (+0000) Subject: Do an early check for function definition. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=685477f910901e57b2441981c3bd3d5b9c0f228d;p=clang Do an early check for function definition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74796 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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; } }