summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index/ASTLocation.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-07-17 06:58:08 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-07-17 06:58:08 +0000
commitd25ea831b2bd55aeec3481e690d624fdb229f59a (patch)
tree145c6aed19b221bd0e6f5d59f2f1e3ae842a55e9 /clang/lib/Index/ASTLocation.cpp
parentaeb44a31f6fd67ae4c24c8d1841d15461a581335 (diff)
downloadbcm5719-llvm-d25ea831b2bd55aeec3481e690d624fdb229f59a.tar.gz
bcm5719-llvm-d25ea831b2bd55aeec3481e690d624fdb229f59a.zip
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. llvm-svn: 76159
Diffstat (limited to 'clang/lib/Index/ASTLocation.cpp')
-rw-r--r--clang/lib/Index/ASTLocation.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Index/ASTLocation.cpp b/clang/lib/Index/ASTLocation.cpp
index 3cd657b9b91..3beff3f31a8 100644
--- a/clang/lib/Index/ASTLocation.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud