diff --git a/clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h --- a/clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h +++ b/clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h @@ -14,7 +14,7 @@ #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_NOOPANALYSIS_H #include "clang/AST/ASTContext.h" -#include "clang/AST/Stmt.h" +#include "clang/Analysis/CFG.h" #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/NoopLattice.h" @@ -38,7 +38,7 @@ static NoopLattice initialElement() { return {}; } - void transfer(const Stmt *S, NoopLattice &E, Environment &Env) {} + void transfer(const CFGElement *E, NoopLattice &L, Environment &Env) {} }; } // namespace dataflow diff --git a/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp b/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp @@ -10,11 +10,10 @@ #include "clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h" #include "TestingSupport.h" #include "clang/AST/ASTContext.h" -#include "clang/ASTMatchers/ASTMatchers.h" -#include "clang/Analysis/FlowSensitive/NoopAnalysis.h" +#include "clang/Analysis/CFG.h" +#include "clang/Analysis/FlowSensitive/NoopLattice.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/Support/Error.h" #include "llvm/Testing/Support/Error.h" #include "gmock/gmock.h" @@ -120,8 +119,10 @@ static NoopLattice initialElement() { return NoopLattice(); } - void transfer(const Stmt *S, NoopLattice &, Environment &Env) { - M.transfer(S, Env); + void transfer(const CFGElement *E, NoopLattice &, Environment &Env) { + if (auto S = E->getAs()) { + M.transfer(S->getStmt(), Env); + } } private: 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 @@ -19,17 +19,16 @@ #include "clang/AST/Stmt.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Analysis/CFG.h" #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/DataflowLattice.h" #include "clang/Analysis/FlowSensitive/MapLattice.h" -#include "clang/Tooling/Tooling.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Error.h" -#include "llvm/Testing/Support/Annotations.h" #include "llvm/Testing/Support/Error.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -133,8 +132,12 @@ return ConstantPropagationLattice::bottom(); } - void transfer(const Stmt *S, ConstantPropagationLattice &Vars, + void transfer(const CFGElement *E, ConstantPropagationLattice &Vars, Environment &Env) { + auto CS = E->getAs(); + if (!CS) + return; + auto S = CS->getStmt(); auto matcher = stmt(anyOf(declStmt(hasSingleDecl( varDecl(decl().bind(kVar), hasType(isInteger()), 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 @@ -19,16 +19,15 @@ #include "clang/AST/Stmt.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Analysis/CFG.h" #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h" #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h" #include "clang/Analysis/FlowSensitive/DataflowLattice.h" -#include "clang/Tooling/Tooling.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Error.h" -#include "llvm/Testing/Support/Annotations.h" #include "llvm/Testing/Support/Error.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -122,8 +121,12 @@ return ConstantPropagationLattice::bottom(); } - void transfer(const Stmt *S, ConstantPropagationLattice &Element, + void transfer(const CFGElement *E, ConstantPropagationLattice &Element, Environment &Env) { + auto CS = E->getAs(); + if (!CS) + return; + auto S = CS->getStmt(); auto matcher = stmt( anyOf(declStmt(hasSingleDecl(varDecl(hasType(isInteger()), hasInitializer(expr().bind(kInit))) 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 @@ -111,7 +111,7 @@ static NonConvergingLattice initialElement() { return {0}; } - void transfer(const Stmt *S, NonConvergingLattice &E, Environment &Env) { + void transfer(const CFGElement *, NonConvergingLattice &E, Environment &) { ++E.State; } }; @@ -162,7 +162,11 @@ static FunctionCallLattice initialElement() { return {}; } - void transfer(const Stmt *S, FunctionCallLattice &E, Environment &Env) { + void transfer(const CFGElement *Elt, FunctionCallLattice &E, Environment &) { + auto CS = Elt->getAs(); + if (!CS) + return; + auto S = CS->getStmt(); if (auto *C = dyn_cast(S)) { if (auto *F = dyn_cast(C->getCalleeDecl())) { E.CalledFunctions.insert(F->getNameInfo().getAsString()); @@ -314,7 +318,11 @@ static NoopLattice initialElement() { return {}; } - void transfer(const Stmt *S, NoopLattice &, Environment &Env) { + void transfer(const CFGElement *Elt, NoopLattice &, Environment &Env) { + auto CS = Elt->getAs(); + if (!CS) + return; + auto S = CS->getStmt(); auto SpecialBoolRecordDecl = recordDecl(hasName("SpecialBool")); auto HasSpecialBoolType = hasType(SpecialBoolRecordDecl); @@ -466,7 +474,11 @@ static NoopLattice initialElement() { return {}; } - void transfer(const Stmt *S, NoopLattice &, Environment &Env) { + void transfer(const CFGElement *Elt, NoopLattice &, Environment &Env) { + auto CS = Elt->getAs(); + if (!CS) + return; + auto S = CS->getStmt(); auto OptionalIntRecordDecl = recordDecl(hasName("OptionalInt")); auto HasOptionalIntType = hasType(OptionalIntRecordDecl);