[cfe-commits] r68128 - in /cfe/trunk: include/clang/AST/TemplateName.h include/clang/Basic/DiagnosticSemaKinds.td lib/AST/TemplateName.cpp lib/Sema/Sema.h lib/Sema/SemaTemplateInstantiate.cpp test/SemaTemplate/instantiate-template-template-parm.cpp test/SemaTemplate/metafun-apply.cpp
Douglas Gregor
dgregor at apple.com
Tue Mar 31 13:22:01 PDT 2009
On Mar 31, 2009, at 12:43 PM, Chris Lattner wrote:
> On Mar 31, 2009, at 11:38 AM, Douglas Gregor wrote:
>> URL: http://llvm.org/viewvc/llvm-project?rev=68128&view=rev
>> Log:
>> Implement template instantiation for template names, including both
>> template template parameters and dependent template names. For
>> example, the oft-mentioned
>>
>> typename MetaFun::template apply<T1, T2>::type
>>
>> can now be instantiated, with the appropriate name lookup for
>> "apply".
>
> Nice! Some nits:
>
>> +++ cfe/trunk/include/clang/AST/TemplateName.h Tue Mar 31 13:38:02
>> 2009
>> @@ -99,6 +99,10 @@
>> /// \brief Print the template name.
>> void Print(llvm::raw_ostream &OS) const;
>>
>> + /// \brief Debugging aid that dumps the template name to standard
>> + /// error.
>> + void Dump() const;
>
> Most of the other dump/print methods are lower case. Should these
> be lower case also?
Sure. Same fix in NestedNameSpecifier, too.
>>
>> +++ cfe/trunk/lib/AST/TemplateName.cpp Tue Mar 31 13:38:02 2009
>> @@ -14,6 +14,7 @@
>> #include "clang/AST/DeclTemplate.h"
>> #include "clang/AST/NestedNameSpecifier.h"
>> #include "llvm/Support/raw_ostream.h"
>> +#include <stdio.h>
>
> <cstdio>?
>
>
>> +void TemplateName::Dump() const {
>> + std::string Result;
>> + {
>> + llvm::raw_string_ostream OS(Result);
>> + Print(OS);
>> + }
>> + fprintf(stderr, "%s", Result.c_str());
>> +}
>
> Please just use Print(llvm::errs()), which eliminates the need for
> <stdio>
Much better! Thanks.
>> +TemplateName
>> +Sema::InstantiateTemplateName(TemplateName Name, SourceLocation Loc,
>> + const TemplateArgument *TemplateArgs,
>> + unsigned NumTemplateArgs) {
>> + if (TemplateTemplateParmDecl *TTP
>> + = dyn_cast_or_null<TemplateTemplateParmDecl>(
>> +
>> Name.getAsTemplateDecl())) {
>> + assert(TTP->getDepth() == 0 &&
>> + "Cannot reduce depth of a template template parameter");
>> + assert(TTP->getPosition() < NumTemplateArgs && "Wrong # of
>> template args");
>> + assert(dyn_cast_or_null<ClassTemplateDecl>(
>
> Maybe Casting.h should grow an isa_or_null?
I'm doing something ugly there anyway. It's cleaner, now.
Thanks for the review!
- Doug
More information about the cfe-commits
mailing list