1 //===--- DeclSpec.cpp - Declaration Specifier Semantic Analysis -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements semantic analysis for declaration specifiers.
12 //===----------------------------------------------------------------------===//
14 #include "clang/Sema/DeclSpec.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/DeclCXX.h"
17 #include "clang/AST/Expr.h"
18 #include "clang/AST/LocInfoType.h"
19 #include "clang/AST/TypeLoc.h"
20 #include "clang/Basic/LangOptions.h"
21 #include "clang/Basic/TargetInfo.h"
22 #include "clang/Sema/ParsedTemplate.h"
23 #include "clang/Sema/Sema.h"
24 #include "clang/Sema/SemaDiagnostic.h"
25 #include "llvm/ADT/STLExtras.h"
26 #include "llvm/ADT/SmallString.h"
28 using namespace clang;
31 void UnqualifiedId::setTemplateId(TemplateIdAnnotation *TemplateId) {
32 assert(TemplateId && "NULL template-id annotation?");
34 this->TemplateId = TemplateId;
35 StartLocation = TemplateId->TemplateNameLoc;
36 EndLocation = TemplateId->RAngleLoc;
39 void UnqualifiedId::setConstructorTemplateId(TemplateIdAnnotation *TemplateId) {
40 assert(TemplateId && "NULL template-id annotation?");
41 Kind = IK_ConstructorTemplateId;
42 this->TemplateId = TemplateId;
43 StartLocation = TemplateId->TemplateNameLoc;
44 EndLocation = TemplateId->RAngleLoc;
47 void CXXScopeSpec::Extend(ASTContext &Context, SourceLocation TemplateKWLoc,
48 TypeLoc TL, SourceLocation ColonColonLoc) {
49 Builder.Extend(Context, TemplateKWLoc, TL, ColonColonLoc);
50 if (Range.getBegin().isInvalid())
51 Range.setBegin(TL.getBeginLoc());
52 Range.setEnd(ColonColonLoc);
54 assert(Range == Builder.getSourceRange() &&
55 "NestedNameSpecifierLoc range computation incorrect");
58 void CXXScopeSpec::Extend(ASTContext &Context, IdentifierInfo *Identifier,
59 SourceLocation IdentifierLoc,
60 SourceLocation ColonColonLoc) {
61 Builder.Extend(Context, Identifier, IdentifierLoc, ColonColonLoc);
63 if (Range.getBegin().isInvalid())
64 Range.setBegin(IdentifierLoc);
65 Range.setEnd(ColonColonLoc);
67 assert(Range == Builder.getSourceRange() &&
68 "NestedNameSpecifierLoc range computation incorrect");
71 void CXXScopeSpec::Extend(ASTContext &Context, NamespaceDecl *Namespace,
72 SourceLocation NamespaceLoc,
73 SourceLocation ColonColonLoc) {
74 Builder.Extend(Context, Namespace, NamespaceLoc, ColonColonLoc);
76 if (Range.getBegin().isInvalid())
77 Range.setBegin(NamespaceLoc);
78 Range.setEnd(ColonColonLoc);
80 assert(Range == Builder.getSourceRange() &&
81 "NestedNameSpecifierLoc range computation incorrect");
84 void CXXScopeSpec::Extend(ASTContext &Context, NamespaceAliasDecl *Alias,
85 SourceLocation AliasLoc,
86 SourceLocation ColonColonLoc) {
87 Builder.Extend(Context, Alias, AliasLoc, ColonColonLoc);
89 if (Range.getBegin().isInvalid())
90 Range.setBegin(AliasLoc);
91 Range.setEnd(ColonColonLoc);
93 assert(Range == Builder.getSourceRange() &&
94 "NestedNameSpecifierLoc range computation incorrect");
97 void CXXScopeSpec::MakeGlobal(ASTContext &Context,
98 SourceLocation ColonColonLoc) {
99 Builder.MakeGlobal(Context, ColonColonLoc);
101 Range = SourceRange(ColonColonLoc);
103 assert(Range == Builder.getSourceRange() &&
104 "NestedNameSpecifierLoc range computation incorrect");
107 void CXXScopeSpec::MakeSuper(ASTContext &Context, CXXRecordDecl *RD,
108 SourceLocation SuperLoc,
109 SourceLocation ColonColonLoc) {
110 Builder.MakeSuper(Context, RD, SuperLoc, ColonColonLoc);
112 Range.setBegin(SuperLoc);
113 Range.setEnd(ColonColonLoc);
115 assert(Range == Builder.getSourceRange() &&
116 "NestedNameSpecifierLoc range computation incorrect");
119 void CXXScopeSpec::MakeTrivial(ASTContext &Context,
120 NestedNameSpecifier *Qualifier, SourceRange R) {
121 Builder.MakeTrivial(Context, Qualifier, R);
125 void CXXScopeSpec::Adopt(NestedNameSpecifierLoc Other) {
127 Range = SourceRange();
132 Range = Other.getSourceRange();
133 Builder.Adopt(Other);
136 SourceLocation CXXScopeSpec::getLastQualifierNameLoc() const {
137 if (!Builder.getRepresentation())
138 return SourceLocation();
139 return Builder.getTemporary().getLocalBeginLoc();
142 NestedNameSpecifierLoc
143 CXXScopeSpec::getWithLocInContext(ASTContext &Context) const {
144 if (!Builder.getRepresentation())
145 return NestedNameSpecifierLoc();
147 return Builder.getWithLocInContext(Context);
150 /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
151 /// "TheDeclarator" is the declarator that this will be added to.
152 DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto,
154 SourceLocation LParenLoc,
157 SourceLocation EllipsisLoc,
158 SourceLocation RParenLoc,
160 bool RefQualifierIsLvalueRef,
161 SourceLocation RefQualifierLoc,
162 SourceLocation ConstQualifierLoc,
164 VolatileQualifierLoc,
166 RestrictQualifierLoc,
167 SourceLocation MutableLoc,
168 ExceptionSpecificationType
170 SourceRange ESpecRange,
171 ParsedType *Exceptions,
172 SourceRange *ExceptionRanges,
173 unsigned NumExceptions,
175 CachedTokens *ExceptionSpecTokens,
178 SourceLocation LocalRangeBegin,
179 SourceLocation LocalRangeEnd,
180 Declarator &TheDeclarator,
181 TypeResult TrailingReturnType) {
182 assert(!(TypeQuals & DeclSpec::TQ_atomic) &&
183 "function cannot have _Atomic qualifier");
187 I.Loc = LocalRangeBegin;
188 I.EndLoc = LocalRangeEnd;
189 I.Fun.AttrList = nullptr;
190 I.Fun.hasPrototype = hasProto;
191 I.Fun.isVariadic = EllipsisLoc.isValid();
192 I.Fun.isAmbiguous = isAmbiguous;
193 I.Fun.LParenLoc = LParenLoc.getRawEncoding();
194 I.Fun.EllipsisLoc = EllipsisLoc.getRawEncoding();
195 I.Fun.RParenLoc = RParenLoc.getRawEncoding();
196 I.Fun.DeleteParams = false;
197 I.Fun.TypeQuals = TypeQuals;
198 I.Fun.NumParams = NumParams;
199 I.Fun.Params = nullptr;
200 I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef;
201 I.Fun.RefQualifierLoc = RefQualifierLoc.getRawEncoding();
202 I.Fun.ConstQualifierLoc = ConstQualifierLoc.getRawEncoding();
203 I.Fun.VolatileQualifierLoc = VolatileQualifierLoc.getRawEncoding();
204 I.Fun.RestrictQualifierLoc = RestrictQualifierLoc.getRawEncoding();
205 I.Fun.MutableLoc = MutableLoc.getRawEncoding();
206 I.Fun.ExceptionSpecType = ESpecType;
207 I.Fun.ExceptionSpecLocBeg = ESpecRange.getBegin().getRawEncoding();
208 I.Fun.ExceptionSpecLocEnd = ESpecRange.getEnd().getRawEncoding();
209 I.Fun.NumExceptionsOrDecls = 0;
210 I.Fun.Exceptions = nullptr;
211 I.Fun.NoexceptExpr = nullptr;
212 I.Fun.HasTrailingReturnType = TrailingReturnType.isUsable() ||
213 TrailingReturnType.isInvalid();
214 I.Fun.TrailingReturnType = TrailingReturnType.get();
216 assert(I.Fun.TypeQuals == TypeQuals && "bitfield overflow");
217 assert(I.Fun.ExceptionSpecType == ESpecType && "bitfield overflow");
219 // new[] a parameter array if needed.
221 // If the 'InlineParams' in Declarator is unused and big enough, put our
222 // parameter list there (in an effort to avoid new/delete traffic). If it
223 // is already used (consider a function returning a function pointer) or too
224 // small (function with too many parameters), go to the heap.
225 if (!TheDeclarator.InlineStorageUsed &&
226 NumParams <= llvm::array_lengthof(TheDeclarator.InlineParams)) {
227 I.Fun.Params = TheDeclarator.InlineParams;
228 new (I.Fun.Params) ParamInfo[NumParams];
229 I.Fun.DeleteParams = false;
230 TheDeclarator.InlineStorageUsed = true;
232 I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams];
233 I.Fun.DeleteParams = true;
235 for (unsigned i = 0; i < NumParams; i++)
236 I.Fun.Params[i] = std::move(Params[i]);
239 // Check what exception specification information we should actually store.
241 default: break; // By default, save nothing.
243 // new[] an exception array if needed
245 I.Fun.NumExceptionsOrDecls = NumExceptions;
246 I.Fun.Exceptions = new DeclaratorChunk::TypeAndRange[NumExceptions];
247 for (unsigned i = 0; i != NumExceptions; ++i) {
248 I.Fun.Exceptions[i].Ty = Exceptions[i];
249 I.Fun.Exceptions[i].Range = ExceptionRanges[i];
254 case EST_ComputedNoexcept:
255 I.Fun.NoexceptExpr = NoexceptExpr;
259 I.Fun.ExceptionSpecTokens = ExceptionSpecTokens;
263 if (!DeclsInPrototype.empty()) {
264 assert(ESpecType == EST_None && NumExceptions == 0 &&
265 "cannot have exception specifiers and decls in prototype");
266 I.Fun.NumExceptionsOrDecls = DeclsInPrototype.size();
267 // Copy the array of decls into stable heap storage.
268 I.Fun.DeclsInPrototype = new NamedDecl *[DeclsInPrototype.size()];
269 for (size_t J = 0; J < DeclsInPrototype.size(); ++J)
270 I.Fun.DeclsInPrototype[J] = DeclsInPrototype[J];
276 void Declarator::setDecompositionBindings(
277 SourceLocation LSquareLoc,
278 ArrayRef<DecompositionDeclarator::Binding> Bindings,
279 SourceLocation RSquareLoc) {
280 assert(!hasName() && "declarator given multiple names!");
282 BindingGroup.LSquareLoc = LSquareLoc;
283 BindingGroup.RSquareLoc = RSquareLoc;
284 BindingGroup.NumBindings = Bindings.size();
285 Range.setEnd(RSquareLoc);
287 // We're now past the identifier.
288 SetIdentifier(nullptr, LSquareLoc);
289 Name.EndLocation = RSquareLoc;
291 // Allocate storage for bindings and stash them away.
292 if (Bindings.size()) {
293 if (!InlineStorageUsed &&
294 Bindings.size() <= llvm::array_lengthof(InlineBindings)) {
295 BindingGroup.Bindings = InlineBindings;
296 BindingGroup.DeleteBindings = false;
297 InlineStorageUsed = true;
299 BindingGroup.Bindings =
300 new DecompositionDeclarator::Binding[Bindings.size()];
301 BindingGroup.DeleteBindings = true;
303 std::uninitialized_copy(Bindings.begin(), Bindings.end(),
304 BindingGroup.Bindings);
308 bool Declarator::isDeclarationOfFunction() const {
309 for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
310 switch (DeclTypeInfo[i].Kind) {
311 case DeclaratorChunk::Function:
313 case DeclaratorChunk::Paren:
315 case DeclaratorChunk::Pointer:
316 case DeclaratorChunk::Reference:
317 case DeclaratorChunk::Array:
318 case DeclaratorChunk::BlockPointer:
319 case DeclaratorChunk::MemberPointer:
320 case DeclaratorChunk::Pipe:
323 llvm_unreachable("Invalid type chunk");
326 switch (DS.getTypeSpecType()) {
349 case TST_unknown_anytype:
350 case TST_unspecified:
353 #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
354 #include "clang/Basic/OpenCLImageTypes.def"
357 case TST_decltype_auto:
358 // This must have an initializer, so can't be a function declaration,
359 // even if the initializer has function type.
364 if (Expr *E = DS.getRepAsExpr())
365 return E->getType()->isFunctionType();
368 case TST_underlyingType:
370 case TST_typeofType: {
371 QualType QT = DS.getRepAsType().get();
375 if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT))
381 return QT->isFunctionType();
385 llvm_unreachable("Invalid TypeSpecType!");
388 bool Declarator::isStaticMember() {
389 assert(getContext() == MemberContext);
390 return getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
391 (getName().Kind == UnqualifiedId::IK_OperatorFunctionId &&
392 CXXMethodDecl::isStaticOverloadedOperator(
393 getName().OperatorFunctionId.Operator));
396 bool Declarator::isCtorOrDtor() {
397 return (getName().getKind() == UnqualifiedId::IK_ConstructorName) ||
398 (getName().getKind() == UnqualifiedId::IK_DestructorName);
401 bool DeclSpec::hasTagDefinition() const {
404 return cast<TagDecl>(getRepAsDecl())->isCompleteDefinition();
407 /// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
408 /// declaration specifier includes.
410 unsigned DeclSpec::getParsedSpecifiers() const {
412 if (StorageClassSpec != SCS_unspecified ||
413 ThreadStorageClassSpec != TSCS_unspecified)
414 Res |= PQ_StorageClassSpecifier;
416 if (TypeQualifiers != TQ_unspecified)
417 Res |= PQ_TypeQualifier;
419 if (hasTypeSpecifier())
420 Res |= PQ_TypeSpecifier;
422 if (FS_inline_specified || FS_virtual_specified || FS_explicit_specified ||
423 FS_noreturn_specified || FS_forceinline_specified)
424 Res |= PQ_FunctionSpecifier;
428 template <class T> static bool BadSpecifier(T TNew, T TPrev,
429 const char *&PrevSpec,
431 bool IsExtension = true) {
432 PrevSpec = DeclSpec::getSpecifierName(TPrev);
434 DiagID = diag::err_invalid_decl_spec_combination;
436 DiagID = IsExtension ? diag::ext_duplicate_declspec :
437 diag::warn_duplicate_declspec;
441 const char *DeclSpec::getSpecifierName(DeclSpec::SCS S) {
443 case DeclSpec::SCS_unspecified: return "unspecified";
444 case DeclSpec::SCS_typedef: return "typedef";
445 case DeclSpec::SCS_extern: return "extern";
446 case DeclSpec::SCS_static: return "static";
447 case DeclSpec::SCS_auto: return "auto";
448 case DeclSpec::SCS_register: return "register";
449 case DeclSpec::SCS_private_extern: return "__private_extern__";
450 case DeclSpec::SCS_mutable: return "mutable";
452 llvm_unreachable("Unknown typespec!");
455 const char *DeclSpec::getSpecifierName(DeclSpec::TSCS S) {
457 case DeclSpec::TSCS_unspecified: return "unspecified";
458 case DeclSpec::TSCS___thread: return "__thread";
459 case DeclSpec::TSCS_thread_local: return "thread_local";
460 case DeclSpec::TSCS__Thread_local: return "_Thread_local";
462 llvm_unreachable("Unknown typespec!");
465 const char *DeclSpec::getSpecifierName(TSW W) {
467 case TSW_unspecified: return "unspecified";
468 case TSW_short: return "short";
469 case TSW_long: return "long";
470 case TSW_longlong: return "long long";
472 llvm_unreachable("Unknown typespec!");
475 const char *DeclSpec::getSpecifierName(TSC C) {
477 case TSC_unspecified: return "unspecified";
478 case TSC_imaginary: return "imaginary";
479 case TSC_complex: return "complex";
481 llvm_unreachable("Unknown typespec!");
485 const char *DeclSpec::getSpecifierName(TSS S) {
487 case TSS_unspecified: return "unspecified";
488 case TSS_signed: return "signed";
489 case TSS_unsigned: return "unsigned";
491 llvm_unreachable("Unknown typespec!");
494 const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
495 const PrintingPolicy &Policy) {
497 case DeclSpec::TST_unspecified: return "unspecified";
498 case DeclSpec::TST_void: return "void";
499 case DeclSpec::TST_char: return "char";
500 case DeclSpec::TST_wchar: return Policy.MSWChar ? "__wchar_t" : "wchar_t";
501 case DeclSpec::TST_char16: return "char16_t";
502 case DeclSpec::TST_char32: return "char32_t";
503 case DeclSpec::TST_int: return "int";
504 case DeclSpec::TST_int128: return "__int128";
505 case DeclSpec::TST_half: return "half";
506 case DeclSpec::TST_float: return "float";
507 case DeclSpec::TST_double: return "double";
508 case DeclSpec::TST_float128: return "__float128";
509 case DeclSpec::TST_bool: return Policy.Bool ? "bool" : "_Bool";
510 case DeclSpec::TST_decimal32: return "_Decimal32";
511 case DeclSpec::TST_decimal64: return "_Decimal64";
512 case DeclSpec::TST_decimal128: return "_Decimal128";
513 case DeclSpec::TST_enum: return "enum";
514 case DeclSpec::TST_class: return "class";
515 case DeclSpec::TST_union: return "union";
516 case DeclSpec::TST_struct: return "struct";
517 case DeclSpec::TST_interface: return "__interface";
518 case DeclSpec::TST_typename: return "type-name";
519 case DeclSpec::TST_typeofType:
520 case DeclSpec::TST_typeofExpr: return "typeof";
521 case DeclSpec::TST_auto: return "auto";
522 case DeclSpec::TST_auto_type: return "__auto_type";
523 case DeclSpec::TST_decltype: return "(decltype)";
524 case DeclSpec::TST_decltype_auto: return "decltype(auto)";
525 case DeclSpec::TST_underlyingType: return "__underlying_type";
526 case DeclSpec::TST_unknown_anytype: return "__unknown_anytype";
527 case DeclSpec::TST_atomic: return "_Atomic";
528 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
529 case DeclSpec::TST_##ImgType##_t: \
530 return #ImgType "_t";
531 #include "clang/Basic/OpenCLImageTypes.def"
532 case DeclSpec::TST_error: return "(error)";
534 llvm_unreachable("Unknown typespec!");
537 const char *DeclSpec::getSpecifierName(TQ T) {
539 case DeclSpec::TQ_unspecified: return "unspecified";
540 case DeclSpec::TQ_const: return "const";
541 case DeclSpec::TQ_restrict: return "restrict";
542 case DeclSpec::TQ_volatile: return "volatile";
543 case DeclSpec::TQ_atomic: return "_Atomic";
544 case DeclSpec::TQ_unaligned: return "__unaligned";
546 llvm_unreachable("Unknown typespec!");
549 bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
550 const char *&PrevSpec,
552 const PrintingPolicy &Policy) {
553 // OpenCL v1.1 s6.8g: "The extern, static, auto and register storage-class
554 // specifiers are not supported.
555 // It seems sensible to prohibit private_extern too
556 // The cl_clang_storage_class_specifiers extension enables support for
557 // these storage-class specifiers.
558 // OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
559 // specifiers are not supported."
560 if (S.getLangOpts().OpenCL &&
561 !S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) {
564 case SCS_private_extern:
566 if (S.getLangOpts().OpenCLVersion < 120) {
567 DiagID = diag::err_opencl_unknown_type_specifier;
568 PrevSpec = getSpecifierName(SC);
574 DiagID = diag::err_opencl_unknown_type_specifier;
575 PrevSpec = getSpecifierName(SC);
582 if (StorageClassSpec != SCS_unspecified) {
583 // Maybe this is an attempt to use C++11 'auto' outside of C++11 mode.
584 bool isInvalid = true;
585 if (TypeSpecType == TST_unspecified && S.getLangOpts().CPlusPlus) {
587 return SetTypeSpecType(TST_auto, Loc, PrevSpec, DiagID, Policy);
588 if (StorageClassSpec == SCS_auto) {
589 isInvalid = SetTypeSpecType(TST_auto, StorageClassSpecLoc,
590 PrevSpec, DiagID, Policy);
591 assert(!isInvalid && "auto SCS -> TST recovery failed");
595 // Changing storage class is allowed only if the previous one
596 // was the 'extern' that is part of a linkage specification and
597 // the new storage class is 'typedef'.
599 !(SCS_extern_in_linkage_spec &&
600 StorageClassSpec == SCS_extern &&
602 return BadSpecifier(SC, (SCS)StorageClassSpec, PrevSpec, DiagID);
604 StorageClassSpec = SC;
605 StorageClassSpecLoc = Loc;
606 assert((unsigned)SC == StorageClassSpec && "SCS constants overflow bitfield");
610 bool DeclSpec::SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc,
611 const char *&PrevSpec,
613 if (ThreadStorageClassSpec != TSCS_unspecified)
614 return BadSpecifier(TSC, (TSCS)ThreadStorageClassSpec, PrevSpec, DiagID);
616 ThreadStorageClassSpec = TSC;
617 ThreadStorageClassSpecLoc = Loc;
621 /// These methods set the specified attribute of the DeclSpec, but return true
622 /// and ignore the request if invalid (e.g. "extern" then "auto" is
624 bool DeclSpec::SetTypeSpecWidth(TSW W, SourceLocation Loc,
625 const char *&PrevSpec,
627 const PrintingPolicy &Policy) {
628 // Overwrite TSWRange.Begin only if TypeSpecWidth was unspecified, so that
629 // for 'long long' we will keep the source location of the first 'long'.
630 if (TypeSpecWidth == TSW_unspecified)
631 TSWRange.setBegin(Loc);
632 // Allow turning long -> long long.
633 else if (W != TSW_longlong || TypeSpecWidth != TSW_long)
634 return BadSpecifier(W, (TSW)TypeSpecWidth, PrevSpec, DiagID);
636 // Remember location of the last 'long'
637 TSWRange.setEnd(Loc);
641 bool DeclSpec::SetTypeSpecComplex(TSC C, SourceLocation Loc,
642 const char *&PrevSpec,
644 if (TypeSpecComplex != TSC_unspecified)
645 return BadSpecifier(C, (TSC)TypeSpecComplex, PrevSpec, DiagID);
651 bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc,
652 const char *&PrevSpec,
654 if (TypeSpecSign != TSS_unspecified)
655 return BadSpecifier(S, (TSS)TypeSpecSign, PrevSpec, DiagID);
661 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
662 const char *&PrevSpec,
665 const PrintingPolicy &Policy) {
666 return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Policy);
669 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc,
670 SourceLocation TagNameLoc,
671 const char *&PrevSpec,
674 const PrintingPolicy &Policy) {
675 assert(isTypeRep(T) && "T does not store a type");
676 assert(Rep && "no type provided!");
677 if (TypeSpecType != TST_unspecified) {
678 PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
679 DiagID = diag::err_invalid_decl_spec_combination;
685 TSTNameLoc = TagNameLoc;
686 TypeSpecOwned = false;
690 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
691 const char *&PrevSpec,
694 const PrintingPolicy &Policy) {
695 assert(isExprRep(T) && "T does not store an expr");
696 assert(Rep && "no expression provided!");
697 if (TypeSpecType != TST_unspecified) {
698 PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
699 DiagID = diag::err_invalid_decl_spec_combination;
706 TypeSpecOwned = false;
710 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
711 const char *&PrevSpec,
713 Decl *Rep, bool Owned,
714 const PrintingPolicy &Policy) {
715 return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Owned, Policy);
718 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc,
719 SourceLocation TagNameLoc,
720 const char *&PrevSpec,
722 Decl *Rep, bool Owned,
723 const PrintingPolicy &Policy) {
724 assert(isDeclRep(T) && "T does not store a decl");
725 // Unlike the other cases, we don't assert that we actually get a decl.
727 if (TypeSpecType != TST_unspecified) {
728 PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
729 DiagID = diag::err_invalid_decl_spec_combination;
735 TSTNameLoc = TagNameLoc;
736 TypeSpecOwned = Owned && Rep != nullptr;
740 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
741 const char *&PrevSpec,
743 const PrintingPolicy &Policy) {
744 assert(!isDeclRep(T) && !isTypeRep(T) && !isExprRep(T) &&
745 "rep required for these type-spec kinds!");
746 if (TypeSpecType != TST_unspecified) {
747 PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
748 DiagID = diag::err_invalid_decl_spec_combination;
753 if (TypeAltiVecVector && (T == TST_bool) && !TypeAltiVecBool) {
754 TypeAltiVecBool = true;
758 TypeSpecOwned = false;
762 bool DeclSpec::SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
763 const char *&PrevSpec, unsigned &DiagID,
764 const PrintingPolicy &Policy) {
765 if (TypeSpecType != TST_unspecified) {
766 PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
767 DiagID = diag::err_invalid_vector_decl_spec_combination;
770 TypeAltiVecVector = isAltiVecVector;
775 bool DeclSpec::SetTypePipe(bool isPipe, SourceLocation Loc,
776 const char *&PrevSpec, unsigned &DiagID,
777 const PrintingPolicy &Policy) {
779 if (TypeSpecType != TST_unspecified) {
780 PrevSpec = DeclSpec::getSpecifierName((TST)TypeSpecType, Policy);
781 DiagID = diag::err_invalid_decl_spec_combination;
786 TypeSpecPipe = TSP_pipe;
791 bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
792 const char *&PrevSpec, unsigned &DiagID,
793 const PrintingPolicy &Policy) {
794 if (!TypeAltiVecVector || TypeAltiVecPixel ||
795 (TypeSpecType != TST_unspecified)) {
796 PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
797 DiagID = diag::err_invalid_pixel_decl_spec_combination;
800 TypeAltiVecPixel = isAltiVecPixel;
806 bool DeclSpec::SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
807 const char *&PrevSpec, unsigned &DiagID,
808 const PrintingPolicy &Policy) {
809 if (!TypeAltiVecVector || TypeAltiVecBool ||
810 (TypeSpecType != TST_unspecified)) {
811 PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
812 DiagID = diag::err_invalid_vector_bool_decl_spec;
815 TypeAltiVecBool = isAltiVecBool;
821 bool DeclSpec::SetTypeSpecError() {
822 TypeSpecType = TST_error;
823 TypeSpecOwned = false;
824 TSTLoc = SourceLocation();
825 TSTNameLoc = SourceLocation();
829 bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
830 unsigned &DiagID, const LangOptions &Lang) {
831 // Duplicates are permitted in C99 onwards, but are not permitted in C89 or
832 // C++. However, since this is likely not what the user intended, we will
833 // always warn. We do not need to set the qualifier's location since we
835 if (TypeQualifiers & T) {
836 bool IsExtension = true;
839 return BadSpecifier(T, T, PrevSpec, DiagID, IsExtension);
844 case TQ_unspecified: break;
845 case TQ_const: TQ_constLoc = Loc; return false;
846 case TQ_restrict: TQ_restrictLoc = Loc; return false;
847 case TQ_volatile: TQ_volatileLoc = Loc; return false;
848 case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
849 case TQ_atomic: TQ_atomicLoc = Loc; return false;
852 llvm_unreachable("Unknown type qualifier!");
855 bool DeclSpec::setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
857 // 'inline inline' is ok. However, since this is likely not what the user
858 // intended, we will always warn, similar to duplicates of type qualifiers.
859 if (FS_inline_specified) {
860 DiagID = diag::warn_duplicate_declspec;
864 FS_inline_specified = true;
869 bool DeclSpec::setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec,
871 if (FS_forceinline_specified) {
872 DiagID = diag::warn_duplicate_declspec;
873 PrevSpec = "__forceinline";
876 FS_forceinline_specified = true;
877 FS_forceinlineLoc = Loc;
881 bool DeclSpec::setFunctionSpecVirtual(SourceLocation Loc,
882 const char *&PrevSpec,
884 // 'virtual virtual' is ok, but warn as this is likely not what the user
886 if (FS_virtual_specified) {
887 DiagID = diag::warn_duplicate_declspec;
888 PrevSpec = "virtual";
891 FS_virtual_specified = true;
896 bool DeclSpec::setFunctionSpecExplicit(SourceLocation Loc,
897 const char *&PrevSpec,
899 // 'explicit explicit' is ok, but warn as this is likely not what the user
901 if (FS_explicit_specified) {
902 DiagID = diag::warn_duplicate_declspec;
903 PrevSpec = "explicit";
906 FS_explicit_specified = true;
907 FS_explicitLoc = Loc;
911 bool DeclSpec::setFunctionSpecNoreturn(SourceLocation Loc,
912 const char *&PrevSpec,
914 // '_Noreturn _Noreturn' is ok, but warn as this is likely not what the user
916 if (FS_noreturn_specified) {
917 DiagID = diag::warn_duplicate_declspec;
918 PrevSpec = "_Noreturn";
921 FS_noreturn_specified = true;
922 FS_noreturnLoc = Loc;
926 bool DeclSpec::SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
928 if (Friend_specified) {
930 // Keep the later location, so that we can later diagnose ill-formed
931 // declarations like 'friend class X friend;'. Per [class.friend]p3,
932 // 'friend' must be the first token in a friend declaration that is
933 // not a function declaration.
935 DiagID = diag::warn_duplicate_declspec;
939 Friend_specified = true;
944 bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
946 if (isModulePrivateSpecified()) {
947 PrevSpec = "__module_private__";
948 DiagID = diag::ext_duplicate_declspec;
952 ModulePrivateLoc = Loc;
956 bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec,
958 // 'constexpr constexpr' is ok, but warn as this is likely not what the user
960 if (Constexpr_specified) {
961 DiagID = diag::warn_duplicate_declspec;
962 PrevSpec = "constexpr";
965 Constexpr_specified = true;
970 bool DeclSpec::SetConceptSpec(SourceLocation Loc, const char *&PrevSpec,
972 if (Concept_specified) {
973 DiagID = diag::ext_duplicate_declspec;
974 PrevSpec = "concept";
977 Concept_specified = true;
982 void DeclSpec::SaveWrittenBuiltinSpecs() {
983 writtenBS.Sign = getTypeSpecSign();
984 writtenBS.Width = getTypeSpecWidth();
985 writtenBS.Type = getTypeSpecType();
986 // Search the list of attributes for the presence of a mode attribute.
987 writtenBS.ModeAttr = false;
988 AttributeList* attrs = getAttributes().getList();
990 if (attrs->getKind() == AttributeList::AT_Mode) {
991 writtenBS.ModeAttr = true;
994 attrs = attrs->getNext();
998 /// Finish - This does final analysis of the declspec, rejecting things like
999 /// "_Imaginary" (lacking an FP type). This returns a diagnostic to issue or
1000 /// diag::NUM_DIAGNOSTICS if there is no error. After calling this method,
1001 /// DeclSpec is guaranteed self-consistent, even if an error occurred.
1002 void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
1003 // Before possibly changing their values, save specs as written.
1004 SaveWrittenBuiltinSpecs();
1006 // Check the type specifier components first.
1008 // If decltype(auto) is used, no other type specifiers are permitted.
1009 if (TypeSpecType == TST_decltype_auto &&
1010 (TypeSpecWidth != TSW_unspecified ||
1011 TypeSpecComplex != TSC_unspecified ||
1012 TypeSpecSign != TSS_unspecified ||
1013 TypeAltiVecVector || TypeAltiVecPixel || TypeAltiVecBool ||
1015 const unsigned NumLocs = 9;
1016 SourceLocation ExtraLocs[NumLocs] = {
1017 TSWRange.getBegin(), TSCLoc, TSSLoc,
1018 AltiVecLoc, TQ_constLoc, TQ_restrictLoc,
1019 TQ_volatileLoc, TQ_atomicLoc, TQ_unalignedLoc};
1020 FixItHint Hints[NumLocs];
1021 SourceLocation FirstLoc;
1022 for (unsigned I = 0; I != NumLocs; ++I) {
1023 if (ExtraLocs[I].isValid()) {
1024 if (FirstLoc.isInvalid() ||
1025 S.getSourceManager().isBeforeInTranslationUnit(ExtraLocs[I],
1027 FirstLoc = ExtraLocs[I];
1028 Hints[I] = FixItHint::CreateRemoval(ExtraLocs[I]);
1031 TypeSpecWidth = TSW_unspecified;
1032 TypeSpecComplex = TSC_unspecified;
1033 TypeSpecSign = TSS_unspecified;
1034 TypeAltiVecVector = TypeAltiVecPixel = TypeAltiVecBool = false;
1036 S.Diag(TSTLoc, diag::err_decltype_auto_cannot_be_combined)
1037 << Hints[0] << Hints[1] << Hints[2] << Hints[3]
1038 << Hints[4] << Hints[5] << Hints[6] << Hints[7];
1041 // Validate and finalize AltiVec vector declspec.
1042 if (TypeAltiVecVector) {
1043 if (TypeAltiVecBool) {
1044 // Sign specifiers are not allowed with vector bool. (PIM 2.1)
1045 if (TypeSpecSign != TSS_unspecified) {
1046 S.Diag(TSSLoc, diag::err_invalid_vector_bool_decl_spec)
1047 << getSpecifierName((TSS)TypeSpecSign);
1050 // Only char/int are valid with vector bool. (PIM 2.1)
1051 if (((TypeSpecType != TST_unspecified) && (TypeSpecType != TST_char) &&
1052 (TypeSpecType != TST_int)) || TypeAltiVecPixel) {
1053 S.Diag(TSTLoc, diag::err_invalid_vector_bool_decl_spec)
1054 << (TypeAltiVecPixel ? "__pixel" :
1055 getSpecifierName((TST)TypeSpecType, Policy));
1058 // Only 'short' and 'long long' are valid with vector bool. (PIM 2.1)
1059 if ((TypeSpecWidth != TSW_unspecified) && (TypeSpecWidth != TSW_short) &&
1060 (TypeSpecWidth != TSW_longlong))
1061 S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_bool_decl_spec)
1062 << getSpecifierName((TSW)TypeSpecWidth);
1064 // vector bool long long requires VSX support or ZVector.
1065 if ((TypeSpecWidth == TSW_longlong) &&
1066 (!S.Context.getTargetInfo().hasFeature("vsx")) &&
1067 (!S.Context.getTargetInfo().hasFeature("power8-vector")) &&
1068 !S.getLangOpts().ZVector)
1069 S.Diag(TSTLoc, diag::err_invalid_vector_long_long_decl_spec);
1071 // Elements of vector bool are interpreted as unsigned. (PIM 2.1)
1072 if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) ||
1073 (TypeSpecWidth != TSW_unspecified))
1074 TypeSpecSign = TSS_unsigned;
1075 } else if (TypeSpecType == TST_double) {
1076 // vector long double and vector long long double are never allowed.
1077 // vector double is OK for Power7 and later, and ZVector.
1078 if (TypeSpecWidth == TSW_long || TypeSpecWidth == TSW_longlong)
1079 S.Diag(TSWRange.getBegin(),
1080 diag::err_invalid_vector_long_double_decl_spec);
1081 else if (!S.Context.getTargetInfo().hasFeature("vsx") &&
1082 !S.getLangOpts().ZVector)
1083 S.Diag(TSTLoc, diag::err_invalid_vector_double_decl_spec);
1084 } else if (TypeSpecType == TST_float) {
1085 // vector float is unsupported for ZVector.
1086 if (S.getLangOpts().ZVector)
1087 S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec);
1088 } else if (TypeSpecWidth == TSW_long) {
1089 // vector long is unsupported for ZVector and deprecated for AltiVec.
1090 if (S.getLangOpts().ZVector)
1091 S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_decl_spec);
1093 S.Diag(TSWRange.getBegin(),
1094 diag::warn_vector_long_decl_spec_combination)
1095 << getSpecifierName((TST)TypeSpecType, Policy);
1098 if (TypeAltiVecPixel) {
1099 //TODO: perform validation
1100 TypeSpecType = TST_int;
1101 TypeSpecSign = TSS_unsigned;
1102 TypeSpecWidth = TSW_short;
1103 TypeSpecOwned = false;
1107 // signed/unsigned are only valid with int/char/wchar_t.
1108 if (TypeSpecSign != TSS_unspecified) {
1109 if (TypeSpecType == TST_unspecified)
1110 TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
1111 else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 &&
1112 TypeSpecType != TST_char && TypeSpecType != TST_wchar) {
1113 S.Diag(TSSLoc, diag::err_invalid_sign_spec)
1114 << getSpecifierName((TST)TypeSpecType, Policy);
1115 // signed double -> double.
1116 TypeSpecSign = TSS_unspecified;
1120 // Validate the width of the type.
1121 switch (TypeSpecWidth) {
1122 case TSW_unspecified: break;
1123 case TSW_short: // short int
1124 case TSW_longlong: // long long int
1125 if (TypeSpecType == TST_unspecified)
1126 TypeSpecType = TST_int; // short -> short int, long long -> long long int.
1127 else if (TypeSpecType != TST_int) {
1128 S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1129 << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1130 TypeSpecType = TST_int;
1131 TypeSpecOwned = false;
1134 case TSW_long: // long double, long int
1135 if (TypeSpecType == TST_unspecified)
1136 TypeSpecType = TST_int; // long -> long int.
1137 else if (TypeSpecType != TST_int && TypeSpecType != TST_double) {
1138 S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1139 << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1140 TypeSpecType = TST_int;
1141 TypeSpecOwned = false;
1146 // TODO: if the implementation does not implement _Complex or _Imaginary,
1147 // disallow their use. Need information about the backend.
1148 if (TypeSpecComplex != TSC_unspecified) {
1149 if (TypeSpecType == TST_unspecified) {
1150 S.Diag(TSCLoc, diag::ext_plain_complex)
1151 << FixItHint::CreateInsertion(
1152 S.getLocForEndOfToken(getTypeSpecComplexLoc()),
1154 TypeSpecType = TST_double; // _Complex -> _Complex double.
1155 } else if (TypeSpecType == TST_int || TypeSpecType == TST_char) {
1156 // Note that this intentionally doesn't include _Complex _Bool.
1157 if (!S.getLangOpts().CPlusPlus)
1158 S.Diag(TSTLoc, diag::ext_integer_complex);
1159 } else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
1160 S.Diag(TSCLoc, diag::err_invalid_complex_spec)
1161 << getSpecifierName((TST)TypeSpecType, Policy);
1162 TypeSpecComplex = TSC_unspecified;
1166 // C11 6.7.1/3, C++11 [dcl.stc]p1, GNU TLS: __thread, thread_local and
1167 // _Thread_local can only appear with the 'static' and 'extern' storage class
1168 // specifiers. We also allow __private_extern__ as an extension.
1169 if (ThreadStorageClassSpec != TSCS_unspecified) {
1170 switch (StorageClassSpec) {
1171 case SCS_unspecified:
1173 case SCS_private_extern:
1177 if (S.getSourceManager().isBeforeInTranslationUnit(
1178 getThreadStorageClassSpecLoc(), getStorageClassSpecLoc()))
1179 S.Diag(getStorageClassSpecLoc(),
1180 diag::err_invalid_decl_spec_combination)
1181 << DeclSpec::getSpecifierName(getThreadStorageClassSpec())
1182 << SourceRange(getThreadStorageClassSpecLoc());
1184 S.Diag(getThreadStorageClassSpecLoc(),
1185 diag::err_invalid_decl_spec_combination)
1186 << DeclSpec::getSpecifierName(getStorageClassSpec())
1187 << SourceRange(getStorageClassSpecLoc());
1188 // Discard the thread storage class specifier to recover.
1189 ThreadStorageClassSpec = TSCS_unspecified;
1190 ThreadStorageClassSpecLoc = SourceLocation();
1194 // If no type specifier was provided and we're parsing a language where
1195 // the type specifier is not optional, but we got 'auto' as a storage
1196 // class specifier, then assume this is an attempt to use C++0x's 'auto'
1198 if (S.getLangOpts().CPlusPlus &&
1199 TypeSpecType == TST_unspecified && StorageClassSpec == SCS_auto) {
1200 TypeSpecType = TST_auto;
1201 StorageClassSpec = SCS_unspecified;
1202 TSTLoc = TSTNameLoc = StorageClassSpecLoc;
1203 StorageClassSpecLoc = SourceLocation();
1205 // Diagnose if we've recovered from an ill-formed 'auto' storage class
1206 // specifier in a pre-C++11 dialect of C++.
1207 if (!S.getLangOpts().CPlusPlus11 && TypeSpecType == TST_auto)
1208 S.Diag(TSTLoc, diag::ext_auto_type_specifier);
1209 if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11 &&
1210 StorageClassSpec == SCS_auto)
1211 S.Diag(StorageClassSpecLoc, diag::warn_auto_storage_class)
1212 << FixItHint::CreateRemoval(StorageClassSpecLoc);
1213 if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32)
1214 S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type)
1215 << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
1216 if (Constexpr_specified)
1217 S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr);
1219 // C++ [class.friend]p6:
1220 // No storage-class-specifier shall appear in the decl-specifier-seq
1221 // of a friend declaration.
1222 if (isFriendSpecified() &&
1223 (getStorageClassSpec() || getThreadStorageClassSpec())) {
1224 SmallString<32> SpecName;
1225 SourceLocation SCLoc;
1226 FixItHint StorageHint, ThreadHint;
1228 if (DeclSpec::SCS SC = getStorageClassSpec()) {
1229 SpecName = getSpecifierName(SC);
1230 SCLoc = getStorageClassSpecLoc();
1231 StorageHint = FixItHint::CreateRemoval(SCLoc);
1234 if (DeclSpec::TSCS TSC = getThreadStorageClassSpec()) {
1235 if (!SpecName.empty()) SpecName += " ";
1236 SpecName += getSpecifierName(TSC);
1237 SCLoc = getThreadStorageClassSpecLoc();
1238 ThreadHint = FixItHint::CreateRemoval(SCLoc);
1241 S.Diag(SCLoc, diag::err_friend_decl_spec)
1242 << SpecName << StorageHint << ThreadHint;
1244 ClearStorageClassSpecs();
1247 // C++11 [dcl.fct.spec]p5:
1248 // The virtual specifier shall be used only in the initial
1249 // declaration of a non-static class member function;
1250 // C++11 [dcl.fct.spec]p6:
1251 // The explicit specifier shall be used only in the declaration of
1252 // a constructor or conversion function within its class
1254 if (isFriendSpecified() && (isVirtualSpecified() || isExplicitSpecified())) {
1256 SourceLocation SCLoc;
1258 if (isVirtualSpecified()) {
1259 Keyword = "virtual";
1260 SCLoc = getVirtualSpecLoc();
1262 Keyword = "explicit";
1263 SCLoc = getExplicitSpecLoc();
1266 FixItHint Hint = FixItHint::CreateRemoval(SCLoc);
1267 S.Diag(SCLoc, diag::err_friend_decl_spec)
1270 FS_virtual_specified = FS_explicit_specified = false;
1271 FS_virtualLoc = FS_explicitLoc = SourceLocation();
1274 assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
1276 // Okay, now we can infer the real type.
1278 // TODO: return "auto function" and other bad things based on the real type.
1280 // 'data definition has no type or storage class'?
1283 bool DeclSpec::isMissingDeclaratorOk() {
1284 TST tst = getTypeSpecType();
1285 return isDeclRep(tst) && getRepAsDecl() != nullptr &&
1286 StorageClassSpec != DeclSpec::SCS_typedef;
1289 void UnqualifiedId::setOperatorFunctionId(SourceLocation OperatorLoc,
1290 OverloadedOperatorKind Op,
1291 SourceLocation SymbolLocations[3]) {
1292 Kind = IK_OperatorFunctionId;
1293 StartLocation = OperatorLoc;
1294 EndLocation = OperatorLoc;
1295 OperatorFunctionId.Operator = Op;
1296 for (unsigned I = 0; I != 3; ++I) {
1297 OperatorFunctionId.SymbolLocations[I] = SymbolLocations[I].getRawEncoding();
1299 if (SymbolLocations[I].isValid())
1300 EndLocation = SymbolLocations[I];
1304 bool VirtSpecifiers::SetSpecifier(Specifier VS, SourceLocation Loc,
1305 const char *&PrevSpec) {
1306 if (!FirstLocation.isValid())
1307 FirstLocation = Loc;
1311 if (Specifiers & VS) {
1312 PrevSpec = getSpecifierName(VS);
1319 default: llvm_unreachable("Unknown specifier!");
1320 case VS_Override: VS_overrideLoc = Loc; break;
1323 case VS_Final: VS_finalLoc = Loc; break;
1329 const char *VirtSpecifiers::getSpecifierName(Specifier VS) {
1331 default: llvm_unreachable("Unknown specifier");
1332 case VS_Override: return "override";
1333 case VS_Final: return "final";
1334 case VS_GNU_Final: return "__final";
1335 case VS_Sealed: return "sealed";