[analyzer]Skip unstable CSA tests failing on several platforms

Clang static analyzer uses bitwidth to infer the integer value type, that is, any 32-bit integer is considered of type `int`, and any 64-bit integer is considered of type `long`. This isn't always true, for instance, in ILP32 (e.g., 32-bit AIX), 32-bit could be `long`, and in LP64 (e.g., 64-bit wasm64), 64-bit could be `long long`.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D114454
This commit is contained in:
Steven Wan 2021-12-02 18:29:43 -05:00
parent 885fb9a257
commit 9c4d194f44
2 changed files with 52 additions and 1 deletions

View File

@ -31,5 +31,6 @@ clang_target_link_libraries(StaticAnalysisTests
clangSerialization
clangStaticAnalyzerCore
clangStaticAnalyzerFrontend
clangTesting
clangTooling
)

View File

@ -21,6 +21,7 @@
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
#include "clang/Testing/TestClangConfig.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
@ -91,6 +92,21 @@ private:
mutable SVals CollectedSVals;
};
// Fixture class for parameterized SValTest
class SValTest : public testing::TestWithParam<TestClangConfig> {
protected:
// FIXME: The tests "GetConstType" and "GetLocAsIntType" infer the type of
// integrals based on their bitwidth. This is not a reliable method on
// platforms where different integrals have the same width.
bool skipTest(StringRef TestName) {
std::string target = GetParam().Target;
return (target == "powerpc-ibm-aix" || target == "i686-apple-darwin9" ||
target == "wasm32-unknown-unknown" ||
target == "wasm64-unknown-unknown") &&
(TestName == "GetConstType" || TestName == "GetLocAsIntType");
}
};
// SVAL_TEST is a combined way of providing a short code snippet and
// to test some programmatic predicates on symbolic values produced by the
// engine for the actual code.
@ -135,7 +151,16 @@ private:
}); \
} \
\
TEST(SValTest, NAME) { runCheckerOnCode<add##NAME##SValCollector>(CODE); } \
TEST_P(SValTest, NAME) { \
if (skipTest(#NAME)) { \
std::string target = GetParam().Target; \
GTEST_SKIP() << "certain integrals have the same bitwidth on " \
<< target; \
return; \
} \
runCheckerOnCodeWithArgs<add##NAME##SValCollector>( \
CODE, GetParam().getCommandLineArgs()); \
} \
void NAME##SValCollector::test(ExprEngine &Engine, \
const ASTContext &Context) const
@ -361,6 +386,31 @@ void foo() {
EXPECT_EQ(Context.VoidPtrTy, B.getType(Context));
}
std::vector<TestClangConfig> allTestClangConfigs() {
std::vector<TestClangConfig> all_configs;
TestClangConfig config;
config.Language = Lang_CXX14;
for (std::string target :
{"i686-pc-windows-msvc", "i686-apple-darwin9",
"x86_64-apple-darwin9", "x86_64-scei-ps4",
"x86_64-windows-msvc", "x86_64-unknown-linux",
"x86_64-apple-macosx", "x86_64-apple-ios14.0",
"wasm32-unknown-unknown", "wasm64-unknown-unknown",
"thumb-pc-win32", "sparc64-none-openbsd",
"sparc-none-none", "riscv64-unknown-linux",
"ppc64-windows-msvc", "powerpc-ibm-aix",
"powerpc64-ibm-aix", "s390x-ibm-zos",
"armv7-pc-windows-msvc", "aarch64-pc-windows-msvc",
"xcore-xmos-elf"}) {
config.Target = target;
all_configs.push_back(config);
}
return all_configs;
}
INSTANTIATE_TEST_SUITE_P(SValTests, SValTest,
testing::ValuesIn(allTestClangConfigs()));
} // namespace
} // namespace ento
} // namespace clang