[cfe-commits] r74796 - /cfe/trunk/lib/Frontend/ResolveLocation.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Sun Jul 5 15:21:17 PDT 2009
Author: akirtzidis
Date: Sun Jul 5 17:21:17 2009
New Revision: 74796
URL: http://llvm.org/viewvc/llvm-project?rev=74796&view=rev
Log:
Do an early check for function definition.
Modified:
cfe/trunk/lib/Frontend/ResolveLocation.cpp
Modified: cfe/trunk/lib/Frontend/ResolveLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ResolveLocation.cpp?rev=74796&r1=74795&r2=74796&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ResolveLocation.cpp (original)
+++ cfe/trunk/lib/Frontend/ResolveLocation.cpp Sun Jul 5 17:21:17 2009
@@ -197,6 +197,9 @@
// 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 @@
// 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;
}
}
More information about the cfe-commits
mailing list