forked from OSchip/llvm-project
As suggested by Argyrios, revert r76159 and make "FindImmediateParent"
a public static method of ASTLocation. llvm-svn: 76166
This commit is contained in:
parent
fab6cbe6cd
commit
3436f58e40
|
@ -42,7 +42,11 @@ class ASTLocation {
|
|||
public:
|
||||
ASTLocation() : D(0), Stm(0) {}
|
||||
|
||||
explicit ASTLocation(const Decl *d, const Stmt *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.");
|
||||
}
|
||||
|
||||
const Decl *getDecl() const { return D; }
|
||||
const Stmt *getStmt() const { return Stm; }
|
||||
|
@ -58,6 +62,7 @@ public:
|
|||
|
||||
/// \brief Checks that D is the immediate Decl parent of Node.
|
||||
static bool isImmediateParent(Decl *D, Stmt *Node);
|
||||
static Decl *FindImmediateParent(Decl *D, Stmt *Node);
|
||||
|
||||
friend bool operator==(const ASTLocation &L, const ASTLocation &R) {
|
||||
return L.D == R.D && L.Stm == R.Stm;
|
||||
|
|
|
@ -69,7 +69,10 @@ void CGBuilder::VisitCallExpr(CallExpr *CE) {
|
|||
if (FunctionDecl *CalleeDecl = CE->getDirectCallee()) {
|
||||
Entity *Ent = Entity::get(CalleeDecl, G.getProgram());
|
||||
CallGraphNode *CalleeNode = G.getOrInsertFunction(Ent);
|
||||
CallerNode->addCallee(ASTLocation(FD, CE), CalleeNode);
|
||||
|
||||
Decl *Parent = ASTLocation::FindImmediateParent(FD, CE);
|
||||
|
||||
CallerNode->addCallee(ASTLocation(Parent, CE), CalleeNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ static bool isContainedInStatement(Stmt *Node, Stmt *Parent) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static Decl *FindImmediateParent(Decl *D, Stmt *Node) {
|
||||
Decl *ASTLocation::FindImmediateParent(Decl *D, Stmt *Node) {
|
||||
assert(D && Node && "Passed null Decl or null Stmt");
|
||||
|
||||
if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
|
||||
|
@ -61,16 +61,6 @@ 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