[clang] 26089d4 - Revert "[clang][dataflow] Don't crash when caller args are missing storage locations"
Evgenii Stepanov via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 10 14:30:02 PDT 2022
Author: Evgenii Stepanov
Date: 2022-08-10T14:21:46-07:00
New Revision: 26089d4da489dc17711213f917779e480a78ed51
URL: https://github.com/llvm/llvm-project/commit/26089d4da489dc17711213f917779e480a78ed51
DIFF: https://github.com/llvm/llvm-project/commit/26089d4da489dc17711213f917779e480a78ed51.diff
LOG: Revert "[clang][dataflow] Don't crash when caller args are missing storage locations"
https://lab.llvm.org/buildbot/#/builders/74/builds/12713
This reverts commit 43b298ea1282f29d448fc0f6ca971bc5fa698355.
Added:
Modified:
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index b3bc52a79a2fc..8c169005846ef 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -140,6 +140,8 @@ class Environment {
/// The body of the callee must not reference globals.
///
/// The arguments of `Call` must map 1:1 to the callee's parameters.
+ ///
+ /// Each argument of `Call` must already have a `StorageLocation`.
Environment pushCall(const CallExpr *Call) const;
Environment pushCall(const CXXConstructExpr *Call) const;
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 119ef337c6319..e4af68e53e14e 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -253,8 +253,7 @@ void Environment::pushCallInternal(const FunctionDecl *FuncDecl,
const Expr *Arg = Args[ArgIndex];
auto *ArgLoc = getStorageLocation(*Arg, SkipPast::Reference);
- if (ArgLoc == nullptr)
- continue;
+ assert(ArgLoc != nullptr);
const VarDecl *Param = *ParamIt;
auto &Loc = createStorageLocation(*Param);
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 0e33df3a38008..af06021abccfd 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -4229,27 +4229,6 @@ TEST(TransferTest, ContextSensitiveReturnArg) {
/*.BuiltinTransferOptions=*/{/*.ContextSensitive=*/true}});
}
-TEST(TransferTest, ContextSensitiveReturnInt) {
- std::string Code = R"(
- int identity(int x) { return x; }
-
- void target() {
- int y = identity(42);
- // [[p]]
- }
- )";
- runDataflow(Code,
- [](llvm::ArrayRef<
- std::pair<std::string, DataflowAnalysisState<NoopLattice>>>
- Results,
- ASTContext &ASTCtx) {
- ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
- // This just tests that the analysis doesn't crash.
- },
- {/*.ApplyBuiltinTransfer=*/true,
- /*.BuiltinTransferOptions=*/{/*.ContextSensitive=*/true}});
-}
-
TEST(TransferTest, ContextSensitiveMethodLiteral) {
std::string Code = R"(
class MyClass {
More information about the cfe-commits
mailing list