diff options
Diffstat (limited to 'include/clang/Sema/DeclSpec.h')
-rw-r--r-- | include/clang/Sema/DeclSpec.h | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 8d6f0bc9148b..b417f89c0e5b 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -1,9 +1,8 @@ //===--- DeclSpec.h - Parsed declaration specifiers -------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// @@ -23,6 +22,7 @@ #ifndef LLVM_CLANG_SEMA_DECLSPEC_H #define LLVM_CLANG_SEMA_DECLSPEC_H +#include "clang/AST/DeclCXX.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/Basic/ExceptionSpecificationType.h" #include "clang/Basic/Lambda.h" @@ -357,14 +357,13 @@ private: unsigned FS_inline_specified : 1; unsigned FS_forceinline_specified: 1; unsigned FS_virtual_specified : 1; - unsigned FS_explicit_specified : 1; unsigned FS_noreturn_specified : 1; // friend-specifier unsigned Friend_specified : 1; // constexpr-specifier - unsigned Constexpr_specified : 1; + unsigned ConstexprSpecifier : 2; union { UnionParsedType TypeRep; @@ -372,6 +371,9 @@ private: Expr *ExprRep; }; + /// ExplicitSpecifier - Store information about explicit spicifer. + ExplicitSpecifier FS_explicit_specifier; + // attributes. ParsedAttributes Attrs; @@ -394,6 +396,7 @@ private: SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc, TQ_unalignedLoc; SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc, FS_noreturnLoc; + SourceLocation FS_explicitCloseParenLoc; SourceLocation FS_forceinlineLoc; SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc; SourceLocation TQ_pipeLoc; @@ -421,31 +424,18 @@ 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), - TypeSpecSat(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) { - } + : 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), TypeSpecSat(false), TypeQualifiers(TQ_unspecified), + FS_inline_specified(false), FS_forceinline_specified(false), + FS_virtual_specified(false), FS_noreturn_specified(false), + Friend_specified(false), ConstexprSpecifier(CSK_unspecified), + FS_explicit_specifier(), Attrs(attrFactory), writtenBS(), + ObjCQualifiers(nullptr) {} // storage-class-specifier SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; } @@ -540,6 +530,7 @@ public: static const char *getSpecifierName(DeclSpec::TSW W); static const char *getSpecifierName(DeclSpec::SCS S); static const char *getSpecifierName(DeclSpec::TSCS S); + static const char *getSpecifierName(ConstexprSpecKind C); // type-qualifiers @@ -571,11 +562,22 @@ public: return FS_inline_specified ? FS_inlineLoc : FS_forceinlineLoc; } + ExplicitSpecifier getExplicitSpecifier() const { + return FS_explicit_specifier; + } + bool isVirtualSpecified() const { return FS_virtual_specified; } SourceLocation getVirtualSpecLoc() const { return FS_virtualLoc; } - bool isExplicitSpecified() const { return FS_explicit_specified; } + bool hasExplicitSpecifier() const { + return FS_explicit_specifier.isSpecified(); + } SourceLocation getExplicitSpecLoc() const { return FS_explicitLoc; } + SourceRange getExplicitSpecRange() const { + return FS_explicit_specifier.getExpr() + ? SourceRange(FS_explicitLoc, FS_explicitCloseParenLoc) + : SourceRange(FS_explicitLoc); + } bool isNoreturnSpecified() const { return FS_noreturn_specified; } SourceLocation getNoreturnSpecLoc() const { return FS_noreturnLoc; } @@ -587,8 +589,9 @@ public: FS_forceinlineLoc = SourceLocation(); FS_virtual_specified = false; FS_virtualLoc = SourceLocation(); - FS_explicit_specified = false; + FS_explicit_specifier = ExplicitSpecifier(); FS_explicitLoc = SourceLocation(); + FS_explicitCloseParenLoc = SourceLocation(); FS_noreturn_specified = false; FS_noreturnLoc = SourceLocation(); } @@ -707,7 +710,8 @@ public: bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID); + unsigned &DiagID, ExplicitSpecifier ExplicitSpec, + SourceLocation CloseParenLoc); bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); @@ -715,8 +719,8 @@ public: unsigned &DiagID); bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); - bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID); + bool SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, + const char *&PrevSpec, unsigned &DiagID); bool isFriendSpecified() const { return Friend_specified; } SourceLocation getFriendSpecLoc() const { return FriendLoc; } @@ -724,11 +728,17 @@ public: bool isModulePrivateSpecified() const { return ModulePrivateLoc.isValid(); } SourceLocation getModulePrivateSpecLoc() const { return ModulePrivateLoc; } - bool isConstexprSpecified() const { return Constexpr_specified; } + ConstexprSpecKind getConstexprSpecifier() const { + return ConstexprSpecKind(ConstexprSpecifier); + } + SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; } + bool hasConstexprSpecifier() const { + return ConstexprSpecifier != CSK_unspecified; + } void ClearConstexprSpec() { - Constexpr_specified = false; + ConstexprSpecifier = CSK_unspecified; ConstexprLoc = SourceLocation(); } |