diff options
Diffstat (limited to 'include/clang/AST')
-rw-r--r-- | include/clang/AST/ASTContext.h | 7 | ||||
-rw-r--r-- | include/clang/AST/ASTImporter.h | 9 | ||||
-rw-r--r-- | include/clang/AST/CMakeLists.txt | 35 | ||||
-rw-r--r-- | include/clang/AST/Decl.h | 84 | ||||
-rw-r--r-- | include/clang/AST/DeclBase.h | 11 | ||||
-rw-r--r-- | include/clang/AST/DeclCXX.h | 218 | ||||
-rw-r--r-- | include/clang/AST/DeclGroup.h | 4 | ||||
-rw-r--r-- | include/clang/AST/DeclTemplate.h | 17 | ||||
-rw-r--r-- | include/clang/AST/Expr.h | 4 | ||||
-rw-r--r-- | include/clang/AST/ExprCXX.h | 77 | ||||
-rw-r--r-- | include/clang/AST/NestedNameSpecifier.h | 163 | ||||
-rw-r--r-- | include/clang/AST/RecursiveASTVisitor.h | 48 | ||||
-rw-r--r-- | include/clang/AST/Stmt.h | 3 |
13 files changed, 405 insertions, 275 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 0e88713..c0eeb5a 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -115,6 +115,7 @@ class ASTContext { llvm::FoldingSet<PackExpansionType> PackExpansionTypes; mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes; mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes; + mutable llvm::FoldingSet<AutoType> AutoTypes; llvm::FoldingSet<AttributedType> AttributedTypes; mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames; @@ -551,11 +552,6 @@ public: return cudaConfigureCallDecl; } - /// This gets the struct used to keep track of pointer to blocks, complete - /// with captured variables. - QualType getBlockParmType(bool BlockHasCopyDispose, - llvm::SmallVectorImpl<const Expr *> &Layout) const; - /// This builds the struct used for __block variables. QualType BuildByRefType(llvm::StringRef DeclName, QualType Ty) const; @@ -1525,7 +1521,6 @@ private: /// \brief A counter used to uniquely identify "blocks". mutable unsigned int UniqueBlockByRefTypeID; - mutable unsigned int UniqueBlockParmTypeID; friend class DeclContext; friend class DeclarationNameTable; diff --git a/include/clang/AST/ASTImporter.h b/include/clang/AST/ASTImporter.h index b659ce7..e153596 100644 --- a/include/clang/AST/ASTImporter.h +++ b/include/clang/AST/ASTImporter.h @@ -145,7 +145,14 @@ namespace clang { /// \returns the equivalent nested-name-specifier in the "to" /// context, or NULL if an error occurred. NestedNameSpecifier *Import(NestedNameSpecifier *FromNNS); - + + /// \brief Import the given nested-name-specifier from the "from" + /// context into the "to" context. + /// + /// \returns the equivalent nested-name-specifier in the "to" + /// context. + NestedNameSpecifierLoc Import(NestedNameSpecifierLoc FromNNS); + /// \brief Import the goven template name from the "from" context into the /// "to" context. TemplateName Import(TemplateName From); diff --git a/include/clang/AST/CMakeLists.txt b/include/clang/AST/CMakeLists.txt index 800c583..c10cda8 100644 --- a/include/clang/AST/CMakeLists.txt +++ b/include/clang/AST/CMakeLists.txt @@ -1,24 +1,17 @@ -set(LLVM_TARGET_DEFINITIONS ../Basic/Attr.td) -tablegen(Attrs.inc - -gen-clang-attr-classes - -I ${CMAKE_CURRENT_SOURCE_DIR}/../../) -add_custom_target(ClangAttrClasses - DEPENDS Attrs.inc) +clang_tablegen(Attrs.inc -gen-clang-attr-classes + -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ + SOURCE ../Basic/Attr.td + TARGET ClangAttrClasses) -tablegen(AttrImpl.inc - -gen-clang-attr-impl - -I ${CMAKE_CURRENT_SOURCE_DIR}/../../) -add_custom_target(ClangAttrImpl - DEPENDS AttrImpl.inc) +clang_tablegen(AttrImpl.inc -gen-clang-attr-impl + -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ + SOURCE ../Basic/Attr.td + TARGET ClangAttrImpl) -set(LLVM_TARGET_DEFINITIONS ../Basic/StmtNodes.td) -tablegen(StmtNodes.inc - -gen-clang-stmt-nodes) -add_custom_target(ClangStmtNodes - DEPENDS StmtNodes.inc) +clang_tablegen(StmtNodes.inc -gen-clang-stmt-nodes + SOURCE ../Basic/StmtNodes.td + TARGET ClangStmtNodes) -set(LLVM_TARGET_DEFINITIONS ../Basic/DeclNodes.td) -tablegen(DeclNodes.inc - -gen-clang-decl-nodes) -add_custom_target(ClangDeclNodes - DEPENDS DeclNodes.inc) +clang_tablegen(DeclNodes.inc -gen-clang-decl-nodes + SOURCE ../Basic/DeclNodes.td + TARGET ClangDeclNodes) diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index ee515da..31cee24 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -119,6 +119,14 @@ public: return getIdentifier() ? getIdentifier()->getName() : ""; } + llvm::StringRef getMessageUnavailableAttr(bool unavailable) const { + if (!unavailable) + return ""; + if (const UnavailableAttr *UA = getAttr<UnavailableAttr>()) + return UA->getMessage(); + return ""; + } + /// getNameAsString - Get a human-readable name for the declaration, even if /// it is one of the special kinds of names (C++ constructor, Objective-C /// selector, etc). Creating this name requires expensive string @@ -475,10 +483,7 @@ public: /// 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; + NestedNameSpecifierLoc QualifierLoc; /// NumTemplParamLists - The number of template parameter lists /// that were matched against the template-ids occurring into the NNS. unsigned NumTemplParamLists; @@ -487,8 +492,7 @@ struct QualifierInfo { TemplateParameterList** TemplParamLists; /// Default constructor. - QualifierInfo() - : NNS(0), NNSRange(), NumTemplParamLists(0), TemplParamLists(0) {} + QualifierInfo() : QualifierLoc(), NumTemplParamLists(0), TemplParamLists(0) {} /// setTemplateParameterListsInfo - Sets info about matched template /// parameter lists. void setTemplateParameterListsInfo(ASTContext &Context, @@ -545,14 +549,22 @@ public: return SourceRange(getOuterLocStart(), getLocation()); } + /// \brief Retrieve the nested-name-specifier that qualifies the name of this + /// declaration, if it was present in the source. NestedNameSpecifier *getQualifier() const { - return hasExtInfo() ? getExtInfo()->NNS : 0; + return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier() + : 0; } - SourceRange getQualifierRange() const { - return hasExtInfo() ? getExtInfo()->NNSRange : SourceRange(); + + /// \brief Retrieve the nested-name-specifier (with source-location + /// information) that qualifies the name of this declaration, if it was + /// present in the source. + NestedNameSpecifierLoc getQualifierLoc() const { + return hasExtInfo() ? getExtInfo()->QualifierLoc + : NestedNameSpecifierLoc(); } - void setQualifierInfo(NestedNameSpecifier *Qualifier, - SourceRange QualifierRange); + + void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc); unsigned getNumTemplateParameterLists() const { return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0; @@ -652,10 +664,6 @@ private: /// slot of its function, enabling the named return value optimization (NRVO). bool NRVOVariable : 1; - /// \brief Whether this variable has a deduced C++0x auto type for which we're - /// currently parsing the initializer. - bool ParsingAutoInit : 1; - friend class StmtIteratorBase; friend class ASTDeclReader; @@ -665,7 +673,7 @@ protected: StorageClass SCAsWritten) : DeclaratorDecl(DK, DC, L, Id, T, TInfo), Init(), ThreadSpecified(false), HasCXXDirectInit(false), - ExceptionVar(false), NRVOVariable(false), ParsingAutoInit(false) { + ExceptionVar(false), NRVOVariable(false) { SClass = SC; SClassAsWritten = SCAsWritten; } @@ -889,18 +897,6 @@ public: void setInit(Expr *I); - /// \brief Check whether we are in the process of parsing an initializer - /// needed to deduce the type of this variable. - bool isParsingAutoInit() const { - return ParsingAutoInit; - } - - /// \brief Note whether we are currently parsing an initializer needed to - /// deduce the type of this variable. - void setParsingAutoInit(bool P) { - ParsingAutoInit = P; - } - EvaluatedStmt *EnsureEvaluatedStmt() const { EvaluatedStmt *Eval = Init.dyn_cast<EvaluatedStmt *>(); if (!Eval) { @@ -1050,16 +1046,18 @@ public: }; class ImplicitParamDecl : public VarDecl { -protected: - ImplicitParamDecl(Kind DK, DeclContext *DC, SourceLocation L, - IdentifierInfo *Id, QualType Tw) - : VarDecl(DK, DC, L, Id, Tw, /*TInfo=*/0, SC_None, SC_None) { - setImplicit(); - } public: static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T); + + ImplicitParamDecl(DeclContext *DC, SourceLocation loc, + IdentifierInfo *name, QualType type) + : VarDecl(ImplicitParam, DC, loc, name, type, + /*tinfo*/ 0, SC_None, SC_None) { + setImplicit(); + } + // Implement isa/cast/dyncast/etc. static bool classof(const ImplicitParamDecl *D) { return true; } static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -2154,14 +2152,22 @@ public: void setTypedefForAnonDecl(TypedefDecl *TDD); + /// \brief Retrieve the nested-name-specifier that qualifies the name of this + /// declaration, if it was present in the source. NestedNameSpecifier *getQualifier() const { - return hasExtInfo() ? getExtInfo()->NNS : 0; + return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier() + : 0; } - SourceRange getQualifierRange() const { - return hasExtInfo() ? getExtInfo()->NNSRange : SourceRange(); + + /// \brief Retrieve the nested-name-specifier (with source-location + /// information) that qualifies the name of this declaration, if it was + /// present in the source. + NestedNameSpecifierLoc getQualifierLoc() const { + return hasExtInfo() ? getExtInfo()->QualifierLoc + : NestedNameSpecifierLoc(); } - void setQualifierInfo(NestedNameSpecifier *Qualifier, - SourceRange QualifierRange); + + void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc); unsigned getNumTemplateParameterLists() const { return hasExtInfo() ? getExtInfo()->NumTemplParamLists : 0; diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index bf249ce..b35d134 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -299,6 +299,13 @@ public: return const_cast<Decl*>(this)->getDeclContext(); } + /// Finds the innermost non-closure context of this declaration. + /// That is, walk out the DeclContext chain, skipping any blocks. + DeclContext *getNonClosureContext(); + const DeclContext *getNonClosureContext() const { + return const_cast<Decl*>(this)->getNonClosureContext(); + } + TranslationUnitDecl *getTranslationUnitDecl(); const TranslationUnitDecl *getTranslationUnitDecl() const { return const_cast<Decl*>(this)->getTranslationUnitDecl(); @@ -787,6 +794,10 @@ public: return cast<Decl>(this)->getASTContext(); } + bool isClosure() const { + return DeclKind == Decl::Block; + } + bool isFunctionOrMethod() const { switch (DeclKind) { case Decl::Block: diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index d11ee8f..1656a7e 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -1741,13 +1741,8 @@ class UsingDirectiveDecl : public NamedDecl { /// SourceLocation - Location of 'namespace' token. SourceLocation NamespaceLoc; - /// \brief The source range that covers the nested-name-specifier - /// preceding the namespace name. - SourceRange QualifierRange; - - /// \brief The nested-name-specifier that precedes the namespace - /// name, if any. - NestedNameSpecifier *Qualifier; + /// \brief The nested-name-specifier that precedes the namespace. + NestedNameSpecifierLoc QualifierLoc; /// NominatedNamespace - Namespace nominated by using-directive. NamedDecl *NominatedNamespace; @@ -1765,25 +1760,24 @@ class UsingDirectiveDecl : public NamedDecl { UsingDirectiveDecl(DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespcLoc, - SourceRange QualifierRange, - NestedNameSpecifier *Qualifier, + NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor) : NamedDecl(UsingDirective, DC, IdentLoc, getName()), UsingLoc(UsingLoc), - NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange), - Qualifier(Qualifier), NominatedNamespace(Nominated), - CommonAncestor(CommonAncestor) { - } + NamespaceLoc(NamespcLoc), QualifierLoc(QualifierLoc), + NominatedNamespace(Nominated), CommonAncestor(CommonAncestor) { } public: - /// \brief Retrieve the source range of the nested-name-specifier - /// that qualifies the namespace name. - SourceRange getQualifierRange() const { return QualifierRange; } - + /// \brief Retrieve the nested-name-specifier that qualifies the + /// name of the namespace, with source-location information. + NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } + /// \brief Retrieve the nested-name-specifier that qualifies the /// name of the namespace. - NestedNameSpecifier *getQualifier() const { return Qualifier; } + NestedNameSpecifier *getQualifier() const { + return QualifierLoc.getNestedNameSpecifier(); + } NamedDecl *getNominatedNamespaceAsWritten() { return NominatedNamespace; } const NamedDecl *getNominatedNamespaceAsWritten() const { @@ -1815,8 +1809,7 @@ public: static UsingDirectiveDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, - SourceRange QualifierRange, - NestedNameSpecifier *Qualifier, + NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor); @@ -1844,49 +1837,37 @@ class NamespaceAliasDecl : public NamedDecl { /// \brief The location of the "namespace" keyword. SourceLocation NamespaceLoc; - /// \brief The source range that covers the nested-name-specifier - /// preceding the namespace name. - SourceRange QualifierRange; - - /// \brief The nested-name-specifier that precedes the namespace - /// name, if any. - NestedNameSpecifier *Qualifier; - /// IdentLoc - Location of namespace identifier. Accessed by TargetNameLoc. SourceLocation IdentLoc; - + + /// \brief The nested-name-specifier that precedes the namespace. + NestedNameSpecifierLoc QualifierLoc; + /// Namespace - The Decl that this alias points to. Can either be a /// NamespaceDecl or a NamespaceAliasDecl. NamedDecl *Namespace; NamespaceAliasDecl(DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, - SourceRange QualifierRange, - NestedNameSpecifier *Qualifier, + NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace) : NamedDecl(NamespaceAlias, DC, AliasLoc, Alias), - NamespaceLoc(NamespaceLoc), QualifierRange(QualifierRange), - Qualifier(Qualifier), IdentLoc(IdentLoc), Namespace(Namespace) { } + NamespaceLoc(NamespaceLoc), IdentLoc(IdentLoc), + QualifierLoc(QualifierLoc), Namespace(Namespace) { } friend class ASTDeclReader; public: - /// \brief Retrieve the source range of the nested-name-specifier - /// that qualifiers the namespace name. - SourceRange getQualifierRange() const { return QualifierRange; } - - /// \brief Set the source range of the nested-name-specifier that qualifies - /// the namespace name. - void setQualifierRange(SourceRange R) { QualifierRange = R; } - + /// \brief Retrieve the nested-name-specifier that qualifies the + /// name of the namespace, with source-location information. + NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } + /// \brief Retrieve the nested-name-specifier that qualifies the /// name of the namespace. - NestedNameSpecifier *getQualifier() const { return Qualifier; } - - /// \brief Set the nested-name-specifier that qualifies the name of the - /// namespace. - void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } - + NestedNameSpecifier *getQualifier() const { + return QualifierLoc.getNestedNameSpecifier(); + } + /// \brief Retrieve the namespace declaration aliased by this directive. NamespaceDecl *getNamespace() { if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(Namespace)) @@ -1917,8 +1898,7 @@ public: SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, - SourceRange QualifierRange, - NestedNameSpecifier *Qualifier, + NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace); @@ -2002,15 +1982,11 @@ public: /// UsingDecl - Represents a C++ using-declaration. For example: /// using someNameSpace::someIdentifier; class UsingDecl : public NamedDecl { - /// \brief The source range that covers the nested-name-specifier - /// preceding the declaration name. - SourceRange NestedNameRange; - /// \brief The source location of the "using" location itself. SourceLocation UsingLocation; - /// \brief Target nested name specifier. - NestedNameSpecifier* TargetNestedName; + /// \brief The nested-name-specifier that precedes the name. + NestedNameSpecifierLoc QualifierLoc; /// DNLoc - Provides source/type location info for the /// declaration name embedded in the ValueDecl base class. @@ -2023,37 +1999,34 @@ class UsingDecl : public NamedDecl { // \brief Has 'typename' keyword. bool IsTypeName; - UsingDecl(DeclContext *DC, SourceRange NNR, - SourceLocation UL, NestedNameSpecifier* TargetNNS, + UsingDecl(DeclContext *DC, SourceLocation UL, + NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool IsTypeNameArg) : NamedDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()), - NestedNameRange(NNR), UsingLocation(UL), TargetNestedName(TargetNNS), + UsingLocation(UL), QualifierLoc(QualifierLoc), DNLoc(NameInfo.getInfo()), FirstUsingShadow(0),IsTypeName(IsTypeNameArg) { } public: - /// \brief Returns the source range that covers the nested-name-specifier - /// preceding the namespace name. - SourceRange getNestedNameRange() const { return NestedNameRange; } - - /// \brief Set the source range of the nested-name-specifier. - void setNestedNameRange(SourceRange R) { NestedNameRange = R; } - - // FIXME: Naming is inconsistent with other get*Loc functions. /// \brief Returns the source location of the "using" keyword. SourceLocation getUsingLocation() const { return UsingLocation; } /// \brief Set the source location of the 'using' keyword. void setUsingLocation(SourceLocation L) { UsingLocation = L; } - /// \brief Get the target nested name declaration. - NestedNameSpecifier* getTargetNestedNameDecl() const { - return TargetNestedName; + /// \brief Retrieve the nested-name-specifier that qualifies the name, + /// with source-location information. + NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } + + /// \brief Retrieve the nested-name-specifier that qualifies the name. + NestedNameSpecifier *getQualifier() const { + return QualifierLoc.getNestedNameSpecifier(); } - /// \brief Set the target nested name declaration. - void setTargetNestedNameDecl(NestedNameSpecifier *NNS) { - TargetNestedName = NNS; + /// \brief Retrieve the source range of the nested-name-specifier + /// that qualifies the name. + SourceRange getQualifierRange() const { + return QualifierLoc.getSourceRange(); } DeclarationNameInfo getNameInfo() const { @@ -2119,8 +2092,8 @@ public: void removeShadowDecl(UsingShadowDecl *S); static UsingDecl *Create(ASTContext &C, DeclContext *DC, - SourceRange NNR, SourceLocation UsingL, - NestedNameSpecifier* TargetNNS, + SourceLocation UsingL, + NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool IsTypeNameArg); @@ -2145,61 +2118,55 @@ public: /// using Base<T>::foo; /// }; class UnresolvedUsingValueDecl : public ValueDecl { - /// \brief The source range that covers the nested-name-specifier - /// preceding the declaration name. - SourceRange TargetNestedNameRange; - /// \brief The source location of the 'using' keyword SourceLocation UsingLocation; - NestedNameSpecifier *TargetNestedNameSpecifier; + /// \brief The nested-name-specifier that precedes the name. + NestedNameSpecifierLoc QualifierLoc; /// DNLoc - Provides source/type location info for the /// declaration name embedded in the ValueDecl base class. DeclarationNameLoc DNLoc; UnresolvedUsingValueDecl(DeclContext *DC, QualType Ty, - SourceLocation UsingLoc, SourceRange TargetNNR, - NestedNameSpecifier *TargetNNS, + SourceLocation UsingLoc, + NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo) : ValueDecl(UnresolvedUsingValue, DC, NameInfo.getLoc(), NameInfo.getName(), Ty), - TargetNestedNameRange(TargetNNR), UsingLocation(UsingLoc), - TargetNestedNameSpecifier(TargetNNS), DNLoc(NameInfo.getInfo()) + UsingLocation(UsingLoc), QualifierLoc(QualifierLoc), + DNLoc(NameInfo.getInfo()) { } public: - /// \brief Returns the source range that covers the nested-name-specifier - /// preceding the namespace name. - SourceRange getTargetNestedNameRange() const { return TargetNestedNameRange; } - - /// \brief Set the source range coverting the nested-name-specifier preceding - /// the namespace name. - void setTargetNestedNameRange(SourceRange R) { TargetNestedNameRange = R; } - - /// \brief Get target nested name declaration. - NestedNameSpecifier* getTargetNestedNameSpecifier() const { - return TargetNestedNameSpecifier; - } - - /// \brief Set the nested name declaration. - void setTargetNestedNameSpecifier(NestedNameSpecifier* NNS) { - TargetNestedNameSpecifier = NNS; - } - /// \brief Returns the source location of the 'using' keyword. SourceLocation getUsingLoc() const { return UsingLocation; } /// \brief Set the source location of the 'using' keyword. void setUsingLoc(SourceLocation L) { UsingLocation = L; } + /// \brief Retrieve the nested-name-specifier that qualifies the name, + /// with source-location information. + NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } + + /// \brief Retrieve the nested-name-specifier that qualifies the name. + NestedNameSpecifier *getQualifier() const { + return QualifierLoc.getNestedNameSpecifier(); + } + + /// \brief Retrieve the source range of the nested-name-specifier + /// that qualifies the name. + SourceRange getQualifierRange() const { + return QualifierLoc.getSourceRange(); + } + DeclarationNameInfo getNameInfo() const { return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); } static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, - SourceRange TargetNNR, NestedNameSpecifier *TargetNNS, + NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo); SourceRange getSourceRange() const { @@ -2224,49 +2191,52 @@ public: /// The type associated with a unresolved using typename decl is /// currently always a typename type. class UnresolvedUsingTypenameDecl : public TypeDecl { - /// \brief The source range that covers the nested-name-specifier - /// preceding the declaration name. - SourceRange TargetNestedNameRange; - /// \brief The source location of the 'using' keyword SourceLocation UsingLocation; /// \brief The source location of the 'typename' keyword SourceLocation TypenameLocation; - NestedNameSpecifier *TargetNestedNameSpecifier; + /// \brief The nested-name-specifier that precedes the name. + NestedNameSpecifierLoc QualifierLoc; UnresolvedUsingTypenameDecl(DeclContext *DC, SourceLocation UsingLoc, - SourceLocation TypenameLoc, - SourceRange TargetNNR, NestedNameSpecifier *TargetNNS, - SourceLocation TargetNameLoc, IdentifierInfo *TargetName) + SourceLocation TypenameLoc, + NestedNameSpecifierLoc QualifierLoc, + SourceLocation TargetNameLoc, + IdentifierInfo *TargetName) : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName), - TargetNestedNameRange(TargetNNR), UsingLocation(UsingLoc), - TypenameLocation(TypenameLoc), TargetNestedNameSpecifier(TargetNNS) - { } + UsingLocation(UsingLoc), TypenameLocation(TypenameLoc), + QualifierLoc(QualifierLoc) { } friend class ASTDeclReader; public: - /// \brief Returns the source range that covers the nested-name-specifier - /// preceding the namespace name. - SourceRange getTargetNestedNameRange() const { return TargetNestedNameRange; } - - /// \brief Get target nested name declaration. - NestedNameSpecifier* getTargetNestedNameSpecifier() { - return TargetNestedNameSpecifier; - } - /// \brief Returns the source location of the 'using' keyword. SourceLocation getUsingLoc() const { return UsingLocation; } /// \brief Returns the source location of the 'typename' keyword. SourceLocation getTypenameLoc() const { return TypenameLocation; } + /// \brief Retrieve the nested-name-specifier that qualifies the name, + /// with source-location information. + NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } + + /// \brief Retrieve the nested-name-specifier that qualifies the name. + NestedNameSpecifier *getQualifier() const { + return QualifierLoc.getNestedNameSpecifier(); + } + + /// \brief Retrieve the source range of the nested-name-specifier + /// that qualifies the name. + SourceRange getQualifierRange() const { + return QualifierLoc.getSourceRange(); + } + + // FIXME: DeclarationNameInfo static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, - SourceLocation TypenameLoc, - SourceRange TargetNNR, NestedNameSpecifier *TargetNNS, + SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName); SourceRange getSourceRange() const { diff --git a/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h index cb9e168..63cdac5 100644 --- a/include/clang/AST/DeclGroup.h +++ b/include/clang/AST/DeclGroup.h @@ -39,12 +39,12 @@ public: Decl*& operator[](unsigned i) { assert (i < NumDecls && "Out-of-bounds access."); - return *((Decl**) (this+1)); + return ((Decl**) (this+1))[i]; } Decl* const& operator[](unsigned i) const { assert (i < NumDecls && "Out-of-bounds access."); - return *((Decl* const*) (this+1)); + return ((Decl* const*) (this+1))[i]; } }; diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 176c6ba..f41859c 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -48,6 +48,7 @@ class TemplateParameterList { /// parameter list. unsigned NumParams; +protected: TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, NamedDecl **Params, unsigned NumParams, SourceLocation RAngleLoc); @@ -107,6 +108,19 @@ public: } }; +/// FixedSizeTemplateParameterList - Stores a list of template parameters for a +/// TemplateDecl and its derived classes. Suitable for creating on the stack. +template<size_t N> +class FixedSizeTemplateParameterList : public TemplateParameterList { + NamedDecl *Params[N]; + +public: + FixedSizeTemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, + NamedDecl **Params, SourceLocation RAngleLoc) : + TemplateParameterList(TemplateLoc, LAngleLoc, Params, N, RAngleLoc) { + } +}; + /// \brief A template argument list. class TemplateArgumentList { /// \brief The template argument list. @@ -914,6 +928,9 @@ class TemplateTypeParmDecl : public TypeDecl { TypeForDecl = Type.getTypePtrOrNull(); } + /// Sema creates these on the stack during auto type deduction. + friend class Sema; + public: static TemplateTypeParmDecl *Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index a17205c..95bfad5 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1843,9 +1843,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { - return SourceRange(getCallee()->getLocStart(), RParenLoc); - } + SourceRange getSourceRange() const; static bool classof(const Stmt *T) { return T->getStmtClass() >= firstCallExprConstant && diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 85ce962..225db3c 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -108,8 +108,6 @@ public: /// FIXME: Returns 0 for member pointer call exprs. CXXRecordDecl *getRecordDecl(); - SourceRange getSourceRange() const; - static bool classof(const Stmt *T) { return T->getStmtClass() == CXXMemberCallExprClass; } @@ -1333,13 +1331,9 @@ class CXXPseudoDestructorExpr : public Expr { /// \brief The location of the '.' or '->' operator. SourceLocation OperatorLoc; - + /// \brief The nested-name-specifier that follows the operator, if present. - NestedNameSpecifier *Qualifier; - - /// \brief The source range that covers the nested-name-specifier, if - /// present. - SourceRange QualifierRange; + NestedNameSpecifierLoc QualifierLoc; /// \brief The type that precedes the '::' in a qualified pseudo-destructor /// expression. @@ -1356,11 +1350,12 @@ class CXXPseudoDestructorExpr : public Expr { /// resolve the name. PseudoDestructorTypeStorage DestroyedType; + friend class ASTStmtReader; + public: CXXPseudoDestructorExpr(ASTContext &Context, Expr *Base, bool isArrow, SourceLocation OperatorLoc, - NestedNameSpecifier *Qualifier, - SourceRange QualifierRange, + NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc, SourceLocation TildeLoc, @@ -1368,36 +1363,32 @@ public: explicit CXXPseudoDestructorExpr(EmptyShell Shell) : Expr(CXXPseudoDestructorExprClass, Shell), - Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { } + Base(0), IsArrow(false), QualifierLoc(), ScopeType(0) { } - void setBase(Expr *E) { Base = E; } Expr *getBase() const { return cast<Expr>(Base); } /// \brief Determines whether this member expression actually had /// a C++ nested-name-specifier prior to the name of the member, e.g., /// x->Base::foo. - bool hasQualifier() const { return Qualifier != 0; } - - /// \brief If the member name was qualified, retrieves the source range of - /// the nested-name-specifier that precedes the member name. Otherwise, - /// returns an empty source range. - SourceRange getQualifierRange() const { return QualifierRange; } - void setQualifierRange(SourceRange R) { QualifierRange = R; } + bool hasQualifier() const { return QualifierLoc; } + /// \brief Retrieves the nested-name-specifier that qualifies the type name, + /// with source-location information. + NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } + /// \brief If the member name was qualified, retrieves the /// nested-name-specifier that precedes the member name. Otherwise, returns /// NULL. - NestedNameSpecifier *getQualifier() const { return Qualifier; } - void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } + NestedNameSpecifier *getQualifier() const { + return QualifierLoc.getNestedNameSpecifier(); + } /// \brief Determine whether this pseudo-destructor expression was written /// using an '->' (otherwise, it used a '.'). bool isArrow() const { return IsArrow; } - void setArrow(bool A) { IsArrow = A; } /// \brief Retrieve the location of the '.' or '->' operator. SourceLocation getOperatorLoc() const { return OperatorLoc; } - void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } /// \brief Retrieve the scope type in a qualified pseudo-destructor /// expression. @@ -1409,16 +1400,13 @@ public: /// nested-name-specifier. It is stored as the "scope type" of the pseudo- /// destructor expression. TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; } - void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; } /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor /// expression. SourceLocation getColonColonLoc() const { return ColonColonLoc; } - void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; } /// \brief Retrieve the location of the '~'. SourceLocation getTildeLoc() const { return TildeLoc; } - void setTildeLoc(SourceLocation L) { TildeLoc = L; } /// \brief Retrieve the source location information for the type /// being destroyed. @@ -1885,30 +1873,24 @@ public: /// ("value"). Such expressions will instantiate to a DeclRefExpr once the /// declaration can be found. class DependentScopeDeclRefExpr : public Expr { - /// The name of the entity we will be referencing. - DeclarationNameInfo NameInfo; - - /// QualifierRange - The source range that covers the - /// nested-name-specifier. - SourceRange QualifierRange; - /// \brief The nested-name-specifier that qualifies this unresolved /// declaration name. - NestedNameSpecifier *Qualifier; + NestedNameSpecifierLoc QualifierLoc; + + /// The name of the entity we will be referencing. + DeclarationNameInfo NameInfo; /// \brief Whether the name includes explicit template arguments. bool HasExplicitTemplateArgs; DependentScopeDeclRefExpr(QualType T, - NestedNameSpecifier *Qualifier, - SourceRange QualifierRange, + NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *Args); public: static DependentScopeDeclRefExpr *Create(ASTContext &C, - NestedNameSpecifier *Qualifier, - SourceRange QualifierRange, + NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs = 0); @@ -1918,24 +1900,23 @@ public: /// \brief Retrieve the name that this expression refers to. const DeclarationNameInfo &getNameInfo() const { return NameInfo; } - void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; } /// \brief Retrieve the name that this expression refers to. DeclarationName getDeclName() const { return NameInfo.getName(); } - void setDeclName(DeclarationName N) { NameInfo.setName(N); } /// \brief Retrieve the location of the name within the expression. SourceLocation getLocation() const { return NameInfo.getLoc(); } - void setLocation(SourceLocation L) { NameInfo.setLoc(L); } - - /// \brief Retrieve the source range of the nested-name-specifier. - SourceRange getQualifierRange() const { return QualifierRange; } - void setQualifierRange(SourceRange R) { QualifierRange = R; } + /// \brief Retrieve the nested-name-specifier that qualifies the + /// name, with source location information. + NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } + + /// \brief Retrieve the nested-name-specifier that qualifies this /// declaration. - NestedNameSpecifier *getQualifier() const { return Qualifier; } - void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } + NestedNameSpecifier *getQualifier() const { + return QualifierLoc.getNestedNameSpecifier(); + } /// Determines whether this lookup had explicit template arguments. bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } @@ -1986,7 +1967,7 @@ public: } SourceRange getSourceRange() const { - SourceRange Range(QualifierRange.getBegin(), getLocation()); + SourceRange Range(QualifierLoc.getBeginLoc(), getLocation()); if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc()); return Range; diff --git a/include/clang/AST/NestedNameSpecifier.h b/include/clang/AST/NestedNameSpecifier.h index 99cc1f2..024bf40 100644 --- a/include/clang/AST/NestedNameSpecifier.h +++ b/include/clang/AST/NestedNameSpecifier.h @@ -25,10 +25,12 @@ namespace llvm { namespace clang { class ASTContext; +class NamespaceAliasDecl; class NamespaceDecl; class IdentifierInfo; struct PrintingPolicy; class Type; +class TypeLoc; class LangOptions; /// \brief Represents a C++ nested name specifier, such as @@ -41,13 +43,22 @@ class LangOptions; /// (for dependent names), or the global specifier ('::', must be the /// first specifier). class NestedNameSpecifier : public llvm::FoldingSetNode { + + /// \brief Enumeration describing + enum StoredSpecifierKind { + StoredIdentifier = 0, + StoredNamespaceOrAlias = 1, + StoredTypeSpec = 2, + StoredTypeSpecWithTemplate = 3 + }; + /// \brief The nested name specifier that precedes this nested name /// specifier. /// /// The pointer is the nested-name-specifier that precedes this /// one. The integer stores one of the first four values of type /// SpecifierKind. - llvm::PointerIntPair<NestedNameSpecifier *, 2> Prefix; + llvm::PointerIntPair<NestedNameSpecifier *, 2, StoredSpecifierKind> Prefix; /// \brief The last component in the nested name specifier, which /// can be an identifier, a declaration, or a type. @@ -63,21 +74,23 @@ public: /// specifier. enum SpecifierKind { /// \brief An identifier, stored as an IdentifierInfo*. - Identifier = 0, - /// \brief A namespace, stored as a Namespace*. - Namespace = 1, + Identifier, + /// \brief A namespace, stored as a NamespaceDecl*. + Namespace, + /// \brief A namespace alias, stored as a NamespaceAliasDecl*. + NamespaceAlias, /// \brief A type, stored as a Type*. - TypeSpec = 2, + TypeSpec, /// \brief A type that was preceded by the 'template' keyword, /// stored as a Type*. - TypeSpecWithTemplate = 3, + TypeSpecWithTemplate, /// \brief The global specifier '::'. There is no stored value. - Global = 4 + Global }; private: /// \brief Builds the global specifier. - NestedNameSpecifier() : Prefix(0, 0), Specifier(0) { } + NestedNameSpecifier() : Prefix(0, StoredIdentifier), Specifier(0) { } /// \brief Copy constructor used internally to clone nested name /// specifiers. @@ -108,6 +121,11 @@ public: NestedNameSpecifier *Prefix, NamespaceDecl *NS); + /// \brief Builds a nested name specifier that names a namespace alias. + static NestedNameSpecifier *Create(const ASTContext &Context, + NestedNameSpecifier *Prefix, + NamespaceAliasDecl *Alias); + /// \brief Builds a nested name specifier that names a type. static NestedNameSpecifier *Create(const ASTContext &Context, NestedNameSpecifier *Prefix, @@ -136,16 +154,12 @@ public: NestedNameSpecifier *getPrefix() const { return Prefix.getPointer(); } /// \brief Determine what kind of nested name specifier is stored. - SpecifierKind getKind() const { - if (Specifier == 0) - return Global; - return (SpecifierKind)Prefix.getInt(); - } + SpecifierKind getKind() const; /// \brief Retrieve the identifier stored in this nested name /// specifier. IdentifierInfo *getAsIdentifier() const { - if (Prefix.getInt() == Identifier) + if (Prefix.getInt() == StoredIdentifier) return (IdentifierInfo *)Specifier; return 0; @@ -153,17 +167,16 @@ public: /// \brief Retrieve the namespace stored in this nested name /// specifier. - NamespaceDecl *getAsNamespace() const { - if (Prefix.getInt() == Namespace) - return (NamespaceDecl *)Specifier; + NamespaceDecl *getAsNamespace() const; - return 0; - } + /// \brief Retrieve the namespace alias stored in this nested name + /// specifier. + NamespaceAliasDecl *getAsNamespaceAlias() const; /// \brief Retrieve the type stored in this nested name specifier. const Type *getAsType() const { - if (Prefix.getInt() == TypeSpec || - Prefix.getInt() == TypeSpecWithTemplate) + if (Prefix.getInt() == StoredTypeSpec || + Prefix.getInt() == StoredTypeSpecWithTemplate) return (const Type *)Specifier; return 0; @@ -191,6 +204,114 @@ public: void dump(const LangOptions &LO); }; +/// \brief A C++ nested-name-specifier augmented with source location +/// information. +class NestedNameSpecifierLoc { + NestedNameSpecifier *Qualifier; + void *Data; + + /// \brief Determines the data length for the last component in the + /// given nested-name-specifier. + static unsigned getLocalDataLength(NestedNameSpecifier *Qualifier); + + /// \brief Determines the data length for the entire + /// nested-name-specifier. + static unsigned getDataLength(NestedNameSpecifier *Qualifier); + +public: + /// \brief Construct an empty nested-name-specifier. + NestedNameSpecifierLoc() : Qualifier(0), Data(0) { } + + /// \brief Construct a nested-name-specifier with source location information + /// from + NestedNameSpecifierLoc(NestedNameSpecifier *Qualifier, void *Data) + : Qualifier(Qualifier), Data(Data) { } + + /// \brief Evalutes true when this nested-name-specifier location is + /// non-empty. + operator bool() const { return Qualifier; } + + /// \brief Retrieve the nested-name-specifier to which this instance + /// refers. + NestedNameSpecifier *getNestedNameSpecifier() const { + return Qualifier; + } + + /// \brief Retrieve the opaque pointer that refers to source-location data. + void *getOpaqueData() const { return Data; } + + /// \brief Retrieve the source range covering the entirety of this + /// nested-name-specifier. + /// + /// For example, if this instance refers to a nested-name-specifier + /// \c ::std::vector<int>::, the returned source range would cover + /// from the initial '::' to the last '::'. + SourceRange getSourceRange() const; + + /// \brief Retrieve the source range covering just the last part of + /// this nested-name-specifier, not including the prefix. + /// + /// For example, if this instance refers to a nested-name-specifier + /// \c ::std::vector<int>::, the returned source range would cover + /// from "vector" to the last '::'. + SourceRange getLocalSourceRange() const; + + /// \brief Retrieve the location of the beginning of this + /// nested-name-specifier. + SourceLocation getBeginLoc() const { + return getSourceRange().getBegin(); + } + + /// \brief Retrieve the location of the end of this + /// nested-name-specifier. + SourceLocation getEndLoc() const { + return getSourceRange().getEnd(); + } + + /// \brief Retrieve the location of the beginning of this + /// component of the nested-name-specifier. + SourceLocation getLocalBeginLoc() const { + return getLocalSourceRange().getBegin(); + } + + /// \brief Retrieve the location of the end of this component of the + /// nested-name-specifier. + SourceLocation getLocalEndLoc() const { + return getLocalSourceRange().getEnd(); + } + + /// \brief Return the prefix of this nested-name-specifier. + /// + /// For example, if this instance refers to a nested-name-specifier + /// \c ::std::vector<int>::, the prefix is \c ::std::. Note that the + /// returned prefix may be empty, if this is the first component of + /// the nested-name-specifier. + NestedNameSpecifierLoc getPrefix() const { + if (!Qualifier) + return *this; + + return NestedNameSpecifierLoc(Qualifier->getPrefix(), Data); + } + + /// \brief For a nested-name-specifier that refers to a type, + /// retrieve the type with source-location information. + TypeLoc getTypeLoc() const; + + /// \brief Determines the data length for the entire + /// nested-name-specifier. + unsigned getDataLength() const { return getDataLength(Qualifier); } + + friend bool operator==(NestedNameSpecifierLoc X, + NestedNameSpecifierLoc Y) { + return X.Qualifier == Y.Qualifier && X.Data == Y.Data; + } + + friend bool operator!=(NestedNameSpecifierLoc X, + NestedNameSpecifierLoc Y) { + return !(X == Y); + } +}; + /// Insertion operator for diagnostics. This allows sending NestedNameSpecifiers /// into a diagnostic with <<. inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 921b799..e85b6dc 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -181,6 +181,12 @@ public: /// \returns false if the visitation was terminated early, true otherwise. bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS); + /// \brief Recursively visit a C++ nested-name-specifier with location + /// information. + /// + /// \returns false if the visitation was terminated early, true otherwise. + bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS); + /// \brief Recursively visit a template name and dispatch to the /// appropriate method. /// @@ -502,6 +508,7 @@ bool RecursiveASTVisitor<Derived>::TraverseNestedNameSpecifier( switch (NNS->getKind()) { case NestedNameSpecifier::Identifier: case NestedNameSpecifier::Namespace: + case NestedNameSpecifier::NamespaceAlias: case NestedNameSpecifier::Global: return true; @@ -514,6 +521,31 @@ bool RecursiveASTVisitor<Derived>::TraverseNestedNameSpecifier( } template<typename Derived> +bool RecursiveASTVisitor<Derived>::TraverseNestedNameSpecifierLoc( + NestedNameSpecifierLoc NNS) { + if (!NNS) + return true; + + if (NestedNameSpecifierLoc Prefix = NNS.getPrefix()) + TRY_TO(TraverseNestedNameSpecifierLoc(Prefix)); + + switch (NNS.getNestedNameSpecifier()->getKind()) { + case NestedNameSpecifier::Identifier: + case NestedNameSpecifier::Namespace: + case NestedNameSpecifier::NamespaceAlias: + case NestedNameSpecifier::Global: + return true; + + case NestedNameSpecifier::TypeSpec: + case NestedNameSpecifier::TypeSpecWithTemplate: + TRY_TO(TraverseTypeLoc(NNS.getTypeLoc())); + break; + } + + return true; +} + +template<typename Derived> bool RecursiveASTVisitor<Derived>::TraverseTemplateName(TemplateName Template) { if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier())); @@ -1142,11 +1174,11 @@ DEF_TRAVERSE_DECL(ObjCPropertyDecl, { }) DEF_TRAVERSE_DECL(UsingDecl, { - TRY_TO(TraverseNestedNameSpecifier(D->getTargetNestedNameDecl())); + TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); }) DEF_TRAVERSE_DECL(UsingDirectiveDecl, { - TRY_TO(TraverseNestedNameSpecifier(D->getQualifier())); + TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); }) DEF_TRAVERSE_DECL(UsingShadowDecl, { }) @@ -1312,7 +1344,7 @@ DEF_TRAVERSE_DECL(TypedefDecl, { DEF_TRAVERSE_DECL(UnresolvedUsingTypenameDecl, { // A dependent using declaration which was marked with 'typename'. // template<class T> class A : public B<T> { using typename B<T>::foo; }; - TRY_TO(TraverseNestedNameSpecifier(D->getTargetNestedNameSpecifier())); + TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); // We shouldn't traverse D->getTypeForDecl(); it's a result of // declaring the type, not something that was written in the // source. @@ -1425,7 +1457,7 @@ DEF_TRAVERSE_DECL(EnumConstantDecl, { DEF_TRAVERSE_DECL(UnresolvedUsingValueDecl, { // Like UnresolvedUsingTypenameDecl, but without the 'typename': // template <class T> Class A : public Base<T> { using Base<T>::foo; }; - TRY_TO(TraverseNestedNameSpecifier(D->getTargetNestedNameSpecifier())); + TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); }) DEF_TRAVERSE_DECL(IndirectFieldDecl, {}) @@ -1660,20 +1692,18 @@ DEF_TRAVERSE_STMT(CXXDependentScopeMemberExpr, { }) DEF_TRAVERSE_STMT(DeclRefExpr, { + TRY_TO(TraverseNestedNameSpecifier(S->getQualifier())); TRY_TO(TraverseTemplateArgumentLocsHelper( S->getTemplateArgs(), S->getNumTemplateArgs())); - // FIXME: Should we be recursing on the qualifier? - TRY_TO(TraverseNestedNameSpecifier(S->getQualifier())); }) DEF_TRAVERSE_STMT(DependentScopeDeclRefExpr, { - // FIXME: Should we be recursing on these two things? + TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); if (S->hasExplicitTemplateArgs()) { TRY_TO(TraverseTemplateArgumentLocsHelper( S->getExplicitTemplateArgs().getTemplateArgs(), S->getNumTemplateArgs())); } - TRY_TO(TraverseNestedNameSpecifier(S->getQualifier())); }) DEF_TRAVERSE_STMT(MemberExpr, { @@ -1814,7 +1844,7 @@ DEF_TRAVERSE_STMT(CXXDeleteExpr, { }) DEF_TRAVERSE_STMT(ExprWithCleanups, { }) DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, { }) DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, { - TRY_TO(TraverseNestedNameSpecifier(S->getQualifier())); + TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo()) TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc())); if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo()) diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 7ede9ce..d1f7d66 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1328,7 +1328,8 @@ public: } Expr *getInputExpr(unsigned i); - + void setInputExpr(unsigned i, Expr *E); + const Expr *getInputExpr(unsigned i) const { return const_cast<AsmStmt*>(this)->getInputExpr(i); } |