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
This commit is contained in:
parent
aeb44a31f6
commit
d25ea831b2
|
@ -42,11 +42,7 @@ class ASTLocation {
|
|||
public:
|
||||
ASTLocation() : D(0), Stm(0) {}
|
||||
|
||||
explicit ASTLocation(const Decl *d, const Stmt *stm = 0)
|
||||
: D(const_cast<Decl*>(d)), Stm(const_cast<Stmt*>(stm)) {
|
||||
assert((Stm == 0 || isImmediateParent(D, Stm)) &&
|
||||
"The Decl is not the immediate parent of the Stmt.");
|
||||
}
|
||||
explicit ASTLocation(const Decl *d, const Stmt *stm = 0);
|
||||
|
||||
const Decl *getDecl() const { return D; }
|
||||
const Stmt *getStmt() const { return Stm; }
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue