diff options
author | Etienne Bergeron <etienneb@google.com> | 2016-04-07 14:58:13 +0000 |
---|---|---|
committer | Etienne Bergeron <etienneb@google.com> | 2016-04-07 14:58:13 +0000 |
commit | 2c82ebe813c5f851852bdf4451a34f1d5dfe473c (patch) | |
tree | c4ace5dd02e678753a0f549c432e16d376e5a5b1 /clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp | |
parent | a62e2232815e537952bd6df271763521a0472498 (diff) | |
download | bcm5719-llvm-2c82ebe813c5f851852bdf4451a34f1d5dfe473c.tar.gz bcm5719-llvm-2c82ebe813c5f851852bdf4451a34f1d5dfe473c.zip |
[clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.
Summary:
This is the same kind of bug than [[ http://reviews.llvm.org/D18238 | D18238 ]].
Fix crashes caused by deferencing null pointer when declarations parsing may be delayed.
The body of the declarations may be null.
The crashes were observed with a Windows build of clang-tidy and the following command-line.
```
command-line switches: -fms-compatibility-version=19 -fms-compatibility
```
Reviewers: alexfh
Subscribers: kimgr, LegalizeAdulthood, cfe-commits
Differential Revision: http://reviews.llvm.org/D18852
llvm-svn: 265681
Diffstat (limited to 'clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp index e3be05ee0f2..e5757b0ec7a 100644 --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -51,6 +51,10 @@ void UnnecessaryValueParamCheck::check(const MatchFinder::MatchResult &Result) { bool IsConstQualified = Param->getType().getCanonicalType().isConstQualified(); + // Skip declarations delayed by late template parsing without a body. + if (!Function->getBody()) + return; + // Do not trigger on non-const value parameters when: // 1. they are in a constructor definition since they can likely trigger // misc-move-constructor-init which will suggest to move the argument. |