]> granicus.if.org Git - clang/commitdiff
Extend -Wuninitialized to support vector types.
authorTed Kremenek <kremenek@apple.com>
Thu, 17 Mar 2011 03:06:11 +0000 (03:06 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 17 Mar 2011 03:06:11 +0000 (03:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127794 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/UninitializedValues.cpp
test/Sema/uninit-variables-vectors.c [new file with mode: 0644]

index ae0dbf10e89f8e5ca9e10531403e64e2d1dd9728..c2ac6310ba3239804505f20424b4823d16d8fe4c 100644 (file)
 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;
 }
 
 //------------------------------------------------------------------------====//
diff --git a/test/Sema/uninit-variables-vectors.c b/test/Sema/uninit-variables-vectors.c
new file mode 100644 (file)
index 0000000..7197fb6
--- /dev/null
@@ -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
+}
+