summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
diff options
context:
space:
mode:
authorYan Wang <yawanng@google.com>2017-05-14 04:14:59 +0000
committerYan Wang <yawanng@google.com>2017-05-14 04:14:59 +0000
commit7696b71d6418e7ac6b76bc40e3af7e9e796a3f10 (patch)
tree6dba2eb2ad5d52434964facc9efa34195598f257 /clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
parent90a9ef6cedb2fb6f3c31b9d96faf21eae92dee14 (diff)
downloadbcm5719-llvm-7696b71d6418e7ac6b76bc40e3af7e9e796a3f10.tar.gz
bcm5719-llvm-7696b71d6418e7ac6b76bc40e3af7e9e796a3f10.zip
[clang-tidy] TwineLocalCheck: add param # checking
Summary: The statement **getArg** tries to get the first one without checking, which may cause segmentation fault. Reviewers: chh, bkramer Reviewed By: bkramer Subscribers: cfe-commits, xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33103 llvm-svn: 303001
Diffstat (limited to 'clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
index 3fb5f5d9f0a..67c85a6728c 100644
--- a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -35,8 +35,11 @@ void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {
// of the initializer.
const Expr *C = VD->getInit()->IgnoreImplicit();
- while (isa<CXXConstructExpr>(C))
+ while (isa<CXXConstructExpr>(C)) {
+ if (cast<CXXConstructExpr>(C)->getNumArgs() == 0)
+ break;
C = cast<CXXConstructExpr>(C)->getArg(0)->IgnoreParenImpCasts();
+ }
SourceRange TypeRange =
VD->getTypeSourceInfo()->getTypeLoc().getSourceRange();
OpenPOWER on IntegriCloud