diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/include/clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h rename from clang/unittests/Analysis/FlowSensitive/TestingSupport.h rename to clang/include/clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h --- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h +++ b/clang/include/clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h @@ -1,4 +1,4 @@ -//===--- TestingSupport.h - Testing utils for dataflow analyses -*- C++ -*-===// +//===--- DataflowAnalysis.h - Testing utils for dataflow analyses * C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_ANALYSIS_FLOW_SENSITIVE_TESTING_SUPPORT_H_ -#define LLVM_CLANG_ANALYSIS_FLOW_SENSITIVE_TESTING_SUPPORT_H_ +#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TESTING_DATAFLOWANALYSIS_H +#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TESTING_DATAFLOWANALYSIS_H #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" @@ -179,4 +179,4 @@ } // namespace dataflow } // namespace clang -#endif // LLVM_CLANG_ANALYSIS_FLOW_SENSITIVE_TESTING_SUPPORT_H_ +#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TESTING_DATAFLOWANALYSIS_H diff --git a/clang/unittests/Analysis/FlowSensitive/NoopAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/Testing/NoopAnalysis.h rename from clang/unittests/Analysis/FlowSensitive/NoopAnalysis.h rename to clang/include/clang/Analysis/FlowSensitive/Testing/NoopAnalysis.h --- a/clang/unittests/Analysis/FlowSensitive/NoopAnalysis.h +++ b/clang/include/clang/Analysis/FlowSensitive/Testing/NoopAnalysis.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_UNITTESTS_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H -#define LLVM_CLANG_UNITTESTS_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H +#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TESTING_NOOPANALYSIS_H +#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TESTING_NOOPANALYSIS_H #include "clang/AST/ASTContext.h" #include "clang/AST/Stmt.h" @@ -55,4 +55,4 @@ } // namespace dataflow } // namespace clang -#endif // LLVM_CLANG_UNITTESTS_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H +#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_TESTING_NOOPANALYSIS_H diff --git a/clang/lib/Analysis/FlowSensitive/CMakeLists.txt b/clang/lib/Analysis/FlowSensitive/CMakeLists.txt --- a/clang/lib/Analysis/FlowSensitive/CMakeLists.txt +++ b/clang/lib/Analysis/FlowSensitive/CMakeLists.txt @@ -12,3 +12,5 @@ clangAST clangBasic ) + +add_subdirectory(Testing) diff --git a/clang/lib/Analysis/FlowSensitive/Testing/CMakeLists.txt b/clang/lib/Analysis/FlowSensitive/Testing/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/clang/lib/Analysis/FlowSensitive/Testing/CMakeLists.txt @@ -0,0 +1,14 @@ +add_clang_library(clangAnalysisFlowSensitiveTesting + DataflowAnalysis.cpp + + LINK_LIBS + clangAnalysis + clangAnalysisFlowSensitive + clangAST + clangBasic + clangFrontend + clangLex + clangSerialization + clangTesting + clangTooling + ) diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp b/clang/lib/Analysis/FlowSensitive/Testing/DataflowAnalysis.cpp rename from clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp rename to clang/lib/Analysis/FlowSensitive/Testing/DataflowAnalysis.cpp --- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp +++ b/clang/lib/Analysis/FlowSensitive/Testing/DataflowAnalysis.cpp @@ -1,4 +1,16 @@ -#include "TestingSupport.h" +//===-- DataflowAnalysis.cpp ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines utilities to simplify testing of dataflow analyses. +// +//===----------------------------------------------------------------------===// + +#include "clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/Stmt.h" diff --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt --- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt +++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt @@ -11,8 +11,6 @@ MultiVarConstantPropagationTest.cpp SingleVarConstantPropagationTest.cpp SourceLocationsLatticeTest.cpp - TestingSupport.cpp - TestingSupportTest.cpp TransferTest.cpp TypeErasedDataflowAnalysisTest.cpp SolverTest.cpp @@ -22,6 +20,7 @@ PRIVATE clangAnalysis clangAnalysisFlowSensitive + clangAnalysisFlowSensitiveTesting clangAST clangASTMatchers clangBasic @@ -36,3 +35,5 @@ PRIVATE LLVMTestingSupport ) + +add_subdirectory(Testing) diff --git a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" -#include "NoopAnalysis.h" -#include "TestingSupport.h" #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h" +#include "clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h" +#include "clang/Analysis/FlowSensitive/Testing/NoopAnalysis.h" #include "clang/Analysis/FlowSensitive/Value.h" #include "clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h" #include "gmock/gmock.h" diff --git a/clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp b/clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "clang/Analysis/FlowSensitive/MatchSwitch.h" -#include "TestingSupport.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" @@ -24,6 +23,7 @@ #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/DataflowLattice.h" #include "clang/Analysis/FlowSensitive/MapLattice.h" +#include "clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" diff --git a/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp b/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#include "TestingSupport.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" @@ -23,6 +22,7 @@ #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/DataflowLattice.h" #include "clang/Analysis/FlowSensitive/MapLattice.h" +#include "clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" diff --git a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#include "TestingSupport.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" @@ -22,6 +21,7 @@ #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/DataflowLattice.h" +#include "clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" diff --git a/clang/unittests/Analysis/FlowSensitive/Testing/CMakeLists.txt b/clang/unittests/Analysis/FlowSensitive/Testing/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/clang/unittests/Analysis/FlowSensitive/Testing/CMakeLists.txt @@ -0,0 +1,28 @@ +set(LLVM_LINK_COMPONENTS + FrontendOpenMP + Support + ) + +add_clang_unittest(ClangAnalysisFlowSensitiveTestingTests + DataflowCheckerTest.cpp + ) + +clang_target_link_libraries(ClangAnalysisFlowSensitiveTestingTests + PRIVATE + clangAnalysis + clangAnalysisFlowSensitive + clangAnalysisFlowSensitiveTesting + clangAST + clangASTMatchers + clangBasic + clangFrontend + clangLex + clangSerialization + clangTesting + clangTooling + ) + +target_link_libraries(ClangAnalysisFlowSensitiveTestingTests + PRIVATE + LLVMTestingSupport + ) diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp b/clang/unittests/Analysis/FlowSensitive/Testing/DataflowCheckerTest.cpp rename from clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp rename to clang/unittests/Analysis/FlowSensitive/Testing/DataflowCheckerTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/Testing/DataflowCheckerTest.cpp @@ -1,8 +1,16 @@ -#include "TestingSupport.h" -#include "NoopAnalysis.h" +//===- DataflowAnalysisTest.cpp -------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h" +#include "clang/Analysis/FlowSensitive/Testing/NoopAnalysis.h" #include "clang/Tooling/Tooling.h" #include "llvm/Testing/Support/Error.h" #include "gmock/gmock.h" diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#include "NoopAnalysis.h" -#include "TestingSupport.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/StorageLocation.h" +#include "clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h" +#include "clang/Analysis/FlowSensitive/Testing/NoopAnalysis.h" #include "clang/Analysis/FlowSensitive/Value.h" #include "clang/Basic/LangStandard.h" #include "llvm/ADT/ArrayRef.h" diff --git a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp @@ -6,8 +6,6 @@ // //===----------------------------------------------------------------------===// -#include "NoopAnalysis.h" -#include "TestingSupport.h" #include "clang/AST/Decl.h" #include "clang/AST/ExprCXX.h" #include "clang/ASTMatchers/ASTMatchFinder.h" @@ -17,6 +15,8 @@ #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/DataflowLattice.h" +#include "clang/Analysis/FlowSensitive/Testing/DataflowAnalysis.h" +#include "clang/Analysis/FlowSensitive/Testing/NoopAnalysis.h" #include "clang/Analysis/FlowSensitive/Value.h" #include "clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h" #include "clang/Tooling/Tooling.h"