Fixing 80 col violations (& removing any trailing whitespace on files I was touching anyway)

llvm-svn: 144171
This commit is contained in:
David Blaikie 2011-11-09 06:07:30 +00:00
parent 8569b53e81
commit 21bfbf8d7c
33 changed files with 1907 additions and 1844 deletions

View File

@ -99,7 +99,9 @@ public:
/// \brief If the consumer is interested in entities being deserialized from /// \brief If the consumer is interested in entities being deserialized from
/// AST files, it should return a pointer to a ASTDeserializationListener here /// AST files, it should return a pointer to a ASTDeserializationListener here
virtual ASTDeserializationListener *GetASTDeserializationListener() { return 0; } virtual ASTDeserializationListener *GetASTDeserializationListener() {
return 0;
}
/// PrintStats - If desired, print any statistics. /// PrintStats - If desired, print any statistics.
virtual void PrintStats() {} virtual void PrintStats() {}

View File

@ -185,13 +185,13 @@ public:
/// \brief Whether this declaration was marked as being private to the /// \brief Whether this declaration was marked as being private to the
/// module in which it was defined. /// module in which it was defined.
bool isModulePrivate() const { return ModulePrivate; } bool isModulePrivate() const { return ModulePrivate; }
/// \brief Specify whether this declaration was marked as being private /// \brief Specify whether this declaration was marked as being private
/// to the module in which it was defined. /// to the module in which it was defined.
void setModulePrivate(bool MP = true) { void setModulePrivate(bool MP = true) {
ModulePrivate = MP; ModulePrivate = MP;
} }
/// \brief Determine whether this declaration is a C++ class member. /// \brief Determine whether this declaration is a C++ class member.
bool isCXXClassMember() const { bool isCXXClassMember() const {
const DeclContext *DC = getDeclContext(); const DeclContext *DC = getDeclContext();
@ -281,7 +281,9 @@ public:
Linkage getLinkage() const; Linkage getLinkage() const;
/// \brief Determines the visibility of this entity. /// \brief Determines the visibility of this entity.
Visibility getVisibility() const { return getLinkageAndVisibility().visibility(); } Visibility getVisibility() const {
return getLinkageAndVisibility().visibility();
}
/// \brief Determines the linkage and visibility of this entity. /// \brief Determines the linkage and visibility of this entity.
LinkageInfo getLinkageAndVisibility() const; LinkageInfo getLinkageAndVisibility() const;
@ -291,7 +293,7 @@ public:
llvm::Optional<Visibility> getExplicitVisibility() const; llvm::Optional<Visibility> getExplicitVisibility() const;
/// \brief Clear the linkage cache in response to a change /// \brief Clear the linkage cache in response to a change
/// to the declaration. /// to the declaration.
void ClearLinkageCache(); void ClearLinkageCache();
/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
@ -349,7 +351,7 @@ public:
static bool classof(const LabelDecl *D) { return true; } static bool classof(const LabelDecl *D) { return true; }
static bool classofKind(Kind K) { return K == Label; } static bool classofKind(Kind K) { return K == Label; }
}; };
/// NamespaceDecl - Represent a C++ namespace. /// NamespaceDecl - Represent a C++ namespace.
class NamespaceDecl : public NamedDecl, public DeclContext { class NamespaceDecl : public NamedDecl, public DeclContext {
bool IsInline : 1; bool IsInline : 1;
@ -422,7 +424,7 @@ public:
/// \brief Return the next extended namespace declaration or null if there /// \brief Return the next extended namespace declaration or null if there
/// is none. /// is none.
NamespaceDecl *getNextNamespace(); NamespaceDecl *getNextNamespace();
const NamespaceDecl *getNextNamespace() const { const NamespaceDecl *getNextNamespace() const {
return const_cast<NamespaceDecl *>(this)->getNextNamespace(); return const_cast<NamespaceDecl *>(this)->getNextNamespace();
} }
@ -445,7 +447,7 @@ public:
} }
/// \brief Set the original (first) namespace declaration. /// \brief Set the original (first) namespace declaration.
void setOriginalNamespace(NamespaceDecl *ND) { void setOriginalNamespace(NamespaceDecl *ND) {
if (ND != this) { if (ND != this) {
OrigOrAnonNamespace.setPointer(ND); OrigOrAnonNamespace.setPointer(ND);
OrigOrAnonNamespace.setInt(false); OrigOrAnonNamespace.setInt(false);
@ -463,8 +465,8 @@ public:
} }
virtual NamespaceDecl *getCanonicalDecl() { return getOriginalNamespace(); } virtual NamespaceDecl *getCanonicalDecl() { return getOriginalNamespace(); }
const NamespaceDecl *getCanonicalDecl() const { const NamespaceDecl *getCanonicalDecl() const {
return getOriginalNamespace(); return getOriginalNamespace();
} }
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const {
@ -486,7 +488,7 @@ public:
static NamespaceDecl *castFromDeclContext(const DeclContext *DC) { static NamespaceDecl *castFromDeclContext(const DeclContext *DC) {
return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC)); return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC));
} }
friend class ASTDeclReader; friend class ASTDeclReader;
friend class ASTDeclWriter; friend class ASTDeclWriter;
}; };
@ -537,7 +539,7 @@ struct QualifierInfo {
void setTemplateParameterListsInfo(ASTContext &Context, void setTemplateParameterListsInfo(ASTContext &Context,
unsigned NumTPLists, unsigned NumTPLists,
TemplateParameterList **TPLists); TemplateParameterList **TPLists);
private: private:
// Copy constructor and copy assignment are disabled. // Copy constructor and copy assignment are disabled.
QualifierInfo(const QualifierInfo&); QualifierInfo(const QualifierInfo&);
@ -600,15 +602,15 @@ public:
return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier() return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier()
: 0; : 0;
} }
/// \brief Retrieve the nested-name-specifier (with source-location /// \brief Retrieve the nested-name-specifier (with source-location
/// information) that qualifies the name of this declaration, if it was /// information) that qualifies the name of this declaration, if it was
/// present in the source. /// present in the source.
NestedNameSpecifierLoc getQualifierLoc() const { NestedNameSpecifierLoc getQualifierLoc() const {
return hasExtInfo() ? getExtInfo()->QualifierLoc return hasExtInfo() ? getExtInfo()->QualifierLoc
: NestedNameSpecifierLoc(); : NestedNameSpecifierLoc();
} }
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc); void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc);
unsigned getNumTemplateParameterLists() const { unsigned getNumTemplateParameterLists() const {
@ -705,9 +707,10 @@ private:
/// \brief Whether this variable is the exception variable in a C++ catch /// \brief Whether this variable is the exception variable in a C++ catch
/// or an Objective-C @catch statement. /// or an Objective-C @catch statement.
unsigned ExceptionVar : 1; unsigned ExceptionVar : 1;
/// \brief Whether this local variable could be allocated in the return /// \brief Whether this local variable could be allocated in the return
/// slot of its function, enabling the named return value optimization (NRVO). /// slot of its function, enabling the named return value optimization
/// (NRVO).
unsigned NRVOVariable : 1; unsigned NRVOVariable : 1;
/// \brief Whether this variable is the for-range-declaration in a C++0x /// \brief Whether this variable is the for-range-declaration in a C++0x
@ -725,10 +728,10 @@ private:
friend class ASTDeclReader; friend class ASTDeclReader;
friend class StmtIteratorBase; friend class StmtIteratorBase;
protected: protected:
enum { NumParameterIndexBits = 8 }; enum { NumParameterIndexBits = 8 };
class ParmVarDeclBitfields { class ParmVarDeclBitfields {
friend class ParmVarDecl; friend class ParmVarDecl;
friend class ASTDeclReader; friend class ASTDeclReader;
@ -823,12 +826,12 @@ public:
return getStorageClass() >= SC_Auto; return getStorageClass() >= SC_Auto;
} }
/// isStaticLocal - Returns true if a variable with function scope is a /// isStaticLocal - Returns true if a variable with function scope is a
/// static local variable. /// static local variable.
bool isStaticLocal() const { bool isStaticLocal() const {
return getStorageClass() == SC_Static && !isFileVarDecl(); return getStorageClass() == SC_Static && !isFileVarDecl();
} }
/// hasExternStorage - Returns true if a variable has extern or /// hasExternStorage - Returns true if a variable has extern or
/// __private_extern__ storage. /// __private_extern__ storage.
bool hasExternalStorage() const { bool hasExternalStorage() const {
@ -919,21 +922,21 @@ public:
return const_cast<VarDecl*>(this)->getDefinition(); return const_cast<VarDecl*>(this)->getDefinition();
} }
/// \brief Determine whether this is or was instantiated from an out-of-line /// \brief Determine whether this is or was instantiated from an out-of-line
/// definition of a static data member. /// definition of a static data member.
virtual bool isOutOfLine() const; virtual bool isOutOfLine() const;
/// \brief If this is a static data member, find its out-of-line definition. /// \brief If this is a static data member, find its out-of-line definition.
VarDecl *getOutOfLineDefinition(); VarDecl *getOutOfLineDefinition();
/// isFileVarDecl - Returns true for file scoped variable declaration. /// isFileVarDecl - Returns true for file scoped variable declaration.
bool isFileVarDecl() const { bool isFileVarDecl() const {
if (getKind() != Decl::Var) if (getKind() != Decl::Var)
return false; return false;
if (getDeclContext()->getRedeclContext()->isFileContext()) if (getDeclContext()->getRedeclContext()->isFileContext())
return true; return true;
if (isStaticDataMember()) if (isStaticDataMember())
return true; return true;
@ -996,7 +999,7 @@ public:
void setInit(Expr *I); void setInit(Expr *I);
/// \brief Determine whether this variable is a reference that /// \brief Determine whether this variable is a reference that
/// extends the lifetime of its temporary initializer. /// extends the lifetime of its temporary initializer.
/// ///
/// A reference extends the lifetime of its temporary initializer if /// A reference extends the lifetime of its temporary initializer if
/// it's initializer is an rvalue that would normally go out of scope /// it's initializer is an rvalue that would normally go out of scope
@ -1118,7 +1121,7 @@ public:
return VarDeclBits.ExceptionVar; return VarDeclBits.ExceptionVar;
} }
void setExceptionVariable(bool EV) { VarDeclBits.ExceptionVar = EV; } void setExceptionVariable(bool EV) { VarDeclBits.ExceptionVar = EV; }
/// \brief Determine whether this local variable can be used with the named /// \brief Determine whether this local variable can be used with the named
/// return value optimization (NRVO). /// return value optimization (NRVO).
/// ///
@ -1143,7 +1146,7 @@ public:
/// Generally such variables are also 'const' for safety. /// Generally such variables are also 'const' for safety.
bool isARCPseudoStrong() const { return VarDeclBits.ARCPseudoStrong; } bool isARCPseudoStrong() const { return VarDeclBits.ARCPseudoStrong; }
void setARCPseudoStrong(bool ps) { VarDeclBits.ARCPseudoStrong = ps; } void setARCPseudoStrong(bool ps) { VarDeclBits.ARCPseudoStrong = ps; }
/// Whether this variable is (C++0x) constexpr. /// Whether this variable is (C++0x) constexpr.
bool isConstexpr() const { return VarDeclBits.IsConstexpr; } bool isConstexpr() const { return VarDeclBits.IsConstexpr; }
void setConstexpr(bool IC) { VarDeclBits.IsConstexpr = IC; } void setConstexpr(bool IC) { VarDeclBits.IsConstexpr = IC; }
@ -1153,15 +1156,15 @@ public:
/// from which it was instantiated. /// from which it was instantiated.
VarDecl *getInstantiatedFromStaticDataMember() const; VarDecl *getInstantiatedFromStaticDataMember() const;
/// \brief If this variable is a static data member, determine what kind of /// \brief If this variable is a static data member, determine what kind of
/// template specialization or instantiation this is. /// template specialization or instantiation this is.
TemplateSpecializationKind getTemplateSpecializationKind() const; TemplateSpecializationKind getTemplateSpecializationKind() const;
/// \brief If this variable is an instantiation of a static data member of a /// \brief If this variable is an instantiation of a static data member of a
/// class template specialization, retrieves the member specialization /// class template specialization, retrieves the member specialization
/// information. /// information.
MemberSpecializationInfo *getMemberSpecializationInfo() const; MemberSpecializationInfo *getMemberSpecializationInfo() const;
/// \brief For a static data member that was instantiated from a static /// \brief For a static data member that was instantiated from a static
/// data member of a class template, set the template specialiation kind. /// data member of a class template, set the template specialiation kind.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, void setTemplateSpecializationKind(TemplateSpecializationKind TSK,
@ -1219,7 +1222,7 @@ public:
Expr *DefArg); Expr *DefArg);
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const;
void setObjCMethodScopeInfo(unsigned parameterIndex) { void setObjCMethodScopeInfo(unsigned parameterIndex) {
ParmVarDeclBits.IsObjCMethodParam = true; ParmVarDeclBits.IsObjCMethodParam = true;
setParameterIndex(parameterIndex); setParameterIndex(parameterIndex);
@ -1229,7 +1232,8 @@ public:
assert(!ParmVarDeclBits.IsObjCMethodParam); assert(!ParmVarDeclBits.IsObjCMethodParam);
ParmVarDeclBits.ScopeDepthOrObjCQuals = scopeDepth; ParmVarDeclBits.ScopeDepthOrObjCQuals = scopeDepth;
assert(ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth && "truncation!"); assert(ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth
&& "truncation!");
setParameterIndex(parameterIndex); setParameterIndex(parameterIndex);
} }
@ -1276,7 +1280,7 @@ public:
const Expr *getDefaultArg() const { const Expr *getDefaultArg() const {
return const_cast<ParmVarDecl *>(this)->getDefaultArg(); return const_cast<ParmVarDecl *>(this)->getDefaultArg();
} }
void setDefaultArg(Expr *defarg) { void setDefaultArg(Expr *defarg) {
Init = reinterpret_cast<Stmt *>(defarg); Init = reinterpret_cast<Stmt *>(defarg);
} }
@ -1286,10 +1290,10 @@ public:
const CXXTemporary *getDefaultArgTemporary(unsigned i) const { const CXXTemporary *getDefaultArgTemporary(unsigned i) const {
return const_cast<ParmVarDecl *>(this)->getDefaultArgTemporary(i); return const_cast<ParmVarDecl *>(this)->getDefaultArgTemporary(i);
} }
/// \brief Retrieve the source range that covers the entire default /// \brief Retrieve the source range that covers the entire default
/// argument. /// argument.
SourceRange getDefaultArgRange() const; SourceRange getDefaultArgRange() const;
void setUninstantiatedDefaultArg(Expr *arg) { void setUninstantiatedDefaultArg(Expr *arg) {
Init = reinterpret_cast<UninstantiatedDefaultArgument *>(arg); Init = reinterpret_cast<UninstantiatedDefaultArgument *>(arg);
} }
@ -1351,7 +1355,7 @@ public:
/// \brief Determine whether this parameter is actually a function /// \brief Determine whether this parameter is actually a function
/// parameter pack. /// parameter pack.
bool isParameterPack() const; bool isParameterPack() const;
/// setOwningFunction - Sets the function declaration that owns this /// setOwningFunction - Sets the function declaration that owns this
/// ParmVarDecl. Since ParmVarDecls are often created before the /// ParmVarDecl. Since ParmVarDecls are often created before the
/// FunctionDecls that own them, this routine is required to update /// FunctionDecls that own them, this routine is required to update
@ -1362,7 +1366,7 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const ParmVarDecl *D) { return true; } static bool classof(const ParmVarDecl *D) { return true; }
static bool classofKind(Kind K) { return K == ParmVar; } static bool classofKind(Kind K) { return K == ParmVar; }
private: private:
enum { ParameterIndexSentinel = (1 << NumParameterIndexBits) - 1 }; enum { ParameterIndexSentinel = (1 << NumParameterIndexBits) - 1 };
@ -1371,7 +1375,7 @@ private:
setParameterIndexLarge(parameterIndex); setParameterIndexLarge(parameterIndex);
return; return;
} }
ParmVarDeclBits.ParameterIndex = parameterIndex; ParmVarDeclBits.ParameterIndex = parameterIndex;
assert(ParmVarDeclBits.ParameterIndex == parameterIndex && "truncation!"); assert(ParmVarDeclBits.ParameterIndex == parameterIndex && "truncation!");
} }
@ -1379,7 +1383,7 @@ private:
unsigned d = ParmVarDeclBits.ParameterIndex; unsigned d = ParmVarDeclBits.ParameterIndex;
return d == ParameterIndexSentinel ? getParameterIndexLarge() : d; return d == ParameterIndexSentinel ? getParameterIndexLarge() : d;
} }
void setParameterIndexLarge(unsigned parameterIndex); void setParameterIndexLarge(unsigned parameterIndex);
unsigned getParameterIndexLarge() const; unsigned getParameterIndexLarge() const;
}; };
@ -1456,7 +1460,7 @@ private:
/// FunctionTemplateSpecializationInfo, which contains information about /// FunctionTemplateSpecializationInfo, which contains information about
/// the template being specialized and the template arguments involved in /// the template being specialized and the template arguments involved in
/// that specialization. /// that specialization.
llvm::PointerUnion4<FunctionTemplateDecl *, llvm::PointerUnion4<FunctionTemplateDecl *,
MemberSpecializationInfo *, MemberSpecializationInfo *,
FunctionTemplateSpecializationInfo *, FunctionTemplateSpecializationInfo *,
DependentFunctionTemplateSpecializationInfo *> DependentFunctionTemplateSpecializationInfo *>
@ -1486,7 +1490,7 @@ private:
/// \param TemplateArgsAsWritten location info of template arguments. /// \param TemplateArgsAsWritten location info of template arguments.
/// ///
/// \param PointOfInstantiation point at which the function template /// \param PointOfInstantiation point at which the function template
/// specialization was first instantiated. /// specialization was first instantiated.
void setFunctionTemplateSpecialization(ASTContext &C, void setFunctionTemplateSpecialization(ASTContext &C,
FunctionTemplateDecl *Template, FunctionTemplateDecl *Template,
const TemplateArgumentList *TemplateArgs, const TemplateArgumentList *TemplateArgs,
@ -1656,7 +1660,7 @@ public:
void setTrivial(bool IT) { IsTrivial = IT; } void setTrivial(bool IT) { IsTrivial = IT; }
/// Whether this function is defaulted per C++0x. Only valid for /// Whether this function is defaulted per C++0x. Only valid for
/// special member functions. /// special member functions.
bool isDefaulted() const { return IsDefaulted; } bool isDefaulted() const { return IsDefaulted; }
void setDefaulted(bool D = true) { IsDefaulted = D; } void setDefaulted(bool D = true) { IsDefaulted = D; }
@ -1783,12 +1787,12 @@ public:
QualType getResultType() const { QualType getResultType() const {
return getType()->getAs<FunctionType>()->getResultType(); return getType()->getAs<FunctionType>()->getResultType();
} }
/// \brief Determine the type of an expression that calls this function. /// \brief Determine the type of an expression that calls this function.
QualType getCallResultType() const { QualType getCallResultType() const {
return getType()->getAs<FunctionType>()->getCallResultType(getASTContext()); return getType()->getAs<FunctionType>()->getCallResultType(getASTContext());
} }
StorageClass getStorageClass() const { return StorageClass(SClass); } StorageClass getStorageClass() const { return StorageClass(SClass); }
void setStorageClass(StorageClass SC); void setStorageClass(StorageClass SC);
@ -1799,10 +1803,10 @@ public:
/// \brief Determine whether the "inline" keyword was specified for this /// \brief Determine whether the "inline" keyword was specified for this
/// function. /// function.
bool isInlineSpecified() const { return IsInlineSpecified; } bool isInlineSpecified() const { return IsInlineSpecified; }
/// Set whether the "inline" keyword was specified for this function. /// Set whether the "inline" keyword was specified for this function.
void setInlineSpecified(bool I) { void setInlineSpecified(bool I) {
IsInlineSpecified = I; IsInlineSpecified = I;
IsInline = I; IsInline = I;
} }
@ -1819,7 +1823,7 @@ public:
bool isInlineDefinitionExternallyVisible() const; bool isInlineDefinitionExternallyVisible() const;
bool doesDeclarationForceExternallyVisibleDefinition() const; bool doesDeclarationForceExternallyVisibleDefinition() const;
/// isOverloadedOperator - Whether this function declaration /// isOverloadedOperator - Whether this function declaration
/// represents an C++ overloaded operator, e.g., "operator+". /// represents an C++ overloaded operator, e.g., "operator+".
bool isOverloadedOperator() const { bool isOverloadedOperator() const {
@ -1852,7 +1856,7 @@ public:
/// X<int>::A is required, it will be instantiated from the /// X<int>::A is required, it will be instantiated from the
/// declaration returned by getInstantiatedFromMemberFunction(). /// declaration returned by getInstantiatedFromMemberFunction().
FunctionDecl *getInstantiatedFromMemberFunction() const; FunctionDecl *getInstantiatedFromMemberFunction() const;
/// \brief What kind of templated function this is. /// \brief What kind of templated function this is.
TemplatedKind getTemplatedKind() const; TemplatedKind getTemplatedKind() const;
@ -1860,7 +1864,7 @@ public:
/// class template specialization, retrieves the member specialization /// class template specialization, retrieves the member specialization
/// information. /// information.
MemberSpecializationInfo *getMemberSpecializationInfo() const; MemberSpecializationInfo *getMemberSpecializationInfo() const;
/// \brief Specify that this record is an instantiation of the /// \brief Specify that this record is an instantiation of the
/// member function FD. /// member function FD.
void setInstantiationOfMemberFunction(FunctionDecl *FD, void setInstantiationOfMemberFunction(FunctionDecl *FD,
@ -1888,7 +1892,7 @@ public:
TemplateOrSpecialization = Template; TemplateOrSpecialization = Template;
} }
/// \brief Determine whether this function is a function template /// \brief Determine whether this function is a function template
/// specialization. /// specialization.
bool isFunctionTemplateSpecialization() const { bool isFunctionTemplateSpecialization() const {
return getPrimaryTemplate() != 0; return getPrimaryTemplate() != 0;
@ -1899,7 +1903,7 @@ public:
FunctionDecl *getClassScopeSpecializationPattern() const; FunctionDecl *getClassScopeSpecializationPattern() const;
/// \brief If this function is actually a function template specialization, /// \brief If this function is actually a function template specialization,
/// retrieve information about this function template specialization. /// retrieve information about this function template specialization.
/// Otherwise, returns NULL. /// Otherwise, returns NULL.
FunctionTemplateSpecializationInfo *getTemplateSpecializationInfo() const { FunctionTemplateSpecializationInfo *getTemplateSpecializationInfo() const {
return TemplateOrSpecialization. return TemplateOrSpecialization.
@ -1910,7 +1914,7 @@ public:
/// specialization or a member of a class template specialization that can /// specialization or a member of a class template specialization that can
/// be implicitly instantiated. /// be implicitly instantiated.
bool isImplicitlyInstantiable() const; bool isImplicitlyInstantiable() const;
/// \brief Retrieve the function declaration from which this function could /// \brief Retrieve the function declaration from which this function could
/// be instantiated, if it is an instantiation (rather than a non-template /// be instantiated, if it is an instantiation (rather than a non-template
/// or a specialization, for example). /// or a specialization, for example).
@ -1958,7 +1962,7 @@ public:
/// \param TemplateArgsAsWritten location info of template arguments. /// \param TemplateArgsAsWritten location info of template arguments.
/// ///
/// \param PointOfInstantiation point at which the function template /// \param PointOfInstantiation point at which the function template
/// specialization was first instantiated. /// specialization was first instantiated.
void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template, void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template,
const TemplateArgumentList *TemplateArgs, const TemplateArgumentList *TemplateArgs,
void *InsertPos, void *InsertPos,
@ -1994,15 +1998,15 @@ public:
/// \brief Retrieve the (first) point of instantiation of a function template /// \brief Retrieve the (first) point of instantiation of a function template
/// specialization or a member of a class template specialization. /// specialization or a member of a class template specialization.
/// ///
/// \returns the first point of instantiation, if this function was /// \returns the first point of instantiation, if this function was
/// instantiated from a template; otherwise, returns an invalid source /// instantiated from a template; otherwise, returns an invalid source
/// location. /// location.
SourceLocation getPointOfInstantiation() const; SourceLocation getPointOfInstantiation() const;
/// \brief Determine whether this is or was instantiated from an out-of-line /// \brief Determine whether this is or was instantiated from an out-of-line
/// definition of a member function. /// definition of a member function.
virtual bool isOutOfLine() const; virtual bool isOutOfLine() const;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const FunctionDecl *D) { return true; } static bool classof(const FunctionDecl *D) { return true; }
@ -2108,7 +2112,8 @@ public:
Expr *getInClassInitializer() const { Expr *getInClassInitializer() const {
return hasInClassInitializer() ? InitializerOrBitWidth.getPointer() : 0; return hasInClassInitializer() ? InitializerOrBitWidth.getPointer() : 0;
} }
/// setInClassInitializer - Set the C++0x in-class initializer for this member. /// setInClassInitializer - Set the C++0x in-class initializer for this
/// member.
void setInClassInitializer(Expr *Init); void setInClassInitializer(Expr *Init);
/// removeInClassInitializer - Remove the C++0x in-class initializer from this /// removeInClassInitializer - Remove the C++0x in-class initializer from this
/// member. /// member.
@ -2164,7 +2169,7 @@ public:
void setInitVal(const llvm::APSInt &V) { Val = V; } void setInitVal(const llvm::APSInt &V) { Val = V; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const EnumConstantDecl *D) { return true; } static bool classof(const EnumConstantDecl *D) { return true; }
@ -2189,7 +2194,7 @@ public:
static IndirectFieldDecl *Create(ASTContext &C, DeclContext *DC, static IndirectFieldDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id, SourceLocation L, IdentifierInfo *Id,
QualType T, NamedDecl **CH, unsigned CHS); QualType T, NamedDecl **CH, unsigned CHS);
typedef NamedDecl * const *chain_iterator; typedef NamedDecl * const *chain_iterator;
chain_iterator chain_begin() const { return Chaining; } chain_iterator chain_begin() const { return Chaining; }
chain_iterator chain_end() const { return Chaining+ChainingSize; } chain_iterator chain_end() const { return Chaining+ChainingSize; }
@ -2435,8 +2440,8 @@ protected:
/// @brief Completes the definition of this tag declaration. /// @brief Completes the definition of this tag declaration.
/// ///
/// This is a helper function for derived classes. /// This is a helper function for derived classes.
void completeDefinition(); void completeDefinition();
public: public:
typedef redeclarable_base::redecl_iterator redecl_iterator; typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const { redecl_iterator redecls_begin() const {
@ -2532,7 +2537,8 @@ public:
bool isEnum() const { return getTagKind() == TTK_Enum; } bool isEnum() const { return getTagKind() == TTK_Enum; }
TypedefNameDecl *getTypedefNameForAnonDecl() const { TypedefNameDecl *getTypedefNameForAnonDecl() const {
return hasExtInfo() ? 0 : TypedefNameDeclOrQualifier.get<TypedefNameDecl*>(); return hasExtInfo() ? 0 :
TypedefNameDeclOrQualifier.get<TypedefNameDecl*>();
} }
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD); void setTypedefNameForAnonDecl(TypedefNameDecl *TDD);
@ -2543,15 +2549,15 @@ public:
return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier() return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier()
: 0; : 0;
} }
/// \brief Retrieve the nested-name-specifier (with source-location /// \brief Retrieve the nested-name-specifier (with source-location
/// information) that qualifies the name of this declaration, if it was /// information) that qualifies the name of this declaration, if it was
/// present in the source. /// present in the source.
NestedNameSpecifierLoc getQualifierLoc() const { NestedNameSpecifierLoc getQualifierLoc() const {
return hasExtInfo() ? getExtInfo()->QualifierLoc return hasExtInfo() ? getExtInfo()->QualifierLoc
: NestedNameSpecifierLoc(); : NestedNameSpecifierLoc();
} }
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc); void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc);
unsigned getNumTemplateParameterLists() const { unsigned getNumTemplateParameterLists() const {
@ -2723,7 +2729,7 @@ public:
/// \brief Returns the width in bits required to store all the /// \brief Returns the width in bits required to store all the
/// negative enumerators of this enum. These widths include /// negative enumerators of this enum. These widths include
/// the rightmost leading 1; that is: /// the rightmost leading 1; that is:
/// ///
/// MOST NEGATIVE ENUMERATOR PATTERN NUM NEGATIVE BITS /// MOST NEGATIVE ENUMERATOR PATTERN NUM NEGATIVE BITS
/// ------------------------ ------- ----------------- /// ------------------------ ------- -----------------
/// -1 1111111 1 /// -1 1111111 1
@ -3058,7 +3064,7 @@ public:
bool capturesCXXThis); bool capturesCXXThis);
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const BlockDecl *D) { return true; } static bool classof(const BlockDecl *D) { return true; }
@ -3086,20 +3092,20 @@ void Redeclarable<decl_type>::setPreviousDeclaration(decl_type *PrevDecl) {
// and Redeclarable to be defined. // and Redeclarable to be defined.
decl_type *First; decl_type *First;
if (PrevDecl) { if (PrevDecl) {
// Point to previous. Make sure that this is actually the most recent // Point to previous. Make sure that this is actually the most recent
// redeclaration, or we can build invalid chains. If the most recent // redeclaration, or we can build invalid chains. If the most recent
// redeclaration is invalid, it won't be PrevDecl, but we want it anyway. // redeclaration is invalid, it won't be PrevDecl, but we want it anyway.
RedeclLink = PreviousDeclLink(llvm::cast<decl_type>( RedeclLink = PreviousDeclLink(
PrevDecl->getMostRecentDeclaration())); llvm::cast<decl_type>(PrevDecl->getMostRecentDeclaration()));
First = PrevDecl->getFirstDeclaration(); First = PrevDecl->getFirstDeclaration();
assert(First->RedeclLink.NextIsLatest() && "Expected first"); assert(First->RedeclLink.NextIsLatest() && "Expected first");
} else { } else {
// Make this first. // Make this first.
First = static_cast<decl_type*>(this); First = static_cast<decl_type*>(this);
} }
// First one will point to this one as latest. // First one will point to this one as latest.
First->RedeclLink = LatestDeclLink(static_cast<decl_type*>(this)); First->RedeclLink = LatestDeclLink(static_cast<decl_type*>(this));
if (NamedDecl *ND = dyn_cast<NamedDecl>(static_cast<decl_type*>(this))) if (NamedDecl *ND = dyn_cast<NamedDecl>(static_cast<decl_type*>(this)))

View File

@ -98,7 +98,7 @@ public:
/// identifiers. C++ describes lookup completely differently: /// identifiers. C++ describes lookup completely differently:
/// certain lookups merely "ignore" certain kinds of declarations, /// certain lookups merely "ignore" certain kinds of declarations,
/// usually based on whether the declaration is of a type, etc. /// usually based on whether the declaration is of a type, etc.
/// ///
/// These are meant as bitmasks, so that searches in /// These are meant as bitmasks, so that searches in
/// C++ can look into the "tag" namespace during ordinary lookup. /// C++ can look into the "tag" namespace during ordinary lookup.
/// ///
@ -243,7 +243,7 @@ private:
/// evaluated context or not, e.g. functions used in uninstantiated templates /// evaluated context or not, e.g. functions used in uninstantiated templates
/// are regarded as "referenced" but not "used". /// are regarded as "referenced" but not "used".
unsigned Referenced : 1; unsigned Referenced : 1;
protected: protected:
/// Access - Used by C++ decls for the access specifier. /// Access - Used by C++ decls for the access specifier.
// NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
@ -252,7 +252,7 @@ protected:
/// \brief Whether this declaration was loaded from an AST file. /// \brief Whether this declaration was loaded from an AST file.
unsigned FromASTFile : 1; unsigned FromASTFile : 1;
/// ChangedAfterLoad - if this declaration has changed since being loaded /// ChangedAfterLoad - if this declaration has changed since being loaded
unsigned ChangedAfterLoad : 1; unsigned ChangedAfterLoad : 1;
@ -267,12 +267,12 @@ protected:
/// ///
/// This field is only valid for NamedDecls subclasses. /// This field is only valid for NamedDecls subclasses.
mutable unsigned HasCachedLinkage : 1; mutable unsigned HasCachedLinkage : 1;
/// \brief If \c HasCachedLinkage, the linkage of this declaration. /// \brief If \c HasCachedLinkage, the linkage of this declaration.
/// ///
/// This field is only valid for NamedDecls subclasses. /// This field is only valid for NamedDecls subclasses.
mutable unsigned CachedLinkage : 2; mutable unsigned CachedLinkage : 2;
friend class ASTDeclWriter; friend class ASTDeclWriter;
friend class ASTDeclReader; friend class ASTDeclReader;
@ -288,7 +288,7 @@ protected:
Access(AS_none), FromASTFile(0), ChangedAfterLoad(false), Access(AS_none), FromASTFile(0), ChangedAfterLoad(false),
ModulePrivate(0), ModulePrivate(0),
IdentifierNamespace(getIdentifierNamespaceForKind(DK)), IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0) HasCachedLinkage(0)
{ {
if (Decl::CollectingStats()) add(DK); if (Decl::CollectingStats()) add(DK);
} }
@ -389,11 +389,11 @@ public:
attr_iterator attr_end() const { attr_iterator attr_end() const {
return hasAttrs() ? getAttrs().end() : 0; return hasAttrs() ? getAttrs().end() : 0;
} }
template <typename T> template <typename T>
void dropAttr() { void dropAttr() {
if (!HasAttrs) return; if (!HasAttrs) return;
AttrVec &Attrs = getAttrs(); AttrVec &Attrs = getAttrs();
for (unsigned i = 0, e = Attrs.size(); i != e; /* in loop */) { for (unsigned i = 0, e = Attrs.size(); i != e; /* in loop */) {
if (isa<T>(Attrs[i])) { if (isa<T>(Attrs[i])) {
@ -406,7 +406,7 @@ public:
if (Attrs.empty()) if (Attrs.empty())
HasAttrs = false; HasAttrs = false;
} }
template <typename T> template <typename T>
specific_attr_iterator<T> specific_attr_begin() const { specific_attr_iterator<T> specific_attr_begin() const {
return specific_attr_iterator<T>(attr_begin()); return specific_attr_iterator<T>(attr_begin());
@ -504,7 +504,7 @@ public:
/// \brief Determine whether this declaration came from an AST file (such as /// \brief Determine whether this declaration came from an AST file (such as
/// a precompiled header or module) rather than having been parsed. /// a precompiled header or module) rather than having been parsed.
bool isFromASTFile() const { return FromASTFile; } bool isFromASTFile() const { return FromASTFile; }
/// \brief Query whether this declaration was changed in a significant way /// \brief Query whether this declaration was changed in a significant way
/// since being loaded from an AST file. /// since being loaded from an AST file.
/// ///
@ -673,7 +673,7 @@ public:
/// \brief Whether this declaration is a parameter pack. /// \brief Whether this declaration is a parameter pack.
bool isParameterPack() const; bool isParameterPack() const;
/// \brief returns true if this declaration is a template /// \brief returns true if this declaration is a template
bool isTemplateDecl() const; bool isTemplateDecl() const;
@ -722,7 +722,7 @@ public:
unsigned mask unsigned mask
= (IdentifierNamespace & (IDNS_TagFriend | IDNS_OrdinaryFriend)); = (IdentifierNamespace & (IDNS_TagFriend | IDNS_OrdinaryFriend));
if (!mask) return FOK_None; if (!mask) return FOK_None;
return (IdentifierNamespace & (IDNS_Tag | IDNS_Ordinary) ? return (IdentifierNamespace & (IDNS_Tag | IDNS_Ordinary) ?
FOK_Declared : FOK_Undeclared); FOK_Declared : FOK_Undeclared);
} }
@ -886,11 +886,11 @@ public:
} }
DeclContext *getLookupParent(); DeclContext *getLookupParent();
const DeclContext *getLookupParent() const { const DeclContext *getLookupParent() const {
return const_cast<DeclContext*>(this)->getLookupParent(); return const_cast<DeclContext*>(this)->getLookupParent();
} }
ASTContext &getParentASTContext() const { ASTContext &getParentASTContext() const {
return cast<Decl>(this)->getASTContext(); return cast<Decl>(this)->getASTContext();
} }
@ -1141,13 +1141,13 @@ public:
return tmp; return tmp;
} }
friend bool friend bool operator==(const specific_decl_iterator& x,
operator==(const specific_decl_iterator& x, const specific_decl_iterator& y) { const specific_decl_iterator& y) {
return x.Current == y.Current; return x.Current == y.Current;
} }
friend bool friend bool operator!=(const specific_decl_iterator& x,
operator!=(const specific_decl_iterator& x, const specific_decl_iterator& y) { const specific_decl_iterator& y) {
return x.Current != y.Current; return x.Current != y.Current;
} }
}; };
@ -1215,13 +1215,13 @@ public:
return tmp; return tmp;
} }
friend bool friend bool operator==(const filtered_decl_iterator& x,
operator==(const filtered_decl_iterator& x, const filtered_decl_iterator& y) { const filtered_decl_iterator& y) {
return x.Current == y.Current; return x.Current == y.Current;
} }
friend bool friend bool operator!=(const filtered_decl_iterator& x,
operator!=(const filtered_decl_iterator& x, const filtered_decl_iterator& y) { const filtered_decl_iterator& y) {
return x.Current != y.Current; return x.Current != y.Current;
} }
}; };
@ -1283,12 +1283,12 @@ public:
/// \brief A simplistic name lookup mechanism that performs name lookup /// \brief A simplistic name lookup mechanism that performs name lookup
/// into this declaration context without consulting the external source. /// into this declaration context without consulting the external source.
/// ///
/// This function should almost never be used, because it subverts the /// This function should almost never be used, because it subverts the
/// usual relationship between a DeclContext and the external source. /// usual relationship between a DeclContext and the external source.
/// See the ASTImporter for the (few, but important) use cases. /// See the ASTImporter for the (few, but important) use cases.
void localUncachedLookup(DeclarationName Name, void localUncachedLookup(DeclarationName Name,
llvm::SmallVectorImpl<NamedDecl *> &Results); llvm::SmallVectorImpl<NamedDecl *> &Results);
/// @brief Makes a declaration visible within this context. /// @brief Makes a declaration visible within this context.
/// ///
/// This routine makes the declaration D visible to name lookup /// This routine makes the declaration D visible to name lookup
@ -1360,7 +1360,7 @@ public:
bool isDeclInLexicalTraversal(const Decl *D) const { bool isDeclInLexicalTraversal(const Decl *D) const {
return D && (D->NextDeclInContext || D == FirstDecl || D == LastDecl); return D && (D->NextDeclInContext || D == FirstDecl || D == LastDecl);
} }
static bool classof(const Decl *D); static bool classof(const Decl *D);
static bool classof(const DeclContext *D) { return true; } static bool classof(const DeclContext *D) { return true; }
#define DECL(NAME, BASE) #define DECL(NAME, BASE)
@ -1372,8 +1372,8 @@ public:
private: private:
void LoadLexicalDeclsFromExternalStorage() const; void LoadLexicalDeclsFromExternalStorage() const;
/// @brief Makes a declaration visible within this context, but /// @brief Makes a declaration visible within this context, but
/// suppresses searches for external declarations with the same /// suppresses searches for external declarations with the same
/// name. /// name.
/// ///
@ -1386,7 +1386,8 @@ private:
StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const; StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const;
void buildLookup(DeclContext *DCtx); void buildLookup(DeclContext *DCtx);
void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal, bool Recoverable); void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal,
bool Recoverable);
void makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal); void makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal);
}; };

View File

@ -36,7 +36,7 @@ class CXXMemberLookupCriteria;
class CXXFinalOverriderMap; class CXXFinalOverriderMap;
class CXXIndirectPrimaryBaseSet; class CXXIndirectPrimaryBaseSet;
class FriendDecl; class FriendDecl;
/// \brief Represents any kind of function declaration, whether it is a /// \brief Represents any kind of function declaration, whether it is a
/// concrete function or a function template. /// concrete function or a function template.
class AnyFunctionDecl { class AnyFunctionDecl {
@ -170,7 +170,7 @@ class CXXBaseSpecifier {
/// \brief The source location of the ellipsis, if this is a pack /// \brief The source location of the ellipsis, if this is a pack
/// expansion. /// expansion.
SourceLocation EllipsisLoc; SourceLocation EllipsisLoc;
/// Virtual - Whether this is a virtual base class or not. /// Virtual - Whether this is a virtual base class or not.
bool Virtual : 1; bool Virtual : 1;
@ -200,7 +200,7 @@ public:
CXXBaseSpecifier(SourceRange R, bool V, bool BC, AccessSpecifier A, CXXBaseSpecifier(SourceRange R, bool V, bool BC, AccessSpecifier A,
TypeSourceInfo *TInfo, SourceLocation EllipsisLoc) TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
: Range(R), EllipsisLoc(EllipsisLoc), Virtual(V), BaseOfClass(BC), : Range(R), EllipsisLoc(EllipsisLoc), Virtual(V), BaseOfClass(BC),
Access(A), InheritConstructors(false), BaseTypeInfo(TInfo) { } Access(A), InheritConstructors(false), BaseTypeInfo(TInfo) { }
/// getSourceRange - Retrieves the source range that contains the /// getSourceRange - Retrieves the source range that contains the
@ -214,7 +214,7 @@ public:
/// \brief Determine whether this base class is a base of a class declared /// \brief Determine whether this base class is a base of a class declared
/// with the 'class' keyword (vs. one declared with the 'struct' keyword). /// with the 'class' keyword (vs. one declared with the 'struct' keyword).
bool isBaseOfClass() const { return BaseOfClass; } bool isBaseOfClass() const { return BaseOfClass; }
/// \brief Determine whether this base specifier is a pack expansion. /// \brief Determine whether this base specifier is a pack expansion.
bool isPackExpansion() const { return EllipsisLoc.isValid(); } bool isPackExpansion() const { return EllipsisLoc.isValid(); }
@ -319,7 +319,8 @@ class CXXRecordDecl : public RecordDecl {
/// * has no non-static data members of type non-standard-layout class (or /// * has no non-static data members of type non-standard-layout class (or
/// array of such types) or reference, /// array of such types) or reference,
/// * has no virtual functions (10.3) and no virtual base classes (10.1), /// * has no virtual functions (10.3) and no virtual base classes (10.1),
/// * has the same access control (Clause 11) for all non-static data members /// * has the same access control (Clause 11) for all non-static data
/// members
/// * has no non-standard-layout base classes, /// * has no non-standard-layout base classes,
/// * either has no non-static data members in the most derived class and at /// * either has no non-static data members in the most derived class and at
/// most one base class with non-static data members, or has no base /// most one base class with non-static data members, or has no base
@ -346,7 +347,7 @@ class CXXRecordDecl : public RecordDecl {
/// \brief True if this class (or any subobject) has mutable fields. /// \brief True if this class (or any subobject) has mutable fields.
bool HasMutableFields : 1; bool HasMutableFields : 1;
/// HasTrivialDefaultConstructor - True when, if this class has a default /// HasTrivialDefaultConstructor - True when, if this class has a default
/// constructor, this default constructor is trivial. /// constructor, this default constructor is trivial.
/// ///
@ -458,13 +459,13 @@ class CXXRecordDecl : public RecordDecl {
/// \brief Whether we have already declared the move constructor. /// \brief Whether we have already declared the move constructor.
bool DeclaredMoveConstructor : 1; bool DeclaredMoveConstructor : 1;
/// \brief Whether we have already declared the copy-assignment operator. /// \brief Whether we have already declared the copy-assignment operator.
bool DeclaredCopyAssignment : 1; bool DeclaredCopyAssignment : 1;
/// \brief Whether we have already declared the move-assignment operator. /// \brief Whether we have already declared the move-assignment operator.
bool DeclaredMoveAssignment : 1; bool DeclaredMoveAssignment : 1;
/// \brief Whether we have already declared a destructor within the class. /// \brief Whether we have already declared a destructor within the class.
bool DeclaredDestructor : 1; bool DeclaredDestructor : 1;
@ -478,7 +479,7 @@ class CXXRecordDecl : public RecordDecl {
/// NumBases - The number of base class specifiers in Bases. /// NumBases - The number of base class specifiers in Bases.
unsigned NumBases; unsigned NumBases;
/// NumVBases - The number of virtual base class specifiers in VBases. /// NumVBases - The number of virtual base class specifiers in VBases.
unsigned NumVBases; unsigned NumVBases;
@ -510,12 +511,12 @@ class CXXRecordDecl : public RecordDecl {
/// in reverse order. /// in reverse order.
FriendDecl *FirstFriend; FriendDecl *FirstFriend;
/// \brief Retrieve the set of direct base classes. /// \brief Retrieve the set of direct base classes.
CXXBaseSpecifier *getBases() const { CXXBaseSpecifier *getBases() const {
return Bases.get(Definition->getASTContext().getExternalSource()); return Bases.get(Definition->getASTContext().getExternalSource());
} }
/// \brief Retrieve the set of virtual base classes. /// \brief Retrieve the set of virtual base classes.
CXXBaseSpecifier *getVBases() const { CXXBaseSpecifier *getVBases() const {
return VBases.get(Definition->getASTContext().getExternalSource()); return VBases.get(Definition->getASTContext().getExternalSource());
} }
@ -530,7 +531,7 @@ class CXXRecordDecl : public RecordDecl {
assert(DefinitionData && "queried property of class with no definition"); assert(DefinitionData && "queried property of class with no definition");
return *DefinitionData; return *DefinitionData;
} }
/// \brief The template or declaration that this declaration /// \brief The template or declaration that this declaration
/// describes or was instantiated from, respectively. /// describes or was instantiated from, respectively.
/// ///
@ -538,25 +539,25 @@ class CXXRecordDecl : public RecordDecl {
/// declarations that describe a class template, this will be a /// declarations that describe a class template, this will be a
/// pointer to a ClassTemplateDecl. For member /// pointer to a ClassTemplateDecl. For member
/// classes of class template specializations, this will be the /// classes of class template specializations, this will be the
/// MemberSpecializationInfo referring to the member class that was /// MemberSpecializationInfo referring to the member class that was
/// instantiated or specialized. /// instantiated or specialized.
llvm::PointerUnion<ClassTemplateDecl*, MemberSpecializationInfo*> llvm::PointerUnion<ClassTemplateDecl*, MemberSpecializationInfo*>
TemplateOrInstantiation; TemplateOrInstantiation;
friend class DeclContext; friend class DeclContext;
/// \brief Notify the class that member has been added. /// \brief Notify the class that member has been added.
/// ///
/// This routine helps maintain information about the class based on which /// This routine helps maintain information about the class based on which
/// members have been added. It will be invoked by DeclContext::addDecl() /// members have been added. It will be invoked by DeclContext::addDecl()
/// whenever a member is added to this record. /// whenever a member is added to this record.
void addedMember(Decl *D); void addedMember(Decl *D);
void markedVirtualFunctionPure(); void markedVirtualFunctionPure();
friend void FunctionDecl::setPure(bool); friend void FunctionDecl::setPure(bool);
friend class ASTNodeImporter; friend class ASTNodeImporter;
protected: protected:
CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC, CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc, SourceLocation StartLoc, SourceLocation IdLoc,
@ -587,7 +588,7 @@ public:
virtual const CXXRecordDecl *getCanonicalDecl() const { virtual const CXXRecordDecl *getCanonicalDecl() const {
return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl()); return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl());
} }
const CXXRecordDecl *getPreviousDeclaration() const { const CXXRecordDecl *getPreviousDeclaration() const {
return cast_or_null<CXXRecordDecl>(RecordDecl::getPreviousDeclaration()); return cast_or_null<CXXRecordDecl>(RecordDecl::getPreviousDeclaration());
} }
@ -706,7 +707,7 @@ public:
/// ///
/// This value is used for lazy creation of default constructors. /// This value is used for lazy creation of default constructors.
bool needsImplicitDefaultConstructor() const { bool needsImplicitDefaultConstructor() const {
return !data().UserDeclaredConstructor && return !data().UserDeclaredConstructor &&
!data().DeclaredDefaultConstructor; !data().DeclaredDefaultConstructor;
} }
@ -724,11 +725,11 @@ public:
CXXConstructorDecl *getCopyConstructor(unsigned TypeQuals) const; CXXConstructorDecl *getCopyConstructor(unsigned TypeQuals) const;
/// getMoveConstructor - Returns the move constructor for this class /// getMoveConstructor - Returns the move constructor for this class
CXXConstructorDecl *getMoveConstructor() const; CXXConstructorDecl *getMoveConstructor() const;
/// \brief Retrieve the copy-assignment operator for this class, if available. /// \brief Retrieve the copy-assignment operator for this class, if available.
/// ///
/// This routine attempts to find the copy-assignment operator for this /// This routine attempts to find the copy-assignment operator for this
/// class, using a simplistic form of overload resolution. /// class, using a simplistic form of overload resolution.
/// ///
/// \param ArgIsConst Whether the argument to the copy-assignment operator /// \param ArgIsConst Whether the argument to the copy-assignment operator
@ -741,7 +742,7 @@ public:
/// getMoveAssignmentOperator - Returns the move assignment operator for this /// getMoveAssignmentOperator - Returns the move assignment operator for this
/// class /// class
CXXMethodDecl *getMoveAssignmentOperator() const; CXXMethodDecl *getMoveAssignmentOperator() const;
/// hasUserDeclaredConstructor - Whether this class has any /// hasUserDeclaredConstructor - Whether this class has any
/// user-declared constructors. When true, a default constructor /// user-declared constructors. When true, a default constructor
/// will not be implicitly declared. /// will not be implicitly declared.
@ -762,7 +763,7 @@ public:
return data().UserDeclaredCopyConstructor; return data().UserDeclaredCopyConstructor;
} }
/// \brief Determine whether this class has had its copy constructor /// \brief Determine whether this class has had its copy constructor
/// declared, either via the user or via an implicit declaration. /// declared, either via the user or via an implicit declaration.
/// ///
/// This value is used for lazy creation of copy constructors. /// This value is used for lazy creation of copy constructors.
@ -824,7 +825,7 @@ public:
return data().UserDeclaredCopyAssignment; return data().UserDeclaredCopyAssignment;
} }
/// \brief Determine whether this class has had its copy assignment operator /// \brief Determine whether this class has had its copy assignment operator
/// declared, either via the user or via an implicit declaration. /// declared, either via the user or via an implicit declaration.
/// ///
/// This value is used for lazy creation of copy assignment operators. /// This value is used for lazy creation of copy assignment operators.
@ -943,7 +944,7 @@ public:
/// \brief Whether this class, or any of its class subobjects, contains a /// \brief Whether this class, or any of its class subobjects, contains a
/// mutable field. /// mutable field.
bool hasMutableFields() const { return data().HasMutableFields; } bool hasMutableFields() const { return data().HasMutableFields; }
// hasTrivialDefaultConstructor - Whether this class has a trivial default // hasTrivialDefaultConstructor - Whether this class has a trivial default
// constructor // constructor
// (C++0x [class.ctor]p5) // (C++0x [class.ctor]p5)
@ -1045,12 +1046,12 @@ public:
/// X<int>::A is required, it will be instantiated from the /// X<int>::A is required, it will be instantiated from the
/// declaration returned by getInstantiatedFromMemberClass(). /// declaration returned by getInstantiatedFromMemberClass().
CXXRecordDecl *getInstantiatedFromMemberClass() const; CXXRecordDecl *getInstantiatedFromMemberClass() const;
/// \brief If this class is an instantiation of a member class of a /// \brief If this class is an instantiation of a member class of a
/// class template specialization, retrieves the member specialization /// class template specialization, retrieves the member specialization
/// information. /// information.
MemberSpecializationInfo *getMemberSpecializationInfo() const; MemberSpecializationInfo *getMemberSpecializationInfo() const;
/// \brief Specify that this record is an instantiation of the /// \brief Specify that this record is an instantiation of the
/// member class RD. /// member class RD.
void setInstantiationOfMemberClass(CXXRecordDecl *RD, void setInstantiationOfMemberClass(CXXRecordDecl *RD,
@ -1079,7 +1080,7 @@ public:
/// instantiation of a class template or member class of a class template, /// instantiation of a class template or member class of a class template,
/// and how it was instantiated or specialized. /// and how it was instantiated or specialized.
TemplateSpecializationKind getTemplateSpecializationKind() const; TemplateSpecializationKind getTemplateSpecializationKind() const;
/// \brief Set the kind of specialization or template instantiation this is. /// \brief Set the kind of specialization or template instantiation this is.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK); void setTemplateSpecializationKind(TemplateSpecializationKind TSK);
@ -1106,7 +1107,7 @@ public:
/// ///
/// \returns true if this class is derived from Base, false otherwise. /// \returns true if this class is derived from Base, false otherwise.
bool isDerivedFrom(const CXXRecordDecl *Base) const; bool isDerivedFrom(const CXXRecordDecl *Base) const;
/// \brief Determine whether this class is derived from the type \p Base. /// \brief Determine whether this class is derived from the type \p Base.
/// ///
/// This routine only determines whether this class is derived from \p Base, /// This routine only determines whether this class is derived from \p Base,
@ -1121,8 +1122,8 @@ public:
/// ///
/// \returns true if this class is derived from Base, false otherwise. /// \returns true if this class is derived from Base, false otherwise.
/// ///
/// \todo add a separate paramaeter to configure IsDerivedFrom, rather than /// \todo add a separate paramaeter to configure IsDerivedFrom, rather than
/// tangling input and output in \p Paths /// tangling input and output in \p Paths
bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths) const; bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths) const;
/// \brief Determine whether this class is virtually derived from /// \brief Determine whether this class is virtually derived from
@ -1157,20 +1158,20 @@ public:
/// ///
/// The class itself does not count as a base class. This routine /// The class itself does not count as a base class. This routine
/// returns false if the class has non-computable base classes. /// returns false if the class has non-computable base classes.
/// ///
/// \param AllowShortCircuit if false, forces the callback to be called /// \param AllowShortCircuit if false, forces the callback to be called
/// for every base class, even if a dependent or non-matching base was /// for every base class, even if a dependent or non-matching base was
/// found. /// found.
bool forallBases(ForallBasesCallback *BaseMatches, void *UserData, bool forallBases(ForallBasesCallback *BaseMatches, void *UserData,
bool AllowShortCircuit = true) const; bool AllowShortCircuit = true) const;
/// \brief Function type used by lookupInBases() to determine whether a /// \brief Function type used by lookupInBases() to determine whether a
/// specific base class subobject matches the lookup criteria. /// specific base class subobject matches the lookup criteria.
/// ///
/// \param Specifier the base-class specifier that describes the inheritance /// \param Specifier the base-class specifier that describes the inheritance
/// from the base class we are trying to match. /// from the base class we are trying to match.
/// ///
/// \param Path the current path, from the most-derived class down to the /// \param Path the current path, from the most-derived class down to the
/// base named by the \p Specifier. /// base named by the \p Specifier.
/// ///
/// \param UserData a single pointer to user-specified data, provided to /// \param UserData a single pointer to user-specified data, provided to
@ -1180,13 +1181,13 @@ public:
typedef bool BaseMatchesCallback(const CXXBaseSpecifier *Specifier, typedef bool BaseMatchesCallback(const CXXBaseSpecifier *Specifier,
CXXBasePath &Path, CXXBasePath &Path,
void *UserData); void *UserData);
/// \brief Look for entities within the base classes of this C++ class, /// \brief Look for entities within the base classes of this C++ class,
/// transitively searching all base class subobjects. /// transitively searching all base class subobjects.
/// ///
/// This routine uses the callback function \p BaseMatches to find base /// This routine uses the callback function \p BaseMatches to find base
/// classes meeting some search criteria, walking all base class subobjects /// classes meeting some search criteria, walking all base class subobjects
/// and populating the given \p Paths structure with the paths through the /// and populating the given \p Paths structure with the paths through the
/// inheritance hierarchy that resulted in a match. On a successful search, /// inheritance hierarchy that resulted in a match. On a successful search,
/// the \p Paths structure can be queried to retrieve the matching paths and /// the \p Paths structure can be queried to retrieve the matching paths and
/// to determine if there were any ambiguities. /// to determine if there were any ambiguities.
@ -1203,7 +1204,7 @@ public:
/// subobject that matches the search criteria. /// subobject that matches the search criteria.
bool lookupInBases(BaseMatchesCallback *BaseMatches, void *UserData, bool lookupInBases(BaseMatchesCallback *BaseMatches, void *UserData,
CXXBasePaths &Paths) const; CXXBasePaths &Paths) const;
/// \brief Base-class lookup callback that determines whether the given /// \brief Base-class lookup callback that determines whether the given
/// base class specifier refers to a specific class declaration. /// base class specifier refers to a specific class declaration.
/// ///
@ -1225,7 +1226,7 @@ public:
/// are searching for. /// are searching for.
static bool FindVirtualBaseClass(const CXXBaseSpecifier *Specifier, static bool FindVirtualBaseClass(const CXXBaseSpecifier *Specifier,
CXXBasePath &Path, void *BaseRecord); CXXBasePath &Path, void *BaseRecord);
/// \brief Base-class lookup callback that determines whether there exists /// \brief Base-class lookup callback that determines whether there exists
/// a tag with the given name. /// a tag with the given name.
/// ///
@ -1243,7 +1244,7 @@ public:
/// is an opaque \c DeclarationName pointer. /// is an opaque \c DeclarationName pointer.
static bool FindOrdinaryMember(const CXXBaseSpecifier *Specifier, static bool FindOrdinaryMember(const CXXBaseSpecifier *Specifier,
CXXBasePath &Path, void *Name); CXXBasePath &Path, void *Name);
/// \brief Base-class lookup callback that determines whether there exists /// \brief Base-class lookup callback that determines whether there exists
/// a member with the given name that can be used in a nested-name-specifier. /// a member with the given name that can be used in a nested-name-specifier.
/// ///
@ -1279,15 +1280,15 @@ public:
/// \brief Indicates that the definition of this class is now complete. /// \brief Indicates that the definition of this class is now complete.
virtual void completeDefinition(); virtual void completeDefinition();
/// \brief Indicates that the definition of this class is now complete, /// \brief Indicates that the definition of this class is now complete,
/// and provides a final overrider map to help determine /// and provides a final overrider map to help determine
/// ///
/// \param FinalOverriders The final overrider map for this class, which can /// \param FinalOverriders The final overrider map for this class, which can
/// be provided as an optimization for abstract-class checking. If NULL, /// be provided as an optimization for abstract-class checking. If NULL,
/// final overriders will be computed if they are needed to complete the /// final overriders will be computed if they are needed to complete the
/// definition. /// definition.
void completeDefinition(CXXFinalOverriderMap *FinalOverriders); void completeDefinition(CXXFinalOverriderMap *FinalOverriders);
/// \brief Determine whether this class may end up being abstract, even though /// \brief Determine whether this class may end up being abstract, even though
/// it is not yet known to be abstract. /// it is not yet known to be abstract.
/// ///
@ -1296,7 +1297,7 @@ public:
/// will need to compute final overriders to determine whether the class is /// will need to compute final overriders to determine whether the class is
/// actually abstract. /// actually abstract.
bool mayBeAbstract() const; bool mayBeAbstract() const;
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { static bool classofKind(Kind K) {
return K >= firstCXXRecord && K <= lastCXXRecord; return K >= firstCXXRecord && K <= lastCXXRecord;
@ -1343,12 +1344,12 @@ public:
bool isInstance() const { return !isStatic(); } bool isInstance() const { return !isStatic(); }
bool isVirtual() const { bool isVirtual() const {
CXXMethodDecl *CD = CXXMethodDecl *CD =
cast<CXXMethodDecl>(const_cast<CXXMethodDecl*>(this)->getCanonicalDecl()); cast<CXXMethodDecl>(const_cast<CXXMethodDecl*>(this)->getCanonicalDecl());
if (CD->isVirtualAsWritten()) if (CD->isVirtualAsWritten())
return true; return true;
return (CD->begin_overridden_methods() != CD->end_overridden_methods()); return (CD->begin_overridden_methods() != CD->end_overridden_methods());
} }
@ -1356,14 +1357,14 @@ public:
/// (C++ [basic.stc.dynamic.deallocation]p2), which is an overloaded /// (C++ [basic.stc.dynamic.deallocation]p2), which is an overloaded
/// delete or delete[] operator with a particular signature. /// delete or delete[] operator with a particular signature.
bool isUsualDeallocationFunction() const; bool isUsualDeallocationFunction() const;
/// \brief Determine whether this is a copy-assignment operator, regardless /// \brief Determine whether this is a copy-assignment operator, regardless
/// of whether it was declared implicitly or explicitly. /// of whether it was declared implicitly or explicitly.
bool isCopyAssignmentOperator() const; bool isCopyAssignmentOperator() const;
/// \brief Determine whether this is a move assignment operator. /// \brief Determine whether this is a move assignment operator.
bool isMoveAssignmentOperator() const; bool isMoveAssignmentOperator() const;
const CXXMethodDecl *getCanonicalDecl() const { const CXXMethodDecl *getCanonicalDecl() const {
return cast<CXXMethodDecl>(FunctionDecl::getCanonicalDecl()); return cast<CXXMethodDecl>(FunctionDecl::getCanonicalDecl());
} }
@ -1376,7 +1377,7 @@ public:
bool isUserProvided() const { bool isUserProvided() const {
return !(isDeleted() || getCanonicalDecl()->isDefaulted()); return !(isDeleted() || getCanonicalDecl()->isDefaulted());
} }
/// ///
void addOverriddenMethod(const CXXMethodDecl *MD); void addOverriddenMethod(const CXXMethodDecl *MD);
@ -1421,7 +1422,7 @@ public:
RefQualifierKind getRefQualifier() const { RefQualifierKind getRefQualifier() const {
return getType()->getAs<FunctionProtoType>()->getRefQualifier(); return getType()->getAs<FunctionProtoType>()->getRefQualifier();
} }
bool hasInlineBody() const; bool hasInlineBody() const;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
@ -1448,23 +1449,23 @@ public:
/// @endcode /// @endcode
class CXXCtorInitializer { class CXXCtorInitializer {
/// \brief Either the base class name/delegating constructor type (stored as /// \brief Either the base class name/delegating constructor type (stored as
/// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field /// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field
/// (IndirectFieldDecl*) being initialized. /// (IndirectFieldDecl*) being initialized.
llvm::PointerUnion3<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *> llvm::PointerUnion3<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *>
Initializee; Initializee;
/// \brief The source location for the field name or, for a base initializer /// \brief The source location for the field name or, for a base initializer
/// pack expansion, the location of the ellipsis. In the case of a delegating /// pack expansion, the location of the ellipsis. In the case of a delegating
/// constructor, it will still include the type's source location as the /// constructor, it will still include the type's source location as the
/// Initializee points to the CXXConstructorDecl (to allow loop detection). /// Initializee points to the CXXConstructorDecl (to allow loop detection).
SourceLocation MemberOrEllipsisLocation; SourceLocation MemberOrEllipsisLocation;
/// \brief The argument used to initialize the base or member, which may /// \brief The argument used to initialize the base or member, which may
/// end up constructing an object (when multiple arguments are involved). /// end up constructing an object (when multiple arguments are involved).
/// If 0, this is a field initializer, and the in-class member initializer /// If 0, this is a field initializer, and the in-class member initializer
/// will be used. /// will be used.
Stmt *Init; Stmt *Init;
/// LParenLoc - Location of the left paren of the ctor-initializer. /// LParenLoc - Location of the left paren of the ctor-initializer.
SourceLocation LParenLoc; SourceLocation LParenLoc;
@ -1474,7 +1475,7 @@ class CXXCtorInitializer {
/// \brief If the initializee is a type, whether that type makes this /// \brief If the initializee is a type, whether that type makes this
/// a delegating initialization. /// a delegating initialization.
bool IsDelegating : 1; bool IsDelegating : 1;
/// IsVirtual - If the initializer is a base initializer, this keeps track /// IsVirtual - If the initializer is a base initializer, this keeps track
/// of whether the base is virtual or not. /// of whether the base is virtual or not.
bool IsVirtual : 1; bool IsVirtual : 1;
@ -1493,7 +1494,7 @@ class CXXCtorInitializer {
CXXCtorInitializer(ASTContext &Context, FieldDecl *Member, CXXCtorInitializer(ASTContext &Context, FieldDecl *Member,
SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation MemberLoc, SourceLocation L, Expr *Init,
SourceLocation R, VarDecl **Indices, unsigned NumIndices); SourceLocation R, VarDecl **Indices, unsigned NumIndices);
public: public:
/// CXXCtorInitializer - Creates a new base-class initializer. /// CXXCtorInitializer - Creates a new base-class initializer.
explicit explicit
@ -1518,24 +1519,24 @@ public:
CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo, CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo,
SourceLocation L, Expr *Init, SourceLocation R); SourceLocation L, Expr *Init, SourceLocation R);
/// \brief Creates a new member initializer that optionally contains /// \brief Creates a new member initializer that optionally contains
/// array indices used to describe an elementwise initialization. /// array indices used to describe an elementwise initialization.
static CXXCtorInitializer *Create(ASTContext &Context, FieldDecl *Member, static CXXCtorInitializer *Create(ASTContext &Context, FieldDecl *Member,
SourceLocation MemberLoc, SourceLocation L, SourceLocation MemberLoc, SourceLocation L,
Expr *Init, SourceLocation R, Expr *Init, SourceLocation R,
VarDecl **Indices, unsigned NumIndices); VarDecl **Indices, unsigned NumIndices);
/// isBaseInitializer - Returns true when this initializer is /// isBaseInitializer - Returns true when this initializer is
/// initializing a base class. /// initializing a base class.
bool isBaseInitializer() const { bool isBaseInitializer() const {
return Initializee.is<TypeSourceInfo*>() && !IsDelegating; return Initializee.is<TypeSourceInfo*>() && !IsDelegating;
} }
/// isMemberInitializer - Returns true when this initializer is /// isMemberInitializer - Returns true when this initializer is
/// initializing a non-static data member. /// initializing a non-static data member.
bool isMemberInitializer() const { return Initializee.is<FieldDecl*>(); } bool isMemberInitializer() const { return Initializee.is<FieldDecl*>(); }
bool isAnyMemberInitializer() const { bool isAnyMemberInitializer() const {
return isMemberInitializer() || isIndirectMemberInitializer(); return isMemberInitializer() || isIndirectMemberInitializer();
} }
@ -1553,21 +1554,21 @@ public:
/// isDelegatingInitializer - Returns true when this initializer is creating /// isDelegatingInitializer - Returns true when this initializer is creating
/// a delegating constructor. /// a delegating constructor.
bool isDelegatingInitializer() const { bool isDelegatingInitializer() const {
return Initializee.is<TypeSourceInfo*>() && IsDelegating; return Initializee.is<TypeSourceInfo*>() && IsDelegating;
} }
/// \brief Determine whether this initializer is a pack expansion. /// \brief Determine whether this initializer is a pack expansion.
bool isPackExpansion() const { bool isPackExpansion() const {
return isBaseInitializer() && MemberOrEllipsisLocation.isValid(); return isBaseInitializer() && MemberOrEllipsisLocation.isValid();
} }
// \brief For a pack expansion, returns the location of the ellipsis. // \brief For a pack expansion, returns the location of the ellipsis.
SourceLocation getEllipsisLoc() const { SourceLocation getEllipsisLoc() const {
assert(isPackExpansion() && "Initializer is not a pack expansion"); assert(isPackExpansion() && "Initializer is not a pack expansion");
return MemberOrEllipsisLocation; return MemberOrEllipsisLocation;
} }
/// If this is a base class initializer, returns the type of the /// If this is a base class initializer, returns the type of the
/// base class with location information. Otherwise, returns an NULL /// base class with location information. Otherwise, returns an NULL
/// type location. /// type location.
TypeLoc getBaseClassLoc() const; TypeLoc getBaseClassLoc() const;
@ -1579,7 +1580,7 @@ public:
/// Returns whether the base is virtual or not. /// Returns whether the base is virtual or not.
bool isBaseVirtual() const { bool isBaseVirtual() const {
assert(isBaseInitializer() && "Must call this on base initializer!"); assert(isBaseInitializer() && "Must call this on base initializer!");
return IsVirtual; return IsVirtual;
} }
@ -1588,7 +1589,7 @@ public:
TypeSourceInfo *getTypeSourceInfo() const { TypeSourceInfo *getTypeSourceInfo() const {
return Initializee.dyn_cast<TypeSourceInfo *>(); return Initializee.dyn_cast<TypeSourceInfo *>();
} }
/// getMember - If this is a member initializer, returns the /// getMember - If this is a member initializer, returns the
/// declaration of the non-static data member being /// declaration of the non-static data member being
/// initialized. Otherwise, returns NULL. /// initialized. Otherwise, returns NULL.
@ -1614,13 +1615,13 @@ public:
return 0; return 0;
} }
SourceLocation getMemberLocation() const { SourceLocation getMemberLocation() const {
return MemberOrEllipsisLocation; return MemberOrEllipsisLocation;
} }
/// \brief Determine the source location of the initializer. /// \brief Determine the source location of the initializer.
SourceLocation getSourceLocation() const; SourceLocation getSourceLocation() const;
/// \brief Determine the source range covering the entire initializer. /// \brief Determine the source range covering the entire initializer.
SourceRange getSourceRange() const; SourceRange getSourceRange() const;
@ -1657,7 +1658,7 @@ public:
return IsWritten ? 0 : SourceOrderOrNumArrayIndices; return IsWritten ? 0 : SourceOrderOrNumArrayIndices;
} }
/// \brief Retrieve a particular array index variable used to /// \brief Retrieve a particular array index variable used to
/// describe an array member initialization. /// describe an array member initialization.
VarDecl *getArrayIndex(unsigned I) { VarDecl *getArrayIndex(unsigned I) {
assert(I < getNumArrayIndices() && "Out of bounds member array index"); assert(I < getNumArrayIndices() && "Out of bounds member array index");
@ -1671,7 +1672,7 @@ public:
assert(I < getNumArrayIndices() && "Out of bounds member array index"); assert(I < getNumArrayIndices() && "Out of bounds member array index");
reinterpret_cast<VarDecl **>(this + 1)[I] = Index; reinterpret_cast<VarDecl **>(this + 1)[I] = Index;
} }
/// \brief Get the initializer. This is 0 if this is an in-class initializer /// \brief Get the initializer. This is 0 if this is an in-class initializer
/// for a non-static data member which has not yet been parsed. /// for a non-static data member which has not yet been parsed.
Expr *getInit() const { Expr *getInit() const {
@ -1713,7 +1714,7 @@ class CXXConstructorDecl : public CXXMethodDecl {
CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation StartLoc, CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo, const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo, QualType T, TypeSourceInfo *TInfo,
bool isExplicitSpecified, bool isInline, bool isExplicitSpecified, bool isInline,
bool isImplicitlyDeclared, bool isConstexpr) bool isImplicitlyDeclared, bool isConstexpr)
: CXXMethodDecl(CXXConstructor, RD, StartLoc, NameInfo, T, TInfo, false, : CXXMethodDecl(CXXConstructor, RD, StartLoc, NameInfo, T, TInfo, false,
SC_None, isInline, isConstexpr, SourceLocation()), SC_None, isInline, isConstexpr, SourceLocation()),
@ -1735,7 +1736,7 @@ public:
/// isExplicitSpecified - Whether this constructor declaration has the /// isExplicitSpecified - Whether this constructor declaration has the
/// 'explicit' keyword specified. /// 'explicit' keyword specified.
bool isExplicitSpecified() const { return IsExplicitSpecified; } bool isExplicitSpecified() const { return IsExplicitSpecified; }
/// isExplicit - Whether this constructor was marked "explicit" or not. /// isExplicit - Whether this constructor was marked "explicit" or not.
bool isExplicit() const { bool isExplicit() const {
return cast<CXXConstructorDecl>(getFirstDeclaration()) return cast<CXXConstructorDecl>(getFirstDeclaration())
@ -1783,7 +1784,8 @@ public:
} }
typedef std::reverse_iterator<init_iterator> init_reverse_iterator; typedef std::reverse_iterator<init_iterator> init_reverse_iterator;
typedef std::reverse_iterator<init_const_iterator> init_const_reverse_iterator; typedef std::reverse_iterator<init_const_iterator>
init_const_reverse_iterator;
init_reverse_iterator init_rbegin() { init_reverse_iterator init_rbegin() {
return init_reverse_iterator(init_end()); return init_reverse_iterator(init_end());
@ -1899,12 +1901,12 @@ public:
CXXConstructorDecl *getCanonicalDecl() { CXXConstructorDecl *getCanonicalDecl() {
return cast<CXXConstructorDecl>(FunctionDecl::getCanonicalDecl()); return cast<CXXConstructorDecl>(FunctionDecl::getCanonicalDecl());
} }
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const CXXConstructorDecl *D) { return true; } static bool classof(const CXXConstructorDecl *D) { return true; }
static bool classofKind(Kind K) { return K == CXXConstructor; } static bool classofKind(Kind K) { return K == CXXConstructor; }
friend class ASTDeclReader; friend class ASTDeclReader;
friend class ASTDeclWriter; friend class ASTDeclWriter;
}; };
@ -1928,7 +1930,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
bool ImplicitlyDefined : 1; bool ImplicitlyDefined : 1;
FunctionDecl *OperatorDelete; FunctionDecl *OperatorDelete;
CXXDestructorDecl(CXXRecordDecl *RD, SourceLocation StartLoc, CXXDestructorDecl(CXXRecordDecl *RD, SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo, const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo, QualType T, TypeSourceInfo *TInfo,
@ -1954,7 +1956,8 @@ public:
/// already been defined. /// already been defined.
bool isImplicitlyDefined() const { bool isImplicitlyDefined() const {
assert(isThisDeclarationADefinition() && assert(isThisDeclarationADefinition() &&
"Can only get the implicit-definition flag once the destructor has been defined"); "Can only get the implicit-definition flag once the destructor has "
"been defined");
return ImplicitlyDefined; return ImplicitlyDefined;
} }
@ -1962,7 +1965,8 @@ public:
/// implicitly defined or not. /// implicitly defined or not.
void setImplicitlyDefined(bool ID) { void setImplicitlyDefined(bool ID) {
assert(isThisDeclarationADefinition() && assert(isThisDeclarationADefinition() &&
"Can only set the implicit-definition flag once the destructor has been defined"); "Can only set the implicit-definition flag once the destructor has "
"been defined");
ImplicitlyDefined = ID; ImplicitlyDefined = ID;
} }
@ -1973,7 +1977,7 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const CXXDestructorDecl *D) { return true; } static bool classof(const CXXDestructorDecl *D) { return true; }
static bool classofKind(Kind K) { return K == CXXDestructor; } static bool classofKind(Kind K) { return K == CXXDestructor; }
friend class ASTDeclReader; friend class ASTDeclReader;
friend class ASTDeclWriter; friend class ASTDeclWriter;
}; };
@ -1988,7 +1992,7 @@ public:
/// }; /// };
/// @endcode /// @endcode
class CXXConversionDecl : public CXXMethodDecl { class CXXConversionDecl : public CXXMethodDecl {
/// IsExplicitSpecified - Whether this conversion function declaration is /// IsExplicitSpecified - Whether this conversion function declaration is
/// marked "explicit", meaning that it can only be applied when the user /// marked "explicit", meaning that it can only be applied when the user
/// explicitly wrote a cast. This is a C++0x feature. /// explicitly wrote a cast. This is a C++0x feature.
bool IsExplicitSpecified : 1; bool IsExplicitSpecified : 1;
@ -2012,7 +2016,7 @@ public:
bool isConstexpr, bool isConstexpr,
SourceLocation EndLocation); SourceLocation EndLocation);
/// IsExplicitSpecified - Whether this conversion function declaration is /// IsExplicitSpecified - Whether this conversion function declaration is
/// marked "explicit", meaning that it can only be applied when the user /// marked "explicit", meaning that it can only be applied when the user
/// explicitly wrote a cast. This is a C++0x feature. /// explicitly wrote a cast. This is a C++0x feature.
bool isExplicitSpecified() const { return IsExplicitSpecified; } bool isExplicitSpecified() const { return IsExplicitSpecified; }
@ -2035,7 +2039,7 @@ public:
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const CXXConversionDecl *D) { return true; } static bool classof(const CXXConversionDecl *D) { return true; }
static bool classofKind(Kind K) { return K == CXXConversion; } static bool classofKind(Kind K) { return K == CXXConversion; }
friend class ASTDeclReader; friend class ASTDeclReader;
friend class ASTDeclWriter; friend class ASTDeclWriter;
}; };
@ -2121,7 +2125,7 @@ public:
class UsingDirectiveDecl : public NamedDecl { class UsingDirectiveDecl : public NamedDecl {
/// \brief The location of the "using" keyword. /// \brief The location of the "using" keyword.
SourceLocation UsingLoc; SourceLocation UsingLoc;
/// SourceLocation - Location of 'namespace' token. /// SourceLocation - Location of 'namespace' token.
SourceLocation NamespaceLoc; SourceLocation NamespaceLoc;
@ -2156,11 +2160,11 @@ public:
/// \brief Retrieve the nested-name-specifier that qualifies the /// \brief Retrieve the nested-name-specifier that qualifies the
/// name of the namespace, with source-location information. /// name of the namespace, with source-location information.
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// \brief Retrieve the nested-name-specifier that qualifies the /// \brief Retrieve the nested-name-specifier that qualifies the
/// name of the namespace. /// name of the namespace.
NestedNameSpecifier *getQualifier() const { NestedNameSpecifier *getQualifier() const {
return QualifierLoc.getNestedNameSpecifier(); return QualifierLoc.getNestedNameSpecifier();
} }
NamedDecl *getNominatedNamespaceAsWritten() { return NominatedNamespace; } NamedDecl *getNominatedNamespaceAsWritten() { return NominatedNamespace; }
@ -2182,7 +2186,7 @@ public:
/// \brief Return the location of the "using" keyword. /// \brief Return the location of the "using" keyword.
SourceLocation getUsingLoc() const { return UsingLoc; } SourceLocation getUsingLoc() const { return UsingLoc; }
// FIXME: Could omit 'Key' in name. // FIXME: Could omit 'Key' in name.
/// getNamespaceKeyLocation - Returns location of namespace keyword. /// getNamespaceKeyLocation - Returns location of namespace keyword.
SourceLocation getNamespaceKeyLocation() const { return NamespaceLoc; } SourceLocation getNamespaceKeyLocation() const { return NamespaceLoc; }
@ -2201,14 +2205,14 @@ public:
SourceRange getSourceRange() const { SourceRange getSourceRange() const {
return SourceRange(UsingLoc, getLocation()); return SourceRange(UsingLoc, getLocation());
} }
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const UsingDirectiveDecl *D) { return true; } static bool classof(const UsingDirectiveDecl *D) { return true; }
static bool classofKind(Kind K) { return K == UsingDirective; } static bool classofKind(Kind K) { return K == UsingDirective; }
// Friend for getUsingDirectiveName. // Friend for getUsingDirectiveName.
friend class DeclContext; friend class DeclContext;
friend class ASTDeclReader; friend class ASTDeclReader;
}; };
@ -2223,10 +2227,10 @@ class NamespaceAliasDecl : public NamedDecl {
/// IdentLoc - Location of namespace identifier. Accessed by TargetNameLoc. /// IdentLoc - Location of namespace identifier. Accessed by TargetNameLoc.
SourceLocation IdentLoc; SourceLocation IdentLoc;
/// \brief The nested-name-specifier that precedes the namespace. /// \brief The nested-name-specifier that precedes the namespace.
NestedNameSpecifierLoc QualifierLoc; NestedNameSpecifierLoc QualifierLoc;
/// Namespace - The Decl that this alias points to. Can either be a /// Namespace - The Decl that this alias points to. Can either be a
/// NamespaceDecl or a NamespaceAliasDecl. /// NamespaceDecl or a NamespaceAliasDecl.
NamedDecl *Namespace; NamedDecl *Namespace;
@ -2235,23 +2239,23 @@ class NamespaceAliasDecl : public NamedDecl {
SourceLocation AliasLoc, IdentifierInfo *Alias, SourceLocation AliasLoc, IdentifierInfo *Alias,
NestedNameSpecifierLoc QualifierLoc, NestedNameSpecifierLoc QualifierLoc,
SourceLocation IdentLoc, NamedDecl *Namespace) SourceLocation IdentLoc, NamedDecl *Namespace)
: NamedDecl(NamespaceAlias, DC, AliasLoc, Alias), : NamedDecl(NamespaceAlias, DC, AliasLoc, Alias),
NamespaceLoc(NamespaceLoc), IdentLoc(IdentLoc), NamespaceLoc(NamespaceLoc), IdentLoc(IdentLoc),
QualifierLoc(QualifierLoc), Namespace(Namespace) { } QualifierLoc(QualifierLoc), Namespace(Namespace) { }
friend class ASTDeclReader; friend class ASTDeclReader;
public: public:
/// \brief Retrieve the nested-name-specifier that qualifies the /// \brief Retrieve the nested-name-specifier that qualifies the
/// name of the namespace, with source-location information. /// name of the namespace, with source-location information.
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// \brief Retrieve the nested-name-specifier that qualifies the /// \brief Retrieve the nested-name-specifier that qualifies the
/// name of the namespace. /// name of the namespace.
NestedNameSpecifier *getQualifier() const { NestedNameSpecifier *getQualifier() const {
return QualifierLoc.getNestedNameSpecifier(); return QualifierLoc.getNestedNameSpecifier();
} }
/// \brief Retrieve the namespace declaration aliased by this directive. /// \brief Retrieve the namespace declaration aliased by this directive.
NamespaceDecl *getNamespace() { NamespaceDecl *getNamespace() {
if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(Namespace)) if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(Namespace))
@ -2279,7 +2283,7 @@ public:
NamedDecl *getAliasedNamespace() const { return Namespace; } NamedDecl *getAliasedNamespace() const { return Namespace; }
static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC, static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation NamespaceLoc, SourceLocation NamespaceLoc,
SourceLocation AliasLoc, SourceLocation AliasLoc,
IdentifierInfo *Alias, IdentifierInfo *Alias,
NestedNameSpecifierLoc QualifierLoc, NestedNameSpecifierLoc QualifierLoc,
@ -2289,7 +2293,7 @@ public:
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const {
return SourceRange(NamespaceLoc, IdentLoc); return SourceRange(NamespaceLoc, IdentLoc);
} }
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const NamespaceAliasDecl *D) { return true; } static bool classof(const NamespaceAliasDecl *D) { return true; }
static bool classofKind(Kind K) { return K == NamespaceAlias; } static bool classofKind(Kind K) { return K == NamespaceAlias; }
@ -2383,7 +2387,7 @@ class UsingDecl : public NamedDecl {
// \brief Has 'typename' keyword. // \brief Has 'typename' keyword.
bool IsTypeName; bool IsTypeName;
UsingDecl(DeclContext *DC, SourceLocation UL, UsingDecl(DeclContext *DC, SourceLocation UL,
NestedNameSpecifierLoc QualifierLoc, NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo, bool IsTypeNameArg) const DeclarationNameInfo &NameInfo, bool IsTypeNameArg)
: NamedDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()), : NamedDecl(Using, DC, NameInfo.getLoc(), NameInfo.getName()),
@ -2403,8 +2407,8 @@ public:
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// \brief Retrieve the nested-name-specifier that qualifies the name. /// \brief Retrieve the nested-name-specifier that qualifies the name.
NestedNameSpecifier *getQualifier() const { NestedNameSpecifier *getQualifier() const {
return QualifierLoc.getNestedNameSpecifier(); return QualifierLoc.getNestedNameSpecifier();
} }
DeclarationNameInfo getNameInfo() const { DeclarationNameInfo getNameInfo() const {
@ -2507,7 +2511,7 @@ class UnresolvedUsingValueDecl : public ValueDecl {
DeclarationNameLoc DNLoc; DeclarationNameLoc DNLoc;
UnresolvedUsingValueDecl(DeclContext *DC, QualType Ty, UnresolvedUsingValueDecl(DeclContext *DC, QualType Ty,
SourceLocation UsingLoc, SourceLocation UsingLoc,
NestedNameSpecifierLoc QualifierLoc, NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo) const DeclarationNameInfo &NameInfo)
: ValueDecl(UnresolvedUsingValue, DC, : ValueDecl(UnresolvedUsingValue, DC,
@ -2528,17 +2532,17 @@ public:
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// \brief Retrieve the nested-name-specifier that qualifies the name. /// \brief Retrieve the nested-name-specifier that qualifies the name.
NestedNameSpecifier *getQualifier() const { NestedNameSpecifier *getQualifier() const {
return QualifierLoc.getNestedNameSpecifier(); return QualifierLoc.getNestedNameSpecifier();
} }
DeclarationNameInfo getNameInfo() const { DeclarationNameInfo getNameInfo() const {
return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
} }
static UnresolvedUsingValueDecl * static UnresolvedUsingValueDecl *
Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc,
NestedNameSpecifierLoc QualifierLoc, NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo); const DeclarationNameInfo &NameInfo);
SourceRange getSourceRange() const { SourceRange getSourceRange() const {
@ -2575,14 +2579,14 @@ class UnresolvedUsingTypenameDecl : public TypeDecl {
UnresolvedUsingTypenameDecl(DeclContext *DC, SourceLocation UsingLoc, UnresolvedUsingTypenameDecl(DeclContext *DC, SourceLocation UsingLoc,
SourceLocation TypenameLoc, SourceLocation TypenameLoc,
NestedNameSpecifierLoc QualifierLoc, NestedNameSpecifierLoc QualifierLoc,
SourceLocation TargetNameLoc, SourceLocation TargetNameLoc,
IdentifierInfo *TargetName) IdentifierInfo *TargetName)
: TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName, : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName,
UsingLoc), UsingLoc),
TypenameLocation(TypenameLoc), QualifierLoc(QualifierLoc) { } TypenameLocation(TypenameLoc), QualifierLoc(QualifierLoc) { }
friend class ASTDeclReader; friend class ASTDeclReader;
public: public:
/// \brief Returns the source location of the 'using' keyword. /// \brief Returns the source location of the 'using' keyword.
SourceLocation getUsingLoc() const { return getLocStart(); } SourceLocation getUsingLoc() const { return getLocStart(); }
@ -2595,8 +2599,8 @@ public:
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// \brief Retrieve the nested-name-specifier that qualifies the name. /// \brief Retrieve the nested-name-specifier that qualifies the name.
NestedNameSpecifier *getQualifier() const { NestedNameSpecifier *getQualifier() const {
return QualifierLoc.getNestedNameSpecifier(); return QualifierLoc.getNestedNameSpecifier();
} }
static UnresolvedUsingTypenameDecl * static UnresolvedUsingTypenameDecl *

View File

@ -84,7 +84,7 @@ public:
loc_iterator loc_begin() const { return Locations; } loc_iterator loc_begin() const { return Locations; }
loc_iterator loc_end() const { return Locations + size(); } loc_iterator loc_end() const { return Locations + size(); }
void set(ObjCProtocolDecl* const* InList, unsigned Elts, void set(ObjCProtocolDecl* const* InList, unsigned Elts,
const SourceLocation *Locs, ASTContext &Ctx); const SourceLocation *Locs, ASTContext &Ctx);
}; };
@ -124,7 +124,7 @@ private:
// Synthesized declaration method for a property setter/getter // Synthesized declaration method for a property setter/getter
unsigned IsSynthesized : 1; unsigned IsSynthesized : 1;
// Method has a definition. // Method has a definition.
unsigned IsDefined : 1; unsigned IsDefined : 1;
@ -144,14 +144,14 @@ private:
/// \brief Indicates whether this method has a related result type. /// \brief Indicates whether this method has a related result type.
unsigned RelatedResultType : 1; unsigned RelatedResultType : 1;
/// \brief Whether the locations of the selector identifiers are in a /// \brief Whether the locations of the selector identifiers are in a
/// "standard" position, a enum SelectorLocationsKind. /// "standard" position, a enum SelectorLocationsKind.
unsigned SelLocsKind : 2; unsigned SelLocsKind : 2;
// Result type of this method. // Result type of this method.
QualType MethodDeclType; QualType MethodDeclType;
// Type source information for the result type. // Type source information for the result type.
TypeSourceInfo *ResultTInfo; TypeSourceInfo *ResultTInfo;
@ -246,7 +246,7 @@ public:
SourceLocation beginLoc, SourceLocation beginLoc,
SourceLocation endLoc, SourceLocation endLoc,
Selector SelInfo, Selector SelInfo,
QualType T, QualType T,
TypeSourceInfo *ResultTInfo, TypeSourceInfo *ResultTInfo,
DeclContext *contextDecl, DeclContext *contextDecl,
bool isInstance = true, bool isInstance = true,
@ -270,14 +270,14 @@ public:
/// \brief Determine whether this method has a result type that is related /// \brief Determine whether this method has a result type that is related
/// to the message receiver's type. /// to the message receiver's type.
bool hasRelatedResultType() const { return RelatedResultType; } bool hasRelatedResultType() const { return RelatedResultType; }
/// \brief Note whether this method has a related result type. /// \brief Note whether this method has a related result type.
void SetRelatedResultType(bool RRT = true) { RelatedResultType = RRT; } void SetRelatedResultType(bool RRT = true) { RelatedResultType = RRT; }
/// \brief True if this is a method redeclaration in the same interface. /// \brief True if this is a method redeclaration in the same interface.
bool isRedeclaration() const { return IsRedeclaration; } bool isRedeclaration() const { return IsRedeclaration; }
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod); void setAsRedeclaration(const ObjCMethodDecl *PrevMethod);
// Location information, modeled after the Stmt API. // Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); } SourceLocation getLocStart() const { return getLocation(); }
SourceLocation getLocEnd() const { return EndLoc; } SourceLocation getLocEnd() const { return EndLoc; }
@ -319,12 +319,12 @@ public:
QualType getResultType() const { return MethodDeclType; } QualType getResultType() const { return MethodDeclType; }
void setResultType(QualType T) { MethodDeclType = T; } void setResultType(QualType T) { MethodDeclType = T; }
/// \brief Determine the type of an expression that sends a message to this /// \brief Determine the type of an expression that sends a message to this
/// function. /// function.
QualType getSendResultType() const { QualType getSendResultType() const {
return getResultType().getNonLValueExprType(getASTContext()); return getResultType().getNonLValueExprType(getASTContext());
} }
TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; } TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; }
void setResultTypeSourceInfo(TypeSourceInfo *TInfo) { ResultTInfo = TInfo; } void setResultTypeSourceInfo(TypeSourceInfo *TInfo) { ResultTInfo = TInfo; }
@ -338,8 +338,8 @@ public:
param_iterator param_end() { return getParams() + NumParams; } param_iterator param_end() { return getParams() + NumParams; }
// This method returns and of the parameters which are part of the selector // This method returns and of the parameters which are part of the selector
// name mangling requirements. // name mangling requirements.
param_const_iterator sel_param_end() const { param_const_iterator sel_param_end() const {
return param_begin() + getSelector().getNumArgs(); return param_begin() + getSelector().getNumArgs();
} }
/// \brief Sets the method's parameters and selector source locations. /// \brief Sets the method's parameters and selector source locations.
@ -385,7 +385,7 @@ public:
bool isSynthesized() const { return IsSynthesized; } bool isSynthesized() const { return IsSynthesized; }
void setSynthesized(bool isSynth) { IsSynthesized = isSynth; } void setSynthesized(bool isSynth) { IsSynthesized = isSynth; }
bool isDefined() const { return IsDefined; } bool isDefined() const { return IsDefined; }
void setDefined(bool isDefined) { IsDefined = isDefined; } void setDefined(bool isDefined) { IsDefined = isDefined; }
@ -551,7 +551,7 @@ class ObjCInterfaceDecl : public ObjCContainerDecl {
/// Protocols referenced in the @interface declaration /// Protocols referenced in the @interface declaration
ObjCProtocolList ReferencedProtocols; ObjCProtocolList ReferencedProtocols;
/// Protocols reference in both the @interface and class extensions. /// Protocols reference in both the @interface and class extensions.
ObjCList<ObjCProtocolDecl> AllReferencedProtocols; ObjCList<ObjCProtocolDecl> AllReferencedProtocols;
@ -561,7 +561,7 @@ class ObjCInterfaceDecl : public ObjCContainerDecl {
/// and class extensions come long after the initial interface declaration, /// and class extensions come long after the initial interface declaration,
/// and we avoid dynamically-resized arrays in the AST wherever possible. /// and we avoid dynamically-resized arrays in the AST wherever possible.
ObjCCategoryDecl *CategoryList; ObjCCategoryDecl *CategoryList;
/// IvarList - List of all ivars defined by this class; including class /// IvarList - List of all ivars defined by this class; including class
/// extensions and implementation. This list is built lazily. /// extensions and implementation. This list is built lazily.
ObjCIvarDecl *IvarList; ObjCIvarDecl *IvarList;
@ -573,11 +573,11 @@ class ObjCInterfaceDecl : public ObjCContainerDecl {
bool InitiallyForwardDecl : 1; bool InitiallyForwardDecl : 1;
bool ForwardDecl:1; // declared with @class. bool ForwardDecl:1; // declared with @class.
bool InternalInterface:1; // true - no @interface for @implementation bool InternalInterface:1; // true - no @interface for @implementation
/// \brief Indicates that the contents of this Objective-C class will be /// \brief Indicates that the contents of this Objective-C class will be
/// completed by the external AST source when required. /// completed by the external AST source when required.
mutable bool ExternallyCompleted : 1; mutable bool ExternallyCompleted : 1;
SourceLocation SuperClassLoc; // location of the super class identifier. SourceLocation SuperClassLoc; // location of the super class identifier.
SourceLocation EndLoc; // marks the '>', '}', or identifier. SourceLocation EndLoc; // marks the '>', '}', or identifier.
@ -598,16 +598,16 @@ public:
return SourceRange(getAtStartLoc(), getLocation()); return SourceRange(getAtStartLoc(), getLocation());
return ObjCContainerDecl::getSourceRange(); return ObjCContainerDecl::getSourceRange();
} }
/// \brief Indicate that this Objective-C class is complete, but that /// \brief Indicate that this Objective-C class is complete, but that
/// the external AST source will be responsible for filling in its contents /// the external AST source will be responsible for filling in its contents
/// when a complete class is required. /// when a complete class is required.
void setExternallyCompleted(); void setExternallyCompleted();
const ObjCProtocolList &getReferencedProtocols() const { const ObjCProtocolList &getReferencedProtocols() const {
if (ExternallyCompleted) if (ExternallyCompleted)
LoadExternalDefinition(); LoadExternalDefinition();
return ReferencedProtocols; return ReferencedProtocols;
} }
@ -625,7 +625,7 @@ public:
} }
typedef ObjCProtocolList::iterator protocol_iterator; typedef ObjCProtocolList::iterator protocol_iterator;
protocol_iterator protocol_begin() const { protocol_iterator protocol_begin() const {
if (ExternallyCompleted) if (ExternallyCompleted)
LoadExternalDefinition(); LoadExternalDefinition();
@ -641,22 +641,22 @@ public:
typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
protocol_loc_iterator protocol_loc_begin() const { protocol_loc_iterator protocol_loc_begin() const {
if (ExternallyCompleted) if (ExternallyCompleted)
LoadExternalDefinition(); LoadExternalDefinition();
return ReferencedProtocols.loc_begin(); return ReferencedProtocols.loc_begin();
} }
protocol_loc_iterator protocol_loc_end() const { protocol_loc_iterator protocol_loc_end() const {
if (ExternallyCompleted) if (ExternallyCompleted)
LoadExternalDefinition(); LoadExternalDefinition();
return ReferencedProtocols.loc_end(); return ReferencedProtocols.loc_end();
} }
typedef ObjCList<ObjCProtocolDecl>::iterator all_protocol_iterator; typedef ObjCList<ObjCProtocolDecl>::iterator all_protocol_iterator;
all_protocol_iterator all_referenced_protocol_begin() const { all_protocol_iterator all_referenced_protocol_begin() const {
if (ExternallyCompleted) if (ExternallyCompleted)
LoadExternalDefinition(); LoadExternalDefinition();
@ -668,7 +668,7 @@ public:
if (ExternallyCompleted) if (ExternallyCompleted)
LoadExternalDefinition(); LoadExternalDefinition();
return AllReferencedProtocols.empty() ? protocol_end() return AllReferencedProtocols.empty() ? protocol_end()
: AllReferencedProtocols.end(); : AllReferencedProtocols.end();
} }
@ -680,9 +680,9 @@ public:
unsigned ivar_size() const { unsigned ivar_size() const {
return std::distance(ivar_begin(), ivar_end()); return std::distance(ivar_begin(), ivar_end());
} }
bool ivar_empty() const { return ivar_begin() == ivar_end(); } bool ivar_empty() const { return ivar_begin() == ivar_end(); }
ObjCIvarDecl *all_declared_ivar_begin(); ObjCIvarDecl *all_declared_ivar_begin();
const ObjCIvarDecl *all_declared_ivar_begin() const { const ObjCIvarDecl *all_declared_ivar_begin() const {
// Even though this modifies IvarList, it's conceptually const: // Even though this modifies IvarList, it's conceptually const:
@ -690,7 +690,7 @@ public:
return const_cast<ObjCInterfaceDecl *>(this)->all_declared_ivar_begin(); return const_cast<ObjCInterfaceDecl *>(this)->all_declared_ivar_begin();
} }
void setIvarList(ObjCIvarDecl *ivar) { IvarList = ivar; } void setIvarList(ObjCIvarDecl *ivar) { IvarList = ivar; }
/// setProtocolList - Set the list of protocols that this interface /// setProtocolList - Set the list of protocols that this interface
/// implements. /// implements.
void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num, void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num,
@ -700,7 +700,7 @@ public:
/// mergeClassExtensionProtocolList - Merge class extension's protocol list /// mergeClassExtensionProtocolList - Merge class extension's protocol list
/// into the protocol list for this class. /// into the protocol list for this class.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const* List, void mergeClassExtensionProtocolList(ObjCProtocolDecl *const* List,
unsigned Num, unsigned Num,
ASTContext &C); ASTContext &C);
@ -712,26 +712,26 @@ public:
bool isForwardDecl() const { return ForwardDecl; } bool isForwardDecl() const { return ForwardDecl; }
void setForwardDecl(bool val) { ForwardDecl = val; } void setForwardDecl(bool val) { ForwardDecl = val; }
ObjCInterfaceDecl *getSuperClass() const { ObjCInterfaceDecl *getSuperClass() const {
if (ExternallyCompleted) if (ExternallyCompleted)
LoadExternalDefinition(); LoadExternalDefinition();
return SuperClass; return SuperClass;
} }
void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
ObjCCategoryDecl* getCategoryList() const { ObjCCategoryDecl* getCategoryList() const {
if (ExternallyCompleted) if (ExternallyCompleted)
LoadExternalDefinition(); LoadExternalDefinition();
return CategoryList; return CategoryList;
} }
void setCategoryList(ObjCCategoryDecl *category) { void setCategoryList(ObjCCategoryDecl *category) {
CategoryList = category; CategoryList = category;
} }
ObjCCategoryDecl* getFirstClassExtension() const; ObjCCategoryDecl* getFirstClassExtension() const;
ObjCPropertyDecl ObjCPropertyDecl
@ -758,7 +758,7 @@ public:
return true; return true;
Class = Class->getSuperClass(); Class = Class->getSuperClass();
} }
return false; return false;
} }
ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName, ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
@ -778,7 +778,7 @@ public:
return lookupMethod(Sel, false/*isInstance*/); return lookupMethod(Sel, false/*isInstance*/);
} }
ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName); ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName);
// Lookup a method in the classes implementation hierarchy. // Lookup a method in the classes implementation hierarchy.
ObjCMethodDecl *lookupPrivateMethod(const Selector &Sel, bool Instance=true); ObjCMethodDecl *lookupPrivateMethod(const Selector &Sel, bool Instance=true);
@ -858,7 +858,7 @@ public:
/// interface the ivar is conceptually a part of in the case of synthesized /// interface the ivar is conceptually a part of in the case of synthesized
/// ivars. /// ivars.
const ObjCInterfaceDecl *getContainingInterface() const; const ObjCInterfaceDecl *getContainingInterface() const;
ObjCIvarDecl *getNextIvar() { return NextIvar; } ObjCIvarDecl *getNextIvar() { return NextIvar; }
const ObjCIvarDecl *getNextIvar() const { return NextIvar; } const ObjCIvarDecl *getNextIvar() const { return NextIvar; }
void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; } void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; }
@ -873,16 +873,16 @@ public:
void setSynthesize(bool synth) { Synthesized = synth; } void setSynthesize(bool synth) { Synthesized = synth; }
bool getSynthesize() const { return Synthesized; } bool getSynthesize() const { return Synthesized; }
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const ObjCIvarDecl *D) { return true; } static bool classof(const ObjCIvarDecl *D) { return true; }
static bool classofKind(Kind K) { return K == ObjCIvar; } static bool classofKind(Kind K) { return K == ObjCIvar; }
private: private:
/// NextIvar - Next Ivar in the list of ivars declared in class; class's /// NextIvar - Next Ivar in the list of ivars declared in class; class's
/// extensions and class's implementation /// extensions and class's implementation
ObjCIvarDecl *NextIvar; ObjCIvarDecl *NextIvar;
// NOTE: VC++ treats enums as signed, avoid using the AccessControl enum // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum
unsigned DeclAccess : 3; unsigned DeclAccess : 3;
unsigned Synthesized : 1; unsigned Synthesized : 1;
@ -967,11 +967,11 @@ public:
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
protocol_loc_iterator protocol_loc_begin() const { protocol_loc_iterator protocol_loc_begin() const {
return ReferencedProtocols.loc_begin(); return ReferencedProtocols.loc_begin();
} }
protocol_loc_iterator protocol_loc_end() const { protocol_loc_iterator protocol_loc_end() const {
return ReferencedProtocols.loc_end(); return ReferencedProtocols.loc_end();
} }
unsigned protocol_size() const { return ReferencedProtocols.size(); } unsigned protocol_size() const { return ReferencedProtocols.size(); }
@ -998,7 +998,7 @@ public:
/// Differs with \see isForwardDecl in that \see isForwardDecl will change to /// Differs with \see isForwardDecl in that \see isForwardDecl will change to
/// false when we see the definition, but this will remain true. /// false when we see the definition, but this will remain true.
bool isInitiallyForwardDecl() const { return InitiallyForwardDecl; } bool isInitiallyForwardDecl() const { return InitiallyForwardDecl; }
bool isForwardDecl() const { return isForwardProtoDecl; } bool isForwardDecl() const { return isForwardProtoDecl; }
void setForwardDecl(bool val) { isForwardProtoDecl = val; } void setForwardDecl(bool val) { isForwardProtoDecl = val; }
@ -1033,18 +1033,20 @@ private:
ObjCClassRef *ForwardDecl; ObjCClassRef *ForwardDecl;
ObjCClassDecl(DeclContext *DC, SourceLocation L, ObjCClassDecl(DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *const Elt, const SourceLocation Loc, ObjCInterfaceDecl *const Elt, const SourceLocation Loc,
ASTContext &C); ASTContext &C);
public: public:
static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *const Elt = 0, ObjCInterfaceDecl *const Elt = 0,
const SourceLocation Locs = SourceLocation()); const SourceLocation Locs = SourceLocation());
ObjCInterfaceDecl *getForwardInterfaceDecl() { return ForwardDecl->getInterface(); } ObjCInterfaceDecl *getForwardInterfaceDecl() {
return ForwardDecl->getInterface();
}
ObjCClassRef *getForwardDecl() { return ForwardDecl; } ObjCClassRef *getForwardDecl() { return ForwardDecl; }
void setClass(ASTContext &C, ObjCInterfaceDecl*const Cls, void setClass(ASTContext &C, ObjCInterfaceDecl*const Cls,
const SourceLocation Locs); const SourceLocation Locs);
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const;
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@ -1080,11 +1082,11 @@ public:
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();} protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
protocol_loc_iterator protocol_loc_begin() const { protocol_loc_iterator protocol_loc_begin() const {
return ReferencedProtocols.loc_begin(); return ReferencedProtocols.loc_begin();
} }
protocol_loc_iterator protocol_loc_end() const { protocol_loc_iterator protocol_loc_end() const {
return ReferencedProtocols.loc_end(); return ReferencedProtocols.loc_end();
} }
unsigned protocol_size() const { return ReferencedProtocols.size(); } unsigned protocol_size() const { return ReferencedProtocols.size(); }
@ -1133,7 +1135,7 @@ class ObjCCategoryDecl : public ObjCContainerDecl {
/// \brief The location of the category name in this declaration. /// \brief The location of the category name in this declaration.
SourceLocation CategoryNameLoc; SourceLocation CategoryNameLoc;
ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc, ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc,
SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc,
IdentifierInfo *Id, ObjCInterfaceDecl *IDecl) IdentifierInfo *Id, ObjCInterfaceDecl *IDecl)
: ObjCContainerDecl(ObjCCategory, DC, Id, ClassNameLoc, AtLoc), : ObjCContainerDecl(ObjCCategory, DC, Id, ClassNameLoc, AtLoc),
@ -1143,7 +1145,7 @@ class ObjCCategoryDecl : public ObjCContainerDecl {
public: public:
static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC, static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation AtLoc, SourceLocation AtLoc,
SourceLocation ClassNameLoc, SourceLocation ClassNameLoc,
SourceLocation CategoryNameLoc, SourceLocation CategoryNameLoc,
IdentifierInfo *Id, IdentifierInfo *Id,
@ -1172,21 +1174,21 @@ public:
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
unsigned protocol_size() const { return ReferencedProtocols.size(); } unsigned protocol_size() const { return ReferencedProtocols.size(); }
typedef ObjCProtocolList::loc_iterator protocol_loc_iterator; typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
protocol_loc_iterator protocol_loc_begin() const { protocol_loc_iterator protocol_loc_begin() const {
return ReferencedProtocols.loc_begin(); return ReferencedProtocols.loc_begin();
} }
protocol_loc_iterator protocol_loc_end() const { protocol_loc_iterator protocol_loc_end() const {
return ReferencedProtocols.loc_end(); return ReferencedProtocols.loc_end();
} }
ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; } ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
bool IsClassExtension() const { return getIdentifier() == 0; } bool IsClassExtension() const { return getIdentifier() == 0; }
const ObjCCategoryDecl *getNextClassExtension() const; const ObjCCategoryDecl *getNextClassExtension() const;
bool hasSynthBitfield() const { return HasSynthBitfield; } bool hasSynthBitfield() const { return HasSynthBitfield; }
void setHasSynthBitfield (bool val) { HasSynthBitfield = val; } void setHasSynthBitfield (bool val) { HasSynthBitfield = val; }
typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator; typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
ivar_iterator ivar_begin() const { ivar_iterator ivar_begin() const {
return ivar_iterator(decls_begin()); return ivar_iterator(decls_begin());
@ -1295,9 +1297,9 @@ public:
/// interface associated with this implementation. /// interface associated with this implementation.
/// FIXME: This is a bad API, we are overriding the NamedDecl::getIdentifier() /// FIXME: This is a bad API, we are overriding the NamedDecl::getIdentifier()
/// to mean something different. For example: /// to mean something different. For example:
/// ((NamedDecl *)SomeCategoryImplDecl)->getIdentifier() /// ((NamedDecl *)SomeCategoryImplDecl)->getIdentifier()
/// returns the class interface name, whereas /// returns the class interface name, whereas
/// ((ObjCCategoryImplDecl *)SomeCategoryImplDecl)->getIdentifier() /// ((ObjCCategoryImplDecl *)SomeCategoryImplDecl)->getIdentifier()
/// returns the category name. /// returns the category name.
IdentifierInfo *getIdentifier() const { IdentifierInfo *getIdentifier() const {
return Id; return Id;
@ -1363,10 +1365,10 @@ class ObjCImplementationDecl : public ObjCImplDecl {
/// true if class has a .cxx_[construct,destruct] method. /// true if class has a .cxx_[construct,destruct] method.
bool HasCXXStructors : 1; bool HasCXXStructors : 1;
/// true of class extension has at least one bitfield ivar. /// true of class extension has at least one bitfield ivar.
bool HasSynthBitfield : 1; bool HasSynthBitfield : 1;
ObjCImplementationDecl(DeclContext *DC, ObjCImplementationDecl(DeclContext *DC,
ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl, ObjCInterfaceDecl *superDecl,
@ -1380,18 +1382,18 @@ public:
ObjCInterfaceDecl *superDecl, ObjCInterfaceDecl *superDecl,
SourceLocation nameLoc, SourceLocation nameLoc,
SourceLocation atStartLoc); SourceLocation atStartLoc);
/// init_iterator - Iterates through the ivar initializer list. /// init_iterator - Iterates through the ivar initializer list.
typedef CXXCtorInitializer **init_iterator; typedef CXXCtorInitializer **init_iterator;
/// init_const_iterator - Iterates through the ivar initializer list. /// init_const_iterator - Iterates through the ivar initializer list.
typedef CXXCtorInitializer * const * init_const_iterator; typedef CXXCtorInitializer * const * init_const_iterator;
/// init_begin() - Retrieve an iterator to the first initializer. /// init_begin() - Retrieve an iterator to the first initializer.
init_iterator init_begin() { return IvarInitializers; } init_iterator init_begin() { return IvarInitializers; }
/// begin() - Retrieve an iterator to the first initializer. /// begin() - Retrieve an iterator to the first initializer.
init_const_iterator init_begin() const { return IvarInitializers; } init_const_iterator init_begin() const { return IvarInitializers; }
/// init_end() - Retrieve an iterator past the last initializer. /// init_end() - Retrieve an iterator past the last initializer.
init_iterator init_end() { init_iterator init_end() {
return IvarInitializers + NumIvarInitializers; return IvarInitializers + NumIvarInitializers;
@ -1404,21 +1406,21 @@ public:
unsigned getNumIvarInitializers() const { unsigned getNumIvarInitializers() const {
return NumIvarInitializers; return NumIvarInitializers;
} }
void setNumIvarInitializers(unsigned numNumIvarInitializers) { void setNumIvarInitializers(unsigned numNumIvarInitializers) {
NumIvarInitializers = numNumIvarInitializers; NumIvarInitializers = numNumIvarInitializers;
} }
void setIvarInitializers(ASTContext &C, void setIvarInitializers(ASTContext &C,
CXXCtorInitializer ** initializers, CXXCtorInitializer ** initializers,
unsigned numInitializers); unsigned numInitializers);
bool hasCXXStructors() const { return HasCXXStructors; } bool hasCXXStructors() const { return HasCXXStructors; }
void setHasCXXStructors(bool val) { HasCXXStructors = val; } void setHasCXXStructors(bool val) { HasCXXStructors = val; }
bool hasSynthBitfield() const { return HasSynthBitfield; } bool hasSynthBitfield() const { return HasSynthBitfield; }
void setHasSynthBitfield (bool val) { HasSynthBitfield = val; } void setHasSynthBitfield (bool val) { HasSynthBitfield = val; }
/// getIdentifier - Get the identifier that names the class /// getIdentifier - Get the identifier that names the class
/// interface associated with this implementation. /// interface associated with this implementation.
IdentifierInfo *getIdentifier() const { IdentifierInfo *getIdentifier() const {
@ -1553,7 +1555,7 @@ private:
ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
SourceLocation AtLocation, TypeSourceInfo *T) SourceLocation AtLocation, TypeSourceInfo *T)
: NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), DeclType(T), : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), DeclType(T),
PropertyAttributes(OBJC_PR_noattr), PropertyAttributes(OBJC_PR_noattr),
PropertyAttributesAsWritten(OBJC_PR_noattr), PropertyAttributesAsWritten(OBJC_PR_noattr),
PropertyImplementation(None), PropertyImplementation(None),
GetterName(Selector()), GetterName(Selector()),
@ -1567,7 +1569,7 @@ public:
PropertyControl propControl = None); PropertyControl propControl = None);
SourceLocation getAtLoc() const { return AtLoc; } SourceLocation getAtLoc() const { return AtLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; } void setAtLoc(SourceLocation L) { AtLoc = L; }
TypeSourceInfo *getTypeSourceInfo() const { return DeclType; } TypeSourceInfo *getTypeSourceInfo() const { return DeclType; }
QualType getType() const { return DeclType->getType(); } QualType getType() const { return DeclType->getType(); }
void setType(TypeSourceInfo *T) { DeclType = T; } void setType(TypeSourceInfo *T) { DeclType = T; }
@ -1588,11 +1590,11 @@ public:
OBJC_PR_unsafe_unretained | OBJC_PR_retain | OBJC_PR_strong | OBJC_PR_unsafe_unretained | OBJC_PR_retain | OBJC_PR_strong |
OBJC_PR_weak); OBJC_PR_weak);
} }
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) { void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) {
PropertyAttributesAsWritten = PRVal; PropertyAttributesAsWritten = PRVal;
} }
void makeitReadWriteAttribute(void) { void makeitReadWriteAttribute(void) {
PropertyAttributes &= ~OBJC_PR_readonly; PropertyAttributes &= ~OBJC_PR_readonly;
PropertyAttributes |= OBJC_PR_readwrite; PropertyAttributes |= OBJC_PR_readwrite;
@ -1683,7 +1685,7 @@ public:
}; };
private: private:
SourceLocation AtLoc; // location of @synthesize or @dynamic SourceLocation AtLoc; // location of @synthesize or @dynamic
/// \brief For @synthesize, the location of the ivar, if it was written in /// \brief For @synthesize, the location of the ivar, if it was written in
/// the source code. /// the source code.
/// ///
@ -1691,16 +1693,16 @@ private:
/// @synthesize int a = b /// @synthesize int a = b
/// \endcode /// \endcode
SourceLocation IvarLoc; SourceLocation IvarLoc;
/// Property declaration being implemented /// Property declaration being implemented
ObjCPropertyDecl *PropertyDecl; ObjCPropertyDecl *PropertyDecl;
/// Null for @dynamic. Required for @synthesize. /// Null for @dynamic. Required for @synthesize.
ObjCIvarDecl *PropertyIvarDecl; ObjCIvarDecl *PropertyIvarDecl;
/// Null for @dynamic. Non-null if property must be copy-constructed in getter /// Null for @dynamic. Non-null if property must be copy-constructed in getter
Expr *GetterCXXConstructor; Expr *GetterCXXConstructor;
/// Null for @dynamic. Non-null if property has assignment operator to call /// Null for @dynamic. Non-null if property has assignment operator to call
/// in Setter synthesis. /// in Setter synthesis.
Expr *SetterCXXAssignment; Expr *SetterCXXAssignment;
@ -1711,7 +1713,7 @@ private:
ObjCIvarDecl *ivarDecl, ObjCIvarDecl *ivarDecl,
SourceLocation ivarLoc) SourceLocation ivarLoc)
: Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc), : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl), IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl),
GetterCXXConstructor(0), SetterCXXAssignment(0) { GetterCXXConstructor(0), SetterCXXAssignment(0) {
assert (PK == Dynamic || PropertyIvarDecl); assert (PK == Dynamic || PropertyIvarDecl);
} }
@ -1725,7 +1727,7 @@ public:
SourceLocation ivarLoc); SourceLocation ivarLoc);
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const;
SourceLocation getLocStart() const { return AtLoc; } SourceLocation getLocStart() const { return AtLoc; }
void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
@ -1742,13 +1744,13 @@ public:
return PropertyIvarDecl; return PropertyIvarDecl;
} }
SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; } SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; }
void setPropertyIvarDecl(ObjCIvarDecl *Ivar, void setPropertyIvarDecl(ObjCIvarDecl *Ivar,
SourceLocation IvarLoc) { SourceLocation IvarLoc) {
PropertyIvarDecl = Ivar; PropertyIvarDecl = Ivar;
this->IvarLoc = IvarLoc; this->IvarLoc = IvarLoc;
} }
Expr *getGetterCXXConstructor() const { Expr *getGetterCXXConstructor() const {
return GetterCXXConstructor; return GetterCXXConstructor;
} }
@ -1762,11 +1764,11 @@ public:
void setSetterCXXAssignment(Expr *setterCXXAssignment) { void setSetterCXXAssignment(Expr *setterCXXAssignment) {
SetterCXXAssignment = setterCXXAssignment; SetterCXXAssignment = setterCXXAssignment;
} }
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const ObjCPropertyImplDecl *D) { return true; } static bool classof(const ObjCPropertyImplDecl *D) { return true; }
static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; } static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; }
friend class ASTDeclReader; friend class ASTDeclReader;
}; };

View File

@ -99,7 +99,7 @@ public:
/// The first template parameter list in a declaration will have depth 0, /// The first template parameter list in a declaration will have depth 0,
/// the second template parameter list will have depth 1, etc. /// the second template parameter list will have depth 1, etc.
unsigned getDepth() const; unsigned getDepth() const;
SourceLocation getTemplateLoc() const { return TemplateLoc; } SourceLocation getTemplateLoc() const { return TemplateLoc; }
SourceLocation getLAngleLoc() const { return LAngleLoc; } SourceLocation getLAngleLoc() const { return LAngleLoc; }
SourceLocation getRAngleLoc() const { return RAngleLoc; } SourceLocation getRAngleLoc() const { return RAngleLoc; }
@ -116,7 +116,8 @@ class FixedSizeTemplateParameterList : public TemplateParameterList {
NamedDecl *Params[N]; NamedDecl *Params[N];
public: public:
FixedSizeTemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, FixedSizeTemplateParameterList(SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
NamedDecl **Params, SourceLocation RAngleLoc) : NamedDecl **Params, SourceLocation RAngleLoc) :
TemplateParameterList(TemplateLoc, LAngleLoc, Params, N, RAngleLoc) { TemplateParameterList(TemplateLoc, LAngleLoc, Params, N, RAngleLoc) {
} }
@ -142,7 +143,7 @@ class TemplateArgumentList {
: Arguments(Args, Owned), NumArguments(NumArgs) { } : Arguments(Args, Owned), NumArguments(NumArgs) { }
public: public:
/// \brief Type used to indicate that the template argument list itself is a /// \brief Type used to indicate that the template argument list itself is a
/// stack object. It does not own its template arguments. /// stack object. It does not own its template arguments.
enum OnStackType { OnStack }; enum OnStackType { OnStack };
@ -156,12 +157,12 @@ public:
/// ///
/// The template argument list does not own the template arguments /// The template argument list does not own the template arguments
/// provided. /// provided.
explicit TemplateArgumentList(OnStackType, explicit TemplateArgumentList(OnStackType,
const TemplateArgument *Args, unsigned NumArgs) const TemplateArgument *Args, unsigned NumArgs)
: Arguments(Args, false), NumArguments(NumArgs) { } : Arguments(Args, false), NumArguments(NumArgs) { }
/// \brief Produces a shallow copy of the given template argument list. /// \brief Produces a shallow copy of the given template argument list.
/// ///
/// This operation assumes that the input argument list outlives it. /// This operation assumes that the input argument list outlives it.
/// This takes the list as a pointer to avoid looking like a copy /// This takes the list as a pointer to avoid looking like a copy
/// constructor, since this really really isn't safe to use that /// constructor, since this really really isn't safe to use that
@ -244,7 +245,7 @@ public:
protected: protected:
NamedDecl *TemplatedDecl; NamedDecl *TemplatedDecl;
TemplateParameterList* TemplateParams; TemplateParameterList* TemplateParams;
public: public:
/// \brief Initialize the underlying templated declaration and /// \brief Initialize the underlying templated declaration and
/// template parameters. /// template parameters.
@ -298,9 +299,9 @@ public:
const ASTTemplateArgumentListInfo *TemplateArgumentsAsWritten; const ASTTemplateArgumentListInfo *TemplateArgumentsAsWritten;
/// \brief The point at which this function template specialization was /// \brief The point at which this function template specialization was
/// first instantiated. /// first instantiated.
SourceLocation PointOfInstantiation; SourceLocation PointOfInstantiation;
/// \brief Retrieve the template from which this function was specialized. /// \brief Retrieve the template from which this function was specialized.
FunctionTemplateDecl *getTemplate() const { return Template.getPointer(); } FunctionTemplateDecl *getTemplate() const { return Template.getPointer(); }
@ -325,16 +326,16 @@ public:
/// ///
/// The point of instantiation may be an invalid source location if this /// The point of instantiation may be an invalid source location if this
/// function has yet to be instantiated. /// function has yet to be instantiated.
SourceLocation getPointOfInstantiation() const { SourceLocation getPointOfInstantiation() const {
return PointOfInstantiation; return PointOfInstantiation;
} }
/// \brief Set the (first) point of instantiation of this function template /// \brief Set the (first) point of instantiation of this function template
/// specialization. /// specialization.
void setPointOfInstantiation(SourceLocation POI) { void setPointOfInstantiation(SourceLocation POI) {
PointOfInstantiation = POI; PointOfInstantiation = POI;
} }
void Profile(llvm::FoldingSetNodeID &ID) { void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, TemplateArguments->data(), Profile(ID, TemplateArguments->data(),
TemplateArguments->size(), TemplateArguments->size(),
@ -350,49 +351,49 @@ public:
} }
}; };
/// \brief Provides information a specialization of a member of a class /// \brief Provides information a specialization of a member of a class
/// template, which may be a member function, static data member, or /// template, which may be a member function, static data member, or
/// member class. /// member class.
class MemberSpecializationInfo { class MemberSpecializationInfo {
// The member declaration from which this member was instantiated, and the // The member declaration from which this member was instantiated, and the
// manner in which the instantiation occurred (in the lower two bits). // manner in which the instantiation occurred (in the lower two bits).
llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK; llvm::PointerIntPair<NamedDecl *, 2> MemberAndTSK;
// The point at which this member was first instantiated. // The point at which this member was first instantiated.
SourceLocation PointOfInstantiation; SourceLocation PointOfInstantiation;
public: public:
explicit explicit
MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK,
SourceLocation POI = SourceLocation()) SourceLocation POI = SourceLocation())
: MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) { : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
assert(TSK != TSK_Undeclared && assert(TSK != TSK_Undeclared &&
"Cannot encode undeclared template specializations for members"); "Cannot encode undeclared template specializations for members");
} }
/// \brief Retrieve the member declaration from which this member was /// \brief Retrieve the member declaration from which this member was
/// instantiated. /// instantiated.
NamedDecl *getInstantiatedFrom() const { return MemberAndTSK.getPointer(); } NamedDecl *getInstantiatedFrom() const { return MemberAndTSK.getPointer(); }
/// \brief Determine what kind of template specialization this is. /// \brief Determine what kind of template specialization this is.
TemplateSpecializationKind getTemplateSpecializationKind() const { TemplateSpecializationKind getTemplateSpecializationKind() const {
return (TemplateSpecializationKind)(MemberAndTSK.getInt() + 1); return (TemplateSpecializationKind)(MemberAndTSK.getInt() + 1);
} }
/// \brief Set the template specialization kind. /// \brief Set the template specialization kind.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK) { void setTemplateSpecializationKind(TemplateSpecializationKind TSK) {
assert(TSK != TSK_Undeclared && assert(TSK != TSK_Undeclared &&
"Cannot encode undeclared template specializations for members"); "Cannot encode undeclared template specializations for members");
MemberAndTSK.setInt(TSK - 1); MemberAndTSK.setInt(TSK - 1);
} }
/// \brief Retrieve the first point of instantiation of this member. /// \brief Retrieve the first point of instantiation of this member.
/// If the point of instantiation is an invalid location, then this member /// If the point of instantiation is an invalid location, then this member
/// has not yet been instantiated. /// has not yet been instantiated.
SourceLocation getPointOfInstantiation() const { SourceLocation getPointOfInstantiation() const {
return PointOfInstantiation; return PointOfInstantiation;
} }
/// \brief Set the first point of instantiation. /// \brief Set the first point of instantiation.
void setPointOfInstantiation(SourceLocation POI) { void setPointOfInstantiation(SourceLocation POI) {
PointOfInstantiation = POI; PointOfInstantiation = POI;
@ -414,14 +415,14 @@ class DependentFunctionTemplateSpecializationInfo {
union { union {
// Force sizeof to be a multiple of sizeof(void*) so that the // Force sizeof to be a multiple of sizeof(void*) so that the
// trailing data is aligned. // trailing data is aligned.
void *Aligner; void *Aligner;
struct { struct {
/// The number of potential template candidates. /// The number of potential template candidates.
unsigned NumTemplates; unsigned NumTemplates;
/// The number of template arguments. /// The number of template arguments.
unsigned NumArgs; unsigned NumArgs;
} d; } d;
}; };
@ -452,7 +453,7 @@ public:
/// \brief Returns the explicit template arguments that were given. /// \brief Returns the explicit template arguments that were given.
const TemplateArgumentLoc *getTemplateArgs() const { const TemplateArgumentLoc *getTemplateArgs() const {
return reinterpret_cast<const TemplateArgumentLoc*>( return reinterpret_cast<const TemplateArgumentLoc*>(
&getTemplates()[getNumTemplates()]); &getTemplates()[getNumTemplates()]);
} }
/// \brief Returns the number of explicit template arguments that were given. /// \brief Returns the number of explicit template arguments that were given.
@ -474,7 +475,7 @@ public:
return AngleLocs.getEnd(); return AngleLocs.getEnd();
} }
}; };
/// Declaration of a redeclarable template. /// Declaration of a redeclarable template.
class RedeclarableTemplateDecl : public TemplateDecl { class RedeclarableTemplateDecl : public TemplateDecl {
@ -631,7 +632,7 @@ public:
const_cast<RedeclarableTemplateDecl*>(this)->getMostRecentDeclaration(); const_cast<RedeclarableTemplateDecl*>(this)->getMostRecentDeclaration();
} }
/// \brief Determines whether this template was a specialization of a /// \brief Determines whether this template was a specialization of a
/// member template. /// member template.
/// ///
/// In the following example, the function template \c X<int>::f and the /// In the following example, the function template \c X<int>::f and the
@ -652,14 +653,14 @@ public:
bool isMemberSpecialization() { bool isMemberSpecialization() {
return getCommonPtr()->InstantiatedFromMember.getInt(); return getCommonPtr()->InstantiatedFromMember.getInt();
} }
/// \brief Note that this member template is a specialization. /// \brief Note that this member template is a specialization.
void setMemberSpecialization() { void setMemberSpecialization() {
assert(getCommonPtr()->InstantiatedFromMember.getPointer() && assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
"Only member templates can be member template specializations"); "Only member templates can be member template specializations");
getCommonPtr()->InstantiatedFromMember.setInt(true); getCommonPtr()->InstantiatedFromMember.setInt(true);
} }
/// \brief Retrieve the previous declaration of this template, or /// \brief Retrieve the previous declaration of this template, or
/// NULL if no such declaration exists. /// NULL if no such declaration exists.
RedeclarableTemplateDecl *getInstantiatedFromMemberTemplate() { RedeclarableTemplateDecl *getInstantiatedFromMemberTemplate() {
@ -774,11 +775,11 @@ protected:
/// function template. /// function template.
struct Common : CommonBase { struct Common : CommonBase {
Common() : InjectedArgs(0) { } Common() : InjectedArgs(0) { }
/// \brief The function template specializations for this function /// \brief The function template specializations for this function
/// template, including explicit specializations and instantiations. /// template, including explicit specializations and instantiations.
llvm::FoldingSet<FunctionTemplateSpecializationInfo> Specializations; llvm::FoldingSet<FunctionTemplateSpecializationInfo> Specializations;
/// \brief The set of "injected" template arguments used within this /// \brief The set of "injected" template arguments used within this
/// function template. /// function template.
/// ///
@ -813,7 +814,7 @@ protected:
/// retrieved by an earlier call to findSpecialization(). /// retrieved by an earlier call to findSpecialization().
void addSpecialization(FunctionTemplateSpecializationInfo* Info, void addSpecialization(FunctionTemplateSpecializationInfo* Info,
void *InsertPos); void *InsertPos);
public: public:
/// Get the underlying function declaration of the template. /// Get the underlying function declaration of the template.
FunctionDecl *getTemplatedDecl() const { FunctionDecl *getTemplatedDecl() const {
@ -866,13 +867,13 @@ public:
/// \brief Retrieve the "injected" template arguments that correspond to the /// \brief Retrieve the "injected" template arguments that correspond to the
/// template parameters of this function template. /// template parameters of this function template.
/// ///
/// Although the C++ standard has no notion of the "injected" template /// Although the C++ standard has no notion of the "injected" template
/// arguments for a function template, the notion is convenient when /// arguments for a function template, the notion is convenient when
/// we need to perform substitutions inside the definition of a function /// we need to perform substitutions inside the definition of a function
/// template. /// template.
std::pair<const TemplateArgument *, unsigned> getInjectedTemplateArgs(); std::pair<const TemplateArgument *, unsigned> getInjectedTemplateArgs();
/// \brief Create a function template node. /// \brief Create a function template node.
static FunctionTemplateDecl *Create(ASTContext &C, DeclContext *DC, static FunctionTemplateDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, SourceLocation L,
@ -1003,14 +1004,14 @@ public:
DefaultArgument = 0; DefaultArgument = 0;
InheritedDefault = false; InheritedDefault = false;
} }
/// \brief Set whether this template type parameter was declared with /// \brief Set whether this template type parameter was declared with
/// the 'typename' or 'class' keyword. /// the 'typename' or 'class' keyword.
void setDeclaredWithTypename(bool withTypename) { Typename = withTypename; } void setDeclaredWithTypename(bool withTypename) { Typename = withTypename; }
/// \brief Retrieve the depth of the template parameter. /// \brief Retrieve the depth of the template parameter.
unsigned getDepth() const; unsigned getDepth() const;
/// \brief Retrieve the index of the template parameter. /// \brief Retrieve the index of the template parameter.
unsigned getIndex() const; unsigned getIndex() const;
@ -1038,18 +1039,18 @@ class NonTypeTemplateParmDecl
// FIXME: Collapse this into TemplateParamPosition; or, just move depth/index // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index
// down here to save memory. // down here to save memory.
/// \brief Whether this non-type template parameter is a parameter pack. /// \brief Whether this non-type template parameter is a parameter pack.
bool ParameterPack; bool ParameterPack;
/// \brief Whether this non-type template parameter is an "expanded" /// \brief Whether this non-type template parameter is an "expanded"
/// parameter pack, meaning that its type is a pack expansion and we /// parameter pack, meaning that its type is a pack expansion and we
/// already know the set of types that expansion expands to. /// already know the set of types that expansion expands to.
bool ExpandedParameterPack; bool ExpandedParameterPack;
/// \brief The number of types in an expanded parameter pack. /// \brief The number of types in an expanded parameter pack.
unsigned NumExpandedTypes; unsigned NumExpandedTypes;
NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc, NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, unsigned D, unsigned P, SourceLocation IdLoc, unsigned D, unsigned P,
IdentifierInfo *Id, QualType T, IdentifierInfo *Id, QualType T,
@ -1069,7 +1070,7 @@ class NonTypeTemplateParmDecl
TypeSourceInfo **ExpandedTInfos); TypeSourceInfo **ExpandedTInfos);
friend class ASTDeclReader; friend class ASTDeclReader;
public: public:
static NonTypeTemplateParmDecl * static NonTypeTemplateParmDecl *
Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
@ -1135,7 +1136,7 @@ public:
/// template<typename T, unsigned ...Dims> struct multi_array; /// template<typename T, unsigned ...Dims> struct multi_array;
/// \endcode /// \endcode
bool isParameterPack() const { return ParameterPack; } bool isParameterPack() const { return ParameterPack; }
/// \brief Whether this parameter is a non-type template parameter pack /// \brief Whether this parameter is a non-type template parameter pack
/// that has different types at different positions. /// that has different types at different positions.
/// ///
@ -1150,25 +1151,26 @@ public:
/// struct Y { /* ... */ }; /// struct Y { /* ... */ };
/// }; /// };
/// \endcode /// \endcode
/// ///
/// The parameter pack \c Values has a \c PackExpansionType as its type, /// The parameter pack \c Values has a \c PackExpansionType as its type,
/// which expands \c Types. When \c Types is supplied with template arguments /// which expands \c Types. When \c Types is supplied with template arguments
/// by instantiating \c X, the instantiation of \c Values becomes an /// by instantiating \c X, the instantiation of \c Values becomes an
/// expanded parameter pack. For example, instantiating /// expanded parameter pack. For example, instantiating
/// \c X<int, unsigned int> results in \c Values being an expanded parameter /// \c X<int, unsigned int> results in \c Values being an expanded parameter
/// pack with expansion types \c int and \c unsigned int. /// pack with expansion types \c int and \c unsigned int.
/// ///
/// The \c getExpansionType() and \c getExpansionTypeSourceInfo() functions /// The \c getExpansionType() and \c getExpansionTypeSourceInfo() functions
/// return the expansion types. /// return the expansion types.
bool isExpandedParameterPack() const { return ExpandedParameterPack; } bool isExpandedParameterPack() const { return ExpandedParameterPack; }
/// \brief Retrieves the number of expansion types in an expanded parameter pack. /// \brief Retrieves the number of expansion types in an expanded parameter
/// pack.
unsigned getNumExpansionTypes() const { unsigned getNumExpansionTypes() const {
assert(ExpandedParameterPack && "Not an expansion parameter pack"); assert(ExpandedParameterPack && "Not an expansion parameter pack");
return NumExpandedTypes; return NumExpandedTypes;
} }
/// \brief Retrieve a particular expansion type within an expanded parameter /// \brief Retrieve a particular expansion type within an expanded parameter
/// pack. /// pack.
QualType getExpansionType(unsigned I) const { QualType getExpansionType(unsigned I) const {
assert(I < NumExpandedTypes && "Out-of-range expansion type index"); assert(I < NumExpandedTypes && "Out-of-range expansion type index");
@ -1176,7 +1178,7 @@ public:
return QualType::getFromOpaquePtr(TypesAndInfos[2*I]); return QualType::getFromOpaquePtr(TypesAndInfos[2*I]);
} }
/// \brief Retrieve a particular expansion type source info within an /// \brief Retrieve a particular expansion type source info within an
/// expanded parameter pack. /// expanded parameter pack.
TypeSourceInfo *getExpansionTypeSourceInfo(unsigned I) const { TypeSourceInfo *getExpansionTypeSourceInfo(unsigned I) const {
assert(I < NumExpandedTypes && "Out-of-range expansion type index"); assert(I < NumExpandedTypes && "Out-of-range expansion type index");
@ -1207,7 +1209,7 @@ class TemplateTemplateParmDecl
/// \brief Whether this parameter is a parameter pack. /// \brief Whether this parameter is a parameter pack.
bool ParameterPack; bool ParameterPack;
TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L, TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L,
unsigned D, unsigned P, bool ParameterPack, unsigned D, unsigned P, bool ParameterPack,
IdentifierInfo *Id, TemplateParameterList *Params) IdentifierInfo *Id, TemplateParameterList *Params)
@ -1552,7 +1554,7 @@ public:
static bool classof(const ClassTemplatePartialSpecializationDecl *) { static bool classof(const ClassTemplatePartialSpecializationDecl *) {
return true; return true;
} }
friend class ASTDeclReader; friend class ASTDeclReader;
friend class ASTDeclWriter; friend class ASTDeclWriter;
}; };
@ -1571,15 +1573,15 @@ class ClassTemplatePartialSpecializationDecl
/// specialization was added to the set of partial specializations for /// specialization was added to the set of partial specializations for
/// its owning class template. /// its owning class template.
unsigned SequenceNumber; unsigned SequenceNumber;
/// \brief The class template partial specialization from which this /// \brief The class template partial specialization from which this
/// class template partial specialization was instantiated. /// class template partial specialization was instantiated.
/// ///
/// The boolean value will be true to indicate that this class template /// The boolean value will be true to indicate that this class template
/// partial specialization was specialized at this level. /// partial specialization was specialized at this level.
llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool> llvm::PointerIntPair<ClassTemplatePartialSpecializationDecl *, 1, bool>
InstantiatedFromMember; InstantiatedFromMember;
ClassTemplatePartialSpecializationDecl(ASTContext &Context, TagKind TK, ClassTemplatePartialSpecializationDecl(ASTContext &Context, TagKind TK,
DeclContext *DC, DeclContext *DC,
SourceLocation StartLoc, SourceLocation StartLoc,
@ -1592,7 +1594,7 @@ class ClassTemplatePartialSpecializationDecl
unsigned NumArgInfos, unsigned NumArgInfos,
ClassTemplatePartialSpecializationDecl *PrevDecl, ClassTemplatePartialSpecializationDecl *PrevDecl,
unsigned SequenceNumber); unsigned SequenceNumber);
ClassTemplatePartialSpecializationDecl() ClassTemplatePartialSpecializationDecl()
: ClassTemplateSpecializationDecl(ClassTemplatePartialSpecialization), : ClassTemplateSpecializationDecl(ClassTemplatePartialSpecialization),
TemplateParams(0), ArgsAsWritten(0), TemplateParams(0), ArgsAsWritten(0),
@ -1654,9 +1656,9 @@ public:
/// \endcode /// \endcode
/// ///
/// In this example, the instantiation of \c Outer<float>::Inner<int*> will /// In this example, the instantiation of \c Outer<float>::Inner<int*> will
/// end up instantiating the partial specialization /// end up instantiating the partial specialization
/// \c Outer<float>::Inner<U*>, which itself was instantiated from the class /// \c Outer<float>::Inner<U*>, which itself was instantiated from the class
/// template partial specialization \c Outer<T>::Inner<U*>. Given /// template partial specialization \c Outer<T>::Inner<U*>. Given
/// \c Outer<float>::Inner<U*>, this function would return /// \c Outer<float>::Inner<U*>, this function would return
/// \c Outer<T>::Inner<U*>. /// \c Outer<T>::Inner<U*>.
ClassTemplatePartialSpecializationDecl *getInstantiatedFromMember() { ClassTemplatePartialSpecializationDecl *getInstantiatedFromMember() {
@ -1664,15 +1666,15 @@ public:
= cast<ClassTemplatePartialSpecializationDecl>(getFirstDeclaration()); = cast<ClassTemplatePartialSpecializationDecl>(getFirstDeclaration());
return First->InstantiatedFromMember.getPointer(); return First->InstantiatedFromMember.getPointer();
} }
void setInstantiatedFromMember( void setInstantiatedFromMember(
ClassTemplatePartialSpecializationDecl *PartialSpec) { ClassTemplatePartialSpecializationDecl *PartialSpec) {
ClassTemplatePartialSpecializationDecl *First ClassTemplatePartialSpecializationDecl *First
= cast<ClassTemplatePartialSpecializationDecl>(getFirstDeclaration()); = cast<ClassTemplatePartialSpecializationDecl>(getFirstDeclaration());
First->InstantiatedFromMember.setPointer(PartialSpec); First->InstantiatedFromMember.setPointer(PartialSpec);
} }
/// \brief Determines whether this class template partial specialization /// \brief Determines whether this class template partial specialization
/// template was a specialization of a member partial specialization. /// template was a specialization of a member partial specialization.
/// ///
/// In the following example, the member template partial specialization /// In the following example, the member template partial specialization
@ -1693,7 +1695,7 @@ public:
= cast<ClassTemplatePartialSpecializationDecl>(getFirstDeclaration()); = cast<ClassTemplatePartialSpecializationDecl>(getFirstDeclaration());
return First->InstantiatedFromMember.getInt(); return First->InstantiatedFromMember.getInt();
} }
/// \brief Note that this member template is a specialization. /// \brief Note that this member template is a specialization.
void setMemberSpecialization() { void setMemberSpecialization() {
ClassTemplatePartialSpecializationDecl *First ClassTemplatePartialSpecializationDecl *First
@ -1711,7 +1713,7 @@ public:
return cast<InjectedClassNameType>(getTypeForDecl()) return cast<InjectedClassNameType>(getTypeForDecl())
->getInjectedSpecializationType(); ->getInjectedSpecializationType();
} }
// FIXME: Add Profile support! // FIXME: Add Profile support!
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@ -1731,7 +1733,7 @@ public:
class ClassTemplateDecl : public RedeclarableTemplateDecl, class ClassTemplateDecl : public RedeclarableTemplateDecl,
public RedeclarableTemplate<ClassTemplateDecl> { public RedeclarableTemplate<ClassTemplateDecl> {
static void DeallocateCommon(void *Ptr); static void DeallocateCommon(void *Ptr);
protected: protected:
typedef RedeclarableTemplate<ClassTemplateDecl> redeclarable_base; typedef RedeclarableTemplate<ClassTemplateDecl> redeclarable_base;
@ -1739,7 +1741,7 @@ protected:
/// class template. /// class template.
struct Common : CommonBase { struct Common : CommonBase {
Common() : LazySpecializations() { } Common() : LazySpecializations() { }
/// \brief The class template specializations for this class /// \brief The class template specializations for this class
/// template, including explicit specializations and instantiations. /// template, including explicit specializations and instantiations.
llvm::FoldingSet<ClassTemplateSpecializationDecl> Specializations; llvm::FoldingSet<ClassTemplateSpecializationDecl> Specializations;
@ -1751,7 +1753,7 @@ protected:
/// \brief The injected-class-name type for this class template. /// \brief The injected-class-name type for this class template.
QualType InjectedClassNameType; QualType InjectedClassNameType;
/// \brief If non-null, points to an array of specializations (including /// \brief If non-null, points to an array of specializations (including
/// partial specializations) known ownly by their external declaration IDs. /// partial specializations) known ownly by their external declaration IDs.
/// ///
@ -1762,7 +1764,7 @@ protected:
/// \brief Load any lazily-loaded specializations from the external source. /// \brief Load any lazily-loaded specializations from the external source.
void LoadLazySpecializations(); void LoadLazySpecializations();
/// \brief Retrieve the set of specializations of this class template. /// \brief Retrieve the set of specializations of this class template.
llvm::FoldingSet<ClassTemplateSpecializationDecl> &getSpecializations(); llvm::FoldingSet<ClassTemplateSpecializationDecl> &getSpecializations();
@ -1860,7 +1862,7 @@ public:
/// \brief Retrieve the partial specializations as an ordered list. /// \brief Retrieve the partial specializations as an ordered list.
void getPartialSpecializations( void getPartialSpecializations(
SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS); SmallVectorImpl<ClassTemplatePartialSpecializationDecl *> &PS);
/// \brief Find a class template partial specialization with the given /// \brief Find a class template partial specialization with the given
/// type T. /// type T.
/// ///
@ -1870,7 +1872,7 @@ public:
/// \returns the class template partial specialization that exactly matches /// \returns the class template partial specialization that exactly matches
/// the type \p T, or NULL if no such partial specialization exists. /// the type \p T, or NULL if no such partial specialization exists.
ClassTemplatePartialSpecializationDecl *findPartialSpecialization(QualType T); ClassTemplatePartialSpecializationDecl *findPartialSpecialization(QualType T);
/// \brief Find a class template partial specialization which was instantiated /// \brief Find a class template partial specialization which was instantiated
/// from the given member partial specialization. /// from the given member partial specialization.
/// ///
@ -1957,7 +1959,7 @@ private:
FriendTemplateDecl(DeclContext *DC, SourceLocation Loc, FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
unsigned NParams, unsigned NParams,
TemplateParameterList **Params, TemplateParameterList **Params,
FriendUnion Friend, FriendUnion Friend,
SourceLocation FriendLoc) SourceLocation FriendLoc)
@ -1977,7 +1979,7 @@ private:
public: public:
static FriendTemplateDecl *Create(ASTContext &Context, static FriendTemplateDecl *Create(ASTContext &Context,
DeclContext *DC, SourceLocation Loc, DeclContext *DC, SourceLocation Loc,
unsigned NParams, unsigned NParams,
TemplateParameterList **Params, TemplateParameterList **Params,
FriendUnion Friend, FriendUnion Friend,
SourceLocation FriendLoc); SourceLocation FriendLoc);
@ -2072,7 +2074,7 @@ public:
return redeclarable_base::getInstantiatedFromMemberTemplate(); return redeclarable_base::getInstantiatedFromMemberTemplate();
} }
/// \brief Create a function template node. /// \brief Create a function template node.
static TypeAliasTemplateDecl *Create(ASTContext &C, DeclContext *DC, static TypeAliasTemplateDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, SourceLocation L,

View File

@ -56,8 +56,8 @@ class Expr : public Stmt {
protected: protected:
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK,
bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack) bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
: Stmt(SC) : Stmt(SC)
{ {
ExprBits.TypeDependent = TD; ExprBits.TypeDependent = TD;
ExprBits.ValueDependent = VD; ExprBits.ValueDependent = VD;
@ -97,8 +97,8 @@ public:
bool isValueDependent() const { return ExprBits.ValueDependent; } bool isValueDependent() const { return ExprBits.ValueDependent; }
/// \brief Set whether this expression is value-dependent or not. /// \brief Set whether this expression is value-dependent or not.
void setValueDependent(bool VD) { void setValueDependent(bool VD) {
ExprBits.ValueDependent = VD; ExprBits.ValueDependent = VD;
if (VD) if (VD)
ExprBits.InstantiationDependent = true; ExprBits.InstantiationDependent = true;
} }
@ -117,8 +117,8 @@ public:
bool isTypeDependent() const { return ExprBits.TypeDependent; } bool isTypeDependent() const { return ExprBits.TypeDependent; }
/// \brief Set whether this expression is type-dependent or not. /// \brief Set whether this expression is type-dependent or not.
void setTypeDependent(bool TD) { void setTypeDependent(bool TD) {
ExprBits.TypeDependent = TD; ExprBits.TypeDependent = TD;
if (TD) if (TD)
ExprBits.InstantiationDependent = true; ExprBits.InstantiationDependent = true;
} }
@ -140,12 +140,12 @@ public:
/// } /// }
/// \endcode /// \endcode
/// ///
bool isInstantiationDependent() const { bool isInstantiationDependent() const {
return ExprBits.InstantiationDependent; return ExprBits.InstantiationDependent;
} }
/// \brief Set whether this expression is instantiation-dependent or not. /// \brief Set whether this expression is instantiation-dependent or not.
void setInstantiationDependent(bool ID) { void setInstantiationDependent(bool ID) {
ExprBits.InstantiationDependent = ID; ExprBits.InstantiationDependent = ID;
} }
@ -163,8 +163,8 @@ public:
/// ///
/// The expressions \c args and \c static_cast<Types&&>(args) both /// The expressions \c args and \c static_cast<Types&&>(args) both
/// contain parameter packs. /// contain parameter packs.
bool containsUnexpandedParameterPack() const { bool containsUnexpandedParameterPack() const {
return ExprBits.ContainsUnexpandedParameterPack; return ExprBits.ContainsUnexpandedParameterPack;
} }
/// \brief Set the bit that describes whether this expression /// \brief Set the bit that describes whether this expression
@ -302,12 +302,12 @@ public:
bool isPRValue() const { return Kind >= CL_Function; } bool isPRValue() const { return Kind >= CL_Function; }
bool isRValue() const { return Kind >= CL_XValue; } bool isRValue() const { return Kind >= CL_XValue; }
bool isModifiable() const { return getModifiable() == CM_Modifiable; } bool isModifiable() const { return getModifiable() == CM_Modifiable; }
/// \brief Create a simple, modifiably lvalue /// \brief Create a simple, modifiably lvalue
static Classification makeSimpleLValue() { static Classification makeSimpleLValue() {
return Classification(CL_LValue, CM_Modifiable); return Classification(CL_LValue, CM_Modifiable);
} }
}; };
/// \brief Classify - Classify this expression according to the C++0x /// \brief Classify - Classify this expression according to the C++0x
/// expression taxonomy. /// expression taxonomy.
@ -403,13 +403,13 @@ public:
return BT->getKind() == K; return BT->getKind() == K;
return false; return false;
} }
/// isKnownToHaveBooleanValue - Return true if this is an integer expression /// isKnownToHaveBooleanValue - Return true if this is an integer expression
/// that is known to return 0 or 1. This happens for _Bool/bool expressions /// that is known to return 0 or 1. This happens for _Bool/bool expressions
/// but also int expressions which are produced by things like comparisons in /// but also int expressions which are produced by things like comparisons in
/// C. /// C.
bool isKnownToHaveBooleanValue() const; bool isKnownToHaveBooleanValue() const;
/// isIntegerConstantExpr - Return true if this expression is a valid integer /// isIntegerConstantExpr - Return true if this expression is a valid integer
/// constant expression, and, if so, return its value in Result. If not a /// constant expression, and, if so, return its value in Result. If not a
/// valid i-c-e, return false and fill in Loc (if specified) with the location /// valid i-c-e, return false and fill in Loc (if specified) with the location
@ -521,16 +521,16 @@ public:
enum NullPointerConstantValueDependence { enum NullPointerConstantValueDependence {
/// \brief Specifies that the expression should never be value-dependent. /// \brief Specifies that the expression should never be value-dependent.
NPC_NeverValueDependent = 0, NPC_NeverValueDependent = 0,
/// \brief Specifies that a value-dependent expression of integral or /// \brief Specifies that a value-dependent expression of integral or
/// dependent type should be considered a null pointer constant. /// dependent type should be considered a null pointer constant.
NPC_ValueDependentIsNull, NPC_ValueDependentIsNull,
/// \brief Specifies that a value-dependent expression should be considered /// \brief Specifies that a value-dependent expression should be considered
/// to never be a null pointer constant. /// to never be a null pointer constant.
NPC_ValueDependentIsNotNull NPC_ValueDependentIsNotNull
}; };
/// isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to /// isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to
/// a Null pointer constant. The return value can further distinguish the /// a Null pointer constant. The return value can further distinguish the
/// kind of NULL pointer constant that was detected. /// kind of NULL pointer constant that was detected.
@ -578,8 +578,8 @@ public:
/// or CastExprs, returning their operand. /// or CastExprs, returning their operand.
Expr *IgnoreParenCasts(); Expr *IgnoreParenCasts();
/// IgnoreParenImpCasts - Ignore parentheses and implicit casts. Strip off any /// IgnoreParenImpCasts - Ignore parentheses and implicit casts. Strip off
/// ParenExpr or ImplicitCastExprs, returning their operand. /// any ParenExpr or ImplicitCastExprs, returning their operand.
Expr *IgnoreParenImpCasts(); Expr *IgnoreParenImpCasts();
/// IgnoreConversionOperator - Ignore conversion operator. If this Expr is a /// IgnoreConversionOperator - Ignore conversion operator. If this Expr is a
@ -593,11 +593,11 @@ public:
const Expr *IgnoreParenImpCasts() const { const Expr *IgnoreParenImpCasts() const {
return const_cast<Expr*>(this)->IgnoreParenImpCasts(); return const_cast<Expr*>(this)->IgnoreParenImpCasts();
} }
/// Ignore parentheses and lvalue casts. Strip off any ParenExpr and /// Ignore parentheses and lvalue casts. Strip off any ParenExpr and
/// CastExprs that represent lvalue casts, returning their operand. /// CastExprs that represent lvalue casts, returning their operand.
Expr *IgnoreParenLValueCasts(); Expr *IgnoreParenLValueCasts();
const Expr *IgnoreParenLValueCasts() const { const Expr *IgnoreParenLValueCasts() const {
return const_cast<Expr*>(this)->IgnoreParenLValueCasts(); return const_cast<Expr*>(this)->IgnoreParenLValueCasts();
} }
@ -610,12 +610,12 @@ public:
/// \brief Determine whether this expression is a default function argument. /// \brief Determine whether this expression is a default function argument.
/// ///
/// Default arguments are implicitly generated in the abstract syntax tree /// Default arguments are implicitly generated in the abstract syntax tree
/// by semantic analysis for function calls, object constructions, etc. in /// by semantic analysis for function calls, object constructions, etc. in
/// C++. Default arguments are represented by \c CXXDefaultArgExpr nodes; /// C++. Default arguments are represented by \c CXXDefaultArgExpr nodes;
/// this routine also looks through any implicit casts to determine whether /// this routine also looks through any implicit casts to determine whether
/// the expression is a default argument. /// the expression is a default argument.
bool isDefaultArgument() const; bool isDefaultArgument() const;
/// \brief Determine whether the result of this expression is a /// \brief Determine whether the result of this expression is a
/// temporary object of the given class type. /// temporary object of the given class type.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const; bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const;
@ -660,14 +660,14 @@ class OpaqueValueExpr : public Expr {
friend class ASTStmtReader; friend class ASTStmtReader;
Expr *SourceExpr; Expr *SourceExpr;
SourceLocation Loc; SourceLocation Loc;
public: public:
OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK, OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK,
ExprObjectKind OK = OK_Ordinary) ExprObjectKind OK = OK_Ordinary)
: Expr(OpaqueValueExprClass, T, VK, OK, : Expr(OpaqueValueExprClass, T, VK, OK,
T->isDependentType(), T->isDependentType(), T->isDependentType(), T->isDependentType(),
T->isInstantiationDependentType(), T->isInstantiationDependentType(),
false), false),
SourceExpr(0), Loc(Loc) { SourceExpr(0), Loc(Loc) {
} }
@ -681,7 +681,7 @@ public:
/// \brief Retrieve the location of this expression. /// \brief Retrieve the location of this expression.
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const {
if (SourceExpr) return SourceExpr->getSourceRange(); if (SourceExpr) return SourceExpr->getSourceRange();
return Loc; return Loc;
@ -989,7 +989,7 @@ private:
public: public:
PredefinedExpr(SourceLocation l, QualType type, IdentType IT) PredefinedExpr(SourceLocation l, QualType type, IdentType IT)
: Expr(PredefinedExprClass, type, VK_LValue, OK_Ordinary, : Expr(PredefinedExprClass, type, VK_LValue, OK_Ordinary,
type->isDependentType(), type->isDependentType(), type->isDependentType(), type->isDependentType(),
type->isInstantiationDependentType(), type->isInstantiationDependentType(),
/*ContainsUnexpandedParameterPack=*/false), /*ContainsUnexpandedParameterPack=*/false),
Loc(l), Type(IT) {} Loc(l), Type(IT) {}
@ -1051,14 +1051,14 @@ protected:
}; };
class APIntStorage : public APNumericStorage { class APIntStorage : public APNumericStorage {
public: public:
llvm::APInt getValue() const { return getIntValue(); } llvm::APInt getValue() const { return getIntValue(); }
void setValue(ASTContext &C, const llvm::APInt &Val) { setIntValue(C, Val); } void setValue(ASTContext &C, const llvm::APInt &Val) { setIntValue(C, Val); }
}; };
class APFloatStorage : public APNumericStorage { class APFloatStorage : public APNumericStorage {
public: public:
llvm::APFloat getValue() const { return llvm::APFloat(getIntValue()); } llvm::APFloat getValue() const { return llvm::APFloat(getIntValue()); }
void setValue(ASTContext &C, const llvm::APFloat &Val) { void setValue(ASTContext &C, const llvm::APFloat &Val) {
setIntValue(C, Val.bitcastToAPInt()); setIntValue(C, Val.bitcastToAPInt());
} }
@ -1347,8 +1347,8 @@ public:
StringKind Kind, bool IsPascal); StringKind Kind, bool IsPascal);
StringKind getKind() const { return static_cast<StringKind>(Kind); } StringKind getKind() const { return static_cast<StringKind>(Kind); }
bool isAscii() const { return Kind == Ascii; } bool isAscii() const { return Kind == Ascii; }
bool isWide() const { return Kind == Wide; } bool isWide() const { return Kind == Wide; }
bool isUTF8() const { return Kind == UTF8; } bool isUTF8() const { return Kind == UTF8; }
@ -1363,7 +1363,7 @@ public:
return true; return true;
return false; return false;
} }
/// getNumConcatenated - Get the number of string literal tokens that were /// getNumConcatenated - Get the number of string literal tokens that were
/// concatenated in translation phase #6 to form this string literal. /// concatenated in translation phase #6 to form this string literal.
unsigned getNumConcatenated() const { return NumConcatenated; } unsigned getNumConcatenated() const { return NumConcatenated; }
@ -1376,7 +1376,7 @@ public:
assert(TokNum < NumConcatenated && "Invalid tok number"); assert(TokNum < NumConcatenated && "Invalid tok number");
TokLocs[TokNum] = L; TokLocs[TokNum] = L;
} }
/// getLocationOfByte - Return a source location that points to the specified /// getLocationOfByte - Return a source location that points to the specified
/// byte of this string literal. /// byte of this string literal.
/// ///
@ -1471,7 +1471,7 @@ public:
: Expr(UnaryOperatorClass, type, VK, OK, : Expr(UnaryOperatorClass, type, VK, OK,
input->isTypeDependent() || type->isDependentType(), input->isTypeDependent() || type->isDependentType(),
input->isValueDependent(), input->isValueDependent(),
(input->isInstantiationDependent() || (input->isInstantiationDependent() ||
type->isInstantiationDependentType()), type->isInstantiationDependentType()),
input->containsUnexpandedParameterPack()), input->containsUnexpandedParameterPack()),
Opc(opc), Loc(l), Val(input) {} Opc(opc), Loc(l), Val(input) {}
@ -1561,14 +1561,14 @@ public:
/// @code /// @code
/// struct S { /// struct S {
/// float f; /// float f;
/// double d; /// double d;
/// }; /// };
/// struct T { /// struct T {
/// int i; /// int i;
/// struct S s[10]; /// struct S s[10];
/// }; /// };
/// @endcode /// @endcode
/// we can represent and evaluate the expression @c offsetof(struct T, s[2].d). /// we can represent and evaluate the expression @c offsetof(struct T, s[2].d).
class OffsetOfExpr : public Expr { class OffsetOfExpr : public Expr {
public: public:
@ -1590,48 +1590,48 @@ public:
private: private:
enum { MaskBits = 2, Mask = 0x03 }; enum { MaskBits = 2, Mask = 0x03 };
/// \brief The source range that covers this part of the designator. /// \brief The source range that covers this part of the designator.
SourceRange Range; SourceRange Range;
/// \brief The data describing the designator, which comes in three /// \brief The data describing the designator, which comes in three
/// different forms, depending on the lower two bits. /// different forms, depending on the lower two bits.
/// - An unsigned index into the array of Expr*'s stored after this node /// - An unsigned index into the array of Expr*'s stored after this node
/// in memory, for [constant-expression] designators. /// in memory, for [constant-expression] designators.
/// - A FieldDecl*, for references to a known field. /// - A FieldDecl*, for references to a known field.
/// - An IdentifierInfo*, for references to a field with a given name /// - An IdentifierInfo*, for references to a field with a given name
/// when the class type is dependent. /// when the class type is dependent.
/// - A CXXBaseSpecifier*, for references that look at a field in a /// - A CXXBaseSpecifier*, for references that look at a field in a
/// base class. /// base class.
uintptr_t Data; uintptr_t Data;
public: public:
/// \brief Create an offsetof node that refers to an array element. /// \brief Create an offsetof node that refers to an array element.
OffsetOfNode(SourceLocation LBracketLoc, unsigned Index, OffsetOfNode(SourceLocation LBracketLoc, unsigned Index,
SourceLocation RBracketLoc) SourceLocation RBracketLoc)
: Range(LBracketLoc, RBracketLoc), Data((Index << 2) | Array) { } : Range(LBracketLoc, RBracketLoc), Data((Index << 2) | Array) { }
/// \brief Create an offsetof node that refers to a field. /// \brief Create an offsetof node that refers to a field.
OffsetOfNode(SourceLocation DotLoc, FieldDecl *Field, OffsetOfNode(SourceLocation DotLoc, FieldDecl *Field,
SourceLocation NameLoc) SourceLocation NameLoc)
: Range(DotLoc.isValid()? DotLoc : NameLoc, NameLoc), : Range(DotLoc.isValid()? DotLoc : NameLoc, NameLoc),
Data(reinterpret_cast<uintptr_t>(Field) | OffsetOfNode::Field) { } Data(reinterpret_cast<uintptr_t>(Field) | OffsetOfNode::Field) { }
/// \brief Create an offsetof node that refers to an identifier. /// \brief Create an offsetof node that refers to an identifier.
OffsetOfNode(SourceLocation DotLoc, IdentifierInfo *Name, OffsetOfNode(SourceLocation DotLoc, IdentifierInfo *Name,
SourceLocation NameLoc) SourceLocation NameLoc)
: Range(DotLoc.isValid()? DotLoc : NameLoc, NameLoc), : Range(DotLoc.isValid()? DotLoc : NameLoc, NameLoc),
Data(reinterpret_cast<uintptr_t>(Name) | Identifier) { } Data(reinterpret_cast<uintptr_t>(Name) | Identifier) { }
/// \brief Create an offsetof node that refers into a C++ base class. /// \brief Create an offsetof node that refers into a C++ base class.
explicit OffsetOfNode(const CXXBaseSpecifier *Base) explicit OffsetOfNode(const CXXBaseSpecifier *Base)
: Range(), Data(reinterpret_cast<uintptr_t>(Base) | OffsetOfNode::Base) {} : Range(), Data(reinterpret_cast<uintptr_t>(Base) | OffsetOfNode::Base) {}
/// \brief Determine what kind of offsetof node this is. /// \brief Determine what kind of offsetof node this is.
Kind getKind() const { Kind getKind() const {
return static_cast<Kind>(Data & Mask); return static_cast<Kind>(Data & Mask);
} }
/// \brief For an array element node, returns the index into the array /// \brief For an array element node, returns the index into the array
/// of expressions. /// of expressions.
unsigned getArrayExprIndex() const { unsigned getArrayExprIndex() const {
@ -1644,28 +1644,28 @@ public:
assert(getKind() == Field); assert(getKind() == Field);
return reinterpret_cast<FieldDecl *>(Data & ~(uintptr_t)Mask); return reinterpret_cast<FieldDecl *>(Data & ~(uintptr_t)Mask);
} }
/// \brief For a field or identifier offsetof node, returns the name of /// \brief For a field or identifier offsetof node, returns the name of
/// the field. /// the field.
IdentifierInfo *getFieldName() const; IdentifierInfo *getFieldName() const;
/// \brief For a base class node, returns the base specifier. /// \brief For a base class node, returns the base specifier.
CXXBaseSpecifier *getBase() const { CXXBaseSpecifier *getBase() const {
assert(getKind() == Base); assert(getKind() == Base);
return reinterpret_cast<CXXBaseSpecifier *>(Data & ~(uintptr_t)Mask); return reinterpret_cast<CXXBaseSpecifier *>(Data & ~(uintptr_t)Mask);
} }
/// \brief Retrieve the source range that covers this offsetof node. /// \brief Retrieve the source range that covers this offsetof node.
/// ///
/// For an array element node, the source range contains the locations of /// For an array element node, the source range contains the locations of
/// the square brackets. For a field or identifier node, the source range /// the square brackets. For a field or identifier node, the source range
/// contains the location of the period (if there is one) and the /// contains the location of the period (if there is one) and the
/// identifier. /// identifier.
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const { return Range; }
}; };
private: private:
SourceLocation OperatorLoc, RParenLoc; SourceLocation OperatorLoc, RParenLoc;
// Base type; // Base type;
TypeSourceInfo *TSInfo; TypeSourceInfo *TSInfo;
@ -1673,26 +1673,26 @@ private:
unsigned NumComps; unsigned NumComps;
// Number of sub-expressions (i.e. array subscript expressions). // Number of sub-expressions (i.e. array subscript expressions).
unsigned NumExprs; unsigned NumExprs;
OffsetOfExpr(ASTContext &C, QualType type, OffsetOfExpr(ASTContext &C, QualType type,
SourceLocation OperatorLoc, TypeSourceInfo *tsi, SourceLocation OperatorLoc, TypeSourceInfo *tsi,
OffsetOfNode* compsPtr, unsigned numComps, OffsetOfNode* compsPtr, unsigned numComps,
Expr** exprsPtr, unsigned numExprs, Expr** exprsPtr, unsigned numExprs,
SourceLocation RParenLoc); SourceLocation RParenLoc);
explicit OffsetOfExpr(unsigned numComps, unsigned numExprs) explicit OffsetOfExpr(unsigned numComps, unsigned numExprs)
: Expr(OffsetOfExprClass, EmptyShell()), : Expr(OffsetOfExprClass, EmptyShell()),
TSInfo(0), NumComps(numComps), NumExprs(numExprs) {} TSInfo(0), NumComps(numComps), NumExprs(numExprs) {}
public: public:
static OffsetOfExpr *Create(ASTContext &C, QualType type, static OffsetOfExpr *Create(ASTContext &C, QualType type,
SourceLocation OperatorLoc, TypeSourceInfo *tsi, SourceLocation OperatorLoc, TypeSourceInfo *tsi,
OffsetOfNode* compsPtr, unsigned numComps, OffsetOfNode* compsPtr, unsigned numComps,
Expr** exprsPtr, unsigned numExprs, Expr** exprsPtr, unsigned numExprs,
SourceLocation RParenLoc); SourceLocation RParenLoc);
static OffsetOfExpr *CreateEmpty(ASTContext &C, static OffsetOfExpr *CreateEmpty(ASTContext &C,
unsigned NumComps, unsigned NumExprs); unsigned NumComps, unsigned NumExprs);
/// getOperatorLoc - Return the location of the operator. /// getOperatorLoc - Return the location of the operator.
@ -1702,14 +1702,14 @@ public:
/// \brief Return the location of the right parentheses. /// \brief Return the location of the right parentheses.
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation R) { RParenLoc = R; } void setRParenLoc(SourceLocation R) { RParenLoc = R; }
TypeSourceInfo *getTypeSourceInfo() const { TypeSourceInfo *getTypeSourceInfo() const {
return TSInfo; return TSInfo;
} }
void setTypeSourceInfo(TypeSourceInfo *tsi) { void setTypeSourceInfo(TypeSourceInfo *tsi) {
TSInfo = tsi; TSInfo = tsi;
} }
const OffsetOfNode &getComponent(unsigned Idx) const { const OffsetOfNode &getComponent(unsigned Idx) const {
assert(Idx < NumComps && "Subscript out of range"); assert(Idx < NumComps && "Subscript out of range");
return reinterpret_cast<const OffsetOfNode *> (this + 1)[Idx]; return reinterpret_cast<const OffsetOfNode *> (this + 1)[Idx];
@ -1719,7 +1719,7 @@ public:
assert(Idx < NumComps && "Subscript out of range"); assert(Idx < NumComps && "Subscript out of range");
reinterpret_cast<OffsetOfNode *> (this + 1)[Idx] = ON; reinterpret_cast<OffsetOfNode *> (this + 1)[Idx] = ON;
} }
unsigned getNumComponents() const { unsigned getNumComponents() const {
return NumComps; return NumComps;
} }
@ -1738,7 +1738,7 @@ public:
reinterpret_cast<Expr **>( reinterpret_cast<Expr **>(
reinterpret_cast<OffsetOfNode *>(this+1) + NumComps)[Idx] = E; reinterpret_cast<OffsetOfNode *>(this+1) + NumComps)[Idx] = E;
} }
unsigned getNumExpressions() const { unsigned getNumExpressions() const {
return NumExprs; return NumExprs;
} }
@ -2007,7 +2007,7 @@ public:
const Expr *const *getArgs() const { const Expr *const *getArgs() const {
return const_cast<CallExpr*>(this)->getArgs(); return const_cast<CallExpr*>(this)->getArgs();
} }
/// getArg - Return the specified argument. /// getArg - Return the specified argument.
Expr *getArg(unsigned Arg) { Expr *getArg(unsigned Arg) {
assert(Arg < NumArgs && "Arg access out of range!"); assert(Arg < NumArgs && "Arg access out of range!");
@ -2139,7 +2139,7 @@ public:
const DeclarationNameInfo &NameInfo, QualType ty, const DeclarationNameInfo &NameInfo, QualType ty,
ExprValueKind VK, ExprObjectKind OK) ExprValueKind VK, ExprObjectKind OK)
: Expr(MemberExprClass, ty, VK, OK, : Expr(MemberExprClass, ty, VK, OK,
base->isTypeDependent(), base->isTypeDependent(),
base->isValueDependent(), base->isValueDependent(),
base->isInstantiationDependent(), base->isInstantiationDependent(),
base->containsUnexpandedParameterPack()), base->containsUnexpandedParameterPack()),
@ -2206,13 +2206,13 @@ public:
return getMemberQualifier()->QualifierLoc.getNestedNameSpecifier(); return getMemberQualifier()->QualifierLoc.getNestedNameSpecifier();
} }
/// \brief If the member name was qualified, retrieves the /// \brief If the member name was qualified, retrieves the
/// nested-name-specifier that precedes the member name, with source-location /// nested-name-specifier that precedes the member name, with source-location
/// information. /// information.
NestedNameSpecifierLoc getQualifierLoc() const { NestedNameSpecifierLoc getQualifierLoc() const {
if (!hasQualifier()) if (!hasQualifier())
return NestedNameSpecifierLoc(); return NestedNameSpecifierLoc();
return getMemberQualifier()->QualifierLoc; return getMemberQualifier()->QualifierLoc;
} }
@ -2255,7 +2255,7 @@ public:
if (!hasExplicitTemplateArgs()) return 0; if (!hasExplicitTemplateArgs()) return 0;
return &getExplicitTemplateArgs(); return &getExplicitTemplateArgs();
} }
/// \brief Retrieve the location of the left angle bracket following the /// \brief Retrieve the location of the left angle bracket following the
/// member name ('<'), if any. /// member name ('<'), if any.
SourceLocation getLAngleLoc() const { SourceLocation getLAngleLoc() const {
@ -2307,7 +2307,7 @@ public:
void setMemberLoc(SourceLocation L) { MemberLoc = L; } void setMemberLoc(SourceLocation L) { MemberLoc = L; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const;
SourceLocation getExprLoc() const { return MemberLoc; } SourceLocation getExprLoc() const { return MemberLoc; }
/// \brief Determine whether the base of this explicit is implicit. /// \brief Determine whether the base of this explicit is implicit.
@ -2356,7 +2356,7 @@ public:
CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo, CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo,
QualType T, ExprValueKind VK, Expr *init, bool fileScope) QualType T, ExprValueKind VK, Expr *init, bool fileScope)
: Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary, : Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary,
tinfo->getType()->isDependentType(), tinfo->getType()->isDependentType(),
init->isValueDependent(), init->isValueDependent(),
(init->isInstantiationDependent() || (init->isInstantiationDependent() ||
tinfo->getType()->isInstantiationDependentType()), tinfo->getType()->isInstantiationDependentType()),
@ -2432,7 +2432,7 @@ protected:
// Cast expressions are value-dependent if the type is // Cast expressions are value-dependent if the type is
// dependent or if the subexpression is value-dependent. // dependent or if the subexpression is value-dependent.
ty->isDependentType() || (op && op->isValueDependent()), ty->isDependentType() || (op && op->isValueDependent()),
(ty->isInstantiationDependentType() || (ty->isInstantiationDependentType() ||
(op && op->isInstantiationDependent())), (op && op->isInstantiationDependent())),
(ty->containsUnexpandedParameterPack() || (ty->containsUnexpandedParameterPack() ||
op->containsUnexpandedParameterPack())), op->containsUnexpandedParameterPack())),
@ -2929,7 +2929,7 @@ public:
// the expression if the condition evaluates to false. This is // the expression if the condition evaluates to false. This is
// the same as getRHS. // the same as getRHS.
Expr *getFalseExpr() const { return cast<Expr>(SubExprs[RHS]); } Expr *getFalseExpr() const { return cast<Expr>(SubExprs[RHS]); }
Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); } Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); } Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
@ -3015,7 +3015,7 @@ public:
Expr *getFalseExpr() const { Expr *getFalseExpr() const {
return cast<Expr>(SubExprs[RHS]); return cast<Expr>(SubExprs[RHS]);
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const {
return SourceRange(getCommon()->getLocStart(), getFalseExpr()->getLocEnd()); return SourceRange(getCommon()->getLocStart(), getFalseExpr()->getLocEnd());
} }
@ -3175,7 +3175,7 @@ public:
/// \brief Retrieve the array of expressions. /// \brief Retrieve the array of expressions.
Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); } Expr **getSubExprs() { return reinterpret_cast<Expr **>(SubExprs); }
/// getExpr - Return the Expr at the specified index. /// getExpr - Return the Expr at the specified index.
Expr *getExpr(unsigned Index) { Expr *getExpr(unsigned Index) {
assert((Index < NumExprs) && "Arg access out of range!"); assert((Index < NumExprs) && "Arg access out of range!");
@ -3423,7 +3423,7 @@ public:
/// \brief Retrieve the set of initializers. /// \brief Retrieve the set of initializers.
Expr **getInits() { return reinterpret_cast<Expr **>(InitExprs.data()); } Expr **getInits() { return reinterpret_cast<Expr **>(InitExprs.data()); }
const Expr *getInit(unsigned Init) const { const Expr *getInit(unsigned Init) const {
assert(Init < getNumInits() && "Initializer access out of range!"); assert(Init < getNumInits() && "Initializer access out of range!");
return cast_or_null<Expr>(InitExprs[Init]); return cast_or_null<Expr>(InitExprs[Init]);
@ -3798,7 +3798,7 @@ public:
Designator *getDesignator(unsigned Idx) { return &designators_begin()[Idx]; } Designator *getDesignator(unsigned Idx) { return &designators_begin()[Idx]; }
void setDesignators(ASTContext &C, const Designator *Desigs, void setDesignators(ASTContext &C, const Designator *Desigs,
unsigned NumDesigs); unsigned NumDesigs);
Expr *getArrayIndex(const Designator& D); Expr *getArrayIndex(const Designator& D);
@ -4133,7 +4133,7 @@ protected:
public: public:
BlockExpr(BlockDecl *BD, QualType ty) BlockExpr(BlockDecl *BD, QualType ty)
: Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary, : Expr(BlockExprClass, ty, VK_RValue, OK_Ordinary,
ty->isDependentType(), false, ty->isDependentType(), false,
// FIXME: Check for instantiate-dependence in the statement? // FIXME: Check for instantiate-dependence in the statement?
ty->isInstantiationDependentType(), ty->isInstantiationDependentType(),
false), false),
@ -4197,7 +4197,7 @@ public:
bool isConstQualAdded() const { return ConstQualAdded; } bool isConstQualAdded() const { return ConstQualAdded; }
void setConstQualAdded(bool C) { ConstQualAdded = C; } void setConstQualAdded(bool C) { ConstQualAdded = C; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == BlockDeclRefExprClass; return T->getStmtClass() == BlockDeclRefExprClass;
} }
@ -4218,12 +4218,12 @@ private:
friend class ASTReader; friend class ASTReader;
friend class ASTStmtReader; friend class ASTStmtReader;
explicit AsTypeExpr(EmptyShell Empty) : Expr(AsTypeExprClass, Empty) {} explicit AsTypeExpr(EmptyShell Empty) : Expr(AsTypeExprClass, Empty) {}
public: public:
AsTypeExpr(Expr* SrcExpr, QualType DstType, AsTypeExpr(Expr* SrcExpr, QualType DstType,
ExprValueKind VK, ExprObjectKind OK, ExprValueKind VK, ExprObjectKind OK,
SourceLocation BuiltinLoc, SourceLocation RParenLoc) SourceLocation BuiltinLoc, SourceLocation RParenLoc)
: Expr(AsTypeExprClass, DstType, VK, OK, : Expr(AsTypeExprClass, DstType, VK, OK,
DstType->isDependentType(), DstType->isDependentType(),
DstType->isDependentType() || SrcExpr->isValueDependent(), DstType->isDependentType() || SrcExpr->isValueDependent(),
(DstType->isInstantiationDependentType() || (DstType->isInstantiationDependentType() ||
@ -4231,7 +4231,7 @@ public:
(DstType->containsUnexpandedParameterPack() || (DstType->containsUnexpandedParameterPack() ||
SrcExpr->containsUnexpandedParameterPack())), SrcExpr->containsUnexpandedParameterPack())),
SrcExpr(SrcExpr), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {} SrcExpr(SrcExpr), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {}
/// getSrcExpr - Return the Expr to be converted. /// getSrcExpr - Return the Expr to be converted.
Expr *getSrcExpr() const { return cast<Expr>(SrcExpr); } Expr *getSrcExpr() const { return cast<Expr>(SrcExpr); }
@ -4240,16 +4240,16 @@ public:
/// getRParenLoc - Return the location of final right parenthesis. /// getRParenLoc - Return the location of final right parenthesis.
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const {
return SourceRange(BuiltinLoc, RParenLoc); return SourceRange(BuiltinLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == AsTypeExprClass; return T->getStmtClass() == AsTypeExprClass;
} }
static bool classof(const AsTypeExpr *) { return true; } static bool classof(const AsTypeExpr *) { return true; }
// Iterators // Iterators
child_range children() { return child_range(&SrcExpr, &SrcExpr+1); } child_range children() { return child_range(&SrcExpr, &SrcExpr+1); }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -95,7 +95,8 @@ private:
Specifier(Other.Specifier) { Specifier(Other.Specifier) {
} }
NestedNameSpecifier &operator=(const NestedNameSpecifier &); // do not implement NestedNameSpecifier &operator=(const NestedNameSpecifier &); // do not
// implement
/// \brief Either find or insert the given nested name specifier /// \brief Either find or insert the given nested name specifier
/// mockup in the given context. /// mockup in the given context.
@ -221,12 +222,12 @@ class NestedNameSpecifierLoc {
public: public:
/// \brief Construct an empty nested-name-specifier. /// \brief Construct an empty nested-name-specifier.
NestedNameSpecifierLoc() : Qualifier(0), Data(0) { } NestedNameSpecifierLoc() : Qualifier(0), Data(0) { }
/// \brief Construct a nested-name-specifier with source location information /// \brief Construct a nested-name-specifier with source location information
/// from /// from
NestedNameSpecifierLoc(NestedNameSpecifier *Qualifier, void *Data) NestedNameSpecifierLoc(NestedNameSpecifier *Qualifier, void *Data)
: Qualifier(Qualifier), Data(Data) { } : Qualifier(Qualifier), Data(Data) { }
/// \brief Evalutes true when this nested-name-specifier location is /// \brief Evalutes true when this nested-name-specifier location is
/// non-empty. /// non-empty.
operator bool() const { return Qualifier; } operator bool() const { return Qualifier; }
@ -239,7 +240,7 @@ public:
/// \brief Retrieve the opaque pointer that refers to source-location data. /// \brief Retrieve the opaque pointer that refers to source-location data.
void *getOpaqueData() const { return Data; } void *getOpaqueData() const { return Data; }
/// \brief Retrieve the source range covering the entirety of this /// \brief Retrieve the source range covering the entirety of this
/// nested-name-specifier. /// nested-name-specifier.
/// ///
@ -258,25 +259,25 @@ public:
/// \brief Retrieve the location of the beginning of this /// \brief Retrieve the location of the beginning of this
/// nested-name-specifier. /// nested-name-specifier.
SourceLocation getBeginLoc() const { SourceLocation getBeginLoc() const {
return getSourceRange().getBegin(); return getSourceRange().getBegin();
} }
/// \brief Retrieve the location of the end of this /// \brief Retrieve the location of the end of this
/// nested-name-specifier. /// nested-name-specifier.
SourceLocation getEndLoc() const { SourceLocation getEndLoc() const {
return getSourceRange().getEnd(); return getSourceRange().getEnd();
} }
/// \brief Retrieve the location of the beginning of this /// \brief Retrieve the location of the beginning of this
/// component of the nested-name-specifier. /// component of the nested-name-specifier.
SourceLocation getLocalBeginLoc() const { SourceLocation getLocalBeginLoc() const {
return getLocalSourceRange().getBegin(); return getLocalSourceRange().getBegin();
} }
/// \brief Retrieve the location of the end of this component of the /// \brief Retrieve the location of the end of this component of the
/// nested-name-specifier. /// nested-name-specifier.
SourceLocation getLocalEndLoc() const { SourceLocation getLocalEndLoc() const {
return getLocalSourceRange().getEnd(); return getLocalSourceRange().getEnd();
} }
@ -300,13 +301,13 @@ public:
/// \brief Determines the data length for the entire /// \brief Determines the data length for the entire
/// nested-name-specifier. /// nested-name-specifier.
unsigned getDataLength() const { return getDataLength(Qualifier); } unsigned getDataLength() const { return getDataLength(Qualifier); }
friend bool operator==(NestedNameSpecifierLoc X, friend bool operator==(NestedNameSpecifierLoc X,
NestedNameSpecifierLoc Y) { NestedNameSpecifierLoc Y) {
return X.Qualifier == Y.Qualifier && X.Data == Y.Data; return X.Qualifier == Y.Qualifier && X.Data == Y.Data;
} }
friend bool operator!=(NestedNameSpecifierLoc X, friend bool operator!=(NestedNameSpecifierLoc X,
NestedNameSpecifierLoc Y) { NestedNameSpecifierLoc Y) {
return !(X == Y); return !(X == Y);
} }
@ -316,39 +317,39 @@ public:
/// with source-location information for all of the components of the /// with source-location information for all of the components of the
/// nested-name-specifier. /// nested-name-specifier.
class NestedNameSpecifierLocBuilder { class NestedNameSpecifierLocBuilder {
/// \brief The current representation of the nested-name-specifier we're /// \brief The current representation of the nested-name-specifier we're
/// building. /// building.
NestedNameSpecifier *Representation; NestedNameSpecifier *Representation;
/// \brief Buffer used to store source-location information for the /// \brief Buffer used to store source-location information for the
/// nested-name-specifier. /// nested-name-specifier.
/// ///
/// Note that we explicitly manage the buffer (rather than using a /// Note that we explicitly manage the buffer (rather than using a
/// SmallVector) because \c Declarator expects it to be possible to memcpy() /// SmallVector) because \c Declarator expects it to be possible to memcpy()
/// a \c CXXScopeSpec, and CXXScopeSpec uses a NestedNameSpecifierLocBuilder. /// a \c CXXScopeSpec, and CXXScopeSpec uses a NestedNameSpecifierLocBuilder.
char *Buffer; char *Buffer;
/// \brief The size of the buffer used to store source-location information /// \brief The size of the buffer used to store source-location information
/// for the nested-name-specifier. /// for the nested-name-specifier.
unsigned BufferSize; unsigned BufferSize;
/// \brief The capacity of the buffer used to store source-location /// \brief The capacity of the buffer used to store source-location
/// information for the nested-name-specifier. /// information for the nested-name-specifier.
unsigned BufferCapacity; unsigned BufferCapacity;
public: public:
NestedNameSpecifierLocBuilder(); NestedNameSpecifierLocBuilder();
NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other); NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other);
NestedNameSpecifierLocBuilder & NestedNameSpecifierLocBuilder &
operator=(const NestedNameSpecifierLocBuilder &Other); operator=(const NestedNameSpecifierLocBuilder &Other);
~NestedNameSpecifierLocBuilder(); ~NestedNameSpecifierLocBuilder();
/// \brief Retrieve the representation of the nested-name-specifier. /// \brief Retrieve the representation of the nested-name-specifier.
NestedNameSpecifier *getRepresentation() const { return Representation; } NestedNameSpecifier *getRepresentation() const { return Representation; }
/// \brief Extend the current nested-name-specifier by another /// \brief Extend the current nested-name-specifier by another
/// nested-name-specifier component of the form 'type::'. /// nested-name-specifier component of the form 'type::'.
/// ///
@ -362,8 +363,8 @@ public:
/// \param ColonColonLoc The location of the trailing '::'. /// \param ColonColonLoc The location of the trailing '::'.
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL,
SourceLocation ColonColonLoc); SourceLocation ColonColonLoc);
/// \brief Extend the current nested-name-specifier by another /// \brief Extend the current nested-name-specifier by another
/// nested-name-specifier component of the form 'identifier::'. /// nested-name-specifier component of the form 'identifier::'.
/// ///
/// \param Context The AST context in which this nested-name-specifier /// \param Context The AST context in which this nested-name-specifier
@ -376,8 +377,8 @@ public:
/// \param ColonColonLoc The location of the trailing '::'. /// \param ColonColonLoc The location of the trailing '::'.
void Extend(ASTContext &Context, IdentifierInfo *Identifier, void Extend(ASTContext &Context, IdentifierInfo *Identifier,
SourceLocation IdentifierLoc, SourceLocation ColonColonLoc); SourceLocation IdentifierLoc, SourceLocation ColonColonLoc);
/// \brief Extend the current nested-name-specifier by another /// \brief Extend the current nested-name-specifier by another
/// nested-name-specifier component of the form 'namespace::'. /// nested-name-specifier component of the form 'namespace::'.
/// ///
/// \param Context The AST context in which this nested-name-specifier /// \param Context The AST context in which this nested-name-specifier
@ -390,8 +391,8 @@ public:
/// \param ColonColonLoc The location of the trailing '::'. /// \param ColonColonLoc The location of the trailing '::'.
void Extend(ASTContext &Context, NamespaceDecl *Namespace, void Extend(ASTContext &Context, NamespaceDecl *Namespace,
SourceLocation NamespaceLoc, SourceLocation ColonColonLoc); SourceLocation NamespaceLoc, SourceLocation ColonColonLoc);
/// \brief Extend the current nested-name-specifier by another /// \brief Extend the current nested-name-specifier by another
/// nested-name-specifier component of the form 'namespace-alias::'. /// nested-name-specifier component of the form 'namespace-alias::'.
/// ///
/// \param Context The AST context in which this nested-name-specifier /// \param Context The AST context in which this nested-name-specifier
@ -399,35 +400,35 @@ public:
/// ///
/// \param Alias The namespace alias. /// \param Alias The namespace alias.
/// ///
/// \param AliasLoc The location of the namespace alias /// \param AliasLoc The location of the namespace alias
/// name. /// name.
/// ///
/// \param ColonColonLoc The location of the trailing '::'. /// \param ColonColonLoc The location of the trailing '::'.
void Extend(ASTContext &Context, NamespaceAliasDecl *Alias, void Extend(ASTContext &Context, NamespaceAliasDecl *Alias,
SourceLocation AliasLoc, SourceLocation ColonColonLoc); SourceLocation AliasLoc, SourceLocation ColonColonLoc);
/// \brief Turn this (empty) nested-name-specifier into the global /// \brief Turn this (empty) nested-name-specifier into the global
/// nested-name-specifier '::'. /// nested-name-specifier '::'.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc); void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc);
/// \brief Make a new nested-name-specifier from incomplete source-location /// \brief Make a new nested-name-specifier from incomplete source-location
/// information. /// information.
/// ///
/// This routine should be used very, very rarely, in cases where we /// This routine should be used very, very rarely, in cases where we
/// need to synthesize a nested-name-specifier. Most code should instead use /// need to synthesize a nested-name-specifier. Most code should instead use
/// \c Adopt() with a proper \c NestedNameSpecifierLoc. /// \c Adopt() with a proper \c NestedNameSpecifierLoc.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier,
SourceRange R); SourceRange R);
/// \brief Adopt an existing nested-name-specifier (with source-range /// \brief Adopt an existing nested-name-specifier (with source-range
/// information). /// information).
void Adopt(NestedNameSpecifierLoc Other); void Adopt(NestedNameSpecifierLoc Other);
/// \brief Retrieve the source range covered by this nested-name-specifier. /// \brief Retrieve the source range covered by this nested-name-specifier.
SourceRange getSourceRange() const { SourceRange getSourceRange() const {
return NestedNameSpecifierLoc(Representation, Buffer).getSourceRange(); return NestedNameSpecifierLoc(Representation, Buffer).getSourceRange();
} }
/// \brief Retrieve a nested-name-specifier with location information, /// \brief Retrieve a nested-name-specifier with location information,
/// copied into the given AST context. /// copied into the given AST context.
/// ///
@ -449,7 +450,7 @@ public:
Representation = 0; Representation = 0;
BufferSize = 0; BufferSize = 0;
} }
/// \brief Retrieve the underlying buffer. /// \brief Retrieve the underlying buffer.
/// ///
/// \returns A pair containing a pointer to the buffer of source-location /// \returns A pair containing a pointer to the buffer of source-location
@ -459,9 +460,9 @@ public:
return std::make_pair(Buffer, BufferSize); return std::make_pair(Buffer, BufferSize);
} }
}; };
/// Insertion operator for diagnostics. This allows sending NestedNameSpecifiers /// Insertion operator for diagnostics. This allows sending
/// into a diagnostic with <<. /// NestedNameSpecifiers into a diagnostic with <<.
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
NestedNameSpecifier *NNS) { NestedNameSpecifier *NNS) {
DB.AddTaggedVal(reinterpret_cast<intptr_t>(NNS), DB.AddTaggedVal(reinterpret_cast<intptr_t>(NNS),

View File

@ -147,7 +147,7 @@ public:
/// \brief Return whether this visitor should recurse into the types of /// \brief Return whether this visitor should recurse into the types of
/// TypeLocs. /// TypeLocs.
bool shouldWalkTypesOfTypeLocs() const { return true; } bool shouldWalkTypesOfTypeLocs() const { return true; }
/// \brief Recursively visit a statement or expression, by /// \brief Recursively visit a statement or expression, by
/// dispatching to Traverse*() based on the argument's dynamic type. /// dispatching to Traverse*() based on the argument's dynamic type.
/// ///
@ -181,7 +181,7 @@ public:
/// \returns false if the visitation was terminated early, true otherwise. /// \returns false if the visitation was terminated early, true otherwise.
bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS); bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS);
/// \brief Recursively visit a C++ nested-name-specifier with location /// \brief Recursively visit a C++ nested-name-specifier with location
/// information. /// information.
/// ///
/// \returns false if the visitation was terminated early, true otherwise. /// \returns false if the visitation was terminated early, true otherwise.
@ -191,7 +191,7 @@ public:
/// ///
/// \returns false if the visitation was terminated early, true otherwise. /// \returns false if the visitation was terminated early, true otherwise.
bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo); bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo);
/// \brief Recursively visit a template name and dispatch to the /// \brief Recursively visit a template name and dispatch to the
/// appropriate method. /// appropriate method.
/// ///
@ -530,23 +530,23 @@ bool RecursiveASTVisitor<Derived>::TraverseNestedNameSpecifierLoc(
NestedNameSpecifierLoc NNS) { NestedNameSpecifierLoc NNS) {
if (!NNS) if (!NNS)
return true; return true;
if (NestedNameSpecifierLoc Prefix = NNS.getPrefix()) if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
TRY_TO(TraverseNestedNameSpecifierLoc(Prefix)); TRY_TO(TraverseNestedNameSpecifierLoc(Prefix));
switch (NNS.getNestedNameSpecifier()->getKind()) { switch (NNS.getNestedNameSpecifier()->getKind()) {
case NestedNameSpecifier::Identifier: case NestedNameSpecifier::Identifier:
case NestedNameSpecifier::Namespace: case NestedNameSpecifier::Namespace:
case NestedNameSpecifier::NamespaceAlias: case NestedNameSpecifier::NamespaceAlias:
case NestedNameSpecifier::Global: case NestedNameSpecifier::Global:
return true; return true;
case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: case NestedNameSpecifier::TypeSpecWithTemplate:
TRY_TO(TraverseTypeLoc(NNS.getTypeLoc())); TRY_TO(TraverseTypeLoc(NNS.getTypeLoc()));
break; break;
} }
return true; return true;
} }
@ -559,9 +559,9 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclarationNameInfo(
case DeclarationName::CXXConversionFunctionName: case DeclarationName::CXXConversionFunctionName:
if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo()) if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc())); TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
break; break;
case DeclarationName::Identifier: case DeclarationName::Identifier:
case DeclarationName::ObjCZeroArgSelector: case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector: case DeclarationName::ObjCOneArgSelector:
@ -571,7 +571,7 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclarationNameInfo(
case DeclarationName::CXXUsingDirective: case DeclarationName::CXXUsingDirective:
break; break;
} }
return true; return true;
} }
@ -630,7 +630,7 @@ bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLoc(
// FIXME: how can TSI ever be NULL? // FIXME: how can TSI ever be NULL?
if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo()) if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo())
return getDerived().TraverseTypeLoc(TSI->getTypeLoc()); return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
else else
return getDerived().TraverseType(Arg.getAsType()); return getDerived().TraverseType(Arg.getAsType());
} }
@ -669,7 +669,7 @@ bool RecursiveASTVisitor<Derived>::TraverseConstructorInitializer(
CXXCtorInitializer *Init) { CXXCtorInitializer *Init) {
if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo()) if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo())
TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc())); TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
if (Init->isWritten()) if (Init->isWritten())
TRY_TO(TraverseStmt(Init->getInit())); TRY_TO(TraverseStmt(Init->getInit()));
return true; return true;
@ -854,8 +854,8 @@ DEF_TRAVERSE_TYPE(AtomicType, {
// ----------------- TypeLoc traversal ----------------- // ----------------- TypeLoc traversal -----------------
// This macro makes available a variable TL, the passed-in TypeLoc. // This macro makes available a variable TL, the passed-in TypeLoc.
// If requested, it calls WalkUpFrom* for the Type in the given TypeLoc, // If requested, it calls WalkUpFrom* for the Type in the given TypeLoc,
// in addition to WalkUpFrom* for the TypeLoc itself, such that existing // in addition to WalkUpFrom* for the TypeLoc itself, such that existing
// clients that override the WalkUpFrom*Type() and/or Visit*Type() methods // clients that override the WalkUpFrom*Type() and/or Visit*Type() methods
// continue to work. // continue to work.
#define DEF_TRAVERSE_TYPELOC(TYPE, CODE) \ #define DEF_TRAVERSE_TYPELOC(TYPE, CODE) \
@ -1054,7 +1054,7 @@ DEF_TRAVERSE_TYPELOC(DependentTemplateSpecializationType, {
if (TL.getQualifierLoc()) { if (TL.getQualifierLoc()) {
TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc())); TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
} }
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) { for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I))); TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
} }
@ -1196,8 +1196,8 @@ DEF_TRAVERSE_DECL(NamespaceAliasDecl, {
DEF_TRAVERSE_DECL(LabelDecl, { DEF_TRAVERSE_DECL(LabelDecl, {
// There is no code in a LabelDecl. // There is no code in a LabelDecl.
}) })
DEF_TRAVERSE_DECL(NamespaceDecl, { DEF_TRAVERSE_DECL(NamespaceDecl, {
// Code in an unnamed namespace shows up automatically in // Code in an unnamed namespace shows up automatically in
// decls_begin()/decls_end(). Thus we don't need to recurse on // decls_begin()/decls_end(). Thus we don't need to recurse on
@ -1345,7 +1345,8 @@ template<typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseFunctionInstantiations( bool RecursiveASTVisitor<Derived>::TraverseFunctionInstantiations(
FunctionTemplateDecl* D) { FunctionTemplateDecl* D) {
FunctionTemplateDecl::spec_iterator end = D->spec_end(); FunctionTemplateDecl::spec_iterator end = D->spec_end();
for (FunctionTemplateDecl::spec_iterator it = D->spec_begin(); it != end; ++it) { for (FunctionTemplateDecl::spec_iterator it = D->spec_begin(); it != end;
++it) {
FunctionDecl* FD = *it; FunctionDecl* FD = *it;
switch (FD->getTemplateSpecializationKind()) { switch (FD->getTemplateSpecializationKind()) {
case TSK_ImplicitInstantiation: case TSK_ImplicitInstantiation:
@ -1770,7 +1771,7 @@ DEF_TRAVERSE_STMT(ObjCAtTryStmt, { })
DEF_TRAVERSE_STMT(ObjCForCollectionStmt, { }) DEF_TRAVERSE_STMT(ObjCForCollectionStmt, { })
DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, { }) DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, { })
DEF_TRAVERSE_STMT(CXXForRangeStmt, { }) DEF_TRAVERSE_STMT(CXXForRangeStmt, { })
DEF_TRAVERSE_STMT(MSDependentExistsStmt, { DEF_TRAVERSE_STMT(MSDependentExistsStmt, {
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo())); TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
}) })
@ -1986,7 +1987,7 @@ DEF_TRAVERSE_STMT(CXXDefaultArgExpr, { })
DEF_TRAVERSE_STMT(CXXDeleteExpr, { }) DEF_TRAVERSE_STMT(CXXDeleteExpr, { })
DEF_TRAVERSE_STMT(ExprWithCleanups, { }) DEF_TRAVERSE_STMT(ExprWithCleanups, { })
DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, { }) DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, { })
DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, { DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, {
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo()) if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc())); TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
@ -2018,15 +2019,15 @@ DEF_TRAVERSE_STMT(StmtExpr, { })
DEF_TRAVERSE_STMT(UnresolvedLookupExpr, { DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
if (S->hasExplicitTemplateArgs()) { if (S->hasExplicitTemplateArgs()) {
TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(), TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
S->getNumTemplateArgs())); S->getNumTemplateArgs()));
} }
}) })
DEF_TRAVERSE_STMT(UnresolvedMemberExpr, { DEF_TRAVERSE_STMT(UnresolvedMemberExpr, {
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
if (S->hasExplicitTemplateArgs()) { if (S->hasExplicitTemplateArgs()) {
TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(), TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
S->getNumTemplateArgs())); S->getNumTemplateArgs()));
} }
}) })
@ -2061,7 +2062,7 @@ DEF_TRAVERSE_STMT(FloatingLiteral, { })
DEF_TRAVERSE_STMT(ImaginaryLiteral, { }) DEF_TRAVERSE_STMT(ImaginaryLiteral, { })
DEF_TRAVERSE_STMT(StringLiteral, { }) DEF_TRAVERSE_STMT(StringLiteral, { })
DEF_TRAVERSE_STMT(ObjCStringLiteral, { }) DEF_TRAVERSE_STMT(ObjCStringLiteral, { })
// Traverse OpenCL: AsType, Convert. // Traverse OpenCL: AsType, Convert.
DEF_TRAVERSE_STMT(AsTypeExpr, { }) DEF_TRAVERSE_STMT(AsTypeExpr, { })

View File

@ -39,11 +39,11 @@ namespace clang {
class StringLiteral; class StringLiteral;
class SwitchStmt; class SwitchStmt;
//===----------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// ExprIterator - Iterators for iterating over Stmt* arrays that contain // ExprIterator - Iterators for iterating over Stmt* arrays that contain
// only Expr*. This is needed because AST nodes use Stmt* arrays to store // only Expr*. This is needed because AST nodes use Stmt* arrays to store
// references to children (to be compatible with StmtIterator). // references to children (to be compatible with StmtIterator).
//===----------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
class Stmt; class Stmt;
class Expr; class Expr;
@ -261,7 +261,7 @@ public:
if (Stmt::CollectingStats()) Stmt::addStmtClass(SC); if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
} }
StmtClass getStmtClass() const { StmtClass getStmtClass() const {
return static_cast<StmtClass>(StmtBits.sClass); return static_cast<StmtClass>(StmtBits.sClass);
} }
const char *getStmtClassName() const; const char *getStmtClassName() const;
@ -497,7 +497,7 @@ public:
body_iterator body_begin() { return Body; } body_iterator body_begin() { return Body; }
body_iterator body_end() { return Body + size(); } body_iterator body_end() { return Body + size(); }
Stmt *body_back() { return !body_empty() ? Body[size()-1] : 0; } Stmt *body_back() { return !body_empty() ? Body[size()-1] : 0; }
void setLastStmt(Stmt *S) { void setLastStmt(Stmt *S) {
assert(!body_empty() && "setLastStmt"); assert(!body_empty() && "setLastStmt");
Body[size()-1] = S; Body[size()-1] = S;
@ -545,7 +545,7 @@ public:
child_range children() { child_range children() {
return child_range(&Body[0], &Body[0]+CompoundStmtBits.NumStmts); return child_range(&Body[0], &Body[0]+CompoundStmtBits.NumStmts);
} }
const_child_range children() const { const_child_range children() const {
return child_range(&Body[0], &Body[0]+CompoundStmtBits.NumStmts); return child_range(&Body[0], &Body[0]+CompoundStmtBits.NumStmts);
} }
@ -679,7 +679,7 @@ public:
child_range children() { return child_range(&SubStmt, &SubStmt+1); } child_range children() { return child_range(&SubStmt, &SubStmt+1); }
}; };
/// LabelStmt - Represents a label, which has a substatement. For example: /// LabelStmt - Represents a label, which has a substatement. For example:
/// foo: return; /// foo: return;
/// ///
@ -724,11 +724,11 @@ class IfStmt : public Stmt {
SourceLocation IfLoc; SourceLocation IfLoc;
SourceLocation ElseLoc; SourceLocation ElseLoc;
public: public:
IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond, IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond,
Stmt *then, SourceLocation EL = SourceLocation(), Stmt *elsev = 0); Stmt *then, SourceLocation EL = SourceLocation(), Stmt *elsev = 0);
/// \brief Build an empty if/then/else statement /// \brief Build an empty if/then/else statement
explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { } explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { }
@ -742,13 +742,13 @@ public:
/// \endcode /// \endcode
VarDecl *getConditionVariable() const; VarDecl *getConditionVariable() const;
void setConditionVariable(ASTContext &C, VarDecl *V); void setConditionVariable(ASTContext &C, VarDecl *V);
/// If this IfStmt has a condition variable, return the faux DeclStmt /// If this IfStmt has a condition variable, return the faux DeclStmt
/// associated with the creation of that condition variable. /// associated with the creation of that condition variable.
const DeclStmt *getConditionVariableDeclStmt() const { const DeclStmt *getConditionVariableDeclStmt() const {
return reinterpret_cast<DeclStmt*>(SubExprs[VAR]); return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
} }
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);} const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); } void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
const Stmt *getThen() const { return SubExprs[THEN]; } const Stmt *getThen() const { return SubExprs[THEN]; }
@ -815,7 +815,7 @@ public:
/// \endcode /// \endcode
VarDecl *getConditionVariable() const; VarDecl *getConditionVariable() const;
void setConditionVariable(ASTContext &C, VarDecl *V); void setConditionVariable(ASTContext &C, VarDecl *V);
/// If this SwitchStmt has a condition variable, return the faux DeclStmt /// If this SwitchStmt has a condition variable, return the faux DeclStmt
/// associated with the creation of that condition variable. /// associated with the creation of that condition variable.
const DeclStmt *getConditionVariableDeclStmt() const { const DeclStmt *getConditionVariableDeclStmt() const {
@ -846,7 +846,8 @@ public:
SwitchLoc = SL; SwitchLoc = SL;
} }
void addSwitchCase(SwitchCase *SC) { void addSwitchCase(SwitchCase *SC) {
assert(!SC->getNextSwitchCase() && "case/default already added to a switch"); assert(!SC->getNextSwitchCase()
&& "case/default already added to a switch");
SC->setNextSwitchCase(FirstCase); SC->setNextSwitchCase(FirstCase);
FirstCase = SC; FirstCase = SC;
} }
@ -885,7 +886,7 @@ class WhileStmt : public Stmt {
Stmt* SubExprs[END_EXPR]; Stmt* SubExprs[END_EXPR];
SourceLocation WhileLoc; SourceLocation WhileLoc;
public: public:
WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body, WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
SourceLocation WL); SourceLocation WL);
/// \brief Build an empty while statement. /// \brief Build an empty while statement.
@ -993,14 +994,14 @@ class ForStmt : public Stmt {
SourceLocation LParenLoc, RParenLoc; SourceLocation LParenLoc, RParenLoc;
public: public:
ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc,
Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP); Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP);
/// \brief Build an empty for statement. /// \brief Build an empty for statement.
explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { } explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { }
Stmt *getInit() { return SubExprs[INIT]; } Stmt *getInit() { return SubExprs[INIT]; }
/// \brief Retrieve the variable declared in this "for" statement, if any. /// \brief Retrieve the variable declared in this "for" statement, if any.
/// ///
/// In the following example, "y" is the condition variable. /// In the following example, "y" is the condition variable.
@ -1011,7 +1012,7 @@ public:
/// \endcode /// \endcode
VarDecl *getConditionVariable() const; VarDecl *getConditionVariable() const;
void setConditionVariable(ASTContext &C, VarDecl *V); void setConditionVariable(ASTContext &C, VarDecl *V);
/// If this ForStmt has a condition variable, return the faux DeclStmt /// If this ForStmt has a condition variable, return the faux DeclStmt
/// associated with the creation of that condition variable. /// associated with the creation of that condition variable.
const DeclStmt *getConditionVariableDeclStmt() const { const DeclStmt *getConditionVariableDeclStmt() const {
@ -1196,7 +1197,7 @@ class ReturnStmt : public Stmt {
Stmt *RetExpr; Stmt *RetExpr;
SourceLocation RetLoc; SourceLocation RetLoc;
const VarDecl *NRVOCandidate; const VarDecl *NRVOCandidate;
public: public:
ReturnStmt(SourceLocation RL) ReturnStmt(SourceLocation RL)
: Stmt(ReturnStmtClass), RetExpr(0), RetLoc(RL), NRVOCandidate(0) { } : Stmt(ReturnStmtClass), RetExpr(0), RetLoc(RL), NRVOCandidate(0) { }
@ -1222,7 +1223,7 @@ public:
/// also marked as an NRVO object. /// also marked as an NRVO object.
const VarDecl *getNRVOCandidate() const { return NRVOCandidate; } const VarDecl *getNRVOCandidate() const { return NRVOCandidate; }
void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; } void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1256,16 +1257,16 @@ class AsmStmt : public Stmt {
StringLiteral **Constraints; StringLiteral **Constraints;
Stmt **Exprs; Stmt **Exprs;
StringLiteral **Clobbers; StringLiteral **Clobbers;
public: public:
AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile, AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile,
bool msasm, unsigned numoutputs, unsigned numinputs, bool msasm, unsigned numoutputs, unsigned numinputs,
IdentifierInfo **names, StringLiteral **constraints, IdentifierInfo **names, StringLiteral **constraints,
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
StringLiteral **clobbers, SourceLocation rparenloc); StringLiteral **clobbers, SourceLocation rparenloc);
/// \brief Build an empty inline-assembly statement. /// \brief Build an empty inline-assembly statement.
explicit AsmStmt(EmptyShell Empty) : Stmt(AsmStmtClass, Empty), explicit AsmStmt(EmptyShell Empty) : Stmt(AsmStmtClass, Empty),
Names(0), Constraints(0), Exprs(0), Clobbers(0) { } Names(0), Constraints(0), Exprs(0), Clobbers(0) { }
SourceLocation getAsmLoc() const { return AsmLoc; } SourceLocation getAsmLoc() const { return AsmLoc; }
@ -1347,7 +1348,7 @@ public:
StringRef getOutputName(unsigned i) const { StringRef getOutputName(unsigned i) const {
if (IdentifierInfo *II = getOutputIdentifier(i)) if (IdentifierInfo *II = getOutputIdentifier(i))
return II->getName(); return II->getName();
return StringRef(); return StringRef();
} }
@ -1408,7 +1409,7 @@ public:
Expr *getInputExpr(unsigned i); Expr *getInputExpr(unsigned i);
void setInputExpr(unsigned i, Expr *E); void setInputExpr(unsigned i, Expr *E);
const Expr *getInputExpr(unsigned i) const { const Expr *getInputExpr(unsigned i) const {
return const_cast<AsmStmt*>(this)->getInputExpr(i); return const_cast<AsmStmt*>(this)->getInputExpr(i);
} }
@ -1418,7 +1419,7 @@ public:
StringLiteral **Constraints, StringLiteral **Constraints,
Stmt **Exprs, Stmt **Exprs,
unsigned NumOutputs, unsigned NumOutputs,
unsigned NumInputs, unsigned NumInputs,
StringLiteral **Clobbers, StringLiteral **Clobbers,
unsigned NumClobbers); unsigned NumClobbers);
@ -1511,8 +1512,13 @@ public:
SourceLocation getExceptLoc() const { return Loc; } SourceLocation getExceptLoc() const { return Loc; }
SourceLocation getEndLoc() const { return getBlock()->getLocEnd(); } SourceLocation getEndLoc() const { return getBlock()->getLocEnd(); }
Expr *getFilterExpr() const { return reinterpret_cast<Expr*>(Children[FILTER_EXPR]); } Expr *getFilterExpr() const {
CompoundStmt *getBlock() const { return llvm::cast<CompoundStmt>(Children[BLOCK]); } return reinterpret_cast<Expr*>(Children[FILTER_EXPR]);
}
CompoundStmt *getBlock() const {
return llvm::cast<CompoundStmt>(Children[BLOCK]);
}
child_range children() { child_range children() {
return child_range(Children,Children+2); return child_range(Children,Children+2);
@ -1594,7 +1600,11 @@ public:
SourceLocation getEndLoc() const { return Children[HANDLER]->getLocEnd(); } SourceLocation getEndLoc() const { return Children[HANDLER]->getLocEnd(); }
bool getIsCXXTry() const { return IsCXXTry; } bool getIsCXXTry() const { return IsCXXTry; }
CompoundStmt* getTryBlock() const { return llvm::cast<CompoundStmt>(Children[TRY]); }
CompoundStmt* getTryBlock() const {
return llvm::cast<CompoundStmt>(Children[TRY]);
}
Stmt *getHandler() const { return Children[HANDLER]; } Stmt *getHandler() const { return Children[HANDLER]; }
/// Returns 0 if not defined /// Returns 0 if not defined
@ -1611,7 +1621,7 @@ public:
static bool classof(SEHTryStmt *) { return true; } static bool classof(SEHTryStmt *) { return true; }
}; };
} // end namespace clang } // end namespace clang
#endif #endif

View File

@ -148,7 +148,9 @@ public:
DeclStmt *getRangeStmt() { return cast<DeclStmt>(SubExprs[RANGE]); } DeclStmt *getRangeStmt() { return cast<DeclStmt>(SubExprs[RANGE]); }
DeclStmt *getBeginEndStmt() { return cast_or_null<DeclStmt>(SubExprs[BEGINEND]); } DeclStmt *getBeginEndStmt() {
return cast_or_null<DeclStmt>(SubExprs[BEGINEND]);
}
Expr *getCond() { return cast_or_null<Expr>(SubExprs[COND]); } Expr *getCond() { return cast_or_null<Expr>(SubExprs[COND]); }
Expr *getInc() { return cast_or_null<Expr>(SubExprs[INC]); } Expr *getInc() { return cast_or_null<Expr>(SubExprs[INC]); }
DeclStmt *getLoopVarStmt() { return cast<DeclStmt>(SubExprs[LOOPVAR]); } DeclStmt *getLoopVarStmt() { return cast<DeclStmt>(SubExprs[LOOPVAR]); }
@ -209,10 +211,10 @@ public:
/// example: /// example:
/// ///
/// \code /// \code
/// template<typename T> /// template<typename T>
/// void call_foo(T &t) { /// void call_foo(T &t) {
/// __if_exists (T::foo) { /// __if_exists (T::foo) {
/// t.foo(); // okay: only called when T::foo exists. /// t.foo(); // okay: only called when T::foo exists.
/// } /// }
/// } /// }
/// \endcode /// \endcode
@ -234,56 +236,56 @@ class MSDependentExistsStmt : public Stmt {
NestedNameSpecifierLoc QualifierLoc; NestedNameSpecifierLoc QualifierLoc;
DeclarationNameInfo NameInfo; DeclarationNameInfo NameInfo;
Stmt *SubStmt; Stmt *SubStmt;
friend class ASTReader; friend class ASTReader;
friend class ASTStmtReader; friend class ASTStmtReader;
public: public:
MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists,
NestedNameSpecifierLoc QualifierLoc, NestedNameSpecifierLoc QualifierLoc,
DeclarationNameInfo NameInfo, DeclarationNameInfo NameInfo,
CompoundStmt *SubStmt) CompoundStmt *SubStmt)
: Stmt(MSDependentExistsStmtClass), : Stmt(MSDependentExistsStmtClass),
KeywordLoc(KeywordLoc), IsIfExists(IsIfExists), KeywordLoc(KeywordLoc), IsIfExists(IsIfExists),
QualifierLoc(QualifierLoc), NameInfo(NameInfo), QualifierLoc(QualifierLoc), NameInfo(NameInfo),
SubStmt(reinterpret_cast<Stmt *>(SubStmt)) { } SubStmt(reinterpret_cast<Stmt *>(SubStmt)) { }
/// \brief Retrieve the location of the __if_exists or __if_not_exists /// \brief Retrieve the location of the __if_exists or __if_not_exists
/// keyword. /// keyword.
SourceLocation getKeywordLoc() const { return KeywordLoc; } SourceLocation getKeywordLoc() const { return KeywordLoc; }
/// \brief Determine whether this is an __if_exists statement. /// \brief Determine whether this is an __if_exists statement.
bool isIfExists() const { return IsIfExists; } bool isIfExists() const { return IsIfExists; }
/// \brief Determine whether this is an __if_exists statement. /// \brief Determine whether this is an __if_exists statement.
bool isIfNotExists() const { return !IsIfExists; } bool isIfNotExists() const { return !IsIfExists; }
/// \brief Retrieve the nested-name-specifier that qualifies this name, if /// \brief Retrieve the nested-name-specifier that qualifies this name, if
/// any. /// any.
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
/// \brief Retrieve the name of the entity we're testing for, along with /// \brief Retrieve the name of the entity we're testing for, along with
/// location information /// location information
DeclarationNameInfo getNameInfo() const { return NameInfo; } DeclarationNameInfo getNameInfo() const { return NameInfo; }
/// \brief Retrieve the compound statement that will be included in the /// \brief Retrieve the compound statement that will be included in the
/// program only if the existence of the symbol matches the initial keyword. /// program only if the existence of the symbol matches the initial keyword.
CompoundStmt *getSubStmt() const { CompoundStmt *getSubStmt() const {
return reinterpret_cast<CompoundStmt *>(SubStmt); return reinterpret_cast<CompoundStmt *>(SubStmt);
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const {
return SourceRange(KeywordLoc, SubStmt->getLocEnd()); return SourceRange(KeywordLoc, SubStmt->getLocEnd());
} }
child_range children() { child_range children() {
return child_range(&SubStmt, &SubStmt+1); return child_range(&SubStmt, &SubStmt+1);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == MSDependentExistsStmtClass; return T->getStmtClass() == MSDependentExistsStmtClass;
} }
static bool classof(MSDependentExistsStmt *) { return true; } static bool classof(MSDependentExistsStmt *) { return true; }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -159,7 +159,8 @@ public:
static bool classof(const TypeLoc *TL) { return true; } static bool classof(const TypeLoc *TL) { return true; }
private: private:
static void initializeImpl(ASTContext &Context, TypeLoc TL, SourceLocation Loc); static void initializeImpl(ASTContext &Context, TypeLoc TL,
SourceLocation Loc);
static TypeLoc getNextTypeLocImpl(TypeLoc TL); static TypeLoc getNextTypeLocImpl(TypeLoc TL);
static TypeLoc IgnoreParensImpl(TypeLoc TL); static TypeLoc IgnoreParensImpl(TypeLoc TL);
static SourceRange getLocalSourceRangeImpl(TypeLoc TL); static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
@ -226,7 +227,7 @@ public:
/// \brief Returns the size of the type source info data block. /// \brief Returns the size of the type source info data block.
unsigned getFullDataSize() const { unsigned getFullDataSize() const {
return getLocalDataSize() + return getLocalDataSize() +
getFullDataSizeForType(getType().getLocalUnqualifiedType()); getFullDataSizeForType(getType().getLocalUnqualifiedType());
} }
@ -326,7 +327,7 @@ protected:
void *getExtraLocalData() const { void *getExtraLocalData() const {
return getLocalData() + 1; return getLocalData() + 1;
} }
void *getNonLocalData() const { void *getNonLocalData() const {
return static_cast<char*>(Base::Data) + asDerived()->getLocalDataSize(); return static_cast<char*>(Base::Data) + asDerived()->getLocalDataSize();
} }
@ -392,7 +393,7 @@ struct TypeSpecLocInfo {
/// \brief A reasonable base class for TypeLocs that correspond to /// \brief A reasonable base class for TypeLocs that correspond to
/// types that are written as a type-specifier. /// types that are written as a type-specifier.
class TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, class TypeSpecTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
TypeSpecTypeLoc, TypeSpecTypeLoc,
Type, Type,
TypeSpecLocInfo> { TypeSpecLocInfo> {
@ -566,7 +567,7 @@ class TagTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
public: public:
TagDecl *getDecl() const { return getTypePtr()->getDecl(); } TagDecl *getDecl() const { return getTypePtr()->getDecl(); }
/// \brief True if the tag was defined in this type specifier. /// \brief True if the tag was defined in this type specifier.
bool isDefinition() const { bool isDefinition() const {
return getDecl()->isCompleteDefinition() && return getDecl()->isCompleteDefinition() &&
(getNameLoc().isInvalid() || getNameLoc() == getDecl()->getLocation()); (getNameLoc().isInvalid() || getNameLoc() == getDecl()->getLocation());
@ -789,7 +790,7 @@ public:
assert(i < getNumProtocols() && "Index is out of bounds!"); assert(i < getNumProtocols() && "Index is out of bounds!");
return *(this->getTypePtr()->qual_begin() + i); return *(this->getTypePtr()->qual_begin() + i);
} }
bool hasBaseTypeAsWritten() const { bool hasBaseTypeAsWritten() const {
return getLocalData()->HasBaseTypeAsWritten; return getLocalData()->HasBaseTypeAsWritten;
} }
@ -900,11 +901,11 @@ struct PointerLikeLocInfo {
SourceLocation StarLoc; SourceLocation StarLoc;
}; };
/// A base class for /// A base class for
template <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo> template <class Derived, class TypeClass, class LocalData = PointerLikeLocInfo>
class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived, class PointerLikeTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, Derived,
TypeClass, LocalData> { TypeClass, LocalData> {
public: public:
SourceLocation getSigilLoc() const { SourceLocation getSigilLoc() const {
return this->getLocalData()->StarLoc; return this->getLocalData()->StarLoc;
} }
@ -1476,9 +1477,9 @@ class AutoTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
struct ElaboratedLocInfo { struct ElaboratedLocInfo {
SourceLocation KeywordLoc; SourceLocation KeywordLoc;
/// \brief Opaque data pointer used to reconstruct a nested-name-specifier /// \brief Opaque data pointer used to reconstruct a nested-name-specifier
/// from /// from
void *QualifierData; void *QualifierData;
}; };
@ -1495,12 +1496,12 @@ public:
} }
NestedNameSpecifierLoc getQualifierLoc() const { NestedNameSpecifierLoc getQualifierLoc() const {
return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
getLocalData()->QualifierData); getLocalData()->QualifierData);
} }
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
assert(QualifierLoc.getNestedNameSpecifier() assert(QualifierLoc.getNestedNameSpecifier()
== getTypePtr()->getQualifier() && == getTypePtr()->getQualifier() &&
"Inconsistent nested-name-specifier pointer"); "Inconsistent nested-name-specifier pointer");
getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
@ -1537,7 +1538,7 @@ public:
// type is some sort of TypeDeclTypeLoc. // type is some sort of TypeDeclTypeLoc.
struct DependentNameLocInfo : ElaboratedLocInfo { struct DependentNameLocInfo : ElaboratedLocInfo {
SourceLocation NameLoc; SourceLocation NameLoc;
/// \brief Data associated with the nested-name-specifier location. /// \brief Data associated with the nested-name-specifier location.
void *QualifierData; void *QualifierData;
}; };
@ -1555,17 +1556,17 @@ public:
} }
NestedNameSpecifierLoc getQualifierLoc() const { NestedNameSpecifierLoc getQualifierLoc() const {
return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
getLocalData()->QualifierData); getLocalData()->QualifierData);
} }
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
assert(QualifierLoc.getNestedNameSpecifier() assert(QualifierLoc.getNestedNameSpecifier()
== getTypePtr()->getQualifier() && == getTypePtr()->getQualifier() &&
"Inconsistent nested-name-specifier pointer"); "Inconsistent nested-name-specifier pointer");
getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
} }
SourceLocation getNameLoc() const { SourceLocation getNameLoc() const {
return this->getLocalData()->NameLoc; return this->getLocalData()->NameLoc;
} }
@ -1612,22 +1613,22 @@ public:
NestedNameSpecifierLoc getQualifierLoc() const { NestedNameSpecifierLoc getQualifierLoc() const {
if (!getLocalData()->QualifierData) if (!getLocalData()->QualifierData)
return NestedNameSpecifierLoc(); return NestedNameSpecifierLoc();
return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), return NestedNameSpecifierLoc(getTypePtr()->getQualifier(),
getLocalData()->QualifierData); getLocalData()->QualifierData);
} }
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) {
if (!QualifierLoc) { if (!QualifierLoc) {
// Even if we have a nested-name-specifier in the dependent // Even if we have a nested-name-specifier in the dependent
// template specialization type, we won't record the nested-name-specifier // template specialization type, we won't record the nested-name-specifier
// location information when this type-source location information is // location information when this type-source location information is
// part of a nested-name-specifier. // part of a nested-name-specifier.
getLocalData()->QualifierData = 0; getLocalData()->QualifierData = 0;
return; return;
} }
assert(QualifierLoc.getNestedNameSpecifier() assert(QualifierLoc.getNestedNameSpecifier()
== getTypePtr()->getQualifier() && == getTypePtr()->getQualifier() &&
"Inconsistent nested-name-specifier pointer"); "Inconsistent nested-name-specifier pointer");
getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); getLocalData()->QualifierData = QualifierLoc.getOpaqueData();
@ -1702,7 +1703,7 @@ struct PackExpansionTypeLocInfo {
}; };
class PackExpansionTypeLoc class PackExpansionTypeLoc
: public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc, : public ConcreteTypeLoc<UnqualTypeLoc, PackExpansionTypeLoc,
PackExpansionType, PackExpansionTypeLocInfo> { PackExpansionType, PackExpansionTypeLocInfo> {
public: public:
SourceLocation getEllipsisLoc() const { SourceLocation getEllipsisLoc() const {
@ -1736,7 +1737,7 @@ struct AtomicTypeLocInfo {
class AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc, class AtomicTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, AtomicTypeLoc,
AtomicType, AtomicTypeLocInfo> { AtomicType, AtomicTypeLocInfo> {
public: public:
TypeLoc getValueLoc() const { TypeLoc getValueLoc() const {
return this->getInnerTypeLoc(); return this->getInnerTypeLoc();
} }

View File

@ -34,16 +34,16 @@ public:
CK_OffsetToTop, CK_OffsetToTop,
CK_RTTI, CK_RTTI,
CK_FunctionPointer, CK_FunctionPointer,
/// CK_CompleteDtorPointer - A pointer to the complete destructor. /// CK_CompleteDtorPointer - A pointer to the complete destructor.
CK_CompleteDtorPointer, CK_CompleteDtorPointer,
/// CK_DeletingDtorPointer - A pointer to the deleting destructor. /// CK_DeletingDtorPointer - A pointer to the deleting destructor.
CK_DeletingDtorPointer, CK_DeletingDtorPointer,
/// CK_UnusedFunctionPointer - In some cases, a vtable function pointer /// CK_UnusedFunctionPointer - In some cases, a vtable function pointer
/// will end up never being called. Such vtable function pointers are /// will end up never being called. Such vtable function pointers are
/// represented as a CK_UnusedFunctionPointer. /// represented as a CK_UnusedFunctionPointer.
CK_UnusedFunctionPointer CK_UnusedFunctionPointer
}; };
@ -60,34 +60,34 @@ public:
static VTableComponent MakeOffsetToTop(CharUnits Offset) { static VTableComponent MakeOffsetToTop(CharUnits Offset) {
return VTableComponent(CK_OffsetToTop, Offset); return VTableComponent(CK_OffsetToTop, Offset);
} }
static VTableComponent MakeRTTI(const CXXRecordDecl *RD) { static VTableComponent MakeRTTI(const CXXRecordDecl *RD) {
return VTableComponent(CK_RTTI, reinterpret_cast<uintptr_t>(RD)); return VTableComponent(CK_RTTI, reinterpret_cast<uintptr_t>(RD));
} }
static VTableComponent MakeFunction(const CXXMethodDecl *MD) { static VTableComponent MakeFunction(const CXXMethodDecl *MD) {
assert(!isa<CXXDestructorDecl>(MD) && assert(!isa<CXXDestructorDecl>(MD) &&
"Don't use MakeFunction with destructors!"); "Don't use MakeFunction with destructors!");
return VTableComponent(CK_FunctionPointer, return VTableComponent(CK_FunctionPointer,
reinterpret_cast<uintptr_t>(MD)); reinterpret_cast<uintptr_t>(MD));
} }
static VTableComponent MakeCompleteDtor(const CXXDestructorDecl *DD) { static VTableComponent MakeCompleteDtor(const CXXDestructorDecl *DD) {
return VTableComponent(CK_CompleteDtorPointer, return VTableComponent(CK_CompleteDtorPointer,
reinterpret_cast<uintptr_t>(DD)); reinterpret_cast<uintptr_t>(DD));
} }
static VTableComponent MakeDeletingDtor(const CXXDestructorDecl *DD) { static VTableComponent MakeDeletingDtor(const CXXDestructorDecl *DD) {
return VTableComponent(CK_DeletingDtorPointer, return VTableComponent(CK_DeletingDtorPointer,
reinterpret_cast<uintptr_t>(DD)); reinterpret_cast<uintptr_t>(DD));
} }
static VTableComponent MakeUnusedFunction(const CXXMethodDecl *MD) { static VTableComponent MakeUnusedFunction(const CXXMethodDecl *MD) {
assert(!isa<CXXDestructorDecl>(MD) && assert(!isa<CXXDestructorDecl>(MD) &&
"Don't use MakeUnusedFunction with destructors!"); "Don't use MakeUnusedFunction with destructors!");
return VTableComponent(CK_UnusedFunctionPointer, return VTableComponent(CK_UnusedFunctionPointer,
reinterpret_cast<uintptr_t>(MD)); reinterpret_cast<uintptr_t>(MD));
} }
static VTableComponent getFromOpaqueInteger(uint64_t I) { static VTableComponent getFromOpaqueInteger(uint64_t I) {
@ -101,88 +101,88 @@ public:
CharUnits getVCallOffset() const { CharUnits getVCallOffset() const {
assert(getKind() == CK_VCallOffset && "Invalid component kind!"); assert(getKind() == CK_VCallOffset && "Invalid component kind!");
return getOffset(); return getOffset();
} }
CharUnits getVBaseOffset() const { CharUnits getVBaseOffset() const {
assert(getKind() == CK_VBaseOffset && "Invalid component kind!"); assert(getKind() == CK_VBaseOffset && "Invalid component kind!");
return getOffset(); return getOffset();
} }
CharUnits getOffsetToTop() const { CharUnits getOffsetToTop() const {
assert(getKind() == CK_OffsetToTop && "Invalid component kind!"); assert(getKind() == CK_OffsetToTop && "Invalid component kind!");
return getOffset(); return getOffset();
} }
const CXXRecordDecl *getRTTIDecl() const { const CXXRecordDecl *getRTTIDecl() const {
assert(getKind() == CK_RTTI && "Invalid component kind!"); assert(getKind() == CK_RTTI && "Invalid component kind!");
return reinterpret_cast<CXXRecordDecl *>(getPointer()); return reinterpret_cast<CXXRecordDecl *>(getPointer());
} }
const CXXMethodDecl *getFunctionDecl() const { const CXXMethodDecl *getFunctionDecl() const {
assert(getKind() == CK_FunctionPointer); assert(getKind() == CK_FunctionPointer);
return reinterpret_cast<CXXMethodDecl *>(getPointer()); return reinterpret_cast<CXXMethodDecl *>(getPointer());
} }
const CXXDestructorDecl *getDestructorDecl() const { const CXXDestructorDecl *getDestructorDecl() const {
assert((getKind() == CK_CompleteDtorPointer || assert((getKind() == CK_CompleteDtorPointer ||
getKind() == CK_DeletingDtorPointer) && "Invalid component kind!"); getKind() == CK_DeletingDtorPointer) && "Invalid component kind!");
return reinterpret_cast<CXXDestructorDecl *>(getPointer()); return reinterpret_cast<CXXDestructorDecl *>(getPointer());
} }
const CXXMethodDecl *getUnusedFunctionDecl() const { const CXXMethodDecl *getUnusedFunctionDecl() const {
assert(getKind() == CK_UnusedFunctionPointer); assert(getKind() == CK_UnusedFunctionPointer);
return reinterpret_cast<CXXMethodDecl *>(getPointer()); return reinterpret_cast<CXXMethodDecl *>(getPointer());
} }
private: private:
VTableComponent(Kind ComponentKind, CharUnits Offset) { VTableComponent(Kind ComponentKind, CharUnits Offset) {
assert((ComponentKind == CK_VCallOffset || assert((ComponentKind == CK_VCallOffset ||
ComponentKind == CK_VBaseOffset || ComponentKind == CK_VBaseOffset ||
ComponentKind == CK_OffsetToTop) && "Invalid component kind!"); ComponentKind == CK_OffsetToTop) && "Invalid component kind!");
assert(Offset.getQuantity() <= ((1LL << 56) - 1) && "Offset is too big!"); assert(Offset.getQuantity() <= ((1LL << 56) - 1) && "Offset is too big!");
Value = ((Offset.getQuantity() << 3) | ComponentKind); Value = ((Offset.getQuantity() << 3) | ComponentKind);
} }
VTableComponent(Kind ComponentKind, uintptr_t Ptr) { VTableComponent(Kind ComponentKind, uintptr_t Ptr) {
assert((ComponentKind == CK_RTTI || assert((ComponentKind == CK_RTTI ||
ComponentKind == CK_FunctionPointer || ComponentKind == CK_FunctionPointer ||
ComponentKind == CK_CompleteDtorPointer || ComponentKind == CK_CompleteDtorPointer ||
ComponentKind == CK_DeletingDtorPointer || ComponentKind == CK_DeletingDtorPointer ||
ComponentKind == CK_UnusedFunctionPointer) && ComponentKind == CK_UnusedFunctionPointer) &&
"Invalid component kind!"); "Invalid component kind!");
assert((Ptr & 7) == 0 && "Pointer not sufficiently aligned!"); assert((Ptr & 7) == 0 && "Pointer not sufficiently aligned!");
Value = Ptr | ComponentKind; Value = Ptr | ComponentKind;
} }
CharUnits getOffset() const { CharUnits getOffset() const {
assert((getKind() == CK_VCallOffset || getKind() == CK_VBaseOffset || assert((getKind() == CK_VCallOffset || getKind() == CK_VBaseOffset ||
getKind() == CK_OffsetToTop) && "Invalid component kind!"); getKind() == CK_OffsetToTop) && "Invalid component kind!");
return CharUnits::fromQuantity(Value >> 3); return CharUnits::fromQuantity(Value >> 3);
} }
uintptr_t getPointer() const { uintptr_t getPointer() const {
assert((getKind() == CK_RTTI || assert((getKind() == CK_RTTI ||
getKind() == CK_FunctionPointer || getKind() == CK_FunctionPointer ||
getKind() == CK_CompleteDtorPointer || getKind() == CK_CompleteDtorPointer ||
getKind() == CK_DeletingDtorPointer || getKind() == CK_DeletingDtorPointer ||
getKind() == CK_UnusedFunctionPointer) && getKind() == CK_UnusedFunctionPointer) &&
"Invalid component kind!"); "Invalid component kind!");
return static_cast<uintptr_t>(Value & ~7ULL); return static_cast<uintptr_t>(Value & ~7ULL);
} }
explicit VTableComponent(uint64_t Value) explicit VTableComponent(uint64_t Value)
: Value(Value) { } : Value(Value) { }
@ -210,7 +210,7 @@ private:
/// VTableThunks - Contains thunks needed by vtables. /// VTableThunks - Contains thunks needed by vtables.
uint64_t NumVTableThunks; uint64_t NumVTableThunks;
VTableThunkTy *VTableThunks; VTableThunkTy *VTableThunks;
/// Address points - Address points for all vtables. /// Address points - Address points for all vtables.
AddressPointsMapTy AddressPoints; AddressPointsMapTy AddressPoints;
@ -265,10 +265,10 @@ class VTableContext {
ASTContext &Context; ASTContext &Context;
public: public:
typedef SmallVector<std::pair<uint64_t, ThunkInfo>, 1> typedef SmallVector<std::pair<uint64_t, ThunkInfo>, 1>
VTableThunksTy; VTableThunksTy;
typedef SmallVector<ThunkInfo, 1> ThunkInfoVectorTy; typedef SmallVector<ThunkInfo, 1> ThunkInfoVectorTy;
private: private:
/// MethodVTableIndices - Contains the index (relative to the vtable address /// MethodVTableIndices - Contains the index (relative to the vtable address
/// point) where the function pointer for a virtual function is stored. /// point) where the function pointer for a virtual function is stored.
@ -279,22 +279,22 @@ private:
VTableLayoutMapTy; VTableLayoutMapTy;
VTableLayoutMapTy VTableLayouts; VTableLayoutMapTy VTableLayouts;
/// NumVirtualFunctionPointers - Contains the number of virtual function /// NumVirtualFunctionPointers - Contains the number of virtual function
/// pointers in the vtable for a given record decl. /// pointers in the vtable for a given record decl.
llvm::DenseMap<const CXXRecordDecl *, uint64_t> NumVirtualFunctionPointers; llvm::DenseMap<const CXXRecordDecl *, uint64_t> NumVirtualFunctionPointers;
typedef std::pair<const CXXRecordDecl *, typedef std::pair<const CXXRecordDecl *,
const CXXRecordDecl *> ClassPairTy; const CXXRecordDecl *> ClassPairTy;
/// VirtualBaseClassOffsetOffsets - Contains the vtable offset (relative to /// VirtualBaseClassOffsetOffsets - Contains the vtable offset (relative to
/// the address point) in chars where the offsets for virtual bases of a class /// the address point) in chars where the offsets for virtual bases of a class
/// are stored. /// are stored.
typedef llvm::DenseMap<ClassPairTy, CharUnits> typedef llvm::DenseMap<ClassPairTy, CharUnits>
VirtualBaseClassOffsetOffsetsMapTy; VirtualBaseClassOffsetOffsetsMapTy;
VirtualBaseClassOffsetOffsetsMapTy VirtualBaseClassOffsetOffsets; VirtualBaseClassOffsetOffsetsMapTy VirtualBaseClassOffsetOffsets;
typedef llvm::DenseMap<const CXXMethodDecl *, ThunkInfoVectorTy> ThunksMapTy; typedef llvm::DenseMap<const CXXMethodDecl *, ThunkInfoVectorTy> ThunksMapTy;
/// Thunks - Contains all thunks that a given method decl will need. /// Thunks - Contains all thunks that a given method decl will need.
ThunksMapTy Thunks; ThunksMapTy Thunks;
@ -312,7 +312,7 @@ public:
const VTableLayout &getVTableLayout(const CXXRecordDecl *RD) { const VTableLayout &getVTableLayout(const CXXRecordDecl *RD) {
ComputeVTableRelatedInformation(RD); ComputeVTableRelatedInformation(RD);
assert(VTableLayouts.count(RD) && "No layout for this record decl!"); assert(VTableLayouts.count(RD) && "No layout for this record decl!");
return *VTableLayouts[RD]; return *VTableLayouts[RD];
} }
@ -337,14 +337,14 @@ public:
/// getNumVirtualFunctionPointers - Return the number of virtual function /// getNumVirtualFunctionPointers - Return the number of virtual function
/// pointers in the vtable for a given record decl. /// pointers in the vtable for a given record decl.
uint64_t getNumVirtualFunctionPointers(const CXXRecordDecl *RD); uint64_t getNumVirtualFunctionPointers(const CXXRecordDecl *RD);
/// getMethodVTableIndex - Return the index (relative to the vtable address /// getMethodVTableIndex - Return the index (relative to the vtable address
/// point) where the function pointer for the given virtual function is /// point) where the function pointer for the given virtual function is
/// stored. /// stored.
uint64_t getMethodVTableIndex(GlobalDecl GD); uint64_t getMethodVTableIndex(GlobalDecl GD);
/// getVirtualBaseOffsetOffset - Return the offset in chars (relative to the /// getVirtualBaseOffsetOffset - Return the offset in chars (relative to the
/// vtable address point) where the offset of the virtual base that contains /// vtable address point) where the offset of the virtual base that contains
/// the given base is stored, otherwise, if no virtual base contains the given /// the given base is stored, otherwise, if no virtual base contains the given
/// class, return 0. Base must be a virtual base class or an unambigious /// class, return 0. Base must be a virtual base class or an unambigious
/// base. /// base.

View File

@ -7,7 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements a simple, fast dominance algorithm for source-level CFGs. // This file implements a simple, fast dominance algorithm for source-level
// CFGs.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -27,7 +28,7 @@ class DominatorTree : public ManagedAnalysis {
typedef llvm::DenseMap<const CFGBlock *, CFGBlock*> CFGBlockMapTy; typedef llvm::DenseMap<const CFGBlock *, CFGBlock*> CFGBlockMapTy;
public: public:
DominatorTree(AnalysisDeclContext &ac) DominatorTree(AnalysisDeclContext &ac)
: AC(ac) {} : AC(ac) {}
virtual ~DominatorTree(); virtual ~DominatorTree();
@ -50,7 +51,7 @@ public:
/// Find nearest common dominator for blocks A and B. /// Find nearest common dominator for blocks A and B.
/// Common dominator always exists, ex: entry block. /// Common dominator always exists, ex: entry block.
const CFGBlock *findNearestCommonDominator(const CFGBlock *A, const CFGBlock *findNearestCommonDominator(const CFGBlock *A,
const CFGBlock *B) const; const CFGBlock *B) const;
/// Constructs immediate dominator tree for a given CFG based on the algorithm /// Constructs immediate dominator tree for a given CFG based on the algorithm
@ -61,7 +62,7 @@ public:
/// Software-Practice and Expreience, 2001;4:1-10. /// Software-Practice and Expreience, 2001;4:1-10.
/// ///
/// This implementation is simple and runs faster in practice than the classis /// This implementation is simple and runs faster in practice than the classis
/// Lengauer-Tarjan algorithm. For detailed discussions, refer to the paper. /// Lengauer-Tarjan algorithm. For detailed discussions, refer to the paper.
void BuildDominatorTree(); void BuildDominatorTree();
/// Dump the immediate dominance tree /// Dump the immediate dominance tree

View File

@ -104,7 +104,7 @@ private:
const char *Position; const char *Position;
Kind kind; Kind kind;
}; };
class ConversionSpecifier { class ConversionSpecifier {
public: public:
enum Kind { enum Kind {
@ -113,14 +113,14 @@ public:
cArg, cArg,
dArg, dArg,
iArg, iArg,
IntArgBeg = cArg, IntArgEnd = iArg, IntArgBeg = cArg, IntArgEnd = iArg,
oArg, oArg,
uArg, uArg,
xArg, xArg,
XArg, XArg,
UIntArgBeg = oArg, UIntArgEnd = XArg, UIntArgBeg = oArg, UIntArgEnd = XArg,
fArg, fArg,
FArg, FArg,
eArg, eArg,
@ -130,44 +130,44 @@ public:
aArg, aArg,
AArg, AArg,
DoubleArgBeg = fArg, DoubleArgEnd = AArg, DoubleArgBeg = fArg, DoubleArgEnd = AArg,
sArg, sArg,
pArg, pArg,
nArg, nArg,
PercentArg, PercentArg,
CArg, CArg,
SArg, SArg,
// ** Printf-specific ** // ** Printf-specific **
// Objective-C specific specifiers. // Objective-C specific specifiers.
ObjCObjArg, // '@' ObjCObjArg, // '@'
ObjCBeg = ObjCObjArg, ObjCEnd = ObjCObjArg, ObjCBeg = ObjCObjArg, ObjCEnd = ObjCObjArg,
// GlibC specific specifiers. // GlibC specific specifiers.
PrintErrno, // 'm' PrintErrno, // 'm'
PrintfConvBeg = ObjCObjArg, PrintfConvEnd = PrintErrno, PrintfConvBeg = ObjCObjArg, PrintfConvEnd = PrintErrno,
// ** Scanf-specific ** // ** Scanf-specific **
ScanListArg, // '[' ScanListArg, // '['
ScanfConvBeg = ScanListArg, ScanfConvEnd = ScanListArg ScanfConvBeg = ScanListArg, ScanfConvEnd = ScanListArg
}; };
ConversionSpecifier(bool isPrintf) ConversionSpecifier(bool isPrintf)
: IsPrintf(isPrintf), Position(0), EndScanList(0), kind(InvalidSpecifier) {} : IsPrintf(isPrintf), Position(0), EndScanList(0), kind(InvalidSpecifier) {}
ConversionSpecifier(bool isPrintf, const char *pos, Kind k) ConversionSpecifier(bool isPrintf, const char *pos, Kind k)
: IsPrintf(isPrintf), Position(pos), EndScanList(0), kind(k) {} : IsPrintf(isPrintf), Position(pos), EndScanList(0), kind(k) {}
const char *getStart() const { const char *getStart() const {
return Position; return Position;
} }
StringRef getCharacters() const { StringRef getCharacters() const {
return StringRef(getStart(), getLength()); return StringRef(getStart(), getLength());
} }
bool consumesDataArgument() const { bool consumesDataArgument() const {
switch (kind) { switch (kind) {
case PrintErrno: case PrintErrno:
@ -178,15 +178,15 @@ public:
return true; return true;
} }
} }
Kind getKind() const { return kind; } Kind getKind() const { return kind; }
void setKind(Kind k) { kind = k; } void setKind(Kind k) { kind = k; }
unsigned getLength() const { unsigned getLength() const {
return EndScanList ? EndScanList - Position : 1; return EndScanList ? EndScanList - Position : 1;
} }
const char *toString() const; const char *toString() const;
bool isPrintfKind() const { return IsPrintf; } bool isPrintfKind() const { return IsPrintf; }
protected: protected:
@ -337,7 +337,7 @@ public:
} }
bool usesPositionalArg() const { return UsesPositionalArg; } bool usesPositionalArg() const { return UsesPositionalArg; }
bool hasValidLengthModifier() const; bool hasValidLengthModifier() const;
}; };
@ -348,7 +348,7 @@ public:
namespace analyze_printf { namespace analyze_printf {
class PrintfConversionSpecifier : class PrintfConversionSpecifier :
public analyze_format_string::ConversionSpecifier { public analyze_format_string::ConversionSpecifier {
public: public:
PrintfConversionSpecifier() PrintfConversionSpecifier()
@ -360,7 +360,7 @@ public:
bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; } bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; }
bool isIntArg() const { return kind >= IntArgBeg && kind <= IntArgEnd; } bool isIntArg() const { return kind >= IntArgBeg && kind <= IntArgEnd; }
bool isUIntArg() const { return kind >= UIntArgBeg && kind <= UIntArgEnd; } bool isUIntArg() const { return kind >= UIntArgBeg && kind <= UIntArgEnd; }
bool isDoubleArg() const { return kind >= DoubleArgBeg && bool isDoubleArg() const { return kind >= DoubleArgBeg &&
kind <= DoubleArgBeg; } kind <= DoubleArgBeg; }
unsigned getLength() const { unsigned getLength() const {
// Conversion specifiers currently only are represented by // Conversion specifiers currently only are represented by
@ -438,7 +438,7 @@ public:
const OptionalAmount &getPrecision() const { const OptionalAmount &getPrecision() const {
return Precision; return Precision;
} }
bool consumesDataArgument() const { bool consumesDataArgument() const {
return getConversionSpecifier().consumesDataArgument(); return getConversionSpecifier().consumesDataArgument();
} }
@ -450,7 +450,7 @@ public:
/// more than one type. /// more than one type.
ArgTypeResult getArgType(ASTContext &Ctx) const; ArgTypeResult getArgType(ASTContext &Ctx) const;
const OptionalFlag &hasThousandsGrouping() const { const OptionalFlag &hasThousandsGrouping() const {
return HasThousandsGrouping; return HasThousandsGrouping;
} }
const OptionalFlag &isLeftJustified() const { return IsLeftJustified; } const OptionalFlag &isLeftJustified() const { return IsLeftJustified; }
@ -467,7 +467,7 @@ public:
void toString(raw_ostream &os) const; void toString(raw_ostream &os) const;
// Validation methods - to check if any element results in undefined behavior // Validation methods - to check if any element results in undefined behavior
bool hasValidPlusPrefix() const; bool hasValidPlusPrefix() const;
bool hasValidAlternativeForm() const; bool hasValidAlternativeForm() const;
bool hasValidLeadingZeros() const; bool hasValidLeadingZeros() const;
@ -495,10 +495,10 @@ public:
: ConversionSpecifier(false, pos, k) {} : ConversionSpecifier(false, pos, k) {}
void setEndScanList(const char *pos) { EndScanList = pos; } void setEndScanList(const char *pos) { EndScanList = pos; }
static bool classof(const analyze_format_string::ConversionSpecifier *CS) { static bool classof(const analyze_format_string::ConversionSpecifier *CS) {
return !CS->isPrintfKind(); return !CS->isPrintfKind();
} }
}; };
using analyze_format_string::LengthModifier; using analyze_format_string::LengthModifier;
@ -528,7 +528,7 @@ public:
const ScanfConversionSpecifier &getConversionSpecifier() const { const ScanfConversionSpecifier &getConversionSpecifier() const {
return cast<ScanfConversionSpecifier>(CS); return cast<ScanfConversionSpecifier>(CS);
} }
bool consumesDataArgument() const { bool consumesDataArgument() const {
return CS.consumesDataArgument() && !SuppressAssignment; return CS.consumesDataArgument() && !SuppressAssignment;
} }

View File

@ -25,15 +25,15 @@
#include "clang/Analysis/CFG.h" #include "clang/Analysis/CFG.h"
namespace clang { namespace clang {
class PostOrderCFGView : public ManagedAnalysis { class PostOrderCFGView : public ManagedAnalysis {
public: public:
/// \brief Implements a set of CFGBlocks using a BitVector. /// \brief Implements a set of CFGBlocks using a BitVector.
/// ///
/// This class contains a minimal interface, primarily dictated by the SetType /// This class contains a minimal interface, primarily dictated by the SetType
/// template parameter of the llvm::po_iterator template, as used with external /// template parameter of the llvm::po_iterator template, as used with
/// storage. We also use this set to keep track of which CFGBlocks we visit /// external storage. We also use this set to keep track of which CFGBlocks we
/// during the analysis. /// visit during the analysis.
class CFGBlockSet { class CFGBlockSet {
llvm::BitVector VisitedBlockIDs; llvm::BitVector VisitedBlockIDs;
public: public:
@ -47,8 +47,8 @@ public:
/// \brief Set the bit associated with a particular CFGBlock. /// \brief Set the bit associated with a particular CFGBlock.
/// This is the important method for the SetType template parameter. /// This is the important method for the SetType template parameter.
bool insert(const CFGBlock *Block) { bool insert(const CFGBlock *Block) {
// Note that insert() is called by po_iterator, which doesn't check to make // Note that insert() is called by po_iterator, which doesn't check to
// sure that Block is non-null. Moreover, the CFGBlock iterator will // make sure that Block is non-null. Moreover, the CFGBlock iterator will
// occasionally hand out null pointers for pruned edges, so we catch those // occasionally hand out null pointers for pruned edges, so we catch those
// here. // here.
if (Block == 0) if (Block == 0)
@ -60,30 +60,30 @@ public:
} }
/// \brief Check if the bit for a CFGBlock has been already set. /// \brief Check if the bit for a CFGBlock has been already set.
/// This method is for tracking visited blocks in the main threadsafety loop. /// This method is for tracking visited blocks in the main threadsafety
/// Block must not be null. /// loop. Block must not be null.
bool alreadySet(const CFGBlock *Block) { bool alreadySet(const CFGBlock *Block) {
return VisitedBlockIDs.test(Block->getBlockID()); return VisitedBlockIDs.test(Block->getBlockID());
} }
}; };
private: private:
typedef llvm::po_iterator<const CFG*, CFGBlockSet, true> po_iterator; typedef llvm::po_iterator<const CFG*, CFGBlockSet, true> po_iterator;
std::vector<const CFGBlock*> Blocks; std::vector<const CFGBlock*> Blocks;
typedef llvm::DenseMap<const CFGBlock *, unsigned> BlockOrderTy; typedef llvm::DenseMap<const CFGBlock *, unsigned> BlockOrderTy;
BlockOrderTy BlockOrder; BlockOrderTy BlockOrder;
public: public:
typedef std::vector<const CFGBlock*>::reverse_iterator iterator; typedef std::vector<const CFGBlock*>::reverse_iterator iterator;
PostOrderCFGView(const CFG *cfg); PostOrderCFGView(const CFG *cfg);
iterator begin() { return Blocks.rbegin(); } iterator begin() { return Blocks.rbegin(); }
iterator end() { return Blocks.rend(); } iterator end() { return Blocks.rend(); }
bool empty() { return begin() == end(); } bool empty() { return begin() == end(); }
struct BlockOrderCompare; struct BlockOrderCompare;
friend struct BlockOrderCompare; friend struct BlockOrderCompare;
@ -91,9 +91,9 @@ public:
const PostOrderCFGView &POV; const PostOrderCFGView &POV;
public: public:
BlockOrderCompare(const PostOrderCFGView &pov) : POV(pov) {} BlockOrderCompare(const PostOrderCFGView &pov) : POV(pov) {}
bool operator()(const CFGBlock *b1, const CFGBlock *b2) const; bool operator()(const CFGBlock *b1, const CFGBlock *b2) const;
}; };
BlockOrderCompare getComparator() const { BlockOrderCompare getComparator() const {
return BlockOrderCompare(*this); return BlockOrderCompare(*this);
} }
@ -103,7 +103,7 @@ public:
static PostOrderCFGView *create(AnalysisDeclContext &analysisContext); static PostOrderCFGView *create(AnalysisDeclContext &analysisContext);
}; };
} // end clang namespace } // end clang namespace
#endif #endif

View File

@ -93,7 +93,8 @@ public:
/// 3. or when a mutex is locked but not unlocked inside a function. /// 3. or when a mutex is locked but not unlocked inside a function.
/// \param LockName -- A StringRef name for the lock expression, to be printed /// \param LockName -- A StringRef name for the lock expression, to be printed
/// in the error message. /// in the error message.
/// \param Loc -- The location of the lock expression where the mutex is locked /// \param Loc -- The location of the lock expression where the mutex is
/// locked
/// \param LEK -- which of the three above cases we should warn for /// \param LEK -- which of the three above cases we should warn for
virtual void handleMutexHeldEndOfScope(Name LockName, SourceLocation Loc, virtual void handleMutexHeldEndOfScope(Name LockName, SourceLocation Loc,
LockErrorKind LEK){} LockErrorKind LEK){}
@ -143,7 +144,8 @@ public:
/// We traverse the blocks in the CFG, compute the set of mutexes that are held /// We traverse the blocks in the CFG, compute the set of mutexes that are held
/// at the end of each block, and issue warnings for thread safety violations. /// at the end of each block, and issue warnings for thread safety violations.
/// Each block in the CFG is traversed exactly once. /// Each block in the CFG is traversed exactly once.
void runThreadSafetyAnalysis(AnalysisDeclContext &AC, ThreadSafetyHandler &Handler); void runThreadSafetyAnalysis(AnalysisDeclContext &AC,
ThreadSafetyHandler &Handler);
/// \brief Helper function that returns a LockKind required for the given level /// \brief Helper function that returns a LockKind required for the given level
/// of access. /// of access.

View File

@ -1,4 +1,4 @@
//= UninitializedValues.h - Finding uses of uninitialized values --*- C++ -*-==// //= UninitializedValues.h - Finding uses of uninitialized values -*- C++ -*-==//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -18,11 +18,11 @@
namespace clang { namespace clang {
class AnalysisDeclContext; class AnalysisDeclContext;
class CFG; class CFG;
class DeclContext; class DeclContext;
class Expr; class Expr;
class VarDecl; class VarDecl;
class UninitVariablesHandler { class UninitVariablesHandler {
public: public:
UninitVariablesHandler() {} UninitVariablesHandler() {}
@ -32,7 +32,7 @@ public:
virtual void handleUseOfUninitVariable(const Expr *ex, virtual void handleUseOfUninitVariable(const Expr *ex,
const VarDecl *vd, const VarDecl *vd,
bool isAlwaysUninit) {} bool isAlwaysUninit) {}
/// Called when the uninitialized variable analysis detects the /// Called when the uninitialized variable analysis detects the
/// idiom 'int x = x'. All other uses of 'x' within the initializer /// idiom 'int x = x'. All other uses of 'x' within the initializer
/// are handled by handleUseOfUninitVariable. /// are handled by handleUseOfUninitVariable.

View File

@ -7,8 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines AnalysisDeclContext, a class that manages the analysis context // This file defines AnalysisDeclContext, a class that manages the analysis
// data for path sensitive analysis. // context data for path sensitive analysis.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -39,7 +39,7 @@ class ImplicitParamDecl;
class LocationContextManager; class LocationContextManager;
class StackFrameContext; class StackFrameContext;
class AnalysisDeclContextManager; class AnalysisDeclContextManager;
class LocationContext; class LocationContext;
namespace idx { class TranslationUnit; } namespace idx { class TranslationUnit; }
@ -50,7 +50,7 @@ protected:
ManagedAnalysis() {} ManagedAnalysis() {}
public: public:
virtual ~ManagedAnalysis(); virtual ~ManagedAnalysis();
// Subclasses need to implement: // Subclasses need to implement:
// //
// static const void *getTag(); // static const void *getTag();
@ -62,15 +62,15 @@ public:
// //
// which creates the analysis object given an AnalysisDeclContext. // which creates the analysis object given an AnalysisDeclContext.
}; };
/// AnalysisDeclContext contains the context data for the function or method under /// AnalysisDeclContext contains the context data for the function or method
/// analysis. /// under analysis.
class AnalysisDeclContext { class AnalysisDeclContext {
/// Backpoint to the AnalysisManager object that created this AnalysisDeclContext. /// Backpoint to the AnalysisManager object that created this
/// This may be null. /// AnalysisDeclContext. This may be null.
AnalysisDeclContextManager *Manager; AnalysisDeclContextManager *Manager;
const Decl *D; const Decl *D;
// TranslationUnit is NULL if we don't have multiple translation units. // TranslationUnit is NULL if we don't have multiple translation units.
@ -81,7 +81,7 @@ class AnalysisDeclContext {
CFG::BuildOptions cfgBuildOptions; CFG::BuildOptions cfgBuildOptions;
CFG::BuildOptions::ForcedBlkExprs *forcedBlkExprs; CFG::BuildOptions::ForcedBlkExprs *forcedBlkExprs;
bool builtCFG, builtCompleteCFG; bool builtCFG, builtCompleteCFG;
llvm::OwningPtr<LiveVariables> liveness; llvm::OwningPtr<LiveVariables> liveness;
@ -122,12 +122,12 @@ public:
const CFG::BuildOptions &getCFGBuildOptions() const { const CFG::BuildOptions &getCFGBuildOptions() const {
return cfgBuildOptions; return cfgBuildOptions;
} }
/// getAddEHEdges - Return true iff we are adding exceptional edges from /// getAddEHEdges - Return true iff we are adding exceptional edges from
/// callExprs. If this is false, then try/catch statements and blocks /// callExprs. If this is false, then try/catch statements and blocks
/// reachable from them can appear to be dead in the CFG, analysis passes must /// reachable from them can appear to be dead in the CFG, analysis passes must
/// cope with that. /// cope with that.
bool getAddEHEdges() const { return cfgBuildOptions.AddEHEdges; } bool getAddEHEdges() const { return cfgBuildOptions.AddEHEdges; }
bool getUseUnoptimizedCFG() const { bool getUseUnoptimizedCFG() const {
return !cfgBuildOptions.PruneTriviallyFalseEdges; return !cfgBuildOptions.PruneTriviallyFalseEdges;
} }
@ -136,14 +136,14 @@ public:
void registerForcedBlockExpression(const Stmt *stmt); void registerForcedBlockExpression(const Stmt *stmt);
const CFGBlock *getBlockForRegisteredExpression(const Stmt *stmt); const CFGBlock *getBlockForRegisteredExpression(const Stmt *stmt);
Stmt *getBody() const; Stmt *getBody() const;
CFG *getCFG(); CFG *getCFG();
CFGStmtMap *getCFGStmtMap(); CFGStmtMap *getCFGStmtMap();
CFGReverseBlockReachabilityAnalysis *getCFGReachablityAnalysis(); CFGReverseBlockReachabilityAnalysis *getCFGReachablityAnalysis();
/// Return a version of the CFG without any edges pruned. /// Return a version of the CFG without any edges pruned.
CFG *getUnoptimizedCFG(); CFG *getUnoptimizedCFG();
@ -165,12 +165,12 @@ public:
/// Return the ImplicitParamDecl* associated with 'self' if this /// Return the ImplicitParamDecl* associated with 'self' if this
/// AnalysisDeclContext wraps an ObjCMethodDecl. Returns NULL otherwise. /// AnalysisDeclContext wraps an ObjCMethodDecl. Returns NULL otherwise.
const ImplicitParamDecl *getSelfDecl() const; const ImplicitParamDecl *getSelfDecl() const;
const StackFrameContext *getStackFrame(LocationContext const *Parent, const StackFrameContext *getStackFrame(LocationContext const *Parent,
const Stmt *S, const Stmt *S,
const CFGBlock *Blk, const CFGBlock *Blk,
unsigned Idx); unsigned Idx);
/// Return the specified analysis object, lazily running the analysis if /// Return the specified analysis object, lazily running the analysis if
/// necessary. Return NULL if the analysis could not run. /// necessary. Return NULL if the analysis could not run.
template <typename T> template <typename T>
@ -184,7 +184,7 @@ public:
} }
private: private:
ManagedAnalysis *&getAnalysisImpl(const void* tag); ManagedAnalysis *&getAnalysisImpl(const void* tag);
LocationContextManager &getLocationContextManager(); LocationContextManager &getLocationContextManager();
}; };
@ -195,7 +195,8 @@ public:
private: private:
ContextKind Kind; ContextKind Kind;
// AnalysisDeclContext can't be const since some methods may modify its member. // AnalysisDeclContext can't be const since some methods may modify its
// member.
AnalysisDeclContext *Ctx; AnalysisDeclContext *Ctx;
const LocationContext *Parent; const LocationContext *Parent;
@ -212,8 +213,8 @@ public:
AnalysisDeclContext *getAnalysisDeclContext() const { return Ctx; } AnalysisDeclContext *getAnalysisDeclContext() const { return Ctx; }
idx::TranslationUnit *getTranslationUnit() const { idx::TranslationUnit *getTranslationUnit() const {
return Ctx->getTranslationUnit(); return Ctx->getTranslationUnit();
} }
const LocationContext *getParent() const { return Parent; } const LocationContext *getParent() const { return Parent; }
@ -265,7 +266,7 @@ class StackFrameContext : public LocationContext {
friend class LocationContextManager; friend class LocationContextManager;
StackFrameContext(AnalysisDeclContext *ctx, const LocationContext *parent, StackFrameContext(AnalysisDeclContext *ctx, const LocationContext *parent,
const Stmt *s, const CFGBlock *blk, const Stmt *s, const CFGBlock *blk,
unsigned idx) unsigned idx)
: LocationContext(StackFrame, ctx, parent), CallSite(s), : LocationContext(StackFrame, ctx, parent), CallSite(s),
Block(blk), Index(idx) {} Block(blk), Index(idx) {}
@ -324,7 +325,8 @@ class BlockInvocationContext : public LocationContext {
friend class LocationContextManager; friend class LocationContextManager;
BlockInvocationContext(AnalysisDeclContext *ctx, const LocationContext *parent, BlockInvocationContext(AnalysisDeclContext *ctx,
const LocationContext *parent,
const BlockDecl *bd) const BlockDecl *bd)
: LocationContext(Block, ctx, parent), BD(bd) {} : LocationContext(Block, ctx, parent), BD(bd) {}
@ -370,28 +372,28 @@ private:
class AnalysisDeclContextManager { class AnalysisDeclContextManager {
typedef llvm::DenseMap<const Decl*, AnalysisDeclContext*> ContextMap; typedef llvm::DenseMap<const Decl*, AnalysisDeclContext*> ContextMap;
ContextMap Contexts; ContextMap Contexts;
LocationContextManager LocContexts; LocationContextManager LocContexts;
CFG::BuildOptions cfgBuildOptions; CFG::BuildOptions cfgBuildOptions;
public: public:
AnalysisDeclContextManager(bool useUnoptimizedCFG = false, AnalysisDeclContextManager(bool useUnoptimizedCFG = false,
bool addImplicitDtors = false, bool addImplicitDtors = false,
bool addInitializers = false); bool addInitializers = false);
~AnalysisDeclContextManager(); ~AnalysisDeclContextManager();
AnalysisDeclContext *getContext(const Decl *D, idx::TranslationUnit *TU = 0); AnalysisDeclContext *getContext(const Decl *D, idx::TranslationUnit *TU = 0);
bool getUseUnoptimizedCFG() const { bool getUseUnoptimizedCFG() const {
return !cfgBuildOptions.PruneTriviallyFalseEdges; return !cfgBuildOptions.PruneTriviallyFalseEdges;
} }
CFG::BuildOptions &getCFGBuildOptions() { CFG::BuildOptions &getCFGBuildOptions() {
return cfgBuildOptions; return cfgBuildOptions;
} }
const StackFrameContext *getStackFrame(AnalysisDeclContext *Ctx, const StackFrameContext *getStackFrame(AnalysisDeclContext *Ctx,
LocationContext const *Parent, LocationContext const *Parent,
const Stmt *S, const Stmt *S,
@ -399,15 +401,15 @@ public:
unsigned Idx) { unsigned Idx) {
return LocContexts.getStackFrame(Ctx, Parent, S, Blk, Idx); return LocContexts.getStackFrame(Ctx, Parent, S, Blk, Idx);
} }
// Get the top level stack frame. // Get the top level stack frame.
const StackFrameContext *getStackFrame(Decl const *D, const StackFrameContext *getStackFrame(Decl const *D,
idx::TranslationUnit *TU) { idx::TranslationUnit *TU) {
return LocContexts.getStackFrame(getContext(D, TU), 0, 0, 0, 0); return LocContexts.getStackFrame(getContext(D, TU), 0, 0, 0, 0);
} }
// Get a stack frame with parent. // Get a stack frame with parent.
StackFrameContext const *getStackFrame(const Decl *D, StackFrameContext const *getStackFrame(const Decl *D,
LocationContext const *Parent, LocationContext const *Parent,
const Stmt *S, const Stmt *S,
const CFGBlock *Blk, const CFGBlock *Blk,
@ -415,7 +417,7 @@ public:
return LocContexts.getStackFrame(getContext(D), Parent, S, Blk, Idx); return LocContexts.getStackFrame(getContext(D), Parent, S, Blk, Idx);
} }
/// Discard all previously created AnalysisDeclContexts. /// Discard all previously created AnalysisDeclContexts.
void clear(); void clear();

View File

@ -67,22 +67,22 @@ protected:
CFGElement(Kind kind, const void *Ptr1, const void *Ptr2 = 0) CFGElement(Kind kind, const void *Ptr1, const void *Ptr2 = 0)
: Data1(const_cast<void*>(Ptr1), ((unsigned) kind) & 0x3), : Data1(const_cast<void*>(Ptr1), ((unsigned) kind) & 0x3),
Data2(const_cast<void*>(Ptr2), (((unsigned) kind) >> 2) & 0x3) {} Data2(const_cast<void*>(Ptr2), (((unsigned) kind) >> 2) & 0x3) {}
public: public:
CFGElement() {} CFGElement() {}
Kind getKind() const { Kind getKind() const {
unsigned x = Data2.getInt(); unsigned x = Data2.getInt();
x <<= 2; x <<= 2;
x |= Data1.getInt(); x |= Data1.getInt();
return (Kind) x; return (Kind) x;
} }
bool isValid() const { return getKind() != Invalid; } bool isValid() const { return getKind() != Invalid; }
operator bool() const { return isValid(); } operator bool() const { return isValid(); }
template<class ElemTy> const ElemTy *getAs() const { template<class ElemTy> const ElemTy *getAs() const {
if (llvm::isa<ElemTy>(this)) if (llvm::isa<ElemTy>(this))
return static_cast<const ElemTy*>(this); return static_cast<const ElemTy*>(this);
@ -96,7 +96,7 @@ class CFGStmt : public CFGElement {
public: public:
CFGStmt(Stmt *S) : CFGElement(Statement, S) {} CFGStmt(Stmt *S) : CFGElement(Statement, S) {}
const Stmt *getStmt() const { const Stmt *getStmt() const {
return static_cast<const Stmt *>(Data1.getPointer()); return static_cast<const Stmt *>(Data1.getPointer());
} }
@ -125,9 +125,9 @@ public:
/// by compiler on various occasions. /// by compiler on various occasions.
class CFGImplicitDtor : public CFGElement { class CFGImplicitDtor : public CFGElement {
protected: protected:
CFGImplicitDtor(Kind kind, const void *data1, const void *data2 = 0) CFGImplicitDtor(Kind kind, const void *data1, const void *data2 = 0)
: CFGElement(kind, data1, data2) { : CFGElement(kind, data1, data2) {
assert(kind >= DTOR_BEGIN && kind <= DTOR_END); assert(kind >= DTOR_BEGIN && kind <= DTOR_END);
} }
public: public:
@ -272,12 +272,12 @@ class CFGBlock {
ImplTy Impl; ImplTy Impl;
public: public:
ElementList(BumpVectorContext &C) : Impl(C, 4) {} ElementList(BumpVectorContext &C) : Impl(C, 4) {}
typedef std::reverse_iterator<ImplTy::iterator> iterator; typedef std::reverse_iterator<ImplTy::iterator> iterator;
typedef std::reverse_iterator<ImplTy::const_iterator> const_iterator; typedef std::reverse_iterator<ImplTy::const_iterator> const_iterator;
typedef ImplTy::iterator reverse_iterator; typedef ImplTy::iterator reverse_iterator;
typedef ImplTy::const_iterator const_reverse_iterator; typedef ImplTy::const_iterator const_reverse_iterator;
void push_back(CFGElement e, BumpVectorContext &C) { Impl.push_back(e, C); } void push_back(CFGElement e, BumpVectorContext &C) { Impl.push_back(e, C); }
reverse_iterator insert(reverse_iterator I, size_t Cnt, CFGElement E, reverse_iterator insert(reverse_iterator I, size_t Cnt, CFGElement E,
BumpVectorContext &C) { BumpVectorContext &C) {
@ -286,7 +286,7 @@ class CFGBlock {
CFGElement front() const { return Impl.back(); } CFGElement front() const { return Impl.back(); }
CFGElement back() const { return Impl.front(); } CFGElement back() const { return Impl.front(); }
iterator begin() { return Impl.rbegin(); } iterator begin() { return Impl.rbegin(); }
iterator end() { return Impl.rend(); } iterator end() { return Impl.rend(); }
const_iterator begin() const { return Impl.rbegin(); } const_iterator begin() const { return Impl.rbegin(); }
@ -300,7 +300,7 @@ class CFGBlock {
assert(i < Impl.size()); assert(i < Impl.size());
return Impl[Impl.size() - 1 - i]; return Impl[Impl.size() - 1 - i];
} }
size_t size() const { return Impl.size(); } size_t size() const { return Impl.size(); }
bool empty() const { return Impl.empty(); } bool empty() const { return Impl.empty(); }
}; };
@ -492,13 +492,13 @@ public:
void dump(const CFG *cfg, const LangOptions &LO) const; void dump(const CFG *cfg, const LangOptions &LO) const;
void print(raw_ostream &OS, const CFG* cfg, const LangOptions &LO) const; void print(raw_ostream &OS, const CFG* cfg, const LangOptions &LO) const;
void printTerminator(raw_ostream &OS, const LangOptions &LO) const; void printTerminator(raw_ostream &OS, const LangOptions &LO) const;
void addSuccessor(CFGBlock *Block, BumpVectorContext &C) { void addSuccessor(CFGBlock *Block, BumpVectorContext &C) {
if (Block) if (Block)
Block->Preds.push_back(this, C); Block->Preds.push_back(this, C);
Succs.push_back(Block, C); Succs.push_back(Block, C);
} }
void appendStmt(Stmt *statement, BumpVectorContext &C) { void appendStmt(Stmt *statement, BumpVectorContext &C) {
Elements.push_back(CFGStmt(statement), C); Elements.push_back(CFGStmt(statement), C);
} }
@ -515,7 +515,7 @@ public:
void appendMemberDtor(FieldDecl *FD, BumpVectorContext &C) { void appendMemberDtor(FieldDecl *FD, BumpVectorContext &C) {
Elements.push_back(CFGMemberDtor(FD), C); Elements.push_back(CFGMemberDtor(FD), C);
} }
void appendTemporaryDtor(CXXBindTemporaryExpr *E, BumpVectorContext &C) { void appendTemporaryDtor(CXXBindTemporaryExpr *E, BumpVectorContext &C) {
Elements.push_back(CFGTemporaryDtor(E), C); Elements.push_back(CFGTemporaryDtor(E), C);
} }
@ -554,22 +554,22 @@ public:
llvm::BitVector alwaysAddMask; llvm::BitVector alwaysAddMask;
public: public:
typedef llvm::DenseMap<const Stmt *, const CFGBlock*> ForcedBlkExprs; typedef llvm::DenseMap<const Stmt *, const CFGBlock*> ForcedBlkExprs;
ForcedBlkExprs **forcedBlkExprs; ForcedBlkExprs **forcedBlkExprs;
bool PruneTriviallyFalseEdges; bool PruneTriviallyFalseEdges;
bool AddEHEdges; bool AddEHEdges;
bool AddInitializers; bool AddInitializers;
bool AddImplicitDtors; bool AddImplicitDtors;
bool alwaysAdd(const Stmt *stmt) const { bool alwaysAdd(const Stmt *stmt) const {
return alwaysAddMask[stmt->getStmtClass()]; return alwaysAddMask[stmt->getStmtClass()];
} }
BuildOptions &setAlwaysAdd(Stmt::StmtClass stmtClass, bool val = true) { BuildOptions &setAlwaysAdd(Stmt::StmtClass stmtClass, bool val = true) {
alwaysAddMask[stmtClass] = val; alwaysAddMask[stmtClass] = val;
return *this; return *this;
} }
BuildOptions &setAllAlwaysAdd() { BuildOptions &setAllAlwaysAdd() {
alwaysAddMask.set(); alwaysAddMask.set();
return *this; return *this;
@ -605,7 +605,7 @@ public:
// Block Iterators // Block Iterators
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
typedef BumpVector<CFGBlock*> CFGBlockListTy; typedef BumpVector<CFGBlock*> CFGBlockListTy;
typedef CFGBlockListTy::iterator iterator; typedef CFGBlockListTy::iterator iterator;
typedef CFGBlockListTy::const_iterator const_iterator; typedef CFGBlockListTy::const_iterator const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator;
@ -631,7 +631,7 @@ public:
CFGBlock * getIndirectGotoBlock() { return IndirectGotoBlock; } CFGBlock * getIndirectGotoBlock() { return IndirectGotoBlock; }
const CFGBlock * getIndirectGotoBlock() const { return IndirectGotoBlock; } const CFGBlock * getIndirectGotoBlock() const { return IndirectGotoBlock; }
typedef std::vector<const CFGBlock*>::const_iterator try_block_iterator; typedef std::vector<const CFGBlock*>::const_iterator try_block_iterator;
try_block_iterator try_blocks_begin() const { try_block_iterator try_blocks_begin() const {
return TryDispatchBlocks.begin(); return TryDispatchBlocks.begin();
@ -639,7 +639,7 @@ public:
try_block_iterator try_blocks_end() const { try_block_iterator try_blocks_end() const {
return TryDispatchBlocks.end(); return TryDispatchBlocks.end();
} }
void addTryDispatchBlock(const CFGBlock *block) { void addTryDispatchBlock(const CFGBlock *block) {
TryDispatchBlocks.push_back(block); TryDispatchBlocks.push_back(block);
} }
@ -701,7 +701,7 @@ public:
llvm::BumpPtrAllocator& getAllocator() { llvm::BumpPtrAllocator& getAllocator() {
return BlkBVC.getAllocator(); return BlkBVC.getAllocator();
} }
BumpVectorContext &getBumpVectorContext() { BumpVectorContext &getBumpVectorContext() {
return BlkBVC; return BlkBVC;
} }
@ -717,11 +717,11 @@ private:
// It represents a map from Expr* to integers to record the set of // It represents a map from Expr* to integers to record the set of
// block-level expressions and their "statement number" in the CFG. // block-level expressions and their "statement number" in the CFG.
void * BlkExprMap; void * BlkExprMap;
BumpVectorContext BlkBVC; BumpVectorContext BlkBVC;
CFGBlockListTy Blocks; CFGBlockListTy Blocks;
/// C++ 'try' statements are modeled with an indirect dispatch block. /// C++ 'try' statements are modeled with an indirect dispatch block.
/// This is the collection of such blocks present in the CFG. /// This is the collection of such blocks present in the CFG.
std::vector<const CFGBlock *> TryDispatchBlocks; std::vector<const CFGBlock *> TryDispatchBlocks;

View File

@ -66,7 +66,8 @@ void InitializePreprocessor(Preprocessor &PP,
/// ProcessWarningOptions - Initialize the diagnostic client and process the /// ProcessWarningOptions - Initialize the diagnostic client and process the
/// warning options specified on the command line. /// warning options specified on the command line.
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts); void ProcessWarningOptions(DiagnosticsEngine &Diags,
const DiagnosticOptions &Opts);
/// DoPrintPreprocessedInput - Implement -E mode. /// DoPrintPreprocessedInput - Implement -E mode.
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS, void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS,

View File

@ -42,7 +42,7 @@ public:
struct NamedRef { struct NamedRef {
NamedDecl *ND; NamedDecl *ND;
SourceLocation Loc; SourceLocation Loc;
NamedRef() : ND(0) { } NamedRef() : ND(0) { }
NamedRef(NamedDecl *nd, SourceLocation loc) : ND(nd), Loc(loc) { } NamedRef(NamedDecl *nd, SourceLocation loc) : ND(nd), Loc(loc) { }
}; };
@ -95,14 +95,14 @@ public:
bool isValid() const { return ParentDecl.getPointer() != 0; } bool isValid() const { return ParentDecl.getPointer() != 0; }
bool isInvalid() const { return !isValid(); } bool isInvalid() const { return !isValid(); }
NodeKind getKind() const { NodeKind getKind() const {
assert(isValid()); assert(isValid());
return (NodeKind)ParentDecl.getInt(); return (NodeKind)ParentDecl.getInt();
} }
Decl *getParentDecl() const { return ParentDecl.getPointer(); } Decl *getParentDecl() const { return ParentDecl.getPointer(); }
Decl *AsDecl() const { Decl *AsDecl() const {
assert(getKind() == N_Decl); assert(getKind() == N_Decl);
return D; return D;
@ -121,14 +121,16 @@ public:
} }
Decl *dyn_AsDecl() const { return isValid() && getKind() == N_Decl ? D : 0; } Decl *dyn_AsDecl() const { return isValid() && getKind() == N_Decl ? D : 0; }
Stmt *dyn_AsStmt() const { return isValid() && getKind() == N_Stmt ? Stm : 0; } Stmt *dyn_AsStmt() const {
return isValid() && getKind() == N_Stmt ? Stm : 0;
}
NamedRef dyn_AsNamedRef() const { NamedRef dyn_AsNamedRef() const {
return getKind() == N_Type ? AsNamedRef() : NamedRef(); return getKind() == N_Type ? AsNamedRef() : NamedRef();
} }
TypeLoc dyn_AsTypeLoc() const { TypeLoc dyn_AsTypeLoc() const {
return getKind() == N_Type ? AsTypeLoc() : TypeLoc(); return getKind() == N_Type ? AsTypeLoc() : TypeLoc();
} }
bool isDecl() const { return isValid() && getKind() == N_Decl; } bool isDecl() const { return isValid() && getKind() == N_Decl; }
bool isStmt() const { return isValid() && getKind() == N_Stmt; } bool isStmt() const { return isValid() && getKind() == N_Stmt; }
bool isNamedRef() const { return isValid() && getKind() == N_NamedRef; } bool isNamedRef() const { return isValid() && getKind() == N_NamedRef; }

View File

@ -50,7 +50,7 @@ class CodeCompletionHandler;
class DirectoryLookup; class DirectoryLookup;
class PreprocessingRecord; class PreprocessingRecord;
class ModuleLoader; class ModuleLoader;
/// Preprocessor - This object engages in a tight little dance with the lexer to /// Preprocessor - This object engages in a tight little dance with the lexer to
/// efficiently preprocess tokens. Lexers know only about tokens within a /// efficiently preprocess tokens. Lexers know only about tokens within a
/// single source file, and don't know anything about preprocessor-level issues /// single source file, and don't know anything about preprocessor-level issues
@ -69,7 +69,7 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
/// \brief External source of macros. /// \brief External source of macros.
ExternalPreprocessorSource *ExternalSource; ExternalPreprocessorSource *ExternalSource;
/// PTH - An optional PTHManager object used for getting tokens from /// PTH - An optional PTHManager object used for getting tokens from
/// a token cache rather than lexing the original source file. /// a token cache rather than lexing the original source file.
llvm::OwningPtr<PTHManager> PTH; llvm::OwningPtr<PTHManager> PTH;
@ -108,7 +108,7 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
bool KeepMacroComments : 1; bool KeepMacroComments : 1;
bool SuppressIncludeNotFoundError : 1; bool SuppressIncludeNotFoundError : 1;
bool AutoModuleImport : 1; bool AutoModuleImport : 1;
// State that changes while the preprocessor runs: // State that changes while the preprocessor runs:
bool InMacroArgs : 1; // True if parsing fn macro invocation args. bool InMacroArgs : 1; // True if parsing fn macro invocation args.
@ -147,7 +147,7 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
/// \brief The code-completion handler. /// \brief The code-completion handler.
CodeCompletionHandler *CodeComplete; CodeCompletionHandler *CodeComplete;
/// \brief The file that we're performing code-completion for, if any. /// \brief The file that we're performing code-completion for, if any.
const FileEntry *CodeCompletionFile; const FileEntry *CodeCompletionFile;
@ -170,7 +170,7 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
/// \brief The source location of the currently-active /// \brief The source location of the currently-active
/// #pragma clang arc_cf_code_audited begin. /// #pragma clang arc_cf_code_audited begin.
SourceLocation PragmaARCCFCodeAuditedLoc; SourceLocation PragmaARCCFCodeAuditedLoc;
/// \brief True if we hit the code-completion point. /// \brief True if we hit the code-completion point.
bool CodeCompletionReached; bool CodeCompletionReached;
@ -179,7 +179,7 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
/// with a flag that indicates whether skipping this number of bytes will /// with a flag that indicates whether skipping this number of bytes will
/// place the lexer at the start of a line. /// place the lexer at the start of a line.
std::pair<unsigned, bool> SkipMainFilePreamble; std::pair<unsigned, bool> SkipMainFilePreamble;
/// CurLexer - This is the current top of the stack that we're lexing from if /// CurLexer - This is the current top of the stack that we're lexing from if
/// not expanding a macro and we are lexing directly from source code. /// not expanding a macro and we are lexing directly from source code.
/// Only one of CurLexer, CurPTHLexer, or CurTokenLexer will be non-null. /// Only one of CurLexer, CurPTHLexer, or CurTokenLexer will be non-null.
@ -194,7 +194,7 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
/// if not expanding a macro. This is an alias for either CurLexer or /// if not expanding a macro. This is an alias for either CurLexer or
/// CurPTHLexer. /// CurPTHLexer.
PreprocessorLexer *CurPPLexer; PreprocessorLexer *CurPPLexer;
/// CurLookup - The DirectoryLookup structure used to find the current /// CurLookup - The DirectoryLookup structure used to find the current
/// FileEntry, if CurLexer is non-null and if applicable. This allows us to /// FileEntry, if CurLexer is non-null and if applicable. This allows us to
/// implement #include_next and find directory-specific properties. /// implement #include_next and find directory-specific properties.
@ -205,10 +205,10 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
llvm::OwningPtr<TokenLexer> CurTokenLexer; llvm::OwningPtr<TokenLexer> CurTokenLexer;
/// \brief The kind of lexer we're currently working with. /// \brief The kind of lexer we're currently working with.
enum CurLexerKind { enum CurLexerKind {
CLK_Lexer, CLK_Lexer,
CLK_PTHLexer, CLK_PTHLexer,
CLK_TokenLexer, CLK_TokenLexer,
CLK_CachingLexer, CLK_CachingLexer,
CLK_LexAfterModuleImport CLK_LexAfterModuleImport
} CurLexerKind; } CurLexerKind;
@ -224,10 +224,10 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
TokenLexer *TheTokenLexer; TokenLexer *TheTokenLexer;
const DirectoryLookup *TheDirLookup; const DirectoryLookup *TheDirLookup;
IncludeStackInfo(enum CurLexerKind K, Lexer *L, PTHLexer* P, IncludeStackInfo(enum CurLexerKind K, Lexer *L, PTHLexer* P,
PreprocessorLexer* PPL, PreprocessorLexer* PPL,
TokenLexer* TL, const DirectoryLookup *D) TokenLexer* TL, const DirectoryLookup *D)
: CurLexerKind(K), TheLexer(L), ThePTHLexer(P), ThePPLexer(PPL), : CurLexerKind(K), TheLexer(L), ThePTHLexer(P), ThePPLexer(PPL),
TheTokenLexer(TL), TheDirLookup(D) {} TheTokenLexer(TL), TheDirLookup(D) {}
}; };
std::vector<IncludeStackInfo> IncludeMacroStack; std::vector<IncludeStackInfo> IncludeMacroStack;
@ -254,9 +254,9 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
/// reused for quick allocation. /// reused for quick allocation.
MacroArgs *MacroArgCache; MacroArgs *MacroArgCache;
friend class MacroArgs; friend class MacroArgs;
/// PragmaPushMacroInfo - For each IdentifierInfo used in a #pragma /// PragmaPushMacroInfo - For each IdentifierInfo used in a #pragma
/// push_macro directive, we keep a MacroInfo stack used to restore /// push_macro directive, we keep a MacroInfo stack used to restore
/// previous macro value. /// previous macro value.
llvm::DenseMap<IdentifierInfo*, std::vector<MacroInfo*> > PragmaPushMacroInfo; llvm::DenseMap<IdentifierInfo*, std::vector<MacroInfo*> > PragmaPushMacroInfo;
@ -286,12 +286,12 @@ class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
std::vector<std::pair<TokenLexer *, size_t> > MacroExpandingLexersStack; std::vector<std::pair<TokenLexer *, size_t> > MacroExpandingLexersStack;
/// \brief A record of the macro definitions and expansions that /// \brief A record of the macro definitions and expansions that
/// occurred during preprocessing. /// occurred during preprocessing.
/// ///
/// This is an optional side structure that can be enabled with /// This is an optional side structure that can be enabled with
/// \c createPreprocessingRecord() prior to preprocessing. /// \c createPreprocessingRecord() prior to preprocessing.
PreprocessingRecord *Record; PreprocessingRecord *Record;
private: // Cached tokens state. private: // Cached tokens state.
typedef SmallVector<Token, 1> CachedTokensTy; typedef SmallVector<Token, 1> CachedTokensTy;
@ -325,7 +325,7 @@ private: // Cached tokens state.
MacroInfoChain *MICache; MacroInfoChain *MICache;
MacroInfo *getInfoForMacro(IdentifierInfo *II) const; MacroInfo *getInfoForMacro(IdentifierInfo *II) const;
public: public:
Preprocessor(DiagnosticsEngine &diags, LangOptions &opts, Preprocessor(DiagnosticsEngine &diags, LangOptions &opts,
const TargetInfo *target, const TargetInfo *target,
@ -342,7 +342,7 @@ public:
/// ///
/// \param Target Information about the target. /// \param Target Information about the target.
void Initialize(const TargetInfo &Target); void Initialize(const TargetInfo &Target);
DiagnosticsEngine &getDiagnostics() const { return *Diags; } DiagnosticsEngine &getDiagnostics() const { return *Diags; }
void setDiagnostics(DiagnosticsEngine &D) { Diags = &D; } void setDiagnostics(DiagnosticsEngine &D) { Diags = &D; }
@ -371,7 +371,7 @@ public:
/// \brief Retrieve the module loader associated with this preprocessor. /// \brief Retrieve the module loader associated with this preprocessor.
ModuleLoader &getModuleLoader() const { return TheModuleLoader; } ModuleLoader &getModuleLoader() const { return TheModuleLoader; }
/// SetCommentRetentionState - Control whether or not the preprocessor retains /// SetCommentRetentionState - Control whether or not the preprocessor retains
/// comments in output. /// comments in output.
void SetCommentRetentionState(bool KeepComments, bool KeepMacroComments) { void SetCommentRetentionState(bool KeepComments, bool KeepMacroComments) {
@ -393,7 +393,7 @@ public:
void setAutoModuleImport(bool AutoModuleImport = true) { void setAutoModuleImport(bool AutoModuleImport = true) {
this->AutoModuleImport = AutoModuleImport; this->AutoModuleImport = AutoModuleImport;
} }
/// isCurrentLexer - Return true if we are lexing directly from the specified /// isCurrentLexer - Return true if we are lexing directly from the specified
/// lexer. /// lexer.
bool isCurrentLexer(const PreprocessorLexer *L) const { bool isCurrentLexer(const PreprocessorLexer *L) const {
@ -425,7 +425,7 @@ public:
MacroInfo *getMacroInfo(IdentifierInfo *II) const { MacroInfo *getMacroInfo(IdentifierInfo *II) const {
if (!II->hasMacroDefinition()) if (!II->hasMacroDefinition())
return 0; return 0;
return getInfoForMacro(II); return getInfoForMacro(II);
} }
@ -484,29 +484,29 @@ public:
void setCodeCompletionHandler(CodeCompletionHandler &Handler) { void setCodeCompletionHandler(CodeCompletionHandler &Handler) {
CodeComplete = &Handler; CodeComplete = &Handler;
} }
/// \brief Retrieve the current code-completion handler. /// \brief Retrieve the current code-completion handler.
CodeCompletionHandler *getCodeCompletionHandler() const { CodeCompletionHandler *getCodeCompletionHandler() const {
return CodeComplete; return CodeComplete;
} }
/// \brief Clear out the code completion handler. /// \brief Clear out the code completion handler.
void clearCodeCompletionHandler() { void clearCodeCompletionHandler() {
CodeComplete = 0; CodeComplete = 0;
} }
/// \brief Hook used by the lexer to invoke the "natural language" code /// \brief Hook used by the lexer to invoke the "natural language" code
/// completion point. /// completion point.
void CodeCompleteNaturalLanguage(); void CodeCompleteNaturalLanguage();
/// \brief Retrieve the preprocessing record, or NULL if there is no /// \brief Retrieve the preprocessing record, or NULL if there is no
/// preprocessing record. /// preprocessing record.
PreprocessingRecord *getPreprocessingRecord() const { return Record; } PreprocessingRecord *getPreprocessingRecord() const { return Record; }
/// \brief Create a new preprocessing record, which will keep track of /// \brief Create a new preprocessing record, which will keep track of
/// all macro expansions, macro definitions, etc. /// all macro expansions, macro definitions, etc.
void createPreprocessingRecord(bool IncludeNestedMacroExpansions); void createPreprocessingRecord(bool IncludeNestedMacroExpansions);
/// EnterMainSourceFile - Enter the specified FileID as the main source file, /// EnterMainSourceFile - Enter the specified FileID as the main source file,
/// which implicitly adds the builtin defines etc. /// which implicitly adds the builtin defines etc.
void EnterMainSourceFile(); void EnterMainSourceFile();
@ -588,7 +588,7 @@ public:
} }
void LexAfterModuleImport(Token &Result); void LexAfterModuleImport(Token &Result);
/// LexNonComment - Lex a token. If it's a comment, keep lexing until we get /// LexNonComment - Lex a token. If it's a comment, keep lexing until we get
/// something not a comment. This is useful in -E -C mode where comments /// something not a comment. This is useful in -E -C mode where comments
/// would foul up preprocessor directive handling. /// would foul up preprocessor directive handling.
@ -745,11 +745,11 @@ public:
/// ///
/// \brief StartOfLine Whether skipping these bytes puts the lexer at the /// \brief StartOfLine Whether skipping these bytes puts the lexer at the
/// start of a line. /// start of a line.
void setSkipMainFilePreamble(unsigned Bytes, bool StartOfLine) { void setSkipMainFilePreamble(unsigned Bytes, bool StartOfLine) {
SkipMainFilePreamble.first = Bytes; SkipMainFilePreamble.first = Bytes;
SkipMainFilePreamble.second = StartOfLine; SkipMainFilePreamble.second = StartOfLine;
} }
/// Diag - Forwarding function for diagnostics. This emits a diagnostic at /// Diag - Forwarding function for diagnostics. This emits a diagnostic at
/// the specified Token's location, translating the token's start /// the specified Token's location, translating the token's start
/// position in the current buffer into a SourcePosition object for rendering. /// position in the current buffer into a SourcePosition object for rendering.
@ -795,7 +795,7 @@ public:
/// to point to a constant buffer with the data already in it (avoiding a /// to point to a constant buffer with the data already in it (avoiding a
/// copy). The caller is not allowed to modify the returned buffer pointer /// copy). The caller is not allowed to modify the returned buffer pointer
/// if an internal buffer is returned. /// if an internal buffer is returned.
unsigned getSpelling(const Token &Tok, const char *&Buffer, unsigned getSpelling(const Token &Tok, const char *&Buffer,
bool *Invalid = 0) const { bool *Invalid = 0) const {
return Lexer::getSpelling(Tok, Buffer, SourceMgr, Features, Invalid); return Lexer::getSpelling(Tok, Buffer, SourceMgr, Features, Invalid);
} }
@ -804,12 +804,12 @@ public:
/// SmallVector. Note that the returned StringRef may not point to the /// SmallVector. Note that the returned StringRef may not point to the
/// supplied buffer if a copy can be avoided. /// supplied buffer if a copy can be avoided.
StringRef getSpelling(const Token &Tok, StringRef getSpelling(const Token &Tok,
SmallVectorImpl<char> &Buffer, SmallVectorImpl<char> &Buffer,
bool *Invalid = 0) const; bool *Invalid = 0) const;
/// getSpellingOfSingleCharacterNumericConstant - Tok is a numeric constant /// getSpellingOfSingleCharacterNumericConstant - Tok is a numeric constant
/// with length 1, return the character. /// with length 1, return the character.
char getSpellingOfSingleCharacterNumericConstant(const Token &Tok, char getSpellingOfSingleCharacterNumericConstant(const Token &Tok,
bool *Invalid = 0) const { bool *Invalid = 0) const {
assert(Tok.is(tok::numeric_constant) && assert(Tok.is(tok::numeric_constant) &&
Tok.getLength() == 1 && "Called on unsupported token"); Tok.getLength() == 1 && "Called on unsupported token");
@ -930,9 +930,18 @@ public:
private: private:
/// Identifiers used for SEH handling in Borland. These are only /// Identifiers used for SEH handling in Borland. These are only
/// allowed in particular circumstances /// allowed in particular circumstances
IdentifierInfo *Ident__exception_code, *Ident___exception_code, *Ident_GetExceptionCode; // __except block // __except block
IdentifierInfo *Ident__exception_info, *Ident___exception_info, *Ident_GetExceptionInfo; // __except filter expression IdentifierInfo *Ident__exception_code,
IdentifierInfo *Ident__abnormal_termination, *Ident___abnormal_termination, *Ident_AbnormalTermination; // __finally *Ident___exception_code,
*Ident_GetExceptionCode;
// __except filter expression
IdentifierInfo *Ident__exception_info,
*Ident___exception_info,
*Ident_GetExceptionInfo;
// __finally
IdentifierInfo *Ident__abnormal_termination,
*Ident___abnormal_termination,
*Ident_AbnormalTermination;
public: public:
void PoisonSEHIdentifiers(bool Poison = true); // Borland void PoisonSEHIdentifiers(bool Poison = true); // Borland
@ -1163,7 +1172,7 @@ private:
bool InCachingLexMode() const { bool InCachingLexMode() const {
// If the Lexer pointers are 0 and IncludeMacroStack is empty, it means // If the Lexer pointers are 0 and IncludeMacroStack is empty, it means
// that we are past EOF, not that we are in CachingLex mode. // that we are past EOF, not that we are in CachingLex mode.
return CurPPLexer == 0 && CurTokenLexer == 0 && CurPTHLexer == 0 && return CurPPLexer == 0 && CurTokenLexer == 0 && CurPTHLexer == 0 &&
!IncludeMacroStack.empty(); !IncludeMacroStack.empty();
} }
void EnterCachingLexMode(); void EnterCachingLexMode();
@ -1184,7 +1193,7 @@ private:
void HandleIdentSCCSDirective(Token &Tok); void HandleIdentSCCSDirective(Token &Tok);
void HandleMacroExportDirective(Token &Tok); void HandleMacroExportDirective(Token &Tok);
void HandleMacroPrivateDirective(Token &Tok); void HandleMacroPrivateDirective(Token &Tok);
// File inclusion. // File inclusion.
void HandleIncludeDirective(SourceLocation HashLoc, void HandleIncludeDirective(SourceLocation HashLoc,
Token &Tok, Token &Tok,

View File

@ -24,14 +24,14 @@
namespace clang { namespace clang {
class Decl; class Decl;
/// \brief Default priority values for code-completion results based /// \brief Default priority values for code-completion results based
/// on their kind. /// on their kind.
enum { enum {
/// \brief Priority for the next initialization in a constructor initializer /// \brief Priority for the next initialization in a constructor initializer
/// list. /// list.
CCP_NextInitializer = 7, CCP_NextInitializer = 7,
/// \brief Priority for an enumeration constant inside a switch whose /// \brief Priority for an enumeration constant inside a switch whose
/// condition is of the enumeration type. /// condition is of the enumeration type.
CCP_EnumInCase = 7, CCP_EnumInCase = 7,
/// \brief Priority for a send-to-super completion. /// \brief Priority for a send-to-super completion.
@ -59,7 +59,7 @@ enum {
/// \brief Priority for a result that isn't likely to be what the user wants, /// \brief Priority for a result that isn't likely to be what the user wants,
/// but is included for completeness. /// but is included for completeness.
CCP_Unlikely = 80, CCP_Unlikely = 80,
/// \brief Priority for the Objective-C "_cmd" implicit parameter. /// \brief Priority for the Objective-C "_cmd" implicit parameter.
CCP_ObjC_cmd = CCP_Unlikely CCP_ObjC_cmd = CCP_Unlikely
}; };
@ -76,15 +76,15 @@ enum {
/// of the current method, which might imply that some kind of delegation /// of the current method, which might imply that some kind of delegation
/// is occurring. /// is occurring.
CCD_SelectorMatch = -3, CCD_SelectorMatch = -3,
/// \brief Adjustment to the "bool" type in Objective-C, where the typedef /// \brief Adjustment to the "bool" type in Objective-C, where the typedef
/// "BOOL" is preferred. /// "BOOL" is preferred.
CCD_bool_in_ObjC = 1, CCD_bool_in_ObjC = 1,
/// \brief Adjustment for KVC code pattern priorities when it doesn't look /// \brief Adjustment for KVC code pattern priorities when it doesn't look
/// like the /// like the
CCD_ProbablyNotObjCCollection = 15, CCD_ProbablyNotObjCCollection = 15,
/// \brief An Objective-C method being used as a property. /// \brief An Objective-C method being used as a property.
CCD_MethodAsProperty = 2 CCD_MethodAsProperty = 2
}; };
@ -114,14 +114,14 @@ enum SimplifiedTypeClass {
STC_Record, STC_Record,
STC_Void STC_Void
}; };
/// \brief Determine the simplified type class of the given canonical type. /// \brief Determine the simplified type class of the given canonical type.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T); SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T);
/// \brief Determine the type that this declaration will have if it is used /// \brief Determine the type that this declaration will have if it is used
/// as a type or in an expression. /// as a type or in an expression.
QualType getDeclUsageType(ASTContext &C, NamedDecl *ND); QualType getDeclUsageType(ASTContext &C, NamedDecl *ND);
/// \brief Determine the priority to be given to a macro code completion result /// \brief Determine the priority to be given to a macro code completion result
/// with the given name. /// with the given name.
/// ///
@ -131,14 +131,14 @@ QualType getDeclUsageType(ASTContext &C, NamedDecl *ND);
/// ///
/// \param PreferredTypeIsPointer Whether the preferred type for the context /// \param PreferredTypeIsPointer Whether the preferred type for the context
/// of this macro is a pointer type. /// of this macro is a pointer type.
unsigned getMacroUsagePriority(StringRef MacroName, unsigned getMacroUsagePriority(StringRef MacroName,
const LangOptions &LangOpts, const LangOptions &LangOpts,
bool PreferredTypeIsPointer = false); bool PreferredTypeIsPointer = false);
/// \brief Determine the libclang cursor kind associated with the given /// \brief Determine the libclang cursor kind associated with the given
/// declaration. /// declaration.
CXCursorKind getCursorKindForDecl(Decl *D); CXCursorKind getCursorKindForDecl(Decl *D);
class FunctionDecl; class FunctionDecl;
class FunctionType; class FunctionType;
class FunctionTemplateDecl; class FunctionTemplateDecl;
@ -182,22 +182,22 @@ public:
/// \brief Code completion occurred on the right-hand side of a member /// \brief Code completion occurred on the right-hand side of a member
/// access expression using the dot operator. /// access expression using the dot operator.
/// ///
/// The results of this completion are the members of the type being /// The results of this completion are the members of the type being
/// accessed. The type itself is available via /// accessed. The type itself is available via
/// \c CodeCompletionContext::getType(). /// \c CodeCompletionContext::getType().
CCC_DotMemberAccess, CCC_DotMemberAccess,
/// \brief Code completion occurred on the right-hand side of a member /// \brief Code completion occurred on the right-hand side of a member
/// access expression using the arrow operator. /// access expression using the arrow operator.
/// ///
/// The results of this completion are the members of the type being /// The results of this completion are the members of the type being
/// accessed. The type itself is available via /// accessed. The type itself is available via
/// \c CodeCompletionContext::getType(). /// \c CodeCompletionContext::getType().
CCC_ArrowMemberAccess, CCC_ArrowMemberAccess,
/// \brief Code completion occurred on the right-hand side of an Objective-C /// \brief Code completion occurred on the right-hand side of an Objective-C
/// property access expression. /// property access expression.
/// ///
/// The results of this completion are the members of the type being /// The results of this completion are the members of the type being
/// accessed. The type itself is available via /// accessed. The type itself is available via
/// \c CodeCompletionContext::getType(). /// \c CodeCompletionContext::getType().
CCC_ObjCPropertyAccess, CCC_ObjCPropertyAccess,
/// \brief Code completion occurred after the "enum" keyword, to indicate /// \brief Code completion occurred after the "enum" keyword, to indicate
@ -228,7 +228,7 @@ public:
CCC_MacroNameUse, CCC_MacroNameUse,
/// \brief Code completion occurred within a preprocessor expression. /// \brief Code completion occurred within a preprocessor expression.
CCC_PreprocessorExpression, CCC_PreprocessorExpression,
/// \brief Code completion occurred where a preprocessor directive is /// \brief Code completion occurred where a preprocessor directive is
/// expected. /// expected.
CCC_PreprocessorDirective, CCC_PreprocessorDirective,
/// \brief Code completion occurred in a context where natural language is /// \brief Code completion occurred in a context where natural language is
@ -246,14 +246,14 @@ public:
CCC_ParenthesizedExpression, CCC_ParenthesizedExpression,
/// \brief Code completion where an Objective-C instance message is expcted. /// \brief Code completion where an Objective-C instance message is expcted.
CCC_ObjCInstanceMessage, CCC_ObjCInstanceMessage,
/// \brief Code completion where an Objective-C class message is expected. /// \brief Code completion where an Objective-C class message is expected.
CCC_ObjCClassMessage, CCC_ObjCClassMessage,
/// \brief Code completion where the name of an Objective-C class is /// \brief Code completion where the name of an Objective-C class is
/// expected. /// expected.
CCC_ObjCInterfaceName, CCC_ObjCInterfaceName,
/// \brief Code completion where an Objective-C category name is expected. /// \brief Code completion where an Objective-C category name is expected.
CCC_ObjCCategoryName, CCC_ObjCCategoryName,
/// \brief An unknown context, in which we are recovering from a parsing /// \brief An unknown context, in which we are recovering from a parsing
/// error and don't know which completions we should give. /// error and don't know which completions we should give.
CCC_Recovery CCC_Recovery
}; };
@ -264,27 +264,27 @@ private:
/// \brief The type that would prefer to see at this point (e.g., the type /// \brief The type that would prefer to see at this point (e.g., the type
/// of an initializer or function parameter). /// of an initializer or function parameter).
QualType PreferredType; QualType PreferredType;
/// \brief The type of the base object in a member access expression. /// \brief The type of the base object in a member access expression.
QualType BaseType; QualType BaseType;
/// \brief The identifiers for Objective-C selector parts. /// \brief The identifiers for Objective-C selector parts.
IdentifierInfo **SelIdents; IdentifierInfo **SelIdents;
/// \brief The number of Objective-C selector parts. /// \brief The number of Objective-C selector parts.
unsigned NumSelIdents; unsigned NumSelIdents;
public: public:
/// \brief Construct a new code-completion context of the given kind. /// \brief Construct a new code-completion context of the given kind.
CodeCompletionContext(enum Kind Kind) : Kind(Kind), SelIdents(NULL), CodeCompletionContext(enum Kind Kind) : Kind(Kind), SelIdents(NULL),
NumSelIdents(0) { } NumSelIdents(0) { }
/// \brief Construct a new code-completion context of the given kind. /// \brief Construct a new code-completion context of the given kind.
CodeCompletionContext(enum Kind Kind, QualType T, CodeCompletionContext(enum Kind Kind, QualType T,
IdentifierInfo **SelIdents = NULL, IdentifierInfo **SelIdents = NULL,
unsigned NumSelIdents = 0) : Kind(Kind), unsigned NumSelIdents = 0) : Kind(Kind),
SelIdents(SelIdents), SelIdents(SelIdents),
NumSelIdents(NumSelIdents) { NumSelIdents(NumSelIdents) {
if (Kind == CCC_DotMemberAccess || Kind == CCC_ArrowMemberAccess || if (Kind == CCC_DotMemberAccess || Kind == CCC_ArrowMemberAccess ||
Kind == CCC_ObjCPropertyAccess || Kind == CCC_ObjCClassMessage || Kind == CCC_ObjCPropertyAccess || Kind == CCC_ObjCClassMessage ||
Kind == CCC_ObjCInstanceMessage) Kind == CCC_ObjCInstanceMessage)
@ -292,22 +292,22 @@ public:
else else
PreferredType = T; PreferredType = T;
} }
/// \brief Retrieve the kind of code-completion context. /// \brief Retrieve the kind of code-completion context.
enum Kind getKind() const { return Kind; } enum Kind getKind() const { return Kind; }
/// \brief Retrieve the type that this expression would prefer to have, e.g., /// \brief Retrieve the type that this expression would prefer to have, e.g.,
/// if the expression is a variable initializer or a function argument, the /// if the expression is a variable initializer or a function argument, the
/// type of the corresponding variable or function parameter. /// type of the corresponding variable or function parameter.
QualType getPreferredType() const { return PreferredType; } QualType getPreferredType() const { return PreferredType; }
/// \brief Retrieve the type of the base object in a member-access /// \brief Retrieve the type of the base object in a member-access
/// expression. /// expression.
QualType getBaseType() const { return BaseType; } QualType getBaseType() const { return BaseType; }
/// \brief Retrieve the Objective-C selector identifiers. /// \brief Retrieve the Objective-C selector identifiers.
IdentifierInfo **getSelIdents() const { return SelIdents; } IdentifierInfo **getSelIdents() const { return SelIdents; }
/// \brief Retrieve the number of Objective-C selector identifiers. /// \brief Retrieve the number of Objective-C selector identifiers.
unsigned getNumSelIdents() const { return NumSelIdents; } unsigned getNumSelIdents() const { return NumSelIdents; }
@ -320,10 +320,10 @@ public:
/// \brief A "string" used to describe how code completion can /// \brief A "string" used to describe how code completion can
/// be performed for an entity. /// be performed for an entity.
/// ///
/// A code completion string typically shows how a particular entity can be /// A code completion string typically shows how a particular entity can be
/// used. For example, the code completion string for a function would show /// used. For example, the code completion string for a function would show
/// the syntax to call it, including the parentheses, placeholders for the /// the syntax to call it, including the parentheses, placeholders for the
/// arguments, etc. /// arguments, etc.
class CodeCompletionString { class CodeCompletionString {
public: public:
/// \brief The different kinds of "chunks" that can occur within a code /// \brief The different kinds of "chunks" that can occur within a code
@ -340,7 +340,7 @@ public:
/// an optional code completion string that describes the default arguments /// an optional code completion string that describes the default arguments
/// in a function call. /// in a function call.
CK_Optional, CK_Optional,
/// \brief A string that acts as a placeholder for, e.g., a function /// \brief A string that acts as a placeholder for, e.g., a function
/// call argument. /// call argument.
CK_Placeholder, CK_Placeholder,
/// \brief A piece of text that describes something about the result but /// \brief A piece of text that describes something about the result but
@ -383,30 +383,30 @@ public:
/// platform). /// platform).
CK_VerticalSpace CK_VerticalSpace
}; };
/// \brief One piece of the code completion string. /// \brief One piece of the code completion string.
struct Chunk { struct Chunk {
/// \brief The kind of data stored in this piece of the code completion /// \brief The kind of data stored in this piece of the code completion
/// string. /// string.
ChunkKind Kind; ChunkKind Kind;
union { union {
/// \brief The text string associated with a CK_Text, CK_Placeholder, /// \brief The text string associated with a CK_Text, CK_Placeholder,
/// CK_Informative, or CK_Comma chunk. /// CK_Informative, or CK_Comma chunk.
/// The string is owned by the chunk and will be deallocated /// The string is owned by the chunk and will be deallocated
/// (with delete[]) when the chunk is destroyed. /// (with delete[]) when the chunk is destroyed.
const char *Text; const char *Text;
/// \brief The code completion string associated with a CK_Optional chunk. /// \brief The code completion string associated with a CK_Optional chunk.
/// The optional code completion string is owned by the chunk, and will /// The optional code completion string is owned by the chunk, and will
/// be deallocated (with delete) when the chunk is destroyed. /// be deallocated (with delete) when the chunk is destroyed.
CodeCompletionString *Optional; CodeCompletionString *Optional;
}; };
Chunk() : Kind(CK_Text), Text(0) { } Chunk() : Kind(CK_Text), Text(0) { }
Chunk(ChunkKind Kind, const char *Text = ""); Chunk(ChunkKind Kind, const char *Text = "");
/// \brief Create a new text chunk. /// \brief Create a new text chunk.
static Chunk CreateText(const char *Text); static Chunk CreateText(const char *Text);
@ -425,49 +425,49 @@ public:
/// \brief Create a new current-parameter chunk. /// \brief Create a new current-parameter chunk.
static Chunk CreateCurrentParameter(const char *CurrentParameter); static Chunk CreateCurrentParameter(const char *CurrentParameter);
}; };
private: private:
/// \brief The number of chunks stored in this string. /// \brief The number of chunks stored in this string.
unsigned NumChunks : 16; unsigned NumChunks : 16;
/// \brief The number of annotations for this code-completion result. /// \brief The number of annotations for this code-completion result.
unsigned NumAnnotations : 16; unsigned NumAnnotations : 16;
/// \brief The priority of this code-completion string. /// \brief The priority of this code-completion string.
unsigned Priority : 30; unsigned Priority : 30;
/// \brief The availability of this code-completion result. /// \brief The availability of this code-completion result.
unsigned Availability : 2; unsigned Availability : 2;
CodeCompletionString(const CodeCompletionString &); // DO NOT IMPLEMENT CodeCompletionString(const CodeCompletionString &); // DO NOT IMPLEMENT
CodeCompletionString &operator=(const CodeCompletionString &); // DITTO CodeCompletionString &operator=(const CodeCompletionString &); // DITTO
CodeCompletionString(const Chunk *Chunks, unsigned NumChunks, CodeCompletionString(const Chunk *Chunks, unsigned NumChunks,
unsigned Priority, CXAvailabilityKind Availability, unsigned Priority, CXAvailabilityKind Availability,
const char **Annotations, unsigned NumAnnotations); const char **Annotations, unsigned NumAnnotations);
~CodeCompletionString() { } ~CodeCompletionString() { }
friend class CodeCompletionBuilder; friend class CodeCompletionBuilder;
friend class CodeCompletionResult; friend class CodeCompletionResult;
public: public:
typedef const Chunk *iterator; typedef const Chunk *iterator;
iterator begin() const { return reinterpret_cast<const Chunk *>(this + 1); } iterator begin() const { return reinterpret_cast<const Chunk *>(this + 1); }
iterator end() const { return begin() + NumChunks; } iterator end() const { return begin() + NumChunks; }
bool empty() const { return NumChunks == 0; } bool empty() const { return NumChunks == 0; }
unsigned size() const { return NumChunks; } unsigned size() const { return NumChunks; }
const Chunk &operator[](unsigned I) const { const Chunk &operator[](unsigned I) const {
assert(I < size() && "Chunk index out-of-range"); assert(I < size() && "Chunk index out-of-range");
return begin()[I]; return begin()[I];
} }
/// \brief Returns the text in the TypedText chunk. /// \brief Returns the text in the TypedText chunk.
const char *getTypedText() const; const char *getTypedText() const;
/// \brief Retrieve the priority of this code completion result. /// \brief Retrieve the priority of this code completion result.
unsigned getPriority() const { return Priority; } unsigned getPriority() const { return Priority; }
/// \brief Retrieve the availability of this code completion result. /// \brief Retrieve the availability of this code completion result.
unsigned getAvailability() const { return Availability; } unsigned getAvailability() const { return Availability; }
@ -476,26 +476,26 @@ public:
/// \brief Retrieve the annotation string specified by \c AnnotationNr. /// \brief Retrieve the annotation string specified by \c AnnotationNr.
const char *getAnnotation(unsigned AnnotationNr) const; const char *getAnnotation(unsigned AnnotationNr) const;
/// \brief Retrieve a string representation of the code completion string, /// \brief Retrieve a string representation of the code completion string,
/// which is mainly useful for debugging. /// which is mainly useful for debugging.
std::string getAsString() const; std::string getAsString() const;
}; };
/// \brief An allocator used specifically for the purpose of code completion. /// \brief An allocator used specifically for the purpose of code completion.
class CodeCompletionAllocator : public llvm::BumpPtrAllocator { class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
public: public:
/// \brief Copy the given string into this allocator. /// \brief Copy the given string into this allocator.
const char *CopyString(StringRef String); const char *CopyString(StringRef String);
/// \brief Copy the given string into this allocator. /// \brief Copy the given string into this allocator.
const char *CopyString(Twine String); const char *CopyString(Twine String);
// \brief Copy the given string into this allocator. // \brief Copy the given string into this allocator.
const char *CopyString(const char *String) { const char *CopyString(const char *String) {
return CopyString(StringRef(String)); return CopyString(StringRef(String));
} }
/// \brief Copy the given string into this allocator. /// \brief Copy the given string into this allocator.
const char *CopyString(const std::string &String) { const char *CopyString(const std::string &String) {
return CopyString(StringRef(String)); return CopyString(StringRef(String));
@ -514,78 +514,78 @@ namespace clang {
/// \brief A builder class used to construct new code-completion strings. /// \brief A builder class used to construct new code-completion strings.
class CodeCompletionBuilder { class CodeCompletionBuilder {
public: public:
typedef CodeCompletionString::Chunk Chunk; typedef CodeCompletionString::Chunk Chunk;
private: private:
CodeCompletionAllocator &Allocator; CodeCompletionAllocator &Allocator;
unsigned Priority; unsigned Priority;
CXAvailabilityKind Availability; CXAvailabilityKind Availability;
/// \brief The chunks stored in this string. /// \brief The chunks stored in this string.
SmallVector<Chunk, 4> Chunks; SmallVector<Chunk, 4> Chunks;
SmallVector<const char *, 2> Annotations; SmallVector<const char *, 2> Annotations;
public: public:
CodeCompletionBuilder(CodeCompletionAllocator &Allocator) CodeCompletionBuilder(CodeCompletionAllocator &Allocator)
: Allocator(Allocator), Priority(0), Availability(CXAvailability_Available){ : Allocator(Allocator), Priority(0), Availability(CXAvailability_Available){
} }
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionBuilder(CodeCompletionAllocator &Allocator,
unsigned Priority, CXAvailabilityKind Availability) unsigned Priority, CXAvailabilityKind Availability)
: Allocator(Allocator), Priority(Priority), Availability(Availability) { } : Allocator(Allocator), Priority(Priority), Availability(Availability) { }
/// \brief Retrieve the allocator into which the code completion /// \brief Retrieve the allocator into which the code completion
/// strings should be allocated. /// strings should be allocated.
CodeCompletionAllocator &getAllocator() const { return Allocator; } CodeCompletionAllocator &getAllocator() const { return Allocator; }
/// \brief Take the resulting completion string. /// \brief Take the resulting completion string.
/// ///
/// This operation can only be performed once. /// This operation can only be performed once.
CodeCompletionString *TakeString(); CodeCompletionString *TakeString();
/// \brief Add a new typed-text chunk. /// \brief Add a new typed-text chunk.
void AddTypedTextChunk(const char *Text) { void AddTypedTextChunk(const char *Text) {
Chunks.push_back(Chunk(CodeCompletionString::CK_TypedText, Text)); Chunks.push_back(Chunk(CodeCompletionString::CK_TypedText, Text));
} }
/// \brief Add a new text chunk. /// \brief Add a new text chunk.
void AddTextChunk(const char *Text) { void AddTextChunk(const char *Text) {
Chunks.push_back(Chunk::CreateText(Text)); Chunks.push_back(Chunk::CreateText(Text));
} }
/// \brief Add a new optional chunk. /// \brief Add a new optional chunk.
void AddOptionalChunk(CodeCompletionString *Optional) { void AddOptionalChunk(CodeCompletionString *Optional) {
Chunks.push_back(Chunk::CreateOptional(Optional)); Chunks.push_back(Chunk::CreateOptional(Optional));
} }
/// \brief Add a new placeholder chunk. /// \brief Add a new placeholder chunk.
void AddPlaceholderChunk(const char *Placeholder) { void AddPlaceholderChunk(const char *Placeholder) {
Chunks.push_back(Chunk::CreatePlaceholder(Placeholder)); Chunks.push_back(Chunk::CreatePlaceholder(Placeholder));
} }
/// \brief Add a new informative chunk. /// \brief Add a new informative chunk.
void AddInformativeChunk(const char *Text) { void AddInformativeChunk(const char *Text) {
Chunks.push_back(Chunk::CreateInformative(Text)); Chunks.push_back(Chunk::CreateInformative(Text));
} }
/// \brief Add a new result-type chunk. /// \brief Add a new result-type chunk.
void AddResultTypeChunk(const char *ResultType) { void AddResultTypeChunk(const char *ResultType) {
Chunks.push_back(Chunk::CreateResultType(ResultType)); Chunks.push_back(Chunk::CreateResultType(ResultType));
} }
/// \brief Add a new current-parameter chunk. /// \brief Add a new current-parameter chunk.
void AddCurrentParameterChunk(const char *CurrentParameter) { void AddCurrentParameterChunk(const char *CurrentParameter) {
Chunks.push_back(Chunk::CreateCurrentParameter(CurrentParameter)); Chunks.push_back(Chunk::CreateCurrentParameter(CurrentParameter));
} }
/// \brief Add a new chunk. /// \brief Add a new chunk.
void AddChunk(Chunk C) { Chunks.push_back(C); } void AddChunk(Chunk C) { Chunks.push_back(C); }
void AddAnnotation(const char *A) { Annotations.push_back(A); } void AddAnnotation(const char *A) { Annotations.push_back(A); }
}; };
/// \brief Captures a result of code completion. /// \brief Captures a result of code completion.
class CodeCompletionResult { class CodeCompletionResult {
public: public:
@ -596,23 +596,23 @@ public:
RK_Macro, //< Refers to a macro RK_Macro, //< Refers to a macro
RK_Pattern //< Refers to a precomputed pattern. RK_Pattern //< Refers to a precomputed pattern.
}; };
/// \brief The kind of result stored here. /// \brief The kind of result stored here.
ResultKind Kind; ResultKind Kind;
union { union {
/// \brief When Kind == RK_Declaration, the declaration we are referring /// \brief When Kind == RK_Declaration, the declaration we are referring
/// to. /// to.
NamedDecl *Declaration; NamedDecl *Declaration;
/// \brief When Kind == RK_Keyword, the string representing the keyword /// \brief When Kind == RK_Keyword, the string representing the keyword
/// or symbol's spelling. /// or symbol's spelling.
const char *Keyword; const char *Keyword;
/// \brief When Kind == RK_Pattern, the code-completion string that /// \brief When Kind == RK_Pattern, the code-completion string that
/// describes the completion text to insert. /// describes the completion text to insert.
CodeCompletionString *Pattern; CodeCompletionString *Pattern;
/// \brief When Kind == RK_Macro, the identifier that refers to a macro. /// \brief When Kind == RK_Macro, the identifier that refers to a macro.
IdentifierInfo *Macro; IdentifierInfo *Macro;
}; };
@ -622,21 +622,21 @@ public:
/// \brief The cursor kind that describes this result. /// \brief The cursor kind that describes this result.
CXCursorKind CursorKind; CXCursorKind CursorKind;
/// \brief The availability of this result. /// \brief The availability of this result.
CXAvailabilityKind Availability; CXAvailabilityKind Availability;
/// \brief Specifies which parameter (of a function, Objective-C method, /// \brief Specifies which parameter (of a function, Objective-C method,
/// macro, etc.) we should start with when formatting the result. /// macro, etc.) we should start with when formatting the result.
unsigned StartParameter; unsigned StartParameter;
/// \brief Whether this result is hidden by another name. /// \brief Whether this result is hidden by another name.
bool Hidden : 1; bool Hidden : 1;
/// \brief Whether this result was found via lookup into a base class. /// \brief Whether this result was found via lookup into a base class.
bool QualifierIsInformative : 1; bool QualifierIsInformative : 1;
/// \brief Whether this declaration is the beginning of a /// \brief Whether this declaration is the beginning of a
/// nested-name-specifier and, therefore, should be followed by '::'. /// nested-name-specifier and, therefore, should be followed by '::'.
bool StartsNestedNameSpecifier : 1; bool StartsNestedNameSpecifier : 1;
@ -647,43 +647,43 @@ public:
/// \brief Whether we're completing a declaration of the given entity, /// \brief Whether we're completing a declaration of the given entity,
/// rather than a use of that entity. /// rather than a use of that entity.
bool DeclaringEntity : 1; bool DeclaringEntity : 1;
/// \brief If the result should have a nested-name-specifier, this is it. /// \brief If the result should have a nested-name-specifier, this is it.
/// When \c QualifierIsInformative, the nested-name-specifier is /// When \c QualifierIsInformative, the nested-name-specifier is
/// informative rather than required. /// informative rather than required.
NestedNameSpecifier *Qualifier; NestedNameSpecifier *Qualifier;
/// \brief Build a result that refers to a declaration. /// \brief Build a result that refers to a declaration.
CodeCompletionResult(NamedDecl *Declaration, CodeCompletionResult(NamedDecl *Declaration,
NestedNameSpecifier *Qualifier = 0, NestedNameSpecifier *Qualifier = 0,
bool QualifierIsInformative = false, bool QualifierIsInformative = false,
bool Accessible = true) bool Accessible = true)
: Kind(RK_Declaration), Declaration(Declaration), : Kind(RK_Declaration), Declaration(Declaration),
Priority(getPriorityFromDecl(Declaration)), Priority(getPriorityFromDecl(Declaration)),
Availability(CXAvailability_Available), StartParameter(0), Availability(CXAvailability_Available), StartParameter(0),
Hidden(false), QualifierIsInformative(QualifierIsInformative), Hidden(false), QualifierIsInformative(QualifierIsInformative),
StartsNestedNameSpecifier(false), AllParametersAreInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
DeclaringEntity(false), Qualifier(Qualifier) { DeclaringEntity(false), Qualifier(Qualifier) {
computeCursorKindAndAvailability(Accessible); computeCursorKindAndAvailability(Accessible);
} }
/// \brief Build a result that refers to a keyword or symbol. /// \brief Build a result that refers to a keyword or symbol.
CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword) CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword)
: Kind(RK_Keyword), Keyword(Keyword), Priority(Priority), : Kind(RK_Keyword), Keyword(Keyword), Priority(Priority),
Availability(CXAvailability_Available), Availability(CXAvailability_Available),
StartParameter(0), Hidden(false), QualifierIsInformative(0), StartParameter(0), Hidden(false), QualifierIsInformative(0),
StartsNestedNameSpecifier(false), AllParametersAreInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
DeclaringEntity(false), Qualifier(0) { DeclaringEntity(false), Qualifier(0) {
computeCursorKindAndAvailability(); computeCursorKindAndAvailability();
} }
/// \brief Build a result that refers to a macro. /// \brief Build a result that refers to a macro.
CodeCompletionResult(IdentifierInfo *Macro, unsigned Priority = CCP_Macro) CodeCompletionResult(IdentifierInfo *Macro, unsigned Priority = CCP_Macro)
: Kind(RK_Macro), Macro(Macro), Priority(Priority), : Kind(RK_Macro), Macro(Macro), Priority(Priority),
Availability(CXAvailability_Available), StartParameter(0), Availability(CXAvailability_Available), StartParameter(0),
Hidden(false), QualifierIsInformative(0), Hidden(false), QualifierIsInformative(0),
StartsNestedNameSpecifier(false), AllParametersAreInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
DeclaringEntity(false), Qualifier(0) { DeclaringEntity(false), Qualifier(0) {
computeCursorKindAndAvailability(); computeCursorKindAndAvailability();
} }
@ -692,26 +692,26 @@ public:
unsigned Priority = CCP_CodePattern, unsigned Priority = CCP_CodePattern,
CXCursorKind CursorKind = CXCursor_NotImplemented, CXCursorKind CursorKind = CXCursor_NotImplemented,
CXAvailabilityKind Availability = CXAvailability_Available) CXAvailabilityKind Availability = CXAvailability_Available)
: Kind(RK_Pattern), Pattern(Pattern), Priority(Priority), : Kind(RK_Pattern), Pattern(Pattern), Priority(Priority),
CursorKind(CursorKind), Availability(Availability), StartParameter(0), CursorKind(CursorKind), Availability(Availability), StartParameter(0),
Hidden(false), QualifierIsInformative(0), Hidden(false), QualifierIsInformative(0),
StartsNestedNameSpecifier(false), AllParametersAreInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
DeclaringEntity(false), Qualifier(0) DeclaringEntity(false), Qualifier(0)
{ {
} }
/// \brief Retrieve the declaration stored in this result. /// \brief Retrieve the declaration stored in this result.
NamedDecl *getDeclaration() const { NamedDecl *getDeclaration() const {
assert(Kind == RK_Declaration && "Not a declaration result"); assert(Kind == RK_Declaration && "Not a declaration result");
return Declaration; return Declaration;
} }
/// \brief Retrieve the keyword stored in this result. /// \brief Retrieve the keyword stored in this result.
const char *getKeyword() const { const char *getKeyword() const {
assert(Kind == RK_Keyword && "Not a keyword result"); assert(Kind == RK_Keyword && "Not a keyword result");
return Keyword; return Keyword;
} }
/// \brief Create a new code-completion string that describes how to insert /// \brief Create a new code-completion string that describes how to insert
/// this result into a program. /// this result into a program.
/// ///
@ -721,36 +721,36 @@ public:
/// string itself. /// string itself.
CodeCompletionString *CreateCodeCompletionString(Sema &S, CodeCompletionString *CreateCodeCompletionString(Sema &S,
CodeCompletionAllocator &Allocator); CodeCompletionAllocator &Allocator);
/// \brief Determine a base priority for the given declaration. /// \brief Determine a base priority for the given declaration.
static unsigned getPriorityFromDecl(NamedDecl *ND); static unsigned getPriorityFromDecl(NamedDecl *ND);
private: private:
void computeCursorKindAndAvailability(bool Accessible = true); void computeCursorKindAndAvailability(bool Accessible = true);
}; };
bool operator<(const CodeCompletionResult &X, const CodeCompletionResult &Y); bool operator<(const CodeCompletionResult &X, const CodeCompletionResult &Y);
inline bool operator>(const CodeCompletionResult &X, inline bool operator>(const CodeCompletionResult &X,
const CodeCompletionResult &Y) { const CodeCompletionResult &Y) {
return Y < X; return Y < X;
} }
inline bool operator<=(const CodeCompletionResult &X, inline bool operator<=(const CodeCompletionResult &X,
const CodeCompletionResult &Y) { const CodeCompletionResult &Y) {
return !(Y < X); return !(Y < X);
} }
inline bool operator>=(const CodeCompletionResult &X, inline bool operator>=(const CodeCompletionResult &X,
const CodeCompletionResult &Y) { const CodeCompletionResult &Y) {
return !(X < Y); return !(X < Y);
} }
raw_ostream &operator<<(raw_ostream &OS, raw_ostream &operator<<(raw_ostream &OS,
const CodeCompletionString &CCS); const CodeCompletionString &CCS);
/// \brief Abstract interface for a consumer of code-completion /// \brief Abstract interface for a consumer of code-completion
/// information. /// information.
class CodeCompleteConsumer { class CodeCompleteConsumer {
protected: protected:
@ -760,15 +760,15 @@ protected:
/// \brief Whether to include code patterns (such as for loops) within /// \brief Whether to include code patterns (such as for loops) within
/// the completion results. /// the completion results.
bool IncludeCodePatterns; bool IncludeCodePatterns;
/// \brief Whether to include global (top-level) declarations and names in /// \brief Whether to include global (top-level) declarations and names in
/// the completion results. /// the completion results.
bool IncludeGlobals; bool IncludeGlobals;
/// \brief Whether the output format for the code-completion consumer is /// \brief Whether the output format for the code-completion consumer is
/// binary. /// binary.
bool OutputIsBinary; bool OutputIsBinary;
public: public:
class OverloadCandidate { class OverloadCandidate {
public: public:
@ -782,25 +782,25 @@ public:
/// for which we only have a function prototype. /// for which we only have a function prototype.
CK_FunctionType CK_FunctionType
}; };
private: private:
/// \brief The kind of overload candidate. /// \brief The kind of overload candidate.
CandidateKind Kind; CandidateKind Kind;
union { union {
/// \brief The function overload candidate, available when /// \brief The function overload candidate, available when
/// Kind == CK_Function. /// Kind == CK_Function.
FunctionDecl *Function; FunctionDecl *Function;
/// \brief The function template overload candidate, available when /// \brief The function template overload candidate, available when
/// Kind == CK_FunctionTemplate. /// Kind == CK_FunctionTemplate.
FunctionTemplateDecl *FunctionTemplate; FunctionTemplateDecl *FunctionTemplate;
/// \brief The function type that describes the entity being called, /// \brief The function type that describes the entity being called,
/// when Kind == CK_FunctionType. /// when Kind == CK_FunctionType.
const FunctionType *Type; const FunctionType *Type;
}; };
public: public:
OverloadCandidate(FunctionDecl *Function) OverloadCandidate(FunctionDecl *Function)
: Kind(CK_Function), Function(Function) { } : Kind(CK_Function), Function(Function) { }
@ -813,55 +813,55 @@ public:
/// \brief Determine the kind of overload candidate. /// \brief Determine the kind of overload candidate.
CandidateKind getKind() const { return Kind; } CandidateKind getKind() const { return Kind; }
/// \brief Retrieve the function overload candidate or the templated /// \brief Retrieve the function overload candidate or the templated
/// function declaration for a function template. /// function declaration for a function template.
FunctionDecl *getFunction() const; FunctionDecl *getFunction() const;
/// \brief Retrieve the function template overload candidate. /// \brief Retrieve the function template overload candidate.
FunctionTemplateDecl *getFunctionTemplate() const { FunctionTemplateDecl *getFunctionTemplate() const {
assert(getKind() == CK_FunctionTemplate && "Not a function template"); assert(getKind() == CK_FunctionTemplate && "Not a function template");
return FunctionTemplate; return FunctionTemplate;
} }
/// \brief Retrieve the function type of the entity, regardless of how the /// \brief Retrieve the function type of the entity, regardless of how the
/// function is stored. /// function is stored.
const FunctionType *getFunctionType() const; const FunctionType *getFunctionType() const;
/// \brief Create a new code-completion string that describes the function /// \brief Create a new code-completion string that describes the function
/// signature of this overload candidate. /// signature of this overload candidate.
CodeCompletionString *CreateSignatureString(unsigned CurrentArg, CodeCompletionString *CreateSignatureString(unsigned CurrentArg,
Sema &S, Sema &S,
CodeCompletionAllocator &Allocator) const; CodeCompletionAllocator &Allocator) const;
}; };
CodeCompleteConsumer() : IncludeMacros(false), IncludeCodePatterns(false), CodeCompleteConsumer() : IncludeMacros(false), IncludeCodePatterns(false),
IncludeGlobals(true), OutputIsBinary(false) { } IncludeGlobals(true), OutputIsBinary(false) { }
CodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns, CodeCompleteConsumer(bool IncludeMacros, bool IncludeCodePatterns,
bool IncludeGlobals, bool OutputIsBinary) bool IncludeGlobals, bool OutputIsBinary)
: IncludeMacros(IncludeMacros), IncludeCodePatterns(IncludeCodePatterns), : IncludeMacros(IncludeMacros), IncludeCodePatterns(IncludeCodePatterns),
IncludeGlobals(IncludeGlobals), OutputIsBinary(OutputIsBinary) { } IncludeGlobals(IncludeGlobals), OutputIsBinary(OutputIsBinary) { }
/// \brief Whether the code-completion consumer wants to see macros. /// \brief Whether the code-completion consumer wants to see macros.
bool includeMacros() const { return IncludeMacros; } bool includeMacros() const { return IncludeMacros; }
/// \brief Whether the code-completion consumer wants to see code patterns. /// \brief Whether the code-completion consumer wants to see code patterns.
bool includeCodePatterns() const { return IncludeCodePatterns; } bool includeCodePatterns() const { return IncludeCodePatterns; }
/// \brief Whether to include global (top-level) declaration results. /// \brief Whether to include global (top-level) declaration results.
bool includeGlobals() const { return IncludeGlobals; } bool includeGlobals() const { return IncludeGlobals; }
/// \brief Determine whether the output of this consumer is binary. /// \brief Determine whether the output of this consumer is binary.
bool isOutputBinary() const { return OutputIsBinary; } bool isOutputBinary() const { return OutputIsBinary; }
/// \brief Deregisters and destroys this code-completion consumer. /// \brief Deregisters and destroys this code-completion consumer.
virtual ~CodeCompleteConsumer(); virtual ~CodeCompleteConsumer();
/// \name Code-completion callbacks /// \name Code-completion callbacks
//@{ //@{
/// \brief Process the finalized code-completion results. /// \brief Process the finalized code-completion results.
virtual void ProcessCodeCompleteResults(Sema &S, virtual void ProcessCodeCompleteResults(Sema &S,
CodeCompletionContext Context, CodeCompletionContext Context,
CodeCompletionResult *Results, CodeCompletionResult *Results,
unsigned NumResults) { } unsigned NumResults) { }
@ -878,20 +878,20 @@ public:
OverloadCandidate *Candidates, OverloadCandidate *Candidates,
unsigned NumCandidates) { } unsigned NumCandidates) { }
//@} //@}
/// \brief Retrieve the allocator that will be used to allocate /// \brief Retrieve the allocator that will be used to allocate
/// code completion strings. /// code completion strings.
virtual CodeCompletionAllocator &getAllocator() = 0; virtual CodeCompletionAllocator &getAllocator() = 0;
}; };
/// \brief A simple code-completion consumer that prints the results it /// \brief A simple code-completion consumer that prints the results it
/// receives in a simple format. /// receives in a simple format.
class PrintingCodeCompleteConsumer : public CodeCompleteConsumer { class PrintingCodeCompleteConsumer : public CodeCompleteConsumer {
/// \brief The raw output stream. /// \brief The raw output stream.
raw_ostream &OS; raw_ostream &OS;
CodeCompletionAllocator Allocator; CodeCompletionAllocator Allocator;
public: public:
/// \brief Create a new printing code-completion consumer that prints its /// \brief Create a new printing code-completion consumer that prints its
/// results to the given raw output stream. /// results to the given raw output stream.
@ -900,20 +900,20 @@ public:
raw_ostream &OS) raw_ostream &OS)
: CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals, : CodeCompleteConsumer(IncludeMacros, IncludeCodePatterns, IncludeGlobals,
false), OS(OS) {} false), OS(OS) {}
/// \brief Prints the finalized code-completion results. /// \brief Prints the finalized code-completion results.
virtual void ProcessCodeCompleteResults(Sema &S, virtual void ProcessCodeCompleteResults(Sema &S,
CodeCompletionContext Context, CodeCompletionContext Context,
CodeCompletionResult *Results, CodeCompletionResult *Results,
unsigned NumResults); unsigned NumResults);
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
OverloadCandidate *Candidates, OverloadCandidate *Candidates,
unsigned NumCandidates); unsigned NumCandidates);
virtual CodeCompletionAllocator &getAllocator() { return Allocator; } virtual CodeCompletionAllocator &getAllocator() { return Allocator; }
}; };
} // end namespace clang } // end namespace clang
#endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H #endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H

View File

@ -36,16 +36,16 @@ class LocInfoType : public Type {
TypeSourceInfo *DeclInfo; TypeSourceInfo *DeclInfo;
LocInfoType(QualType ty, TypeSourceInfo *TInfo) LocInfoType(QualType ty, TypeSourceInfo *TInfo)
: Type((TypeClass)LocInfo, ty, ty->isDependentType(), : Type((TypeClass)LocInfo, ty, ty->isDependentType(),
ty->isInstantiationDependentType(), ty->isInstantiationDependentType(),
ty->isVariablyModifiedType(), ty->isVariablyModifiedType(),
ty->containsUnexpandedParameterPack()), ty->containsUnexpandedParameterPack()),
DeclInfo(TInfo) { DeclInfo(TInfo) {
assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?"); assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
} }
friend class Sema; friend class Sema;
public: public:
QualType getType() const { return getCanonicalTypeInternal(); } QualType getType() const { return getCanonicalTypeInternal(); }
TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; } TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }

View File

@ -33,9 +33,10 @@ class PrettyDeclStackTraceEntry : public llvm::PrettyStackTraceEntry {
Decl *TheDecl; Decl *TheDecl;
SourceLocation Loc; SourceLocation Loc;
const char *Message; const char *Message;
public: public:
PrettyDeclStackTraceEntry(Sema &S, Decl *D, SourceLocation Loc, const char *Msg) PrettyDeclStackTraceEntry(Sema &S, Decl *D, SourceLocation Loc,
const char *Msg)
: S(S), TheDecl(D), Loc(Loc), Message(Msg) {} : S(S), TheDecl(D), Loc(Loc), Message(Msg) {}
virtual void print(raw_ostream &OS) const; virtual void print(raw_ostream &OS) const;

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@ class ASTContext;
class TemplateArgumentList; class TemplateArgumentList;
namespace sema { namespace sema {
/// \brief Provides information about an attempted template argument /// \brief Provides information about an attempted template argument
/// deduction, whose success or failure was described by a /// deduction, whose success or failure was described by a
/// TemplateDeductionResult value. /// TemplateDeductionResult value.
@ -39,10 +39,10 @@ class TemplateDeductionInfo {
/// deduction is occurring. /// deduction is occurring.
SourceLocation Loc; SourceLocation Loc;
/// \brief Warnings (and follow-on notes) that were suppressed due to /// \brief Warnings (and follow-on notes) that were suppressed due to
/// SFINAE while performing template argument deduction. /// SFINAE while performing template argument deduction.
SmallVector<PartialDiagnosticAt, 4> SuppressedDiagnostics; SmallVector<PartialDiagnosticAt, 4> SuppressedDiagnostics;
// do not implement these // do not implement these
TemplateDeductionInfo(const TemplateDeductionInfo&); TemplateDeductionInfo(const TemplateDeductionInfo&);
TemplateDeductionInfo &operator=(const TemplateDeductionInfo&); TemplateDeductionInfo &operator=(const TemplateDeductionInfo&);
@ -75,23 +75,24 @@ public:
Deduced = NewDeduced; Deduced = NewDeduced;
} }
/// \brief Add a new diagnostic to the set of diagnostics /// \brief Add a new diagnostic to the set of diagnostics
void addSuppressedDiagnostic(SourceLocation Loc, const PartialDiagnostic &PD) { void addSuppressedDiagnostic(SourceLocation Loc,
const PartialDiagnostic &PD) {
SuppressedDiagnostics.push_back(std::make_pair(Loc, PD)); SuppressedDiagnostics.push_back(std::make_pair(Loc, PD));
} }
/// \brief Iterator over the set of suppressed diagnostics. /// \brief Iterator over the set of suppressed diagnostics.
typedef SmallVectorImpl<PartialDiagnosticAt>::const_iterator typedef SmallVectorImpl<PartialDiagnosticAt>::const_iterator
diag_iterator; diag_iterator;
/// \brief Returns an iterator at the beginning of the sequence of suppressed /// \brief Returns an iterator at the beginning of the sequence of suppressed
/// diagnostics. /// diagnostics.
diag_iterator diag_begin() const { return SuppressedDiagnostics.begin(); } diag_iterator diag_begin() const { return SuppressedDiagnostics.begin(); }
/// \brief Returns an iterator at the end of the sequence of suppressed /// \brief Returns an iterator at the end of the sequence of suppressed
/// diagnostics. /// diagnostics.
diag_iterator diag_end() const { return SuppressedDiagnostics.end(); } diag_iterator diag_end() const { return SuppressedDiagnostics.end(); }
/// \brief The template parameter to which a template argument /// \brief The template parameter to which a template argument
/// deduction failure refers. /// deduction failure refers.
/// ///

View File

@ -162,16 +162,16 @@ private:
void Error(const char *Msg); void Error(const char *Msg);
}; };
namespace serialization { namespace serialization {
class ReadMethodPoolVisitor; class ReadMethodPoolVisitor;
namespace reader { namespace reader {
class ASTIdentifierLookupTrait; class ASTIdentifierLookupTrait;
} }
} // end namespace serialization } // end namespace serialization
/// \brief Reads an AST files chain containing the contents of a translation /// \brief Reads an AST files chain containing the contents of a translation
/// unit. /// unit.
/// ///
@ -191,7 +191,7 @@ class ASTReader
public ExternalSemaSource, public ExternalSemaSource,
public IdentifierInfoLookup, public IdentifierInfoLookup,
public ExternalIdentifierLookup, public ExternalIdentifierLookup,
public ExternalSLocEntrySource public ExternalSLocEntrySource
{ {
public: public:
enum ASTReadResult { Success, Failure, IgnorePCH }; enum ASTReadResult { Success, Failure, IgnorePCH };
@ -205,11 +205,11 @@ public:
friend class ASTWriter; friend class ASTWriter;
friend class ASTUnit; // ASTUnit needs to remap source locations. friend class ASTUnit; // ASTUnit needs to remap source locations.
friend class serialization::ReadMethodPoolVisitor; friend class serialization::ReadMethodPoolVisitor;
typedef serialization::Module Module; typedef serialization::Module Module;
typedef serialization::ModuleKind ModuleKind; typedef serialization::ModuleKind ModuleKind;
typedef serialization::ModuleManager ModuleManager; typedef serialization::ModuleManager ModuleManager;
typedef ModuleManager::ModuleIterator ModuleIterator; typedef ModuleManager::ModuleIterator ModuleIterator;
typedef ModuleManager::ModuleConstIterator ModuleConstIterator; typedef ModuleManager::ModuleConstIterator ModuleConstIterator;
typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator; typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator;
@ -224,7 +224,7 @@ private:
SourceManager &SourceMgr; SourceManager &SourceMgr;
FileManager &FileMgr; FileManager &FileMgr;
DiagnosticsEngine &Diags; DiagnosticsEngine &Diags;
/// \brief The semantic analysis object that will be processing the /// \brief The semantic analysis object that will be processing the
/// AST files and the translation unit that uses it. /// AST files and the translation unit that uses it.
Sema *SemaObj; Sema *SemaObj;
@ -234,7 +234,7 @@ private:
/// \brief The AST context into which we'll read the AST files. /// \brief The AST context into which we'll read the AST files.
ASTContext &Context; ASTContext &Context;
/// \brief The AST consumer. /// \brief The AST consumer.
ASTConsumer *Consumer; ASTConsumer *Consumer;
@ -249,11 +249,11 @@ private:
ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocEntryMap; ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocEntryMap;
typedef ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocOffsetMapType; typedef ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocOffsetMapType;
/// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset) /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
/// SourceLocation offsets to the modules containing them. /// SourceLocation offsets to the modules containing them.
GlobalSLocOffsetMapType GlobalSLocOffsetMap; GlobalSLocOffsetMapType GlobalSLocOffsetMap;
/// \brief Types that have already been loaded from the chain. /// \brief Types that have already been loaded from the chain.
/// ///
/// When the pointer at index I is non-NULL, the type with /// When the pointer at index I is non-NULL, the type with
@ -274,18 +274,18 @@ private:
/// = I + 1 has already been loaded. /// = I + 1 has already been loaded.
std::vector<Decl *> DeclsLoaded; std::vector<Decl *> DeclsLoaded;
typedef ContinuousRangeMap<serialization::DeclID, Module *, 4> typedef ContinuousRangeMap<serialization::DeclID, Module *, 4>
GlobalDeclMapType; GlobalDeclMapType;
/// \brief Mapping from global declaration IDs to the module in which the /// \brief Mapping from global declaration IDs to the module in which the
/// declaration resides. /// declaration resides.
GlobalDeclMapType GlobalDeclMap; GlobalDeclMapType GlobalDeclMap;
typedef std::pair<Module *, uint64_t> FileOffset; typedef std::pair<Module *, uint64_t> FileOffset;
typedef SmallVector<FileOffset, 2> FileOffsetsTy; typedef SmallVector<FileOffset, 2> FileOffsetsTy;
typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy> typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
DeclUpdateOffsetsMap; DeclUpdateOffsetsMap;
/// \brief Declarations that have modifications residing in a later file /// \brief Declarations that have modifications residing in a later file
/// in the chain. /// in the chain.
DeclUpdateOffsetsMap DeclUpdateOffsets; DeclUpdateOffsetsMap DeclUpdateOffsets;
@ -348,7 +348,7 @@ private:
llvm::DenseSet<serialization::GlobalDeclID> ObjCChainedCategoriesInterfaces; llvm::DenseSet<serialization::GlobalDeclID> ObjCChainedCategoriesInterfaces;
/// \brief Read the records that describe the contents of declcontexts. /// \brief Read the records that describe the contents of declcontexts.
bool ReadDeclContextStorage(Module &M, bool ReadDeclContextStorage(Module &M,
llvm::BitstreamCursor &Cursor, llvm::BitstreamCursor &Cursor,
const std::pair<uint64_t, uint64_t> &Offsets, const std::pair<uint64_t, uint64_t> &Offsets,
serialization::DeclContextInfo &Info); serialization::DeclContextInfo &Info);
@ -361,9 +361,9 @@ private:
/// been loaded. /// been loaded.
std::vector<IdentifierInfo *> IdentifiersLoaded; std::vector<IdentifierInfo *> IdentifiersLoaded;
typedef ContinuousRangeMap<serialization::IdentID, Module *, 4> typedef ContinuousRangeMap<serialization::IdentID, Module *, 4>
GlobalIdentifierMapType; GlobalIdentifierMapType;
/// \brief Mapping from global identifer IDs to the module in which the /// \brief Mapping from global identifer IDs to the module in which the
/// identifier resides along with the offset that should be added to the /// identifier resides along with the offset that should be added to the
/// global identifier ID to produce a local ID. /// global identifier ID to produce a local ID.
@ -376,9 +376,9 @@ private:
/// been loaded. /// been loaded.
SmallVector<Selector, 16> SelectorsLoaded; SmallVector<Selector, 16> SelectorsLoaded;
typedef ContinuousRangeMap<serialization::SelectorID, Module *, 4> typedef ContinuousRangeMap<serialization::SelectorID, Module *, 4>
GlobalSelectorMapType; GlobalSelectorMapType;
/// \brief Mapping from global selector IDs to the module in which the /// \brief Mapping from global selector IDs to the module in which the
/// selector resides along with the offset that should be added to the /// selector resides along with the offset that should be added to the
/// global selector ID to produce a local ID. /// global selector ID to produce a local ID.
@ -389,14 +389,14 @@ private:
/// record resides. /// record resides.
llvm::DenseMap<IdentifierInfo *, uint64_t> UnreadMacroRecordOffsets; llvm::DenseMap<IdentifierInfo *, uint64_t> UnreadMacroRecordOffsets;
typedef ContinuousRangeMap<unsigned, Module *, 4> typedef ContinuousRangeMap<unsigned, Module *, 4>
GlobalPreprocessedEntityMapType; GlobalPreprocessedEntityMapType;
/// \brief Mapping from global preprocessing entity IDs to the module in /// \brief Mapping from global preprocessing entity IDs to the module in
/// which the preprocessed entity resides along with the offset that should be /// which the preprocessed entity resides along with the offset that should be
/// added to the global preprocessing entitiy ID to produce a local ID. /// added to the global preprocessing entitiy ID to produce a local ID.
GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap; GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
/// \name CodeGen-relevant special data /// \name CodeGen-relevant special data
/// \brief Fields containing data that is relevant to CodeGen. /// \brief Fields containing data that is relevant to CodeGen.
//@{ //@{
@ -444,7 +444,7 @@ private:
/// \brief A list of all the delegating constructors we've seen, to diagnose /// \brief A list of all the delegating constructors we've seen, to diagnose
/// cycles. /// cycles.
SmallVector<uint64_t, 4> DelegatingCtorDecls; SmallVector<uint64_t, 4> DelegatingCtorDecls;
/// \brief Method selectors used in a @selector expression. Used for /// \brief Method selectors used in a @selector expression. Used for
/// implementation of -Wselector. /// implementation of -Wselector.
SmallVector<uint64_t, 64> ReferencedSelectorsData; SmallVector<uint64_t, 64> ReferencedSelectorsData;
@ -514,7 +514,7 @@ private:
/// \brief The file ID for the original file that was used to build the /// \brief The file ID for the original file that was used to build the
/// primary AST file. /// primary AST file.
FileID OriginalFileID; FileID OriginalFileID;
/// \brief The directory that the PCH was originally created in. Used to /// \brief The directory that the PCH was originally created in. Used to
/// allow resolving headers even after headers+PCH was moved to a new path. /// allow resolving headers even after headers+PCH was moved to a new path.
std::string OriginalDir; std::string OriginalDir;
@ -532,7 +532,7 @@ private:
/// \brief Whether to disable the normal validation performed on precompiled /// \brief Whether to disable the normal validation performed on precompiled
/// headers when they are loaded. /// headers when they are loaded.
bool DisableValidation; bool DisableValidation;
/// \brief Whether to disable the use of stat caches in AST files. /// \brief Whether to disable the use of stat caches in AST files.
bool DisableStatCache; bool DisableStatCache;
@ -588,7 +588,7 @@ private:
/// Number of visible decl contexts read/total. /// Number of visible decl contexts read/total.
unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts; unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts;
/// Total size of modules, in bits, currently loaded /// Total size of modules, in bits, currently loaded
uint64_t TotalModulesSizeInBits; uint64_t TotalModulesSizeInBits;
@ -635,7 +635,7 @@ private:
Read_Decl, Read_Type, Read_Stmt Read_Decl, Read_Type, Read_Stmt
}; };
/// \brief What kind of records we are reading. /// \brief What kind of records we are reading.
ReadingKind ReadingKind; ReadingKind ReadingKind;
/// \brief RAII object to change the reading kind. /// \brief RAII object to change the reading kind.
@ -705,7 +705,7 @@ private:
void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D); void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D);
void loadObjCChainedCategories(serialization::GlobalDeclID ID, void loadObjCChainedCategories(serialization::GlobalDeclID ID,
ObjCInterfaceDecl *D); ObjCInterfaceDecl *D);
RecordLocation getLocalBitOffset(uint64_t GlobalOffset); RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
uint64_t getGlobalBitOffset(Module &M, uint32_t LocalOffset); uint64_t getGlobalBitOffset(Module &M, uint32_t LocalOffset);
@ -713,7 +713,8 @@ private:
serialization::PreprocessedEntityID serialization::PreprocessedEntityID
findBeginPreprocessedEntity(SourceLocation BLoc) const; findBeginPreprocessedEntity(SourceLocation BLoc) const;
/// \brief Returns the first preprocessed entity ID that begins after \arg ELoc. /// \brief Returns the first preprocessed entity ID that begins after \arg
/// ELoc.
serialization::PreprocessedEntityID serialization::PreprocessedEntityID
findEndPreprocessedEntity(SourceLocation ELoc) const; findEndPreprocessedEntity(SourceLocation ELoc) const;
@ -773,7 +774,7 @@ public:
~ASTReader(); ~ASTReader();
SourceManager &getSourceManager() const { return SourceMgr; } SourceManager &getSourceManager() const { return SourceMgr; }
/// \brief Load the AST file designated by the given file name. /// \brief Load the AST file designated by the given file name.
ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type); ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type);
@ -802,7 +803,7 @@ public:
/// \brief Retrieve the preprocessor. /// \brief Retrieve the preprocessor.
Preprocessor &getPreprocessor() const { return PP; } Preprocessor &getPreprocessor() const { return PP; }
/// \brief Retrieve the name of the original source file name /// \brief Retrieve the name of the original source file name
const std::string &getOriginalSourceFile() { return OriginalFileName; } const std::string &getOriginalSourceFile() { return OriginalFileName; }
@ -827,7 +828,7 @@ public:
/// preprocessed entities that \arg Range encompasses. /// preprocessed entities that \arg Range encompasses.
virtual std::pair<unsigned, unsigned> virtual std::pair<unsigned, unsigned>
findPreprocessedEntitiesInRange(SourceRange Range); findPreprocessedEntitiesInRange(SourceRange Range);
/// \brief Optionally returns true or false if the preallocated preprocessed /// \brief Optionally returns true or false if the preallocated preprocessed
/// entity with index \arg Index came from file \arg FID. /// entity with index \arg Index came from file \arg FID.
virtual llvm::Optional<bool> isPreprocessedEntityInFileID(unsigned Index, virtual llvm::Optional<bool> isPreprocessedEntityInFileID(unsigned Index,
@ -871,15 +872,15 @@ public:
E = ModuleMgr.end(); I != E; ++I) { E = ModuleMgr.end(); I != E; ++I) {
Result += (*I)->NumPreprocessedEntities; Result += (*I)->NumPreprocessedEntities;
} }
return Result; return Result;
} }
/// \brief Returns the number of C++ base specifiers found in the chain. /// \brief Returns the number of C++ base specifiers found in the chain.
unsigned getTotalNumCXXBaseSpecifiers() const { unsigned getTotalNumCXXBaseSpecifiers() const {
return NumCXXBaseSpecifiersLoaded; return NumCXXBaseSpecifiersLoaded;
} }
/// \brief Reads a TemplateArgumentLocInfo appropriate for the /// \brief Reads a TemplateArgumentLocInfo appropriate for the
/// given TemplateArgument kind. /// given TemplateArgument kind.
TemplateArgumentLocInfo TemplateArgumentLocInfo
@ -901,20 +902,20 @@ public:
/// \brief Resolve a local type ID within a given AST file into a type. /// \brief Resolve a local type ID within a given AST file into a type.
QualType getLocalType(Module &F, unsigned LocalID); QualType getLocalType(Module &F, unsigned LocalID);
/// \brief Map a local type ID within a given AST file into a global type ID. /// \brief Map a local type ID within a given AST file into a global type ID.
serialization::TypeID getGlobalTypeID(Module &F, unsigned LocalID) const; serialization::TypeID getGlobalTypeID(Module &F, unsigned LocalID) const;
/// \brief Read a type from the current position in the given record, which /// \brief Read a type from the current position in the given record, which
/// was read from the given AST file. /// was read from the given AST file.
QualType readType(Module &F, const RecordData &Record, unsigned &Idx) { QualType readType(Module &F, const RecordData &Record, unsigned &Idx) {
if (Idx >= Record.size()) if (Idx >= Record.size())
return QualType(); return QualType();
return getLocalType(F, Record[Idx++]); return getLocalType(F, Record[Idx++]);
} }
/// \brief Map from a local declaration ID within a given module to a /// \brief Map from a local declaration ID within a given module to a
/// global declaration ID. /// global declaration ID.
serialization::DeclID getGlobalDeclID(Module &F, unsigned LocalID) const; serialization::DeclID getGlobalDeclID(Module &F, unsigned LocalID) const;
@ -924,7 +925,7 @@ public:
/// \brief Returns the source location for the decl \arg ID. /// \brief Returns the source location for the decl \arg ID.
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID); SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID);
/// \brief Resolve a declaration ID into a declaration, potentially /// \brief Resolve a declaration ID into a declaration, potentially
/// building a new declaration. /// building a new declaration.
Decl *GetDecl(serialization::DeclID ID); Decl *GetDecl(serialization::DeclID ID);
@ -943,19 +944,19 @@ public:
return cast_or_null<T>(GetLocalDecl(F, LocalID)); return cast_or_null<T>(GetLocalDecl(F, LocalID));
} }
/// \brief Reads a declaration ID from the given position in a record in the /// \brief Reads a declaration ID from the given position in a record in the
/// given module. /// given module.
/// ///
/// \returns The declaration ID read from the record, adjusted to a global ID. /// \returns The declaration ID read from the record, adjusted to a global ID.
serialization::DeclID ReadDeclID(Module &F, const RecordData &Record, serialization::DeclID ReadDeclID(Module &F, const RecordData &Record,
unsigned &Idx); unsigned &Idx);
/// \brief Reads a declaration from the given position in a record in the /// \brief Reads a declaration from the given position in a record in the
/// given module. /// given module.
Decl *ReadDecl(Module &F, const RecordData &R, unsigned &I) { Decl *ReadDecl(Module &F, const RecordData &R, unsigned &I) {
return GetDecl(ReadDeclID(F, R, I)); return GetDecl(ReadDeclID(F, R, I));
} }
/// \brief Reads a declaration from the given position in a record in the /// \brief Reads a declaration from the given position in a record in the
/// given module. /// given module.
/// ///
@ -968,11 +969,11 @@ public:
/// \brief Read a CXXBaseSpecifiers ID form the given record and /// \brief Read a CXXBaseSpecifiers ID form the given record and
/// return its global bit offset. /// return its global bit offset.
uint64_t readCXXBaseSpecifiers(Module &M, const RecordData &Record, uint64_t readCXXBaseSpecifiers(Module &M, const RecordData &Record,
unsigned &Idx); unsigned &Idx);
virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset);
/// \brief Resolve the offset of a statement into a statement. /// \brief Resolve the offset of a statement into a statement.
/// ///
/// This operation will read a new statement from the external /// This operation will read a new statement from the external
@ -1011,7 +1012,7 @@ public:
/// \brief Get the decls that are contained in a file in the Offset/Length /// \brief Get the decls that are contained in a file in the Offset/Length
/// range. \arg Length can be 0 to indicate a point at \arg Offset instead of /// range. \arg Length can be 0 to indicate a point at \arg Offset instead of
/// a range. /// a range.
virtual void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, virtual void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length,
SmallVectorImpl<Decl *> &Decls); SmallVectorImpl<Decl *> &Decls);
@ -1036,7 +1037,7 @@ public:
/// \brief Dump information about the AST reader to standard error. /// \brief Dump information about the AST reader to standard error.
void dump(); void dump();
/// Return the amount of memory used by memory buffers, breaking down /// Return the amount of memory used by memory buffers, breaking down
/// by heap-backed versus mmap'ed memory. /// by heap-backed versus mmap'ed memory.
virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const;
@ -1092,7 +1093,7 @@ public:
virtual void ReadLocallyScopedExternalDecls( virtual void ReadLocallyScopedExternalDecls(
SmallVectorImpl<NamedDecl *> &Decls); SmallVectorImpl<NamedDecl *> &Decls);
virtual void ReadReferencedSelectors( virtual void ReadReferencedSelectors(
SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels); SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels);
@ -1102,7 +1103,7 @@ public:
virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables); virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables);
virtual void ReadPendingInstantiations( virtual void ReadPendingInstantiations(
SmallVectorImpl<std::pair<ValueDecl *, SmallVectorImpl<std::pair<ValueDecl *,
SourceLocation> > &Pending); SourceLocation> > &Pending);
/// \brief Load a selector from disk, registering its ID if it exists. /// \brief Load a selector from disk, registering its ID if it exists.
@ -1121,7 +1122,7 @@ public:
IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID); IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID);
IdentifierInfo *GetIdentifierInfo(Module &M, const RecordData &Record, IdentifierInfo *GetIdentifierInfo(Module &M, const RecordData &Record,
unsigned &Idx) { unsigned &Idx) {
return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++])); return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]));
} }
@ -1131,10 +1132,10 @@ public:
} }
IdentifierInfo *getLocalIdentifier(Module &M, unsigned LocalID); IdentifierInfo *getLocalIdentifier(Module &M, unsigned LocalID);
serialization::IdentifierID getGlobalIdentifierID(Module &M, serialization::IdentifierID getGlobalIdentifierID(Module &M,
unsigned LocalID); unsigned LocalID);
/// \brief Read the source location entry with index ID. /// \brief Read the source location entry with index ID.
virtual bool ReadSLocEntry(int ID); virtual bool ReadSLocEntry(int ID);
@ -1150,14 +1151,14 @@ public:
Selector ReadSelector(Module &M, const RecordData &Record, unsigned &Idx) { Selector ReadSelector(Module &M, const RecordData &Record, unsigned &Idx) {
return getLocalSelector(M, Record[Idx++]); return getLocalSelector(M, Record[Idx++]);
} }
/// \brief Retrieve the global selector ID that corresponds to this /// \brief Retrieve the global selector ID that corresponds to this
/// the local selector ID in a given module. /// the local selector ID in a given module.
serialization::SelectorID getGlobalSelectorID(Module &F, serialization::SelectorID getGlobalSelectorID(Module &F,
unsigned LocalID) const; unsigned LocalID) const;
/// \brief Read a declaration name. /// \brief Read a declaration name.
DeclarationName ReadDeclarationName(Module &F, DeclarationName ReadDeclarationName(Module &F,
const RecordData &Record, unsigned &Idx); const RecordData &Record, unsigned &Idx);
void ReadDeclarationNameLoc(Module &F, void ReadDeclarationNameLoc(Module &F,
DeclarationNameLoc &DNLoc, DeclarationName Name, DeclarationNameLoc &DNLoc, DeclarationName Name,
@ -1172,23 +1173,23 @@ public:
const RecordData &Record, const RecordData &Record,
unsigned &Idx); unsigned &Idx);
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(Module &F, NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(Module &F,
const RecordData &Record, const RecordData &Record,
unsigned &Idx); unsigned &Idx);
/// \brief Read a template name. /// \brief Read a template name.
TemplateName ReadTemplateName(Module &F, const RecordData &Record, TemplateName ReadTemplateName(Module &F, const RecordData &Record,
unsigned &Idx); unsigned &Idx);
/// \brief Read a template argument. /// \brief Read a template argument.
TemplateArgument ReadTemplateArgument(Module &F, TemplateArgument ReadTemplateArgument(Module &F,
const RecordData &Record,unsigned &Idx); const RecordData &Record,unsigned &Idx);
/// \brief Read a template parameter list. /// \brief Read a template parameter list.
TemplateParameterList *ReadTemplateParameterList(Module &F, TemplateParameterList *ReadTemplateParameterList(Module &F,
const RecordData &Record, const RecordData &Record,
unsigned &Idx); unsigned &Idx);
/// \brief Read a template argument array. /// \brief Read a template argument array.
void void
ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs, ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs,
@ -1242,9 +1243,9 @@ public:
/// \brief Read a version tuple. /// \brief Read a version tuple.
VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx); VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx);
CXXTemporary *ReadCXXTemporary(Module &F, const RecordData &Record, CXXTemporary *ReadCXXTemporary(Module &F, const RecordData &Record,
unsigned &Idx); unsigned &Idx);
/// \brief Reads attributes from the current stream position. /// \brief Reads attributes from the current stream position.
void ReadAttributes(Module &F, AttrVec &Attrs, void ReadAttributes(Module &F, AttrVec &Attrs,
const RecordData &Record, unsigned &Idx); const RecordData &Record, unsigned &Idx);
@ -1270,17 +1271,17 @@ public:
/// \brief Reads the macro record located at the given offset. /// \brief Reads the macro record located at the given offset.
void ReadMacroRecord(Module &F, uint64_t Offset); void ReadMacroRecord(Module &F, uint64_t Offset);
/// \brief Determine the global preprocessed entity ID that corresponds to /// \brief Determine the global preprocessed entity ID that corresponds to
/// the given local ID within the given module. /// the given local ID within the given module.
serialization::PreprocessedEntityID serialization::PreprocessedEntityID
getGlobalPreprocessedEntityID(Module &M, unsigned LocalID) const; getGlobalPreprocessedEntityID(Module &M, unsigned LocalID) const;
/// \brief Note that the identifier is a macro whose record will be loaded /// \brief Note that the identifier is a macro whose record will be loaded
/// from the given AST file at the given (file-local) offset. /// from the given AST file at the given (file-local) offset.
void SetIdentifierIsMacro(IdentifierInfo *II, Module &F, void SetIdentifierIsMacro(IdentifierInfo *II, Module &F,
uint64_t Offset); uint64_t Offset);
/// \brief Read the set of macros defined by this external macro source. /// \brief Read the set of macros defined by this external macro source.
virtual void ReadDefinedMacros(); virtual void ReadDefinedMacros();
@ -1294,7 +1295,7 @@ public:
/// into the unread macro record offsets table. /// into the unread macro record offsets table.
void LoadMacroDefinition( void LoadMacroDefinition(
llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos); llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos);
/// \brief Retrieve the AST context that this AST reader supplements. /// \brief Retrieve the AST context that this AST reader supplements.
ASTContext &getContext() { return Context; } ASTContext &getContext() { return Context; }

View File

@ -84,7 +84,7 @@ private:
/// allow for the const/volatile qualifiers. /// allow for the const/volatile qualifiers.
/// ///
/// Keys in the map never have const/volatile qualifiers. /// Keys in the map never have const/volatile qualifiers.
typedef llvm::DenseMap<QualType, serialization::TypeIdx, typedef llvm::DenseMap<QualType, serialization::TypeIdx,
serialization::UnsafeQualTypeDenseMapInfo> serialization::UnsafeQualTypeDenseMapInfo>
TypeIdxMap; TypeIdxMap;
@ -93,33 +93,33 @@ private:
/// \brief The ASTContext we're writing. /// \brief The ASTContext we're writing.
ASTContext *Context; ASTContext *Context;
/// \brief The reader of existing AST files, if we're chaining. /// \brief The reader of existing AST files, if we're chaining.
ASTReader *Chain; ASTReader *Chain;
/// \brief Indicates when the AST writing is actively performing /// \brief Indicates when the AST writing is actively performing
/// serialization, rather than just queueing updates. /// serialization, rather than just queueing updates.
bool WritingAST; bool WritingAST;
/// \brief Stores a declaration or a type to be written to the AST file. /// \brief Stores a declaration or a type to be written to the AST file.
class DeclOrType { class DeclOrType {
public: public:
DeclOrType(Decl *D) : Stored(D), IsType(false) { } DeclOrType(Decl *D) : Stored(D), IsType(false) { }
DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) { } DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) { }
bool isType() const { return IsType; } bool isType() const { return IsType; }
bool isDecl() const { return !IsType; } bool isDecl() const { return !IsType; }
QualType getType() const { QualType getType() const {
assert(isType() && "Not a type!"); assert(isType() && "Not a type!");
return QualType::getFromOpaquePtr(Stored); return QualType::getFromOpaquePtr(Stored);
} }
Decl *getDecl() const { Decl *getDecl() const {
assert(isDecl() && "Not a decl!"); assert(isDecl() && "Not a decl!");
return static_cast<Decl *>(Stored); return static_cast<Decl *>(Stored);
} }
private: private:
void *Stored; void *Stored;
bool IsType; bool IsType;
@ -215,7 +215,7 @@ private:
/// \brief Offset of each selector within the method pool/selector /// \brief Offset of each selector within the method pool/selector
/// table, indexed by the Selector ID (-1). /// table, indexed by the Selector ID (-1).
std::vector<uint32_t> SelectorOffsets; std::vector<uint32_t> SelectorOffsets;
/// \brief Offsets of each of the macro identifiers into the /// \brief Offsets of each of the macro identifiers into the
/// bitstream. /// bitstream.
/// ///
@ -226,7 +226,7 @@ private:
/// \brief The set of identifiers that had macro definitions at some point. /// \brief The set of identifiers that had macro definitions at some point.
std::vector<const IdentifierInfo *> DeserializedMacroNames; std::vector<const IdentifierInfo *> DeserializedMacroNames;
/// \brief Mapping from macro definitions (as they occur in the preprocessing /// \brief Mapping from macro definitions (as they occur in the preprocessing
/// record) to the macro IDs. /// record) to the macro IDs.
llvm::DenseMap<const MacroDefinition *, serialization::PreprocessedEntityID> llvm::DenseMap<const MacroDefinition *, serialization::PreprocessedEntityID>
@ -242,7 +242,7 @@ private:
/// \brief Map of first declarations from a chained PCH that point to the /// \brief Map of first declarations from a chained PCH that point to the
/// most recent declarations in another PCH. /// most recent declarations in another PCH.
FirstLatestDeclMap FirstLatestDecls; FirstLatestDeclMap FirstLatestDecls;
/// \brief Declarations encountered that might be external /// \brief Declarations encountered that might be external
/// definitions. /// definitions.
/// ///
@ -260,9 +260,10 @@ private:
/// \brief DeclContexts that have received extensions since their serialized /// \brief DeclContexts that have received extensions since their serialized
/// form. /// form.
/// ///
/// For namespaces, when we're chaining and encountering a namespace, we check if /// For namespaces, when we're chaining and encountering a namespace, we check
/// its primary namespace comes from the chain. If it does, we add the primary /// if its primary namespace comes from the chain. If it does, we add the
/// to this set, so that we can write out lexical content updates for it. /// primary to this set, so that we can write out lexical content updates for
/// it.
llvm::SmallPtrSet<const DeclContext *, 16> UpdatedDeclContexts; llvm::SmallPtrSet<const DeclContext *, 16> UpdatedDeclContexts;
typedef llvm::SmallPtrSet<const Decl *, 16> DeclsToRewriteTy; typedef llvm::SmallPtrSet<const Decl *, 16> DeclsToRewriteTy;
@ -275,10 +276,10 @@ private:
/// \brief The local tail category ID that got chained to the imported /// \brief The local tail category ID that got chained to the imported
/// interface. /// interface.
const ObjCCategoryDecl *TailCategory; const ObjCCategoryDecl *TailCategory;
/// \brief ID corresponding to \c Interface. /// \brief ID corresponding to \c Interface.
serialization::DeclID InterfaceID; serialization::DeclID InterfaceID;
/// \brief ID corresponding to TailCategoryID. /// \brief ID corresponding to TailCategoryID.
serialization::DeclID TailCategoryID; serialization::DeclID TailCategoryID;
}; };
@ -310,7 +311,7 @@ private:
SmallVector<Stmt *, 16> StmtsToEmit; SmallVector<Stmt *, 16> StmtsToEmit;
/// \brief Statements collection to use for ASTWriter::AddStmt(). /// \brief Statements collection to use for ASTWriter::AddStmt().
/// It will point to StmtsToEmit unless it is overriden. /// It will point to StmtsToEmit unless it is overriden.
SmallVector<Stmt *, 16> *CollectedStmts; SmallVector<Stmt *, 16> *CollectedStmts;
/// \brief Mapping from SwitchCase statements to IDs. /// \brief Mapping from SwitchCase statements to IDs.
@ -335,33 +336,33 @@ private:
/// \brief The offset of each CXXBaseSpecifier set within the AST. /// \brief The offset of each CXXBaseSpecifier set within the AST.
SmallVector<uint32_t, 4> CXXBaseSpecifiersOffsets; SmallVector<uint32_t, 4> CXXBaseSpecifiersOffsets;
/// \brief The first ID number we can use for our own base specifiers. /// \brief The first ID number we can use for our own base specifiers.
serialization::CXXBaseSpecifiersID FirstCXXBaseSpecifiersID; serialization::CXXBaseSpecifiersID FirstCXXBaseSpecifiersID;
/// \brief The base specifiers ID that will be assigned to the next new /// \brief The base specifiers ID that will be assigned to the next new
/// set of C++ base specifiers. /// set of C++ base specifiers.
serialization::CXXBaseSpecifiersID NextCXXBaseSpecifiersID; serialization::CXXBaseSpecifiersID NextCXXBaseSpecifiersID;
/// \brief A set of C++ base specifiers that is queued to be written into the /// \brief A set of C++ base specifiers that is queued to be written into the
/// AST file. /// AST file.
struct QueuedCXXBaseSpecifiers { struct QueuedCXXBaseSpecifiers {
QueuedCXXBaseSpecifiers() : ID(), Bases(), BasesEnd() { } QueuedCXXBaseSpecifiers() : ID(), Bases(), BasesEnd() { }
QueuedCXXBaseSpecifiers(serialization::CXXBaseSpecifiersID ID, QueuedCXXBaseSpecifiers(serialization::CXXBaseSpecifiersID ID,
CXXBaseSpecifier const *Bases, CXXBaseSpecifier const *Bases,
CXXBaseSpecifier const *BasesEnd) CXXBaseSpecifier const *BasesEnd)
: ID(ID), Bases(Bases), BasesEnd(BasesEnd) { } : ID(ID), Bases(Bases), BasesEnd(BasesEnd) { }
serialization::CXXBaseSpecifiersID ID; serialization::CXXBaseSpecifiersID ID;
CXXBaseSpecifier const * Bases; CXXBaseSpecifier const * Bases;
CXXBaseSpecifier const * BasesEnd; CXXBaseSpecifier const * BasesEnd;
}; };
/// \brief Queue of C++ base specifiers to be written to the AST file, /// \brief Queue of C++ base specifiers to be written to the AST file,
/// in the order they should be written. /// in the order they should be written.
SmallVector<QueuedCXXBaseSpecifiers, 2> CXXBaseSpecifiersToWrite; SmallVector<QueuedCXXBaseSpecifiers, 2> CXXBaseSpecifiersToWrite;
/// \brief Write the given subexpression to the bitstream. /// \brief Write the given subexpression to the bitstream.
void WriteSubStmt(Stmt *S, void WriteSubStmt(Stmt *S,
llvm::DenseMap<Stmt *, uint64_t> &SubStmtEntries, llvm::DenseMap<Stmt *, uint64_t> &SubStmtEntries,
@ -419,13 +420,13 @@ private:
void WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, void WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
StringRef isysroot, const std::string &OutputFile, StringRef isysroot, const std::string &OutputFile,
bool IsModule); bool IsModule);
public: public:
/// \brief Create a new precompiled header writer that outputs to /// \brief Create a new precompiled header writer that outputs to
/// the given bitstream. /// the given bitstream.
ASTWriter(llvm::BitstreamWriter &Stream); ASTWriter(llvm::BitstreamWriter &Stream);
~ASTWriter(); ~ASTWriter();
/// \brief Write a precompiled header for the given semantic analysis. /// \brief Write a precompiled header for the given semantic analysis.
/// ///
/// \param SemaRef a reference to the semantic analysis object that processed /// \param SemaRef a reference to the semantic analysis object that processed
@ -448,7 +449,7 @@ public:
/// \brief Emit a source range. /// \brief Emit a source range.
void AddSourceRange(SourceRange Range, RecordDataImpl &Record); void AddSourceRange(SourceRange Range, RecordDataImpl &Record);
/// \brief Emit an integral value. /// \brief Emit an integral value.
void AddAPInt(const llvm::APInt &Value, RecordDataImpl &Record); void AddAPInt(const llvm::APInt &Value, RecordDataImpl &Record);
@ -471,10 +472,10 @@ public:
void AddCXXBaseSpecifiersRef(CXXBaseSpecifier const *Bases, void AddCXXBaseSpecifiersRef(CXXBaseSpecifier const *Bases,
CXXBaseSpecifier const *BasesEnd, CXXBaseSpecifier const *BasesEnd,
RecordDataImpl &Record); RecordDataImpl &Record);
/// \brief Get the unique number used to refer to the given selector. /// \brief Get the unique number used to refer to the given selector.
serialization::SelectorID getSelectorRef(Selector Sel); serialization::SelectorID getSelectorRef(Selector Sel);
/// \brief Get the unique number used to refer to the given identifier. /// \brief Get the unique number used to refer to the given identifier.
serialization::IdentID getIdentifierRef(const IdentifierInfo *II); serialization::IdentID getIdentifierRef(const IdentifierInfo *II);
@ -487,7 +488,7 @@ public:
"Identifier does not name a macro"); "Identifier does not name a macro");
return MacroOffsets[II]; return MacroOffsets[II];
} }
/// \brief Emit a reference to a type. /// \brief Emit a reference to a type.
void AddTypeRef(QualType T, RecordDataImpl &Record); void AddTypeRef(QualType T, RecordDataImpl &Record);
@ -521,7 +522,7 @@ public:
/// \brief Emit a reference to a declaration. /// \brief Emit a reference to a declaration.
void AddDeclRef(const Decl *D, RecordDataImpl &Record); void AddDeclRef(const Decl *D, RecordDataImpl &Record);
/// \brief Force a declaration to be emitted and get its ID. /// \brief Force a declaration to be emitted and get its ID.
serialization::DeclID GetDeclRef(const Decl *D); serialization::DeclID GetDeclRef(const Decl *D);
@ -542,9 +543,9 @@ public:
void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl &Record); void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl &Record);
/// \brief Emit a nested name specifier with source-location information. /// \brief Emit a nested name specifier with source-location information.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
RecordDataImpl &Record); RecordDataImpl &Record);
/// \brief Emit a template name. /// \brief Emit a template name.
void AddTemplateName(TemplateName Name, RecordDataImpl &Record); void AddTemplateName(TemplateName Name, RecordDataImpl &Record);
@ -563,7 +564,8 @@ public:
void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordDataImpl &Record); void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordDataImpl &Record);
/// \brief Emit a C++ base specifier. /// \brief Emit a C++ base specifier.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordDataImpl &Record); void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
RecordDataImpl &Record);
/// \brief Emit a CXXCtorInitializer array. /// \brief Emit a CXXCtorInitializer array.
void AddCXXCtorInitializers( void AddCXXCtorInitializers(
@ -614,10 +616,10 @@ public:
/// been added to the queue via AddStmt(). /// been added to the queue via AddStmt().
void FlushStmts(); void FlushStmts();
/// \brief Flush all of the C++ base specifier sets that have been added /// \brief Flush all of the C++ base specifier sets that have been added
/// via \c AddCXXBaseSpecifiersRef(). /// via \c AddCXXBaseSpecifiersRef().
void FlushCXXBaseSpecifiers(); void FlushCXXBaseSpecifiers();
/// \brief Record an ID for the given switch-case statement. /// \brief Record an ID for the given switch-case statement.
unsigned RecordSwitchCaseID(SwitchCase *S); unsigned RecordSwitchCaseID(SwitchCase *S);
@ -684,7 +686,7 @@ protected:
const ASTWriter &getWriter() const { return Writer; } const ASTWriter &getWriter() const { return Writer; }
public: public:
PCHGenerator(const Preprocessor &PP, StringRef OutputFile, PCHGenerator(const Preprocessor &PP, StringRef OutputFile,
bool IsModule, bool IsModule,
StringRef isysroot, raw_ostream *Out); StringRef isysroot, raw_ostream *Out);
~PCHGenerator(); ~PCHGenerator();

View File

@ -23,12 +23,12 @@
#include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Bitcode/BitstreamReader.h"
#include <string> #include <string>
namespace clang { namespace clang {
class DeclContext; class DeclContext;
namespace serialization { namespace serialization {
/// \brief Specifies the kind of module that has been loaded. /// \brief Specifies the kind of module that has been loaded.
enum ModuleKind { enum ModuleKind {
MK_Module, ///< File is a module proper. MK_Module, ///< File is a module proper.
@ -39,9 +39,9 @@ enum ModuleKind {
/// \brief Information about the contents of a DeclContext. /// \brief Information about the contents of a DeclContext.
struct DeclContextInfo { struct DeclContextInfo {
DeclContextInfo() DeclContextInfo()
: NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {} : NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {}
void *NameLookupTableData; // an ASTDeclContextNameLookupTable. void *NameLookupTableData; // an ASTDeclContextNameLookupTable.
const KindDeclIDPair *LexicalDecls; const KindDeclIDPair *LexicalDecls;
unsigned NumLexicalDecls; unsigned NumLexicalDecls;
@ -49,216 +49,216 @@ struct DeclContextInfo {
/// \brief Information about a module that has been loaded by the ASTReader. /// \brief Information about a module that has been loaded by the ASTReader.
/// ///
/// Each instance of the Module class corresponds to a single AST file, which /// Each instance of the Module class corresponds to a single AST file, which
/// may be a precompiled header, precompiled preamble, a module, or an AST file /// may be a precompiled header, precompiled preamble, a module, or an AST file
/// of some sort loaded as the main file, all of which are specific formulations of /// of some sort loaded as the main file, all of which are specific formulations
/// the general notion of a "module". A module may depend on any number of /// of the general notion of a "module". A module may depend on any number of
/// other modules. /// other modules.
class Module { class Module {
public: public:
Module(ModuleKind Kind); Module(ModuleKind Kind);
~Module(); ~Module();
// === General information === // === General information ===
/// \brief The type of this module. /// \brief The type of this module.
ModuleKind Kind; ModuleKind Kind;
/// \brief The file name of the module file. /// \brief The file name of the module file.
std::string FileName; std::string FileName;
/// \brief Whether this module has been directly imported by the /// \brief Whether this module has been directly imported by the
/// user. /// user.
bool DirectlyImported; bool DirectlyImported;
/// \brief The memory buffer that stores the data associated with /// \brief The memory buffer that stores the data associated with
/// this AST file. /// this AST file.
llvm::OwningPtr<llvm::MemoryBuffer> Buffer; llvm::OwningPtr<llvm::MemoryBuffer> Buffer;
/// \brief The size of this file, in bits. /// \brief The size of this file, in bits.
uint64_t SizeInBits; uint64_t SizeInBits;
/// \brief The global bit offset (or base) of this module /// \brief The global bit offset (or base) of this module
uint64_t GlobalBitOffset; uint64_t GlobalBitOffset;
/// \brief The bitstream reader from which we'll read the AST file. /// \brief The bitstream reader from which we'll read the AST file.
llvm::BitstreamReader StreamFile; llvm::BitstreamReader StreamFile;
/// \brief The main bitstream cursor for the main block. /// \brief The main bitstream cursor for the main block.
llvm::BitstreamCursor Stream; llvm::BitstreamCursor Stream;
/// \brief The source location where this module was first imported. /// \brief The source location where this module was first imported.
SourceLocation ImportLoc; SourceLocation ImportLoc;
/// \brief The first source location in this module. /// \brief The first source location in this module.
SourceLocation FirstLoc; SourceLocation FirstLoc;
// === Source Locations === // === Source Locations ===
/// \brief Cursor used to read source location entries. /// \brief Cursor used to read source location entries.
llvm::BitstreamCursor SLocEntryCursor; llvm::BitstreamCursor SLocEntryCursor;
/// \brief The number of source location entries in this AST file. /// \brief The number of source location entries in this AST file.
unsigned LocalNumSLocEntries; unsigned LocalNumSLocEntries;
/// \brief The base ID in the source manager's view of this module. /// \brief The base ID in the source manager's view of this module.
int SLocEntryBaseID; int SLocEntryBaseID;
/// \brief The base offset in the source manager's view of this module. /// \brief The base offset in the source manager's view of this module.
unsigned SLocEntryBaseOffset; unsigned SLocEntryBaseOffset;
/// \brief Offsets for all of the source location entries in the /// \brief Offsets for all of the source location entries in the
/// AST file. /// AST file.
const uint32_t *SLocEntryOffsets; const uint32_t *SLocEntryOffsets;
/// \brief SLocEntries that we're going to preload. /// \brief SLocEntries that we're going to preload.
SmallVector<uint64_t, 4> PreloadSLocEntries; SmallVector<uint64_t, 4> PreloadSLocEntries;
/// \brief The number of source location file entries in this AST file. /// \brief The number of source location file entries in this AST file.
unsigned LocalNumSLocFileEntries; unsigned LocalNumSLocFileEntries;
/// \brief Offsets for all of the source location file entries in the /// \brief Offsets for all of the source location file entries in the
/// AST file. /// AST file.
const uint32_t *SLocFileOffsets; const uint32_t *SLocFileOffsets;
/// \brief Remapping table for source locations in this module. /// \brief Remapping table for source locations in this module.
ContinuousRangeMap<uint32_t, int, 2> SLocRemap; ContinuousRangeMap<uint32_t, int, 2> SLocRemap;
// === Identifiers === // === Identifiers ===
/// \brief The number of identifiers in this AST file. /// \brief The number of identifiers in this AST file.
unsigned LocalNumIdentifiers; unsigned LocalNumIdentifiers;
/// \brief Offsets into the identifier table data. /// \brief Offsets into the identifier table data.
/// ///
/// This array is indexed by the identifier ID (-1), and provides /// This array is indexed by the identifier ID (-1), and provides
/// the offset into IdentifierTableData where the string data is /// the offset into IdentifierTableData where the string data is
/// stored. /// stored.
const uint32_t *IdentifierOffsets; const uint32_t *IdentifierOffsets;
/// \brief Base identifier ID for identifiers local to this module. /// \brief Base identifier ID for identifiers local to this module.
serialization::IdentID BaseIdentifierID; serialization::IdentID BaseIdentifierID;
/// \brief Remapping table for identifier IDs in this module. /// \brief Remapping table for identifier IDs in this module.
ContinuousRangeMap<uint32_t, int, 2> IdentifierRemap; ContinuousRangeMap<uint32_t, int, 2> IdentifierRemap;
/// \brief Actual data for the on-disk hash table of identifiers. /// \brief Actual data for the on-disk hash table of identifiers.
/// ///
/// This pointer points into a memory buffer, where the on-disk hash /// This pointer points into a memory buffer, where the on-disk hash
/// table for identifiers actually lives. /// table for identifiers actually lives.
const char *IdentifierTableData; const char *IdentifierTableData;
/// \brief A pointer to an on-disk hash table of opaque type /// \brief A pointer to an on-disk hash table of opaque type
/// IdentifierHashTable. /// IdentifierHashTable.
void *IdentifierLookupTable; void *IdentifierLookupTable;
// === Macros === // === Macros ===
/// \brief The cursor to the start of the preprocessor block, which stores /// \brief The cursor to the start of the preprocessor block, which stores
/// all of the macro definitions. /// all of the macro definitions.
llvm::BitstreamCursor MacroCursor; llvm::BitstreamCursor MacroCursor;
/// \brief The offset of the start of the set of defined macros. /// \brief The offset of the start of the set of defined macros.
uint64_t MacroStartOffset; uint64_t MacroStartOffset;
// === Detailed PreprocessingRecord === // === Detailed PreprocessingRecord ===
/// \brief The cursor to the start of the (optional) detailed preprocessing /// \brief The cursor to the start of the (optional) detailed preprocessing
/// record block. /// record block.
llvm::BitstreamCursor PreprocessorDetailCursor; llvm::BitstreamCursor PreprocessorDetailCursor;
/// \brief The offset of the start of the preprocessor detail cursor. /// \brief The offset of the start of the preprocessor detail cursor.
uint64_t PreprocessorDetailStartOffset; uint64_t PreprocessorDetailStartOffset;
/// \brief Base preprocessed entity ID for preprocessed entities local to /// \brief Base preprocessed entity ID for preprocessed entities local to
/// this module. /// this module.
serialization::PreprocessedEntityID BasePreprocessedEntityID; serialization::PreprocessedEntityID BasePreprocessedEntityID;
/// \brief Remapping table for preprocessed entity IDs in this module. /// \brief Remapping table for preprocessed entity IDs in this module.
ContinuousRangeMap<uint32_t, int, 2> PreprocessedEntityRemap; ContinuousRangeMap<uint32_t, int, 2> PreprocessedEntityRemap;
const PPEntityOffset *PreprocessedEntityOffsets; const PPEntityOffset *PreprocessedEntityOffsets;
unsigned NumPreprocessedEntities; unsigned NumPreprocessedEntities;
// === Header search information === // === Header search information ===
/// \brief The number of local HeaderFileInfo structures. /// \brief The number of local HeaderFileInfo structures.
unsigned LocalNumHeaderFileInfos; unsigned LocalNumHeaderFileInfos;
/// \brief Actual data for the on-disk hash table of header file /// \brief Actual data for the on-disk hash table of header file
/// information. /// information.
/// ///
/// This pointer points into a memory buffer, where the on-disk hash /// This pointer points into a memory buffer, where the on-disk hash
/// table for header file information actually lives. /// table for header file information actually lives.
const char *HeaderFileInfoTableData; const char *HeaderFileInfoTableData;
/// \brief The on-disk hash table that contains information about each of /// \brief The on-disk hash table that contains information about each of
/// the header files. /// the header files.
void *HeaderFileInfoTable; void *HeaderFileInfoTable;
/// \brief Actual data for the list of framework names used in the header /// \brief Actual data for the list of framework names used in the header
/// search information. /// search information.
const char *HeaderFileFrameworkStrings; const char *HeaderFileFrameworkStrings;
// === Selectors === // === Selectors ===
/// \brief The number of selectors new to this file. /// \brief The number of selectors new to this file.
/// ///
/// This is the number of entries in SelectorOffsets. /// This is the number of entries in SelectorOffsets.
unsigned LocalNumSelectors; unsigned LocalNumSelectors;
/// \brief Offsets into the selector lookup table's data array /// \brief Offsets into the selector lookup table's data array
/// where each selector resides. /// where each selector resides.
const uint32_t *SelectorOffsets; const uint32_t *SelectorOffsets;
/// \brief Base selector ID for selectors local to this module. /// \brief Base selector ID for selectors local to this module.
serialization::SelectorID BaseSelectorID; serialization::SelectorID BaseSelectorID;
/// \brief Remapping table for selector IDs in this module. /// \brief Remapping table for selector IDs in this module.
ContinuousRangeMap<uint32_t, int, 2> SelectorRemap; ContinuousRangeMap<uint32_t, int, 2> SelectorRemap;
/// \brief A pointer to the character data that comprises the selector table /// \brief A pointer to the character data that comprises the selector table
/// ///
/// The SelectorOffsets table refers into this memory. /// The SelectorOffsets table refers into this memory.
const unsigned char *SelectorLookupTableData; const unsigned char *SelectorLookupTableData;
/// \brief A pointer to an on-disk hash table of opaque type /// \brief A pointer to an on-disk hash table of opaque type
/// ASTSelectorLookupTable. /// ASTSelectorLookupTable.
/// ///
/// This hash table provides the IDs of all selectors, and the associated /// This hash table provides the IDs of all selectors, and the associated
/// instance and factory methods. /// instance and factory methods.
void *SelectorLookupTable; void *SelectorLookupTable;
// === Declarations === // === Declarations ===
/// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block. It /// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block. It
/// has read all the abbreviations at the start of the block and is ready to /// has read all the abbreviations at the start of the block and is ready to
/// jump around with these in context. /// jump around with these in context.
llvm::BitstreamCursor DeclsCursor; llvm::BitstreamCursor DeclsCursor;
/// \brief The number of declarations in this AST file. /// \brief The number of declarations in this AST file.
unsigned LocalNumDecls; unsigned LocalNumDecls;
/// \brief Offset of each declaration within the bitstream, indexed /// \brief Offset of each declaration within the bitstream, indexed
/// by the declaration ID (-1). /// by the declaration ID (-1).
const DeclOffset *DeclOffsets; const DeclOffset *DeclOffsets;
/// \brief Base declaration ID for declarations local to this module. /// \brief Base declaration ID for declarations local to this module.
serialization::DeclID BaseDeclID; serialization::DeclID BaseDeclID;
/// \brief Remapping table for declaration IDs in this module. /// \brief Remapping table for declaration IDs in this module.
ContinuousRangeMap<uint32_t, int, 2> DeclRemap; ContinuousRangeMap<uint32_t, int, 2> DeclRemap;
/// \brief The number of C++ base specifier sets in this AST file. /// \brief The number of C++ base specifier sets in this AST file.
unsigned LocalNumCXXBaseSpecifiers; unsigned LocalNumCXXBaseSpecifiers;
/// \brief Offset of each C++ base specifier set within the bitstream, /// \brief Offset of each C++ base specifier set within the bitstream,
/// indexed by the C++ base specifier set ID (-1). /// indexed by the C++ base specifier set ID (-1).
const uint32_t *CXXBaseSpecifiersOffsets; const uint32_t *CXXBaseSpecifiersOffsets;
typedef llvm::DenseMap<const DeclContext *, DeclContextInfo> typedef llvm::DenseMap<const DeclContext *, DeclContextInfo>
DeclContextInfosMap; DeclContextInfosMap;
/// \brief Information about the lexical and visible declarations /// \brief Information about the lexical and visible declarations
/// for each DeclContext. /// for each DeclContext.
DeclContextInfosMap DeclContextInfos; DeclContextInfosMap DeclContextInfos;
@ -274,43 +274,43 @@ public:
/// \brief Array of file-level DeclIDs sorted by file. /// \brief Array of file-level DeclIDs sorted by file.
const serialization::DeclID *FileSortedDecls; const serialization::DeclID *FileSortedDecls;
// === Types === // === Types ===
/// \brief The number of types in this AST file. /// \brief The number of types in this AST file.
unsigned LocalNumTypes; unsigned LocalNumTypes;
/// \brief Offset of each type within the bitstream, indexed by the /// \brief Offset of each type within the bitstream, indexed by the
/// type ID, or the representation of a Type*. /// type ID, or the representation of a Type*.
const uint32_t *TypeOffsets; const uint32_t *TypeOffsets;
/// \brief Base type ID for types local to this module as represented in /// \brief Base type ID for types local to this module as represented in
/// the global type ID space. /// the global type ID space.
serialization::TypeID BaseTypeIndex; serialization::TypeID BaseTypeIndex;
/// \brief Remapping table for type IDs in this module. /// \brief Remapping table for type IDs in this module.
ContinuousRangeMap<uint32_t, int, 2> TypeRemap; ContinuousRangeMap<uint32_t, int, 2> TypeRemap;
// === Miscellaneous === // === Miscellaneous ===
/// \brief Diagnostic IDs and their mappings that the user changed. /// \brief Diagnostic IDs and their mappings that the user changed.
SmallVector<uint64_t, 8> PragmaDiagMappings; SmallVector<uint64_t, 8> PragmaDiagMappings;
/// \brief The AST stat cache installed for this file, if any. /// \brief The AST stat cache installed for this file, if any.
/// ///
/// The dynamic type of this stat cache is always ASTStatCache /// The dynamic type of this stat cache is always ASTStatCache
void *StatCache; void *StatCache;
/// \brief List of modules which depend on this module /// \brief List of modules which depend on this module
llvm::SetVector<Module *> ImportedBy; llvm::SetVector<Module *> ImportedBy;
/// \brief List of modules which this module depends on /// \brief List of modules which this module depends on
llvm::SetVector<Module *> Imports; llvm::SetVector<Module *> Imports;
/// \brief Determine whether this module was directly imported at /// \brief Determine whether this module was directly imported at
/// any point during translation. /// any point during translation.
bool isDirectlyImported() const { return DirectlyImported; } bool isDirectlyImported() const { return DirectlyImported; }
/// \brief Dump debugging output for this module. /// \brief Dump debugging output for this module.
void dump(); void dump();
}; };