summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
diff options
context:
space:
mode:
authorAngel Garcia Gomez <angelgarcia@google.com>2015-09-08 09:01:21 +0000
committerAngel Garcia Gomez <angelgarcia@google.com>2015-09-08 09:01:21 +0000
commitd930ef76eaca107e80baa7edda864cf2eb075a24 (patch)
tree564d00004387af71db126446bfad608bd8c108ee /clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
parentf1044c044a520e5c796fd03cea3a8b38e645a167 (diff)
downloadbcm5719-llvm-d930ef76eaca107e80baa7edda864cf2eb075a24.tar.gz
bcm5719-llvm-d930ef76eaca107e80baa7edda864cf2eb075a24.zip
Avoid using rvalue references with trivially copyable types.
Summary: When the dereference operator returns a value that is trivially copyable (like a pointer), copy it. After this change, modernize-loop-convert check can be applied to the whole llvm source code without breaking any build or test. Reviewers: alexfh, klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D12675 llvm-svn: 246989
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
index 116ec5c46c5..d0b2e8177a9 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -349,11 +349,13 @@ static bool isAliasDecl(ASTContext *Context, const Decl *TheDecl,
// Check that the declared type is the same as (or a reference to) the
// container type.
+ QualType InitType = Init->getType();
QualType DeclarationType = VDecl->getType();
- if (DeclarationType->isReferenceType())
+ if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
DeclarationType = DeclarationType.getNonReferenceType();
- QualType InitType = Init->getType();
- if (!Context->hasSameUnqualifiedType(DeclarationType, InitType))
+
+ if (InitType.isNull() || DeclarationType.isNull() ||
+ !Context->hasSameUnqualifiedType(DeclarationType, InitType))
return false;
switch (Init->getStmtClass()) {
OpenPOWER on IntegriCloud