diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-17 06:58:08 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-17 06:58:08 +0000 |
commit | adfc8d14ce2e5611aa366cb9135fa20095b7d191 (patch) | |
tree | 9e26d8fc7c0edad7bdcf9f769c3cded6ae1a9e39 /lib/Index/ASTLocation.cpp | |
parent | 24ff030f400b261c142bab748bf2d26e5aaa948c (diff) |
Relax the assertion in ASTLocation's ctor: if the decl is not the immediate
parent of the stmt, find the immediate parent for the stmt.
This is because sometimes we cannot get the immediate decl of the stmt when
creating the ASTLocation. We can only get a parent of the stmt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76159 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Index/ASTLocation.cpp')
-rw-r--r-- | lib/Index/ASTLocation.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp index 3cd657b9b9..3beff3f31a 100644 --- a/lib/Index/ASTLocation.cpp +++ b/lib/Index/ASTLocation.cpp @@ -61,6 +61,16 @@ static Decl *FindImmediateParent(Decl *D, Stmt *Node) { return 0; } +ASTLocation::ASTLocation(const Decl *d, const Stmt *stm) + : D(const_cast<Decl*>(d)), Stm(const_cast<Stmt*>(stm)) { + if (Stm) { + Decl *Parent = FindImmediateParent(D, Stm); + assert(Parent); + D = Parent; + } +} + + bool ASTLocation::isImmediateParent(Decl *D, Stmt *Node) { assert(D && Node && "Passed null Decl or null Stmt"); return D == FindImmediateParent(D, Node); |