From: Argyrios Kyrtzidis Date: Sun, 5 Jul 2009 22:21:46 +0000 (+0000) Subject: Avoid re-checking the parameters of a function, when trying to resolve a location. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07796e1c522921e2b396df36bf9c1f702ffb2fb5;p=clang Avoid re-checking the parameters of a function, when trying to resolve a location. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74799 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/ResolveLocation.cpp b/lib/Frontend/ResolveLocation.cpp index 3dcd2143cb..5b8eed0c0e 100644 --- a/lib/Frontend/ResolveLocation.cpp +++ b/lib/Frontend/ResolveLocation.cpp @@ -203,13 +203,20 @@ void DeclLocResolver::VisitFunctionDecl(FunctionDecl *D) { // 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); - DLR.VisitDeclContext(D); - if (DLR.FoundIt()) { - llvm::tie(Dcl, Stm) = DLR.getResult(); - return; + for (DeclContext::decl_iterator + I = D->decls_begin(), E = D->decls_end(); I != E; ++I) { + if (isa(*I)) + continue; // We already searched through the parameters. + + DLR.Visit(*I); + if (DLR.FoundIt()) { + llvm::tie(Dcl, Stm) = DLR.getResult(); + return; + } } - + // We didn't find a declaration that corresponds to the source location. // Finally, search through the body of the function.