diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-05 22:21:17 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-05 22:21:17 +0000 |
| commit | 62afb198be0de1f9f14e9676e09b7f1ef8e574ee (patch) | |
| tree | 8faaa2b80b2c2349539ede5924980ae039065a75 /clang/lib | |
| parent | e3aa454e2f81ed5170cffc3f50193634810442f2 (diff) | |
| download | bcm5719-llvm-62afb198be0de1f9f14e9676e09b7f1ef8e574ee.tar.gz bcm5719-llvm-62afb198be0de1f9f14e9676e09b7f1ef8e574ee.zip | |
Do an early check for function definition.
llvm-svn: 74796
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Frontend/ResolveLocation.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/clang/lib/Frontend/ResolveLocation.cpp b/clang/lib/Frontend/ResolveLocation.cpp index d7a9b4852a9..fd5cacf127e 100644 --- a/clang/lib/Frontend/ResolveLocation.cpp +++ b/clang/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; } } |

