aboutsummaryrefslogtreecommitdiffstats
path: root/include/clang/AST/ASTContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/ASTContext.h')
-rw-r--r--include/clang/AST/ASTContext.h136
1 files changed, 75 insertions, 61 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 1d1aaf4fb115..5e2f4031d96c 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -139,6 +139,12 @@ class FullComment;
} // namespace comments
+namespace interp {
+
+class Context;
+
+} // namespace interp
+
struct TypeInfo {
uint64_t Width = 0;
unsigned Align = 0;
@@ -179,7 +185,8 @@ private:
mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes;
mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
- mutable llvm::FoldingSet<ConstantArrayType> ConstantArrayTypes;
+ mutable llvm::ContextualFoldingSet<ConstantArrayType, ASTContext &>
+ ConstantArrayTypes;
mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
mutable std::vector<VariableArrayType*> VariableArrayTypes;
mutable llvm::FoldingSet<DependentSizedArrayType> DependentSizedArrayTypes;
@@ -507,6 +514,8 @@ private:
/// need to be consistently numbered for the mangler).
llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
MangleNumberingContexts;
+ llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
+ ExtraMangleNumberingContexts;
/// Side-table of mangling numbers for declarations which rarely
/// need them (like static local vars).
@@ -564,6 +573,7 @@ private:
const TargetInfo *Target = nullptr;
const TargetInfo *AuxTarget = nullptr;
clang::PrintingPolicy PrintingPolicy;
+ std::unique_ptr<interp::Context> InterpContext;
public:
IdentifierTable &Idents;
@@ -573,6 +583,9 @@ public:
IntrusiveRefCntPtr<ExternalASTSource> ExternalSource;
ASTMutationListener *Listener = nullptr;
+ /// Returns the clang bytecode interpreter context.
+ interp::Context &getInterpContext();
+
/// Container for either a single DynTypedNode or for an ArrayRef to
/// DynTypedNode. For use with ParentMap.
class DynTypedNodeList {
@@ -729,71 +742,49 @@ public:
/// True if comments are already loaded from ExternalASTSource.
mutable bool CommentsLoaded = false;
- class RawCommentAndCacheFlags {
- public:
- enum Kind {
- /// We searched for a comment attached to the particular declaration, but
- /// didn't find any.
- ///
- /// getRaw() == 0.
- NoCommentInDecl = 0,
-
- /// We have found a comment attached to this particular declaration.
- ///
- /// getRaw() != 0.
- FromDecl,
-
- /// This declaration does not have an attached comment, and we have
- /// searched the redeclaration chain.
- ///
- /// If getRaw() == 0, the whole redeclaration chain does not have any
- /// comments.
- ///
- /// If getRaw() != 0, it is a comment propagated from other
- /// redeclaration.
- FromRedecl
- };
-
- Kind getKind() const LLVM_READONLY {
- return Data.getInt();
- }
-
- void setKind(Kind K) {
- Data.setInt(K);
- }
-
- const RawComment *getRaw() const LLVM_READONLY {
- return Data.getPointer();
- }
-
- void setRaw(const RawComment *RC) {
- Data.setPointer(RC);
- }
-
- const Decl *getOriginalDecl() const LLVM_READONLY {
- return OriginalDecl;
- }
-
- void setOriginalDecl(const Decl *Orig) {
- OriginalDecl = Orig;
- }
-
- private:
- llvm::PointerIntPair<const RawComment *, 2, Kind> Data;
- const Decl *OriginalDecl;
- };
+ /// Mapping from declaration to directly attached comment.
+ ///
+ /// Raw comments are owned by Comments list. This mapping is populated
+ /// lazily.
+ mutable llvm::DenseMap<const Decl *, const RawComment *> DeclRawComments;
- /// Mapping from declarations to comments attached to any
- /// redeclaration.
+ /// Mapping from canonical declaration to the first redeclaration in chain
+ /// that has a comment attached.
///
/// Raw comments are owned by Comments list. This mapping is populated
/// lazily.
- mutable llvm::DenseMap<const Decl *, RawCommentAndCacheFlags> RedeclComments;
+ mutable llvm::DenseMap<const Decl *, const Decl *> RedeclChainComments;
+
+ /// Keeps track of redeclaration chains that don't have any comment attached.
+ /// Mapping from canonical declaration to redeclaration chain that has no
+ /// comments attached to any redeclaration. Specifically it's mapping to
+ /// the last redeclaration we've checked.
+ ///
+ /// Shall not contain declarations that have comments attached to any
+ /// redeclaration in their chain.
+ mutable llvm::DenseMap<const Decl *, const Decl *> CommentlessRedeclChains;
/// Mapping from declarations to parsed comments attached to any
/// redeclaration.
mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments;
+ /// Attaches \p Comment to \p OriginalD and to its redeclaration chain
+ /// and removes the redeclaration chain from the set of commentless chains.
+ ///
+ /// Don't do anything if a comment has already been attached to \p OriginalD
+ /// or its redeclaration chain.
+ void cacheRawCommentForDecl(const Decl &OriginalD,
+ const RawComment &Comment) const;
+
+ /// \returns searches \p CommentsInFile for doc comment for \p D.
+ ///
+ /// \p RepresentativeLocForDecl is used as a location for searching doc
+ /// comments. \p CommentsInFile is a mapping offset -> comment of files in the
+ /// same file where \p RepresentativeLocForDecl is.
+ RawComment *getRawCommentForDeclNoCacheImpl(
+ const Decl *D, const SourceLocation RepresentativeLocForDecl,
+ const std::map<unsigned, RawComment *> &CommentsInFile) const;
+
/// Return the documentation comment attached to a given declaration,
/// without looking into cache.
RawComment *getRawCommentForDeclNoCache(const Decl *D) const;
@@ -818,6 +809,16 @@ public:
getRawCommentForAnyRedecl(const Decl *D,
const Decl **OriginalDecl = nullptr) const;
+ /// Searches existing comments for doc comments that should be attached to \p
+ /// Decls. If any doc comment is found, it is parsed.
+ ///
+ /// Requirement: All \p Decls are in the same file.
+ ///
+ /// If the last comment in the file is already attached we assume
+ /// there are not comments left to be attached to \p Decls.
+ void attachCommentsToJustParsedDecls(ArrayRef<Decl *> Decls,
+ const Preprocessor *PP);
+
/// Return parsed documentation comment attached to a given declaration.
/// Returns nullptr if no comment is attached.
///
@@ -1054,6 +1055,9 @@ public:
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
CanQualType Id##Ty;
#include "clang/Basic/OpenCLExtensionTypes.def"
+#define SVE_TYPE(Name, Id, SingletonId) \
+ CanQualType SingletonId;
+#include "clang/Basic/AArch64SVEACLETypes.def"
// Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
mutable QualType AutoDeductTy; // Deduction against 'auto'.
@@ -1329,6 +1333,7 @@ public:
/// Return the unique reference to the type for a constant array of
/// the specified element type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
+ const Expr *SizeExpr,
ArrayType::ArraySizeModifier ASM,
unsigned IndexTypeQuals) const;
@@ -1498,8 +1503,7 @@ public:
bool isKindOf) const;
QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl,
- ArrayRef<ObjCProtocolDecl *> protocols,
- QualType Canonical = QualType()) const;
+ ArrayRef<ObjCProtocolDecl *> protocols) const;
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl);
@@ -2054,6 +2058,11 @@ public:
/// types.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
+ /// Return true if the type has been explicitly qualified with ObjC ownership.
+ /// A type may be implicitly qualified with ownership under ObjC ARC, and in
+ /// some cases the compiler treats these differently.
+ bool hasDirectOwnershipQualifier(QualType Ty) const;
+
/// Return true if this is an \c NSObject object with its \c NSObject
/// attribute set.
static bool isObjCNSObjectType(QualType Ty) {
@@ -2577,10 +2586,12 @@ public:
return T == getObjCSelType();
}
- bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS,
+ bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS,
+ const ObjCObjectPointerType *RHS,
bool ForCompare);
- bool ObjCQualifiedClassTypesAreCompatible(QualType LHS, QualType RHS);
+ bool ObjCQualifiedClassTypesAreCompatible(const ObjCObjectPointerType *LHS,
+ const ObjCObjectPointerType *RHS);
// Check the safety of assignment from LHS to RHS
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT,
@@ -2802,6 +2813,9 @@ public:
/// Retrieve the context for computing mangling numbers in the given
/// DeclContext.
MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);
+ enum NeedExtraManglingDecl_t { NeedExtraManglingDecl };
+ MangleNumberingContext &getManglingNumberContext(NeedExtraManglingDecl_t,
+ const Decl *D);
std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;