18 #include "llvm/ADT/DenseMap.h"
20 using namespace clang;
22 typedef llvm::DenseMap<Stmt*, Stmt*>
MapTy;
32 switch (S->getStmtClass()) {
33 case Stmt::PseudoObjectExprClass: {
34 assert(OVMode ==
OV_Transparent &&
"Should not appear alongside OVEs");
39 for (
Stmt *SubStmt : S->children())
53 case Stmt::BinaryConditionalOperatorClass: {
54 assert(OVMode ==
OV_Transparent &&
"Should not appear alongside OVEs");
71 case Stmt::OpaqueValueExprClass: {
85 for (
Stmt *SubStmt : S->children()) {
104 delete (
MapTy*) Impl;
117 M->insert(std::make_pair(const_cast<Stmt *>(S), const_cast<Stmt *>(Parent)));
122 MapTy::iterator I = M->find(S);
123 return I == M->end() ?
nullptr : I->second;
127 do { S =
getParent(S); }
while (S && isa<ParenExpr>(S));
135 while (S && (isa<ParenExpr>(S) || isa<CastExpr>(S)));
143 }
while (S && isa<Expr>(S) && cast<Expr>(S)->IgnoreParenImpCasts() != S);
150 while (isa<ParenExpr>(S)) {
159 Stmt *DirectChild = E;
162 while (P && (isa<ParenExpr>(P) || isa<CastExpr>(P) ||
163 isa<ExprWithCleanups>(P))) {
171 switch (P->getStmtClass()) {
174 case Stmt::DeclStmtClass:
176 case Stmt::BinaryOperatorClass: {
182 case Stmt::ForStmtClass:
183 return DirectChild == cast<ForStmt>(
P)->getCond();
184 case Stmt::WhileStmtClass:
185 return DirectChild == cast<WhileStmt>(
P)->getCond();
186 case Stmt::DoStmtClass:
187 return DirectChild == cast<DoStmt>(
P)->getCond();
188 case Stmt::IfStmtClass:
189 return DirectChild == cast<IfStmt>(
P)->getCond();
190 case Stmt::IndirectGotoStmtClass:
191 return DirectChild == cast<IndirectGotoStmt>(
P)->getTarget();
192 case Stmt::SwitchStmtClass:
193 return DirectChild == cast<SwitchStmt>(
P)->getCond();
194 case Stmt::ReturnStmtClass:
Expr * getSyntacticForm()
Expr *const * semantics_iterator
llvm::DenseMap< Stmt *, Stmt * > MapTy
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value...
Defines the clang::Expr interface and subclasses for C++ expressions.
void addStmt(Stmt *S)
Adds and/or updates the parent/child-relations of the complete stmt tree of S. All children of S incl...
void setParent(const Stmt *S, const Stmt *Parent)
semantics_iterator semantics_end()
A builtin binary operation expression such as "x + y" or "x <= y".
static void BuildParentMap(MapTy &M, Stmt *S, OpaqueValueMode OVMode=OV_Transparent)
bool isConsumedExpr(Expr *E) const
Stmt * getParent(Stmt *) const
Expr * getSourceExpr() const
Stmt * getParentIgnoreParens(Stmt *) const
Stmt * getOuterParenParent(Stmt *) const
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition. The opaque value will...
semantics_iterator semantics_begin()
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Stmt * getParentIgnoreParenImpCasts(Stmt *) const
Stmt * getParentIgnoreParenCasts(Stmt *) const
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...