stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

CSA uses bitwidth to infer the integer value type. In the ILP32 model, for 
example 32-bit AIX, any 32-bit integer type will be
considerred as `int`, which isn't always true. In these particular failed 
tests, CSA thinks the pointers should be `int`, while in fact they are long on 
AIX.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114454

Files:
  clang/unittests/StaticAnalyzer/SValTest.cpp


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===================================================================
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -143,11 +143,19 @@
 //                                 Actual tests
 
//===----------------------------------------------------------------------===//
 
+#ifdef _AIX
+SVAL_TEST(DISABLED_GetConstType, R"(
+void foo() {
+  int x = 42;
+  int *y = nullptr;
+})") {
+#else
 SVAL_TEST(GetConstType, R"(
 void foo() {
   int x = 42;
   int *y = nullptr;
 })") {
+#endif
   SVal X = getByName("x");
   ASSERT_FALSE(X.getType(Context).isNull());
   EXPECT_EQ(Context.IntTy, X.getType(Context));
@@ -157,12 +165,21 @@
   EXPECT_EQ(Context.getUIntPtrType(), Y.getType(Context));
 }
 
+#ifdef _AIX
+SVAL_TEST(DISABLED_GetLocAsIntType, R"(
+void foo(int *x) {
+  long int a = (long int)x;
+  unsigned b = (long unsigned)&a;
+  int c = (long int)nullptr;
+})") {
+#else
 SVAL_TEST(GetLocAsIntType, R"(
 void foo(int *x) {
   long int a = (long int)x;
   unsigned b = (long unsigned)&a;
   int c = (long int)nullptr;
 })") {
+#endif
   SVal A = getByName("a");
   ASSERT_FALSE(A.getType(Context).isNull());
   // TODO: Turn it into signed long


Index: clang/unittests/StaticAnalyzer/SValTest.cpp
===================================================================
--- clang/unittests/StaticAnalyzer/SValTest.cpp
+++ clang/unittests/StaticAnalyzer/SValTest.cpp
@@ -143,11 +143,19 @@
 //                                 Actual tests
 //===----------------------------------------------------------------------===//
 
+#ifdef _AIX
+SVAL_TEST(DISABLED_GetConstType, R"(
+void foo() {
+  int x = 42;
+  int *y = nullptr;
+})") {
+#else
 SVAL_TEST(GetConstType, R"(
 void foo() {
   int x = 42;
   int *y = nullptr;
 })") {
+#endif
   SVal X = getByName("x");
   ASSERT_FALSE(X.getType(Context).isNull());
   EXPECT_EQ(Context.IntTy, X.getType(Context));
@@ -157,12 +165,21 @@
   EXPECT_EQ(Context.getUIntPtrType(), Y.getType(Context));
 }
 
+#ifdef _AIX
+SVAL_TEST(DISABLED_GetLocAsIntType, R"(
+void foo(int *x) {
+  long int a = (long int)x;
+  unsigned b = (long unsigned)&a;
+  int c = (long int)nullptr;
+})") {
+#else
 SVAL_TEST(GetLocAsIntType, R"(
 void foo(int *x) {
   long int a = (long int)x;
   unsigned b = (long unsigned)&a;
   int c = (long int)nullptr;
 })") {
+#endif
   SVal A = getByName("a");
   ASSERT_FALSE(A.getType(Context).isNull());
   // TODO: Turn it into signed long
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to