summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTDiagnostic.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2016-03-30 22:23:00 +0000
committerRichard Trieu <rtrieu@google.com>2016-03-30 22:23:00 +0000
commita7564d7d66c04804b9104fd0b114e1b5a7972fab (patch)
treeead86654239af607a666e70de900f80555c8133a /clang/lib/AST/ASTDiagnostic.cpp
parent85daf65c5a4a80443fcb2357267d612b244790c3 (diff)
downloadbcm5719-llvm-a7564d7d66c04804b9104fd0b114e1b5a7972fab.tar.gz
bcm5719-llvm-a7564d7d66c04804b9104fd0b114e1b5a7972fab.zip
Fix Clang crash with template type diffing.
Fixes https://llvm.org/bugs/show_bug.cgi?id=27129 which is crash involving type aliases and template type diffing. Template arguments for type aliases and template arguments for the underlying desugared type may not have one-to-one relations, which could mess us the attempt to get more information from the desugared type. For type aliases, ignore the iterator over the desugared type. llvm-svn: 264940
Diffstat (limited to 'clang/lib/AST/ASTDiagnostic.cpp')
-rw-r--r--clang/lib/AST/ASTDiagnostic.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 6e8dfcb937d..658d850b12b 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -990,19 +990,22 @@ class TemplateDiff {
}
};
+ bool UseDesugaredIterator;
InternalIterator SugaredIterator;
InternalIterator DesugaredIterator;
public:
TSTiterator(ASTContext &Context, const TemplateSpecializationType *TST)
- : SugaredIterator(TST),
+ : UseDesugaredIterator(TST->isSugared() && !TST->isTypeAlias()),
+ SugaredIterator(TST),
DesugaredIterator(
GetTemplateSpecializationType(Context, TST->desugar())) {}
/// &operator++ - Increment the iterator to the next template argument.
TSTiterator &operator++() {
++SugaredIterator;
- ++DesugaredIterator;
+ if (UseDesugaredIterator)
+ ++DesugaredIterator;
return *this;
}
@@ -1024,11 +1027,13 @@ class TemplateDiff {
/// hasDesugaredTA - Returns true if there is another TemplateArgument
/// available.
bool hasDesugaredTA() const {
- return !DesugaredIterator.isEnd();
+ return UseDesugaredIterator && !DesugaredIterator.isEnd();
}
/// getDesugaredTA - Returns the desugared TemplateArgument.
reference getDesugaredTA() const {
+ assert(UseDesugaredIterator &&
+ "Desugared TemplateArgument should not be used.");
return *DesugaredIterator;
}
};
OpenPOWER on IntegriCloud