stevewan updated this revision to Diff 390795. stevewan added a comment. Herald added a subscriber: mgorny.
Pin target triple before analysis Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114454/new/ https://reviews.llvm.org/D114454 Files: clang/unittests/StaticAnalyzer/CMakeLists.txt clang/unittests/StaticAnalyzer/SValTest.cpp Index: clang/unittests/StaticAnalyzer/SValTest.cpp =================================================================== --- clang/unittests/StaticAnalyzer/SValTest.cpp +++ 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<TestClangConfig> { +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<add##NAME##SValCollector>(CODE); } \ + TEST_P(SValTest, NAME) { \ + if (skipOnPPC32AIX(#NAME)) \ + return; \ + runCheckerOnCodeWithArgs<add##NAME##SValCollector>( \ + 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<TestClangConfig> allTestClangConfigs() { + std::vector<TestClangConfig> 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 Index: clang/unittests/StaticAnalyzer/CMakeLists.txt =================================================================== --- clang/unittests/StaticAnalyzer/CMakeLists.txt +++ clang/unittests/StaticAnalyzer/CMakeLists.txt @@ -31,5 +31,6 @@ clangSerialization clangStaticAnalyzerCore clangStaticAnalyzerFrontend + clangTesting clangTooling )
Index: clang/unittests/StaticAnalyzer/SValTest.cpp =================================================================== --- clang/unittests/StaticAnalyzer/SValTest.cpp +++ 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<TestClangConfig> { +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<add##NAME##SValCollector>(CODE); } \ + TEST_P(SValTest, NAME) { \ + if (skipOnPPC32AIX(#NAME)) \ + return; \ + runCheckerOnCodeWithArgs<add##NAME##SValCollector>( \ + 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<TestClangConfig> allTestClangConfigs() { + std::vector<TestClangConfig> 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 Index: clang/unittests/StaticAnalyzer/CMakeLists.txt =================================================================== --- clang/unittests/StaticAnalyzer/CMakeLists.txt +++ clang/unittests/StaticAnalyzer/CMakeLists.txt @@ -31,5 +31,6 @@ clangSerialization clangStaticAnalyzerCore clangStaticAnalyzerFrontend + clangTesting clangTooling )
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits