[cfe-commits] r82304 - in /cfe/trunk: lib/Sema/CodeCompleteConsumer.cpp test/CodeCompletion/templates.cpp

Daniel Dunbar daniel at zuster.org
Sat Oct 17 17:28:45 PDT 2009


Hi Doug,

On Fri, Sep 18, 2009 at 3:47 PM, Douglas Gregor <dgregor at apple.com> wrote:
> Author: dgregor
> Date: Fri Sep 18 17:47:56 2009
> New Revision: 82304
>
> URL: http://llvm.org/viewvc/llvm-project?rev=82304&view=rev
> Log:
> Introduce code completion patterns for templates, which provide the
> angle brackets < > along with placeholder template arguments.
...
> +  TemplateParameterList *Params = Template->getTemplateParameters();
> +  for (TemplateParameterList::iterator P = Params->begin(),
> +                                    PEnd = Params->end();
> +       P != PEnd; ++P) {
> +    bool HasDefaultArg = false;
> +    std::string PlaceholderStr;
> +    if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
> +      if (TTP->wasDeclaredWithTypename())
> +        PlaceholderStr = "typename";
> +      else
> +        PlaceholderStr = "class";
> +
> +      if (TTP->getIdentifier()) {
> +        PlaceholderStr += ' ';
> +        PlaceholderStr += TTP->getIdentifier()->getName();
> +      }

This is a nit, but it would be nice to have new code not use
std::string concatenation. It blends well with raw_ostream and
StringRefization, and should generally be more efficient and produce
smaller code. If it works out to be more cumbersome, we should find
some way to make it less so (i.e., PR5231).

 - Daniel




More information about the cfe-commits mailing list