diff options
Diffstat (limited to 'include/clang')
29 files changed, 1243 insertions, 708 deletions
diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h index 023456e2e3..6487613200 100644 --- a/include/clang/AST/CanonicalType.h +++ b/include/clang/AST/CanonicalType.h @@ -1,4 +1,4 @@ -//===-- CanonicalType.h - C Language Family Type Representation -*- C++ -*-===// +//===- CanonicalType.h - C Language Family Type Representation --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,13 +16,29 @@ #define LLVM_CLANG_AST_CANONICALTYPE_H #include "clang/AST/Type.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/iterator.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/PointerLikeTypeTraits.h" +#include <cassert> +#include <iterator> +#include <type_traits> namespace clang { template<typename T> class CanProxy; template<typename T> struct CanProxyAdaptor; +class CXXRecordDecl; +class EnumDecl; +class Expr; +class IdentifierInfo; +class ObjCInterfaceDecl; +class RecordDecl; +class TagDecl; +class TemplateTypeParmDecl; //----------------------------------------------------------------------------// // Canonical, qualified type template @@ -46,8 +62,6 @@ template<typename T> struct CanProxyAdaptor; /// converted to @c CanQual<ReferenceType>. Note that any @c CanQual type can /// be implicitly converted to a QualType, but the reverse operation requires /// a call to ASTContext::getCanonicalType(). -/// -/// template<typename T = Type> class CanQual { /// \brief The actual, canonical type. @@ -55,7 +69,7 @@ class CanQual { public: /// \brief Constructs a NULL canonical type. - CanQual() : Stored() { } + CanQual() = default; /// \brief Converting constructor that permits implicit upcasting of /// canonical type pointers. @@ -66,12 +80,11 @@ public: /// \brief Retrieve the underlying type pointer, which refers to a /// canonical type. /// - /// The underlying pointer must not be NULL. + /// The underlying pointer must not be nullptr. const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); } /// \brief Retrieve the underlying type pointer, which refers to a - /// canonical type, or NULL. - /// + /// canonical type, or nullptr. const T *getTypePtrOrNull() const { return cast_or_null<T>(Stored.getTypePtrOrNull()); } @@ -125,9 +138,11 @@ public: bool isConstQualified() const { return Stored.isLocalConstQualified(); } + bool isVolatileQualified() const { return Stored.isLocalVolatileQualified(); } + bool isRestrictQualified() const { return Stored.isLocalRestrictQualified(); } @@ -195,7 +210,7 @@ inline bool operator!=(CanQual<T> x, CanQual<U> y) { } /// \brief Represents a canonical, potentially-qualified type. -typedef CanQual<Type> CanQualType; +using CanQualType = CanQual<Type>; inline CanQualType Type::getCanonicalTypeUnqualified() const { return CanQualType::CreateUnsafe(getCanonicalTypeInternal()); @@ -320,7 +335,7 @@ public: /// than the more typical @c QualType, to propagate the notion of "canonical" /// through the system. template<typename T> -struct CanProxyAdaptor : CanProxyBase<T> { }; +struct CanProxyAdaptor : CanProxyBase<T> {}; /// \brief Canonical proxy type returned when retrieving the members of a /// canonical type or as the result of the @c CanQual<T>::getAs member @@ -333,7 +348,7 @@ template<typename T> class CanProxy : public CanProxyAdaptor<T> { public: /// \brief Build a NULL proxy. - CanProxy() { } + CanProxy() = default; /// \brief Build a proxy to the given canonical type. CanProxy(CanQual<T> Stored) { this->Stored = Stored; } @@ -342,7 +357,7 @@ public: operator CanQual<T>() const { return this->Stored; } }; -} // end namespace clang +} // namespace clang namespace llvm { @@ -350,8 +365,9 @@ namespace llvm { /// CanQual<T> to a specific Type class. We're prefer isa/dyn_cast/cast/etc. /// to return smart pointer (proxies?). template<typename T> -struct simplify_type< ::clang::CanQual<T> > { - typedef const T *SimpleType; +struct simplify_type< ::clang::CanQual<T>> { + using SimpleType = const T *; + static SimpleType getSimplifiedValue(::clang::CanQual<T> Val) { return Val.getTypePtr(); } @@ -359,18 +375,20 @@ struct simplify_type< ::clang::CanQual<T> > { // Teach SmallPtrSet that CanQual<T> is "basically a pointer". template<typename T> -struct PointerLikeTypeTraits<clang::CanQual<T> > { - static inline void *getAsVoidPointer(clang::CanQual<T> P) { +struct PointerLikeTypeTraits<clang::CanQual<T>> { + static void *getAsVoidPointer(clang::CanQual<T> P) { return P.getAsOpaquePtr(); } - static inline clang::CanQual<T> getFromVoidPointer(void *P) { + + static clang::CanQual<T> getFromVoidPointer(void *P) { return clang::CanQual<T>::getFromOpaquePtr(P); } + // qualifier information is encoded in the low bits. enum { NumLowBitsAvailable = 0 }; }; -} // end namespace llvm +} // namespace llvm namespace clang { @@ -388,7 +406,7 @@ struct CanTypeIterator CanQualType, typename std::iterator_traits<InputIterator>::difference_type, CanProxy<Type>, CanQualType> { - CanTypeIterator() {} + CanTypeIterator() = default; explicit CanTypeIterator(InputIterator Iter) : CanTypeIterator::iterator_adaptor_base(std::move(Iter)) {} @@ -486,6 +504,7 @@ struct CanProxyAdaptor<FunctionProtoType> LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasExtParameterInfos) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR( ArrayRef<FunctionProtoType::ExtParameterInfo>, getExtParameterInfos) + CanQualType getParamType(unsigned i) const { return CanQualType::CreateUnsafe(this->getTypePtr()->getParamType(i)); } @@ -493,8 +512,8 @@ struct CanProxyAdaptor<FunctionProtoType> LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVariadic) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getTypeQuals) - typedef CanTypeIterator<FunctionProtoType::param_type_iterator> - param_type_iterator; + using param_type_iterator = + CanTypeIterator<FunctionProtoType::param_type_iterator>; param_type_iterator param_type_begin() const { return param_type_iterator(this->getTypePtr()->param_type_begin()); @@ -566,7 +585,8 @@ struct CanProxyAdaptor<ObjCObjectType> LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedId) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClass) - typedef ObjCObjectPointerType::qual_iterator qual_iterator; + using qual_iterator = ObjCObjectPointerType::qual_iterator; + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty) @@ -584,7 +604,8 @@ struct CanProxyAdaptor<ObjCObjectPointerType> LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedIdType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClassType) - typedef ObjCObjectPointerType::qual_iterator qual_iterator; + using qual_iterator = ObjCObjectPointerType::qual_iterator; + LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty) @@ -661,7 +682,6 @@ CanProxy<Type> CanTypeIterator<InputIterator>::operator->() const { return CanProxy<Type>(*this); } -} - +} // namespace clang -#endif +#endif // LLVM_CLANG_AST_CANONICALTYPE_H diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 47515a848a..f93c9f0b9a 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -1,4 +1,4 @@ -//===-- DeclBase.h - Base Classes for representing declarations -*- C++ -*-===// +//===- DeclBase.h - Base Classes for representing declarations --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,33 +16,40 @@ #include "clang/AST/AttrIterator.h" #include "clang/AST/DeclarationName.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" #include "clang/Basic/VersionTuple.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/PrettyStackTrace.h" +#include <algorithm> +#include <cassert> +#include <cstddef> +#include <iterator> +#include <string> +#include <type_traits> +#include <utility> namespace clang { + +class ASTContext; class ASTMutationListener; -class BlockDecl; -class CXXRecordDecl; -class CompoundStmt; +class Attr; class DeclContext; -class DeclarationName; -class DependentDiagnostic; -class EnumDecl; -class ExportDecl; class ExternalSourceSymbolAttr; class FunctionDecl; class FunctionType; +class IdentifierInfo; enum Linkage : unsigned char; -class LinkageComputer; class LinkageSpecDecl; class Module; class NamedDecl; -class NamespaceDecl; class ObjCCategoryDecl; class ObjCCategoryImplDecl; class ObjCContainerDecl; @@ -53,23 +60,21 @@ class ObjCMethodDecl; class ObjCProtocolDecl; struct PrintingPolicy; class RecordDecl; +class SourceManager; class Stmt; class StoredDeclsMap; class TemplateDecl; class TranslationUnitDecl; class UsingDirectiveDecl; -} -namespace clang { - - /// \brief Captures the result of checking the availability of a - /// declaration. - enum AvailabilityResult { - AR_Available = 0, - AR_NotYetIntroduced, - AR_Deprecated, - AR_Unavailable - }; +/// \brief Captures the result of checking the availability of a +/// declaration. +enum AvailabilityResult { + AR_Available = 0, + AR_NotYetIntroduced, + AR_Deprecated, + AR_Unavailable +}; /// Decl - This represents one declaration (or definition), e.g. a variable, /// typedef, function, struct, etc. @@ -94,7 +99,7 @@ public: /// \brief A placeholder type used to construct an empty shell of a /// decl-derived type that will be filled in later (e.g., by some /// deserialization method). - struct EmptyShell { }; + struct EmptyShell {}; /// IdentifierNamespace - The different namespaces in which /// declarations may appear. According to C99 6.2.3, there are @@ -208,15 +213,18 @@ public: enum class ModuleOwnershipKind : unsigned { /// This declaration is not owned by a module. Unowned, + /// This declaration has an owning module, but is globally visible /// (typically because its owning module is visible and we know that /// modules cannot later become hidden in this compilation). /// After serialization and deserialization, this will be converted /// to VisibleWhenImported. Visible, + /// This declaration has an owning module, and is visible when that /// module is imported. VisibleWhenImported, + /// This declaration has an owning module, but is only visible to /// lookups that occur within that module. ModulePrivate @@ -238,7 +246,6 @@ private: DeclContext *LexicalDC; }; - /// DeclCtx - Holds either a DeclContext* or a MultipleDC*. /// For declarations that don't contain C++ scope specifiers, it contains /// the DeclContext where the Decl was declared. @@ -254,12 +261,14 @@ private: /// // LexicalDC == global namespace llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx; - inline bool isInSemaDC() const { return DeclCtx.is<DeclContext*>(); } - inline bool isOutOfSemaDC() const { return DeclCtx.is<MultipleDC*>(); } - inline MultipleDC *getMultipleDC() const { + bool isInSemaDC() const { return DeclCtx.is<DeclContext*>(); } + bool isOutOfSemaDC() const { return DeclCtx.is<MultipleDC*>(); } + + MultipleDC *getMultipleDC() const { return DeclCtx.get<MultipleDC*>(); } - inline DeclContext *getSemanticDC() const { + + DeclContext *getSemanticDC() const { return DeclCtx.get<DeclContext*>(); } @@ -298,10 +307,16 @@ private: static bool StatisticsEnabled; protected: + friend class ASTDeclReader; + friend class ASTDeclWriter; + friend class ASTReader; + friend class CXXClassMemberWrapper; + friend class LinkageComputer; + template<typename decl_type> friend class Redeclarable; + /// Access - Used by C++ decls for the access specifier. // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum unsigned Access : 2; - friend class CXXClassMemberWrapper; /// \brief Whether this declaration was loaded from an AST file. unsigned FromASTFile : 1; @@ -313,13 +328,6 @@ protected: /// Otherwise, it is the linkage + 1. mutable unsigned CacheValidAndLinkage : 3; - friend class ASTDeclWriter; - friend class ASTDeclReader; - friend class ASTReader; - friend class LinkageComputer; - - template<typename decl_type> friend class Redeclarable; - /// \brief Allocate memory for a deserialized declaration. /// /// This routine must be used to allocate memory for any declaration that is @@ -357,7 +365,7 @@ private: protected: Decl(Kind DK, DeclContext *DC, SourceLocation L) : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)), - DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(0), HasAttrs(false), + DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(false), HasAttrs(false), Implicit(false), Used(false), Referenced(false), TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0), IdentifierNamespace(getIdentifierNamespaceForKind(DK)), @@ -366,9 +374,9 @@ protected: } Decl(Kind DK, EmptyShell Empty) - : NextInContextAndBits(), DeclKind(DK), InvalidDecl(0), HasAttrs(false), - Implicit(false), Used(false), Referenced(false), - TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0), + : DeclKind(DK), InvalidDecl(false), HasAttrs(false), Implicit(false), + Used(false), Referenced(false), TopLevelDeclInObjCContainer(false), + Access(AS_none), FromASTFile(0), IdentifierNamespace(getIdentifierNamespaceForKind(DK)), CacheValidAndLinkage(0) { if (StatisticsEnabled) add(DK); @@ -392,14 +400,15 @@ protected: } public: - /// \brief Source range that this declaration covers. virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLocation(), getLocation()); } + SourceLocation getLocStart() const LLVM_READONLY { return getSourceRange().getBegin(); } + SourceLocation getLocEnd() const LLVM_READONLY { return getSourceRange().getEnd(); } @@ -460,12 +469,15 @@ public: } bool hasAttrs() const { return HasAttrs; } + void setAttrs(const AttrVec& Attrs) { return setAttrsImpl(Attrs, getASTContext()); } + AttrVec &getAttrs() { return const_cast<AttrVec&>(const_cast<const Decl*>(this)->getAttrs()); } + const AttrVec &getAttrs() const; void dropAttrs(); @@ -476,8 +488,8 @@ public: setAttrs(AttrVec(1, A)); } - typedef AttrVec::const_iterator attr_iterator; - typedef llvm::iterator_range<attr_iterator> attr_range; + using attr_iterator = AttrVec::const_iterator; + using attr_range = llvm::iterator_range<attr_iterator>; attr_range attrs() const { return attr_range(attr_begin(), attr_end()); @@ -510,6 +522,7 @@ public: specific_attr_iterator<T> specific_attr_begin() const { return specific_attr_iterator<T>(attr_begin()); } + template <typename T> specific_attr_iterator<T> specific_attr_end() const { return specific_attr_iterator<T>(attr_end()); @@ -518,6 +531,7 @@ public: template<typename T> T *getAttr() const { return hasAttrs() ? getSpecificAttr<T>(getAttrs()) : nullptr; } + template<typename T> bool hasAttr() const { return hasAttrs() && hasSpecificAttr<T>(getAttrs()); } @@ -616,7 +630,6 @@ protected: } public: - /// \brief Determine the availability of the given declaration. /// /// This routine will determine the most restrictive availability of @@ -698,6 +711,7 @@ public: private: Module *getOwningModuleSlow() const; + protected: bool hasLocalOwningModuleStorage() const; @@ -777,14 +791,17 @@ public: unsigned getIdentifierNamespace() const { return IdentifierNamespace; } + bool isInIdentifierNamespace(unsigned NS) const { return getIdentifierNamespace() & NS; } + static unsigned getIdentifierNamespaceForKind(Kind DK); bool hasTagIdentifierNamespace() const { return isTagIdentifierNamespace(getIdentifierNamespace()); } + static bool isTagIdentifierNamespace(unsigned NS) { // TagDecls have Tag and Type set and may also have TagFriend. return (NS & ~IDNS_TagFriend) == (IDNS_Tag | IDNS_Type); @@ -872,18 +889,18 @@ public: /// \brief Iterates through all the redeclarations of the same decl. class redecl_iterator { /// Current - The current declaration. - Decl *Current; + Decl *Current = nullptr; Decl *Starter; public: - typedef Decl *value_type; - typedef const value_type &reference; - typedef const value_type *pointer; - typedef std::forward_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; + using value_type = Decl *; + using reference = const value_type &; + using pointer = const value_type *; + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; - redecl_iterator() : Current(nullptr) { } - explicit redecl_iterator(Decl *C) : Current(C), Starter(C) { } + redecl_iterator() = default; + explicit redecl_iterator(Decl *C) : Current(C), Starter(C) {} reference operator*() const { return Current; } value_type operator->() const { return Current; } @@ -906,12 +923,13 @@ public: friend bool operator==(redecl_iterator x, redecl_iterator y) { return x.Current == y.Current; } + friend bool operator!=(redecl_iterator x, redecl_iterator y) { return x.Current != y.Current; } }; - typedef llvm::iterator_range<redecl_iterator> redecl_range; + using redecl_range = llvm::iterator_range<redecl_iterator>; /// \brief Returns an iterator range for all the redeclarations of the same /// decl. It will iterate at least once (when this decl is the only one). @@ -922,6 +940,7 @@ public: redecl_iterator redecls_begin() const { return redecl_iterator(const_cast<Decl *>(this)); } + redecl_iterator redecls_end() const { return redecl_iterator(); } /// \brief Retrieve the previous declaration that declares the same entity @@ -1103,10 +1122,13 @@ public: static void printGroup(Decl** Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation = 0); + // Debuggers don't usually respect default arguments. void dump() const; + // Same as dump(), but forces color printing. void dumpColor() const; + void dump(raw_ostream &Out, bool Deserialize = false) const; /// \brief Looks through the Decl's underlying type to extract a FunctionType @@ -1141,10 +1163,11 @@ class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry { SourceLocation Loc; SourceManager &SM; const char *Message; + public: PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L, SourceManager &sm, const char *Msg) - : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {} + : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {} void print(raw_ostream &OS) const override; }; @@ -1153,30 +1176,35 @@ public: /// single result (with no stable storage) or a collection of results (with /// stable storage provided by the lookup table). class DeclContextLookupResult { - typedef ArrayRef<NamedDecl *> ResultTy; + using ResultTy = ArrayRef<NamedDecl *>; + ResultTy Result; + // If there is only one lookup result, it would be invalidated by // reallocations of the name table, so store it separately. - NamedDecl *Single; + NamedDecl *Single = nullptr; static NamedDecl *const SingleElementDummyList; public: - DeclContextLookupResult() : Result(), Single() {} + DeclContextLookupResult() = default; DeclContextLookupResult(ArrayRef<NamedDecl *> Result) - : Result(Result), Single() {} + : Result(Result) {} DeclContextLookupResult(NamedDecl *Single) : Result(SingleElementDummyList), Single(Single) {} class iterator; - typedef llvm::iterator_adaptor_base<iterator, ResultTy::iterator, - std::random_access_iterator_tag, - NamedDecl *const> IteratorBase; + + using IteratorBase = + llvm::iterator_adaptor_base<iterator, ResultTy::iterator, + std::random_access_iterator_tag, + NamedDecl *const>; + class iterator : public IteratorBase { value_type SingleElement; public: - iterator() : IteratorBase(), SingleElement() {} + iterator() = default; explicit iterator(pointer Pos, value_type Single = nullptr) : IteratorBase(Pos), SingleElement(Single) {} @@ -1184,9 +1212,10 @@ public: return SingleElement ? SingleElement : IteratorBase::operator*(); } }; - typedef iterator const_iterator; - typedef iterator::pointer pointer; - typedef iterator::reference reference; + + using const_iterator = iterator; + using pointer = iterator::pointer; + using reference = iterator::reference; iterator begin() const { return iterator(Result.begin(), Single); } iterator end() const { return iterator(Result.end(), Single); } @@ -1220,7 +1249,6 @@ public: /// ExportDecl /// BlockDecl /// OMPDeclareReductionDecl -/// class DeclContext { /// DeclKind - This indicates which class this is. unsigned DeclKind : 8; @@ -1260,22 +1288,22 @@ class DeclContext { /// contains an entry for a DeclarationName (and we haven't lazily /// omitted anything), then it contains all relevant entries for that /// name (modulo the hasExternalDecls() flag). - mutable StoredDeclsMap *LookupPtr; + mutable StoredDeclsMap *LookupPtr = nullptr; protected: + friend class ASTDeclReader; + friend class ASTWriter; + friend class ExternalASTSource; + /// FirstDecl - The first declaration stored within this declaration /// context. - mutable Decl *FirstDecl; + mutable Decl *FirstDecl = nullptr; /// LastDecl - The last declaration stored within this declaration /// context. FIXME: We could probably cache this value somewhere /// outside of the DeclContext, to reduce the size of DeclContext by /// another pointer. - mutable Decl *LastDecl; - - friend class ExternalASTSource; - friend class ASTDeclReader; - friend class ASTWriter; + mutable Decl *LastDecl = nullptr; /// \brief Build up a chain of declarations. /// @@ -1288,8 +1316,7 @@ protected: ExternalVisibleStorage(false), NeedToReconcileExternalVisibleStorage(false), HasLazyLocalLexicalLookups(false), HasLazyExternalLexicalLookups(false), - UseQualifiedLookup(false), - LookupPtr(nullptr), FirstDecl(nullptr), LastDecl(nullptr) {} + UseQualifiedLookup(false) {} public: ~DeclContext(); @@ -1297,6 +1324,7 @@ public: Decl::Kind getDeclKind() const { return static_cast<Decl::Kind>(DeclKind); } + const char *getDeclKindName() const; /// getParent - Returns the containing DeclContext. @@ -1504,19 +1532,20 @@ public: /// within this context. class decl_iterator { /// Current - The current declaration. - Decl *Current; + Decl *Current = nullptr; public: - typedef Decl *value_type; - typedef const value_type &reference; - typedef const value_type *pointer; - typedef std::forward_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; + using value_type = Decl *; + using reference = const value_type &; + using pointer = const value_type *; + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; - decl_iterator() : Current(nullptr) { } - explicit decl_iterator(Decl *C) : Current(C) { } + decl_iterator() = default; + explicit decl_iterator(Decl *C) : Current(C) {} reference operator*() const { return Current; } + // This doesn't meet the iterator requirements, but it's convenient value_type operator->() const { return Current; } @@ -1534,12 +1563,13 @@ public: friend bool operator==(decl_iterator x, decl_iterator y) { return x.Current == y.Current; } + friend bool operator!=(decl_iterator x, decl_iterator y) { return x.Current != y.Current; } }; - typedef llvm::iterator_range<decl_iterator> decl_range; + using decl_range = llvm::iterator_range<decl_iterator>; /// decls_begin/decls_end - Iterate over the declarations stored in /// this context. @@ -1578,16 +1608,16 @@ public: } public: - typedef SpecificDecl *value_type; - // TODO: Add reference and pointer typedefs (with some appropriate proxy - // type) if we ever have a need for them. - typedef void reference; - typedef void pointer; - typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type - difference_type; - typedef std::forward_iterator_tag iterator_category; + using value_type = SpecificDecl *; + // TODO: Add reference and pointer types (with some appropriate proxy type) + // if we ever have a need for them. + using reference = void; + using pointer = void; + using difference_type = + std::iterator_traits<DeclContext::decl_iterator>::difference_type; + using iterator_category = std::forward_iterator_tag; - specific_decl_iterator() : Current() { } + specific_decl_iterator() = default; /// specific_decl_iterator - Construct a new iterator over a /// subset of the declarations the range [C, @@ -1602,6 +1632,7 @@ public: } value_type operator*() const { return cast<SpecificDecl>(*Current); } + // This doesn't meet the iterator requirements, but it's convenient value_type operator->() const { return **this; } @@ -1655,16 +1686,16 @@ public: } public: - typedef SpecificDecl *value_type; - // TODO: Add reference and pointer typedefs (with some appropriate proxy - // type) if we ever have a need for them. - typedef void reference; - typedef void pointer; - typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type - difference_type; - typedef std::forward_iterator_tag iterator_category; + using value_type = SpecificDecl *; + // TODO: Add reference and pointer types (with some appropriate proxy type) + // if we ever have a need for them. + using reference = void; + using pointer = void; + using difference_type = + std::iterator_traits<DeclContext::decl_iterator>::difference_type; + using iterator_category = std::forward_iterator_tag; - filtered_decl_iterator() : Current() { } + filtered_decl_iterator() = default; /// filtered_decl_iterator - Construct a new iterator over a /// subset of the declarations the range [C, @@ -1742,8 +1773,8 @@ public: /// @brief Checks whether a declaration is in this context. bool containsDecl(Decl *D) const; - typedef DeclContextLookupResult lookup_result; - typedef lookup_result::iterator lookup_iterator; + using lookup_result = DeclContextLookupResult; + using lookup_iterator = lookup_result::iterator; /// lookup - Find the declarations (if any) with the given Name in /// this context. Returns a range of iterators that contains all of @@ -1789,7 +1820,7 @@ public: /// of looking up every possible name. class all_lookups_iterator; - typedef llvm::iterator_range<all_lookups_iterator> lookups_range; + using lookups_range = llvm::iterator_range<all_lookups_iterator>; lookups_range lookups() const; lookups_range noload_lookups() const; @@ -1805,21 +1836,26 @@ public: all_lookups_iterator noload_lookups_end() const; struct udir_iterator; - typedef llvm::iterator_adaptor_base<udir_iterator, lookup_iterator, - std::random_access_iterator_tag, - UsingDirectiveDecl *> udir_iterator_base; + + using udir_iterator_base = + llvm::iterator_adaptor_base<udir_iterator, lookup_iterator, + std::random_access_iterator_tag, + UsingDirectiveDecl *>; + struct udir_iterator : udir_iterator_base { udir_iterator(lookup_iterator I) : udir_iterator_base(I) {} + UsingDirectiveDecl *operator*() const; }; - typedef llvm::iterator_range<udir_iterator> udir_range; + using udir_range = llvm::iterator_range<udir_iterator>; udir_range using_directives() const; // These are all defined in DependentDiagnostic.h. class ddiag_iterator; - typedef llvm::iterator_range<DeclContext::ddiag_iterator> ddiag_range; + + using ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>; inline ddiag_range ddiags() const; @@ -1892,6 +1928,8 @@ public: bool Deserialize = false) const; private: + friend class DependentDiagnostic; + void reconcileExternalVisibleStorage() const; bool LoadLexicalDeclsFromExternalStorage() const; @@ -1903,7 +1941,6 @@ private: /// use of addDeclInternal(). void makeDeclVisibleInContextInternal(NamedDecl *D); - friend class DependentDiagnostic; StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const; void buildLookupImpl(DeclContext *DCtx, bool Internal); @@ -1942,8 +1979,7 @@ struct cast_convert_decl_context<ToTy, true> { } }; - -} // end clang. +} // namespace clang namespace llvm { @@ -1963,12 +1999,14 @@ struct cast_convert_val<ToTy, return *::clang::cast_convert_decl_context<ToTy>::doit(&Val); } }; + template<class ToTy> struct cast_convert_val<ToTy, ::clang::DeclContext, ::clang::DeclContext> { static ToTy &doit(::clang::DeclContext &Val) { return *::clang::cast_convert_decl_context<ToTy>::doit(&Val); } }; + template<class ToTy> struct cast_convert_val<ToTy, const ::clang::DeclContext*, const ::clang::DeclContext*> { @@ -1976,6 +2014,7 @@ struct cast_convert_val<ToTy, return ::clang::cast_convert_decl_context<ToTy>::doit(Val); } }; + template<class ToTy> struct cast_convert_val<ToTy, ::clang::DeclContext*, ::clang::DeclContext*> { static ToTy *doit(::clang::DeclContext *Val) { @@ -2012,6 +2051,6 @@ struct cast_convert_val< const ::clang::DeclContext, FromTy*, FromTy*> { } }; -} // end namespace llvm +} // namespace llvm -#endif +#endif // LLVM_CLANG_AST_DECLBASE_H diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h index d8dd18ecb8..be013c5d6b 100644 --- a/include/clang/AST/ExternalASTSource.h +++ b/include/clang/AST/ExternalASTSource.h @@ -1,4 +1,4 @@ -//===--- ExternalASTSource.h - Abstract External AST Interface --*- C++ -*-===// +//===- ExternalASTSource.h - Abstract External AST Interface ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,24 +11,44 @@ // construction of AST nodes from some external source. // //===----------------------------------------------------------------------===// + #ifndef LLVM_CLANG_AST_EXTERNALASTSOURCE_H #define LLVM_CLANG_AST_EXTERNALASTSOURCE_H #include "clang/AST/CharUnits.h" #include "clang/AST/DeclBase.h" +#include "clang/Basic/LLVM.h" #include "clang/Basic/Module.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/PointerUnion.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator.h" +#include "llvm/Support/PointerLikeTypeTraits.h" +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <iterator> +#include <string> +#include <utility> namespace clang { class ASTConsumer; +class ASTContext; class CXXBaseSpecifier; class CXXCtorInitializer; +class CXXRecordDecl; class DeclarationName; -class ExternalSemaSource; // layering violation required for downcasting class FieldDecl; -class Module; +class IdentifierInfo; class NamedDecl; +class ObjCInterfaceDecl; class RecordDecl; class Selector; class Stmt; @@ -42,30 +62,31 @@ class TagDecl; /// actual type and declaration nodes, and read parts of declaration /// contexts. class ExternalASTSource : public RefCountedBase<ExternalASTSource> { + friend class ExternalSemaSource; + /// Generation number for this external AST source. Must be increased /// whenever we might have added new redeclarations for existing decls. - uint32_t CurrentGeneration; + uint32_t CurrentGeneration = 0; /// \brief Whether this AST source also provides information for /// semantic analysis. - bool SemaSource; - - friend class ExternalSemaSource; + bool SemaSource = false; public: - ExternalASTSource() : CurrentGeneration(0), SemaSource(false) { } - + ExternalASTSource() = default; virtual ~ExternalASTSource(); /// \brief RAII class for safely pairing a StartedDeserializing call /// with FinishedDeserializing. class Deserializing { ExternalASTSource *Source; + public: explicit Deserializing(ExternalASTSource *source) : Source(source) { assert(Source); Source->StartedDeserializing(); } + ~Deserializing() { Source->FinishedDeserializing(); } @@ -122,7 +143,7 @@ public: virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); /// \brief Update an out-of-date identifier. - virtual void updateOutOfDateIdentifier(IdentifierInfo &II) { } + virtual void updateOutOfDateIdentifier(IdentifierInfo &II) {} /// \brief Find all declarations with the given name in the given context, /// and add them to the context by calling SetExternalVisibleDeclsForName @@ -154,12 +175,13 @@ public: const Module *ClangModule = nullptr; public: - ASTSourceDescriptor(){}; + ASTSourceDescriptor() = default; ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile, ASTFileSignature Signature) : PCHModuleName(std::move(Name)), Path(std::move(Path)), - ASTFile(std::move(ASTFile)), Signature(Signature){}; + ASTFile(std::move(ASTFile)), Signature(Signature) {} ASTSourceDescriptor(const Module &M); + std::string getModuleName() const; StringRef getPath() const { return Path; } StringRef getASTFile() const { return ASTFile; } @@ -246,7 +268,6 @@ public: /// The default implementation of this method is a no-op. virtual void PrintStats(); - /// \brief Perform layout on the given record. /// /// This routine allows the external AST source to provide an specific @@ -289,7 +310,7 @@ public: size_t mmap_bytes; MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes) - : malloc_bytes(malloc_bytes), mmap_bytes(mmap_bytes) {} + : malloc_bytes(malloc_bytes), mmap_bytes(mmap_bytes) {} }; /// Return the amount of memory used by memory buffers, breaking down @@ -329,12 +350,12 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr; + mutable uint64_t Ptr = 0; public: - LazyOffsetPtr() : Ptr(0) { } + LazyOffsetPtr() = default; + explicit LazyOffsetPtr(T *Ptr) : Ptr(reinterpret_cast<uint64_t>(Ptr)) {} - explicit LazyOffsetPtr(T *Ptr) : Ptr(reinterpret_cast<uint64_t>(Ptr)) { } explicit LazyOffsetPtr(uint64_t Offset) : Ptr((Offset << 1) | 0x01) { assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits"); if (Offset == 0) @@ -392,15 +413,16 @@ struct LazyGenerationalUpdatePtr { /// A cache of the value of this pointer, in the most recent generation in /// which we queried it. struct LazyData { - LazyData(ExternalASTSource *Source, T Value) - : ExternalSource(Source), LastGeneration(0), LastValue(Value) {} ExternalASTSource *ExternalSource; - uint32_t LastGeneration; + uint32_t LastGeneration = 0; T LastValue; + + LazyData(ExternalASTSource *Source, T Value) + : ExternalSource(Source), LastValue(Value) {} }; // Our value is represented as simply T if there is no external AST source. - typedef llvm::PointerUnion<T, LazyData*> ValueType; + using ValueType = llvm::PointerUnion<T, LazyData*>; ValueType Value; LazyGenerationalUpdatePtr(ValueType V) : Value(V) {} @@ -459,25 +481,31 @@ public: return LazyGenerationalUpdatePtr(ValueType::getFromOpaqueValue(Ptr)); } }; -} // end namespace clang + +} // namespace clang /// Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be /// placed into a PointerUnion. namespace llvm { + template<typename Owner, typename T, void (clang::ExternalASTSource::*Update)(Owner)> struct PointerLikeTypeTraits< clang::LazyGenerationalUpdatePtr<Owner, T, Update>> { - typedef clang::LazyGenerationalUpdatePtr<Owner, T, Update> Ptr; + using Ptr = clang::LazyGenerationalUpdatePtr<Owner, T, Update>; + static void *getAsVoidPointer(Ptr P) { return P.getOpaqueValue(); } static Ptr getFromVoidPointer(void *P) { return Ptr::getFromOpaqueValue(P); } + enum { NumLowBitsAvailable = PointerLikeTypeTraits<T>::NumLowBitsAvailable - 1 }; }; -} + +} // namespace llvm namespace clang { + /// \brief Represents a lazily-loaded vector of data. /// /// The lazily-loaded vector of data contains data that is partially loaded @@ -511,13 +539,14 @@ public: class iterator : public llvm::iterator_adaptor_base< iterator, int, std::random_access_iterator_tag, T, int, T *, T &> { + friend class LazyVector; + LazyVector *Self; iterator(LazyVector *Self, int Position) : iterator::iterator_adaptor_base(Position), Self(Self) {} bool isLoaded() const { return this->I < 0; } - friend class LazyVector; public: iterator() : iterator(nullptr, 0) {} @@ -562,23 +591,23 @@ public: }; /// \brief A lazy pointer to a statement. -typedef LazyOffsetPtr<Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt> - LazyDeclStmtPtr; +using LazyDeclStmtPtr = + LazyOffsetPtr<Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt>; /// \brief A lazy pointer to a declaration. -typedef LazyOffsetPtr<Decl, uint32_t, &ExternalASTSource::GetExternalDecl> - LazyDeclPtr; +using LazyDeclPtr = + LazyOffsetPtr<Decl, uint32_t, &ExternalASTSource::GetExternalDecl>; /// \brief A lazy pointer to a set of CXXCtorInitializers. -typedef LazyOffsetPtr<CXXCtorInitializer *, uint64_t, - &ExternalASTSource::GetExternalCXXCtorInitializers> - LazyCXXCtorInitializersPtr; +using LazyCXXCtorInitializersPtr = + LazyOffsetPtr<CXXCtorInitializer *, uint64_t, + &ExternalASTSource::GetExternalCXXCtorInitializers>; /// \brief A lazy pointer to a set of CXXBaseSpecifiers. -typedef LazyOffsetPtr<CXXBaseSpecifier, uint64_t, - &ExternalASTSource::GetExternalCXXBaseSpecifiers> - LazyCXXBaseSpecifiersPtr; +using LazyCXXBaseSpecifiersPtr = + LazyOffsetPtr<CXXBaseSpecifier, uint64_t, + &ExternalASTSource::GetExternalCXXBaseSpecifiers>; -} // end namespace clang +} // namespace clang -#endif +#endif // LLVM_CLANG_AST_EXTERNALASTSOURCE_H diff --git a/include/clang/AST/PrettyPrinter.h b/include/clang/AST/PrettyPrinter.h index 953ecada6c..2c0564335b 100644 --- a/include/clang/AST/PrettyPrinter.h +++ b/include/clang/AST/PrettyPrinter.h @@ -30,8 +30,8 @@ public: virtual bool handledStmt(Stmt* E, raw_ostream& OS) = 0; }; -/// \brief Describes how types, statements, expressions, and -/// declarations should be printed. +/// Describes how types, statements, expressions, and declarations should be +/// printed. /// /// This type is intended to be small and suitable for passing by value. /// It is very frequently copied. @@ -53,20 +53,20 @@ struct PrintingPolicy { IncludeNewlines(true), MSVCFormatting(false), ConstantsAsWritten(false), SuppressImplicitBase(false) { } - /// \brief Adjust this printing policy for cases where it's known that - /// we're printing C++ code (for instance, if AST dumping reaches a - /// C++-only construct). This should not be used if a real LangOptions - /// object is available. + /// Adjust this printing policy for cases where it's known that we're + /// printing C++ code (for instance, if AST dumping reaches a C++-only + /// construct). This should not be used if a real LangOptions object is + /// available. void adjustForCPlusPlus() { SuppressTagKeyword = true; Bool = true; UseVoidForZeroParams = false; } - /// \brief The number of spaces to use to indent each line. + /// The number of spaces to use to indent each line. unsigned Indentation : 8; - /// \brief Whether we should suppress printing of the actual specifiers for + /// Whether we should suppress printing of the actual specifiers for /// the given type or declaration. /// /// This flag is only used when we are printing declarators beyond @@ -82,7 +82,7 @@ struct PrintingPolicy { /// "const int" type specifier and instead only print the "*y". bool SuppressSpecifiers : 1; - /// \brief Whether type printing should skip printing the tag keyword. + /// Whether type printing should skip printing the tag keyword. /// /// This is used when printing the inner type of elaborated types, /// (as the tag keyword is part of the elaborated type): @@ -92,7 +92,7 @@ struct PrintingPolicy { /// \endcode bool SuppressTagKeyword : 1; - /// \brief When true, include the body of a tag definition. + /// When true, include the body of a tag definition. /// /// This is used to place the definition of a struct /// in the middle of another declaration as with: @@ -102,14 +102,14 @@ struct PrintingPolicy { /// \endcode bool IncludeTagDefinition : 1; - /// \brief Suppresses printing of scope specifiers. + /// Suppresses printing of scope specifiers. bool SuppressScope : 1; - /// \brief Suppress printing parts of scope specifiers that don't need + /// Suppress printing parts of scope specifiers that don't need /// to be written, e.g., for inline or anonymous namespaces. bool SuppressUnwrittenScope : 1; - /// \brief Suppress printing of variable initializers. + /// Suppress printing of variable initializers. /// /// This flag is used when printing the loop variable in a for-range /// statement. For example, given: @@ -122,8 +122,8 @@ struct PrintingPolicy { /// internal initializer constructed for x will not be printed. bool SuppressInitializers : 1; - /// \brief Whether we should print the sizes of constant array expressions - /// as written in the sources. + /// Whether we should print the sizes of constant array expressions as written + /// in the sources. /// /// This flag determines whether array types declared as /// @@ -140,69 +140,67 @@ struct PrintingPolicy { /// \endcode bool ConstantArraySizeAsWritten : 1; - /// \brief When printing an anonymous tag name, also print the location of - /// that entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just - /// prints "(anonymous)" for the name. + /// When printing an anonymous tag name, also print the location of that + /// entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just prints + /// "(anonymous)" for the name. bool AnonymousTagLocations : 1; - /// \brief When true, suppress printing of the __strong lifetime qualifier in - /// ARC. + /// When true, suppress printing of the __strong lifetime qualifier in ARC. unsigned SuppressStrongLifetime : 1; - /// \brief When true, suppress printing of lifetime qualifier in - /// ARC. + /// When true, suppress printing of lifetime qualifier in ARC. unsigned SuppressLifetimeQualifiers : 1; /// When true, suppresses printing template arguments in names of C++ /// constructors. unsigned SuppressTemplateArgsInCXXConstructors : 1; - /// \brief Whether we can use 'bool' rather than '_Bool' (even if the language + /// Whether we can use 'bool' rather than '_Bool' (even if the language /// doesn't actually have 'bool', because, e.g., it is defined as a macro). unsigned Bool : 1; - /// \brief Whether we can use 'restrict' rather than '__restrict'. + /// Whether we can use 'restrict' rather than '__restrict'. unsigned Restrict : 1; - /// \brief Whether we can use 'alignof' rather than '__alignof'. + /// Whether we can use 'alignof' rather than '__alignof'. unsigned Alignof : 1; - /// \brief Whether we can use '_Alignof' rather than '__alignof'. + /// Whether we can use '_Alignof' rather than '__alignof'. unsigned UnderscoreAlignof : 1; - /// \brief Whether we should use '(void)' rather than '()' for a function - /// prototype with zero parameters. + /// Whether we should use '(void)' rather than '()' for a function prototype + /// with zero parameters. unsigned UseVoidForZeroParams : 1; - /// \brief Provide a 'terse' output. + /// Provide a 'terse' output. /// /// For example, in this mode we don't print function bodies, class members, /// declarations inside namespaces etc. Effectively, this should print /// only the requested declaration. unsigned TerseOutput : 1; - /// \brief When true, do certain refinement needed for producing proper - /// declaration tag; such as, do not print attributes attached to the declaration. + /// When true, do certain refinement needed for producing proper declaration + /// tag; such as, do not print attributes attached to the declaration. /// unsigned PolishForDeclaration : 1; - /// \brief When true, print the half-precision floating-point type as 'half' + /// When true, print the half-precision floating-point type as 'half' /// instead of '__fp16' unsigned Half : 1; - /// \brief When true, print the built-in wchar_t type as __wchar_t. For use in + /// When true, print the built-in wchar_t type as __wchar_t. For use in /// Microsoft mode when wchar_t is not available. unsigned MSWChar : 1; - /// \brief When true, include newlines after statements like "break", etc. + /// When true, include newlines after statements like "break", etc. unsigned IncludeNewlines : 1; - /// \brief Use whitespace and punctuation like MSVC does. In particular, this - /// prints anonymous namespaces as `anonymous namespace' and does not insert - /// spaces after template arguments. + /// Use whitespace and punctuation like MSVC does. In particular, this prints + /// anonymous namespaces as `anonymous namespace' and does not insert spaces + /// after template arguments. bool MSVCFormatting : 1; - /// \brief Whether we should print the constant expressions as written in the + /// Whether we should print the constant expressions as written in the /// sources. /// /// This flag determines whether constants expressions like @@ -220,7 +218,7 @@ struct PrintingPolicy { /// \endcode bool ConstantsAsWritten : 1; - /// \brief When true, don't print the implicit 'self' or 'this' expressions. + /// When true, don't print the implicit 'self' or 'this' expressions. bool SuppressImplicitBase : 1; }; diff --git a/include/clang/Tooling/Core/QualTypeNames.h b/include/clang/AST/QualTypeNames.h index 7248356e74..86d805feee 100644 --- a/include/clang/Tooling/Core/QualTypeNames.h +++ b/include/clang/AST/QualTypeNames.h @@ -56,8 +56,8 @@ // // ===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H -#define LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H +#ifndef LLVM_CLANG_AST_QUALTYPENAMES_H +#define LLVM_CLANG_AST_QUALTYPENAMES_H #include "clang/AST/ASTContext.h" @@ -71,9 +71,20 @@ namespace TypeName { /// \param[in] Ctx - the ASTContext to be used. /// \param[in] WithGlobalNsPrefix - If true, then the global namespace /// specifier "::" will be prepended to the fully qualified name. -std::string getFullyQualifiedName(QualType QT, - const ASTContext &Ctx, +std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix = false); -} // end namespace TypeName -} // end namespace clang -#endif // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H + +/// \brief Generates a QualType that can be used to name the same type +/// if used at the end of the current translation unit. This ignores +/// issues such as type shadowing. +/// +/// \param[in] QT - the type for which the fully qualified type will be +/// returned. +/// \param[in] Ctx - the ASTContext to be used. +/// \param[in] WithGlobalNsPrefix - Indicate whether the global namespace +/// specifier "::" should be prepended or not. +QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, + bool WithGlobalNsPrefix = false); +} // end namespace TypeName +} // end namespace clang +#endif // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def index 8e276e8445..34ffd8d813 100644 --- a/include/clang/Basic/Builtins.def +++ b/include/clang/Basic/Builtins.def @@ -103,9 +103,9 @@ #endif // Standard libc/libm functions: -BUILTIN(__builtin_atan2 , "ddd" , "Fnc") -BUILTIN(__builtin_atan2f, "fff" , "Fnc") -BUILTIN(__builtin_atan2l, "LdLdLd", "Fnc") +BUILTIN(__builtin_atan2 , "ddd" , "Fne") +BUILTIN(__builtin_atan2f, "fff" , "Fne") +BUILTIN(__builtin_atan2l, "LdLdLd", "Fne") BUILTIN(__builtin_abs , "ii" , "ncF") BUILTIN(__builtin_copysign, "ddd", "ncF") BUILTIN(__builtin_copysignf, "fff", "ncF") @@ -113,9 +113,9 @@ BUILTIN(__builtin_copysignl, "LdLdLd", "ncF") BUILTIN(__builtin_fabs , "dd" , "ncF") BUILTIN(__builtin_fabsf, "ff" , "ncF") BUILTIN(__builtin_fabsl, "LdLd", "ncF") -BUILTIN(__builtin_fmod , "ddd" , "Fnc") -BUILTIN(__builtin_fmodf, "fff" , "Fnc") -BUILTIN(__builtin_fmodl, "LdLdLd", "Fnc") +BUILTIN(__builtin_fmod , "ddd" , "Fne") +BUILTIN(__builtin_fmodf, "fff" , "Fne") +BUILTIN(__builtin_fmodl, "LdLdLd", "Fne") BUILTIN(__builtin_frexp , "ddi*" , "Fn") BUILTIN(__builtin_frexpf, "ffi*" , "Fn") BUILTIN(__builtin_frexpl, "LdLdi*", "Fn") @@ -127,9 +127,9 @@ BUILTIN(__builtin_inff , "f" , "nc") BUILTIN(__builtin_infl , "Ld" , "nc") BUILTIN(__builtin_labs , "LiLi" , "Fnc") BUILTIN(__builtin_llabs, "LLiLLi", "Fnc") -BUILTIN(__builtin_ldexp , "ddi" , "Fnc") -BUILTIN(__builtin_ldexpf, "ffi" , "Fnc") -BUILTIN(__builtin_ldexpl, "LdLdi", "Fnc") +BUILTIN(__builtin_ldexp , "ddi" , "Fne") +BUILTIN(__builtin_ldexpf, "ffi" , "Fne") +BUILTIN(__builtin_ldexpl, "LdLdi", "Fne") BUILTIN(__builtin_modf , "ddd*" , "Fn") BUILTIN(__builtin_modff, "fff*" , "Fn") BUILTIN(__builtin_modfl, "LdLdLd*", "Fn") @@ -142,119 +142,119 @@ BUILTIN(__builtin_nansl, "LdcC*", "ncF") BUILTIN(__builtin_powi , "ddi" , "Fnc") BUILTIN(__builtin_powif, "ffi" , "Fnc") BUILTIN(__builtin_powil, "LdLdi", "Fnc") -BUILTIN(__builtin_pow , "ddd" , "Fnc") -BUILTIN(__builtin_powf, "fff" , "Fnc") -BUILTIN(__builtin_powl, "LdLdLd", "Fnc") +BUILTIN(__builtin_pow , "ddd" , "Fne") +BUILTIN(__builtin_powf, "fff" , "Fne") +BUILTIN(__builtin_powl, "LdLdLd", "Fne") // Standard unary libc/libm functions with double/float/long double variants: -BUILTIN(__builtin_acos , "dd" , "Fnc") -BUILTIN(__builtin_acosf, "ff" , "Fnc") -BUILTIN(__builtin_acosl, "LdLd", "Fnc") -BUILTIN(__builtin_acosh , "dd" , "Fnc") -BUILTIN(__builtin_acoshf, "ff" , "Fnc") -BUILTIN(__builtin_acoshl, "LdLd", "Fnc") -BUILTIN(__builtin_asin , "dd" , "Fnc") -BUILTIN(__builtin_asinf, "ff" , "Fnc") -BUILTIN(__builtin_asinl, "LdLd", "Fnc") -BUILTIN(__builtin_asinh , "dd" , "Fnc") -BUILTIN(__builtin_asinhf, "ff" , "Fnc") -BUILTIN(__builtin_asinhl, "LdLd", "Fnc") -BUILTIN(__builtin_atan , "dd" , "Fnc") -BUILTIN(__builtin_atanf, "ff" , "Fnc") -BUILTIN(__builtin_atanl, "LdLd", "Fnc") -BUILTIN(__builtin_atanh , "dd", "Fnc") -BUILTIN(__builtin_atanhf, "ff", "Fnc") -BUILTIN(__builtin_atanhl, "LdLd", "Fnc") -BUILTIN(__builtin_cbrt , "dd", "Fnc") -BUILTIN(__builtin_cbrtf, "ff", "Fnc") -BUILTIN(__builtin_cbrtl, "LdLd", "Fnc") +BUILTIN(__builtin_acos , "dd" , "Fne") +BUILTIN(__builtin_acosf, "ff" , "Fne") +BUILTIN(__builtin_acosl, "LdLd", "Fne") +BUILTIN(__builtin_acosh , "dd" , "Fne") +BUILTIN(__builtin_acoshf, "ff" , "Fne") +BUILTIN(__builtin_acoshl, "LdLd", "Fne") +BUILTIN(__builtin_asin , "dd" , "Fne") +BUILTIN(__builtin_asinf, "ff" , "Fne") +BUILTIN(__builtin_asinl, "LdLd", "Fne") +BUILTIN(__builtin_asinh , "dd" , "Fne") +BUILTIN(__builtin_asinhf, "ff" , "Fne") +BUILTIN(__builtin_asinhl, "LdLd", "Fne") +BUILTIN(__builtin_atan , "dd" , "Fne") +BUILTIN(__builtin_atanf, "ff" , "Fne") +BUILTIN(__builtin_atanl, "LdLd", "Fne") +BUILTIN(__builtin_atanh , "dd", "Fne") +BUILTIN(__builtin_atanhf, "ff", "Fne") +BUILTIN(__builtin_atanhl, "LdLd", "Fne") +BUILTIN(__builtin_cbrt , "dd", "Fne") +BUILTIN(__builtin_cbrtf, "ff", "Fne") +BUILTIN(__builtin_cbrtl, "LdLd", "Fne") BUILTIN(__builtin_ceil , "dd" , "Fnc") BUILTIN(__builtin_ceilf, "ff" , "Fnc") BUILTIN(__builtin_ceill, "LdLd", "Fnc") -BUILTIN(__builtin_cos , "dd" , "Fnc") -BUILTIN(__builtin_cosf, "ff" , "Fnc") -BUILTIN(__builtin_cosh , "dd" , "Fnc") -BUILTIN(__builtin_coshf, "ff" , "Fnc") -BUILTIN(__builtin_coshl, "LdLd", "Fnc") -BUILTIN(__builtin_cosl, "LdLd", "Fnc") -BUILTIN(__builtin_erf , "dd", "Fnc") -BUILTIN(__builtin_erff, "ff", "Fnc") -BUILTIN(__builtin_erfl, "LdLd", "Fnc") -BUILTIN(__builtin_erfc , "dd", "Fnc") -BUILTIN(__builtin_erfcf, "ff", "Fnc") -BUILTIN(__builtin_erfcl, "LdLd", "Fnc") -BUILTIN(__builtin_exp , "dd" , "Fnc") -BUILTIN(__builtin_expf, "ff" , "Fnc") -BUILTIN(__builtin_expl, "LdLd", "Fnc") -BUILTIN(__builtin_exp2 , "dd" , "Fnc") -BUILTIN(__builtin_exp2f, "ff" , "Fnc") -BUILTIN(__builtin_exp2l, "LdLd", "Fnc") -BUILTIN(__builtin_expm1 , "dd", "Fnc") -BUILTIN(__builtin_expm1f, "ff", "Fnc") -BUILTIN(__builtin_expm1l, "LdLd", "Fnc") -BUILTIN(__builtin_fdim, "ddd", "Fnc") -BUILTIN(__builtin_fdimf, "fff", "Fnc") -BUILTIN(__builtin_fdiml, "LdLdLd", "Fnc") +BUILTIN(__builtin_cos , "dd" , "Fne") +BUILTIN(__builtin_cosf, "ff" , "Fne") +BUILTIN(__builtin_cosh , "dd" , "Fne") +BUILTIN(__builtin_coshf, "ff" , "Fne") +BUILTIN(__builtin_coshl, "LdLd", "Fne") +BUILTIN(__builtin_cosl, "LdLd", "Fne") +BUILTIN(__builtin_erf , "dd", "Fne") +BUILTIN(__builtin_erff, "ff", "Fne") +BUILTIN(__builtin_erfl, "LdLd", "Fne") +BUILTIN(__builtin_erfc , "dd", "Fne") +BUILTIN(__builtin_erfcf, "ff", "Fne") +BUILTIN(__builtin_erfcl, "LdLd", "Fne") +BUILTIN(__builtin_exp , "dd" , "Fne") +BUILTIN(__builtin_expf, "ff" , "Fne") +BUILTIN(__builtin_expl, "LdLd", "Fne") +BUILTIN(__builtin_exp2 , "dd" , "Fne") +BUILTIN(__builtin_exp2f, "ff" , "Fne") +BUILTIN(__builtin_exp2l, "LdLd", "Fne") +BUILTIN(__builtin_expm1 , "dd", "Fne") +BUILTIN(__builtin_expm1f, "ff", "Fne") +BUILTIN(__builtin_expm1l, "LdLd", "Fne") +BUILTIN(__builtin_fdim, "ddd", "Fne") +BUILTIN(__builtin_fdimf, "fff", "Fne") +BUILTIN(__builtin_fdiml, "LdLdLd", "Fne") BUILTIN(__builtin_floor , "dd" , "Fnc") BUILTIN(__builtin_floorf, "ff" , "Fnc") BUILTIN(__builtin_floorl, "LdLd", "Fnc") -BUILTIN(__builtin_fma, "dddd", "Fnc") -BUILTIN(__builtin_fmaf, "ffff", "Fnc") -BUILTIN(__builtin_fmal, "LdLdLdLd", "Fnc") +BUILTIN(__builtin_fma, "dddd", "Fne") +BUILTIN(__builtin_fmaf, "ffff", "Fne") +BUILTIN(__builtin_fmal, "LdLdLdLd", "Fne") BUILTIN(__builtin_fmax, "ddd", "Fnc") BUILTIN(__builtin_fmaxf, "fff", "Fnc") BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc") BUILTIN(__builtin_fmin, "ddd", "Fnc") BUILTIN(__builtin_fminf, "fff", "Fnc") BUILTIN(__builtin_fminl, "LdLdLd", "Fnc") -BUILTIN(__builtin_hypot , "ddd" , "Fnc") -BUILTIN(__builtin_hypotf, "fff" , "Fnc") -BUILTIN(__builtin_hypotl, "LdLdLd", "Fnc") -BUILTIN(__builtin_ilogb , "id", "Fnc") -BUILTIN(__builtin_ilogbf, "if", "Fnc") -BUILTIN(__builtin_ilogbl, "iLd", "Fnc") -BUILTIN(__builtin_lgamma , "dd", "Fnc") -BUILTIN(__builtin_lgammaf, "ff", "Fnc") -BUILTIN(__builtin_lgammal, "LdLd", "Fnc") -BUILTIN(__builtin_llrint, "LLid", "Fnc") -BUILTIN(__builtin_llrintf, "LLif", "Fnc") -BUILTIN(__builtin_llrintl, "LLiLd", "Fnc") -BUILTIN(__builtin_llround , "LLid", "Fnc") -BUILTIN(__builtin_llroundf, "LLif", "Fnc") -BUILTIN(__builtin_llroundl, "LLiLd", "Fnc") -BUILTIN(__builtin_log , "dd" , "Fnc") -BUILTIN(__builtin_log10 , "dd" , "Fnc") -BUILTIN(__builtin_log10f, "ff" , "Fnc") -BUILTIN(__builtin_log10l, "LdLd", "Fnc") -BUILTIN(__builtin_log1p , "dd" , "Fnc") -BUILTIN(__builtin_log1pf, "ff" , "Fnc") -BUILTIN(__builtin_log1pl, "LdLd", "Fnc") -BUILTIN(__builtin_log2, "dd" , "Fnc") -BUILTIN(__builtin_log2f, "ff" , "Fnc") -BUILTIN(__builtin_log2l, "LdLd" , "Fnc") -BUILTIN(__builtin_logb , "dd", "Fnc") -BUILTIN(__builtin_logbf, "ff", "Fnc") -BUILTIN(__builtin_logbl, "LdLd", "Fnc") -BUILTIN(__builtin_logf, "ff" , "Fnc") -BUILTIN(__builtin_logl, "LdLd", "Fnc") -BUILTIN(__builtin_lrint , "Lid", "Fnc") -BUILTIN(__builtin_lrintf, "Lif", "Fnc") -BUILTIN(__builtin_lrintl, "LiLd", "Fnc") -BUILTIN(__builtin_lround , "Lid", "Fnc") -BUILTIN(__builtin_lroundf, "Lif", "Fnc") -BUILTIN(__builtin_lroundl, "LiLd", "Fnc") +BUILTIN(__builtin_hypot , "ddd" , "Fne") +BUILTIN(__builtin_hypotf, "fff" , "Fne") +BUILTIN(__builtin_hypotl, "LdLdLd", "Fne") +BUILTIN(__builtin_ilogb , "id", "Fne") +BUILTIN(__builtin_ilogbf, "if", "Fne") +BUILTIN(__builtin_ilogbl, "iLd", "Fne") +BUILTIN(__builtin_lgamma , "dd", "Fn") +BUILTIN(__builtin_lgammaf, "ff", "Fn") +BUILTIN(__builtin_lgammal, "LdLd", "Fn") +BUILTIN(__builtin_llrint, "LLid", "Fne") +BUILTIN(__builtin_llrintf, "LLif", "Fne") +BUILTIN(__builtin_llrintl, "LLiLd", "Fne") +BUILTIN(__builtin_llround , "LLid", "Fne") +BUILTIN(__builtin_llroundf, "LLif", "Fne") +BUILTIN(__builtin_llroundl, "LLiLd", "Fne") +BUILTIN(__builtin_log , "dd" , "Fne") +BUILTIN(__builtin_log10 , "dd" , "Fne") +BUILTIN(__builtin_log10f, "ff" , "Fne") +BUILTIN(__builtin_log10l, "LdLd", "Fne") +BUILTIN(__builtin_log1p , "dd" , "Fne") +BUILTIN(__builtin_log1pf, "ff" , "Fne") +BUILTIN(__builtin_log1pl, "LdLd", "Fne") +BUILTIN(__builtin_log2, "dd" , "Fne") +BUILTIN(__builtin_log2f, "ff" , "Fne") +BUILTIN(__builtin_log2l, "LdLd" , "Fne") +BUILTIN(__builtin_logb , "dd", "Fne") +BUILTIN(__builtin_logbf, "ff", "Fne") +BUILTIN(__builtin_logbl, "LdLd", "Fne") +BUILTIN(__builtin_logf, "ff" , "Fne") +BUILTIN(__builtin_logl, "LdLd", "Fne") +BUILTIN(__builtin_lrint , "Lid", "Fne") +BUILTIN(__builtin_lrintf, "Lif", "Fne") +BUILTIN(__builtin_lrintl, "LiLd", "Fne") +BUILTIN(__builtin_lround , "Lid", "Fne") +BUILTIN(__builtin_lroundf, "Lif", "Fne") +BUILTIN(__builtin_lroundl, "LiLd", "Fne") BUILTIN(__builtin_nearbyint , "dd", "Fnc") BUILTIN(__builtin_nearbyintf, "ff", "Fnc") BUILTIN(__builtin_nearbyintl, "LdLd", "Fnc") -BUILTIN(__builtin_nextafter , "ddd", "Fnc") -BUILTIN(__builtin_nextafterf, "fff", "Fnc") -BUILTIN(__builtin_nextafterl, "LdLdLd", "Fnc") -BUILTIN(__builtin_nexttoward , "ddLd", "Fnc") -BUILTIN(__builtin_nexttowardf, "ffLd", "Fnc") -BUILTIN(__builtin_nexttowardl, "LdLdLd", "Fnc") -BUILTIN(__builtin_remainder , "ddd", "Fnc") -BUILTIN(__builtin_remainderf, "fff", "Fnc") -BUILTIN(__builtin_remainderl, "LdLdLd", "Fnc") +BUILTIN(__builtin_nextafter , "ddd", "Fne") +BUILTIN(__builtin_nextafterf, "fff", "Fne") +BUILTIN(__builtin_nextafterl, "LdLdLd", "Fne") +BUILTIN(__builtin_nexttoward , "ddLd", "Fne") +BUILTIN(__builtin_nexttowardf, "ffLd", "Fne") +BUILTIN(__builtin_nexttowardl, "LdLdLd", "Fne") +BUILTIN(__builtin_remainder , "ddd", "Fne") +BUILTIN(__builtin_remainderf, "fff", "Fne") +BUILTIN(__builtin_remainderl, "LdLdLd", "Fne") BUILTIN(__builtin_remquo , "dddi*", "Fn") BUILTIN(__builtin_remquof, "fffi*", "Fn") BUILTIN(__builtin_remquol, "LdLdLdi*", "Fn") @@ -264,30 +264,30 @@ BUILTIN(__builtin_rintl, "LdLd", "Fnc") BUILTIN(__builtin_round, "dd" , "Fnc") BUILTIN(__builtin_roundf, "ff" , "Fnc") BUILTIN(__builtin_roundl, "LdLd" , "Fnc") -BUILTIN(__builtin_scalbln , "ddLi", "Fnc") -BUILTIN(__builtin_scalblnf, "ffLi", "Fnc") -BUILTIN(__builtin_scalblnl, "LdLdLi", "Fnc") -BUILTIN(__builtin_scalbn , "ddi", "Fnc") -BUILTIN(__builtin_scalbnf, "ffi", "Fnc") -BUILTIN(__builtin_scalbnl, "LdLdi", "Fnc") -BUILTIN(__builtin_sin , "dd" , "Fnc") -BUILTIN(__builtin_sinf, "ff" , "Fnc") -BUILTIN(__builtin_sinh , "dd" , "Fnc") -BUILTIN(__builtin_sinhf, "ff" , "Fnc") -BUILTIN(__builtin_sinhl, "LdLd", "Fnc") -BUILTIN(__builtin_sinl, "LdLd", "Fnc") -BUILTIN(__builtin_sqrt , "dd" , "Fnc") -BUILTIN(__builtin_sqrtf, "ff" , "Fnc") -BUILTIN(__builtin_sqrtl, "LdLd", "Fnc") -BUILTIN(__builtin_tan , "dd" , "Fnc") -BUILTIN(__builtin_tanf, "ff" , "Fnc") -BUILTIN(__builtin_tanh , "dd" , "Fnc") -BUILTIN(__builtin_tanhf, "ff" , "Fnc") -BUILTIN(__builtin_tanhl, "LdLd", "Fnc") -BUILTIN(__builtin_tanl, "LdLd", "Fnc") -BUILTIN(__builtin_tgamma , "dd", "Fnc") -BUILTIN(__builtin_tgammaf, "ff", "Fnc") -BUILTIN(__builtin_tgammal, "LdLd", "Fnc") +BUILTIN(__builtin_scalbln , "ddLi", "Fne") +BUILTIN(__builtin_scalblnf, "ffLi", "Fne") +BUILTIN(__builtin_scalblnl, "LdLdLi", "Fne") +BUILTIN(__builtin_scalbn , "ddi", "Fne") +BUILTIN(__builtin_scalbnf, "ffi", "Fne") +BUILTIN(__builtin_scalbnl, "LdLdi", "Fne") +BUILTIN(__builtin_sin , "dd" , "Fne") +BUILTIN(__builtin_sinf, "ff" , "Fne") +BUILTIN(__builtin_sinh , "dd" , "Fne") +BUILTIN(__builtin_sinhf, "ff" , "Fne") +BUILTIN(__builtin_sinhl, "LdLd", "Fne") +BUILTIN(__builtin_sinl, "LdLd", "Fne") +BUILTIN(__builtin_sqrt , "dd" , "Fne") +BUILTIN(__builtin_sqrtf, "ff" , "Fne") +BUILTIN(__builtin_sqrtl, "LdLd", "Fne") +BUILTIN(__builtin_tan , "dd" , "Fne") +BUILTIN(__builtin_tanf, "ff" , "Fne") +BUILTIN(__builtin_tanh , "dd" , "Fne") +BUILTIN(__builtin_tanhf, "ff" , "Fne") +BUILTIN(__builtin_tanhl, "LdLd", "Fne") +BUILTIN(__builtin_tanl, "LdLd", "Fne") +BUILTIN(__builtin_tgamma , "dd", "Fne") +BUILTIN(__builtin_tgammaf, "ff", "Fne") +BUILTIN(__builtin_tgammal, "LdLd", "Fne") BUILTIN(__builtin_trunc , "dd", "Fnc") BUILTIN(__builtin_truncf, "ff", "Fnc") BUILTIN(__builtin_truncl, "LdLd", "Fnc") @@ -1162,6 +1162,10 @@ LIBBUILTIN(remainder, "ddd", "fne", "math.h", ALL_LANGUAGES) LIBBUILTIN(remainderf, "fff", "fne", "math.h", ALL_LANGUAGES) LIBBUILTIN(remainderl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES) +LIBBUILTIN(remquo, "dddi*", "fn", "math.h", ALL_LANGUAGES) +LIBBUILTIN(remquof, "fffi*", "fn", "math.h", ALL_LANGUAGES) +LIBBUILTIN(remquol, "LdLdLdi*", "fn", "math.h", ALL_LANGUAGES) + LIBBUILTIN(rint, "dd", "fnc", "math.h", ALL_LANGUAGES) LIBBUILTIN(rintf, "ff", "fnc", "math.h", ALL_LANGUAGES) LIBBUILTIN(rintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES) diff --git a/include/clang/Basic/BuiltinsNVPTX.def b/include/clang/Basic/BuiltinsNVPTX.def index caa860480f..b596793c9c 100644 --- a/include/clang/Basic/BuiltinsNVPTX.def +++ b/include/clang/Basic/BuiltinsNVPTX.def @@ -481,7 +481,7 @@ TARGET_BUILTIN(__nvvm_atom_cta_add_gen_f, "ffD*f", "n", "satom") TARGET_BUILTIN(__nvvm_atom_sys_add_gen_f, "ffD*f", "n", "satom") BUILTIN(__nvvm_atom_add_g_d, "ddD*1d", "n") BUILTIN(__nvvm_atom_add_s_d, "ddD*3d", "n") -BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n") +TARGET_BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n", "satom") TARGET_BUILTIN(__nvvm_atom_cta_add_gen_d, "ddD*d", "n", "satom") TARGET_BUILTIN(__nvvm_atom_sys_add_gen_d, "ddD*d", "n", "satom") diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def index d57ea8f119..6a897b3942 100644 --- a/include/clang/Basic/BuiltinsX86.def +++ b/include/clang/Basic/BuiltinsX86.def @@ -910,39 +910,10 @@ TARGET_BUILTIN(__builtin_ia32_cvttps2dq512_mask, "V16iV16fV16iUsIi", "", "avx512 TARGET_BUILTIN(__builtin_ia32_cvttps2udq512_mask, "V16iV16fV16iUsIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_cvttpd2dq512_mask, "V8iV8dV8iUcIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_cvttpd2udq512_mask, "V8iV8dV8iUcIi", "", "avx512f") -TARGET_BUILTIN(__builtin_ia32_cmpps512_mask, "UsV16fV16fIiUsIi", "", "avx512f") +TARGET_BUILTIN(__builtin_ia32_cmpps512_mask, "UsV16fV16fIiUsIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_cmpps256_mask, "UcV8fV8fIiUc", "", "avx512vl") TARGET_BUILTIN(__builtin_ia32_cmpps128_mask, "UcV4fV4fIiUc", "", "avx512vl") - -TARGET_BUILTIN(__builtin_ia32_pcmpeqb512_mask, "LLiV64cV64cLLi", "", "avx512bw") -TARGET_BUILTIN(__builtin_ia32_pcmpeqd512_mask, "sV16iV16is", "", "avx512f") -TARGET_BUILTIN(__builtin_ia32_pcmpeqq512_mask, "cV8LLiV8LLic", "", "avx512f") -TARGET_BUILTIN(__builtin_ia32_pcmpeqw512_mask, "iV32sV32si", "", "avx512bw") - -TARGET_BUILTIN(__builtin_ia32_pcmpeqb256_mask, "iV32cV32ci", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_pcmpeqd256_mask, "cV8iV8ic", "", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_pcmpeqq256_mask, "cV4LLiV4LLic", "", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_pcmpeqw256_mask, "sV16sV16ss", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_pcmpeqb128_mask, "sV16cV16cs", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_pcmpeqd128_mask, "cV4iV4ic", "", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_pcmpeqq128_mask, "cV2LLiV2LLic", "", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_pcmpeqw128_mask, "cV8sV8sc", "", "avx512vl,avx512bw") - -TARGET_BUILTIN(__builtin_ia32_pcmpgtb512_mask, "LLiV64cV64cLLi", "", "avx512bw") -TARGET_BUILTIN(__builtin_ia32_pcmpgtd512_mask, "sV16iV16is", "", "avx512f") -TARGET_BUILTIN(__builtin_ia32_pcmpgtq512_mask, "cV8LLiV8LLic", "", "avx512f") -TARGET_BUILTIN(__builtin_ia32_pcmpgtw512_mask, "iV32sV32si", "", "avx512bw") - -TARGET_BUILTIN(__builtin_ia32_pcmpgtb256_mask, "iV32cV32ci", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_pcmpgtd256_mask, "cV8iV8ic", "", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_pcmpgtq256_mask, "cV4LLiV4LLic", "", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_pcmpgtw256_mask, "sV16sV16ss", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_pcmpgtb128_mask, "sV16cV16cs", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_pcmpgtd128_mask, "cV4iV4ic", "", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_pcmpgtq128_mask, "cV2LLiV2LLic", "", "avx512vl") -TARGET_BUILTIN(__builtin_ia32_pcmpgtw128_mask, "cV8sV8sc", "", "avx512vl,avx512bw") - TARGET_BUILTIN(__builtin_ia32_cmppd512_mask, "UcV8dV8dIiUcIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_cmppd256_mask, "UcV4dV4dIiUc", "", "avx512vl") TARGET_BUILTIN(__builtin_ia32_cmppd128_mask, "UcV2dV2dIiUc", "", "avx512vl") @@ -1580,12 +1551,6 @@ TARGET_BUILTIN(__builtin_ia32_cvtmask2q128, "V2LLiUc","","avx512dq,avx512vl") TARGET_BUILTIN(__builtin_ia32_cvtmask2q256, "V4LLiUc","","avx512dq,avx512vl") TARGET_BUILTIN(__builtin_ia32_cvtq2mask128, "UcV2LLi","","avx512dq,avx512vl") TARGET_BUILTIN(__builtin_ia32_cvtq2mask256, "UcV4LLi","","avx512dq,avx512vl") -TARGET_BUILTIN(__builtin_ia32_broadcastmb512, "V8LLiUc","","avx512cd") -TARGET_BUILTIN(__builtin_ia32_broadcastmw512, "V16iUs","","avx512cd") -TARGET_BUILTIN(__builtin_ia32_broadcastmb128, "V2LLiUc","","avx512cd,avx512vl") -TARGET_BUILTIN(__builtin_ia32_broadcastmb256, "V4LLiUc","","avx512cd,avx512vl") -TARGET_BUILTIN(__builtin_ia32_broadcastmw128, "V4iUs","","avx512cd,avx512vl") -TARGET_BUILTIN(__builtin_ia32_broadcastmw256, "V8iUs","","avx512cd,avx512vl") TARGET_BUILTIN(__builtin_ia32_pmovsdb512_mask, "V16cV16iV16cUs","","avx512f") TARGET_BUILTIN(__builtin_ia32_pmovsdb512mem_mask, "vV16c*V16iUs","","avx512f") TARGET_BUILTIN(__builtin_ia32_pmovswb512mem_mask, "vV32c*V32sUi","","avx512bw") diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index b8538f92cb..c27b495168 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2778,7 +2778,7 @@ def err_attribute_weakref_not_global_context : Error< def err_attribute_weakref_without_alias : Error< "weakref declaration of %0 must also have an alias attribute">; def err_alias_not_supported_on_darwin : Error < - "only weak aliases are supported on darwin">; + "aliases are not supported on darwin">; def err_alias_to_undefined : Error< "%select{alias|ifunc}0 must point to a defined %select{variable or |}1function">; def warn_alias_to_weak_alias : Warning< diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 3938e09890..8e3c15afbf 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -1,4 +1,4 @@ -//===--- IdentifierTable.h - Hash table for identifier lookup ---*- C++ -*-===// +//===- IdentifierTable.h - Hash table for identifier lookup -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,11 +6,11 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines the clang::IdentifierInfo, clang::IdentifierTable, and /// clang::Selector interfaces. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H @@ -18,35 +18,29 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/PointerLikeTypeTraits.h" +#include "llvm/Support/type_traits.h" #include <cassert> #include <cstddef> #include <cstdint> #include <cstring> -#include <new> #include <string> #include <utility> -namespace llvm { - - template <typename T> struct DenseMapInfo; - -} // end namespace llvm - namespace clang { - class LangOptions; - class IdentifierInfo; - class IdentifierTable; - class SourceLocation; - class MultiKeywordSelector; // private class used by Selector - class DeclarationName; // AST class that stores declaration names +class IdentifierInfo; +class LangOptions; +class MultiKeywordSelector; +class SourceLocation; - /// \brief A simple pair of identifier info and location. - typedef std::pair<IdentifierInfo*, SourceLocation> IdentifierLocPair; +/// \brief A simple pair of identifier info and location. +using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>; /// One of these records is kept for each identifier that /// is lexed. This contains information about whether the token was \#define'd, @@ -85,8 +79,10 @@ class IdentifierInfo { // keyword. // 29 bit left in 64-bit word. - void *FETokenInfo; // Managed by the language front-end. - llvm::StringMapEntry<IdentifierInfo*> *Entry; + // Managed by the language front-end. + void *FETokenInfo = nullptr; + + llvm::StringMapEntry<IdentifierInfo *> *Entry = nullptr; public: IdentifierInfo(); @@ -104,7 +100,6 @@ public: /// \brief Return the beginning of the actual null-terminated string for this /// identifier. - /// const char *getNameStart() const { if (Entry) return Entry->getKeyData(); // FIXME: This is gross. It would be best not to embed specific details @@ -112,12 +107,12 @@ public: // The 'this' pointer really points to a // std::pair<IdentifierInfo, const char*>, where internal pointer // points to the external string data. - typedef std::pair<IdentifierInfo, const char*> actualtype; + using actualtype = std::pair<IdentifierInfo, const char *>; + return ((const actualtype*) this)->second; } /// \brief Efficiently return the length of this identifier info. - /// unsigned getLength() const { if (Entry) return Entry->getKeyLength(); // FIXME: This is gross. It would be best not to embed specific details @@ -125,7 +120,8 @@ public: // The 'this' pointer really points to a // std::pair<IdentifierInfo, const char*>, where internal pointer // points to the external string data. - typedef std::pair<IdentifierInfo, const char*> actualtype; + using actualtype = std::pair<IdentifierInfo, const char *>; + const char* p = ((const actualtype*) this)->second - 2; return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1; } @@ -465,7 +461,7 @@ public: class IdentifierTable { // Shark shows that using MallocAllocator is *much* slower than using this // BumpPtrAllocator! - typedef llvm::StringMap<IdentifierInfo*, llvm::BumpPtrAllocator> HashTableTy; + using HashTableTy = llvm::StringMap<IdentifierInfo *, llvm::BumpPtrAllocator>; HashTableTy HashTable; IdentifierInfoLookup* ExternalLookup; @@ -551,8 +547,8 @@ public: return *II; } - typedef HashTableTy::const_iterator iterator; - typedef HashTableTy::const_iterator const_iterator; + using iterator = HashTableTy::const_iterator; + using const_iterator = HashTableTy::const_iterator; iterator begin() const { return HashTable.begin(); } iterator end() const { return HashTable.end(); } @@ -654,7 +650,9 @@ class Selector { MultiArg = 0x3, ArgFlags = ZeroArg|OneArg }; - uintptr_t InfoPtr; // a pointer to the MultiKeywordSelector or IdentifierInfo. + + // a pointer to the MultiKeywordSelector or IdentifierInfo. + uintptr_t InfoPtr = 0; Selector(IdentifierInfo *II, unsigned nArgs) { InfoPtr = reinterpret_cast<uintptr_t>(II); @@ -662,6 +660,7 @@ class Selector { assert(nArgs < 2 && "nArgs not equal to 0/1"); InfoPtr |= nArgs+1; } + Selector(MultiKeywordSelector *SI) { InfoPtr = reinterpret_cast<uintptr_t>(SI); assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo"); @@ -692,7 +691,7 @@ public: /// The default ctor should only be used when creating data structures that /// will contain selectors. - Selector() : InfoPtr(0) {} + Selector() = default; Selector(uintptr_t V) : InfoPtr(V) {} /// operator==/!= - Indicate whether the specified selectors are identical. @@ -776,7 +775,8 @@ public: /// \brief This table allows us to fully hide how we implement /// multi-keyword caching. class SelectorTable { - void *Impl; // Actually a SelectorTableImpl + // Actually a SelectorTableImpl + void *Impl; public: SelectorTable(); @@ -793,6 +793,7 @@ public: Selector getUnarySelector(IdentifierInfo *ID) { return Selector(ID, 1); } + Selector getNullarySelector(IdentifierInfo *ID) { return Selector(ID, 0); } @@ -848,7 +849,7 @@ public: unsigned ExtraKindOrNumArgs; }; -} // end namespace clang +} // namespace clang namespace llvm { @@ -856,11 +857,11 @@ namespace llvm { /// DenseSets. template <> struct DenseMapInfo<clang::Selector> { - static inline clang::Selector getEmptyKey() { + static clang::Selector getEmptyKey() { return clang::Selector::getEmptyMarker(); } - static inline clang::Selector getTombstoneKey() { + static clang::Selector getTombstoneKey() { return clang::Selector::getTombstoneMarker(); } @@ -874,15 +875,13 @@ struct DenseMapInfo<clang::Selector> { template <> struct isPodLike<clang::Selector> { static const bool value = true; }; -template <typename T> struct PointerLikeTypeTraits; - template<> struct PointerLikeTypeTraits<clang::Selector> { - static inline const void *getAsVoidPointer(clang::Selector P) { + static const void *getAsVoidPointer(clang::Selector P) { return P.getAsOpaquePtr(); } - static inline clang::Selector getFromVoidPointer(const void *P) { + static clang::Selector getFromVoidPointer(const void *P) { return clang::Selector(reinterpret_cast<uintptr_t>(P)); } @@ -893,11 +892,11 @@ struct PointerLikeTypeTraits<clang::Selector> { // are not guaranteed to be 8-byte aligned. template<> struct PointerLikeTypeTraits<clang::IdentifierInfo*> { - static inline void *getAsVoidPointer(clang::IdentifierInfo* P) { + static void *getAsVoidPointer(clang::IdentifierInfo* P) { return P; } - static inline clang::IdentifierInfo *getFromVoidPointer(void *P) { + static clang::IdentifierInfo *getFromVoidPointer(void *P) { return static_cast<clang::IdentifierInfo*>(P); } @@ -906,17 +905,17 @@ struct PointerLikeTypeTraits<clang::IdentifierInfo*> { template<> struct PointerLikeTypeTraits<const clang::IdentifierInfo*> { - static inline const void *getAsVoidPointer(const clang::IdentifierInfo* P) { + static const void *getAsVoidPointer(const clang::IdentifierInfo* P) { return P; } - static inline const clang::IdentifierInfo *getFromVoidPointer(const void *P) { + static const clang::IdentifierInfo *getFromVoidPointer(const void *P) { return static_cast<const clang::IdentifierInfo*>(P); } enum { NumLowBitsAvailable = 1 }; }; -} // end namespace llvm +} // namespace llvm #endif // LLVM_CLANG_BASIC_IDENTIFIERTABLE_H diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index 51fb5ad661..f7a43adefa 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -77,7 +77,8 @@ public: DCC_CDecl, DCC_FastCall, DCC_StdCall, - DCC_VectorCall + DCC_VectorCall, + DCC_RegCall }; enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off }; diff --git a/include/clang/Basic/Module.h b/include/clang/Basic/Module.h index 0b2a665f05..6631721e35 100644 --- a/include/clang/Basic/Module.h +++ b/include/clang/Basic/Module.h @@ -1,4 +1,4 @@ -//===--- Module.h - Describe a module ---------------------------*- C++ -*-===// +//===- Module.h - Describe a module -----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,12 +6,13 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines the clang::Module class, which describes a module in the /// source code. -/// +// //===----------------------------------------------------------------------===// + #ifndef LLVM_CLANG_BASIC_MODULE_H #define LLVM_CLANG_BASIC_MODULE_H @@ -19,6 +20,7 @@ #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SetVector.h" @@ -26,22 +28,28 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator_range.h" +#include <array> +#include <cassert> +#include <cstdint> +#include <ctime> #include <string> #include <utility> #include <vector> namespace llvm { - class raw_ostream; -} + +class raw_ostream; + +} // namespace llvm namespace clang { class LangOptions; class TargetInfo; -class IdentifierInfo; - + /// \brief Describes the name of a module. -typedef SmallVector<std::pair<std::string, SourceLocation>, 2> ModuleId; +using ModuleId = SmallVector<std::pair<std::string, SourceLocation>, 2>; /// The signature of a module, which is a hash of the AST content. struct ASTFileSignature : std::array<uint32_t, 5> { @@ -85,7 +93,7 @@ public: /// \brief The build directory of this module. This is the directory in /// which the module is notionally built, and relative to which its headers /// are found. - const DirectoryEntry *Directory; + const DirectoryEntry *Directory = nullptr; /// \brief The presumed file name for the module map defining this module. /// Only non-empty when building from preprocessed source. @@ -114,7 +122,7 @@ private: /// \brief The AST file if this is a top-level module which has a /// corresponding serialized AST file, or null otherwise. - const FileEntry *ASTFile; + const FileEntry *ASTFile = nullptr; /// \brief The top-level headers associated with this module. llvm::SmallSetVector<const FileEntry *, 2> TopHeaders; @@ -181,7 +189,7 @@ public: /// \brief An individual requirement: a feature name and a flag indicating /// the required state of that feature. - typedef std::pair<std::string, bool> Requirement; + using Requirement = std::pair<std::string, bool>; /// \brief The set of language features required to use this module. /// @@ -270,7 +278,7 @@ public: /// /// The pointer is the module being re-exported, while the bit will be true /// to indicate that this is a wildcard export. - typedef llvm::PointerIntPair<Module *, 1, bool> ExportDecl; + using ExportDecl = llvm::PointerIntPair<Module *, 1, bool>; /// \brief The set of export declarations. SmallVector<ExportDecl, 2> Exports; @@ -302,9 +310,9 @@ public: /// \brief A library or framework to link against when an entity from this /// module is used. struct LinkLibrary { - LinkLibrary() : IsFramework(false) { } + LinkLibrary() = default; LinkLibrary(const std::string &Library, bool IsFramework) - : Library(Library), IsFramework(IsFramework) { } + : Library(Library), IsFramework(IsFramework) {} /// \brief The library to link against. /// @@ -313,7 +321,7 @@ public: std::string Library; /// \brief Whether this is a framework rather than a library. - bool IsFramework; + bool IsFramework = false; }; /// \brief The set of libraries or frameworks to link against when @@ -432,7 +440,6 @@ public: const Module *getTopLevelModule() const; /// \brief Retrieve the name of the top-level module. - /// StringRef getTopLevelModuleName() const { return getTopLevelModule()->Name; } @@ -525,8 +532,8 @@ public: unsigned getVisibilityID() const { return VisibilityID; } - typedef std::vector<Module *>::iterator submodule_iterator; - typedef std::vector<Module *>::const_iterator submodule_const_iterator; + using submodule_iterator = std::vector<Module *>::iterator; + using submodule_const_iterator = std::vector<Module *>::const_iterator; submodule_iterator submodule_begin() { return SubModules.begin(); } submodule_const_iterator submodule_begin() const {return SubModules.begin();} @@ -551,7 +558,6 @@ public: } /// \brief Print the module map for this module to the given stream. - /// void print(raw_ostream &OS, unsigned Indent = 0) const; /// \brief Dump the contents of this module to the given output stream. @@ -564,7 +570,7 @@ private: /// \brief A set of visible modules. class VisibleModuleSet { public: - VisibleModuleSet() : Generation(0) {} + VisibleModuleSet() = default; VisibleModuleSet(VisibleModuleSet &&O) : ImportLocs(std::move(O.ImportLocs)), Generation(O.Generation ? 1 : 0) { O.ImportLocs.clear(); @@ -599,13 +605,15 @@ public: /// \brief A callback to call when a module is made visible (directly or /// indirectly) by a call to \ref setVisible. - typedef llvm::function_ref<void(Module *M)> VisibleCallback; + using VisibleCallback = llvm::function_ref<void(Module *M)>; + /// \brief A callback to call when a module conflict is found. \p Path /// consists of a sequence of modules from the conflicting module to the one /// made visible, where each was exported by the next. - typedef llvm::function_ref<void(ArrayRef<Module *> Path, - Module *Conflict, StringRef Message)> - ConflictCallback; + using ConflictCallback = + llvm::function_ref<void(ArrayRef<Module *> Path, Module *Conflict, + StringRef Message)>; + /// \brief Make a specific module visible. void setVisible(Module *M, SourceLocation Loc, VisibleCallback Vis = [](Module *) {}, @@ -616,11 +624,11 @@ private: /// Import locations for each visible module. Indexed by the module's /// VisibilityID. std::vector<SourceLocation> ImportLocs; + /// Visibility generation, bumped every time the visibility state changes. - unsigned Generation; + unsigned Generation = 0; }; -} // end namespace clang - +} // namespace clang #endif // LLVM_CLANG_BASIC_MODULE_H diff --git a/include/clang/Basic/Sanitizers.def b/include/clang/Basic/Sanitizers.def index d6df617172..3586fc228d 100644 --- a/include/clang/Basic/Sanitizers.def +++ b/include/clang/Basic/Sanitizers.def @@ -135,6 +135,9 @@ SANITIZER("efficiency-working-set", EfficiencyWorkingSet) SANITIZER_GROUP("efficiency-all", Efficiency, EfficiencyCacheFrag | EfficiencyWorkingSet) +// Scudo hardened allocator +SANITIZER("scudo", Scudo) + // Magic group, containing all sanitizers. For example, "-fno-sanitize=all" // can be used to disable all the sanitizers. SANITIZER_GROUP("all", All, ~0ULL) diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 16bd5616a6..397ad2e77f 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -1,4 +1,4 @@ -//===--- SourceManager.h - Track and cache source files ---------*- C++ -*-===// +//===- SourceManager.h - Track and cache source files -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,7 +6,7 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines the SourceManager interface. /// @@ -29,14 +29,13 @@ /// location in the source where the macro was originally defined, /// and the presumed location is where the line directive states that /// the line is 17, or any other line. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_SOURCEMANAGER_H #define LLVM_CLANG_BASIC_SOURCEMANAGER_H #include "clang/Basic/FileManager.h" -#include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" @@ -49,10 +48,8 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/MemoryBuffer.h" -#include <algorithm> #include <cassert> #include <cstddef> -#include <cstdint> #include <map> #include <memory> #include <string> @@ -69,7 +66,6 @@ class SourceManager; /// \brief Public enums and private classes that are part of the /// SourceManager implementation. -/// namespace SrcMgr { /// \brief Indicates whether a file or directory holds normal user code, @@ -100,6 +96,7 @@ namespace SrcMgr { enum CCFlags { /// \brief Whether the buffer is invalid. InvalidFlag = 0x01, + /// \brief Whether the buffer should not be freed on destruction. DoNotFreeFlag = 0x02 }; @@ -130,12 +127,12 @@ namespace SrcMgr { /// /// This is lazily computed. This is owned by the SourceManager /// BumpPointerAllocator object. - unsigned *SourceLineCache; + unsigned *SourceLineCache = nullptr; /// \brief The number of lines in this ContentCache. /// /// This is only valid if SourceLineCache is non-null. - unsigned NumLines; + unsigned NumLines = 0; /// \brief Indicates whether the buffer itself was provided to override /// the actual file contents. @@ -157,15 +154,14 @@ namespace SrcMgr { ContentCache(const FileEntry *Ent, const FileEntry *contentEnt) : Buffer(nullptr, false), OrigEntry(Ent), ContentsEntry(contentEnt), - SourceLineCache(nullptr), NumLines(0), BufferOverridden(false), - IsSystemFile(false), IsTransient(false) {} + BufferOverridden(false), IsSystemFile(false), IsTransient(false) {} /// The copy ctor does not allow copies where source object has either /// a non-NULL Buffer or SourceLineCache. Ownership of allocated memory /// is not transferred, so this is a logical error. ContentCache(const ContentCache &RHS) - : Buffer(nullptr, false), SourceLineCache(nullptr), - BufferOverridden(false), IsSystemFile(false), IsTransient(false) { + : Buffer(nullptr, false), BufferOverridden(false), IsSystemFile(false), + IsTransient(false) { OrigEntry = RHS.OrigEntry; ContentsEntry = RHS.ContentsEntry; @@ -246,6 +242,10 @@ namespace SrcMgr { /// FileInfos contain a "ContentCache *", with the contents of the file. /// class FileInfo { + friend class clang::SourceManager; + friend class clang::ASTWriter; + friend class clang::ASTReader; + /// \brief The location of the \#include that brought in this file. /// /// This is an invalid SLOC for the main file (top of the \#include chain). @@ -264,10 +264,6 @@ namespace SrcMgr { llvm::PointerIntPair<const ContentCache*, 3, CharacteristicKind> ContentAndKind; - friend class clang::SourceManager; - friend class clang::ASTWriter; - friend class clang::ASTReader; - public: /// \brief Return a FileInfo object. static FileInfo get(SourceLocation IL, const ContentCache *Con, @@ -448,7 +444,7 @@ namespace SrcMgr { } }; -} // end SrcMgr namespace. +} // namespace SrcMgr /// \brief External source of source location entries. class ExternalSLocEntrySource { @@ -546,7 +542,7 @@ public: /// \brief The stack used when building modules on demand, which is used /// to provide a link between the source managers of the different compiler /// instances. -typedef ArrayRef<std::pair<std::string, FullSourceLoc>> ModuleBuildStack; +using ModuleBuildStack = ArrayRef<std::pair<std::string, FullSourceLoc>>; /// \brief This class handles loading and caching of source files into memory. /// @@ -578,7 +574,7 @@ class SourceManager : public RefCountedBase<SourceManager> { /// \brief True if the ContentCache for files that are overridden by other /// files, should report the original file name. Defaults to true. - bool OverridenFilesKeepOriginalName; + bool OverridenFilesKeepOriginalName = true; /// \brief True if non-system source files should be treated as volatile /// (likely to change while trying to use them). Defaults to false. @@ -587,12 +583,13 @@ class SourceManager : public RefCountedBase<SourceManager> { /// \brief True if all files read during this compilation should be treated /// as transient (may not be present in later compilations using a module /// file created from this compilation). Defaults to false. - bool FilesAreTransient; + bool FilesAreTransient = false; struct OverriddenFilesInfoTy { /// \brief Files that have been overridden with the contents from another /// file. llvm::DenseMap<const FileEntry *, const FileEntry *> OverriddenFiles; + /// \brief Files that were overridden with a memory buffer. llvm::DenseSet<const FileEntry *> OverriddenFilesWithBuffer; }; @@ -647,7 +644,7 @@ class SourceManager : public RefCountedBase<SourceManager> { llvm::BitVector SLocEntryLoaded; /// \brief An external source for source location entries. - ExternalSLocEntrySource *ExternalSLocEntries; + ExternalSLocEntrySource *ExternalSLocEntries = nullptr; /// \brief A one-entry cache to speed up getFileID. /// @@ -658,7 +655,7 @@ class SourceManager : public RefCountedBase<SourceManager> { /// \brief Holds information for \#line directives. /// /// This is referenced by indices from SLocEntryTable. - LineTableInfo *LineTable; + LineTableInfo *LineTable = nullptr; /// \brief These ivars serve as a cache used in the getLineNumber /// method which is used to speedup getLineNumber calls to nearby locations. @@ -674,7 +671,8 @@ class SourceManager : public RefCountedBase<SourceManager> { FileID PreambleFileID; // Statistics for -print-stats. - mutable unsigned NumLinearScans, NumBinaryProbes; + mutable unsigned NumLinearScans = 0; + mutable unsigned NumBinaryProbes = 0; /// \brief Associates a FileID with its "included/expanded in" decomposed /// location. @@ -684,12 +682,12 @@ class SourceManager : public RefCountedBase<SourceManager> { mutable llvm::DenseMap<FileID, std::pair<FileID, unsigned>> IncludedLocMap; /// The key value into the IsBeforeInTUCache table. - typedef std::pair<FileID, FileID> IsBeforeInTUCacheKey; + using IsBeforeInTUCacheKey = std::pair<FileID, FileID>; /// The IsBeforeInTranslationUnitCache is a mapping from FileID pairs /// to cache results. - typedef llvm::DenseMap<IsBeforeInTUCacheKey, InBeforeInTUCacheEntry> - InBeforeInTUCache; + using InBeforeInTUCache = + llvm::DenseMap<IsBeforeInTUCacheKey, InBeforeInTUCacheEntry>; /// Cache results for the isBeforeInTranslationUnit method. mutable InBeforeInTUCache IBTUCache; @@ -706,7 +704,7 @@ class SourceManager : public RefCountedBase<SourceManager> { /// \brief Lazily computed map of macro argument chunks to their expanded /// source location. - typedef std::map<unsigned, SourceLocation> MacroArgsMap; + using MacroArgsMap = std::map<unsigned, SourceLocation>; mutable llvm::DenseMap<FileID, std::unique_ptr<MacroArgsMap>> MacroArgsCacheMap; @@ -1417,7 +1415,6 @@ public: //===--------------------------------------------------------------------===// /// \brief Return the uniqued ID for the specified filename. - /// unsigned getLineTableFilenameID(StringRef Str); /// \brief Add a line note to the line table for the FileID and offset @@ -1538,8 +1535,9 @@ public: } // Iterators over FileInfos. - typedef llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*> - ::const_iterator fileinfo_iterator; + using fileinfo_iterator = + llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*>::const_iterator; + fileinfo_iterator fileinfo_begin() const { return FileInfos.begin(); } fileinfo_iterator fileinfo_end() const { return FileInfos.end(); } bool hasFileInfo(const FileEntry *File) const { @@ -1547,7 +1545,6 @@ public: } /// \brief Print statistics to stderr. - /// void PrintStats() const; void dump() const; @@ -1638,6 +1635,9 @@ public: } private: + friend class ASTReader; + friend class ASTWriter; + llvm::MemoryBuffer *getFakeBufferForRecovery() const; const SrcMgr::ContentCache *getFakeContentCacheForRecovery() const; @@ -1729,8 +1729,6 @@ private: SourceLocation SpellLoc, SourceLocation ExpansionLoc, unsigned ExpansionLength) const; - friend class ASTReader; - friend class ASTWriter; }; /// \brief Comparison function object. @@ -1743,7 +1741,7 @@ class BeforeThanCompare<SourceLocation> { SourceManager &SM; public: - explicit BeforeThanCompare(SourceManager &SM) : SM(SM) { } + explicit BeforeThanCompare(SourceManager &SM) : SM(SM) {} bool operator()(SourceLocation LHS, SourceLocation RHS) const { return SM.isBeforeInTranslationUnit(LHS, RHS); @@ -1756,13 +1754,13 @@ class BeforeThanCompare<SourceRange> { SourceManager &SM; public: - explicit BeforeThanCompare(SourceManager &SM) : SM(SM) { } + explicit BeforeThanCompare(SourceManager &SM) : SM(SM) {} bool operator()(SourceRange LHS, SourceRange RHS) const { return SM.isBeforeInTranslationUnit(LHS.getBegin(), RHS.getBegin()); } }; -} // end namespace clang +} // namespace clang #endif // LLVM_CLANG_BASIC_SOURCEMANAGER_H diff --git a/include/clang/Basic/SourceManagerInternals.h b/include/clang/Basic/SourceManagerInternals.h index 9403dea888..edd910e704 100644 --- a/include/clang/Basic/SourceManagerInternals.h +++ b/include/clang/Basic/SourceManagerInternals.h @@ -1,4 +1,4 @@ -//===--- SourceManagerInternals.h - SourceManager Internals -----*- C++ -*-===// +//===- SourceManagerInternals.h - SourceManager Internals -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,10 +6,10 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines implementation details of the clang::SourceManager class. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_SOURCEMANAGERINTERNALS_H @@ -18,7 +18,11 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Allocator.h" +#include <cassert> #include <map> +#include <vector> namespace clang { @@ -86,7 +90,8 @@ class LineTableInfo { /// \brief Map from FileIDs to a list of line entries (sorted by the offset /// at which they occur in the file). - std::map<FileID, std::vector<LineEntry> > LineEntries; + std::map<FileID, std::vector<LineEntry>> LineEntries; + public: void clear() { FilenameIDs.clear(); @@ -95,10 +100,12 @@ public: } unsigned getLineTableFilenameID(StringRef Str); + StringRef getFilename(unsigned ID) const { assert(ID < FilenamesByID.size() && "Invalid FilenameID"); return FilenamesByID[ID]->getKey(); } + unsigned getNumFilenames() const { return FilenamesByID.size(); } void AddLineNote(FileID FID, unsigned Offset, @@ -112,7 +119,8 @@ public: const LineEntry *FindNearestLineEntry(FileID FID, unsigned Offset); // Low-level access - typedef std::map<FileID, std::vector<LineEntry> >::iterator iterator; + using iterator = std::map<FileID, std::vector<LineEntry>>::iterator; + iterator begin() { return LineEntries.begin(); } iterator end() { return LineEntries.end(); } @@ -121,6 +129,6 @@ public: void AddEntry(FileID FID, const std::vector<LineEntry> &Entries); }; -} // end namespace clang +} // namespace clang -#endif +#endif // LLVM_CLANG_BASIC_SOURCEMANAGERINTERNALS_H diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index bca51b593a..348a42f4b3 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -704,7 +704,7 @@ def fnative_half_arguments_and_returns : Flag<["-"], "fnative-half-arguments-and def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">, HelpText<"Allow function arguments and returns of type half">; def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, - HelpText<"Set default MS calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall">; + HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">; def finclude_default_header : Flag<["-"], "finclude-default-header">, HelpText<"Include the default header file for OpenCL">; def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">, diff --git a/include/clang/Driver/CLCompatOptions.td b/include/clang/Driver/CLCompatOptions.td index aebb36ed0e..68a9a8136c 100644 --- a/include/clang/Driver/CLCompatOptions.td +++ b/include/clang/Driver/CLCompatOptions.td @@ -302,6 +302,8 @@ def _SLASH_Gz : CLFlag<"Gz">, HelpText<"Set __stdcall as a default calling convention">; def _SLASH_Gv : CLFlag<"Gv">, HelpText<"Set __vectorcall as a default calling convention">; +def _SLASH_Gregcall : CLFlag<"Gregcall">, + HelpText<"Set __regcall as a default calling convention">; // Ignored: diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index e3476c721a..01605619e0 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -519,7 +519,7 @@ def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-round def client__name : JoinedOrSeparate<["-"], "client_name">; def combine : Flag<["-", "--"], "combine">, Flags<[DriverOption, Unsupported]>; def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">; -def coverage : Flag<["-", "--"], "coverage">; +def coverage : Flag<["-", "--"], "coverage">, Flags<[CoreOption]>; def cpp_precomp : Flag<["-"], "cpp-precomp">, Group<clang_ignored_f_Group>; def current__version : JoinedOrSeparate<["-"], "current_version">; def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group<clang_i_Group>, @@ -1384,6 +1384,10 @@ def fpic : Flag<["-"], "fpic">, Group<f_Group>; def fno_pic : Flag<["-"], "fno-pic">, Group<f_Group>; def fpie : Flag<["-"], "fpie">, Group<f_Group>; def fno_pie : Flag<["-"], "fno-pie">, Group<f_Group>; +def fplt : Flag<["-"], "fplt">, Group<f_Group>, Flags<[CC1Option]>, + HelpText<"Use the PLT to make function calls">; +def fno_plt : Flag<["-"], "fno-plt">, Group<f_Group>, Flags<[CC1Option]>, + HelpText<"Do not use the PLT to make function calls">; def fropi : Flag<["-"], "fropi">, Group<f_Group>; def fno_ropi : Flag<["-"], "fno-ropi">, Group<f_Group>; def frwpi : Flag<["-"], "frwpi">, Group<f_Group>; diff --git a/include/clang/Driver/SanitizerArgs.h b/include/clang/Driver/SanitizerArgs.h index 19309c3f3b..44083aec16 100644 --- a/include/clang/Driver/SanitizerArgs.h +++ b/include/clang/Driver/SanitizerArgs.h @@ -72,6 +72,7 @@ class SanitizerArgs { bool needsEsanRt() const { return Sanitizers.hasOneOf(SanitizerKind::Efficiency); } + bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); } bool requiresPIE() const; bool needsUnwindTables() const; diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def index 8f2aae2f14..b4c68a49bb 100644 --- a/include/clang/Frontend/CodeGenOptions.def +++ b/include/clang/Frontend/CodeGenOptions.def @@ -297,6 +297,8 @@ CODEGENOPT(PreserveVec3Type, 1, 0) /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames. CODEGENOPT(GnuPubnames, 1, 0) +CODEGENOPT(NoPLT, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h index 603ce10f64..9ad3e21476 100644 --- a/include/clang/Lex/Lexer.h +++ b/include/clang/Lex/Lexer.h @@ -466,6 +466,13 @@ public: const LangOptions &LangOpts, unsigned MaxLines = 0); + /// Finds the token that comes right after the given location. + /// + /// Returns the next token, or none if the location is inside a macro. + static Optional<Token> findNextToken(SourceLocation Loc, + const SourceManager &SM, + const LangOptions &LangOpts); + /// \brief Checks that the given token is the first token that occurs after /// the given location (this excludes comments and whitespace). Returns the /// location immediately after the specified token. If the token is not found diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 4f211a3eb6..5e847effdc 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -286,6 +286,23 @@ class Preprocessor { /// This is used when loading a precompiled preamble. std::pair<int, bool> SkipMainFilePreamble; +public: + struct PreambleSkipInfo { + PreambleSkipInfo(SourceLocation HashTokenLoc, SourceLocation IfTokenLoc, + bool FoundNonSkipPortion, bool FoundElse, + SourceLocation ElseLoc) + : HashTokenLoc(HashTokenLoc), IfTokenLoc(IfTokenLoc), + FoundNonSkipPortion(FoundNonSkipPortion), FoundElse(FoundElse), + ElseLoc(ElseLoc) {} + + SourceLocation HashTokenLoc; + SourceLocation IfTokenLoc; + bool FoundNonSkipPortion; + bool FoundElse; + SourceLocation ElseLoc; + }; + +private: class PreambleConditionalStackStore { enum State { Off = 0, @@ -319,6 +336,12 @@ class Preprocessor { bool hasRecordedPreamble() const { return !ConditionalStack.empty(); } + bool reachedEOFWhileSkipping() const { return SkipInfo.hasValue(); } + + void clearSkipInfo() { SkipInfo.reset(); } + + llvm::Optional<PreambleSkipInfo> SkipInfo; + private: SmallVector<PPConditionalInfo, 4> ConditionalStack; State ConditionalStackState; @@ -1839,7 +1862,7 @@ private: /// \p FoundElse is false, then \#else directives are ok, if not, then we have /// already seen one so a \#else directive is a duplicate. When this returns, /// the caller can lex the first valid token. - void SkipExcludedConditionalBlock(const Token &HashToken, + void SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, SourceLocation IfTokenLoc, bool FoundNonSkipPortion, bool FoundElse, SourceLocation ElseLoc = SourceLocation()); @@ -2019,9 +2042,15 @@ public: PreambleConditionalStack.setStack(s); } - void setReplayablePreambleConditionalStack(ArrayRef<PPConditionalInfo> s) { + void setReplayablePreambleConditionalStack(ArrayRef<PPConditionalInfo> s, + llvm::Optional<PreambleSkipInfo> SkipInfo) { PreambleConditionalStack.startReplaying(); PreambleConditionalStack.setStack(s); + PreambleConditionalStack.SkipInfo = SkipInfo; + } + + llvm::Optional<PreambleSkipInfo> getPreambleSkipInfo() const { + return PreambleConditionalStack.SkipInfo; } private: diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 42c62257ad..34a7bb3301 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -14,17 +14,23 @@ // respective lists. // //===----------------------------------------------------------------------===// + #ifndef LLVM_CLANG_SERIALIZATION_ASTBITCODES_H #define LLVM_CLANG_SERIALIZATION_ASTBITCODES_H #include "clang/AST/DeclarationName.h" #include "clang/AST/Type.h" -#include "llvm/ADT/DenseMap.h" +#include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/OperatorKinds.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/DenseMapInfo.h" #include "llvm/Bitcode/BitCodes.h" -#include "llvm/Support/DataTypes.h" +#include <cassert> +#include <cstdint> namespace clang { - namespace serialization { +namespace serialization { + /// \brief AST file major version number supported by this version of /// Clang. /// @@ -52,7 +58,7 @@ namespace clang { /// /// The ID numbers of identifiers are consecutive (in order of discovery) /// and start at 1. 0 is reserved for NULL. - typedef uint32_t IdentifierID; + using IdentifierID = uint32_t; /// \brief An ID number that refers to a declaration in an AST file. /// @@ -60,12 +66,12 @@ namespace clang { /// discovery), with values below NUM_PREDEF_DECL_IDS being reserved. /// At the start of a chain of precompiled headers, declaration ID 1 is /// used for the translation unit declaration. - typedef uint32_t DeclID; + using DeclID = uint32_t; // FIXME: Turn these into classes so we can have some type safety when // we go from local ID to global and vice-versa. - typedef DeclID LocalDeclID; - typedef DeclID GlobalDeclID; + using LocalDeclID = DeclID; + using GlobalDeclID = DeclID; /// \brief An ID number that refers to a type in an AST file. /// @@ -77,22 +83,25 @@ namespace clang { /// IDs (based on the PREDEF_TYPE_*_ID constants), with 0 as a /// placeholder for "no type". Values from NUM_PREDEF_TYPE_IDs are /// other types that have serialized representations. - typedef uint32_t TypeID; + using TypeID = uint32_t; /// \brief A type index; the type ID with the qualifier bits removed. class TypeIdx { - uint32_t Idx; + uint32_t Idx = 0; + public: - TypeIdx() : Idx(0) { } - explicit TypeIdx(uint32_t index) : Idx(index) { } + TypeIdx() = default; + explicit TypeIdx(uint32_t index) : Idx(index) {} uint32_t getIndex() const { return Idx; } + TypeID asTypeID(unsigned FastQuals) const { if (Idx == uint32_t(-1)) return TypeID(-1); return (Idx << Qualifiers::FastWidth) | FastQuals; } + static TypeIdx fromTypeID(TypeID ID) { if (ID == TypeID(-1)) return TypeIdx(-1); @@ -104,14 +113,17 @@ namespace clang { /// A structure for putting "fast"-unqualified QualTypes into a /// DenseMap. This uses the standard pointer hash function. struct UnsafeQualTypeDenseMapInfo { - static inline bool isEqual(QualType A, QualType B) { return A == B; } - static inline QualType getEmptyKey() { + static bool isEqual(QualType A, QualType B) { return A == B; } + + static QualType getEmptyKey() { return QualType::getFromOpaquePtr((void*) 1); } - static inline QualType getTombstoneKey() { + + static QualType getTombstoneKey() { return QualType::getFromOpaquePtr((void*) 2); } - static inline unsigned getHashValue(QualType T) { + + static unsigned getHashValue(QualType T) { assert(!T.getLocalFastQualifiers() && "hash invalid for types with fast quals"); uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr()); @@ -120,44 +132,44 @@ namespace clang { }; /// \brief An ID number that refers to an identifier in an AST file. - typedef uint32_t IdentID; + using IdentID = uint32_t; /// \brief The number of predefined identifier IDs. const unsigned int NUM_PREDEF_IDENT_IDS = 1; /// \brief An ID number that refers to a macro in an AST file. - typedef uint32_t MacroID; + using MacroID = uint32_t; /// \brief A global ID number that refers to a macro in an AST file. - typedef uint32_t GlobalMacroID; + using GlobalMacroID = uint32_t; /// \brief A local to a module ID number that refers to a macro in an /// AST file. - typedef uint32_t LocalMacroID; + using LocalMacroID = uint32_t; /// \brief The number of predefined macro IDs. const unsigned int NUM_PREDEF_MACRO_IDS = 1; /// \brief An ID number that refers to an ObjC selector in an AST file. - typedef uint32_t SelectorID; + using SelectorID = uint32_t; /// \brief The number of predefined selector IDs. const unsigned int NUM_PREDEF_SELECTOR_IDS = 1; /// \brief An ID number that refers to a set of CXXBaseSpecifiers in an /// AST file. - typedef uint32_t CXXBaseSpecifiersID; + using CXXBaseSpecifiersID = uint32_t; /// \brief An ID number that refers to a list of CXXCtorInitializers in an /// AST file. - typedef uint32_t CXXCtorInitializersID; + using CXXCtorInitializersID = uint32_t; /// \brief An ID number that refers to an entity in the detailed /// preprocessing record. - typedef uint32_t PreprocessedEntityID; + using PreprocessedEntityID = uint32_t; /// \brief An ID number that refers to a submodule in a module file. - typedef uint32_t SubmoduleID; + using SubmoduleID = uint32_t; /// \brief The number of predefined submodule IDs. const unsigned int NUM_PREDEF_SUBMODULE_IDS = 1; @@ -166,18 +178,21 @@ namespace clang { struct PPEntityOffset { /// \brief Raw source location of beginning of range. unsigned Begin; + /// \brief Raw source location of end of range. unsigned End; + /// \brief Offset in the AST file. uint32_t BitOffset; PPEntityOffset(SourceRange R, uint32_t BitOffset) : Begin(R.getBegin().getRawEncoding()), - End(R.getEnd().getRawEncoding()), - BitOffset(BitOffset) { } + End(R.getEnd().getRawEncoding()), BitOffset(BitOffset) {} + SourceLocation getBegin() const { return SourceLocation::getFromRawEncoding(Begin); } + SourceLocation getEnd() const { return SourceLocation::getFromRawEncoding(End); } @@ -186,17 +201,19 @@ namespace clang { /// \brief Source range/offset of a preprocessed entity. struct DeclOffset { /// \brief Raw source location. - unsigned Loc; + unsigned Loc = 0; + /// \brief Offset in the AST file. - uint32_t BitOffset; + uint32_t BitOffset = 0; - DeclOffset() : Loc(0), BitOffset(0) { } + DeclOffset() = default; DeclOffset(SourceLocation Loc, uint32_t BitOffset) - : Loc(Loc.getRawEncoding()), - BitOffset(BitOffset) { } + : Loc(Loc.getRawEncoding()), BitOffset(BitOffset) {} + void setLocation(SourceLocation L) { Loc = L.getRawEncoding(); } + SourceLocation getLocation() const { return SourceLocation::getFromRawEncoding(Loc); } @@ -617,17 +634,21 @@ namespace clang { /// \brief Describes a source location entry (SLocEntry) for a /// file. SM_SLOC_FILE_ENTRY = 1, + /// \brief Describes a source location entry (SLocEntry) for a /// buffer. SM_SLOC_BUFFER_ENTRY = 2, + /// \brief Describes a blob that contains the data for a buffer /// entry. This kind of record always directly follows a /// SM_SLOC_BUFFER_ENTRY record or a SM_SLOC_FILE_ENTRY with an /// overridden buffer. SM_SLOC_BUFFER_BLOB = 3, + /// \brief Describes a zlib-compressed blob that contains the data for /// a buffer entry. SM_SLOC_BUFFER_BLOB_COMPRESSED = 4, + /// \brief Describes a source location entry (SLocEntry) for a /// macro expansion. SM_SLOC_EXPANSION_ENTRY = 5 @@ -676,46 +697,63 @@ namespace clang { enum SubmoduleRecordTypes { /// \brief Metadata for submodules as a whole. SUBMODULE_METADATA = 0, + /// \brief Defines the major attributes of a submodule, including its /// name and parent. SUBMODULE_DEFINITION = 1, + /// \brief Specifies the umbrella header used to create this module, /// if any. SUBMODULE_UMBRELLA_HEADER = 2, + /// \brief Specifies a header that falls into this (sub)module. SUBMODULE_HEADER = 3, + /// \brief Specifies a top-level header that falls into this (sub)module. SUBMODULE_TOPHEADER = 4, + /// \brief Specifies an umbrella directory. SUBMODULE_UMBRELLA_DIR = 5, + /// \brief Specifies the submodules that are imported by this /// submodule. SUBMODULE_IMPORTS = 6, + /// \brief Specifies the submodules that are re-exported from this /// submodule. SUBMODULE_EXPORTS = 7, + /// \brief Specifies a required feature. SUBMODULE_REQUIRES = 8, + /// \brief Specifies a header that has been explicitly excluded /// from this submodule. SUBMODULE_EXCLUDED_HEADER = 9, + /// \brief Specifies a library or framework to link against. SUBMODULE_LINK_LIBRARY = 10, + /// \brief Specifies a configuration macro for this module. SUBMODULE_CONFIG_MACRO = 11, + /// \brief Specifies a conflict with another module. SUBMODULE_CONFLICT = 12, + /// \brief Specifies a header that is private to this submodule. SUBMODULE_PRIVATE_HEADER = 13, + /// \brief Specifies a header that is part of the module but must be /// textually included. SUBMODULE_TEXTUAL_HEADER = 14, + /// \brief Specifies a header that is private to this submodule but /// must be textually included. SUBMODULE_PRIVATE_TEXTUAL_HEADER = 15, + /// \brief Specifies some declarations with initializers that must be /// emitted to initialize the module. SUBMODULE_INITIALIZERS = 16, + /// \brief Specifies the name of the module that will eventually /// re-export the entities in this module. SUBMODULE_EXPORT_AS = 17, @@ -743,94 +781,139 @@ namespace clang { enum PredefinedTypeIDs { /// \brief The NULL type. PREDEF_TYPE_NULL_ID = 0, + /// \brief The void type. PREDEF_TYPE_VOID_ID = 1, + /// \brief The 'bool' or '_Bool' type. PREDEF_TYPE_BOOL_ID = 2, + /// \brief The 'char' type, when it is unsigned. PREDEF_TYPE_CHAR_U_ID = 3, + /// \brief The 'unsigned char' type. PREDEF_TYPE_UCHAR_ID = 4, + /// \brief The 'unsigned short' type. PREDEF_TYPE_USHORT_ID = 5, + /// \brief The 'unsigned int' type. PREDEF_TYPE_UINT_ID = 6, + /// \brief The 'unsigned long' type. PREDEF_TYPE_ULONG_ID = 7, + /// \brief The 'unsigned long long' type. PREDEF_TYPE_ULONGLONG_ID = 8, + /// \brief The 'char' type, when it is signed. PREDEF_TYPE_CHAR_S_ID = 9, + /// \brief The 'signed char' type. PREDEF_TYPE_SCHAR_ID = 10, + /// \brief The C++ 'wchar_t' type. PREDEF_TYPE_WCHAR_ID = 11, + /// \brief The (signed) 'short' type. PREDEF_TYPE_SHORT_ID = 12, + /// \brief The (signed) 'int' type. PREDEF_TYPE_INT_ID = 13, + /// \brief The (signed) 'long' type. PREDEF_TYPE_LONG_ID = 14, + /// \brief The (signed) 'long long' type. PREDEF_TYPE_LONGLONG_ID = 15, + /// \brief The 'float' type. PREDEF_TYPE_FLOAT_ID = 16, + /// \brief The 'double' type. PREDEF_TYPE_DOUBLE_ID = 17, + /// \brief The 'long double' type. PREDEF_TYPE_LONGDOUBLE_ID = 18, + /// \brief The placeholder type for overloaded function sets. PREDEF_TYPE_OVERLOAD_ID = 19, + /// \brief The placeholder type for dependent types. PREDEF_TYPE_DEPENDENT_ID = 20, + /// \brief The '__uint128_t' type. PREDEF_TYPE_UINT128_ID = 21, + /// \brief The '__int128_t' type. PREDEF_TYPE_INT128_ID = 22, + /// \brief The type of 'nullptr'. PREDEF_TYPE_NULLPTR_ID = 23, + /// \brief The C++ 'char16_t' type. PREDEF_TYPE_CHAR16_ID = 24, + /// \brief The C++ 'char32_t' type. PREDEF_TYPE_CHAR32_ID = 25, + /// \brief The ObjC 'id' type. PREDEF_TYPE_OBJC_ID = 26, + /// \brief The ObjC 'Class' type. PREDEF_TYPE_OBJC_CLASS = 27, + /// \brief The ObjC 'SEL' type. PREDEF_TYPE_OBJC_SEL = 28, + /// \brief The 'unknown any' placeholder type. PREDEF_TYPE_UNKNOWN_ANY = 29, + /// \brief The placeholder type for bound member functions. PREDEF_TYPE_BOUND_MEMBER = 30, + /// \brief The "auto" deduction type. PREDEF_TYPE_AUTO_DEDUCT = 31, + /// \brief The "auto &&" deduction type. PREDEF_TYPE_AUTO_RREF_DEDUCT = 32, + /// \brief The OpenCL 'half' / ARM NEON __fp16 type. PREDEF_TYPE_HALF_ID = 33, + /// \brief ARC's unbridged-cast placeholder type. PREDEF_TYPE_ARC_UNBRIDGED_CAST = 34, + /// \brief The pseudo-object placeholder type. PREDEF_TYPE_PSEUDO_OBJECT = 35, + /// \brief The placeholder type for builtin functions. PREDEF_TYPE_BUILTIN_FN = 36, + /// \brief OpenCL event type. PREDEF_TYPE_EVENT_ID = 37, + /// \brief OpenCL clk event type. PREDEF_TYPE_CLK_EVENT_ID = 38, + /// \brief OpenCL sampler type. PREDEF_TYPE_SAMPLER_ID = 39, + /// \brief OpenCL queue type. PREDEF_TYPE_QUEUE_ID = 40, + /// \brief OpenCL reserve_id type. PREDEF_TYPE_RESERVE_ID_ID = 41, + /// \brief The placeholder type for OpenMP array section. PREDEF_TYPE_OMP_ARRAY_SECTION = 42, + /// \brief The '__float128' type PREDEF_TYPE_FLOAT128_ID = 43, + /// \brief The '_Float16' type PREDEF_TYPE_FLOAT16_ID = 44, + /// \brief OpenCL image types with auto numeration #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ PREDEF_TYPE_##Id##_ID, @@ -853,94 +936,139 @@ namespace clang { enum TypeCode { /// \brief An ExtQualType record. TYPE_EXT_QUAL = 1, + /// \brief A ComplexType record. TYPE_COMPLEX = 3, + /// \brief A PointerType record. TYPE_POINTER = 4, + /// \brief A BlockPointerType record. TYPE_BLOCK_POINTER = 5, + /// \brief An LValueReferenceType record. TYPE_LVALUE_REFERENCE = 6, + /// \brief An RValueReferenceType record. TYPE_RVALUE_REFERENCE = 7, + /// \brief A MemberPointerType record. TYPE_MEMBER_POINTER = 8, + /// \brief A ConstantArrayType record. TYPE_CONSTANT_ARRAY = 9, + /// \brief An IncompleteArrayType record. TYPE_INCOMPLETE_ARRAY = 10, + /// \brief A VariableArrayType record. TYPE_VARIABLE_ARRAY = 11, + /// \brief A VectorType record. TYPE_VECTOR = 12, + /// \brief An ExtVectorType record. TYPE_EXT_VECTOR = 13, + /// \brief A FunctionNoProtoType record. TYPE_FUNCTION_NO_PROTO = 14, + /// \brief A FunctionProtoType record. TYPE_FUNCTION_PROTO = 15, + /// \brief A TypedefType record. TYPE_TYPEDEF = 16, + /// \brief A TypeOfExprType record. TYPE_TYPEOF_EXPR = 17, + /// \brief A TypeOfType record. TYPE_TYPEOF = 18, + /// \brief A RecordType record. TYPE_RECORD = 19, + /// \brief An EnumType record. TYPE_ENUM = 20, + /// \brief An ObjCInterfaceType record. TYPE_OBJC_INTERFACE = 21, + /// \brief An ObjCObjectPointerType record. TYPE_OBJC_OBJECT_POINTER = 22, + /// \brief a DecltypeType record. TYPE_DECLTYPE = 23, + /// \brief An ElaboratedType record. TYPE_ELABORATED = 24, + /// \brief A SubstTemplateTypeParmType record. TYPE_SUBST_TEMPLATE_TYPE_PARM = 25, + /// \brief An UnresolvedUsingType record. TYPE_UNRESOLVED_USING = 26, + /// \brief An InjectedClassNameType record. TYPE_INJECTED_CLASS_NAME = 27, + /// \brief An ObjCObjectType record. TYPE_OBJC_OBJECT = 28, + /// \brief An TemplateTypeParmType record. TYPE_TEMPLATE_TYPE_PARM = 29, + /// \brief An TemplateSpecializationType record. TYPE_TEMPLATE_SPECIALIZATION = 30, + /// \brief A DependentNameType record. TYPE_DEPENDENT_NAME = 31, + /// \brief A DependentTemplateSpecializationType record. TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION = 32, + /// \brief A DependentSizedArrayType record. TYPE_DEPENDENT_SIZED_ARRAY = 33, + /// \brief A ParenType record. TYPE_PAREN = 34, + /// \brief A PackExpansionType record. TYPE_PACK_EXPANSION = 35, + /// \brief An AttributedType record. TYPE_ATTRIBUTED = 36, + /// \brief A SubstTemplateTypeParmPackType record. TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK = 37, + /// \brief A AutoType record. TYPE_AUTO = 38, + /// \brief A UnaryTransformType record. TYPE_UNARY_TRANSFORM = 39, + /// \brief An AtomicType record. TYPE_ATOMIC = 40, + /// \brief A DecayedType record. TYPE_DECAYED = 41, + /// \brief An AdjustedType record. TYPE_ADJUSTED = 42, + /// \brief A PipeType record. TYPE_PIPE = 43, + /// \brief An ObjCTypeParamType record. TYPE_OBJC_TYPE_PARAM = 44, + /// \brief A DeducedTemplateSpecializationType record. TYPE_DEDUCED_TEMPLATE_SPECIALIZATION = 45, + /// \brief A DependentSizedExtVectorType record. TYPE_DEPENDENT_SIZED_EXT_VECTOR = 46, + /// \brief A DependentAddressSpaceType record. TYPE_DEPENDENT_ADDRESS_SPACE = 47 }; @@ -953,18 +1081,25 @@ namespace clang { enum SpecialTypeIDs { /// \brief CFConstantString type SPECIAL_TYPE_CF_CONSTANT_STRING = 0, + /// \brief C FILE typedef type SPECIAL_TYPE_FILE = 1, + /// \brief C jmp_buf typedef type SPECIAL_TYPE_JMP_BUF = 2, + /// \brief C sigjmp_buf typedef type SPECIAL_TYPE_SIGJMP_BUF = 3, + /// \brief Objective-C "id" redefinition type SPECIAL_TYPE_OBJC_ID_REDEFINITION = 4, + /// \brief Objective-C "Class" redefinition type SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 5, + /// \brief Objective-C "SEL" redefinition type SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 6, + /// \brief C ucontext_t typedef type SPECIAL_TYPE_UCONTEXT_T = 7 }; @@ -1055,57 +1190,84 @@ namespace clang { /// \brief A TypedefDecl record. DECL_TYPEDEF = 51, /// \brief A TypeAliasDecl record. + DECL_TYPEALIAS, + /// \brief An EnumDecl record. DECL_ENUM, + /// \brief A RecordDecl record. DECL_RECORD, + /// \brief An EnumConstantDecl record. DECL_ENUM_CONSTANT, + /// \brief A FunctionDecl record. DECL_FUNCTION, + /// \brief A ObjCMethodDecl record. DECL_OBJC_METHOD, + /// \brief A ObjCInterfaceDecl record. DECL_OBJC_INTERFACE, + /// \brief A ObjCProtocolDecl record. DECL_OBJC_PROTOCOL, + /// \brief A ObjCIvarDecl record. DECL_OBJC_IVAR, + /// \brief A ObjCAtDefsFieldDecl record. DECL_OBJC_AT_DEFS_FIELD, + /// \brief A ObjCCategoryDecl record. DECL_OBJC_CATEGORY, + /// \brief A ObjCCategoryImplDecl record. DECL_OBJC_CATEGORY_IMPL, + /// \brief A ObjCImplementationDecl record. DECL_OBJC_IMPLEMENTATION, + /// \brief A ObjCCompatibleAliasDecl record. DECL_OBJC_COMPATIBLE_ALIAS, + /// \brief A ObjCPropertyDecl record. DECL_OBJC_PROPERTY, + /// \brief A ObjCPropertyImplDecl record. DECL_OBJC_PROPERTY_IMPL, + /// \brief A FieldDecl record. DECL_FIELD, + /// \brief A MSPropertyDecl record. DECL_MS_PROPERTY, + /// \brief A VarDecl record. DECL_VAR, + /// \brief An ImplicitParamDecl record. DECL_IMPLICIT_PARAM, + /// \brief A ParmVarDecl record. DECL_PARM_VAR, + /// \brief A DecompositionDecl record. DECL_DECOMPOSITION, + /// \brief A BindingDecl record. DECL_BINDING, + /// \brief A FileScopeAsmDecl record. DECL_FILE_SCOPE_ASM, + /// \brief A BlockDecl record. DECL_BLOCK, + /// \brief A CapturedDecl record. DECL_CAPTURED, + /// \brief A record that stores the set of declarations that are /// lexically stored within a given DeclContext. /// @@ -1115,6 +1277,7 @@ namespace clang { /// the contents of a DeclContext, e.g., via /// DeclContext::decls_begin() and DeclContext::decls_end(). DECL_CONTEXT_LEXICAL, + /// \brief A record that stores the set of declarations that are /// visible from a given DeclContext. /// @@ -1123,104 +1286,151 @@ namespace clang { /// IDs. This data is used when performing qualified name lookup /// into a DeclContext via DeclContext::lookup. DECL_CONTEXT_VISIBLE, + /// \brief A LabelDecl record. DECL_LABEL, + /// \brief A NamespaceDecl record. DECL_NAMESPACE, + /// \brief A NamespaceAliasDecl record. DECL_NAMESPACE_ALIAS, + /// \brief A UsingDecl record. DECL_USING, + /// \brief A UsingPackDecl record. DECL_USING_PACK, + /// \brief A UsingShadowDecl record. DECL_USING_SHADOW, + /// \brief A ConstructorUsingShadowDecl record. DECL_CONSTRUCTOR_USING_SHADOW, + /// \brief A UsingDirecitveDecl record. DECL_USING_DIRECTIVE, + /// \brief An UnresolvedUsingValueDecl record. DECL_UNRESOLVED_USING_VALUE, + /// \brief An UnresolvedUsingTypenameDecl record. DECL_UNRESOLVED_USING_TYPENAME, + /// \brief A LinkageSpecDecl record. DECL_LINKAGE_SPEC, + /// \brief An ExportDecl record. DECL_EXPORT, + /// \brief A CXXRecordDecl record. DECL_CXX_RECORD, + /// \brief A CXXDeductionGuideDecl record. DECL_CXX_DEDUCTION_GUIDE, + /// \brief A CXXMethodDecl record. DECL_CXX_METHOD, + /// \brief A CXXConstructorDecl record. DECL_CXX_CONSTRUCTOR, + /// \brief A CXXConstructorDecl record for an inherited constructor. DECL_CXX_INHERITED_CONSTRUCTOR, + /// \brief A CXXDestructorDecl record. DECL_CXX_DESTRUCTOR, + /// \brief A CXXConversionDecl record. DECL_CXX_CONVERSION, + /// \brief An AccessSpecDecl record. DECL_ACCESS_SPEC, /// \brief A FriendDecl record. DECL_FRIEND, + /// \brief A FriendTemplateDecl record. DECL_FRIEND_TEMPLATE, + /// \brief A ClassTemplateDecl record. DECL_CLASS_TEMPLATE, + /// \brief A ClassTemplateSpecializationDecl record. DECL_CLASS_TEMPLATE_SPECIALIZATION, + /// \brief A ClassTemplatePartialSpecializationDecl record. DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION, + /// \brief A VarTemplateDecl record. DECL_VAR_TEMPLATE, + /// \brief A VarTemplateSpecializationDecl record. DECL_VAR_TEMPLATE_SPECIALIZATION, + /// \brief A VarTemplatePartialSpecializationDecl record. DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION, + /// \brief A FunctionTemplateDecl record. DECL_FUNCTION_TEMPLATE, + /// \brief A TemplateTypeParmDecl record. DECL_TEMPLATE_TYPE_PARM, + /// \brief A NonTypeTemplateParmDecl record. DECL_NON_TYPE_TEMPLATE_PARM, + /// \brief A TemplateTemplateParmDecl record. DECL_TEMPLATE_TEMPLATE_PARM, + /// \brief A TypeAliasTemplateDecl record. DECL_TYPE_ALIAS_TEMPLATE, + /// \brief A StaticAssertDecl record. DECL_STATIC_ASSERT, + /// \brief A record containing CXXBaseSpecifiers. DECL_CXX_BASE_SPECIFIERS, + /// \brief A record containing CXXCtorInitializers. DECL_CXX_CTOR_INITIALIZERS, + /// \brief A IndirectFieldDecl record. DECL_INDIRECTFIELD, + /// \brief A NonTypeTemplateParmDecl record that stores an expanded /// non-type template parameter pack. DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK, + /// \brief A TemplateTemplateParmDecl record that stores an expanded /// template template parameter pack. DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK, + /// \brief A ClassScopeFunctionSpecializationDecl record a class scope /// function specialization. (Microsoft extension). DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION, + /// \brief An ImportDecl recording a module import. DECL_IMPORT, + /// \brief An OMPThreadPrivateDecl record. DECL_OMP_THREADPRIVATE, + /// \brief An EmptyDecl record. DECL_EMPTY, + /// \brief An ObjCTypeParamDecl record. DECL_OBJC_TYPE_PARAM, + /// \brief An OMPCapturedExprDecl record. DECL_OMP_CAPTUREDEXPR, + /// \brief A PragmaCommentDecl record. DECL_PRAGMA_COMMENT, + /// \brief A PragmaDetectMismatchDecl record. DECL_PRAGMA_DETECT_MISMATCH, + /// \brief An OMPDeclareReductionDecl record. DECL_OMP_DECLARE_REDUCTION, }; @@ -1236,128 +1446,190 @@ namespace clang { /// \brief A marker record that indicates that we are at the end /// of an expression. STMT_STOP = 128, + /// \brief A NULL expression. STMT_NULL_PTR, + /// \brief A reference to a previously [de]serialized Stmt record. STMT_REF_PTR, + /// \brief A NullStmt record. STMT_NULL, + /// \brief A CompoundStmt record. STMT_COMPOUND, + /// \brief A CaseStmt record. STMT_CASE, + /// \brief A DefaultStmt record. STMT_DEFAULT, + /// \brief A LabelStmt record. STMT_LABEL, + /// \brief An AttributedStmt record. STMT_ATTRIBUTED, + /// \brief An IfStmt record. STMT_IF, + /// \brief A SwitchStmt record. STMT_SWITCH, + /// \brief A WhileStmt record. STMT_WHILE, + /// \brief A DoStmt record. STMT_DO, + /// \brief A ForStmt record. STMT_FOR, + /// \brief A GotoStmt record. STMT_GOTO, + /// \brief An IndirectGotoStmt record. STMT_INDIRECT_GOTO, + /// \brief A ContinueStmt record. STMT_CONTINUE, + /// \brief A BreakStmt record. STMT_BREAK, + /// \brief A ReturnStmt record. STMT_RETURN, + /// \brief A DeclStmt record. STMT_DECL, + /// \brief A CapturedStmt record. STMT_CAPTURED, + /// \brief A GCC-style AsmStmt record. STMT_GCCASM, + /// \brief A MS-style AsmStmt record. STMT_MSASM, + /// \brief A PredefinedExpr record. EXPR_PREDEFINED, + /// \brief A DeclRefExpr record. EXPR_DECL_REF, + /// \brief An IntegerLiteral record. EXPR_INTEGER_LITERAL, + /// \brief A FloatingLiteral record. EXPR_FLOATING_LITERAL, + /// \brief An ImaginaryLiteral record. EXPR_IMAGINARY_LITERAL, + /// \brief A StringLiteral record. EXPR_STRING_LITERAL, + /// \brief A CharacterLiteral record. EXPR_CHARACTER_LITERAL, + /// \brief A ParenExpr record. EXPR_PAREN, + /// \brief A ParenListExpr record. EXPR_PAREN_LIST, + /// \brief A UnaryOperator record. EXPR_UNARY_OPERATOR, + /// \brief An OffsetOfExpr record. EXPR_OFFSETOF, + /// \brief A SizefAlignOfExpr record. EXPR_SIZEOF_ALIGN_OF, + /// \brief An ArraySubscriptExpr record. EXPR_ARRAY_SUBSCRIPT, + /// \brief A CallExpr record. EXPR_CALL, + /// \brief A MemberExpr record. EXPR_MEMBER, + /// \brief A BinaryOperator record. EXPR_BINARY_OPERATOR, + /// \brief A CompoundAssignOperator record. EXPR_COMPOUND_ASSIGN_OPERATOR, + /// \brief A ConditionOperator record. EXPR_CONDITIONAL_OPERATOR, + /// \brief An ImplicitCastExpr record. EXPR_IMPLICIT_CAST, + /// \brief A CStyleCastExpr record. EXPR_CSTYLE_CAST, + /// \brief A CompoundLiteralExpr record. EXPR_COMPOUND_LITERAL, + /// \brief An ExtVectorElementExpr record. EXPR_EXT_VECTOR_ELEMENT, + /// \brief An InitListExpr record. EXPR_INIT_LIST, + /// \brief A DesignatedInitExpr record. EXPR_DESIGNATED_INIT, + /// \brief A DesignatedInitUpdateExpr record. EXPR_DESIGNATED_INIT_UPDATE, + /// \brief An NoInitExpr record. EXPR_NO_INIT, + /// \brief An ArrayInitLoopExpr record. EXPR_ARRAY_INIT_LOOP, + /// \brief An ArrayInitIndexExpr record. EXPR_ARRAY_INIT_INDEX, + /// \brief An ImplicitValueInitExpr record. EXPR_IMPLICIT_VALUE_INIT, + /// \brief A VAArgExpr record. EXPR_VA_ARG, + /// \brief An AddrLabelExpr record. EXPR_ADDR_LABEL, + /// \brief A StmtExpr record. EXPR_STMT, + /// \brief A ChooseExpr record. EXPR_CHOOSE, + /// \brief A GNUNullExpr record. EXPR_GNU_NULL, + /// \brief A ShuffleVectorExpr record. EXPR_SHUFFLE_VECTOR, + /// \brief A ConvertVectorExpr record. EXPR_CONVERT_VECTOR, + /// \brief BlockExpr EXPR_BLOCK, + /// \brief A GenericSelectionExpr record. EXPR_GENERIC_SELECTION, + /// \brief A PseudoObjectExpr record. EXPR_PSEUDO_OBJECT, + /// \brief An AtomicExpr record. EXPR_ATOMIC, @@ -1369,45 +1641,61 @@ namespace clang { EXPR_OBJC_BOXED_EXPRESSION, EXPR_OBJC_ARRAY_LITERAL, EXPR_OBJC_DICTIONARY_LITERAL, - - + /// \brief An ObjCEncodeExpr record. EXPR_OBJC_ENCODE, + /// \brief An ObjCSelectorExpr record. EXPR_OBJC_SELECTOR_EXPR, + /// \brief An ObjCProtocolExpr record. EXPR_OBJC_PROTOCOL_EXPR, + /// \brief An ObjCIvarRefExpr record. EXPR_OBJC_IVAR_REF_EXPR, + /// \brief An ObjCPropertyRefExpr record. EXPR_OBJC_PROPERTY_REF_EXPR, + /// \brief An ObjCSubscriptRefExpr record. EXPR_OBJC_SUBSCRIPT_REF_EXPR, + /// \brief UNUSED EXPR_OBJC_KVC_REF_EXPR, + /// \brief An ObjCMessageExpr record. EXPR_OBJC_MESSAGE_EXPR, + /// \brief An ObjCIsa Expr record. EXPR_OBJC_ISA, + /// \brief An ObjCIndirectCopyRestoreExpr record. EXPR_OBJC_INDIRECT_COPY_RESTORE, /// \brief An ObjCForCollectionStmt record. STMT_OBJC_FOR_COLLECTION, + /// \brief An ObjCAtCatchStmt record. STMT_OBJC_CATCH, + /// \brief An ObjCAtFinallyStmt record. STMT_OBJC_FINALLY, + /// \brief An ObjCAtTryStmt record. STMT_OBJC_AT_TRY, + /// \brief An ObjCAtSynchronizedStmt record. STMT_OBJC_AT_SYNCHRONIZED, + /// \brief An ObjCAtThrowStmt record. STMT_OBJC_AT_THROW, + /// \brief An ObjCAutoreleasePoolStmt record. STMT_OBJC_AUTORELEASE_POOL, + /// \brief An ObjCBoolLiteralExpr record. EXPR_OBJC_BOOL_LITERAL, + /// \brief An ObjCAvailabilityCheckExpr record. EXPR_OBJC_AVAILABILITY_CHECK, @@ -1415,37 +1703,52 @@ namespace clang { /// \brief A CXXCatchStmt record. STMT_CXX_CATCH, + /// \brief A CXXTryStmt record. STMT_CXX_TRY, /// \brief A CXXForRangeStmt record. + STMT_CXX_FOR_RANGE, /// \brief A CXXOperatorCallExpr record. EXPR_CXX_OPERATOR_CALL, + /// \brief A CXXMemberCallExpr record. EXPR_CXX_MEMBER_CALL, + /// \brief A CXXConstructExpr record. EXPR_CXX_CONSTRUCT, + /// \brief A CXXInheritedCtorInitExpr record. EXPR_CXX_INHERITED_CTOR_INIT, + /// \brief A CXXTemporaryObjectExpr record. EXPR_CXX_TEMPORARY_OBJECT, + /// \brief A CXXStaticCastExpr record. EXPR_CXX_STATIC_CAST, + /// \brief A CXXDynamicCastExpr record. EXPR_CXX_DYNAMIC_CAST, + /// \brief A CXXReinterpretCastExpr record. EXPR_CXX_REINTERPRET_CAST, + /// \brief A CXXConstCastExpr record. EXPR_CXX_CONST_CAST, + /// \brief A CXXFunctionalCastExpr record. EXPR_CXX_FUNCTIONAL_CAST, + /// \brief A UserDefinedLiteral record. EXPR_USER_DEFINED_LITERAL, + /// \brief A CXXStdInitializerListExpr record. EXPR_CXX_STD_INITIALIZER_LIST, + /// \brief A CXXBoolLiteralExpr record. EXPR_CXX_BOOL_LITERAL, + EXPR_CXX_NULL_PTR_LITERAL, // CXXNullPtrLiteralExpr EXPR_CXX_TYPEID_EXPR, // CXXTypeidExpr (of expr). EXPR_CXX_TYPEID_TYPE, // CXXTypeidExpr (of type). @@ -1567,11 +1870,14 @@ namespace clang { enum DesignatorTypes { /// \brief Field designator where only the field name is known. DESIG_FIELD_NAME = 0, + /// \brief Field designator where the field has been resolved to /// a declaration. DESIG_FIELD_DECL = 1, + /// \brief Array designator. DESIG_ARRAY = 2, + /// \brief GNU array range designator. DESIG_ARRAY_RANGE = 3 }; @@ -1587,8 +1893,11 @@ namespace clang { /// \brief Describes the redeclarations of a declaration. struct LocalRedeclarationsInfo { - DeclID FirstID; // The ID of the first declaration - unsigned Offset; // Offset into the array of redeclaration chains. + // The ID of the first declaration + DeclID FirstID; + + // Offset into the array of redeclaration chains. + unsigned Offset; friend bool operator<(const LocalRedeclarationsInfo &X, const LocalRedeclarationsInfo &Y) { @@ -1613,8 +1922,11 @@ namespace clang { /// \brief Describes the categories of an Objective-C class. struct ObjCCategoriesInfo { - DeclID DefinitionID; // The ID of the definition - unsigned Offset; // Offset into the array of category lists. + // The ID of the definition + DeclID DefinitionID; + + // Offset into the array of category lists. + unsigned Offset; friend bool operator<(const ObjCCategoriesInfo &X, const ObjCCategoriesInfo &Y) { @@ -1643,15 +1955,14 @@ namespace clang { /// same key can occasionally represent multiple names (for names that /// contain types, in particular). class DeclarationNameKey { - typedef unsigned NameKind; + using NameKind = unsigned; - NameKind Kind; - uint64_t Data; + NameKind Kind = 0; + uint64_t Data = 0; public: - DeclarationNameKey() : Kind(), Data() {} + DeclarationNameKey() = default; DeclarationNameKey(DeclarationName Name); - DeclarationNameKey(NameKind Kind, uint64_t Data) : Kind(Kind), Data(Data) {} @@ -1663,12 +1974,14 @@ namespace clang { Kind == DeclarationName::CXXDeductionGuideName); return (IdentifierInfo *)Data; } + Selector getSelector() const { assert(Kind == DeclarationName::ObjCZeroArgSelector || Kind == DeclarationName::ObjCOneArgSelector || Kind == DeclarationName::ObjCMultiArgSelector); return Selector(Data); } + OverloadedOperatorKind getOperatorKind() const { assert(Kind == DeclarationName::CXXOperatorName); return (OverloadedOperatorKind)Data; @@ -1684,26 +1997,32 @@ namespace clang { }; /// @} - } -} // end namespace clang + +} // namespace serialization +} // namespace clang namespace llvm { + template <> struct DenseMapInfo<clang::serialization::DeclarationNameKey> { static clang::serialization::DeclarationNameKey getEmptyKey() { return clang::serialization::DeclarationNameKey(-1, 1); } + static clang::serialization::DeclarationNameKey getTombstoneKey() { return clang::serialization::DeclarationNameKey(-1, 2); } + static unsigned getHashValue(const clang::serialization::DeclarationNameKey &Key) { return Key.getHash(); } + static bool isEqual(const clang::serialization::DeclarationNameKey &L, const clang::serialization::DeclarationNameKey &R) { return L == R; } }; -} -#endif +} // namespace llvm + +#endif // LLVM_CLANG_SERIALIZATION_ASTBITCODES_H diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 9c5ad00691..7b71fee95d 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -1,4 +1,4 @@ -//===--- ASTReader.h - AST File Reader --------------------------*- C++ -*-===// +//===- ASTReader.h - AST File Reader ----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,13 +17,21 @@ #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/TemplateBase.h" +#include "clang/AST/TemplateName.h" +#include "clang/AST/Type.h" #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileSystemOptions.h" #include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/Module.h" +#include "clang/Basic/OpenCLOptions.h" +#include "clang/Basic/SourceLocation.h" #include "clang/Basic/Version.h" +#include "clang/Basic/VersionTuple.h" #include "clang/Lex/ExternalPreprocessorSource.h" #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/PreprocessingRecord.h" +#include "clang/Lex/Token.h" #include "clang/Sema/ExternalSemaSource.h" #include "clang/Sema/IdentifierResolver.h" #include "clang/Serialization/ASTBitCodes.h" @@ -31,70 +39,86 @@ #include "clang/Serialization/Module.h" #include "clang/Serialization/ModuleFileExtension.h" #include "clang/Serialization/ModuleManager.h" +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/MapVector.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/TinyPtrVector.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/Bitcode/BitstreamReader.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Timer.h" +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <ctime> #include <deque> #include <memory> +#include <set> #include <string> #include <utility> #include <vector> -namespace llvm { - class BitstreamCursor; - class MemoryBuffer; - class APInt; - class APSInt; - class APFloat; -} - namespace clang { -class SourceManager; -class HeaderSearchOptions; -class FileManager; -class AddrLabelExpr; class ASTConsumer; class ASTContext; -class ASTIdentifierIterator; -class ASTUnit; // FIXME: Layering violation and egregious hack. -class Attr; -class Decl; -class DeclContext; -class DefMacroDirective; -class DiagnosticOptions; -class NestedNameSpecifier; +class ASTDeserializationListener; +class ASTReader; +class ASTRecordReader; class CXXBaseSpecifier; class CXXConstructorDecl; class CXXCtorInitializer; +class CXXTemporary; +class Decl; +class DeclaratorDecl; +class DeclContext; +class EnumDecl; +class Expr; +class FieldDecl; +class FileEntry; +class FileManager; +class FileSystemOptions; +class FunctionDecl; class GlobalModuleIndex; -class GotoStmt; -class MacroDefinition; -class MacroDirective; -class ModuleMacro; +struct HeaderFileInfo; +class HeaderSearchOptions; +class LangOptions; +class LazyASTUnresolvedSet; +class MacroInfo; +class MemoryBufferCache; class NamedDecl; -class OpaqueValueExpr; +class NamespaceDecl; +class NestedNameSpecifier; +class ObjCCategoryDecl; +class ObjCInterfaceDecl; +class PCHContainerReader; class Preprocessor; class PreprocessorOptions; +struct QualifierInfo; class Sema; +class SourceManager; +class Stmt; class SwitchCase; -class ASTDeserializationListener; -class ASTWriter; -class ASTReader; -class ASTDeclReader; -class ASTStmtReader; -class ASTRecordReader; -class TypeLocReader; -struct HeaderFileInfo; -class VersionTuple; class TargetOptions; -class LazyASTUnresolvedSet; +class TemplateParameterList; +class TypedefNameDecl; +class TypeSourceInfo; +class ValueDecl; +class VarDecl; /// \brief Abstract interface for callback invocations by the ASTReader. /// @@ -189,9 +213,11 @@ public: /// \brief Returns true if this \c ASTReaderListener wants to receive the /// input files of the AST file via \c visitInputFile, false otherwise. virtual bool needsInputFileVisitation() { return false; } + /// \brief Returns true if this \c ASTReaderListener wants to receive the /// system input files of the AST file via \c visitInputFile, false otherwise. virtual bool needsSystemInputFileVisitation() { return false; } + /// \brief if \c needsInputFileVisitation returns true, this is called for /// each non-system input file of the AST File. If /// \c needsSystemInputFileVisitation is true, then it is called for all @@ -206,6 +232,7 @@ public: /// \brief Returns true if this \c ASTReaderListener wants to receive the /// imports of the AST file via \c visitImport, false otherwise. virtual bool needsImportVisitation() const { return false; } + /// \brief If needsImportVisitation returns \c true, this is called for each /// AST file imported by this AST file. virtual void visitImport(StringRef Filename) {} @@ -306,12 +333,15 @@ namespace serialization { class ReadMethodPoolVisitor; namespace reader { - class ASTIdentifierLookupTrait; - /// \brief The on-disk hash table(s) used for DeclContext name lookup. - struct DeclContextLookupTable; -} -} // end namespace serialization +class ASTIdentifierLookupTrait; + +/// \brief The on-disk hash table(s) used for DeclContext name lookup. +struct DeclContextLookupTable; + +} // namespace reader + +} // namespace serialization /// \brief Reads an AST files chain containing the contents of a translation /// unit. @@ -334,8 +364,20 @@ class ASTReader public ExternalSLocEntrySource { public: - typedef SmallVector<uint64_t, 64> RecordData; - typedef SmallVectorImpl<uint64_t> RecordDataImpl; + /// \brief Types of AST files. + friend class ASTDeclReader; + friend class ASTIdentifierIterator; + friend class ASTRecordReader; + friend class ASTStmtReader; + friend class ASTUnit; // ASTUnit needs to remap source locations. + friend class ASTWriter; + friend class PCHValidator; + friend class serialization::reader::ASTIdentifierLookupTrait; + friend class serialization::ReadMethodPoolVisitor; + friend class TypeLocReader; + + using RecordData = SmallVector<uint64_t, 64>; + using RecordDataImpl = SmallVectorImpl<uint64_t>; /// \brief The result of reading the control block of an AST file, which /// can fail for various reasons. @@ -343,41 +385,34 @@ public: /// \brief The control block was read successfully. Aside from failures, /// the AST file is safe to read into the current context. Success, + /// \brief The AST file itself appears corrupted. Failure, + /// \brief The AST file was missing. Missing, + /// \brief The AST file is out-of-date relative to its input files, /// and needs to be regenerated. OutOfDate, + /// \brief The AST file was written by a different version of Clang. VersionMismatch, + /// \brief The AST file was writtten with a different language/target /// configuration. ConfigurationMismatch, + /// \brief The AST file has errors. HadErrors }; - /// \brief Types of AST files. - friend class PCHValidator; - friend class ASTDeclReader; - friend class ASTStmtReader; - friend class ASTIdentifierIterator; - friend class serialization::reader::ASTIdentifierLookupTrait; - friend class TypeLocReader; - friend class ASTRecordReader; - friend class ASTWriter; - friend class ASTUnit; // ASTUnit needs to remap source locations. - friend class serialization::ReadMethodPoolVisitor; - - typedef serialization::ModuleFile ModuleFile; - typedef serialization::ModuleKind ModuleKind; - typedef serialization::ModuleManager ModuleManager; - - typedef ModuleManager::ModuleIterator ModuleIterator; - typedef ModuleManager::ModuleConstIterator ModuleConstIterator; - typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator; + using ModuleFile = serialization::ModuleFile; + using ModuleKind = serialization::ModuleKind; + using ModuleManager = serialization::ModuleManager; + using ModuleIterator = ModuleManager::ModuleIterator; + using ModuleConstIterator = ModuleManager::ModuleConstIterator; + using ModuleReverseIterator = ModuleManager::ModuleReverseIterator; private: /// \brief The receiver of some callbacks invoked by ASTReader. @@ -385,6 +420,7 @@ private: /// \brief The receiver of deserialization events. ASTDeserializationListener *DeserializationListener = nullptr; + bool OwnsDeserializationListener = false; SourceManager &SourceMgr; @@ -436,7 +472,8 @@ private: /// \brief A map of negated SLocEntryIDs to the modules containing them. ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap; - typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType; + using GlobalSLocOffsetMapType = + ContinuousRangeMap<unsigned, ModuleFile *, 64>; /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset) /// SourceLocation offsets to the modules containing them. @@ -448,8 +485,8 @@ private: /// ID = (I + 1) << FastQual::Width has already been loaded std::vector<QualType> TypesLoaded; - typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4> - GlobalTypeMapType; + using GlobalTypeMapType = + ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4>; /// \brief Mapping from global type IDs to the module in which the /// type resides along with the offset that should be added to the @@ -462,17 +499,17 @@ private: /// = I + 1 has already been loaded. std::vector<Decl *> DeclsLoaded; - typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4> - GlobalDeclMapType; + using GlobalDeclMapType = + ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4>; /// \brief Mapping from global declaration IDs to the module in which the /// declaration resides. GlobalDeclMapType GlobalDeclMap; - typedef std::pair<ModuleFile *, uint64_t> FileOffset; - typedef SmallVector<FileOffset, 2> FileOffsetsTy; - typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy> - DeclUpdateOffsetsMap; + using FileOffset = std::pair<ModuleFile *, uint64_t>; + using FileOffsetsTy = SmallVector<FileOffset, 2>; + using DeclUpdateOffsetsMap = + llvm::DenseMap<serialization::DeclID, FileOffsetsTy>; /// \brief Declarations that have modifications residing in a later file /// in the chain. @@ -481,12 +518,15 @@ private: struct PendingUpdateRecord { Decl *D; serialization::GlobalDeclID ID; + // Whether the declaration was just deserialized. bool JustLoaded; + PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D, bool JustLoaded) : D(D), ID(ID), JustLoaded(JustLoaded) {} }; + /// \brief Declaration updates for already-loaded declarations that we need /// to apply once we finish processing an import. llvm::SmallVector<PendingUpdateRecord, 16> PendingUpdateRecords; @@ -505,7 +545,7 @@ private: /// \brief Declarations that have been imported and have typedef names for /// linkage purposes. - llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*> + llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>, NamedDecl *> ImportedTypedefNamesForLinkage; /// \brief Mergeable declaration contexts that have anonymous declarations @@ -514,10 +554,10 @@ private: AnonymousDeclarationsForMerging; struct FileDeclsInfo { - ModuleFile *Mod; + ModuleFile *Mod = nullptr; ArrayRef<serialization::LocalDeclID> Decls; - FileDeclsInfo() : Mod(nullptr) {} + FileDeclsInfo() = default; FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls) : Mod(Mod), Decls(Decls) {} }; @@ -527,7 +567,7 @@ private: /// \brief An array of lexical contents of a declaration context, as a sequence of /// Decl::Kind, DeclID pairs. - typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents; + using LexicalContents = ArrayRef<llvm::support::unaligned_uint32_t>; /// \brief Map from a DeclContext to its lexical contents. llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>> @@ -548,7 +588,7 @@ private: ModuleFile *Mod; const unsigned char *Data; }; - typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates; + using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate, 1>; /// \brief Updates to the visible declarations of declaration contexts that /// haven't been loaded yet. @@ -559,22 +599,23 @@ private: /// declarations that have not yet been linked to their definitions. llvm::SmallPtrSet<Decl *, 4> PendingDefinitions; - typedef llvm::MapVector<Decl *, uint64_t, - llvm::SmallDenseMap<Decl *, unsigned, 4>, - SmallVector<std::pair<Decl *, uint64_t>, 4> > - PendingBodiesMap; + using PendingBodiesMap = + llvm::MapVector<Decl *, uint64_t, + llvm::SmallDenseMap<Decl *, unsigned, 4>, + SmallVector<std::pair<Decl *, uint64_t>, 4>>; /// \brief Functions or methods that have bodies that will be attached. PendingBodiesMap PendingBodies; /// \brief Definitions for which we have added merged definitions but not yet /// performed deduplication. - llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate; + llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate; /// \brief Read the record that describes the lexical contents of a DC. bool ReadLexicalDeclContextStorage(ModuleFile &M, llvm::BitstreamCursor &Cursor, uint64_t Offset, DeclContext *DC); + /// \brief Read the record that describes the visible contents of a DC. bool ReadVisibleDeclContextStorage(ModuleFile &M, llvm::BitstreamCursor &Cursor, @@ -588,8 +629,8 @@ private: /// been loaded. std::vector<IdentifierInfo *> IdentifiersLoaded; - typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4> - GlobalIdentifierMapType; + using GlobalIdentifierMapType = + ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>; /// \brief Mapping from global identifier IDs to the module in which the /// identifier resides along with the offset that should be added to the @@ -604,16 +645,16 @@ private: /// been loaded. std::vector<MacroInfo *> MacrosLoaded; - typedef std::pair<IdentifierInfo *, serialization::SubmoduleID> - LoadedMacroInfo; + using LoadedMacroInfo = + std::pair<IdentifierInfo *, serialization::SubmoduleID>; /// \brief A set of #undef directives that we have loaded; used to /// deduplicate the same #undef information coming from multiple module /// files. llvm::DenseSet<LoadedMacroInfo> LoadedUndefs; - typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4> - GlobalMacroMapType; + using GlobalMacroMapType = + ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>; /// \brief Mapping from global macro IDs to the module in which the /// macro resides along with the offset that should be added to the @@ -626,8 +667,8 @@ private: /// indicate that the particular submodule ID has not yet been loaded. SmallVector<Module *, 2> SubmodulesLoaded; - typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4> - GlobalSubmoduleMapType; + using GlobalSubmoduleMapType = + ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>; /// \brief Mapping from global submodule IDs to the module file in which the /// submodule resides along with the offset that should be added to the @@ -635,14 +676,13 @@ private: GlobalSubmoduleMapType GlobalSubmoduleMap; /// \brief A set of hidden declarations. - typedef SmallVector<Decl*, 2> HiddenNames; - typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType; + using HiddenNames = SmallVector<Decl *, 2>; + using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>; /// \brief A mapping from each of the hidden submodules to the deserialized /// declarations in that submodule that could be made visible. HiddenNamesMapType HiddenNamesMap; - /// \brief A module import, export, or conflict that hasn't yet been resolved. struct UnresolvedModuleRef { /// \brief The file in which this module resides. @@ -675,11 +715,10 @@ private: /// been loaded. SmallVector<Selector, 16> SelectorsLoaded; - typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4> - GlobalSelectorMapType; + using GlobalSelectorMapType = + ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>; /// \brief Mapping from global selector IDs to the module in which the - /// global selector ID to produce a local ID. GlobalSelectorMapType GlobalSelectorMap; @@ -699,15 +738,15 @@ private: : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {} }; - typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> > - PendingMacroIDsMap; + using PendingMacroIDsMap = + llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2>>; /// \brief Mapping from identifiers that have a macro history to the global /// IDs have not yet been deserialized to the global IDs of those macros. PendingMacroIDsMap PendingMacroIDs; - typedef ContinuousRangeMap<unsigned, ModuleFile *, 4> - GlobalPreprocessedEntityMapType; + using GlobalPreprocessedEntityMapType = + ContinuousRangeMap<unsigned, ModuleFile *, 4>; /// \brief Mapping from global preprocessing entity IDs to the module in /// which the preprocessed entity resides along with the offset that should be @@ -895,7 +934,8 @@ private: ///\brief Whether we are currently processing update records. bool ProcessingUpdateRecords = false; - typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy; + using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>; + /// \brief Mapping from switch-case IDs in the chain to switch-case statements /// /// Statements usually don't have IDs, but switch cases need them, so that the @@ -979,7 +1019,7 @@ private: /// /// The declarations on the identifier chain for these identifiers will be /// loaded once the recursive loading has completed. - llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> > + llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4>> PendingIdentifierInfos; /// \brief The set of lookup results that we have faked in order to support @@ -998,7 +1038,9 @@ private: public: InterestingDecl(Decl *D, bool HasBody) : D(D), DeclHasPendingBody(HasBody) {} + Decl *getDecl() { return D; } + /// Whether the declaration has a pending body. bool hasPendingBody() { return DeclHasPendingBody; } }; @@ -1062,8 +1104,8 @@ private: /// module is loaded. SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded; - typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> > - KeyDeclsMap; + using KeyDeclsMap = + llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>; /// \brief A mapping from canonical declarations to the set of global /// declaration IDs for key declaration that have been merged with that @@ -1097,15 +1139,14 @@ private: ASTReader &Reader; enum ReadingKind PrevKind; - ReadingKindTracker(const ReadingKindTracker &) = delete; - void operator=(const ReadingKindTracker &) = delete; - public: ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader) : Reader(reader), PrevKind(Reader.ReadingKind) { Reader.ReadingKind = newKind; } + ReadingKindTracker(const ReadingKindTracker &) = delete; + ReadingKindTracker &operator=(const ReadingKindTracker &) = delete; ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; } }; @@ -1114,15 +1155,15 @@ private: ASTReader &Reader; bool PrevState; - ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete; - void operator=(const ProcessingUpdatesRAIIObj &) = delete; - public: ProcessingUpdatesRAIIObj(ASTReader &reader) : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) { Reader.ProcessingUpdateRecords = true; } + ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete; + ProcessingUpdatesRAIIObj & + operator=(const ProcessingUpdatesRAIIObj &) = delete; ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; } }; @@ -1205,7 +1246,7 @@ private: ImportedModule(ModuleFile *Mod, ModuleFile *ImportedBy, SourceLocation ImportLoc) - : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { } + : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {} }; ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type, @@ -1266,10 +1307,11 @@ private: std::string &SuggestedPredefines); struct RecordLocation { - RecordLocation(ModuleFile *M, uint64_t O) - : F(M), Offset(O) {} ModuleFile *F; uint64_t Offset; + + RecordLocation(ModuleFile *M, uint64_t O) + : F(M), Offset(O) {} }; QualType readTypeRecord(unsigned Index); @@ -1328,12 +1370,11 @@ public: ModuleDeclIterator, const serialization::LocalDeclID *, std::random_access_iterator_tag, const Decl *, ptrdiff_t, const Decl *, const Decl *> { - ASTReader *Reader; - ModuleFile *Mod; + ASTReader *Reader = nullptr; + ModuleFile *Mod = nullptr; public: - ModuleDeclIterator() - : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {} + ModuleDeclIterator() : iterator_adaptor_base(nullptr) {} ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, const serialization::LocalDeclID *Pos) @@ -1342,6 +1383,7 @@ public: value_type operator*() const { return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I)); } + value_type operator->() const { return **this; } bool operator==(const ModuleDeclIterator &RHS) const { @@ -1378,8 +1420,6 @@ private: void Error(unsigned DiagID, StringRef Arg1 = StringRef(), StringRef Arg2 = StringRef()) const; - ASTReader(const ASTReader &) = delete; - void operator=(const ASTReader &) = delete; public: /// \brief Load the AST file and validate its contents against the given /// Preprocessor. @@ -1428,7 +1468,8 @@ public: bool AllowConfigurationMismatch = false, bool ValidateSystemInputs = false, bool UseGlobalIndex = true, std::unique_ptr<llvm::Timer> ReadTimer = {}); - + ASTReader(const ASTReader &) = delete; + ASTReader &operator=(const ASTReader &) = delete; ~ASTReader() override; SourceManager &getSourceManager() const { return SourceMgr; } @@ -1443,15 +1484,19 @@ public: enum LoadFailureCapabilities { /// \brief The client can't handle any AST loading failures. ARR_None = 0, + /// \brief The client can handle an AST file that cannot load because it /// is missing. ARR_Missing = 0x1, + /// \brief The client can handle an AST file that cannot load because it /// is out-of-date relative to its input files. ARR_OutOfDate = 0x2, + /// \brief The client can handle an AST file that cannot load because it /// was built with a different version of Clang. ARR_VersionMismatch = 0x4, + /// \brief The client can handle an AST file that cannot load because it's /// compiled configuration doesn't match that of the context it was /// loaded into. @@ -1522,11 +1567,11 @@ public: /// RAII object to temporarily add an AST callback listener. class ListenerScope { ASTReader &Reader; - bool Chained; + bool Chained = false; public: ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L) - : Reader(Reader), Chained(false) { + : Reader(Reader) { auto Old = Reader.takeListener(); if (Old) { Chained = true; @@ -1535,6 +1580,7 @@ public: } Reader.setListener(std::move(L)); } + ~ListenerScope() { auto New = Reader.takeListener(); if (Chained) @@ -1933,16 +1979,16 @@ public: llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override; void ReadReferencedSelectors( - SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override; + SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) override; void ReadWeakUndeclaredIdentifiers( - SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) override; + SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WI) override; void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override; void ReadPendingInstantiations( - SmallVectorImpl<std::pair<ValueDecl *, - SourceLocation> > &Pending) override; + SmallVectorImpl<std::pair<ValueDecl *, + SourceLocation>> &Pending) override; void ReadLateParsedTemplates( llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>> @@ -2275,20 +2321,19 @@ public: /// \brief An object for streaming information from a record. class ASTRecordReader { - typedef serialization::ModuleFile ModuleFile; + using ModuleFile = serialization::ModuleFile; ASTReader *Reader; ModuleFile *F; unsigned Idx = 0; ASTReader::RecordData Record; - typedef ASTReader::RecordData RecordData; - typedef ASTReader::RecordDataImpl RecordDataImpl; + using RecordData = ASTReader::RecordData; + using RecordDataImpl = ASTReader::RecordDataImpl; public: /// Construct an ASTRecordReader that uses the default encoding scheme. - ASTRecordReader(ASTReader &Reader, ModuleFile &F) - : Reader(&Reader), F(&F) {} + ASTRecordReader(ASTReader &Reader, ModuleFile &F) : Reader(&Reader), F(&F) {} /// \brief Reads a record with id AbbrevID from Cursor, resetting the /// internal state. @@ -2302,17 +2347,20 @@ public: /// \brief The current position in this record. unsigned getIdx() const { return Idx; } + /// \brief The length of this record. size_t size() const { return Record.size(); } /// \brief An arbitrary index in this record. const uint64_t &operator[](size_t N) { return Record[N]; } + /// \brief The last element in this record. const uint64_t &back() const { return Record.back(); } /// \brief Returns the current value in this record, and advances to the /// next value. const uint64_t &readInt() { return Record[Idx++]; } + /// \brief Returns the current value in this record, without advancing. const uint64_t &peekInt() { return Record[Idx]; } @@ -2566,7 +2614,7 @@ public: /// then restores it when destroyed. struct SavedStreamPosition { explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor) - : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { } + : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {} ~SavedStreamPosition() { Cursor.JumpToBit(Offset); @@ -2581,6 +2629,6 @@ inline void PCHValidator::Error(const char *Msg) { Reader.Error(Msg); } -} // end namespace clang +} // namespace clang -#endif +#endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h index 244b01b22a..24bfadd0f8 100644 --- a/include/clang/Serialization/ContinuousRangeMap.h +++ b/include/clang/Serialization/ContinuousRangeMap.h @@ -1,4 +1,4 @@ -//===--- ContinuousRangeMap.h - Map with int range as key -------*- C++ -*-===// +//===- ContinuousRangeMap.h - Map with int range as key ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -18,6 +18,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/SmallVector.h" #include <algorithm> +#include <cassert> #include <utility> namespace clang { @@ -35,14 +36,15 @@ namespace clang { template <typename Int, typename V, unsigned InitialCapacity> class ContinuousRangeMap { public: - typedef std::pair<Int, V> value_type; - typedef value_type &reference; - typedef const value_type &const_reference; - typedef value_type *pointer; - typedef const value_type *const_pointer; + using value_type = std::pair<Int, V>; + using reference = value_type &; + using const_reference = const value_type &; + using pointer = value_type *; + using const_pointer = const value_type *; private: - typedef SmallVector<value_type, InitialCapacity> Representation; + using Representation = SmallVector<value_type, InitialCapacity>; + Representation Rep; struct Compare { @@ -52,7 +54,7 @@ private: bool operator ()(Int L, const_reference R) const { return L < R.first; } - bool operator ()(Int L, Int R) const { + bool operator ()(Int L, Int R) const { return L < R; } bool operator ()(const_reference L, const_reference R) const { @@ -80,8 +82,8 @@ public: Rep.insert(I, Val); } - typedef typename Representation::iterator iterator; - typedef typename Representation::const_iterator const_iterator; + using iterator = typename Representation::iterator; + using const_iterator = typename Representation::const_iterator; iterator begin() { return Rep.begin(); } iterator end() { return Rep.end(); } @@ -108,13 +110,12 @@ public: /// from a set of values. class Builder { ContinuousRangeMap &Self; - + + public: + explicit Builder(ContinuousRangeMap &Self) : Self(Self) {} Builder(const Builder&) = delete; Builder &operator=(const Builder&) = delete; - public: - explicit Builder(ContinuousRangeMap &Self) : Self(Self) { } - ~Builder() { std::sort(Self.Rep.begin(), Self.Rep.end(), Compare()); std::unique(Self.Rep.begin(), Self.Rep.end(), @@ -131,9 +132,10 @@ public: Self.Rep.push_back(Val); } }; + friend class Builder; }; -} +} // namespace clang -#endif +#endif // LLVM_CLANG_SERIALIZATION_CONTINUOUSRANGEMAP_H diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index af1af4590d..06132587b4 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -103,9 +103,6 @@ public: return *static_cast<const T *>(this); } - /// BufferTy - A temporary buffer to hold a set of SVals. - typedef SmallVector<SVal,5> BufferTy; - inline unsigned getRawKind() const { return Kind; } inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); } inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; } diff --git a/include/clang/Tooling/Execution.h b/include/clang/Tooling/Execution.h index 9d07c5659e..1a44c4788c 100644 --- a/include/clang/Tooling/Execution.h +++ b/include/clang/Tooling/Execution.h @@ -162,6 +162,13 @@ createExecutorFromCommandLineArgs(int &argc, const char **argv, llvm::cl::OptionCategory &Category, const char *Overview = nullptr); +namespace internal { +llvm::Expected<std::unique_ptr<ToolExecutor>> +createExecutorFromCommandLineArgsImpl(int &argc, const char **argv, + llvm::cl::OptionCategory &Category, + const char *Overview = nullptr); +} // end namespace internal + } // end namespace tooling } // end namespace clang diff --git a/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h b/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h index 8b01a61256..d96ad78ad8 100644 --- a/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h +++ b/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h @@ -70,6 +70,18 @@ public: return visit(Expr->getFoundDecl().getDecl(), Expr->getMemberLoc()); } + bool VisitOffsetOfExpr(const OffsetOfExpr *S) { + for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) { + const OffsetOfNode &Component = S->getComponent(I); + if (Component.getKind() == OffsetOfNode::Field) { + if (!visit(Component.getField(), Component.getLocEnd())) + return false; + } + // FIXME: Try to resolve dependent field references. + } + return true; + } + // Other visitors: bool VisitTypeLoc(const TypeLoc Loc) { diff --git a/include/clang/Tooling/Refactoring/Rename/RenamingAction.h b/include/clang/Tooling/Refactoring/Rename/RenamingAction.h index d9ed7d3a1f..734b624d77 100644 --- a/include/clang/Tooling/Refactoring/Rename/RenamingAction.h +++ b/include/clang/Tooling/Refactoring/Rename/RenamingAction.h @@ -66,6 +66,28 @@ private: std::string NewName; }; +class QualifiedRenameRule final : public SourceChangeRefactoringRule { +public: + static Expected<QualifiedRenameRule> initiate(RefactoringRuleContext &Context, + std::string OldQualifiedName, + std::string NewQualifiedName); + + static const RefactoringDescriptor &describe(); + +private: + QualifiedRenameRule(const NamedDecl *ND, + std::string NewQualifiedName) + : ND(ND), NewQualifiedName(std::move(NewQualifiedName)) {} + + Expected<AtomicChanges> + createSourceReplacements(RefactoringRuleContext &Context) override; + + // A NamedDecl which indentifies the the symbol being renamed. + const NamedDecl *ND; + // The new qualified name to change the symbol to. + std::string NewQualifiedName; +}; + /// Returns source replacements that correspond to the rename of the given /// symbol occurrences. llvm::Expected<std::vector<AtomicChange>> |