aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-06 00:33:28 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-06 00:33:28 +0000
commitb0ddf3aeb2f119cac42468b029584e8839b354cc (patch)
tree5c877eef861f4920fc442d7e70054f9d03c41348
parent0bbacf8d2b3c7a5f19f292f3201e371836445502 (diff)
When default-initializing a TemplateArgumentLocInfo, make sure that we
initialize *all* of the bits to zero. Also, when the pattern of a template argument pack expansion, make sure to set the ellipsis location along all paths. This should clear up the valgrind failure that popped up in Clang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122931 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/TemplateBase.h2
-rw-r--r--include/clang/AST/TypeLoc.h5
-rw-r--r--lib/AST/TemplateBase.cpp10
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());