[cfe-commits] r105882 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplate.cpp

Douglas Gregor dgregor at apple.com
Mon Jun 14 14:02:11 PDT 2010


On Jun 12, 2010, at 1:15 AM, Abramo Bagnara wrote:

> Author: abramo
> Date: Sat Jun 12 03:15:14 2010
> New Revision: 105882
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=105882&view=rev
> Log:
> Added template parameters info for out-of-line definitions of class template methods.
> 
> Modified:
>    cfe/trunk/include/clang/AST/Decl.h
>    cfe/trunk/lib/AST/Decl.cpp
>    cfe/trunk/lib/Sema/SemaDecl.cpp
>    cfe/trunk/lib/Sema/SemaTemplate.cpp
> 
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=105882&r1=105881&r2=105882&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Sat Jun 12 03:15:14 2010
> @@ -28,6 +28,8 @@
> class Stmt;
> class CompoundStmt;
> class StringLiteral;
> +class NestedNameSpecifier;
> +class TemplateParameterList;
> class TemplateArgumentList;
> class MemberSpecializationInfo;
> class FunctionTemplateSpecializationInfo;
> @@ -364,15 +366,42 @@
>   static bool classofKind(Kind K) { return K >= firstValue && K <= lastValue; }
> };
> 
> +/// QualifierInfo - A struct with extended info about a syntactic
> +/// name qualifier, to be used for the case of out-of-line declarations.
> +struct QualifierInfo {
> +  /// NNS - The syntactic name qualifier.
> +  NestedNameSpecifier *NNS;
> +  /// NNSRange - The source range for the qualifier.
> +  SourceRange NNSRange;
> +  /// NumTemplParamLists - The number of template parameter lists
> +  /// that were matched against the template-ids occurring into the NNS.
> +  unsigned NumTemplParamLists;
> +  /// TemplParamLists - A new-allocated array of size NumTemplParamLists,
> +  /// containing pointers to the matched template parameter lists.
> +  TemplateParameterList** TemplParamLists;
> +
> +  /// Default constructor.
> +  QualifierInfo()
> +    : NNS(0), NNSRange(), NumTemplParamLists(0), TemplParamLists(0) {}
> +  /// setTemplateParameterListsInfo - Sets info about matched template
> +  /// parameter lists.
> +  void setTemplateParameterListsInfo(unsigned NumTPLists,
> +                                     TemplateParameterList **TPLists);
> +  /// Destructor: frees the array of template parameter lists pointers.
> +  ~QualifierInfo() { delete[] TemplParamLists; }

The template parameter lists should be stored in memory allocated via the ASTContext, not on the normal heap. AST or Sema will need to copy the TemplateParameterList pointers into ASTContext-allocated memory, and rather than have a destructor, QualifierInfo should have a Destroy method that deallocates that memory.

Everything else looks great!

	- Doug





More information about the cfe-commits mailing list