diff options
author | dim <dim@FreeBSD.org> | 2013-06-10 20:45:12 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-06-10 20:45:12 +0000 |
commit | ea266cad53e3d49771fa38103913d3ec7a166694 (patch) | |
tree | 8f7776b7310bebaf415ac5b69e46e9f928c37144 /test/Analysis/stack-addr-ps.cpp | |
parent | c72c57c9e9b69944e3e009cd5e209634839581d3 (diff) | |
download | FreeBSD-src-ea266cad53e3d49771fa38103913d3ec7a166694.zip FreeBSD-src-ea266cad53e3d49771fa38103913d3ec7a166694.tar.gz |
Vendor import of clang tags/RELEASE_33/final r183502 (effectively, 3.3
release):
http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_33/final@183502
Diffstat (limited to 'test/Analysis/stack-addr-ps.cpp')
-rw-r--r-- | test/Analysis/stack-addr-ps.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/test/Analysis/stack-addr-ps.cpp b/test/Analysis/stack-addr-ps.cpp index 7aefea5..65d7571 100644 --- a/test/Analysis/stack-addr-ps.cpp +++ b/test/Analysis/stack-addr-ps.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s -// FIXME: Only the stack-address checking in Sema catches this right now, and -// the stack analyzer doesn't handle the ImplicitCastExpr (lvalue). +typedef __INTPTR_TYPE__ intptr_t; + const int& g() { int s; return s; // expected-warning{{Address of stack memory associated with local variable 's' returned}} expected-warning{{reference to stack memory associated with local variable 's' returned}} @@ -96,3 +96,40 @@ void *radar13226577() { return p; // expected-warning {{stack memory associated with local variable 'p' returned to caller}} } +namespace rdar13296133 { + class ConvertsToBool { + public: + operator bool() const { return this; } + }; + + class ConvertsToIntptr { + public: + operator intptr_t() const { return reinterpret_cast<intptr_t>(this); } + }; + + class ConvertsToPointer { + public: + operator const void *() const { return this; } + }; + + intptr_t returnAsNonLoc() { + ConvertsToIntptr obj; + return obj; // expected-warning{{Address of stack memory associated with local variable 'obj' returned to caller}} + } + + bool returnAsBool() { + ConvertsToBool obj; + return obj; // no-warning + } + + intptr_t returnAsNonLocViaPointer() { + ConvertsToPointer obj; + return reinterpret_cast<intptr_t>(static_cast<const void *>(obj)); // expected-warning{{Address of stack memory associated with local variable 'obj' returned to caller}} + } + + bool returnAsBoolViaPointer() { + ConvertsToPointer obj; + return obj; // no-warning + } +} + |