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