[cfe-commits] r47040 - in /cfe/trunk: AST/Expr.cpp Sema/SemaChecking.cpp Sema/SemaUtil.h include/clang/AST/Expr.h
Chris Lattner
sabre at nondot.org
Tue Feb 12 17:02:39 PST 2008
Author: lattner
Date: Tue Feb 12 19:02:39 2008
New Revision: 47040
URL: http://llvm.org/viewvc/llvm-project?rev=47040&view=rev
Log:
Move IgnoreParenCasts to be a method on Expr.
Modified:
cfe/trunk/AST/Expr.cpp
cfe/trunk/Sema/SemaChecking.cpp
cfe/trunk/Sema/SemaUtil.h
cfe/trunk/include/clang/AST/Expr.h
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=47040&r1=47039&r2=47040&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Tue Feb 12 19:02:39 2008
@@ -474,6 +474,23 @@
return E;
}
+/// IgnoreParenCasts - Ignore parentheses and casts. Strip off any ParenExpr
+/// or CastExprs or ImplicitCastExprs, returning their operand.
+Expr *Expr::IgnoreParenCasts() {
+ Expr *E = this;
+ while (true) {
+ if (ParenExpr *P = dyn_cast<ParenExpr>(E))
+ E = P->getSubExpr();
+ else if (CastExpr *P = dyn_cast<CastExpr>(E))
+ E = P->getSubExpr();
+ else if (ImplicitCastExpr *P = dyn_cast<ImplicitCastExpr>(E))
+ E = P->getSubExpr();
+ else
+ return E;
+ }
+}
+
+
bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const {
switch (getStmtClass()) {
default:
Modified: cfe/trunk/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaChecking.cpp?rev=47040&r1=47039&r2=47040&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/Sema/SemaChecking.cpp Tue Feb 12 19:02:39 2008
@@ -88,7 +88,7 @@
/// CheckBuiltinCFStringArgument - Checks that the argument to the builtin
/// CFString constructor is correct
bool Sema::CheckBuiltinCFStringArgument(Expr* Arg) {
- Arg = IgnoreParenCasts(Arg);
+ Arg = Arg->IgnoreParenCasts();
StringLiteral *Literal = dyn_cast<StringLiteral>(Arg);
@@ -267,7 +267,7 @@
return;
}
- Expr *OrigFormatExpr = IgnoreParenCasts(TheCall->getArg(format_idx));
+ Expr *OrigFormatExpr = TheCall->getArg(format_idx)->IgnoreParenCasts();
// CHECK: format string is not a string literal.
//
@@ -527,7 +527,7 @@
void
Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
SourceLocation ReturnLoc) {
-
+
// Perform checking for returned stack addresses.
if (lhsType->isPointerType()) {
if (DeclRefExpr *DR = EvalAddr(RetValExp))
Modified: cfe/trunk/Sema/SemaUtil.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaUtil.h?rev=47040&r1=47039&r2=47040&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaUtil.h (original)
+++ cfe/trunk/Sema/SemaUtil.h Tue Feb 12 19:02:39 2008
@@ -19,23 +19,9 @@
namespace clang {
-/// Utility method to plow through parenthesis and casts.
-static inline Expr* IgnoreParenCasts(Expr* E) {
- while(true) {
- if (ParenExpr* P = dyn_cast<ParenExpr>(E))
- E = P->getSubExpr();
- else if (CastExpr* P = dyn_cast<CastExpr>(E))
- E = P->getSubExpr();
- else if (ImplicitCastExpr* P = dyn_cast<ImplicitCastExpr>(E))
- E = P->getSubExpr();
- else
- return E;
- }
-}
-
/// Utility method to determine if a CallExpr is a call to a builtin.
static inline bool isCallBuiltin(CallExpr* cexp) {
- Expr* sub = IgnoreParenCasts(cexp->getCallee());
+ Expr* sub = cexp->getCallee()->IgnoreParenCasts();
if (DeclRefExpr* E = dyn_cast<DeclRefExpr>(sub))
if (E->getDecl()->getIdentifier()->getBuiltinID() > 0)
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=47040&r1=47039&r2=47040&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Feb 12 19:02:39 2008
@@ -116,11 +116,18 @@
/// then this method recursively returns its subexpression, and so forth.
/// Otherwise, the method returns the current Expr.
Expr* IgnoreParens();
+
+ /// IgnoreParenCasts - Ignore parentheses and casts. Strip off any ParenExpr
+ /// or CastExprs or ImplicitCastExprs, returning their operand.
+ Expr *IgnoreParenCasts();
const Expr* IgnoreParens() const {
return const_cast<Expr*>(this)->IgnoreParens();
}
-
+ const Expr *IgnoreParenCasts() const {
+ return const_cast<Expr*>(this)->IgnoreParenCasts();
+ }
+
static bool classof(const Stmt *T) {
return T->getStmtClass() >= firstExprConstant &&
T->getStmtClass() <= lastExprConstant;
More information about the cfe-commits
mailing list