aboutsummaryrefslogtreecommitdiff
path: root/lib/Index/ASTLocation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Index/ASTLocation.cpp')
-rw-r--r--lib/Index/ASTLocation.cpp10
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);