[cfe-dev] clang and gcc implement __PRETTY_FUNCTION__ differently
Douglas Gregor
dgregor at apple.com
Thu Apr 5 07:56:15 PDT 2012
On Apr 1, 2012, at 6:00 AM, Nikola Smiljanic <popizdeh at gmail.com> wrote:
> This should be it. Additional tests for explicit specializations (both
> function and class template) in which case specialized template
> parameters are not mentioned. I'm still interested in adding a test
> case where getInstantiatedFromMemberTemplate needs to be called more
> than once, I just couldn't figure this one out.
> <pretty_function.txt>
This is looking really good. I have a few more minor comments:
+ const FunctionDecl *Decl = FD->getTemplateInstantiationPattern();
+ if (Decl == 0) Decl = FD;
This would be cleaner as:
if (const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern())
Decl = Pattern;
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
Qualifiers ThisQuals = Qualifiers::fromCVRMask(MD->getTypeQualifiers());
if (ThisQuals.hasConst())
- Proto += " const";
+ POut << " const";
if (ThisQuals.hasVolatile())
- Proto += " volatile";
+ POut << " volatile";
}
Any chance I could get you to add support for C++11 ref-qualifiers here? For example,
struct X {
X &operator=(const X&) &;
};
+ std::string TemplateParams;
+ llvm::raw_string_ostream TOut(TemplateParams);
+ for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
+ I != E; ++I) {
+ const TemplateParameterList *Params
+ = (*I)->getSpecializedTemplate()->getTemplateParameters();
+ const TemplateArgumentList &Args = (*I)->getTemplateArgs();
+ assert(Params->size() == Args.size());
+ for (unsigned i = 0, numParams = Params->size(); i != numParams; ++i) {
+ TOut << Params->getParam(i)->getNameAsString() << " = ";
+ Args.get(i).print(Policy, TOut);
+ TOut << ", ";
+ }
+ }
Some template parameters might be unnamed. Shouldn't we just skip those? (Same comment below)
Thanks for working on this, it's a big improvement!
- Doug
More information about the cfe-dev
mailing list