r213267 - Handle __assume in the VoidExprEvaluator
Hal Finkel
hfinkel at anl.gov
Thu Jul 17 07:49:58 PDT 2014
Author: hfinkel
Date: Thu Jul 17 09:49:58 2014
New Revision: 213267
URL: http://llvm.org/viewvc/llvm-project?rev=213267&view=rev
Log:
Handle __assume in the VoidExprEvaluator
This is a follow-up to an IRC conversation with Richard last night; __assume
does not evaluate its argument, and so the argument should not contribute to
whether (__assume(e), constant) can be used where a constant is required.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/builtin-assume.c
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=213267&r1=213266&r2=213267&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Jul 17 09:49:58 2014
@@ -7955,6 +7955,16 @@ public:
return true;
}
}
+
+ bool VisitCallExpr(const CallExpr *E) {
+ switch (E->getBuiltinCallee()) {
+ default:
+ return ExprEvaluatorBaseTy::VisitCallExpr(E);
+ case Builtin::BI__assume:
+ // The argument is not evaluated!
+ return true;
+ }
+ }
};
} // end anonymous namespace
Modified: cfe/trunk/test/Sema/builtin-assume.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtin-assume.c?rev=213267&r1=213266&r2=213267&view=diff
==============================================================================
--- cfe/trunk/test/Sema/builtin-assume.c (original)
+++ cfe/trunk/test/Sema/builtin-assume.c Thu Jul 17 09:49:58 2014
@@ -3,6 +3,9 @@
int foo(int *a, int i) {
__assume(i != 4);
__assume(++i > 2); //expected-warning {{the argument to __assume has side effects that will be discarded}}
+
+ int test = sizeof(struct{char qq[(__assume(i != 5), 7)];});
+
return a[i];
}
More information about the cfe-commits
mailing list