diff options
author | Anna Zaks <ganna@apple.com> | 2014-06-27 01:03:05 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2014-06-27 01:03:05 +0000 |
commit | a3911af74fa0314c5be721397997b422f9cbb07c (patch) | |
tree | cd961b6ae67fefe1d279159176c20cfd66fe9585 /test | |
parent | 20eceba4ac8acf7f30675294df58d5c5e236419a (diff) | |
download | clang-a3911af74fa0314c5be721397997b422f9cbb07c.tar.gz clang-a3911af74fa0314c5be721397997b422f9cbb07c.tar.bz2 clang-a3911af74fa0314c5be721397997b422f9cbb07c.tar.xz |
Do not inline methods of C++ containers (coming from headers).
This silences false positives (leaks, use of uninitialized value) in simple
code that uses containers such as std::vector and std::list. The analyzer
cannot reason about the internal invariances of those data structures which
leads to false positives. Until we come up with a better solution to that
problem, let's just not inline the methods of the containers and allow objects
to escape whenever such methods are called.
This just extends an already existing flag "c++-container-inlining" and applies
the heuristic not only to constructors and destructors of the containers, but
to all of their methods.
We have a bunch of distinct user reports all related to this issue
(radar://16058651, radar://16580751, radar://16384286, radar://16795491
[PR19637]).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211832 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Analysis/inlining/containers.cpp | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/test/Analysis/inlining/containers.cpp b/test/Analysis/inlining/containers.cpp index 73b2957ad6..c757da66be 100644 --- a/test/Analysis/inlining/containers.cpp +++ b/test/Analysis/inlining/containers.cpp @@ -103,7 +103,10 @@ public: ~MySet() { delete[] storage; } bool isEmpty() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif return size == 0; } @@ -114,23 +117,35 @@ public: }; iterator begin() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif return iterator(storage); } iterator end() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif return iterator(storage+size); } typedef int *raw_iterator; raw_iterator raw_begin() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif return storage; } raw_iterator raw_end() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif return storage + size; } }; @@ -145,7 +160,10 @@ public: } void useIterator(iterator i) { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif } }; @@ -174,7 +192,10 @@ public: typedef IterImpl wrapped_iterator; wrapped_iterator begin() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif return IterImpl(impl.begin()); } }; @@ -193,7 +214,10 @@ public: typedef MySet::iterator iterator; iterator start() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); +#if INLINE + // expected-warning@-2 {{TRUE}} +#endif return impl.begin(); } }; @@ -212,7 +236,10 @@ public: using iterator = MySet::iterator; iterator start() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif return impl.begin(); } }; @@ -233,7 +260,10 @@ public: }; iterator start() { - clang_analyzer_checkInlined(true); // expected-warning {{TRUE}} + clang_analyzer_checkInlined(true); + #if INLINE + // expected-warning@-2 {{TRUE}} + #endif return iterator{impl.begin().impl}; } }; |