summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/cppcoreguidelines
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2016-04-27 12:17:04 +0000
committerHaojian Wu <hokein@google.com>2016-04-27 12:17:04 +0000
commit20d4c20bca22b82f907166b40abc2f4139a3eee4 (patch)
treeee41b5e4eb1d39b9498f82f56748dd48c39da103 /clang-tools-extra/clang-tidy/cppcoreguidelines
parentf23aa2a9c95345a126f1895b4af2dd835b7debef (diff)
downloadbcm5719-llvm-20d4c20bca22b82f907166b40abc2f4139a3eee4.tar.gz
bcm5719-llvm-20d4c20bca22b82f907166b40abc2f4139a3eee4.zip
Fix a crash in cppcoreguidelines-pro-type-member-init when checking a type with a template parameter as a base class.
Summary: Fixed a crash in cppcoreguidelines-pro-type-member-init when encountering a type that uses one of its template parameters as a base when compiling for C++98. Patch by Michael Miller! Reviewers: aaron.ballman, alexfh, hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19539 llvm-svn: 267700
Diffstat (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines')
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
index 7aba5242962..d41175e27d2 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -208,8 +208,12 @@ computeInsertions(const CXXConstructorDecl::init_const_range &Inits,
void getInitializationsInOrder(const CXXRecordDecl *ClassDecl,
SmallVectorImpl<const NamedDecl *> &Decls) {
Decls.clear();
- for (const auto &Base : ClassDecl->bases())
- Decls.emplace_back(getCanonicalRecordDecl(Base.getType()));
+ for (const auto &Base : ClassDecl->bases()) {
+ // Decl may be null if the base class is a template parameter.
+ if (const NamedDecl *Decl = getCanonicalRecordDecl(Base.getType())) {
+ Decls.emplace_back(Decl);
+ }
+ }
Decls.append(ClassDecl->fields().begin(), ClassDecl->fields().end());
}
OpenPOWER on IntegriCloud