diff options
author | Angel Garcia Gomez <angelgarcia@google.com> | 2015-09-08 09:01:21 +0000 |
---|---|---|
committer | Angel Garcia Gomez <angelgarcia@google.com> | 2015-09-08 09:01:21 +0000 |
commit | d930ef76eaca107e80baa7edda864cf2eb075a24 (patch) | |
tree | 564d00004387af71db126446bfad608bd8c108ee /clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp | |
parent | f1044c044a520e5c796fd03cea3a8b38e645a167 (diff) | |
download | bcm5719-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.cpp | 8 |
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()) { |