diff --git a/clang/docs/tools/clang-formatted-files.txt b/clang/docs/tools/clang-formatted-files.txt index 40d95411c3a0a6..5e1c6f130a0e47 100644 --- a/clang/docs/tools/clang-formatted-files.txt +++ b/clang/docs/tools/clang-formatted-files.txt @@ -133,7 +133,6 @@ clang/include/clang/Analysis/FlowSensitive/MapLattice.h clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h clang/include/clang/Analysis/FlowSensitive/NoopLattice.h clang/include/clang/Analysis/FlowSensitive/Solver.h -clang/include/clang/Analysis/FlowSensitive/SourceLocationsLattice.h clang/include/clang/Analysis/FlowSensitive/StorageLocation.h clang/include/clang/Analysis/FlowSensitive/Transfer.h clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h @@ -310,7 +309,6 @@ clang/lib/Analysis/CodeInjector.cpp clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp -clang/lib/Analysis/FlowSensitive/SourceLocationsLattice.cpp clang/lib/Analysis/FlowSensitive/Transfer.cpp clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp @@ -637,7 +635,6 @@ clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp clang/unittests/Analysis/FlowSensitive/NoopAnalysis.h clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp clang/unittests/Analysis/FlowSensitive/SolverTest.cpp -clang/unittests/Analysis/FlowSensitive/SourceLocationsLatticeTest.cpp clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp clang/unittests/Analysis/FlowSensitive/TestingSupport.h clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp diff --git a/clang/include/clang/Analysis/FlowSensitive/SourceLocationsLattice.h b/clang/include/clang/Analysis/FlowSensitive/SourceLocationsLattice.h deleted file mode 100644 index d294f9768cdc56..00000000000000 --- a/clang/include/clang/Analysis/FlowSensitive/SourceLocationsLattice.h +++ /dev/null @@ -1,65 +0,0 @@ -//===-- SourceLocationsLattice.h --------------------------------*- 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 a lattice that collects source locations of interest. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SOURCELOCATIONS_LATTICE_H -#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SOURCELOCATIONS_LATTICE_H - -#include "clang/AST/ASTContext.h" -#include "clang/Analysis/FlowSensitive/DataflowLattice.h" -#include "clang/Basic/SourceLocation.h" -#include "llvm/ADT/DenseSet.h" -#include -#include - -namespace clang { -namespace dataflow { - -/// Lattice for dataflow analysis that keeps track of a set of source locations. -/// -/// Bottom is the empty set, join is set union, and equality is set equality. -/// -/// FIXME: Generalize into a (templated) PowerSetLattice. -class SourceLocationsLattice { -public: - SourceLocationsLattice() = default; - - explicit SourceLocationsLattice(llvm::DenseSet Locs) - : Locs(std::move(Locs)) {} - - bool operator==(const SourceLocationsLattice &Other) const { - return Locs == Other.Locs; - } - - bool operator!=(const SourceLocationsLattice &Other) const { - return !(*this == Other); - } - - LatticeJoinEffect join(const SourceLocationsLattice &Other); - - llvm::DenseSet &getSourceLocations() { return Locs; } - - const llvm::DenseSet &getSourceLocations() const { - return Locs; - } - -private: - llvm::DenseSet Locs; -}; - -/// Returns a string that represents the source locations of the lattice. -std::string DebugString(const SourceLocationsLattice &Lattice, - const ASTContext &Context); - -} // namespace dataflow -} // namespace clang - -#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SOURCELOCATIONS_LATTICE_H diff --git a/clang/lib/Analysis/FlowSensitive/CMakeLists.txt b/clang/lib/Analysis/FlowSensitive/CMakeLists.txt index 4a8c63b3db21e9..672b6e83ee44ba 100644 --- a/clang/lib/Analysis/FlowSensitive/CMakeLists.txt +++ b/clang/lib/Analysis/FlowSensitive/CMakeLists.txt @@ -2,7 +2,6 @@ add_clang_library(clangAnalysisFlowSensitive ControlFlowContext.cpp DataflowAnalysisContext.cpp DataflowEnvironment.cpp - SourceLocationsLattice.cpp Transfer.cpp TypeErasedDataflowAnalysis.cpp WatchedLiteralsSolver.cpp diff --git a/clang/lib/Analysis/FlowSensitive/SourceLocationsLattice.cpp b/clang/lib/Analysis/FlowSensitive/SourceLocationsLattice.cpp deleted file mode 100644 index 9e280f4e634a16..00000000000000 --- a/clang/lib/Analysis/FlowSensitive/SourceLocationsLattice.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===- SourceLocationsLattice.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 -// -//===----------------------------------------------------------------------===// -// -// This file implements a lattice that collects source locations of interest. -// -//===----------------------------------------------------------------------===// - -#include "clang/Analysis/FlowSensitive/SourceLocationsLattice.h" -#include "clang/AST/ASTContext.h" -#include "clang/Analysis/FlowSensitive/DataflowLattice.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/Support/raw_ostream.h" -#include -#include -#include - -namespace clang { -namespace dataflow { - -LatticeJoinEffect -SourceLocationsLattice::join(const SourceLocationsLattice &Other) { - auto SizeBefore = Locs.size(); - Locs.insert(Other.Locs.begin(), Other.Locs.end()); - return SizeBefore == Locs.size() ? LatticeJoinEffect::Unchanged - : LatticeJoinEffect::Changed; -} - -std::string DebugString(const SourceLocationsLattice &Lattice, - const ASTContext &Context) { - if (Lattice.getSourceLocations().empty()) - return ""; - - std::vector Locations; - Locations.reserve(Lattice.getSourceLocations().size()); - for (const clang::SourceLocation &Loc : Lattice.getSourceLocations()) { - Locations.push_back(Loc.printToString(Context.getSourceManager())); - } - std::sort(Locations.begin(), Locations.end()); - std::string result; - llvm::raw_string_ostream OS(result); - llvm::interleaveComma(Locations, OS); - return result; -} - -} // namespace dataflow -} // namespace clang diff --git a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt index e908c7d2747c73..c4d83dc32f8f53 100644 --- a/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt +++ b/clang/unittests/Analysis/FlowSensitive/CMakeLists.txt @@ -11,7 +11,6 @@ add_clang_unittest(ClangAnalysisFlowSensitiveTests MatchSwitchTest.cpp MultiVarConstantPropagationTest.cpp SingleVarConstantPropagationTest.cpp - SourceLocationsLatticeTest.cpp TestingSupport.cpp TestingSupportTest.cpp TransferTest.cpp diff --git a/clang/unittests/Analysis/FlowSensitive/SourceLocationsLatticeTest.cpp b/clang/unittests/Analysis/FlowSensitive/SourceLocationsLatticeTest.cpp deleted file mode 100644 index 4c7b1ce60fb52e..00000000000000 --- a/clang/unittests/Analysis/FlowSensitive/SourceLocationsLatticeTest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//===- unittests/Analysis/FlowSensitive/SourceLocationsLatticeTest.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/Analysis/FlowSensitive/SourceLocationsLattice.h" - -#include "clang/Analysis/FlowSensitive/DataflowLattice.h" -#include "clang/Basic/SourceLocation.h" -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -namespace clang { -namespace dataflow { -namespace { - -TEST(SourceLocationsLatticeTest, Comparison) { - const SourceLocationsLattice Bottom; - const SourceLocationsLattice NonBottom( - {SourceLocation::getFromRawEncoding(0)}); - - EXPECT_TRUE(Bottom == Bottom); - EXPECT_FALSE(Bottom == NonBottom); - EXPECT_FALSE(NonBottom == Bottom); - EXPECT_TRUE(NonBottom == NonBottom); - - EXPECT_FALSE(Bottom != Bottom); - EXPECT_TRUE(Bottom != NonBottom); - EXPECT_TRUE(NonBottom != Bottom); - EXPECT_FALSE(NonBottom != NonBottom); -} - -TEST(SourceLocationsLatticeTest, Join) { - const SourceLocationsLattice Bottom; - const SourceLocationsLattice NonBottom( - {SourceLocation::getFromRawEncoding(0)}); - { - SourceLocationsLattice LHS = Bottom; - const SourceLocationsLattice RHS = Bottom; - EXPECT_EQ(LHS.join(RHS), LatticeJoinEffect::Unchanged); - EXPECT_EQ(LHS, Bottom); - } - { - SourceLocationsLattice LHS = NonBottom; - const SourceLocationsLattice RHS = Bottom; - EXPECT_EQ(LHS.join(RHS), LatticeJoinEffect::Unchanged); - EXPECT_EQ(LHS, NonBottom); - } - { - SourceLocationsLattice LHS = Bottom; - const SourceLocationsLattice RHS = NonBottom; - EXPECT_EQ(LHS.join(RHS), LatticeJoinEffect::Changed); - EXPECT_EQ(LHS, NonBottom); - } - { - SourceLocationsLattice LHS = NonBottom; - const SourceLocationsLattice RHS = NonBottom; - EXPECT_EQ(LHS.join(RHS), LatticeJoinEffect::Unchanged); - EXPECT_EQ(LHS, NonBottom); - } -} - -} // namespace -} // namespace dataflow -} // namespace clang diff --git a/llvm/utils/gn/secondary/clang/lib/Analysis/FlowSensitive/BUILD.gn b/llvm/utils/gn/secondary/clang/lib/Analysis/FlowSensitive/BUILD.gn index 969d7f9f58c5b8..adf425c80b9061 100644 --- a/llvm/utils/gn/secondary/clang/lib/Analysis/FlowSensitive/BUILD.gn +++ b/llvm/utils/gn/secondary/clang/lib/Analysis/FlowSensitive/BUILD.gn @@ -9,7 +9,6 @@ static_library("FlowSensitive") { "ControlFlowContext.cpp", "DataflowAnalysisContext.cpp", "DataflowEnvironment.cpp", - "SourceLocationsLattice.cpp", "Transfer.cpp", "TypeErasedDataflowAnalysis.cpp", "WatchedLiteralsSolver.cpp", diff --git a/llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn b/llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn index f2205e7b7e6bdd..a12ea4657f47e4 100644 --- a/llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn +++ b/llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn @@ -25,7 +25,6 @@ unittest("ClangAnalysisFlowSensitiveTests") { "MultiVarConstantPropagationTest.cpp", "SingleVarConstantPropagationTest.cpp", "SolverTest.cpp", - "SourceLocationsLatticeTest.cpp", "TestingSupport.cpp", "TestingSupportTest.cpp", "TransferTest.cpp",