clang  16.0.0git
DeclSpec.cpp
Go to the documentation of this file.
1 //===--- DeclSpec.cpp - Declaration Specifier Semantic Analysis -----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements semantic analysis for declaration specifiers.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/Sema/DeclSpec.h"
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/DeclCXX.h"
16 #include "clang/AST/Expr.h"
17 #include "clang/AST/LocInfoType.h"
18 #include "clang/AST/TypeLoc.h"
21 #include "clang/Basic/Specifiers.h"
22 #include "clang/Basic/TargetInfo.h"
24 #include "clang/Sema/Sema.h"
26 #include "llvm/ADT/STLExtras.h"
27 #include "llvm/ADT/SmallString.h"
28 #include <cstring>
29 using namespace clang;
30 
31 
33  assert(TemplateId && "NULL template-id annotation?");
34  assert(!TemplateId->isInvalid() &&
35  "should not convert invalid template-ids to unqualified-ids");
36 
38  this->TemplateId = TemplateId;
41 }
42 
44  assert(TemplateId && "NULL template-id annotation?");
45  assert(!TemplateId->isInvalid() &&
46  "should not convert invalid template-ids to unqualified-ids");
47 
49  this->TemplateId = TemplateId;
52 }
53 
54 void CXXScopeSpec::Extend(ASTContext &Context, SourceLocation TemplateKWLoc,
55  TypeLoc TL, SourceLocation ColonColonLoc) {
56  Builder.Extend(Context, TemplateKWLoc, TL, ColonColonLoc);
57  if (Range.getBegin().isInvalid())
58  Range.setBegin(TL.getBeginLoc());
59  Range.setEnd(ColonColonLoc);
60 
61  assert(Range == Builder.getSourceRange() &&
62  "NestedNameSpecifierLoc range computation incorrect");
63 }
64 
67  SourceLocation ColonColonLoc) {
68  Builder.Extend(Context, Identifier, IdentifierLoc, ColonColonLoc);
69 
70  if (Range.getBegin().isInvalid())
71  Range.setBegin(IdentifierLoc);
72  Range.setEnd(ColonColonLoc);
73 
74  assert(Range == Builder.getSourceRange() &&
75  "NestedNameSpecifierLoc range computation incorrect");
76 }
77 
78 void CXXScopeSpec::Extend(ASTContext &Context, NamespaceDecl *Namespace,
79  SourceLocation NamespaceLoc,
80  SourceLocation ColonColonLoc) {
81  Builder.Extend(Context, Namespace, NamespaceLoc, ColonColonLoc);
82 
83  if (Range.getBegin().isInvalid())
84  Range.setBegin(NamespaceLoc);
85  Range.setEnd(ColonColonLoc);
86 
87  assert(Range == Builder.getSourceRange() &&
88  "NestedNameSpecifierLoc range computation incorrect");
89 }
90 
92  SourceLocation AliasLoc,
93  SourceLocation ColonColonLoc) {
94  Builder.Extend(Context, Alias, AliasLoc, ColonColonLoc);
95 
96  if (Range.getBegin().isInvalid())
97  Range.setBegin(AliasLoc);
98  Range.setEnd(ColonColonLoc);
99 
100  assert(Range == Builder.getSourceRange() &&
101  "NestedNameSpecifierLoc range computation incorrect");
102 }
103 
105  SourceLocation ColonColonLoc) {
106  Builder.MakeGlobal(Context, ColonColonLoc);
107 
108  Range = SourceRange(ColonColonLoc);
109 
110  assert(Range == Builder.getSourceRange() &&
111  "NestedNameSpecifierLoc range computation incorrect");
112 }
113 
115  SourceLocation SuperLoc,
116  SourceLocation ColonColonLoc) {
117  Builder.MakeSuper(Context, RD, SuperLoc, ColonColonLoc);
118 
119  Range.setBegin(SuperLoc);
120  Range.setEnd(ColonColonLoc);
121 
122  assert(Range == Builder.getSourceRange() &&
123  "NestedNameSpecifierLoc range computation incorrect");
124 }
125 
127  NestedNameSpecifier *Qualifier, SourceRange R) {
128  Builder.MakeTrivial(Context, Qualifier, R);
129  Range = R;
130 }
131 
133  if (!Other) {
134  Range = SourceRange();
135  Builder.Clear();
136  return;
137  }
138 
139  Range = Other.getSourceRange();
140  Builder.Adopt(Other);
141  assert(Range == Builder.getSourceRange() &&
142  "NestedNameSpecifierLoc range computation incorrect");
143 }
144 
146  if (!Builder.getRepresentation())
147  return SourceLocation();
148  return Builder.getTemporary().getLocalBeginLoc();
149 }
150 
153  if (!Builder.getRepresentation())
154  return NestedNameSpecifierLoc();
155 
156  return Builder.getWithLocInContext(Context);
157 }
158 
159 /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
160 /// "TheDeclarator" is the declarator that this will be added to.
162  bool isAmbiguous,
163  SourceLocation LParenLoc,
164  ParamInfo *Params,
165  unsigned NumParams,
166  SourceLocation EllipsisLoc,
167  SourceLocation RParenLoc,
168  bool RefQualifierIsLvalueRef,
169  SourceLocation RefQualifierLoc,
170  SourceLocation MutableLoc,
172  ESpecType,
173  SourceRange ESpecRange,
174  ParsedType *Exceptions,
175  SourceRange *ExceptionRanges,
176  unsigned NumExceptions,
177  Expr *NoexceptExpr,
178  CachedTokens *ExceptionSpecTokens,
180  DeclsInPrototype,
181  SourceLocation LocalRangeBegin,
182  SourceLocation LocalRangeEnd,
183  Declarator &TheDeclarator,
184  TypeResult TrailingReturnType,
186  TrailingReturnTypeLoc,
187  DeclSpec *MethodQualifiers) {
188  assert(!(MethodQualifiers && MethodQualifiers->getTypeQualifiers() & DeclSpec::TQ_atomic) &&
189  "function cannot have _Atomic qualifier");
190 
191  DeclaratorChunk I;
192  I.Kind = Function;
193  I.Loc = LocalRangeBegin;
194  I.EndLoc = LocalRangeEnd;
195  new (&I.Fun) FunctionTypeInfo;
196  I.Fun.hasPrototype = hasProto;
197  I.Fun.isVariadic = EllipsisLoc.isValid();
198  I.Fun.isAmbiguous = isAmbiguous;
199  I.Fun.LParenLoc = LParenLoc;
200  I.Fun.EllipsisLoc = EllipsisLoc;
201  I.Fun.RParenLoc = RParenLoc;
202  I.Fun.DeleteParams = false;
203  I.Fun.NumParams = NumParams;
204  I.Fun.Params = nullptr;
205  I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef;
206  I.Fun.RefQualifierLoc = RefQualifierLoc;
207  I.Fun.MutableLoc = MutableLoc;
208  I.Fun.ExceptionSpecType = ESpecType;
209  I.Fun.ExceptionSpecLocBeg = ESpecRange.getBegin();
210  I.Fun.ExceptionSpecLocEnd = ESpecRange.getEnd();
212  I.Fun.Exceptions = nullptr;
213  I.Fun.NoexceptExpr = nullptr;
214  I.Fun.HasTrailingReturnType = TrailingReturnType.isUsable() ||
215  TrailingReturnType.isInvalid();
216  I.Fun.TrailingReturnType = TrailingReturnType.get();
217  I.Fun.TrailingReturnTypeLoc = TrailingReturnTypeLoc;
218  I.Fun.MethodQualifiers = nullptr;
219  I.Fun.QualAttrFactory = nullptr;
220 
221  if (MethodQualifiers && (MethodQualifiers->getTypeQualifiers() ||
222  MethodQualifiers->getAttributes().size())) {
223  auto &attrs = MethodQualifiers->getAttributes();
224  I.Fun.MethodQualifiers = new DeclSpec(attrs.getPool().getFactory());
225  MethodQualifiers->forEachCVRUQualifier(
226  [&](DeclSpec::TQ TypeQual, StringRef PrintName, SourceLocation SL) {
227  I.Fun.MethodQualifiers->SetTypeQual(TypeQual, SL);
228  });
230  I.Fun.MethodQualifiers->getAttributePool().takeAllFrom(attrs.getPool());
231  }
232 
233  assert(I.Fun.ExceptionSpecType == ESpecType && "bitfield overflow");
234 
235  // new[] a parameter array if needed.
236  if (NumParams) {
237  // If the 'InlineParams' in Declarator is unused and big enough, put our
238  // parameter list there (in an effort to avoid new/delete traffic). If it
239  // is already used (consider a function returning a function pointer) or too
240  // small (function with too many parameters), go to the heap.
241  if (!TheDeclarator.InlineStorageUsed &&
242  NumParams <= std::size(TheDeclarator.InlineParams)) {
243  I.Fun.Params = TheDeclarator.InlineParams;
244  new (I.Fun.Params) ParamInfo[NumParams];
245  I.Fun.DeleteParams = false;
246  TheDeclarator.InlineStorageUsed = true;
247  } else {
248  I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams];
249  I.Fun.DeleteParams = true;
250  }
251  for (unsigned i = 0; i < NumParams; i++)
252  I.Fun.Params[i] = std::move(Params[i]);
253  }
254 
255  // Check what exception specification information we should actually store.
256  switch (ESpecType) {
257  default: break; // By default, save nothing.
258  case EST_Dynamic:
259  // new[] an exception array if needed
260  if (NumExceptions) {
261  I.Fun.NumExceptionsOrDecls = NumExceptions;
262  I.Fun.Exceptions = new DeclaratorChunk::TypeAndRange[NumExceptions];
263  for (unsigned i = 0; i != NumExceptions; ++i) {
264  I.Fun.Exceptions[i].Ty = Exceptions[i];
265  I.Fun.Exceptions[i].Range = ExceptionRanges[i];
266  }
267  }
268  break;
269 
271  case EST_NoexceptFalse:
272  case EST_NoexceptTrue:
273  I.Fun.NoexceptExpr = NoexceptExpr;
274  break;
275 
276  case EST_Unparsed:
277  I.Fun.ExceptionSpecTokens = ExceptionSpecTokens;
278  break;
279  }
280 
281  if (!DeclsInPrototype.empty()) {
282  assert(ESpecType == EST_None && NumExceptions == 0 &&
283  "cannot have exception specifiers and decls in prototype");
284  I.Fun.NumExceptionsOrDecls = DeclsInPrototype.size();
285  // Copy the array of decls into stable heap storage.
286  I.Fun.DeclsInPrototype = new NamedDecl *[DeclsInPrototype.size()];
287  for (size_t J = 0; J < DeclsInPrototype.size(); ++J)
288  I.Fun.DeclsInPrototype[J] = DeclsInPrototype[J];
289  }
290 
291  return I;
292 }
293 
295  SourceLocation LSquareLoc,
297  SourceLocation RSquareLoc) {
298  assert(!hasName() && "declarator given multiple names!");
299 
300  BindingGroup.LSquareLoc = LSquareLoc;
301  BindingGroup.RSquareLoc = RSquareLoc;
302  BindingGroup.NumBindings = Bindings.size();
303  Range.setEnd(RSquareLoc);
304 
305  // We're now past the identifier.
306  SetIdentifier(nullptr, LSquareLoc);
307  Name.EndLocation = RSquareLoc;
308 
309  // Allocate storage for bindings and stash them away.
310  if (Bindings.size()) {
311  if (!InlineStorageUsed && Bindings.size() <= std::size(InlineBindings)) {
312  BindingGroup.Bindings = InlineBindings;
313  BindingGroup.DeleteBindings = false;
314  InlineStorageUsed = true;
315  } else {
316  BindingGroup.Bindings =
318  BindingGroup.DeleteBindings = true;
319  }
320  std::uninitialized_copy(Bindings.begin(), Bindings.end(),
321  BindingGroup.Bindings);
322  }
323 }
324 
326  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
327  switch (DeclTypeInfo[i].Kind) {
329  return true;
331  continue;
338  return false;
339  }
340  llvm_unreachable("Invalid type chunk");
341  }
342 
343  switch (DS.getTypeSpecType()) {
344  case TST_atomic:
345  case TST_auto:
346  case TST_auto_type:
347  case TST_bool:
348  case TST_char:
349  case TST_char8:
350  case TST_char16:
351  case TST_char32:
352  case TST_class:
353  case TST_decimal128:
354  case TST_decimal32:
355  case TST_decimal64:
356  case TST_double:
357  case TST_Accum:
358  case TST_Fract:
359  case TST_Float16:
360  case TST_float128:
361  case TST_ibm128:
362  case TST_enum:
363  case TST_error:
364  case TST_float:
365  case TST_half:
366  case TST_int:
367  case TST_int128:
368  case TST_bitint:
369  case TST_struct:
370  case TST_interface:
371  case TST_union:
372  case TST_unknown_anytype:
373  case TST_unspecified:
374  case TST_void:
375  case TST_wchar:
376  case TST_BFloat16:
377 #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
378 #include "clang/Basic/OpenCLImageTypes.def"
379  return false;
380 
381  case TST_decltype_auto:
382  // This must have an initializer, so can't be a function declaration,
383  // even if the initializer has function type.
384  return false;
385 
386  case TST_decltype:
388  case TST_typeofExpr:
389  if (Expr *E = DS.getRepAsExpr())
390  return E->getType()->isFunctionType();
391  return false;
392 
393 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case TST_##Trait:
394 #include "clang/Basic/TransformTypeTraits.def"
395  case TST_typename:
397  case TST_typeofType: {
398  QualType QT = DS.getRepAsType().get();
399  if (QT.isNull())
400  return false;
401 
402  if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT))
403  QT = LIT->getType();
404 
405  if (QT.isNull())
406  return false;
407 
408  return QT->isFunctionType();
409  }
410  }
411 
412  llvm_unreachable("Invalid TypeSpecType!");
413 }
414 
420  getName().OperatorFunctionId.Operator));
421 }
422 
426 }
427 
429  llvm::function_ref<void(TQ, StringRef, SourceLocation)> Handle) {
430  if (TypeQualifiers & TQ_const)
431  Handle(TQ_const, "const", TQ_constLoc);
432  if (TypeQualifiers & TQ_volatile)
433  Handle(TQ_volatile, "volatile", TQ_volatileLoc);
434  if (TypeQualifiers & TQ_restrict)
435  Handle(TQ_restrict, "restrict", TQ_restrictLoc);
436  if (TypeQualifiers & TQ_unaligned)
437  Handle(TQ_unaligned, "unaligned", TQ_unalignedLoc);
438 }
439 
441  llvm::function_ref<void(TQ, StringRef, SourceLocation)> Handle) {
442  forEachCVRUQualifier(Handle);
443  // FIXME: Add code below to iterate through the attributes and call Handle.
444 }
445 
447  if (!TypeSpecOwned)
448  return false;
449  return cast<TagDecl>(getRepAsDecl())->isCompleteDefinition();
450 }
451 
452 /// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
453 /// declaration specifier includes.
454 ///
456  unsigned Res = 0;
457  if (StorageClassSpec != SCS_unspecified ||
458  ThreadStorageClassSpec != TSCS_unspecified)
460 
461  if (TypeQualifiers != TQ_unspecified)
462  Res |= PQ_TypeQualifier;
463 
464  if (hasTypeSpecifier())
465  Res |= PQ_TypeSpecifier;
466 
467  if (FS_inline_specified || FS_virtual_specified || hasExplicitSpecifier() ||
468  FS_noreturn_specified || FS_forceinline_specified)
469  Res |= PQ_FunctionSpecifier;
470  return Res;
471 }
472 
473 template <class T> static bool BadSpecifier(T TNew, T TPrev,
474  const char *&PrevSpec,
475  unsigned &DiagID,
476  bool IsExtension = true) {
477  PrevSpec = DeclSpec::getSpecifierName(TPrev);
478  if (TNew != TPrev)
479  DiagID = diag::err_invalid_decl_spec_combination;
480  else
481  DiagID = IsExtension ? diag::ext_warn_duplicate_declspec :
482  diag::warn_duplicate_declspec;
483  return true;
484 }
485 
487  switch (S) {
488  case DeclSpec::SCS_unspecified: return "unspecified";
489  case DeclSpec::SCS_typedef: return "typedef";
490  case DeclSpec::SCS_extern: return "extern";
491  case DeclSpec::SCS_static: return "static";
492  case DeclSpec::SCS_auto: return "auto";
493  case DeclSpec::SCS_register: return "register";
494  case DeclSpec::SCS_private_extern: return "__private_extern__";
495  case DeclSpec::SCS_mutable: return "mutable";
496  }
497  llvm_unreachable("Unknown typespec!");
498 }
499 
501  switch (S) {
502  case DeclSpec::TSCS_unspecified: return "unspecified";
503  case DeclSpec::TSCS___thread: return "__thread";
504  case DeclSpec::TSCS_thread_local: return "thread_local";
505  case DeclSpec::TSCS__Thread_local: return "_Thread_local";
506  }
507  llvm_unreachable("Unknown typespec!");
508 }
509 
511  switch (W) {
513  return "unspecified";
515  return "short";
517  return "long";
519  return "long long";
520  }
521  llvm_unreachable("Unknown typespec!");
522 }
523 
525  switch (C) {
526  case TSC_unspecified: return "unspecified";
527  case TSC_imaginary: return "imaginary";
528  case TSC_complex: return "complex";
529  }
530  llvm_unreachable("Unknown typespec!");
531 }
532 
534  switch (S) {
536  return "unspecified";
538  return "signed";
540  return "unsigned";
541  }
542  llvm_unreachable("Unknown typespec!");
543 }
544 
546  const PrintingPolicy &Policy) {
547  switch (T) {
548  case DeclSpec::TST_unspecified: return "unspecified";
549  case DeclSpec::TST_void: return "void";
550  case DeclSpec::TST_char: return "char";
551  case DeclSpec::TST_wchar: return Policy.MSWChar ? "__wchar_t" : "wchar_t";
552  case DeclSpec::TST_char8: return "char8_t";
553  case DeclSpec::TST_char16: return "char16_t";
554  case DeclSpec::TST_char32: return "char32_t";
555  case DeclSpec::TST_int: return "int";
556  case DeclSpec::TST_int128: return "__int128";
557  case DeclSpec::TST_bitint: return "_BitInt";
558  case DeclSpec::TST_half: return "half";
559  case DeclSpec::TST_float: return "float";
560  case DeclSpec::TST_double: return "double";
561  case DeclSpec::TST_accum: return "_Accum";
562  case DeclSpec::TST_fract: return "_Fract";
563  case DeclSpec::TST_float16: return "_Float16";
564  case DeclSpec::TST_float128: return "__float128";
565  case DeclSpec::TST_ibm128: return "__ibm128";
566  case DeclSpec::TST_bool: return Policy.Bool ? "bool" : "_Bool";
567  case DeclSpec::TST_decimal32: return "_Decimal32";
568  case DeclSpec::TST_decimal64: return "_Decimal64";
569  case DeclSpec::TST_decimal128: return "_Decimal128";
570  case DeclSpec::TST_enum: return "enum";
571  case DeclSpec::TST_class: return "class";
572  case DeclSpec::TST_union: return "union";
573  case DeclSpec::TST_struct: return "struct";
574  case DeclSpec::TST_interface: return "__interface";
575  case DeclSpec::TST_typename: return "type-name";
577  case DeclSpec::TST_typeofExpr: return "typeof";
579  case DeclSpec::TST_typeof_unqualExpr: return "typeof_unqual";
580  case DeclSpec::TST_auto: return "auto";
581  case DeclSpec::TST_auto_type: return "__auto_type";
582  case DeclSpec::TST_decltype: return "(decltype)";
583  case DeclSpec::TST_decltype_auto: return "decltype(auto)";
584 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
585  case DeclSpec::TST_##Trait: \
586  return "__" #Trait;
587 #include "clang/Basic/TransformTypeTraits.def"
588  case DeclSpec::TST_unknown_anytype: return "__unknown_anytype";
589  case DeclSpec::TST_atomic: return "_Atomic";
590  case DeclSpec::TST_BFloat16: return "__bf16";
591 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
592  case DeclSpec::TST_##ImgType##_t: \
593  return #ImgType "_t";
594 #include "clang/Basic/OpenCLImageTypes.def"
595  case DeclSpec::TST_error: return "(error)";
596  }
597  llvm_unreachable("Unknown typespec!");
598 }
599 
601  switch (C) {
603  return "unspecified";
605  return "constexpr";
607  return "consteval";
609  return "constinit";
610  }
611  llvm_unreachable("Unknown ConstexprSpecKind");
612 }
613 
615  switch (T) {
616  case DeclSpec::TQ_unspecified: return "unspecified";
617  case DeclSpec::TQ_const: return "const";
618  case DeclSpec::TQ_restrict: return "restrict";
619  case DeclSpec::TQ_volatile: return "volatile";
620  case DeclSpec::TQ_atomic: return "_Atomic";
621  case DeclSpec::TQ_unaligned: return "__unaligned";
622  }
623  llvm_unreachable("Unknown typespec!");
624 }
625 
627  const char *&PrevSpec,
628  unsigned &DiagID,
629  const PrintingPolicy &Policy) {
630  // OpenCL v1.1 s6.8g: "The extern, static, auto and register storage-class
631  // specifiers are not supported.
632  // It seems sensible to prohibit private_extern too
633  // The cl_clang_storage_class_specifiers extension enables support for
634  // these storage-class specifiers.
635  // OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
636  // specifiers are not supported."
637  if (S.getLangOpts().OpenCL &&
639  "cl_clang_storage_class_specifiers", S.getLangOpts())) {
640  switch (SC) {
641  case SCS_extern:
642  case SCS_private_extern:
643  case SCS_static:
644  if (S.getLangOpts().getOpenCLCompatibleVersion() < 120) {
645  DiagID = diag::err_opencl_unknown_type_specifier;
646  PrevSpec = getSpecifierName(SC);
647  return true;
648  }
649  break;
650  case SCS_auto:
651  case SCS_register:
652  DiagID = diag::err_opencl_unknown_type_specifier;
653  PrevSpec = getSpecifierName(SC);
654  return true;
655  default:
656  break;
657  }
658  }
659 
660  if (StorageClassSpec != SCS_unspecified) {
661  // Maybe this is an attempt to use C++11 'auto' outside of C++11 mode.
662  bool isInvalid = true;
663  if (TypeSpecType == TST_unspecified && S.getLangOpts().CPlusPlus) {
664  if (SC == SCS_auto)
665  return SetTypeSpecType(TST_auto, Loc, PrevSpec, DiagID, Policy);
666  if (StorageClassSpec == SCS_auto) {
667  isInvalid = SetTypeSpecType(TST_auto, StorageClassSpecLoc,
668  PrevSpec, DiagID, Policy);
669  assert(!isInvalid && "auto SCS -> TST recovery failed");
670  }
671  }
672 
673  // Changing storage class is allowed only if the previous one
674  // was the 'extern' that is part of a linkage specification and
675  // the new storage class is 'typedef'.
676  if (isInvalid &&
677  !(SCS_extern_in_linkage_spec &&
678  StorageClassSpec == SCS_extern &&
679  SC == SCS_typedef))
680  return BadSpecifier(SC, (SCS)StorageClassSpec, PrevSpec, DiagID);
681  }
682  StorageClassSpec = SC;
683  StorageClassSpecLoc = Loc;
684  assert((unsigned)SC == StorageClassSpec && "SCS constants overflow bitfield");
685  return false;
686 }
687 
689  const char *&PrevSpec,
690  unsigned &DiagID) {
691  if (ThreadStorageClassSpec != TSCS_unspecified)
692  return BadSpecifier(TSC, (TSCS)ThreadStorageClassSpec, PrevSpec, DiagID);
693 
694  ThreadStorageClassSpec = TSC;
695  ThreadStorageClassSpecLoc = Loc;
696  return false;
697 }
698 
699 /// These methods set the specified attribute of the DeclSpec, but return true
700 /// and ignore the request if invalid (e.g. "extern" then "auto" is
701 /// specified).
703  const char *&PrevSpec, unsigned &DiagID,
704  const PrintingPolicy &Policy) {
705  // Overwrite TSWRange.Begin only if TypeSpecWidth was unspecified, so that
706  // for 'long long' we will keep the source location of the first 'long'.
708  TSWRange.setBegin(Loc);
709  // Allow turning long -> long long.
710  else if (W != TypeSpecifierWidth::LongLong ||
712  return BadSpecifier(W, getTypeSpecWidth(), PrevSpec, DiagID);
713  TypeSpecWidth = static_cast<unsigned>(W);
714  // Remember location of the last 'long'
715  TSWRange.setEnd(Loc);
716  return false;
717 }
718 
720  const char *&PrevSpec,
721  unsigned &DiagID) {
722  if (TypeSpecComplex != TSC_unspecified)
723  return BadSpecifier(C, (TSC)TypeSpecComplex, PrevSpec, DiagID);
724  TypeSpecComplex = C;
725  TSCLoc = Loc;
726  return false;
727 }
728 
730  const char *&PrevSpec, unsigned &DiagID) {
732  return BadSpecifier(S, getTypeSpecSign(), PrevSpec, DiagID);
733  TypeSpecSign = static_cast<unsigned>(S);
734  TSSLoc = Loc;
735  return false;
736 }
737 
739  const char *&PrevSpec,
740  unsigned &DiagID,
741  ParsedType Rep,
742  const PrintingPolicy &Policy) {
743  return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Policy);
744 }
745 
747  SourceLocation TagNameLoc,
748  const char *&PrevSpec,
749  unsigned &DiagID,
750  ParsedType Rep,
751  const PrintingPolicy &Policy) {
752  assert(isTypeRep(T) && "T does not store a type");
753  assert(Rep && "no type provided!");
754  if (TypeSpecType == TST_error)
755  return false;
756  if (TypeSpecType != TST_unspecified) {
757  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
758  DiagID = diag::err_invalid_decl_spec_combination;
759  return true;
760  }
761  TypeSpecType = T;
762  TypeRep = Rep;
763  TSTLoc = TagKwLoc;
764  TSTNameLoc = TagNameLoc;
765  TypeSpecOwned = false;
766  return false;
767 }
768 
770  const char *&PrevSpec,
771  unsigned &DiagID,
772  Expr *Rep,
773  const PrintingPolicy &Policy) {
774  assert(isExprRep(T) && "T does not store an expr");
775  assert(Rep && "no expression provided!");
776  if (TypeSpecType == TST_error)
777  return false;
778  if (TypeSpecType != TST_unspecified) {
779  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
780  DiagID = diag::err_invalid_decl_spec_combination;
781  return true;
782  }
783  TypeSpecType = T;
784  ExprRep = Rep;
785  TSTLoc = Loc;
786  TSTNameLoc = Loc;
787  TypeSpecOwned = false;
788  return false;
789 }
790 
792  const char *&PrevSpec,
793  unsigned &DiagID,
794  Decl *Rep, bool Owned,
795  const PrintingPolicy &Policy) {
796  return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Owned, Policy);
797 }
798 
800  SourceLocation TagNameLoc,
801  const char *&PrevSpec,
802  unsigned &DiagID,
803  Decl *Rep, bool Owned,
804  const PrintingPolicy &Policy) {
805  assert(isDeclRep(T) && "T does not store a decl");
806  // Unlike the other cases, we don't assert that we actually get a decl.
807 
808  if (TypeSpecType == TST_error)
809  return false;
810  if (TypeSpecType != TST_unspecified) {
811  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
812  DiagID = diag::err_invalid_decl_spec_combination;
813  return true;
814  }
815  TypeSpecType = T;
816  DeclRep = Rep;
817  TSTLoc = TagKwLoc;
818  TSTNameLoc = TagNameLoc;
819  TypeSpecOwned = Owned && Rep != nullptr;
820  return false;
821 }
822 
823 bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
824  unsigned &DiagID, TemplateIdAnnotation *Rep,
825  const PrintingPolicy &Policy) {
826  assert(T == TST_auto || T == TST_decltype_auto);
827  ConstrainedAuto = true;
828  TemplateIdRep = Rep;
829  return SetTypeSpecType(T, Loc, PrevSpec, DiagID, Policy);
830 }
831 
833  const char *&PrevSpec,
834  unsigned &DiagID,
835  const PrintingPolicy &Policy) {
836  assert(!isDeclRep(T) && !isTypeRep(T) && !isExprRep(T) &&
837  "rep required for these type-spec kinds!");
838  if (TypeSpecType == TST_error)
839  return false;
840  if (TypeSpecType != TST_unspecified) {
841  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
842  DiagID = diag::err_invalid_decl_spec_combination;
843  return true;
844  }
845  TSTLoc = Loc;
846  TSTNameLoc = Loc;
847  if (TypeAltiVecVector && (T == TST_bool) && !TypeAltiVecBool) {
848  TypeAltiVecBool = true;
849  return false;
850  }
851  TypeSpecType = T;
852  TypeSpecOwned = false;
853  return false;
854 }
855 
856 bool DeclSpec::SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec,
857  unsigned &DiagID) {
858  // Cannot set twice
859  if (TypeSpecSat) {
860  DiagID = diag::warn_duplicate_declspec;
861  PrevSpec = "_Sat";
862  return true;
863  }
864  TypeSpecSat = true;
865  TSSatLoc = Loc;
866  return false;
867 }
868 
869 bool DeclSpec::SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
870  const char *&PrevSpec, unsigned &DiagID,
871  const PrintingPolicy &Policy) {
872  if (TypeSpecType == TST_error)
873  return false;
874  if (TypeSpecType != TST_unspecified) {
875  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
876  DiagID = diag::err_invalid_vector_decl_spec_combination;
877  return true;
878  }
879  TypeAltiVecVector = isAltiVecVector;
880  AltiVecLoc = Loc;
881  return false;
882 }
883 
884 bool DeclSpec::SetTypePipe(bool isPipe, SourceLocation Loc,
885  const char *&PrevSpec, unsigned &DiagID,
886  const PrintingPolicy &Policy) {
887  if (TypeSpecType == TST_error)
888  return false;
889  if (TypeSpecType != TST_unspecified) {
890  PrevSpec = DeclSpec::getSpecifierName((TST)TypeSpecType, Policy);
891  DiagID = diag::err_invalid_decl_spec_combination;
892  return true;
893  }
894 
895  if (isPipe) {
896  TypeSpecPipe = static_cast<unsigned>(TypeSpecifiersPipe::Pipe);
897  }
898  return false;
899 }
900 
901 bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
902  const char *&PrevSpec, unsigned &DiagID,
903  const PrintingPolicy &Policy) {
904  if (TypeSpecType == TST_error)
905  return false;
906  if (!TypeAltiVecVector || TypeAltiVecPixel ||
907  (TypeSpecType != TST_unspecified)) {
908  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
909  DiagID = diag::err_invalid_pixel_decl_spec_combination;
910  return true;
911  }
912  TypeAltiVecPixel = isAltiVecPixel;
913  TSTLoc = Loc;
914  TSTNameLoc = Loc;
915  return false;
916 }
917 
918 bool DeclSpec::SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
919  const char *&PrevSpec, unsigned &DiagID,
920  const PrintingPolicy &Policy) {
921  if (TypeSpecType == TST_error)
922  return false;
923  if (!TypeAltiVecVector || TypeAltiVecBool ||
924  (TypeSpecType != TST_unspecified)) {
925  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
926  DiagID = diag::err_invalid_vector_bool_decl_spec;
927  return true;
928  }
929  TypeAltiVecBool = isAltiVecBool;
930  TSTLoc = Loc;
931  TSTNameLoc = Loc;
932  return false;
933 }
934 
936  TypeSpecType = TST_error;
937  TypeSpecOwned = false;
938  TSTLoc = SourceLocation();
939  TSTNameLoc = SourceLocation();
940  return false;
941 }
942 
944  const char *&PrevSpec, unsigned &DiagID,
945  const PrintingPolicy &Policy) {
946  assert(BitsExpr && "no expression provided!");
947  if (TypeSpecType == TST_error)
948  return false;
949 
950  if (TypeSpecType != TST_unspecified) {
951  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
952  DiagID = diag::err_invalid_decl_spec_combination;
953  return true;
954  }
955 
956  TypeSpecType = TST_bitint;
957  ExprRep = BitsExpr;
958  TSTLoc = KWLoc;
959  TSTNameLoc = KWLoc;
960  TypeSpecOwned = false;
961  return false;
962 }
963 
964 bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
965  unsigned &DiagID, const LangOptions &Lang) {
966  // Duplicates are permitted in C99 onwards, but are not permitted in C89 or
967  // C++. However, since this is likely not what the user intended, we will
968  // always warn. We do not need to set the qualifier's location since we
969  // already have it.
970  if (TypeQualifiers & T) {
971  bool IsExtension = true;
972  if (Lang.C99)
973  IsExtension = false;
974  return BadSpecifier(T, T, PrevSpec, DiagID, IsExtension);
975  }
976 
977  return SetTypeQual(T, Loc);
978 }
979 
981  TypeQualifiers |= T;
982 
983  switch (T) {
984  case TQ_unspecified: break;
985  case TQ_const: TQ_constLoc = Loc; return false;
986  case TQ_restrict: TQ_restrictLoc = Loc; return false;
987  case TQ_volatile: TQ_volatileLoc = Loc; return false;
988  case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
989  case TQ_atomic: TQ_atomicLoc = Loc; return false;
990  }
991 
992  llvm_unreachable("Unknown type qualifier!");
993 }
994 
995 bool DeclSpec::setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
996  unsigned &DiagID) {
997  // 'inline inline' is ok. However, since this is likely not what the user
998  // intended, we will always warn, similar to duplicates of type qualifiers.
999  if (FS_inline_specified) {
1000  DiagID = diag::warn_duplicate_declspec;
1001  PrevSpec = "inline";
1002  return true;
1003  }
1004  FS_inline_specified = true;
1005  FS_inlineLoc = Loc;
1006  return false;
1007 }
1008 
1010  unsigned &DiagID) {
1011  if (FS_forceinline_specified) {
1012  DiagID = diag::warn_duplicate_declspec;
1013  PrevSpec = "__forceinline";
1014  return true;
1015  }
1016  FS_forceinline_specified = true;
1017  FS_forceinlineLoc = Loc;
1018  return false;
1019 }
1020 
1022  const char *&PrevSpec,
1023  unsigned &DiagID) {
1024  // 'virtual virtual' is ok, but warn as this is likely not what the user
1025  // intended.
1026  if (FS_virtual_specified) {
1027  DiagID = diag::warn_duplicate_declspec;
1028  PrevSpec = "virtual";
1029  return true;
1030  }
1031  FS_virtual_specified = true;
1032  FS_virtualLoc = Loc;
1033  return false;
1034 }
1035 
1037  const char *&PrevSpec, unsigned &DiagID,
1038  ExplicitSpecifier ExplicitSpec,
1039  SourceLocation CloseParenLoc) {
1040  // 'explicit explicit' is ok, but warn as this is likely not what the user
1041  // intended.
1042  if (hasExplicitSpecifier()) {
1043  DiagID = (ExplicitSpec.getExpr() || FS_explicit_specifier.getExpr())
1044  ? diag::err_duplicate_declspec
1045  : diag::ext_warn_duplicate_declspec;
1046  PrevSpec = "explicit";
1047  return true;
1048  }
1049  FS_explicit_specifier = ExplicitSpec;
1050  FS_explicitLoc = Loc;
1051  FS_explicitCloseParenLoc = CloseParenLoc;
1052  return false;
1053 }
1054 
1056  const char *&PrevSpec,
1057  unsigned &DiagID) {
1058  // '_Noreturn _Noreturn' is ok, but warn as this is likely not what the user
1059  // intended.
1060  if (FS_noreturn_specified) {
1061  DiagID = diag::warn_duplicate_declspec;
1062  PrevSpec = "_Noreturn";
1063  return true;
1064  }
1065  FS_noreturn_specified = true;
1066  FS_noreturnLoc = Loc;
1067  return false;
1068 }
1069 
1070 bool DeclSpec::SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
1071  unsigned &DiagID) {
1072  if (Friend_specified) {
1073  PrevSpec = "friend";
1074  // Keep the later location, so that we can later diagnose ill-formed
1075  // declarations like 'friend class X friend;'. Per [class.friend]p3,
1076  // 'friend' must be the first token in a friend declaration that is
1077  // not a function declaration.
1078  FriendLoc = Loc;
1079  DiagID = diag::warn_duplicate_declspec;
1080  return true;
1081  }
1082 
1083  Friend_specified = true;
1084  FriendLoc = Loc;
1085  return false;
1086 }
1087 
1088 bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
1089  unsigned &DiagID) {
1090  if (isModulePrivateSpecified()) {
1091  PrevSpec = "__module_private__";
1092  DiagID = diag::ext_warn_duplicate_declspec;
1093  return true;
1094  }
1095 
1096  ModulePrivateLoc = Loc;
1097  return false;
1098 }
1099 
1101  SourceLocation Loc, const char *&PrevSpec,
1102  unsigned &DiagID) {
1104  return BadSpecifier(ConstexprKind, getConstexprSpecifier(), PrevSpec,
1105  DiagID);
1106  ConstexprSpecifier = static_cast<unsigned>(ConstexprKind);
1107  ConstexprLoc = Loc;
1108  return false;
1109 }
1110 
1111 void DeclSpec::SaveWrittenBuiltinSpecs() {
1112  writtenBS.Sign = static_cast<int>(getTypeSpecSign());
1113  writtenBS.Width = static_cast<int>(getTypeSpecWidth());
1114  writtenBS.Type = getTypeSpecType();
1115  // Search the list of attributes for the presence of a mode attribute.
1116  writtenBS.ModeAttr = getAttributes().hasAttribute(ParsedAttr::AT_Mode);
1117 }
1118 
1119 /// Finish - This does final analysis of the declspec, rejecting things like
1120 /// "_Imaginary" (lacking an FP type). After calling this method, DeclSpec is
1121 /// guaranteed to be self-consistent, even if an error occurred.
1123  // Before possibly changing their values, save specs as written.
1124  SaveWrittenBuiltinSpecs();
1125 
1126  // Check the type specifier components first. No checking for an invalid
1127  // type.
1128  if (TypeSpecType == TST_error)
1129  return;
1130 
1131  // If decltype(auto) is used, no other type specifiers are permitted.
1132  if (TypeSpecType == TST_decltype_auto &&
1134  TypeSpecComplex != TSC_unspecified ||
1136  TypeAltiVecVector || TypeAltiVecPixel || TypeAltiVecBool ||
1137  TypeQualifiers)) {
1138  const unsigned NumLocs = 9;
1139  SourceLocation ExtraLocs[NumLocs] = {
1140  TSWRange.getBegin(), TSCLoc, TSSLoc,
1141  AltiVecLoc, TQ_constLoc, TQ_restrictLoc,
1142  TQ_volatileLoc, TQ_atomicLoc, TQ_unalignedLoc};
1143  FixItHint Hints[NumLocs];
1144  SourceLocation FirstLoc;
1145  for (unsigned I = 0; I != NumLocs; ++I) {
1146  if (ExtraLocs[I].isValid()) {
1147  if (FirstLoc.isInvalid() ||
1149  FirstLoc))
1150  FirstLoc = ExtraLocs[I];
1151  Hints[I] = FixItHint::CreateRemoval(ExtraLocs[I]);
1152  }
1153  }
1154  TypeSpecWidth = static_cast<unsigned>(TypeSpecifierWidth::Unspecified);
1155  TypeSpecComplex = TSC_unspecified;
1156  TypeSpecSign = static_cast<unsigned>(TypeSpecifierSign::Unspecified);
1157  TypeAltiVecVector = TypeAltiVecPixel = TypeAltiVecBool = false;
1158  TypeQualifiers = 0;
1159  S.Diag(TSTLoc, diag::err_decltype_auto_cannot_be_combined)
1160  << Hints[0] << Hints[1] << Hints[2] << Hints[3]
1161  << Hints[4] << Hints[5] << Hints[6] << Hints[7];
1162  }
1163 
1164  // Validate and finalize AltiVec vector declspec.
1165  if (TypeAltiVecVector) {
1166  // No vector long long without VSX (or ZVector).
1168  !S.Context.getTargetInfo().hasFeature("vsx") &&
1169  !S.getLangOpts().ZVector)
1170  S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_long_decl_spec);
1171 
1172  // No vector __int128 prior to Power8.
1173  if ((TypeSpecType == TST_int128) &&
1174  !S.Context.getTargetInfo().hasFeature("power8-vector"))
1175  S.Diag(TSTLoc, diag::err_invalid_vector_int128_decl_spec);
1176 
1177  if (TypeAltiVecBool) {
1178  // Sign specifiers are not allowed with vector bool. (PIM 2.1)
1180  S.Diag(TSSLoc, diag::err_invalid_vector_bool_decl_spec)
1182  }
1183  // Only char/int are valid with vector bool prior to Power10.
1184  // Power10 adds instructions that produce vector bool data
1185  // for quadwords as well so allow vector bool __int128.
1186  if (((TypeSpecType != TST_unspecified) && (TypeSpecType != TST_char) &&
1187  (TypeSpecType != TST_int) && (TypeSpecType != TST_int128)) ||
1188  TypeAltiVecPixel) {
1189  S.Diag(TSTLoc, diag::err_invalid_vector_bool_decl_spec)
1190  << (TypeAltiVecPixel ? "__pixel" :
1191  getSpecifierName((TST)TypeSpecType, Policy));
1192  }
1193  // vector bool __int128 requires Power10.
1194  if ((TypeSpecType == TST_int128) &&
1195  (!S.Context.getTargetInfo().hasFeature("power10-vector")))
1196  S.Diag(TSTLoc, diag::err_invalid_vector_bool_int128_decl_spec);
1197 
1198  // Only 'short' and 'long long' are valid with vector bool. (PIM 2.1)
1202  S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_bool_decl_spec)
1204 
1205  // Elements of vector bool are interpreted as unsigned. (PIM 2.1)
1206  if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) ||
1207  (TypeSpecType == TST_int128) ||
1209  TypeSpecSign = static_cast<unsigned>(TypeSpecifierSign::Unsigned);
1210  } else if (TypeSpecType == TST_double) {
1211  // vector long double and vector long long double are never allowed.
1212  // vector double is OK for Power7 and later, and ZVector.
1215  S.Diag(TSWRange.getBegin(),
1216  diag::err_invalid_vector_long_double_decl_spec);
1217  else if (!S.Context.getTargetInfo().hasFeature("vsx") &&
1218  !S.getLangOpts().ZVector)
1219  S.Diag(TSTLoc, diag::err_invalid_vector_double_decl_spec);
1220  } else if (TypeSpecType == TST_float) {
1221  // vector float is unsupported for ZVector unless we have the
1222  // vector-enhancements facility 1 (ISA revision 12).
1223  if (S.getLangOpts().ZVector &&
1224  !S.Context.getTargetInfo().hasFeature("arch12"))
1225  S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec);
1226  } else if (getTypeSpecWidth() == TypeSpecifierWidth::Long) {
1227  // Vector long is unsupported for ZVector, or without VSX, and deprecated
1228  // for AltiVec.
1229  // It has also been historically deprecated on AIX (as an alias for
1230  // "vector int" in both 32-bit and 64-bit modes). It was then made
1231  // unsupported in the Clang-based XL compiler since the deprecated type
1232  // has a number of conflicting semantics and continuing to support it
1233  // is a disservice to users.
1234  if (S.getLangOpts().ZVector ||
1235  !S.Context.getTargetInfo().hasFeature("vsx") ||
1236  S.Context.getTargetInfo().getTriple().isOSAIX())
1237  S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_decl_spec);
1238  else
1239  S.Diag(TSWRange.getBegin(),
1240  diag::warn_vector_long_decl_spec_combination)
1241  << getSpecifierName((TST)TypeSpecType, Policy);
1242  }
1243 
1244  if (TypeAltiVecPixel) {
1245  //TODO: perform validation
1246  TypeSpecType = TST_int;
1247  TypeSpecSign = static_cast<unsigned>(TypeSpecifierSign::Unsigned);
1248  TypeSpecWidth = static_cast<unsigned>(TypeSpecifierWidth::Short);
1249  TypeSpecOwned = false;
1250  }
1251  }
1252 
1253  bool IsFixedPointType =
1254  TypeSpecType == TST_accum || TypeSpecType == TST_fract;
1255 
1256  // signed/unsigned are only valid with int/char/wchar_t/_Accum.
1258  if (TypeSpecType == TST_unspecified)
1259  TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
1260  else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 &&
1261  TypeSpecType != TST_char && TypeSpecType != TST_wchar &&
1262  !IsFixedPointType && TypeSpecType != TST_bitint) {
1263  S.Diag(TSSLoc, diag::err_invalid_sign_spec)
1264  << getSpecifierName((TST)TypeSpecType, Policy);
1265  // signed double -> double.
1266  TypeSpecSign = static_cast<unsigned>(TypeSpecifierSign::Unspecified);
1267  }
1268  }
1269 
1270  // Validate the width of the type.
1271  switch (getTypeSpecWidth()) {
1273  break;
1274  case TypeSpecifierWidth::Short: // short int
1275  case TypeSpecifierWidth::LongLong: // long long int
1276  if (TypeSpecType == TST_unspecified)
1277  TypeSpecType = TST_int; // short -> short int, long long -> long long int.
1278  else if (!(TypeSpecType == TST_int ||
1279  (IsFixedPointType &&
1281  S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1282  << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1283  TypeSpecType = TST_int;
1284  TypeSpecSat = false;
1285  TypeSpecOwned = false;
1286  }
1287  break;
1288  case TypeSpecifierWidth::Long: // long double, long int
1289  if (TypeSpecType == TST_unspecified)
1290  TypeSpecType = TST_int; // long -> long int.
1291  else if (TypeSpecType != TST_int && TypeSpecType != TST_double &&
1292  !IsFixedPointType) {
1293  S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1294  << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1295  TypeSpecType = TST_int;
1296  TypeSpecSat = false;
1297  TypeSpecOwned = false;
1298  }
1299  break;
1300  }
1301 
1302  // TODO: if the implementation does not implement _Complex or _Imaginary,
1303  // disallow their use. Need information about the backend.
1304  if (TypeSpecComplex != TSC_unspecified) {
1305  if (TypeSpecType == TST_unspecified) {
1306  S.Diag(TSCLoc, diag::ext_plain_complex)
1309  " double");
1310  TypeSpecType = TST_double; // _Complex -> _Complex double.
1311  } else if (TypeSpecType == TST_int || TypeSpecType == TST_char ||
1312  TypeSpecType == TST_bitint) {
1313  // Note that this intentionally doesn't include _Complex _Bool.
1314  if (!S.getLangOpts().CPlusPlus)
1315  S.Diag(TSTLoc, diag::ext_integer_complex);
1316  } else if (TypeSpecType != TST_float && TypeSpecType != TST_double &&
1317  TypeSpecType != TST_float128 && TypeSpecType != TST_float16 &&
1318  TypeSpecType != TST_ibm128) {
1319  // FIXME: __fp16?
1320  S.Diag(TSCLoc, diag::err_invalid_complex_spec)
1321  << getSpecifierName((TST)TypeSpecType, Policy);
1322  TypeSpecComplex = TSC_unspecified;
1323  }
1324  }
1325 
1326  // C11 6.7.1/3, C++11 [dcl.stc]p1, GNU TLS: __thread, thread_local and
1327  // _Thread_local can only appear with the 'static' and 'extern' storage class
1328  // specifiers. We also allow __private_extern__ as an extension.
1329  if (ThreadStorageClassSpec != TSCS_unspecified) {
1330  switch (StorageClassSpec) {
1331  case SCS_unspecified:
1332  case SCS_extern:
1333  case SCS_private_extern:
1334  case SCS_static:
1335  break;
1336  default:
1340  diag::err_invalid_decl_spec_combination)
1343  else
1345  diag::err_invalid_decl_spec_combination)
1348  // Discard the thread storage class specifier to recover.
1349  ThreadStorageClassSpec = TSCS_unspecified;
1350  ThreadStorageClassSpecLoc = SourceLocation();
1351  }
1352  }
1353 
1354  // If no type specifier was provided and we're parsing a language where
1355  // the type specifier is not optional, but we got 'auto' as a storage
1356  // class specifier, then assume this is an attempt to use C++0x's 'auto'
1357  // type specifier.
1358  if (S.getLangOpts().CPlusPlus &&
1359  TypeSpecType == TST_unspecified && StorageClassSpec == SCS_auto) {
1360  TypeSpecType = TST_auto;
1361  StorageClassSpec = SCS_unspecified;
1362  TSTLoc = TSTNameLoc = StorageClassSpecLoc;
1363  StorageClassSpecLoc = SourceLocation();
1364  }
1365  // Diagnose if we've recovered from an ill-formed 'auto' storage class
1366  // specifier in a pre-C++11 dialect of C++.
1367  if (!S.getLangOpts().CPlusPlus11 && TypeSpecType == TST_auto)
1368  S.Diag(TSTLoc, diag::ext_auto_type_specifier);
1369  if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11 &&
1370  StorageClassSpec == SCS_auto)
1371  S.Diag(StorageClassSpecLoc, diag::warn_auto_storage_class)
1372  << FixItHint::CreateRemoval(StorageClassSpecLoc);
1373  if (TypeSpecType == TST_char8)
1374  S.Diag(TSTLoc, diag::warn_cxx17_compat_unicode_type);
1375  else if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32)
1376  S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type)
1377  << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
1379  S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr);
1381  S.Diag(ConstexprLoc, diag::warn_cxx20_compat_consteval);
1383  S.Diag(ConstexprLoc, diag::warn_cxx20_compat_constinit);
1384  // C++ [class.friend]p6:
1385  // No storage-class-specifier shall appear in the decl-specifier-seq
1386  // of a friend declaration.
1387  if (isFriendSpecified() &&
1389  SmallString<32> SpecName;
1390  SourceLocation SCLoc;
1391  FixItHint StorageHint, ThreadHint;
1392 
1393  if (DeclSpec::SCS SC = getStorageClassSpec()) {
1394  SpecName = getSpecifierName(SC);
1395  SCLoc = getStorageClassSpecLoc();
1396  StorageHint = FixItHint::CreateRemoval(SCLoc);
1397  }
1398 
1400  if (!SpecName.empty()) SpecName += " ";
1401  SpecName += getSpecifierName(TSC);
1402  SCLoc = getThreadStorageClassSpecLoc();
1403  ThreadHint = FixItHint::CreateRemoval(SCLoc);
1404  }
1405 
1406  S.Diag(SCLoc, diag::err_friend_decl_spec)
1407  << SpecName << StorageHint << ThreadHint;
1408 
1410  }
1411 
1412  // C++11 [dcl.fct.spec]p5:
1413  // The virtual specifier shall be used only in the initial
1414  // declaration of a non-static class member function;
1415  // C++11 [dcl.fct.spec]p6:
1416  // The explicit specifier shall be used only in the declaration of
1417  // a constructor or conversion function within its class
1418  // definition;
1420  StringRef Keyword;
1421  FixItHint Hint;
1422  SourceLocation SCLoc;
1423 
1424  if (isVirtualSpecified()) {
1425  Keyword = "virtual";
1426  SCLoc = getVirtualSpecLoc();
1427  Hint = FixItHint::CreateRemoval(SCLoc);
1428  } else {
1429  Keyword = "explicit";
1430  SCLoc = getExplicitSpecLoc();
1432  }
1433 
1434  S.Diag(SCLoc, diag::err_friend_decl_spec)
1435  << Keyword << Hint;
1436 
1437  FS_virtual_specified = false;
1438  FS_explicit_specifier = ExplicitSpecifier();
1439  FS_virtualLoc = FS_explicitLoc = SourceLocation();
1440  }
1441 
1442  assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
1443 
1444  // Okay, now we can infer the real type.
1445 
1446  // TODO: return "auto function" and other bad things based on the real type.
1447 
1448  // 'data definition has no type or storage class'?
1449 }
1450 
1452  TST tst = getTypeSpecType();
1453  return isDeclRep(tst) && getRepAsDecl() != nullptr &&
1454  StorageClassSpec != DeclSpec::SCS_typedef;
1455 }
1456 
1459  SourceLocation SymbolLocations[3]) {
1461  StartLocation = OperatorLoc;
1462  EndLocation = OperatorLoc;
1463  new (&OperatorFunctionId) struct OFI;
1465  for (unsigned I = 0; I != 3; ++I) {
1466  OperatorFunctionId.SymbolLocations[I] = SymbolLocations[I];
1467 
1468  if (SymbolLocations[I].isValid())
1469  EndLocation = SymbolLocations[I];
1470  }
1471 }
1472 
1474  const char *&PrevSpec) {
1475  if (!FirstLocation.isValid())
1476  FirstLocation = Loc;
1477  LastLocation = Loc;
1478  LastSpecifier = VS;
1479 
1480  if (Specifiers & VS) {
1481  PrevSpec = getSpecifierName(VS);
1482  return true;
1483  }
1484 
1485  Specifiers |= VS;
1486 
1487  switch (VS) {
1488  default: llvm_unreachable("Unknown specifier!");
1489  case VS_Override: VS_overrideLoc = Loc; break;
1490  case VS_GNU_Final:
1491  case VS_Sealed:
1492  case VS_Final: VS_finalLoc = Loc; break;
1493  case VS_Abstract: VS_abstractLoc = Loc; break;
1494  }
1495 
1496  return false;
1497 }
1498 
1500  switch (VS) {
1501  default: llvm_unreachable("Unknown specifier");
1502  case VS_Override: return "override";
1503  case VS_Final: return "final";
1504  case VS_GNU_Final: return "__final";
1505  case VS_Sealed: return "sealed";
1506  case VS_Abstract: return "abstract";
1507  }
1508 }
clang::TypeSpecifierWidth::LongLong
@ LongLong
clang::SourceRange::setBegin
void setBegin(SourceLocation b)
Definition: SourceLocation.h:222
clang::ExplicitSpecifier
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1830
clang::DeclSpec::getVirtualSpecLoc
SourceLocation getVirtualSpecLoc() const
Definition: DeclSpec.h:599
clang::TST_half
@ TST_half
Definition: Specifiers.h:63
clang::Declarator::isDeclarationOfFunction
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
Definition: DeclSpec.cpp:325
clang::DeclaratorChunk::FunctionTypeInfo::NumParams
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1338
clang::DeclaratorChunk::Pointer
@ Pointer
Definition: DeclSpec.h:1200
clang::DeclSpec::SetTypeQual
bool SetTypeQual(TQ T, SourceLocation Loc)
Definition: DeclSpec.cpp:980
clang::DeclaratorChunk::EndLoc
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
Definition: DeclSpec.h:1206
clang::DeclaratorChunk::FunctionTypeInfo::hasPrototype
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
Definition: DeclSpec.h:1303
clang::Declarator::getName
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
Definition: DeclSpec.h:1988
clang::OpaquePtr::get
PtrTy get() const
Definition: Ownership.h:80
clang::TST_Float16
@ TST_Float16
Definition: Specifiers.h:64
clang::DeclaratorChunk::FunctionTypeInfo::RefQualifierLoc
SourceLocation RefQualifierLoc
The location of the ref-qualifier, if any.
Definition: DeclSpec.h:1348
clang::TST_char8
@ TST_char8
Definition: Specifiers.h:57
clang::TST_bool
@ TST_bool
Definition: Specifiers.h:72
clang::VirtSpecifiers::VS_GNU_Final
@ VS_GNU_Final
Definition: DeclSpec.h:2695
clang::DeclSpec::TSC_unspecified
@ TSC_unspecified
Definition: DeclSpec.h:254
Specifiers.h
clang::DeclSpec::TST_typeof_unqualExpr
static const TST TST_typeof_unqualExpr
Definition: DeclSpec.h:293
clang::UnqualifiedId::TemplateId
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
Definition: DeclSpec.h:1025
clang::DeclSpec::SetTypeSpecComplex
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:719
clang::TemplateIdAnnotation
Information about a template-id annotation token.
Definition: ParsedTemplate.h:149
clang::UnqualifiedIdKind::IK_OperatorFunctionId
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
clang::DeclSpec::TQ_unspecified
@ TQ_unspecified
Definition: DeclSpec.h:310
clang::DeclSpec::TST_unknown_anytype
static const TST TST_unknown_anytype
Definition: DeclSpec.h:301
clang::LangOptions::getOpenCLCompatibleVersion
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Definition: LangOptions.cpp:55
clang::CXXScopeSpec::Adopt
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:132
clang::DeclaratorChunk::FunctionTypeInfo::ExceptionSpecType
unsigned ExceptionSpecType
ExceptionSpecType - An ExceptionSpecificationType value.
Definition: DeclSpec.h:1318
clang::DeclSpec::TST_enum
static const TST TST_enum
Definition: DeclSpec.h:284
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::Declarator::InlineParams
DeclaratorChunk::ParamInfo InlineParams[16]
InlineParams - This is a local array used for the first function decl chunk to avoid going to the hea...
Definition: DeclSpec.h:1912
clang::UnqualifiedId::OperatorFunctionId
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
Definition: DeclSpec.h:1005
clang::TST_interface
@ TST_interface
Definition: Specifiers.h:80
clang::WrittenBuiltinSpecs::Sign
unsigned Sign
Definition: Specifiers.h:104
clang::FixItHint::CreateInsertion
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Definition: Diagnostic.h:97
clang::NamespaceAliasDecl
Represents a C++ namespace alias.
Definition: DeclCXX.h:3021
clang::TypeSpecifierSign
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:47
clang::DeclSpec::getExplicitSpecLoc
SourceLocation getExplicitSpecLoc() const
Definition: DeclSpec.h:604
clang::TST_unspecified
@ TST_unspecified
Definition: Specifiers.h:53
clang::DeclSpec::getExplicitSpecRange
SourceRange getExplicitSpecRange() const
Definition: DeclSpec.h:605
clang::TST_typename
@ TST_typename
Definition: Specifiers.h:81
clang::DeclSpec::getAttributes
ParsedAttributes & getAttributes()
Definition: DeclSpec.h:818
clang::NestedNameSpecifierLocBuilder::Adopt
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: NestedNameSpecifier.cpp:672
clang::DeclSpec::SetTypeSpecError
bool SetTypeSpecError()
Definition: DeclSpec.cpp:935
clang::UnqualifiedId::setTemplateId
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
Definition: DeclSpec.cpp:32
clang::DeclSpec::SCS_static
@ SCS_static
Definition: DeclSpec.h:238
llvm::SmallVector< Token, 4 >
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::DeclSpec::TST_error
static const TST TST_error
Definition: DeclSpec.h:306
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::DeclSpec::setFunctionSpecInline
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:995
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::TST_void
@ TST_void
Definition: Specifiers.h:54
clang::DeclSpec::TSC_complex
@ TSC_complex
Definition: DeclSpec.h:256
TargetInfo.h
clang::DeclSpec::getRepAsExpr
Expr * getRepAsExpr() const
Definition: DeclSpec.h:513
clang::DeclSpec::setFunctionSpecExplicit
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, ExplicitSpecifier ExplicitSpec, SourceLocation CloseParenLoc)
Definition: DeclSpec.cpp:1036
clang::TypeSpecifierWidth::Unspecified
@ Unspecified
clang::DeclaratorChunk::FunctionTypeInfo::TrailingReturnType
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
Definition: DeclSpec.h:1393
clang::UnqualifiedId::OFI::Operator
OverloadedOperatorKind Operator
The kind of overloaded operator.
Definition: DeclSpec.h:984
clang::DeclSpec::SCS_auto
@ SCS_auto
Definition: DeclSpec.h:239
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::DeclSpec::SetBitIntType
bool SetBitIntType(SourceLocation KWLoc, Expr *BitWidth, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:943
clang::DeclSpec::SetTypeAltiVecPixel
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:901
clang::EST_None
@ EST_None
no exception specification
Definition: ExceptionSpecificationType.h:21
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::TST_struct
@ TST_struct
Definition: Specifiers.h:78
clang::DeclaratorChunk::Fun
FunctionTypeInfo Fun
Definition: DeclSpec.h:1575
clang::EST_Dynamic
@ EST_Dynamic
throw(T1, T2)
Definition: ExceptionSpecificationType.h:23
clang::Declarator::getContext
DeclaratorContext getContext() const
Definition: DeclSpec.h:1994
clang::Sema::Diag
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: Sema.cpp:1887
DeclCXX.h
int
__device__ int
Definition: __clang_hip_libdevice_declares.h:63
clang::VirtSpecifiers::Specifier
Specifier
Definition: DeclSpec.h:2689
clang::ParsedAttributesView::size
SizeType size() const
Definition: ParsedAttr.h:933
clang::VirtSpecifiers::getSpecifierName
static const char * getSpecifierName(Specifier VS)
Definition: DeclSpec.cpp:1499
clang::Sema::getSourceManager
SourceManager & getSourceManager() const
Definition: Sema.h:1635
clang::DeclSpec::isFriendSpecified
FriendSpecified isFriendSpecified() const
Definition: DeclSpec.h:768
clang::LocInfoType
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
Definition: LocInfoType.h:28
clang::TST_enum
@ TST_enum
Definition: Specifiers.h:76
clang::TST_error
@ TST_error
Definition: Specifiers.h:96
clang::NestedNameSpecifierLoc::getLocalBeginLoc
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Definition: NestedNameSpecifier.h:311
clang::DeclSpec::SCS
SCS
storage-class-specifier
Definition: DeclSpec.h:234
clang::DeclSpec::SCS_unspecified
@ SCS_unspecified
Definition: DeclSpec.h:235
clang::TargetInfo::hasFeature
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
Definition: TargetInfo.h:1380
clang::DeclSpec::getParsedSpecifiers
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
Definition: DeclSpec.cpp:455
clang::DeclSpec::hasExplicitSpecifier
bool hasExplicitSpecifier() const
Definition: DeclSpec.h:601
clang::DeclSpec::TQ_volatile
@ TQ_volatile
Definition: DeclSpec.h:313
SourceManager.h
clang::TST_auto
@ TST_auto
Definition: Specifiers.h:89
clang::EST_Unparsed
@ EST_Unparsed
not parsed yet
Definition: ExceptionSpecificationType.h:32
clang::DeclaratorChunk::FunctionTypeInfo::DeleteParams
unsigned DeleteParams
DeleteParams - If this is true, we need to delete[] Params.
Definition: DeclSpec.h:1321
DeclSpec.h
clang::DeclaratorChunk::FunctionTypeInfo::ExceptionSpecLocBeg
SourceLocation ExceptionSpecLocBeg
The beginning location of the exception specification, if any.
Definition: DeclSpec.h:1355
clang::OpenCLOptions::isAvailableOption
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
Definition: OpenCLOptions.cpp:32
clang::DeclSpec::TQ_unaligned
@ TQ_unaligned
Definition: DeclSpec.h:314
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::DeclSpec::TQ_atomic
@ TQ_atomic
Definition: DeclSpec.h:317
LocInfoType.h
clang::ParsedAttributesView::hasAttribute
bool hasAttribute(ParsedAttr::Kind K) const
Definition: ParsedAttr.h:1007
Identifier
StringRef Identifier
Definition: Format.cpp:2723
clang::NestedNameSpecifierLocBuilder::MakeGlobal
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: NestedNameSpecifier.cpp:611
clang::DeclaratorChunk::FunctionTypeInfo::ExceptionSpecTokens
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed.
Definition: DeclSpec.h:1383
clang::DeclaratorChunk::Function
@ Function
Definition: DeclSpec.h:1200
clang::DeclSpec::getTypeSpecComplexLoc
SourceLocation getTypeSpecComplexLoc() const
Definition: DeclSpec.h:531
clang::TST_auto_type
@ TST_auto_type
Definition: Specifiers.h:91
clang::UnqualifiedId::setConstructorTemplateId
void setConstructorTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id that names a constructor.
Definition: DeclSpec.cpp:43
clang::DeclSpec::getSpecifierName
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
Definition: DeclSpec.cpp:545
clang::TST_unknown_anytype
@ TST_unknown_anytype
Definition: Specifiers.h:92
clang::DeclaratorChunk::FunctionTypeInfo::QualAttrFactory
AttributeFactory * QualAttrFactory
AttributeFactory for the MethodQualifiers.
Definition: DeclSpec.h:1369
clang::DeclaratorChunk::FunctionTypeInfo::EllipsisLoc
SourceLocation EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
Definition: DeclSpec.h:1331
clang::DeclSpec::SetFriendSpec
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:1070
clang::DeclSpec::TSCS_unspecified
static const TSCS TSCS_unspecified
Definition: DeclSpec.h:248
clang::DeclaratorChunk::getFunction
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
Definition: DeclSpec.cpp:161
clang::CXXScopeSpec::MakeSuper
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition: DeclSpec.cpp:114
clang::VirtSpecifiers::VS_Override
@ VS_Override
Definition: DeclSpec.h:2691
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:409
clang::VirtSpecifiers::VS_Sealed
@ VS_Sealed
Definition: DeclSpec.h:2693
clang::Declarator::isStaticMember
bool isStaticMember()
Returns true if this declares a static member.
Definition: DeclSpec.cpp:415
clang::DecompositionDeclarator::Binding
Definition: DeclSpec.h:1727
clang::DeclSpec::TST_float
static const TST TST_float
Definition: DeclSpec.h:273
clang::UnqualifiedId::StartLocation
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Definition: DeclSpec.h:1031
clang::ConstexprSpecKind::Constinit
@ Constinit
clang::TypeLoc::getBeginLoc
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
clang::FixItHint
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
Definition: Diagnostic.h:71
clang::Sema::getLangOpts
const LangOptions & getLangOpts() const
Definition: Sema.h:1630
clang::EST_DependentNoexcept
@ EST_DependentNoexcept
noexcept(expression), value-dependent
Definition: ExceptionSpecificationType.h:27
clang::DeclSpec::TST_char8
static const TST TST_char8
Definition: DeclSpec.h:265
clang::DeclSpec::PQ_TypeSpecifier
@ PQ_TypeSpecifier
Definition: DeclSpec.h:325
clang::Declarator::getDeclSpec
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:1969
clang::EST_NoexceptTrue
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
Definition: ExceptionSpecificationType.h:29
clang::DeclSpec::TST_accum
static const TST TST_accum
Definition: DeclSpec.h:276
clang::AttributePool::takeAllFrom
void takeAllFrom(AttributePool &pool)
Take the given pool's allocations and add them to this pool.
Definition: ParsedAttr.h:834
clang::DeclSpec::SetTypeSpecSign
bool SetTypeSpecSign(TypeSpecifierSign S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:729
clang::DeclSpec::setFunctionSpecForceInline
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:1009
clang::TST_typeof_unqualType
@ TST_typeof_unqualType
Definition: Specifiers.h:84
clang::NestedNameSpecifierLocBuilder::Clear
void Clear()
Clear out this builder, and prepare it to build another nested-name-specifier with source-location in...
Definition: NestedNameSpecifier.h:505
clang::DeclSpec::SetConstexprSpec
bool SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:1100
clang::DeclSpec::getTypeSpecSign
TypeSpecifierSign getTypeSpecSign() const
Definition: DeclSpec.h:492
clang::DeclaratorChunk::BlockPointer
@ BlockPointer
Definition: DeclSpec.h:1200
BadSpecifier
static bool BadSpecifier(T TNew, T TPrev, const char *&PrevSpec, unsigned &DiagID, bool IsExtension=true)
Definition: DeclSpec.cpp:473
clang::DeclaratorChunk::FunctionTypeInfo::Exceptions
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Definition: DeclSpec.h:1375
clang::DeclSpec::hasTypeSpecifier
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Definition: DeclSpec.h:641
clang::ThreadStorageClassSpecifier
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:223
clang::DeclaratorChunk::TypeAndRange
Definition: DeclSpec.h:1294
clang::DeclSpec::getTypeSpecType
TST getTypeSpecType() const
Definition: DeclSpec.h:495
clang::ConstexprSpecKind::Consteval
@ Consteval
clang::ExceptionSpecificationType
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Definition: ExceptionSpecificationType.h:20
clang::TST_decltype
@ TST_decltype
Definition: Specifiers.h:86
clang::TypeSpecifierSign::Signed
@ Signed
clang::TemplateIdAnnotation::RAngleLoc
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
Definition: ParsedTemplate.h:182
clang::CXXScopeSpec::Extend
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
Definition: DeclSpec.cpp:54
clang::Declarator::hasName
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Definition: DeclSpec.h:2241
clang::DeclSpec::TST_interface
static const TST TST_interface
Definition: DeclSpec.h:287
clang::DeclSpec::TST_char
static const TST TST_char
Definition: DeclSpec.h:263
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:220
clang::DeclSpec::TST_double
static const TST TST_double
Definition: DeclSpec.h:274
clang::DeclSpec::PQ_TypeQualifier
@ PQ_TypeQualifier
Definition: DeclSpec.h:326
clang::DeclSpec::TST_BFloat16
static const TST TST_BFloat16
Definition: DeclSpec.h:272
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::VirtSpecifiers::VS_Abstract
@ VS_Abstract
Definition: DeclSpec.h:2696
clang::DeclaratorContext::Member
@ Member
LangOptions.h
clang::DeclaratorChunk::FunctionTypeInfo::DeclsInPrototype
NamedDecl ** DeclsInPrototype
Pointer to a new[]'d array of declarations that need to be available for lookup inside the function b...
Definition: DeclSpec.h:1388
clang::DeclaratorChunk::TypeAndRange::Ty
ParsedType Ty
Definition: DeclSpec.h:1295
clang::NestedNameSpecifierLoc::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Definition: NestedNameSpecifier.cpp:410
clang::DeclaratorChunk::FunctionTypeInfo::isVariadic
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)',...
Definition: DeclSpec.h:1308
clang::DeclaratorChunk::FunctionTypeInfo
Definition: DeclSpec.h:1299
clang::DeclSpec::ClearStorageClassSpecs
void ClearStorageClassSpecs()
Definition: DeclSpec.h:473
clang::TST_atomic
@ TST_atomic
Definition: Specifiers.h:93
clang::DeclaratorChunk::Array
@ Array
Definition: DeclSpec.h:1200
clang::DeclaratorChunk::FunctionTypeInfo::NoexceptExpr
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1379
clang::DeclSpec::TST_decimal32
static const TST TST_decimal32
Definition: DeclSpec.h:281
clang::DeclSpec::TST_class
static const TST TST_class
Definition: DeclSpec.h:288
clang::DeclSpec::SCS_typedef
@ SCS_typedef
Definition: DeclSpec.h:236
clang::RISCV::Policy
Policy
Definition: RISCVVIntrinsicUtils.h:96
clang::DeclSpec::hasTagDefinition
bool hasTagDefinition() const
Definition: DeclSpec.cpp:446
clang::DeclaratorChunk::MemberPointer
@ MemberPointer
Definition: DeclSpec.h:1200
clang::TypeSpecifierSign::Unspecified
@ Unspecified
clang::WrittenBuiltinSpecs::Type
unsigned Type
Definition: Specifiers.h:102
clang::DeclSpec::TST_fract
static const TST TST_fract
Definition: DeclSpec.h:277
clang::DeclaratorChunk::TypeAndRange::Range
SourceRange Range
Definition: DeclSpec.h:1296
clang::DeclSpec::SetTypePipe
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:884
clang::NestedNameSpecifierLocBuilder::MakeSuper
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition: NestedNameSpecifier.cpp:620
clang::Type::isFunctionType
bool isFunctionType() const
Definition: Type.h:6879
clang::UnqualifiedIdKind::IK_ConstructorName
@ IK_ConstructorName
A constructor name.
Expr.h
llvm::SmallString< 32 >
clang::DeclSpec::setFunctionSpecVirtual
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:1021
ASTContext.h
clang::VirtSpecifiers::VS_Final
@ VS_Final
Definition: DeclSpec.h:2692
clang::DeclSpec::TST_typeof_unqualType
static const TST TST_typeof_unqualType
Definition: DeclSpec.h:292
clang::ConstexprSpecKind::Constexpr
@ Constexpr
clang::NestedNameSpecifierLocBuilder::getTemporary
NestedNameSpecifierLoc getTemporary() const
Retrieve a nested-name-specifier with location information based on the information in this builder.
Definition: NestedNameSpecifier.h:499
clang::SourceRange::setEnd
void setEnd(SourceLocation e)
Definition: SourceLocation.h:223
clang::DeclSpec::getStorageClassSpec
SCS getStorageClassSpec() const
Definition: DeclSpec.h:459
isInvalid
static bool isInvalid(LocType Loc, bool *Invalid)
Definition: SourceManager.cpp:1233
clang::TST_char
@ TST_char
Definition: Specifiers.h:55
clang::UnqualifiedId::OFI
Definition: DeclSpec.h:982
clang::Sema::getLocForEndOfToken
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:56
clang::TST_int
@ TST_int
Definition: Specifiers.h:60
clang::TST_int128
@ TST_int128
Definition: Specifiers.h:61
clang::DeclSpec::SetStorageClassSpec
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
Definition: DeclSpec.cpp:626
clang::DeclSpec::TST_union
static const TST TST_union
Definition: DeclSpec.h:285
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::DeclSpec::SCS_register
@ SCS_register
Definition: DeclSpec.h:240
clang::DeclaratorChunk::FunctionTypeInfo::Params
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1363
clang::DeclSpec::getThreadStorageClassSpecLoc
SourceLocation getThreadStorageClassSpecLoc() const
Definition: DeclSpec.h:469
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:1024
clang::DeclSpec::SCS_mutable
@ SCS_mutable
Definition: DeclSpec.h:242
Sema.h
clang::DeclSpec::isTypeRep
bool isTypeRep() const
Definition: DeclSpec.h:500
clang::DeclSpec::setFunctionSpecNoreturn
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:1055
clang::DeclaratorChunk::FunctionTypeInfo::isAmbiguous
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
Definition: DeclSpec.h:1311
clang::Sema::getOpenCLOptions
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:1631
clang::CXXScopeSpec::getWithLocInContext
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition: DeclSpec.cpp:152
clang::OverloadedOperatorKind
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
clang::NestedNameSpecifierLocBuilder::Extend
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
Definition: NestedNameSpecifier.cpp:563
clang::DeclSpec::DeclRep
Decl * DeclRep
Definition: DeclSpec.h:372
clang::DeclSpec::TSC
TSC
Definition: DeclSpec.h:253
clang::Declarator::SetIdentifier
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
Definition: DeclSpec.h:2260
clang::DeclSpec::TST_decimal64
static const TST TST_decimal64
Definition: DeclSpec.h:282
clang::SourceManager::isBeforeInTranslationUnit
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
Definition: SourceManager.cpp:2026
clang::DeclSpec::TST_ibm128
static const TST TST_ibm128
Definition: DeclSpec.h:279
clang::TST_decimal32
@ TST_decimal32
Definition: Specifiers.h:73
clang::OpaquePtr< QualType >
clang::DeclSpec::TST_int
static const TST TST_int
Definition: DeclSpec.h:268
clang::ExplicitSpecifier::getExpr
const Expr * getExpr() const
Definition: DeclCXX.h:1839
clang::DeclSpec::getStorageClassSpecLoc
SourceLocation getStorageClassSpecLoc() const
Definition: DeclSpec.h:468
clang::ConstexprSpecKind
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition: Specifiers.h:32
clang::TargetInfo::getTriple
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:1197
clang::ParsedAttributes::takeAllFrom
void takeAllFrom(ParsedAttributes &Other)
Definition: ParsedAttr.h:1030
clang::TST_float
@ TST_float
Definition: Specifiers.h:68
clang::DeclSpec::TST_int128
static const TST TST_int128
Definition: DeclSpec.h:269
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::DeclaratorChunk::FunctionTypeInfo::TrailingReturnTypeLoc
SourceLocation TrailingReturnTypeLoc
If HasTrailingReturnType is true, this is the location of the trailing return type.
Definition: DeclSpec.h:1397
clang::TST_typeofExpr
@ TST_typeofExpr
Definition: Specifiers.h:83
clang::DeclaratorChunk::ParamInfo
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
Definition: DeclSpec.h:1274
clang::TypeSpecifiersPipe::Pipe
@ Pipe
clang::UnqualifiedIdKind::IK_TemplateId
@ IK_TemplateId
A template-id, e.g., f<int>.
clang::DeclaratorChunk::FunctionTypeInfo::MethodQualifiers
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
Definition: DeclSpec.h:1366
clang::DeclaratorChunk::Paren
@ Paren
Definition: DeclSpec.h:1200
clang::TemplateIdAnnotation::TemplateNameLoc
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
Definition: ParsedTemplate.h:159
clang::TST_Accum
@ TST_Accum
Definition: Specifiers.h:65
clang::DeclSpec::TST_bitint
static const TST TST_bitint
Definition: DeclSpec.h:270
clang::DeclSpec::TST_decimal128
static const TST TST_decimal128
Definition: DeclSpec.h:283
clang::DeclSpec::isDeclRep
static bool isDeclRep(TST T)
Definition: DeclSpec.h:427
clang::ActionResult::get
PtrTy get() const
Definition: Ownership.h:169
SemaDiagnostic.h
clang::DeclSpec::isModulePrivateSpecified
bool isModulePrivateSpecified() const
Definition: DeclSpec.h:774
clang::DeclSpec::isMissingDeclaratorOk
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
Definition: DeclSpec.cpp:1451
clang::DeclaratorChunk::FunctionTypeInfo::LParenLoc
SourceLocation LParenLoc
The location of the left parenthesis in the source.
Definition: DeclSpec.h:1328
clang::DeclSpec::forEachQualifier
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
Definition: DeclSpec.cpp:440
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:802
clang::TST_decimal64
@ TST_decimal64
Definition: Specifiers.h:74
clang::DeclSpec::TST_float16
static const TST TST_float16
Definition: DeclSpec.h:275
llvm::ArrayRef
Definition: LLVM.h:34
clang::DeclSpec::TST_typename
static const TST TST_typename
Definition: DeclSpec.h:289
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::DeclSpec::PQ_FunctionSpecifier
@ PQ_FunctionSpecifier
Definition: DeclSpec.h:327
clang::DeclSpec::TST_typeofType
static const TST TST_typeofType
Definition: DeclSpec.h:290
clang::DeclSpec::TST_half
static const TST TST_half
Definition: DeclSpec.h:271
clang::DeclSpec::TST_decltype_auto
static const TST TST_decltype_auto
Definition: DeclSpec.h:295
clang::DeclSpec::getTypeSpecWidth
TypeSpecifierWidth getTypeSpecWidth() const
Definition: DeclSpec.h:488
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
clang::ActionResult::isInvalid
bool isInvalid() const
Definition: Ownership.h:165
clang::DeclSpec::SCS_private_extern
@ SCS_private_extern
Definition: DeclSpec.h:241
clang::UnqualifiedIdKind::IK_DestructorName
@ IK_DestructorName
A destructor name.
clang::DeclaratorChunk::Loc
SourceLocation Loc
Loc - The place where this type was defined.
Definition: DeclSpec.h:1204
clang::Declarator::setDecompositionBindings
void setDecompositionBindings(SourceLocation LSquareLoc, ArrayRef< DecompositionDeclarator::Binding > Bindings, SourceLocation RSquareLoc)
Set the decomposition bindings for this declarator.
Definition: DeclSpec.cpp:294
clang::CXXScopeSpec::MakeGlobal
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: DeclSpec.cpp:104
clang::CXXMethodDecl::isStaticOverloadedOperator
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Definition: DeclCXX.h:2014
clang::NestedNameSpecifierLocBuilder::getRepresentation
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
Definition: NestedNameSpecifier.h:390
clang::DeclSpec::TST_decltype
static const TST TST_decltype
Definition: DeclSpec.h:294
clang::TST_wchar
@ TST_wchar
Definition: Specifiers.h:56
clang::DeclSpec::SetTypeSpecSat
bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:856
clang::DeclSpec::getConstexprSpecifier
ConstexprSpecKind getConstexprSpecifier() const
Definition: DeclSpec.h:777
clang::UnqualifiedId::EndLocation
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
Definition: DeclSpec.h:1034
clang::NestedNameSpecifierLocBuilder::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covered by this nested-name-specifier.
Definition: NestedNameSpecifier.h:483
clang::TST_typeof_unqualExpr
@ TST_typeof_unqualExpr
Definition: Specifiers.h:85
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::TST_decimal128
@ TST_decimal128
Definition: Specifiers.h:75
clang::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:773
clang::DeclSpec::setModulePrivateSpec
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:1088
clang::TypeSpecifierWidth
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:44
clang::DeclSpec::TST_float128
static const TST TST_float128
Definition: DeclSpec.h:278
clang::DeclaratorChunk::FunctionTypeInfo::RParenLoc
SourceLocation RParenLoc
The location of the right parenthesis in the source.
Definition: DeclSpec.h:1334
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:81
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::ActionResult
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
Definition: Ownership.h:152
clang::TST_ibm128
@ TST_ibm128
Definition: Specifiers.h:71
clang::DeclSpec::getRepAsDecl
Decl * getRepAsDecl() const
Definition: DeclSpec.h:509
clang::DeclSpec::TST_void
static const TST TST_void
Definition: DeclSpec.h:262
clang::DeclaratorChunk::FunctionTypeInfo::RefQualifierIsLValueRef
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
Definition: DeclSpec.h:1315
clang::DeclaratorChunk::FunctionTypeInfo::HasTrailingReturnType
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
Definition: DeclSpec.h:1325
clang::DeclSpec::TST_bool
static const TST TST_bool
Definition: DeclSpec.h:280
clang::TST_class
@ TST_class
Definition: Specifiers.h:79
clang::DeclSpec::TST_char32
static const TST TST_char32
Definition: DeclSpec.h:267
clang::DeclSpec::TST_unspecified
static const TST TST_unspecified
Definition: DeclSpec.h:261
clang::TypeSpecifierSign::Unsigned
@ Unsigned
clang::UnqualifiedId::OFI::SymbolLocations
SourceLocation SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new",...
Definition: DeclSpec.h:993
clang::DeclSpec::TSCS___thread
static const TSCS TSCS___thread
Definition: DeclSpec.h:249
clang::DeclSpec::SetStorageClassSpecThread
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:688
clang::TST_char32
@ TST_char32
Definition: Specifiers.h:59
clang::DeclSpec::TQ
TQ
Definition: DeclSpec.h:309
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:111
clang
Definition: CalledOnceCheck.h:17
clang::DeclSpec::TST_atomic
static const TST TST_atomic
Definition: DeclSpec.h:302
clang::Declarator::InlineBindings
DecompositionDeclarator::Binding InlineBindings[16]
Definition: DeclSpec.h:1913
clang::TST_bitint
@ TST_bitint
Definition: Specifiers.h:62
clang::DeclSpec::TST_auto_type
static const TST TST_auto_type
Definition: DeclSpec.h:300
clang::Declarator::isCtorOrDtor
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
Definition: DeclSpec.cpp:423
clang::Declarator
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1834
clang::DeclSpec::forEachCVRUQualifier
void forEachCVRUQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each CVRU qual being set.
Definition: DeclSpec.cpp:428
clang::TST_char16
@ TST_char16
Definition: Specifiers.h:58
clang::DeclaratorChunk::FunctionTypeInfo::MutableLoc
SourceLocation MutableLoc
The location of the 'mutable' qualifer in a lambda-declarator, if any.
Definition: DeclSpec.h:1352
clang::DeclSpec::TSC_imaginary
@ TSC_imaginary
Definition: DeclSpec.h:255
clang::DeclaratorChunk::Reference
@ Reference
Definition: DeclSpec.h:1200
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::FixItHint::CreateRemoval
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
Definition: Diagnostic.h:123
clang::DeclSpec::getTypeQualifiers
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
Definition: DeclSpec.h:567
clang::CXXScopeSpec::getLastQualifierNameLoc
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
Definition: DeclSpec.cpp:145
clang::DeclSpec::isVirtualSpecified
bool isVirtualSpecified() const
Definition: DeclSpec.h:598
clang::DeclaratorChunk
One instance of this struct is used for each type in a declarator that is parsed.
Definition: DeclSpec.h:1196
clang::UnqualifiedId::setOperatorFunctionId
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Definition: DeclSpec.cpp:1457
clang::NestedNameSpecifierLocBuilder::MakeTrivial
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: NestedNameSpecifier.cpp:631
clang::TemplateIdAnnotation::isInvalid
bool isInvalid() const
Definition: ParsedTemplate.h:233
clang::TST_BFloat16
@ TST_BFloat16
Definition: Specifiers.h:67
clang::DeclSpec::TST_struct
static const TST TST_struct
Definition: DeclSpec.h:286
clang::DeclSpec::TQ_restrict
@ TQ_restrict
Definition: DeclSpec.h:312
clang::DeclSpec::ExprRep
Expr * ExprRep
Definition: DeclSpec.h:373
clang::TST_typeofType
@ TST_typeofType
Definition: Specifiers.h:82
clang::DeclSpec::SetTypeAltiVecVector
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:869
clang::DeclSpec::TQ_const
@ TQ_const
Definition: DeclSpec.h:311
clang::TST_float128
@ TST_float128
Definition: Specifiers.h:70
clang::CXXScopeSpec::MakeTrivial
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: DeclSpec.cpp:126
clang::DeclaratorChunk::FunctionTypeInfo::ExceptionSpecLocEnd
SourceLocation ExceptionSpecLocEnd
The end location of the exception specification, if any.
Definition: DeclSpec.h:1358
clang::DeclSpec::TST_typeofExpr
static const TST TST_typeofExpr
Definition: DeclSpec.h:291
clang::DeclSpec::Finish
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
Definition: DeclSpec.cpp:1122
clang::EST_NoexceptFalse
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
Definition: ExceptionSpecificationType.h:28
clang::UnqualifiedId::isValid
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
Definition: DeclSpec.h:1049
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::DeclSpec::TST_wchar
static const TST TST_wchar
Definition: DeclSpec.h:264
clang::DeclSpec::TypeRep
UnionParsedType TypeRep
Definition: DeclSpec.h:371
clang::TST_Fract
@ TST_Fract
Definition: Specifiers.h:66
clang::VirtSpecifiers::SetSpecifier
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
Definition: DeclSpec.cpp:1473
clang::TypeSpecifierWidth::Short
@ Short
clang::WrittenBuiltinSpecs::Width
unsigned Width
Definition: Specifiers.h:105
clang::IdentifierLoc
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:211
clang::DeclSpec::TSCS__Thread_local
static const TSCS TSCS__Thread_local
Definition: DeclSpec.h:251
clang::TST_decltype_auto
@ TST_decltype_auto
Definition: Specifiers.h:90
clang::DeclSpec::TST_auto
static const TST TST_auto
Definition: DeclSpec.h:299
clang::TST_union
@ TST_union
Definition: Specifiers.h:77
clang::TST_double
@ TST_double
Definition: Specifiers.h:69
clang::DeclSpec::TST_char16
static const TST TST_char16
Definition: DeclSpec.h:266
clang::NamespaceDecl
Represent a C++ namespace.
Definition: Decl.h:542
clang::DeclaratorChunk::FunctionTypeInfo::NumExceptionsOrDecls
unsigned NumExceptionsOrDecls
NumExceptionsOrDecls - This is the number of types in the dynamic-exception-decl, if the function has...
Definition: DeclSpec.h:1343
clang::DeclSpec::getAttributePool
AttributePool & getAttributePool() const
Definition: DeclSpec.h:791
clang::DeclSpec::SetTypeSpecWidth
bool SetTypeSpecWidth(TypeSpecifierWidth W, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec, but return true and ignore the request if ...
Definition: DeclSpec.cpp:702
clang::TypeSpecifierWidth::Long
@ Long
clang::WrittenBuiltinSpecs::ModeAttr
unsigned ModeAttr
Definition: Specifiers.h:106
clang::ActionResult::isUsable
bool isUsable() const
Definition: Ownership.h:166
clang::UnqualifiedId::getKind
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
Definition: DeclSpec.h:1055
clang::DeclSpec::SetTypeSpecType
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:832
clang::DeclSpec
Captures information about "declaration specifiers".
Definition: DeclSpec.h:230
clang::DeclSpec::SCS_extern
@ SCS_extern
Definition: DeclSpec.h:237
clang::DeclSpec::TSCS_thread_local
static const TSCS TSCS_thread_local
Definition: DeclSpec.h:250
clang::DeclSpec::getRepAsType
ParsedType getRepAsType() const
Definition: DeclSpec.h:505
TypeLoc.h
clang::NestedNameSpecifierLocBuilder::getWithLocInContext
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition: NestedNameSpecifier.cpp:692
clang::UnqualifiedIdKind::IK_ConstructorTemplateId
@ IK_ConstructorTemplateId
A constructor named via a template-id.
ParsedTemplate.h
clang::DeclaratorChunk::Kind
enum clang::DeclaratorChunk::@212 Kind
clang::TypeSpecifierType
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:52
clang::DeclaratorChunk::Pipe
@ Pipe
Definition: DeclSpec.h:1200
clang::ConstexprSpecKind::Unspecified
@ Unspecified
clang::DeclSpec::SetTypeAltiVecBool
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:918
clang::DeclSpec::TemplateIdRep
TemplateIdAnnotation * TemplateIdRep
Definition: DeclSpec.h:374
clang::DeclSpec::PQ_StorageClassSpecifier
@ PQ_StorageClassSpecifier
Definition: DeclSpec.h:324
clang::DeclSpec::getThreadStorageClassSpec
TSCS getThreadStorageClassSpec() const
Definition: DeclSpec.h:460