summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTDiagnostic.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2016-08-05 03:16:36 +0000
committerRichard Trieu <rtrieu@google.com>2016-08-05 03:16:36 +0000
commite1a6a7d6d3676db194928d0025a40fe9ea3842de (patch)
treea8110a835fded1ddd29cca2b831901ad6541d5b4 /clang/lib/AST/ASTDiagnostic.cpp
parent7561ed01cb762d336d60dc2b05faab6c948e11fd (diff)
downloadbcm5719-llvm-e1a6a7d6d3676db194928d0025a40fe9ea3842de.tar.gz
bcm5719-llvm-e1a6a7d6d3676db194928d0025a40fe9ea3842de.zip
Fix crash in template type diffing.
When the type being diffed is a type alias, and the orginal type is not a templated type, then there will be no unsugared TemplateSpecializationType. When this happens, exit early from the constructor. Also add assertions to the other iterator accessor to prevent the iterator from being used. llvm-svn: 277797
Diffstat (limited to 'clang/lib/AST/ASTDiagnostic.cpp')
-rw-r--r--clang/lib/AST/ASTDiagnostic.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index b6b9c2f4e2d..85ab4cc3e64 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -916,6 +916,8 @@ class TemplateDiff {
/// template argument.
InternalIterator(const TemplateSpecializationType *TST)
: TST(TST), Index(0), CurrentTA(nullptr), EndTA(nullptr) {
+ if (!TST) return;
+
if (isEnd()) return;
// Set to first template argument. If not a parameter pack, done.
@@ -936,11 +938,13 @@ class TemplateDiff {
/// isEnd - Returns true if the iterator is one past the end.
bool isEnd() const {
+ assert(TST && "InternalalIterator is invalid with a null TST.");
return Index >= TST->getNumArgs();
}
/// &operator++ - Increment the iterator to the next template argument.
InternalIterator &operator++() {
+ assert(TST && "InternalalIterator is invalid with a null TST.");
if (isEnd()) {
return *this;
}
@@ -976,6 +980,7 @@ class TemplateDiff {
/// operator* - Returns the appropriate TemplateArgument.
reference operator*() const {
+ assert(TST && "InternalalIterator is invalid with a null TST.");
assert(!isEnd() && "Index exceeds number of arguments.");
if (CurrentTA == EndTA)
return TST->getArg(Index);
@@ -985,6 +990,7 @@ class TemplateDiff {
/// operator-> - Allow access to the underlying TemplateArgument.
pointer operator->() const {
+ assert(TST && "InternalalIterator is invalid with a null TST.");
return &operator*();
}
};
OpenPOWER on IntegriCloud