]> granicus.if.org Git - clang/commit
[analyzer] Check for returning null references in ReturnUndefChecker.
authorJordan Rose <jordan_rose@apple.com>
Thu, 7 Mar 2013 01:23:25 +0000 (01:23 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 7 Mar 2013 01:23:25 +0000 (01:23 +0000)
commitc236b7327f989c1e7fe6b08a188bfef86727513d
tree719d2044a91b2612bd4f760f6b53b3f638dedaed
parent962fbc46664f2486d6805549130fa6b310de6d60
[analyzer] Check for returning null references in ReturnUndefChecker.

Officially in the C++ standard, a null reference cannot exist. However,
it's still very easy to create one:

int &getNullRef() {
  int *p = 0;
  return *p;
}

We already check that binds to reference regions don't create null references.
This patch checks that we don't create null references by returning, either.

<rdar://problem/13364378>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176601 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
test/Analysis/inlining/false-positive-suppression.cpp
test/Analysis/inlining/path-notes.cpp
test/Analysis/reference.cpp