diff --git a/clang/unittests/StaticAnalyzer/CMakeLists.txt b/clang/unittests/StaticAnalyzer/CMakeLists.txt --- a/clang/unittests/StaticAnalyzer/CMakeLists.txt +++ b/clang/unittests/StaticAnalyzer/CMakeLists.txt @@ -31,5 +31,6 @@ clangSerialization clangStaticAnalyzerCore clangStaticAnalyzerFrontend + clangTesting clangTooling ) diff --git a/clang/unittests/StaticAnalyzer/SValTest.cpp b/clang/unittests/StaticAnalyzer/SValTest.cpp --- a/clang/unittests/StaticAnalyzer/SValTest.cpp +++ b/clang/unittests/StaticAnalyzer/SValTest.cpp @@ -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,17 @@ mutable SVals CollectedSVals; }; +// Fixture class for parameterized SValTest +class SValTest : public testing::TestWithParam { +protected: + // FIXME: This is a hack to work around the fact that there is no way to + // differentiate int and long on 32-bit AIX solely based on bitwidth. + bool skipOnPPC32AIX(StringRef TestName) { + return GetParam().Target == "powerpc-ibm-aix" && + (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 +147,12 @@ }); \ } \ \ - TEST(SValTest, NAME) { runCheckerOnCode(CODE); } \ + TEST_P(SValTest, NAME) { \ + if (skipOnPPC32AIX(#NAME)) \ + return; \ + runCheckerOnCodeWithArgs( \ + CODE, GetParam().getCommandLineArgs()); \ + } \ void NAME##SValCollector::test(ExprEngine &Engine, \ const ASTContext &Context) const @@ -361,6 +378,20 @@ EXPECT_EQ(Context.VoidPtrTy, B.getType(Context)); } +std::vector allTestClangConfigs() { + std::vector all_configs; + TestClangConfig config; + config.Language = Lang_CXX14; + config.Target = "powerpc-ibm-aix"; + all_configs.push_back(config); + config.Target = "powerpc-ibm-linux"; + all_configs.push_back(config); + return all_configs; +} + +INSTANTIATE_TEST_SUITE_P(SValTests, SValTest, + testing::ValuesIn(allTestClangConfigs())); + } // namespace } // namespace ento } // namespace clang