diff options
-rw-r--r-- | include/clang/AST/TemplateBase.h | 2 | ||||
-rw-r--r-- | include/clang/AST/TypeLoc.h | 5 | ||||
-rw-r--r-- | lib/AST/TemplateBase.cpp | 10 |
3 files changed, 14 insertions, 3 deletions
diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h index 7f3e591a96..22ca164d38 100644 --- a/include/clang/AST/TemplateBase.h +++ b/include/clang/AST/TemplateBase.h @@ -330,7 +330,7 @@ private: }; public: - TemplateArgumentLocInfo() : Expression(0) {} + TemplateArgumentLocInfo(); TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {} diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 81ece1799b..3480681fe1 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -1115,8 +1115,11 @@ public: const TemplateArgument *Args, TemplateArgumentLocInfo *ArgInfos, SourceLocation Loc) { - for (unsigned i = 0, e = NumArgs; i != e; ++i) + for (unsigned i = 0, e = NumArgs; i != e; ++i) { + // FIXME: We can generate better location info here for type arguments, + // template template arguments, and template template pack expansions (?). ArgInfos[i] = TemplateArgumentLocInfo(); + } } unsigned getExtraLocalDataSize() const { diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp index de5531f0f7..68e23323ce 100644 --- a/lib/AST/TemplateBase.cpp +++ b/lib/AST/TemplateBase.cpp @@ -292,6 +292,10 @@ void TemplateArgument::print(const PrintingPolicy &Policy, // TemplateArgumentLoc Implementation //===----------------------------------------------------------------------===// +TemplateArgumentLocInfo::TemplateArgumentLocInfo() { + memset(this, 0, sizeof(TemplateArgumentLocInfo)); +} + SourceRange TemplateArgumentLoc::getSourceRange() const { switch (Argument.getKind()) { case TemplateArgument::Expression: @@ -362,11 +366,15 @@ TemplateArgumentLoc::getPackExpansionPattern(SourceLocation &Ellipsis, } case TemplateArgument::Expression: { - Expr *Pattern = cast<PackExpansionExpr>(Argument.getAsExpr())->getPattern(); + PackExpansionExpr *Expansion + = cast<PackExpansionExpr>(Argument.getAsExpr()); + Expr *Pattern = Expansion->getPattern(); + Ellipsis = Expansion->getEllipsisLoc(); return TemplateArgumentLoc(Pattern, Pattern); } case TemplateArgument::TemplateExpansion: + Ellipsis = getTemplateEllipsisLoc(); return TemplateArgumentLoc(Argument.getPackExpansionPattern(), getTemplateQualifierRange(), getTemplateNameLoc()); |