]> granicus.if.org Git - clang/commit
[analyzer] Invalidate regions indirectly accessible through const pointers.
authorJordan Rose <jordan_rose@apple.com>
Wed, 20 Mar 2013 20:35:53 +0000 (20:35 +0000)
committerJordan Rose <jordan_rose@apple.com>
Wed, 20 Mar 2013 20:35:53 +0000 (20:35 +0000)
commitf8ddc098981d4d85cad4e72fc6dfcfe83b842b66
treef03f97abd1fd285147db499e1c4379d961cdc49a
parente1a2e90876cbe2187250939374d26036ccba2ad6
[analyzer] Invalidate regions indirectly accessible through const pointers.

In this case, the value of 'x' may be changed after the call to indirectAccess:

  struct Wrapper {
    int *ptr;
  };

  void indirectAccess(const Wrapper &w);

  void test() {
    int x = 42;
    Wrapper w = { x };

    clang_analyzer_eval(x == 42); // TRUE
    indirectAccess(w);
    clang_analyzer_eval(x == 42); // UNKNOWN
  }

This is important for modelling return-by-value objects in C++, to show
that the contents of the struct are escaping in the return copy-constructor.

<rdar://problem/13239826>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177570 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
lib/StaticAnalyzer/Core/CallEvent.cpp
lib/StaticAnalyzer/Core/ProgramState.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/call-invalidation.cpp [new file with mode: 0644]