[cfe-dev] using declarations

Douglas Gregor dgregor at apple.com
Mon May 11 08:43:13 PDT 2009


On May 11, 2009, at 8:32 AM, Douglas Gregor wrote:

> Index: tools/clang/include/clang/AST/DeclCXX.h
> ===================================================================
> --- tools/clang/include/clang/AST/DeclCXX.h	(revision 68578)
> +++ tools/clang/include/clang/AST/DeclCXX.h	(working copy)
>
> @@ -1003,6 +1003,37 @@
>
>    }
>    static bool classof(const NamespaceAliasDecl *D) { return true; }
>  };
> +
> +/// UsingAliasDecl - Represents C++ using-directive. For example:
> +///    using someNameSpace::someIdentifier;
>
> UsingAliasDecl represents a using declaration, not a using directive.
>
> +class UsingAliasDecl : public NamedDecl {
> +
> +  // Target declaration.
> +  NamedDecl* TargetDecl;
> +  // Had 'typename' keyword.
> +  bool IsTypeName;
> +
>
> We'll probably want to store more location information, e.g., the
> source range covering the nested-name-specifier, (e.g., "N::M::"), the
> source location of the target declaration's name, and the source
> location of the "using" itself. Also, how about keeping track of the
> NestedNameSpecifier used to refer to the target declaration? It's good
> for pretty-printing, and will also be needed when the using directive
> occurs within a template and the nested-name-specifier is dependent.

Oh, and we might even consider storing the list of declarations that  
the using declaration refers to, because we need to model the  
semantics of paragraph 11:

	The entity declared by a using-declaration shall be known in the  
context using it according to its definition
at the point of the using-declaration . Definitions added to the  
namespace after the using-declaration are not
considered when a use of the name is made.

	- Doug




More information about the cfe-dev mailing list