diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-07-31 19:39:37 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-07-31 19:39:37 +0000 |
commit | bd880fe1c1235f48d5e537af563362ddc4f8af53 (patch) | |
tree | 7a3306948c07a228645b403ec6e1c43deb6d6a39 /clang/lib/Analysis/ConstructionContext.cpp | |
parent | 959fe03933e5f841f77219d526f88055c081d9a0 (diff) | |
download | bcm5719-llvm-bd880fe1c1235f48d5e537af563362ddc4f8af53.tar.gz bcm5719-llvm-bd880fe1c1235f48d5e537af563362ddc4f8af53.zip |
[CFG] [analyzer] Add stubs for constructor and message argument constructors.
CFG now correctly identifies construction context for temporaries constructed
for the purpose of passing into a function as an argument.
Such context is still not fully implemented because the information it provides
is not rich enough: it doens't contain information about argument index.
It will be addresssed later.
This patch is an extension of r330377 to C++ construct-expressions and
Objective-C message expressions which aren't call-expressions but require
similar handling. C++ new-expressions with placement arguments still remain to
be handled.
Differential Revision: https://reviews.llvm.org/D49826
llvm-svn: 338425
Diffstat (limited to 'clang/lib/Analysis/ConstructionContext.cpp')
-rw-r--r-- | clang/lib/Analysis/ConstructionContext.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Analysis/ConstructionContext.cpp b/clang/lib/Analysis/ConstructionContext.cpp index ed1e6324321..3ffb0a6b35c 100644 --- a/clang/lib/Analysis/ConstructionContext.cpp +++ b/clang/lib/Analysis/ConstructionContext.cpp @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// #include "clang/Analysis/ConstructionContext.h" +#include "clang/AST/ExprObjC.h" using namespace clang; @@ -111,7 +112,9 @@ const ConstructionContext *ConstructionContext::createFromLayers( assert(ParentLayer->isLast()); // This is a constructor into a function argument. Not implemented yet. - if (isa<CallExpr>(ParentLayer->getTriggerStmt())) + if (isa<CallExpr>(ParentLayer->getTriggerStmt()) || + isa<CXXConstructExpr>(ParentLayer->getTriggerStmt()) || + isa<ObjCMessageExpr>(ParentLayer->getTriggerStmt())) return nullptr; // This is C++17 copy-elided construction into return statement. if (auto *RS = dyn_cast<ReturnStmt>(ParentLayer->getTriggerStmt())) { @@ -173,7 +176,9 @@ const ConstructionContext *ConstructionContext::createFromLayers( return create<SimpleReturnedValueConstructionContext>(C, RS); } // This is a constructor into a function argument. Not implemented yet. - if (isa<CallExpr>(TopLayer->getTriggerStmt())) + if (isa<CallExpr>(TopLayer->getTriggerStmt()) || + isa<CXXConstructExpr>(TopLayer->getTriggerStmt()) || + isa<ObjCMessageExpr>(TopLayer->getTriggerStmt())) return nullptr; llvm_unreachable("Unexpected construction context with statement!"); } else if (const CXXCtorInitializer *I = TopLayer->getTriggerInit()) { |