This revision was automatically updated to reflect the committed changes. Closed by commit rC326952: [analyzer] [PointerArithChecker] do not warn on indexes into vector types (authored by george.karpenkov, committed by ). Herald added a subscriber: cfe-commits.
Repository: rC Clang https://reviews.llvm.org/D44172 Files: lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp test/Analysis/ptr-arith.c Index: lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp +++ lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp @@ -308,6 +308,10 @@ // Indexing with 0 is OK. if (Idx.isZeroConstant()) return; + + // Indexing vector-type expressions is also OK. + if (SubsExpr->getBase()->getType()->isVectorType()) + return; reportPointerArithMisuse(SubsExpr->getBase(), C); } Index: test/Analysis/ptr-arith.c =================================================================== --- test/Analysis/ptr-arith.c +++ test/Analysis/ptr-arith.c @@ -347,3 +347,9 @@ a[0] = 0; label:; } + +typedef __attribute__((__ext_vector_type__(2))) float simd_float2; +float test_nowarning_on_vector_deref() { + simd_float2 x = {0, 1}; + return x[1]; // no-warning +}
Index: lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp +++ lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp @@ -308,6 +308,10 @@ // Indexing with 0 is OK. if (Idx.isZeroConstant()) return; + + // Indexing vector-type expressions is also OK. + if (SubsExpr->getBase()->getType()->isVectorType()) + return; reportPointerArithMisuse(SubsExpr->getBase(), C); } Index: test/Analysis/ptr-arith.c =================================================================== --- test/Analysis/ptr-arith.c +++ test/Analysis/ptr-arith.c @@ -347,3 +347,9 @@ a[0] = 0; label:; } + +typedef __attribute__((__ext_vector_type__(2))) float simd_float2; +float test_nowarning_on_vector_deref() { + simd_float2 x = {0, 1}; + return x[1]; // no-warning +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits