|
@@ -1,4 +1,4 @@
|
|
-//===--- DeclSpec.h - Parsed declaration specifiers -------------*- C++ -*-===//
|
|
|
|
|
|
+//===- DeclSpec.h - Parsed declaration specifiers ---------------*- C++ -*-===//
|
|
//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
//
|
|
@@ -6,7 +6,7 @@
|
|
// License. See LICENSE.TXT for details.
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//===----------------------------------------------------------------------===//
|
|
-///
|
|
|
|
|
|
+//
|
|
/// \file
|
|
/// \file
|
|
/// \brief This file defines the classes used to store parsed information about
|
|
/// \brief This file defines the classes used to store parsed information about
|
|
/// declaration-specifiers and declarators.
|
|
/// declaration-specifiers and declarators.
|
|
@@ -17,7 +17,7 @@
|
|
/// declaration-specifiers \ | /
|
|
/// declaration-specifiers \ | /
|
|
/// declarators
|
|
/// declarators
|
|
/// \endverbatim
|
|
/// \endverbatim
|
|
-///
|
|
|
|
|
|
+//
|
|
//===----------------------------------------------------------------------===//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
#ifndef LLVM_CLANG_SEMA_DECLSPEC_H
|
|
#ifndef LLVM_CLANG_SEMA_DECLSPEC_H
|
|
@@ -25,28 +25,39 @@
|
|
|
|
|
|
#include "clang/AST/NestedNameSpecifier.h"
|
|
#include "clang/AST/NestedNameSpecifier.h"
|
|
#include "clang/Basic/ExceptionSpecificationType.h"
|
|
#include "clang/Basic/ExceptionSpecificationType.h"
|
|
|
|
+#include "clang/Basic/LLVM.h"
|
|
#include "clang/Basic/Lambda.h"
|
|
#include "clang/Basic/Lambda.h"
|
|
#include "clang/Basic/OperatorKinds.h"
|
|
#include "clang/Basic/OperatorKinds.h"
|
|
|
|
+#include "clang/Basic/SourceLocation.h"
|
|
#include "clang/Basic/Specifiers.h"
|
|
#include "clang/Basic/Specifiers.h"
|
|
#include "clang/Lex/Token.h"
|
|
#include "clang/Lex/Token.h"
|
|
#include "clang/Sema/AttributeList.h"
|
|
#include "clang/Sema/AttributeList.h"
|
|
#include "clang/Sema/Ownership.h"
|
|
#include "clang/Sema/Ownership.h"
|
|
|
|
+#include "llvm/ADT/ArrayRef.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
+#include "llvm/ADT/iterator_range.h"
|
|
#include "llvm/Support/Compiler.h"
|
|
#include "llvm/Support/Compiler.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
+#include <cassert>
|
|
|
|
+#include <memory>
|
|
|
|
+#include <utility>
|
|
|
|
|
|
namespace clang {
|
|
namespace clang {
|
|
- class ASTContext;
|
|
|
|
- class CXXRecordDecl;
|
|
|
|
- class TypeLoc;
|
|
|
|
- class LangOptions;
|
|
|
|
- class IdentifierInfo;
|
|
|
|
- class NamespaceAliasDecl;
|
|
|
|
- class NamespaceDecl;
|
|
|
|
- class ObjCDeclSpec;
|
|
|
|
- class Sema;
|
|
|
|
- class Declarator;
|
|
|
|
- struct TemplateIdAnnotation;
|
|
|
|
|
|
+
|
|
|
|
+class ASTContext;
|
|
|
|
+class CXXRecordDecl;
|
|
|
|
+class Decl;
|
|
|
|
+class Declarator;
|
|
|
|
+class Expr;
|
|
|
|
+class IdentifierInfo;
|
|
|
|
+class LangOptions;
|
|
|
|
+class NamedDecl;
|
|
|
|
+class NamespaceAliasDecl;
|
|
|
|
+class NamespaceDecl;
|
|
|
|
+class ObjCDeclSpec;
|
|
|
|
+class Sema;
|
|
|
|
+struct TemplateIdAnnotation;
|
|
|
|
+class TypeLoc;
|
|
|
|
|
|
/// \brief Represents a C++ nested-name-specifier or a global scope specifier.
|
|
/// \brief Represents a C++ nested-name-specifier or a global scope specifier.
|
|
///
|
|
///
|
|
@@ -187,11 +198,13 @@ public:
|
|
|
|
|
|
/// No scope specifier.
|
|
/// No scope specifier.
|
|
bool isEmpty() const { return !Range.isValid(); }
|
|
bool isEmpty() const { return !Range.isValid(); }
|
|
|
|
+
|
|
/// A scope specifier is present, but may be valid or invalid.
|
|
/// A scope specifier is present, but may be valid or invalid.
|
|
bool isNotEmpty() const { return !isEmpty(); }
|
|
bool isNotEmpty() const { return !isEmpty(); }
|
|
|
|
|
|
/// An error occurred during parsing of the scope specifier.
|
|
/// An error occurred during parsing of the scope specifier.
|
|
bool isInvalid() const { return isNotEmpty() && getScopeRep() == nullptr; }
|
|
bool isInvalid() const { return isNotEmpty() && getScopeRep() == nullptr; }
|
|
|
|
+
|
|
/// A scope specifier is present, and it refers to a real scope.
|
|
/// A scope specifier is present, and it refers to a real scope.
|
|
bool isValid() const { return isNotEmpty() && getScopeRep() != nullptr; }
|
|
bool isValid() const { return isNotEmpty() && getScopeRep() != nullptr; }
|
|
|
|
|
|
@@ -242,14 +255,14 @@ public:
|
|
|
|
|
|
// Import thread storage class specifier enumeration and constants.
|
|
// Import thread storage class specifier enumeration and constants.
|
|
// These can be combined with SCS_extern and SCS_static.
|
|
// These can be combined with SCS_extern and SCS_static.
|
|
- typedef ThreadStorageClassSpecifier TSCS;
|
|
|
|
|
|
+ using TSCS = ThreadStorageClassSpecifier;
|
|
static const TSCS TSCS_unspecified = clang::TSCS_unspecified;
|
|
static const TSCS TSCS_unspecified = clang::TSCS_unspecified;
|
|
static const TSCS TSCS___thread = clang::TSCS___thread;
|
|
static const TSCS TSCS___thread = clang::TSCS___thread;
|
|
static const TSCS TSCS_thread_local = clang::TSCS_thread_local;
|
|
static const TSCS TSCS_thread_local = clang::TSCS_thread_local;
|
|
static const TSCS TSCS__Thread_local = clang::TSCS__Thread_local;
|
|
static const TSCS TSCS__Thread_local = clang::TSCS__Thread_local;
|
|
|
|
|
|
// Import type specifier width enumeration and constants.
|
|
// Import type specifier width enumeration and constants.
|
|
- typedef TypeSpecifierWidth TSW;
|
|
|
|
|
|
+ using TSW = TypeSpecifierWidth;
|
|
static const TSW TSW_unspecified = clang::TSW_unspecified;
|
|
static const TSW TSW_unspecified = clang::TSW_unspecified;
|
|
static const TSW TSW_short = clang::TSW_short;
|
|
static const TSW TSW_short = clang::TSW_short;
|
|
static const TSW TSW_long = clang::TSW_long;
|
|
static const TSW TSW_long = clang::TSW_long;
|
|
@@ -262,13 +275,13 @@ public:
|
|
};
|
|
};
|
|
|
|
|
|
// Import type specifier sign enumeration and constants.
|
|
// Import type specifier sign enumeration and constants.
|
|
- typedef TypeSpecifierSign TSS;
|
|
|
|
|
|
+ using TSS = TypeSpecifierSign;
|
|
static const TSS TSS_unspecified = clang::TSS_unspecified;
|
|
static const TSS TSS_unspecified = clang::TSS_unspecified;
|
|
static const TSS TSS_signed = clang::TSS_signed;
|
|
static const TSS TSS_signed = clang::TSS_signed;
|
|
static const TSS TSS_unsigned = clang::TSS_unsigned;
|
|
static const TSS TSS_unsigned = clang::TSS_unsigned;
|
|
|
|
|
|
// Import type specifier type enumeration and constants.
|
|
// Import type specifier type enumeration and constants.
|
|
- typedef TypeSpecifierType TST;
|
|
|
|
|
|
+ using TST = TypeSpecifierType;
|
|
static const TST TST_unspecified = clang::TST_unspecified;
|
|
static const TST TST_unspecified = clang::TST_unspecified;
|
|
static const TST TST_void = clang::TST_void;
|
|
static const TST TST_void = clang::TST_void;
|
|
static const TST TST_char = clang::TST_char;
|
|
static const TST TST_char = clang::TST_char;
|
|
@@ -381,11 +394,13 @@ private:
|
|
SourceLocation StorageClassSpecLoc, ThreadStorageClassSpecLoc;
|
|
SourceLocation StorageClassSpecLoc, ThreadStorageClassSpecLoc;
|
|
SourceRange TSWRange;
|
|
SourceRange TSWRange;
|
|
SourceLocation TSCLoc, TSSLoc, TSTLoc, AltiVecLoc;
|
|
SourceLocation TSCLoc, TSSLoc, TSTLoc, AltiVecLoc;
|
|
|
|
+
|
|
/// TSTNameLoc - If TypeSpecType is any of class, enum, struct, union,
|
|
/// TSTNameLoc - If TypeSpecType is any of class, enum, struct, union,
|
|
/// typename, then this is the location of the named type (if present);
|
|
/// typename, then this is the location of the named type (if present);
|
|
/// otherwise, it is the same as TSTLoc. Hence, the pair TSTLoc and
|
|
/// otherwise, it is the same as TSTLoc. Hence, the pair TSTLoc and
|
|
/// TSTNameLoc provides source range info for tag types.
|
|
/// TSTNameLoc provides source range info for tag types.
|
|
SourceLocation TSTNameLoc;
|
|
SourceLocation TSTNameLoc;
|
|
|
|
+
|
|
SourceRange TypeofParensRange;
|
|
SourceRange TypeofParensRange;
|
|
SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc,
|
|
SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc,
|
|
TQ_unalignedLoc;
|
|
TQ_unalignedLoc;
|
|
@@ -395,64 +410,57 @@ private:
|
|
SourceLocation TQ_pipeLoc;
|
|
SourceLocation TQ_pipeLoc;
|
|
|
|
|
|
WrittenBuiltinSpecs writtenBS;
|
|
WrittenBuiltinSpecs writtenBS;
|
|
|
|
+
|
|
void SaveWrittenBuiltinSpecs();
|
|
void SaveWrittenBuiltinSpecs();
|
|
|
|
|
|
- ObjCDeclSpec *ObjCQualifiers;
|
|
|
|
|
|
+ ObjCDeclSpec *ObjCQualifiers = nullptr;
|
|
|
|
|
|
static bool isTypeRep(TST T) {
|
|
static bool isTypeRep(TST T) {
|
|
return (T == TST_typename || T == TST_typeofType ||
|
|
return (T == TST_typename || T == TST_typeofType ||
|
|
T == TST_underlyingType || T == TST_atomic);
|
|
T == TST_underlyingType || T == TST_atomic);
|
|
}
|
|
}
|
|
|
|
+
|
|
static bool isExprRep(TST T) {
|
|
static bool isExprRep(TST T) {
|
|
return (T == TST_typeofExpr || T == TST_decltype);
|
|
return (T == TST_typeofExpr || T == TST_decltype);
|
|
}
|
|
}
|
|
|
|
|
|
- DeclSpec(const DeclSpec &) = delete;
|
|
|
|
- void operator=(const DeclSpec &) = delete;
|
|
|
|
public:
|
|
public:
|
|
|
|
+ DeclSpec(AttributeFactory &attrFactory)
|
|
|
|
+ : StorageClassSpec(SCS_unspecified),
|
|
|
|
+ ThreadStorageClassSpec(TSCS_unspecified),
|
|
|
|
+ SCS_extern_in_linkage_spec(false), TypeSpecWidth(TSW_unspecified),
|
|
|
|
+ TypeSpecComplex(TSC_unspecified), TypeSpecSign(TSS_unspecified),
|
|
|
|
+ TypeSpecType(TST_unspecified), TypeAltiVecVector(false),
|
|
|
|
+ TypeAltiVecPixel(false), TypeAltiVecBool(false), TypeSpecOwned(false),
|
|
|
|
+ TypeSpecPipe(false), TypeQualifiers(TQ_unspecified),
|
|
|
|
+ FS_inline_specified(false), FS_forceinline_specified(false),
|
|
|
|
+ FS_virtual_specified(false), FS_explicit_specified(false),
|
|
|
|
+ FS_noreturn_specified(false), Friend_specified(false),
|
|
|
|
+ Constexpr_specified(false), Attrs(attrFactory) {}
|
|
|
|
+ DeclSpec(const DeclSpec &) = delete;
|
|
|
|
+ DeclSpec &operator=(const DeclSpec &) = delete;
|
|
|
|
+
|
|
static bool isDeclRep(TST T) {
|
|
static bool isDeclRep(TST T) {
|
|
return (T == TST_enum || T == TST_struct ||
|
|
return (T == TST_enum || T == TST_struct ||
|
|
T == TST_interface || T == TST_union ||
|
|
T == TST_interface || T == TST_union ||
|
|
T == TST_class);
|
|
T == TST_class);
|
|
}
|
|
}
|
|
|
|
|
|
- DeclSpec(AttributeFactory &attrFactory)
|
|
|
|
- : StorageClassSpec(SCS_unspecified),
|
|
|
|
- ThreadStorageClassSpec(TSCS_unspecified),
|
|
|
|
- SCS_extern_in_linkage_spec(false),
|
|
|
|
- TypeSpecWidth(TSW_unspecified),
|
|
|
|
- TypeSpecComplex(TSC_unspecified),
|
|
|
|
- TypeSpecSign(TSS_unspecified),
|
|
|
|
- TypeSpecType(TST_unspecified),
|
|
|
|
- TypeAltiVecVector(false),
|
|
|
|
- TypeAltiVecPixel(false),
|
|
|
|
- TypeAltiVecBool(false),
|
|
|
|
- TypeSpecOwned(false),
|
|
|
|
- TypeSpecPipe(false),
|
|
|
|
- TypeQualifiers(TQ_unspecified),
|
|
|
|
- FS_inline_specified(false),
|
|
|
|
- FS_forceinline_specified(false),
|
|
|
|
- FS_virtual_specified(false),
|
|
|
|
- FS_explicit_specified(false),
|
|
|
|
- FS_noreturn_specified(false),
|
|
|
|
- Friend_specified(false),
|
|
|
|
- Constexpr_specified(false),
|
|
|
|
- Attrs(attrFactory),
|
|
|
|
- writtenBS(),
|
|
|
|
- ObjCQualifiers(nullptr) {
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// storage-class-specifier
|
|
// storage-class-specifier
|
|
SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; }
|
|
SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; }
|
|
|
|
+
|
|
TSCS getThreadStorageClassSpec() const {
|
|
TSCS getThreadStorageClassSpec() const {
|
|
return (TSCS)ThreadStorageClassSpec;
|
|
return (TSCS)ThreadStorageClassSpec;
|
|
}
|
|
}
|
|
|
|
+
|
|
bool isExternInLinkageSpec() const { return SCS_extern_in_linkage_spec; }
|
|
bool isExternInLinkageSpec() const { return SCS_extern_in_linkage_spec; }
|
|
|
|
+
|
|
void setExternInLinkageSpec(bool Value) {
|
|
void setExternInLinkageSpec(bool Value) {
|
|
SCS_extern_in_linkage_spec = Value;
|
|
SCS_extern_in_linkage_spec = Value;
|
|
}
|
|
}
|
|
|
|
|
|
SourceLocation getStorageClassSpecLoc() const { return StorageClassSpecLoc; }
|
|
SourceLocation getStorageClassSpecLoc() const { return StorageClassSpecLoc; }
|
|
|
|
+
|
|
SourceLocation getThreadStorageClassSpecLoc() const {
|
|
SourceLocation getThreadStorageClassSpecLoc() const {
|
|
return ThreadStorageClassSpecLoc;
|
|
return ThreadStorageClassSpecLoc;
|
|
}
|
|
}
|
|
@@ -487,14 +495,17 @@ public:
|
|
assert(isTypeRep((TST) TypeSpecType) && "DeclSpec does not store a type");
|
|
assert(isTypeRep((TST) TypeSpecType) && "DeclSpec does not store a type");
|
|
return TypeRep;
|
|
return TypeRep;
|
|
}
|
|
}
|
|
|
|
+
|
|
Decl *getRepAsDecl() const {
|
|
Decl *getRepAsDecl() const {
|
|
assert(isDeclRep((TST) TypeSpecType) && "DeclSpec does not store a decl");
|
|
assert(isDeclRep((TST) TypeSpecType) && "DeclSpec does not store a decl");
|
|
return DeclRep;
|
|
return DeclRep;
|
|
}
|
|
}
|
|
|
|
+
|
|
Expr *getRepAsExpr() const {
|
|
Expr *getRepAsExpr() const {
|
|
assert(isExprRep((TST) TypeSpecType) && "DeclSpec does not store an expr");
|
|
assert(isExprRep((TST) TypeSpecType) && "DeclSpec does not store an expr");
|
|
return ExprRep;
|
|
return ExprRep;
|
|
}
|
|
}
|
|
|
|
+
|
|
CXXScopeSpec &getTypeSpecScope() { return TypeScope; }
|
|
CXXScopeSpec &getTypeSpecScope() { return TypeScope; }
|
|
const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
|
|
const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
|
|
|
|
|
|
@@ -557,9 +568,11 @@ public:
|
|
}
|
|
}
|
|
|
|
|
|
// function-specifier
|
|
// function-specifier
|
|
|
|
+
|
|
bool isInlineSpecified() const {
|
|
bool isInlineSpecified() const {
|
|
return FS_inline_specified | FS_forceinline_specified;
|
|
return FS_inline_specified | FS_forceinline_specified;
|
|
}
|
|
}
|
|
|
|
+
|
|
SourceLocation getInlineSpecLoc() const {
|
|
SourceLocation getInlineSpecLoc() const {
|
|
return FS_inline_specified ? FS_inlineLoc : FS_forceinlineLoc;
|
|
return FS_inline_specified ? FS_inlineLoc : FS_forceinlineLoc;
|
|
}
|
|
}
|
|
@@ -647,7 +660,7 @@ public:
|
|
|
|
|
|
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
|
|
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
|
|
unsigned &DiagID, Expr *Rep,
|
|
unsigned &DiagID, Expr *Rep,
|
|
- const PrintingPolicy &policy);
|
|
|
|
|
|
+ const PrintingPolicy &Policy);
|
|
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
|
|
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
|
|
const char *&PrevSpec, unsigned &DiagID,
|
|
const char *&PrevSpec, unsigned &DiagID,
|
|
const PrintingPolicy &Policy);
|
|
const PrintingPolicy &Policy);
|
|
@@ -661,14 +674,17 @@ public:
|
|
const char *&PrevSpec, unsigned &DiagID,
|
|
const char *&PrevSpec, unsigned &DiagID,
|
|
const PrintingPolicy &Policy);
|
|
const PrintingPolicy &Policy);
|
|
bool SetTypeSpecError();
|
|
bool SetTypeSpecError();
|
|
|
|
+
|
|
void UpdateDeclRep(Decl *Rep) {
|
|
void UpdateDeclRep(Decl *Rep) {
|
|
assert(isDeclRep((TST) TypeSpecType));
|
|
assert(isDeclRep((TST) TypeSpecType));
|
|
DeclRep = Rep;
|
|
DeclRep = Rep;
|
|
}
|
|
}
|
|
|
|
+
|
|
void UpdateTypeRep(ParsedType Rep) {
|
|
void UpdateTypeRep(ParsedType Rep) {
|
|
assert(isTypeRep((TST) TypeSpecType));
|
|
assert(isTypeRep((TST) TypeSpecType));
|
|
TypeRep = Rep;
|
|
TypeRep = Rep;
|
|
}
|
|
}
|
|
|
|
+
|
|
void UpdateExprRep(Expr *Rep) {
|
|
void UpdateExprRep(Expr *Rep) {
|
|
assert(isExprRep((TST) TypeSpecType));
|
|
assert(isExprRep((TST) TypeSpecType));
|
|
ExprRep = Rep;
|
|
ExprRep = Rep;
|
|
@@ -729,7 +745,6 @@ public:
|
|
/// short __attribute__((unused)) __attribute__((deprecated))
|
|
/// short __attribute__((unused)) __attribute__((deprecated))
|
|
/// int __attribute__((may_alias)) __attribute__((aligned(16))) var;
|
|
/// int __attribute__((may_alias)) __attribute__((aligned(16))) var;
|
|
/// \endcode
|
|
/// \endcode
|
|
- ///
|
|
|
|
void addAttributes(AttributeList *AL) {
|
|
void addAttributes(AttributeList *AL) {
|
|
Attrs.addAll(AL);
|
|
Attrs.addAll(AL);
|
|
}
|
|
}
|
|
@@ -804,15 +819,17 @@ public:
|
|
};
|
|
};
|
|
|
|
|
|
ObjCDeclSpec()
|
|
ObjCDeclSpec()
|
|
- : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
|
|
|
|
- Nullability(0), GetterName(nullptr), SetterName(nullptr) { }
|
|
|
|
|
|
+ : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
|
|
|
|
+ Nullability(0) {}
|
|
|
|
|
|
ObjCDeclQualifier getObjCDeclQualifier() const {
|
|
ObjCDeclQualifier getObjCDeclQualifier() const {
|
|
return (ObjCDeclQualifier)objcDeclQualifier;
|
|
return (ObjCDeclQualifier)objcDeclQualifier;
|
|
}
|
|
}
|
|
|
|
+
|
|
void setObjCDeclQualifier(ObjCDeclQualifier DQVal) {
|
|
void setObjCDeclQualifier(ObjCDeclQualifier DQVal) {
|
|
objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal);
|
|
objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal);
|
|
}
|
|
}
|
|
|
|
+
|
|
void clearObjCDeclQualifier(ObjCDeclQualifier DQVal) {
|
|
void clearObjCDeclQualifier(ObjCDeclQualifier DQVal) {
|
|
objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
|
|
objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
|
|
}
|
|
}
|
|
@@ -820,6 +837,7 @@ public:
|
|
ObjCPropertyAttributeKind getPropertyAttributes() const {
|
|
ObjCPropertyAttributeKind getPropertyAttributes() const {
|
|
return ObjCPropertyAttributeKind(PropertyAttributes);
|
|
return ObjCPropertyAttributeKind(PropertyAttributes);
|
|
}
|
|
}
|
|
|
|
+
|
|
void setPropertyAttributes(ObjCPropertyAttributeKind PRVal) {
|
|
void setPropertyAttributes(ObjCPropertyAttributeKind PRVal) {
|
|
PropertyAttributes =
|
|
PropertyAttributes =
|
|
(ObjCPropertyAttributeKind)(PropertyAttributes | PRVal);
|
|
(ObjCPropertyAttributeKind)(PropertyAttributes | PRVal);
|
|
@@ -850,6 +868,7 @@ public:
|
|
const IdentifierInfo *getGetterName() const { return GetterName; }
|
|
const IdentifierInfo *getGetterName() const { return GetterName; }
|
|
IdentifierInfo *getGetterName() { return GetterName; }
|
|
IdentifierInfo *getGetterName() { return GetterName; }
|
|
SourceLocation getGetterNameLoc() const { return GetterNameLoc; }
|
|
SourceLocation getGetterNameLoc() const { return GetterNameLoc; }
|
|
|
|
+
|
|
void setGetterName(IdentifierInfo *name, SourceLocation loc) {
|
|
void setGetterName(IdentifierInfo *name, SourceLocation loc) {
|
|
GetterName = name;
|
|
GetterName = name;
|
|
GetterNameLoc = loc;
|
|
GetterNameLoc = loc;
|
|
@@ -858,6 +877,7 @@ public:
|
|
const IdentifierInfo *getSetterName() const { return SetterName; }
|
|
const IdentifierInfo *getSetterName() const { return SetterName; }
|
|
IdentifierInfo *getSetterName() { return SetterName; }
|
|
IdentifierInfo *getSetterName() { return SetterName; }
|
|
SourceLocation getSetterNameLoc() const { return SetterNameLoc; }
|
|
SourceLocation getSetterNameLoc() const { return SetterNameLoc; }
|
|
|
|
+
|
|
void setSetterName(IdentifierInfo *name, SourceLocation loc) {
|
|
void setSetterName(IdentifierInfo *name, SourceLocation loc) {
|
|
SetterName = name;
|
|
SetterName = name;
|
|
SetterNameLoc = loc;
|
|
SetterNameLoc = loc;
|
|
@@ -876,33 +896,48 @@ private:
|
|
|
|
|
|
SourceLocation NullabilityLoc;
|
|
SourceLocation NullabilityLoc;
|
|
|
|
|
|
- IdentifierInfo *GetterName; // getter name or NULL if no getter
|
|
|
|
- IdentifierInfo *SetterName; // setter name or NULL if no setter
|
|
|
|
- SourceLocation GetterNameLoc; // location of the getter attribute's value
|
|
|
|
- SourceLocation SetterNameLoc; // location of the setter attribute's value
|
|
|
|
|
|
+ // Getter name or nullptr if no getter.
|
|
|
|
+ IdentifierInfo *GetterName = nullptr;
|
|
|
|
|
|
|
|
+ // Setter name or nullptr if no setter.
|
|
|
|
+ IdentifierInfo *SetterName = nullptr;
|
|
|
|
+
|
|
|
|
+ // Location of the getter attribute's value.
|
|
|
|
+ SourceLocation GetterNameLoc;
|
|
|
|
+
|
|
|
|
+ // Location of the setter attribute's value.
|
|
|
|
+ SourceLocation SetterNameLoc;
|
|
};
|
|
};
|
|
|
|
|
|
/// \brief Describes the kind of unqualified-id parsed.
|
|
/// \brief Describes the kind of unqualified-id parsed.
|
|
enum class UnqualifiedIdKind {
|
|
enum class UnqualifiedIdKind {
|
|
/// \brief An identifier.
|
|
/// \brief An identifier.
|
|
IK_Identifier,
|
|
IK_Identifier,
|
|
|
|
+
|
|
/// \brief An overloaded operator name, e.g., operator+.
|
|
/// \brief An overloaded operator name, e.g., operator+.
|
|
IK_OperatorFunctionId,
|
|
IK_OperatorFunctionId,
|
|
|
|
+
|
|
/// \brief A conversion function name, e.g., operator int.
|
|
/// \brief A conversion function name, e.g., operator int.
|
|
IK_ConversionFunctionId,
|
|
IK_ConversionFunctionId,
|
|
|
|
+
|
|
/// \brief A user-defined literal name, e.g., operator "" _i.
|
|
/// \brief A user-defined literal name, e.g., operator "" _i.
|
|
IK_LiteralOperatorId,
|
|
IK_LiteralOperatorId,
|
|
|
|
+
|
|
/// \brief A constructor name.
|
|
/// \brief A constructor name.
|
|
IK_ConstructorName,
|
|
IK_ConstructorName,
|
|
|
|
+
|
|
/// \brief A constructor named via a template-id.
|
|
/// \brief A constructor named via a template-id.
|
|
IK_ConstructorTemplateId,
|
|
IK_ConstructorTemplateId,
|
|
|
|
+
|
|
/// \brief A destructor name.
|
|
/// \brief A destructor name.
|
|
IK_DestructorName,
|
|
IK_DestructorName,
|
|
|
|
+
|
|
/// \brief A template-id, e.g., f<int>.
|
|
/// \brief A template-id, e.g., f<int>.
|
|
IK_TemplateId,
|
|
IK_TemplateId,
|
|
|
|
+
|
|
/// \brief An implicit 'self' parameter
|
|
/// \brief An implicit 'self' parameter
|
|
IK_ImplicitSelfParam,
|
|
IK_ImplicitSelfParam,
|
|
|
|
+
|
|
/// \brief A deduction-guide name (a template-name)
|
|
/// \brief A deduction-guide name (a template-name)
|
|
IK_DeductionGuideName
|
|
IK_DeductionGuideName
|
|
};
|
|
};
|
|
@@ -910,12 +945,9 @@ enum class UnqualifiedIdKind {
|
|
/// \brief Represents a C++ unqualified-id that has been parsed.
|
|
/// \brief Represents a C++ unqualified-id that has been parsed.
|
|
class UnqualifiedId {
|
|
class UnqualifiedId {
|
|
private:
|
|
private:
|
|
- UnqualifiedId(const UnqualifiedId &Other) = delete;
|
|
|
|
- const UnqualifiedId &operator=(const UnqualifiedId &) = delete;
|
|
|
|
-
|
|
|
|
public:
|
|
public:
|
|
/// \brief Describes the kind of unqualified-id parsed.
|
|
/// \brief Describes the kind of unqualified-id parsed.
|
|
- UnqualifiedIdKind Kind;
|
|
|
|
|
|
+ UnqualifiedIdKind Kind = UnqualifiedIdKind::IK_Identifier;
|
|
|
|
|
|
struct OFI {
|
|
struct OFI {
|
|
/// \brief The kind of overloaded operator.
|
|
/// \brief The kind of overloaded operator.
|
|
@@ -971,8 +1003,9 @@ public:
|
|
/// \brief The location of the last token that describes this unqualified-id.
|
|
/// \brief The location of the last token that describes this unqualified-id.
|
|
SourceLocation EndLocation;
|
|
SourceLocation EndLocation;
|
|
|
|
|
|
- UnqualifiedId()
|
|
|
|
- : Kind(UnqualifiedIdKind::IK_Identifier), Identifier(nullptr) {}
|
|
|
|
|
|
+ UnqualifiedId() : Identifier(nullptr) {}
|
|
|
|
+ UnqualifiedId(const UnqualifiedId &Other) = delete;
|
|
|
|
+ UnqualifiedId &operator=(const UnqualifiedId &) = delete;
|
|
|
|
|
|
/// \brief Clear out this unqualified-id, setting it to default (invalid)
|
|
/// \brief Clear out this unqualified-id, setting it to default (invalid)
|
|
/// state.
|
|
/// state.
|
|
@@ -1111,12 +1144,13 @@ public:
|
|
SourceRange getSourceRange() const LLVM_READONLY {
|
|
SourceRange getSourceRange() const LLVM_READONLY {
|
|
return SourceRange(StartLocation, EndLocation);
|
|
return SourceRange(StartLocation, EndLocation);
|
|
}
|
|
}
|
|
|
|
+
|
|
SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; }
|
|
SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; }
|
|
SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; }
|
|
SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; }
|
|
};
|
|
};
|
|
|
|
|
|
/// \brief A set of tokens that has been cached for later parsing.
|
|
/// \brief A set of tokens that has been cached for later parsing.
|
|
-typedef SmallVector<Token, 4> CachedTokens;
|
|
|
|
|
|
+using CachedTokens = SmallVector<Token, 4>;
|
|
|
|
|
|
/// \brief One instance of this struct is used for each type in a
|
|
/// \brief One instance of this struct is used for each type in a
|
|
/// declarator that is parsed.
|
|
/// declarator that is parsed.
|
|
@@ -1129,6 +1163,7 @@ struct DeclaratorChunk {
|
|
|
|
|
|
/// Loc - The place where this type was defined.
|
|
/// Loc - The place where this type was defined.
|
|
SourceLocation Loc;
|
|
SourceLocation Loc;
|
|
|
|
+
|
|
/// EndLoc - If valid, the place where this chunck ends.
|
|
/// EndLoc - If valid, the place where this chunck ends.
|
|
SourceLocation EndLoc;
|
|
SourceLocation EndLoc;
|
|
|
|
|
|
@@ -1161,17 +1196,17 @@ struct DeclaratorChunk {
|
|
/// The location of the __unaligned-qualifier, if any.
|
|
/// The location of the __unaligned-qualifier, if any.
|
|
unsigned UnalignedQualLoc;
|
|
unsigned UnalignedQualLoc;
|
|
|
|
|
|
- void destroy() {
|
|
|
|
- }
|
|
|
|
|
|
+ void destroy() {}
|
|
};
|
|
};
|
|
|
|
|
|
struct ReferenceTypeInfo : TypeInfoCommon {
|
|
struct ReferenceTypeInfo : TypeInfoCommon {
|
|
/// The type qualifier: restrict. [GNU] C++ extension
|
|
/// The type qualifier: restrict. [GNU] C++ extension
|
|
bool HasRestrict : 1;
|
|
bool HasRestrict : 1;
|
|
|
|
+
|
|
/// True if this is an lvalue reference, false if it's an rvalue reference.
|
|
/// True if this is an lvalue reference, false if it's an rvalue reference.
|
|
bool LValueRef : 1;
|
|
bool LValueRef : 1;
|
|
- void destroy() {
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ void destroy() {}
|
|
};
|
|
};
|
|
|
|
|
|
struct ArrayTypeInfo : TypeInfoCommon {
|
|
struct ArrayTypeInfo : TypeInfoCommon {
|
|
@@ -1216,8 +1251,8 @@ struct DeclaratorChunk {
|
|
ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
|
|
ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
|
|
Decl *param,
|
|
Decl *param,
|
|
std::unique_ptr<CachedTokens> DefArgTokens = nullptr)
|
|
std::unique_ptr<CachedTokens> DefArgTokens = nullptr)
|
|
- : Ident(ident), IdentLoc(iloc), Param(param),
|
|
|
|
- DefaultArgTokens(std::move(DefArgTokens)) {}
|
|
|
|
|
|
+ : Ident(ident), IdentLoc(iloc), Param(param),
|
|
|
|
+ DefaultArgTokens(std::move(DefArgTokens)) {}
|
|
};
|
|
};
|
|
|
|
|
|
struct TypeAndRange {
|
|
struct TypeAndRange {
|
|
@@ -1459,32 +1494,33 @@ struct DeclaratorChunk {
|
|
/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
|
|
/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
|
|
unsigned TypeQuals : 5;
|
|
unsigned TypeQuals : 5;
|
|
|
|
|
|
- void destroy() {
|
|
|
|
- }
|
|
|
|
|
|
+ void destroy() {}
|
|
};
|
|
};
|
|
|
|
|
|
struct MemberPointerTypeInfo : TypeInfoCommon {
|
|
struct MemberPointerTypeInfo : TypeInfoCommon {
|
|
/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
|
|
/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
|
|
unsigned TypeQuals : 5;
|
|
unsigned TypeQuals : 5;
|
|
|
|
+
|
|
// CXXScopeSpec has a constructor, so it can't be a direct member.
|
|
// CXXScopeSpec has a constructor, so it can't be a direct member.
|
|
// So we need some pointer-aligned storage and a bit of trickery.
|
|
// So we need some pointer-aligned storage and a bit of trickery.
|
|
alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
|
|
alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
|
|
|
|
+
|
|
CXXScopeSpec &Scope() {
|
|
CXXScopeSpec &Scope() {
|
|
return *reinterpret_cast<CXXScopeSpec *>(ScopeMem);
|
|
return *reinterpret_cast<CXXScopeSpec *>(ScopeMem);
|
|
}
|
|
}
|
|
|
|
+
|
|
const CXXScopeSpec &Scope() const {
|
|
const CXXScopeSpec &Scope() const {
|
|
return *reinterpret_cast<const CXXScopeSpec *>(ScopeMem);
|
|
return *reinterpret_cast<const CXXScopeSpec *>(ScopeMem);
|
|
}
|
|
}
|
|
- void destroy() {
|
|
|
|
- Scope().~CXXScopeSpec();
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ void destroy() { Scope().~CXXScopeSpec(); }
|
|
};
|
|
};
|
|
|
|
|
|
struct PipeTypeInfo : TypeInfoCommon {
|
|
struct PipeTypeInfo : TypeInfoCommon {
|
|
- /// The access writes.
|
|
|
|
- unsigned AccessWrites : 3;
|
|
|
|
|
|
+ /// The access writes.
|
|
|
|
+ unsigned AccessWrites : 3;
|
|
|
|
|
|
- void destroy() {}
|
|
|
|
|
|
+ void destroy() {}
|
|
};
|
|
};
|
|
|
|
|
|
union {
|
|
union {
|
|
@@ -1659,21 +1695,21 @@ public:
|
|
};
|
|
};
|
|
|
|
|
|
private:
|
|
private:
|
|
|
|
+ friend class Declarator;
|
|
|
|
+
|
|
/// The locations of the '[' and ']' tokens.
|
|
/// The locations of the '[' and ']' tokens.
|
|
SourceLocation LSquareLoc, RSquareLoc;
|
|
SourceLocation LSquareLoc, RSquareLoc;
|
|
|
|
|
|
/// The bindings.
|
|
/// The bindings.
|
|
- Binding *Bindings;
|
|
|
|
|
|
+ Binding *Bindings = nullptr;
|
|
unsigned NumBindings : 31;
|
|
unsigned NumBindings : 31;
|
|
unsigned DeleteBindings : 1;
|
|
unsigned DeleteBindings : 1;
|
|
|
|
|
|
- friend class Declarator;
|
|
|
|
-
|
|
|
|
public:
|
|
public:
|
|
- DecompositionDeclarator()
|
|
|
|
- : Bindings(nullptr), NumBindings(0), DeleteBindings(false) {}
|
|
|
|
|
|
+ DecompositionDeclarator() : NumBindings(0), DeleteBindings(false) {}
|
|
DecompositionDeclarator(const DecompositionDeclarator &G) = delete;
|
|
DecompositionDeclarator(const DecompositionDeclarator &G) = delete;
|
|
DecompositionDeclarator &operator=(const DecompositionDeclarator &G) = delete;
|
|
DecompositionDeclarator &operator=(const DecompositionDeclarator &G) = delete;
|
|
|
|
+
|
|
~DecompositionDeclarator() {
|
|
~DecompositionDeclarator() {
|
|
if (DeleteBindings)
|
|
if (DeleteBindings)
|
|
delete[] Bindings;
|
|
delete[] Bindings;
|
|
@@ -1696,6 +1732,7 @@ public:
|
|
|
|
|
|
SourceLocation getLSquareLoc() const { return LSquareLoc; }
|
|
SourceLocation getLSquareLoc() const { return LSquareLoc; }
|
|
SourceLocation getRSquareLoc() const { return RSquareLoc; }
|
|
SourceLocation getRSquareLoc() const { return RSquareLoc; }
|
|
|
|
+
|
|
SourceRange getSourceRange() const {
|
|
SourceRange getSourceRange() const {
|
|
return SourceRange(LSquareLoc, RSquareLoc);
|
|
return SourceRange(LSquareLoc, RSquareLoc);
|
|
}
|
|
}
|
|
@@ -1711,34 +1748,84 @@ enum FunctionDefinitionKind {
|
|
};
|
|
};
|
|
|
|
|
|
enum class DeclaratorContext {
|
|
enum class DeclaratorContext {
|
|
- FileContext, // File scope declaration.
|
|
|
|
- PrototypeContext, // Within a function prototype.
|
|
|
|
- ObjCResultContext, // An ObjC method result type.
|
|
|
|
- ObjCParameterContext,// An ObjC method parameter type.
|
|
|
|
- KNRTypeListContext, // K&R type definition list for formals.
|
|
|
|
- TypeNameContext, // Abstract declarator for types.
|
|
|
|
- FunctionalCastContext, // Type in a C++ functional cast expression.
|
|
|
|
- MemberContext, // Struct/Union field.
|
|
|
|
- BlockContext, // Declaration within a block in a function.
|
|
|
|
- ForContext, // Declaration within first part of a for loop.
|
|
|
|
- InitStmtContext, // Declaration within optional init stmt of if/switch.
|
|
|
|
- ConditionContext, // Condition declaration in a C++ if/switch/while/for.
|
|
|
|
- TemplateParamContext,// Within a template parameter list.
|
|
|
|
- CXXNewContext, // C++ new-expression.
|
|
|
|
- CXXCatchContext, // C++ catch exception-declaration
|
|
|
|
- ObjCCatchContext, // Objective-C catch exception-declaration
|
|
|
|
- BlockLiteralContext, // Block literal declarator.
|
|
|
|
- LambdaExprContext, // Lambda-expression declarator.
|
|
|
|
- LambdaExprParameterContext, // Lambda-expression parameter declarator.
|
|
|
|
- ConversionIdContext, // C++ conversion-type-id.
|
|
|
|
- TrailingReturnContext, // C++11 trailing-type-specifier.
|
|
|
|
- TrailingReturnVarContext, // C++11 trailing-type-specifier for variable.
|
|
|
|
- TemplateArgContext, // Any template argument (in template argument list).
|
|
|
|
- TemplateTypeArgContext, // Template type argument (in default argument).
|
|
|
|
- AliasDeclContext, // C++11 alias-declaration.
|
|
|
|
- AliasTemplateContext // C++11 alias-declaration template.
|
|
|
|
-};
|
|
|
|
|
|
+ // File scope declaration.
|
|
|
|
+ FileContext,
|
|
|
|
+
|
|
|
|
+ // Within a function prototype.
|
|
|
|
+ PrototypeContext,
|
|
|
|
+
|
|
|
|
+ // An ObjC method result type.
|
|
|
|
+ ObjCResultContext,
|
|
|
|
+
|
|
|
|
+ // An ObjC method parameter type.
|
|
|
|
+ ObjCParameterContext,
|
|
|
|
+
|
|
|
|
+ // K&R type definition list for formals.
|
|
|
|
+ KNRTypeListContext,
|
|
|
|
+
|
|
|
|
+ // Abstract declarator for types.
|
|
|
|
+ TypeNameContext,
|
|
|
|
+
|
|
|
|
+ // Type in a C++ functional cast expression.
|
|
|
|
+ FunctionalCastContext,
|
|
|
|
+
|
|
|
|
+ // Struct/Union field.
|
|
|
|
+ MemberContext,
|
|
|
|
+
|
|
|
|
+ // Declaration within a block in a function.
|
|
|
|
+ BlockContext,
|
|
|
|
+
|
|
|
|
+ // Declaration within first part of a for loop.
|
|
|
|
+ ForContext,
|
|
|
|
|
|
|
|
+ // Declaration within optional init stmt of if/switch.
|
|
|
|
+ InitStmtContext,
|
|
|
|
+
|
|
|
|
+ // Condition declaration in a C++ if/switch/while/for.
|
|
|
|
+ ConditionContext,
|
|
|
|
+
|
|
|
|
+ // Within a template parameter list.
|
|
|
|
+ TemplateParamContext,
|
|
|
|
+
|
|
|
|
+ // C++ new-expression.
|
|
|
|
+ CXXNewContext,
|
|
|
|
+
|
|
|
|
+ // C++ catch exception-declaration.
|
|
|
|
+ CXXCatchContext,
|
|
|
|
+
|
|
|
|
+ // Objective-C catch exception-declaration.
|
|
|
|
+ ObjCCatchContext,
|
|
|
|
+
|
|
|
|
+ // Block literal declarator.
|
|
|
|
+ BlockLiteralContext,
|
|
|
|
+
|
|
|
|
+ // Lambda-expression declarator.
|
|
|
|
+ LambdaExprContext,
|
|
|
|
+
|
|
|
|
+ // Lambda-expression parameter declarator.
|
|
|
|
+ LambdaExprParameterContext,
|
|
|
|
+
|
|
|
|
+ // C++ conversion-type-id.
|
|
|
|
+ ConversionIdContext,
|
|
|
|
+
|
|
|
|
+ // C++11 trailing-type-specifier.
|
|
|
|
+ TrailingReturnContext,
|
|
|
|
+
|
|
|
|
+ // C++11 trailing-type-specifier for variable.
|
|
|
|
+ TrailingReturnVarContext,
|
|
|
|
+
|
|
|
|
+ // Any template argument (in template argument list).
|
|
|
|
+ TemplateArgContext,
|
|
|
|
+
|
|
|
|
+ // Template type argument (in default argument).
|
|
|
|
+ TemplateTypeArgContext,
|
|
|
|
+
|
|
|
|
+ // C++11 alias-declaration.
|
|
|
|
+ AliasDeclContext,
|
|
|
|
+
|
|
|
|
+ // C++11 alias-declaration template.
|
|
|
|
+ AliasTemplateContext
|
|
|
|
+};
|
|
|
|
|
|
/// \brief Information about one declarator, including the parsed type
|
|
/// \brief Information about one declarator, including the parsed type
|
|
/// information and the identifier.
|
|
/// information and the identifier.
|
|
@@ -1753,8 +1840,9 @@ enum class DeclaratorContext {
|
|
/// Instances of this class should be a transient object that lives on the
|
|
/// Instances of this class should be a transient object that lives on the
|
|
/// stack, not objects that are allocated in large quantities on the heap.
|
|
/// stack, not objects that are allocated in large quantities on the heap.
|
|
class Declarator {
|
|
class Declarator {
|
|
-
|
|
|
|
private:
|
|
private:
|
|
|
|
+ friend struct DeclaratorChunk;
|
|
|
|
+
|
|
const DeclSpec &DS;
|
|
const DeclSpec &DS;
|
|
CXXScopeSpec SS;
|
|
CXXScopeSpec SS;
|
|
UnqualifiedId Name;
|
|
UnqualifiedId Name;
|
|
@@ -1803,7 +1891,7 @@ private:
|
|
ParsedAttributes Attrs;
|
|
ParsedAttributes Attrs;
|
|
|
|
|
|
/// \brief The asm label, if specified.
|
|
/// \brief The asm label, if specified.
|
|
- Expr *AsmLabel;
|
|
|
|
|
|
+ Expr *AsmLabel = nullptr;
|
|
|
|
|
|
#ifndef _MSC_VER
|
|
#ifndef _MSC_VER
|
|
union {
|
|
union {
|
|
@@ -1825,8 +1913,6 @@ private:
|
|
/// this declarator as a parameter pack.
|
|
/// this declarator as a parameter pack.
|
|
SourceLocation EllipsisLoc;
|
|
SourceLocation EllipsisLoc;
|
|
|
|
|
|
- friend struct DeclaratorChunk;
|
|
|
|
-
|
|
|
|
public:
|
|
public:
|
|
Declarator(const DeclSpec &ds, DeclaratorContext C)
|
|
Declarator(const DeclSpec &ds, DeclaratorContext C)
|
|
: DS(ds), Range(ds.getSourceRange()), Context(C),
|
|
: DS(ds), Range(ds.getSourceRange()), Context(C),
|
|
@@ -1834,11 +1920,12 @@ public:
|
|
GroupingParens(false), FunctionDefinition(FDK_Declaration),
|
|
GroupingParens(false), FunctionDefinition(FDK_Declaration),
|
|
Redeclaration(false), Extension(false), ObjCIvar(false),
|
|
Redeclaration(false), Extension(false), ObjCIvar(false),
|
|
ObjCWeakProperty(false), InlineStorageUsed(false),
|
|
ObjCWeakProperty(false), InlineStorageUsed(false),
|
|
- Attrs(ds.getAttributePool().getFactory()), AsmLabel(nullptr) {}
|
|
|
|
|
|
+ Attrs(ds.getAttributePool().getFactory()) {}
|
|
|
|
|
|
~Declarator() {
|
|
~Declarator() {
|
|
clear();
|
|
clear();
|
|
}
|
|
}
|
|
|
|
+
|
|
/// getDeclSpec - Return the declaration-specifier that this declarator was
|
|
/// getDeclSpec - Return the declaration-specifier that this declarator was
|
|
/// declared with.
|
|
/// declared with.
|
|
const DeclSpec &getDeclSpec() const { return DS; }
|
|
const DeclSpec &getDeclSpec() const { return DS; }
|
|
@@ -1881,17 +1968,20 @@ public:
|
|
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
|
|
SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
|
|
|
|
|
|
void SetSourceRange(SourceRange R) { Range = R; }
|
|
void SetSourceRange(SourceRange R) { Range = R; }
|
|
|
|
+
|
|
/// SetRangeBegin - Set the start of the source range to Loc, unless it's
|
|
/// SetRangeBegin - Set the start of the source range to Loc, unless it's
|
|
/// invalid.
|
|
/// invalid.
|
|
void SetRangeBegin(SourceLocation Loc) {
|
|
void SetRangeBegin(SourceLocation Loc) {
|
|
if (!Loc.isInvalid())
|
|
if (!Loc.isInvalid())
|
|
Range.setBegin(Loc);
|
|
Range.setBegin(Loc);
|
|
}
|
|
}
|
|
|
|
+
|
|
/// SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
|
|
/// SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
|
|
void SetRangeEnd(SourceLocation Loc) {
|
|
void SetRangeEnd(SourceLocation Loc) {
|
|
if (!Loc.isInvalid())
|
|
if (!Loc.isInvalid())
|
|
Range.setEnd(Loc);
|
|
Range.setEnd(Loc);
|
|
}
|
|
}
|
|
|
|
+
|
|
/// ExtendWithDeclSpec - Extend the declarator source range to include the
|
|
/// ExtendWithDeclSpec - Extend the declarator source range to include the
|
|
/// given declspec, unless its location is invalid. Adopts the range start if
|
|
/// given declspec, unless its location is invalid. Adopts the range start if
|
|
/// the current range start is invalid.
|
|
/// the current range start is invalid.
|
|
@@ -1910,8 +2000,8 @@ public:
|
|
Range = DS.getSourceRange();
|
|
Range = DS.getSourceRange();
|
|
BindingGroup.clear();
|
|
BindingGroup.clear();
|
|
|
|
|
|
- for (unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i)
|
|
|
|
- DeclTypeInfo[i].destroy();
|
|
|
|
|
|
+ for (auto &i : DeclTypeInfo)
|
|
|
|
+ i.destroy();
|
|
DeclTypeInfo.clear();
|
|
DeclTypeInfo.clear();
|
|
Attrs.clear();
|
|
Attrs.clear();
|
|
AsmLabel = nullptr;
|
|
AsmLabel = nullptr;
|
|
@@ -2135,8 +2225,7 @@ public:
|
|
|
|
|
|
/// AddTypeInfo - Add a chunk to this declarator. Also extend the range to
|
|
/// AddTypeInfo - Add a chunk to this declarator. Also extend the range to
|
|
/// EndLoc, which should be the last token of the chunk.
|
|
/// EndLoc, which should be the last token of the chunk.
|
|
- void AddTypeInfo(const DeclaratorChunk &TI,
|
|
|
|
- ParsedAttributes &attrs,
|
|
|
|
|
|
+ void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs,
|
|
SourceLocation EndLoc) {
|
|
SourceLocation EndLoc) {
|
|
DeclTypeInfo.push_back(TI);
|
|
DeclTypeInfo.push_back(TI);
|
|
DeclTypeInfo.back().getAttrListRef() = attrs.getList();
|
|
DeclTypeInfo.back().getAttrListRef() = attrs.getList();
|
|
@@ -2165,8 +2254,8 @@ public:
|
|
return DeclTypeInfo[i];
|
|
return DeclTypeInfo[i];
|
|
}
|
|
}
|
|
|
|
|
|
- typedef SmallVectorImpl<DeclaratorChunk>::const_iterator type_object_iterator;
|
|
|
|
- typedef llvm::iterator_range<type_object_iterator> type_object_range;
|
|
|
|
|
|
+ using type_object_iterator = SmallVectorImpl<DeclaratorChunk>::const_iterator;
|
|
|
|
+ using type_object_range = llvm::iterator_range<type_object_iterator>;
|
|
|
|
|
|
/// Returns the range of type objects, from the identifier outwards.
|
|
/// Returns the range of type objects, from the identifier outwards.
|
|
type_object_range type_objects() const {
|
|
type_object_range type_objects() const {
|
|
@@ -2183,9 +2272,9 @@ public:
|
|
/// declarator that is not a parens chunk, or null if there are no
|
|
/// declarator that is not a parens chunk, or null if there are no
|
|
/// non-parens chunks.
|
|
/// non-parens chunks.
|
|
const DeclaratorChunk *getInnermostNonParenChunk() const {
|
|
const DeclaratorChunk *getInnermostNonParenChunk() const {
|
|
- for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
|
|
|
|
- if (!DeclTypeInfo[i].isParen())
|
|
|
|
- return &DeclTypeInfo[i];
|
|
|
|
|
|
+ for (const auto &i : DeclTypeInfo) {
|
|
|
|
+ if (!i.isParen())
|
|
|
|
+ return &i;
|
|
}
|
|
}
|
|
return nullptr;
|
|
return nullptr;
|
|
}
|
|
}
|
|
@@ -2424,6 +2513,7 @@ public:
|
|
bool isObjCWeakProperty() const { return ObjCWeakProperty; }
|
|
bool isObjCWeakProperty() const { return ObjCWeakProperty; }
|
|
|
|
|
|
void setInvalidType(bool Val = true) { InvalidType = Val; }
|
|
void setInvalidType(bool Val = true) { InvalidType = Val; }
|
|
|
|
+
|
|
bool isInvalidType() const {
|
|
bool isInvalidType() const {
|
|
return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;
|
|
return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;
|
|
}
|
|
}
|
|
@@ -2473,10 +2563,10 @@ public:
|
|
/// structure field declarators, which is basically just a bitfield size.
|
|
/// structure field declarators, which is basically just a bitfield size.
|
|
struct FieldDeclarator {
|
|
struct FieldDeclarator {
|
|
Declarator D;
|
|
Declarator D;
|
|
- Expr *BitfieldSize;
|
|
|
|
|
|
+ Expr *BitfieldSize = nullptr;
|
|
|
|
+
|
|
explicit FieldDeclarator(const DeclSpec &DS)
|
|
explicit FieldDeclarator(const DeclSpec &DS)
|
|
- : D(DS, DeclaratorContext::MemberContext),
|
|
|
|
- BitfieldSize(nullptr) {}
|
|
|
|
|
|
+ : D(DS, DeclaratorContext::MemberContext) {}
|
|
};
|
|
};
|
|
|
|
|
|
/// \brief Represents a C++11 virt-specifier-seq.
|
|
/// \brief Represents a C++11 virt-specifier-seq.
|
|
@@ -2491,7 +2581,7 @@ public:
|
|
VS_GNU_Final = 8
|
|
VS_GNU_Final = 8
|
|
};
|
|
};
|
|
|
|
|
|
- VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { }
|
|
|
|
|
|
+ VirtSpecifiers() = default;
|
|
|
|
|
|
bool SetSpecifier(Specifier VS, SourceLocation Loc,
|
|
bool SetSpecifier(Specifier VS, SourceLocation Loc,
|
|
const char *&PrevSpec);
|
|
const char *&PrevSpec);
|
|
@@ -2514,8 +2604,8 @@ public:
|
|
Specifier getLastSpecifier() const { return LastSpecifier; }
|
|
Specifier getLastSpecifier() const { return LastSpecifier; }
|
|
|
|
|
|
private:
|
|
private:
|
|
- unsigned Specifiers;
|
|
|
|
- Specifier LastSpecifier;
|
|
|
|
|
|
+ unsigned Specifiers = 0;
|
|
|
|
+ Specifier LastSpecifier = VS_None;
|
|
|
|
|
|
SourceLocation VS_overrideLoc, VS_finalLoc;
|
|
SourceLocation VS_overrideLoc, VS_finalLoc;
|
|
SourceLocation FirstLocation;
|
|
SourceLocation FirstLocation;
|
|
@@ -2540,6 +2630,7 @@ struct LambdaIntroducer {
|
|
LambdaCaptureInitKind InitKind;
|
|
LambdaCaptureInitKind InitKind;
|
|
ExprResult Init;
|
|
ExprResult Init;
|
|
ParsedType InitCaptureType;
|
|
ParsedType InitCaptureType;
|
|
|
|
+
|
|
LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc,
|
|
LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc,
|
|
IdentifierInfo *Id, SourceLocation EllipsisLoc,
|
|
IdentifierInfo *Id, SourceLocation EllipsisLoc,
|
|
LambdaCaptureInitKind InitKind, ExprResult Init,
|
|
LambdaCaptureInitKind InitKind, ExprResult Init,
|
|
@@ -2550,11 +2641,10 @@ struct LambdaIntroducer {
|
|
|
|
|
|
SourceRange Range;
|
|
SourceRange Range;
|
|
SourceLocation DefaultLoc;
|
|
SourceLocation DefaultLoc;
|
|
- LambdaCaptureDefault Default;
|
|
|
|
|
|
+ LambdaCaptureDefault Default = LCD_None;
|
|
SmallVector<LambdaCapture, 4> Captures;
|
|
SmallVector<LambdaCapture, 4> Captures;
|
|
|
|
|
|
- LambdaIntroducer()
|
|
|
|
- : Default(LCD_None) {}
|
|
|
|
|
|
+ LambdaIntroducer() = default;
|
|
|
|
|
|
/// \brief Append a capture in a lambda introducer.
|
|
/// \brief Append a capture in a lambda introducer.
|
|
void addCapture(LambdaCaptureKind Kind,
|
|
void addCapture(LambdaCaptureKind Kind,
|
|
@@ -2569,6 +2659,6 @@ struct LambdaIntroducer {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-} // end namespace clang
|
|
|
|
|
|
+} // namespace clang
|
|
|
|
|
|
#endif // LLVM_CLANG_SEMA_DECLSPEC_H
|
|
#endif // LLVM_CLANG_SEMA_DECLSPEC_H
|