r186140 - [analyzer] Add support for __builtin_addressof.
Jordan Rose
jordan_rose at apple.com
Thu Jul 11 17:26:14 PDT 2013
Author: jrose
Date: Thu Jul 11 19:26:14 2013
New Revision: 186140
URL: http://llvm.org/viewvc/llvm-project?rev=186140&view=rev
Log:
[analyzer] Add support for __builtin_addressof.
...so we don't regress on std::addressof.
Added:
cfe/trunk/test/Analysis/builtin-functions.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp?rev=186140&r1=186139&r2=186140&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp Thu Jul 11 19:26:14 2013
@@ -43,8 +43,11 @@ bool BuiltinFunctionChecker::evalCall(co
return false;
switch (id) {
- case Builtin::BI__builtin_expect: {
+ case Builtin::BI__builtin_expect:
+ case Builtin::BI__builtin_addressof: {
// For __builtin_expect, just return the value of the subexpression.
+ // __builtin_addressof is going from a reference to a pointer, but those
+ // are represented the same way in the analyzer.
assert (CE->arg_begin() != CE->arg_end());
SVal X = state->getSVal(*(CE->arg_begin()), LCtx);
C.addTransition(state->BindExpr(CE, LCtx, X));
Added: cfe/trunk/test/Analysis/builtin-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/builtin-functions.cpp?rev=186140&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/builtin-functions.cpp (added)
+++ cfe/trunk/test/Analysis/builtin-functions.cpp Thu Jul 11 19:26:14 2013
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection %s -std=c++11 -verify
+
+void clang_analyzer_eval(bool);
+
+void test(int x) {
+ clang_analyzer_eval(&x == __builtin_addressof(x)); // expected-warning{{TRUE}}
+}
More information about the cfe-commits
mailing list