[cfe-commits] r77361 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/uninit-vals-ps.c
Ted Kremenek
kremenek at apple.com
Tue Jul 28 13:46:55 PDT 2009
Author: kremenek
Date: Tue Jul 28 15:46:55 2009
New Revision: 77361
URL: http://llvm.org/viewvc/llvm-project?rev=77361&view=rev
Log:
Fix PR 4631. The compound initializers of unions were not being evaluated, which
could cause false positives if any the subexpressions had side-effects. These
initializers weren't evaluated because the StoreManager would need to handle
them, but that's an orthogonal problem of whether or not the StoreManager can
handle the binding.
Modified:
cfe/trunk/lib/Analysis/GRExprEngine.cpp
cfe/trunk/test/Analysis/uninit-vals-ps.c
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=77361&r1=77360&r2=77361&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Tue Jul 28 15:46:55 2009
@@ -2228,7 +2228,8 @@
QualType T = getContext().getCanonicalType(E->getType());
unsigned NumInitElements = E->getNumInits();
- if (T->isArrayType() || T->isStructureType()) {
+ if (T->isArrayType() || T->isStructureType() ||
+ T->isUnionType() || T->isVectorType()) {
llvm::ImmutableList<SVal> StartVals = getBasicVals().getEmptySValList();
@@ -2283,13 +2284,6 @@
return;
}
- if (T->isUnionType() || T->isVectorType()) {
- // FIXME: to be implemented.
- // Note: That vectors can return true for T->isIntegerType()
- MakeNode(Dst, E, Pred, state);
- return;
- }
-
if (Loc::IsLocType(T) || T->isIntegerType()) {
assert (E->getNumInits() == 1);
NodeSet Tmp;
Modified: cfe/trunk/test/Analysis/uninit-vals-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals-ps.c?rev=77361&r1=77360&r2=77361&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/uninit-vals-ps.c (original)
+++ cfe/trunk/test/Analysis/uninit-vals-ps.c Tue Jul 28 15:46:55 2009
@@ -102,3 +102,25 @@
}
}
+// PR 4631 - False positive with union initializer
+// Previously the analyzer didn't examine the compound initializers of unions,
+// resulting in some false positives for initializers with side-effects.
+union u_4631 { int a; };
+struct s_4631 { int a; };
+int pr4631_f2(int *p);
+int pr4631_f3(void *q);
+int pr4631_f1(void)
+{
+ int x;
+ union u_4631 m = { pr4631_f2(&x) };
+ pr4631_f3(&m); // tell analyzer that we use m
+ return x; // no-warning
+}
+int pr4631_f1_b(void)
+{
+ int x;
+ struct s_4631 m = { pr4631_f2(&x) };
+ pr4631_f3(&m); // tell analyzer that we use m
+ return x; // no-warning
+}
+
More information about the cfe-commits
mailing list