[cfe-commits] r127794 - in /cfe/trunk: lib/Analysis/UninitializedValues.cpp test/Sema/uninit-variables-vectors.c
Ted Kremenek
kremenek at apple.com
Wed Mar 16 20:06:11 PDT 2011
Author: kremenek
Date: Wed Mar 16 22:06:11 2011
New Revision: 127794
URL: http://llvm.org/viewvc/llvm-project?rev=127794&view=rev
Log:
Extend -Wuninitialized to support vector types.
Added:
cfe/trunk/test/Sema/uninit-variables-vectors.c
Modified:
cfe/trunk/lib/Analysis/UninitializedValues.cpp
Modified: cfe/trunk/lib/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UninitializedValues.cpp?rev=127794&r1=127793&r2=127794&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/lib/Analysis/UninitializedValues.cpp Wed Mar 16 22:06:11 2011
@@ -26,9 +26,12 @@
using namespace clang;
static bool isTrackedVar(const VarDecl *vd, const DeclContext *dc) {
- return vd->isLocalVarDecl() && !vd->hasGlobalStorage() &&
- vd->getType()->isScalarType() &&
- vd->getDeclContext() == dc;
+ if (vd->isLocalVarDecl() && !vd->hasGlobalStorage() &&
+ vd->getDeclContext() == dc) {
+ QualType ty = vd->getType();
+ return ty->isScalarType() || ty->isVectorType();
+ }
+ return false;
}
//------------------------------------------------------------------------====//
Added: cfe/trunk/test/Sema/uninit-variables-vectors.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/uninit-variables-vectors.c?rev=127794&view=auto
==============================================================================
--- cfe/trunk/test/Sema/uninit-variables-vectors.c (added)
+++ cfe/trunk/test/Sema/uninit-variables-vectors.c Wed Mar 16 22:06:11 2011
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only %s -verify
+
+#include <xmmintrin.h>
+
+void test1(float *input) {
+ __m128 x, y, z, w, X; // expected-note {{variable 'x' is declared here}} expected-note {{variable 'y' is declared here}} expected-note {{variable 'w' is declared here}} expected-note {{variable 'z' is declared here}}
+ x = _mm_xor_ps(x,x); // expected-warning {{variable 'x' is possibly uninitialized when used here}}
+ y = _mm_xor_ps(y,y); // expected-warning {{variable 'y' is possibly uninitialized when used here}}
+ z = _mm_xor_ps(z,z); // expected-warning {{variable 'z' is possibly uninitialized when used here}}
+ w = _mm_xor_ps(w,w); // expected-warning {{variable 'w' is possibly uninitialized when used here}}
+ X = _mm_loadu_ps(&input[0]);
+ X = _mm_xor_ps(X,X); // no-warning
+}
+
More information about the cfe-commits
mailing list