]> granicus.if.org Git - clang/commit
[analyzer] Invalidate placement args; return the pointer given to placement new
authorJordan Rose <jordan_rose@apple.com>
Wed, 20 Jun 2012 01:32:01 +0000 (01:32 +0000)
committerJordan Rose <jordan_rose@apple.com>
Wed, 20 Jun 2012 01:32:01 +0000 (01:32 +0000)
commite38c1c2c449529e60f48e740cb8662e68e5a5330
tree4e02ad04c81676317213b6d336dad1d1ad036483
parent8b9fcd7cd1f92e67655899d00fbaeb125c5a0d88
[analyzer] Invalidate placement args; return the pointer given to placement new

The default global placement new just returns the pointer it is given.
Note that other custom 'new' implementations with placement args are not
guaranteed to do this.

In addition, we need to invalidate placement args, since they may be updated by
the allocator function. (Also, right now we don't properly handle the
constructor inside a CXXNewExpr, so we need to invalidate the placement args
just so that callers know something changed!)

This invalidation is not perfect because CallOrObjCMessage doesn't support
CXXNewExpr, and all of our invalidation callbacks expect that if there's no
CallOrObjCMessage, the invalidation is happening manually (e.g. by a direct
assignment) and shouldn't affect checker-specific metadata (like malloc state);
hence the malloc test case in new-fail.cpp. But region values are now
properly invalidated, at least.

The long-term solution to this problem is to rework CallOrObjCMessage into
something more general, rather than the morass of branches it is today.

<rdar://problem/11679031>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158784 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
test/Analysis/new-fail.cpp [new file with mode: 0644]
test/Analysis/new.cpp