diff options
Diffstat (limited to 'lib/AST/TemplateBase.cpp')
-rw-r--r-- | lib/AST/TemplateBase.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp index 02e648879ad7..a3bf1459c283 100644 --- a/lib/AST/TemplateBase.cpp +++ b/lib/AST/TemplateBase.cpp @@ -125,19 +125,22 @@ SourceRange TemplateArgumentLoc::getSourceRange() const { switch (Argument.getKind()) { case TemplateArgument::Expression: return getSourceExpression()->getSourceRange(); - + case TemplateArgument::Declaration: return getSourceDeclExpression()->getSourceRange(); - + case TemplateArgument::Type: - return getTypeSourceInfo()->getTypeLoc().getSourceRange(); - + if (TypeSourceInfo *TSI = getTypeSourceInfo()) + return TSI->getTypeLoc().getSourceRange(); + else + return SourceRange(); + case TemplateArgument::Template: if (getTemplateQualifierRange().isValid()) return SourceRange(getTemplateQualifierRange().getBegin(), getTemplateNameLoc()); return SourceRange(getTemplateNameLoc()); - + case TemplateArgument::Integral: case TemplateArgument::Pack: case TemplateArgument::Null: @@ -152,7 +155,9 @@ const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB, const TemplateArgument &Arg) { switch (Arg.getKind()) { case TemplateArgument::Null: - return DB; + // This is bad, but not as bad as crashing because of argument + // count mismatches. + return DB << "(null template argument)"; case TemplateArgument::Type: return DB << Arg.getAsType(); |