[cfe-commits] r122931 - in /cfe/trunk: include/clang/AST/TemplateBase.h include/clang/AST/TypeLoc.h lib/AST/TemplateBase.cpp
Douglas Gregor
dgregor at apple.com
Wed Jan 5 16:33:28 PST 2011
Author: dgregor
Date: Wed Jan 5 18:33:28 2011
New Revision: 122931
URL: http://llvm.org/viewvc/llvm-project?rev=122931&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/AST/TemplateBase.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/lib/AST/TemplateBase.cpp
Modified: cfe/trunk/include/clang/AST/TemplateBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateBase.h?rev=122931&r1=122930&r2=122931&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TemplateBase.h (original)
+++ cfe/trunk/include/clang/AST/TemplateBase.h Wed Jan 5 18:33:28 2011
@@ -330,7 +330,7 @@
};
public:
- TemplateArgumentLocInfo() : Expression(0) {}
+ TemplateArgumentLocInfo();
TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {}
Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=122931&r1=122930&r2=122931&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Wed Jan 5 18:33:28 2011
@@ -1115,8 +1115,11 @@
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 {
Modified: cfe/trunk/lib/AST/TemplateBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TemplateBase.cpp?rev=122931&r1=122930&r2=122931&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TemplateBase.cpp (original)
+++ cfe/trunk/lib/AST/TemplateBase.cpp Wed Jan 5 18:33:28 2011
@@ -292,6 +292,10 @@
// TemplateArgumentLoc Implementation
//===----------------------------------------------------------------------===//
+TemplateArgumentLocInfo::TemplateArgumentLocInfo() {
+ memset(this, 0, sizeof(TemplateArgumentLocInfo));
+}
+
SourceRange TemplateArgumentLoc::getSourceRange() const {
switch (Argument.getKind()) {
case TemplateArgument::Expression:
@@ -362,11 +366,15 @@
}
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());
More information about the cfe-commits
mailing list