[cfe-commits] r67265 - in /cfe/trunk: include/clang/AST/ include/clang/Parse/ lib/AST/ lib/CodeGen/ lib/Parse/ lib/Sema/ test/SemaCXX/ test/SemaTemplate/
Chris Lattner
clattner at apple.com
Wed Mar 18 22:42:30 PDT 2009
On Mar 18, 2009, at 5:18 PM, Douglas Gregor wrote:
> Author: dgregor
> Date: Wed Mar 18 19:18:19 2009
> New Revision: 67265
> +class NestedNameSpecifier {
> + /// \brief Construct a nested name specifier that refers to a type.
> + NestedNameSpecifier(const Type *T) {
> + Data = reinterpret_cast<uintptr_t>(T);
> + assert((Data & 0x01) == 0 && "cv-qualified type in nested-name-
> specifier");
> + Data |= 0x01;
> + }
Would it be reasonable to use PointerIntPair for this? It would be
nice to only have the bitmangling code and assertions in one place.
Alternatively, maybe having a DiscriminatedPointer<foo*, bar*> class
(which itself wraps PointerIntPair) would be better (perhaps overkill).
> +/// \brief Represents a type that was referred to via a qualified
> +/// name, e.g., N::M::type.
> +///
> +/// This type is used to keep track of a type name as written in the
> +/// source code, including any nested-name-specifiers.
It might be worth explicitly mentioning here that this a sugar type
like typedeftype.
>
> +class QualifiedNameType : public Type, public llvm::FoldingSetNode {
> + /// \brief The number of components in the qualified name, not
> + /// counting the final type.
How about adding:
"In the example above, this would be 2 for N::M" ?
> +++ cfe/trunk/include/clang/Parse/DeclSpec.h Wed Mar 18 19:18:19 2009
> @@ -397,10 +397,36 @@
> /// specifier.
> class CXXScopeSpec {
> SourceRange Range;
> - Action::CXXScopeTy *ScopeRep;
> +
> + /// Storage containing the scope representations for up to four
> + /// levels of nested-name-specifier. NumScopeReps specifiers how
> + /// many levels there are. If there are more than four, we use
> + /// ManyScopeReps.
> + Action::CXXScopeTy *InlineScopeReps[4];
> +
> + /// The number of scope representations we've stored.
> + unsigned NumScopeReps;
> +
> + /// The number of scope representations we can store without
> + /// allocating new memory.
> + unsigned Capacity;
Can this just use SmallVector<Action::CXXScopeTy *,4> ? Why reinvent
it?
>
> +++ cfe/trunk/lib/AST/Type.cpp Wed Mar 18 19:18:19 2009
> @@ -96,6 +96,8 @@
> if (const ClassTemplateSpecializationType *Spec
> = dyn_cast<ClassTemplateSpecializationType>(this))
> return Spec->getCanonicalTypeInternal().getDesugaredType();
> + if (const QualifiedNameType *QualName =
> dyn_cast<QualifiedNameType>(this))
> + return QualName->getNamedType().getDesugaredType();
nit, only one space before the =.
Overall, this is an amazingly great improvement. I'm hacking on
features.html, after it goes in, when convenient, can you please add a
specific example from this? Maybe a simplified std::string or
std::vector<t> example?
-Chris
More information about the cfe-commits
mailing list