clang  5.0.0
DeclSpec.cpp
Go to the documentation of this file.
1 //===--- DeclSpec.cpp - Declaration Specifier Semantic Analysis -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements semantic analysis for declaration specifiers.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/Sema/DeclSpec.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/DeclCXX.h"
17 #include "clang/AST/Expr.h"
18 #include "clang/AST/LocInfoType.h"
19 #include "clang/AST/TypeLoc.h"
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?");
34  this->TemplateId = TemplateId;
35  StartLocation = TemplateId->TemplateNameLoc;
36  EndLocation = TemplateId->RAngleLoc;
37 }
38 
40  assert(TemplateId && "NULL template-id annotation?");
42  this->TemplateId = TemplateId;
43  StartLocation = TemplateId->TemplateNameLoc;
44  EndLocation = TemplateId->RAngleLoc;
45 }
46 
48  TypeLoc TL, SourceLocation ColonColonLoc) {
49  Builder.Extend(Context, TemplateKWLoc, TL, ColonColonLoc);
50  if (Range.getBegin().isInvalid())
51  Range.setBegin(TL.getBeginLoc());
52  Range.setEnd(ColonColonLoc);
53 
54  assert(Range == Builder.getSourceRange() &&
55  "NestedNameSpecifierLoc range computation incorrect");
56 }
57 
60  SourceLocation ColonColonLoc) {
61  Builder.Extend(Context, Identifier, IdentifierLoc, ColonColonLoc);
62 
63  if (Range.getBegin().isInvalid())
64  Range.setBegin(IdentifierLoc);
65  Range.setEnd(ColonColonLoc);
66 
67  assert(Range == Builder.getSourceRange() &&
68  "NestedNameSpecifierLoc range computation incorrect");
69 }
70 
72  SourceLocation NamespaceLoc,
73  SourceLocation ColonColonLoc) {
74  Builder.Extend(Context, Namespace, NamespaceLoc, ColonColonLoc);
75 
76  if (Range.getBegin().isInvalid())
77  Range.setBegin(NamespaceLoc);
78  Range.setEnd(ColonColonLoc);
79 
80  assert(Range == Builder.getSourceRange() &&
81  "NestedNameSpecifierLoc range computation incorrect");
82 }
83 
85  SourceLocation AliasLoc,
86  SourceLocation ColonColonLoc) {
87  Builder.Extend(Context, Alias, AliasLoc, ColonColonLoc);
88 
89  if (Range.getBegin().isInvalid())
90  Range.setBegin(AliasLoc);
91  Range.setEnd(ColonColonLoc);
92 
93  assert(Range == Builder.getSourceRange() &&
94  "NestedNameSpecifierLoc range computation incorrect");
95 }
96 
98  SourceLocation ColonColonLoc) {
99  Builder.MakeGlobal(Context, ColonColonLoc);
100 
101  Range = SourceRange(ColonColonLoc);
102 
103  assert(Range == Builder.getSourceRange() &&
104  "NestedNameSpecifierLoc range computation incorrect");
105 }
106 
108  SourceLocation SuperLoc,
109  SourceLocation ColonColonLoc) {
110  Builder.MakeSuper(Context, RD, SuperLoc, ColonColonLoc);
111 
112  Range.setBegin(SuperLoc);
113  Range.setEnd(ColonColonLoc);
114 
115  assert(Range == Builder.getSourceRange() &&
116  "NestedNameSpecifierLoc range computation incorrect");
117 }
118 
120  NestedNameSpecifier *Qualifier, SourceRange R) {
121  Builder.MakeTrivial(Context, Qualifier, R);
122  Range = R;
123 }
124 
126  if (!Other) {
127  Range = SourceRange();
128  Builder.Clear();
129  return;
130  }
131 
132  Range = Other.getSourceRange();
133  Builder.Adopt(Other);
134 }
135 
137  if (!Builder.getRepresentation())
138  return SourceLocation();
139  return Builder.getTemporary().getLocalBeginLoc();
140 }
141 
144  if (!Builder.getRepresentation())
145  return NestedNameSpecifierLoc();
146 
147  return Builder.getWithLocInContext(Context);
148 }
149 
150 /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
151 /// "TheDeclarator" is the declarator that this will be added to.
153  bool isAmbiguous,
154  SourceLocation LParenLoc,
155  ParamInfo *Params,
156  unsigned NumParams,
157  SourceLocation EllipsisLoc,
158  SourceLocation RParenLoc,
159  unsigned TypeQuals,
160  bool RefQualifierIsLvalueRef,
161  SourceLocation RefQualifierLoc,
162  SourceLocation ConstQualifierLoc,
164  VolatileQualifierLoc,
166  RestrictQualifierLoc,
167  SourceLocation MutableLoc,
169  ESpecType,
170  SourceRange ESpecRange,
171  ParsedType *Exceptions,
172  SourceRange *ExceptionRanges,
173  unsigned NumExceptions,
174  Expr *NoexceptExpr,
175  CachedTokens *ExceptionSpecTokens,
177  DeclsInPrototype,
178  SourceLocation LocalRangeBegin,
179  SourceLocation LocalRangeEnd,
180  Declarator &TheDeclarator,
181  TypeResult TrailingReturnType) {
182  assert(!(TypeQuals & DeclSpec::TQ_atomic) &&
183  "function cannot have _Atomic qualifier");
184 
186  I.Kind = Function;
187  I.Loc = LocalRangeBegin;
188  I.EndLoc = LocalRangeEnd;
189  I.Fun.AttrList = nullptr;
190  I.Fun.hasPrototype = hasProto;
191  I.Fun.isVariadic = EllipsisLoc.isValid();
192  I.Fun.isAmbiguous = isAmbiguous;
193  I.Fun.LParenLoc = LParenLoc.getRawEncoding();
194  I.Fun.EllipsisLoc = EllipsisLoc.getRawEncoding();
195  I.Fun.RParenLoc = RParenLoc.getRawEncoding();
196  I.Fun.DeleteParams = false;
197  I.Fun.TypeQuals = TypeQuals;
198  I.Fun.NumParams = NumParams;
199  I.Fun.Params = nullptr;
200  I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef;
201  I.Fun.RefQualifierLoc = RefQualifierLoc.getRawEncoding();
202  I.Fun.ConstQualifierLoc = ConstQualifierLoc.getRawEncoding();
203  I.Fun.VolatileQualifierLoc = VolatileQualifierLoc.getRawEncoding();
204  I.Fun.RestrictQualifierLoc = RestrictQualifierLoc.getRawEncoding();
205  I.Fun.MutableLoc = MutableLoc.getRawEncoding();
206  I.Fun.ExceptionSpecType = ESpecType;
207  I.Fun.ExceptionSpecLocBeg = ESpecRange.getBegin().getRawEncoding();
208  I.Fun.ExceptionSpecLocEnd = ESpecRange.getEnd().getRawEncoding();
210  I.Fun.Exceptions = nullptr;
211  I.Fun.NoexceptExpr = nullptr;
212  I.Fun.HasTrailingReturnType = TrailingReturnType.isUsable() ||
213  TrailingReturnType.isInvalid();
214  I.Fun.TrailingReturnType = TrailingReturnType.get();
215 
216  assert(I.Fun.TypeQuals == TypeQuals && "bitfield overflow");
217  assert(I.Fun.ExceptionSpecType == ESpecType && "bitfield overflow");
218 
219  // new[] a parameter array if needed.
220  if (NumParams) {
221  // If the 'InlineParams' in Declarator is unused and big enough, put our
222  // parameter list there (in an effort to avoid new/delete traffic). If it
223  // is already used (consider a function returning a function pointer) or too
224  // small (function with too many parameters), go to the heap.
225  if (!TheDeclarator.InlineStorageUsed &&
226  NumParams <= llvm::array_lengthof(TheDeclarator.InlineParams)) {
227  I.Fun.Params = TheDeclarator.InlineParams;
228  new (I.Fun.Params) ParamInfo[NumParams];
229  I.Fun.DeleteParams = false;
230  TheDeclarator.InlineStorageUsed = true;
231  } else {
232  I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams];
233  I.Fun.DeleteParams = true;
234  }
235  for (unsigned i = 0; i < NumParams; i++)
236  I.Fun.Params[i] = std::move(Params[i]);
237  }
238 
239  // Check what exception specification information we should actually store.
240  switch (ESpecType) {
241  default: break; // By default, save nothing.
242  case EST_Dynamic:
243  // new[] an exception array if needed
244  if (NumExceptions) {
245  I.Fun.NumExceptionsOrDecls = NumExceptions;
246  I.Fun.Exceptions = new DeclaratorChunk::TypeAndRange[NumExceptions];
247  for (unsigned i = 0; i != NumExceptions; ++i) {
248  I.Fun.Exceptions[i].Ty = Exceptions[i];
249  I.Fun.Exceptions[i].Range = ExceptionRanges[i];
250  }
251  }
252  break;
253 
255  I.Fun.NoexceptExpr = NoexceptExpr;
256  break;
257 
258  case EST_Unparsed:
259  I.Fun.ExceptionSpecTokens = ExceptionSpecTokens;
260  break;
261  }
262 
263  if (!DeclsInPrototype.empty()) {
264  assert(ESpecType == EST_None && NumExceptions == 0 &&
265  "cannot have exception specifiers and decls in prototype");
266  I.Fun.NumExceptionsOrDecls = DeclsInPrototype.size();
267  // Copy the array of decls into stable heap storage.
268  I.Fun.DeclsInPrototype = new NamedDecl *[DeclsInPrototype.size()];
269  for (size_t J = 0; J < DeclsInPrototype.size(); ++J)
270  I.Fun.DeclsInPrototype[J] = DeclsInPrototype[J];
271  }
272 
273  return I;
274 }
275 
277  SourceLocation LSquareLoc,
279  SourceLocation RSquareLoc) {
280  assert(!hasName() && "declarator given multiple names!");
281 
282  BindingGroup.LSquareLoc = LSquareLoc;
283  BindingGroup.RSquareLoc = RSquareLoc;
284  BindingGroup.NumBindings = Bindings.size();
285  Range.setEnd(RSquareLoc);
286 
287  // We're now past the identifier.
288  SetIdentifier(nullptr, LSquareLoc);
289  Name.EndLocation = RSquareLoc;
290 
291  // Allocate storage for bindings and stash them away.
292  if (Bindings.size()) {
293  if (!InlineStorageUsed &&
294  Bindings.size() <= llvm::array_lengthof(InlineBindings)) {
295  BindingGroup.Bindings = InlineBindings;
296  BindingGroup.DeleteBindings = false;
297  InlineStorageUsed = true;
298  } else {
299  BindingGroup.Bindings =
300  new DecompositionDeclarator::Binding[Bindings.size()];
301  BindingGroup.DeleteBindings = true;
302  }
303  std::uninitialized_copy(Bindings.begin(), Bindings.end(),
304  BindingGroup.Bindings);
305  }
306 }
307 
309  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
310  switch (DeclTypeInfo[i].Kind) {
312  return true;
314  continue;
321  return false;
322  }
323  llvm_unreachable("Invalid type chunk");
324  }
325 
326  switch (DS.getTypeSpecType()) {
327  case TST_atomic:
328  case TST_auto:
329  case TST_auto_type:
330  case TST_bool:
331  case TST_char:
332  case TST_char16:
333  case TST_char32:
334  case TST_class:
335  case TST_decimal128:
336  case TST_decimal32:
337  case TST_decimal64:
338  case TST_double:
339  case TST_float128:
340  case TST_enum:
341  case TST_error:
342  case TST_float:
343  case TST_half:
344  case TST_int:
345  case TST_int128:
346  case TST_struct:
347  case TST_interface:
348  case TST_union:
349  case TST_unknown_anytype:
350  case TST_unspecified:
351  case TST_void:
352  case TST_wchar:
353 #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
354 #include "clang/Basic/OpenCLImageTypes.def"
355  return false;
356 
357  case TST_decltype_auto:
358  // This must have an initializer, so can't be a function declaration,
359  // even if the initializer has function type.
360  return false;
361 
362  case TST_decltype:
363  case TST_typeofExpr:
364  if (Expr *E = DS.getRepAsExpr())
365  return E->getType()->isFunctionType();
366  return false;
367 
368  case TST_underlyingType:
369  case TST_typename:
370  case TST_typeofType: {
371  QualType QT = DS.getRepAsType().get();
372  if (QT.isNull())
373  return false;
374 
375  if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT))
376  QT = LIT->getType();
377 
378  if (QT.isNull())
379  return false;
380 
381  return QT->isFunctionType();
382  }
383  }
384 
385  llvm_unreachable("Invalid TypeSpecType!");
386 }
387 
389  assert(getContext() == MemberContext);
393  getName().OperatorFunctionId.Operator));
394 }
395 
399 }
400 
402  if (!TypeSpecOwned)
403  return false;
404  return cast<TagDecl>(getRepAsDecl())->isCompleteDefinition();
405 }
406 
407 /// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
408 /// declaration specifier includes.
409 ///
411  unsigned Res = 0;
412  if (StorageClassSpec != SCS_unspecified ||
413  ThreadStorageClassSpec != TSCS_unspecified)
415 
416  if (TypeQualifiers != TQ_unspecified)
417  Res |= PQ_TypeQualifier;
418 
419  if (hasTypeSpecifier())
420  Res |= PQ_TypeSpecifier;
421 
422  if (FS_inline_specified || FS_virtual_specified || FS_explicit_specified ||
423  FS_noreturn_specified || FS_forceinline_specified)
424  Res |= PQ_FunctionSpecifier;
425  return Res;
426 }
427 
428 template <class T> static bool BadSpecifier(T TNew, T TPrev,
429  const char *&PrevSpec,
430  unsigned &DiagID,
431  bool IsExtension = true) {
432  PrevSpec = DeclSpec::getSpecifierName(TPrev);
433  if (TNew != TPrev)
434  DiagID = diag::err_invalid_decl_spec_combination;
435  else
436  DiagID = IsExtension ? diag::ext_duplicate_declspec :
437  diag::warn_duplicate_declspec;
438  return true;
439 }
440 
442  switch (S) {
443  case DeclSpec::SCS_unspecified: return "unspecified";
444  case DeclSpec::SCS_typedef: return "typedef";
445  case DeclSpec::SCS_extern: return "extern";
446  case DeclSpec::SCS_static: return "static";
447  case DeclSpec::SCS_auto: return "auto";
448  case DeclSpec::SCS_register: return "register";
449  case DeclSpec::SCS_private_extern: return "__private_extern__";
450  case DeclSpec::SCS_mutable: return "mutable";
451  }
452  llvm_unreachable("Unknown typespec!");
453 }
454 
456  switch (S) {
457  case DeclSpec::TSCS_unspecified: return "unspecified";
458  case DeclSpec::TSCS___thread: return "__thread";
459  case DeclSpec::TSCS_thread_local: return "thread_local";
460  case DeclSpec::TSCS__Thread_local: return "_Thread_local";
461  }
462  llvm_unreachable("Unknown typespec!");
463 }
464 
466  switch (W) {
467  case TSW_unspecified: return "unspecified";
468  case TSW_short: return "short";
469  case TSW_long: return "long";
470  case TSW_longlong: return "long long";
471  }
472  llvm_unreachable("Unknown typespec!");
473 }
474 
476  switch (C) {
477  case TSC_unspecified: return "unspecified";
478  case TSC_imaginary: return "imaginary";
479  case TSC_complex: return "complex";
480  }
481  llvm_unreachable("Unknown typespec!");
482 }
483 
484 
486  switch (S) {
487  case TSS_unspecified: return "unspecified";
488  case TSS_signed: return "signed";
489  case TSS_unsigned: return "unsigned";
490  }
491  llvm_unreachable("Unknown typespec!");
492 }
493 
495  const PrintingPolicy &Policy) {
496  switch (T) {
497  case DeclSpec::TST_unspecified: return "unspecified";
498  case DeclSpec::TST_void: return "void";
499  case DeclSpec::TST_char: return "char";
500  case DeclSpec::TST_wchar: return Policy.MSWChar ? "__wchar_t" : "wchar_t";
501  case DeclSpec::TST_char16: return "char16_t";
502  case DeclSpec::TST_char32: return "char32_t";
503  case DeclSpec::TST_int: return "int";
504  case DeclSpec::TST_int128: return "__int128";
505  case DeclSpec::TST_half: return "half";
506  case DeclSpec::TST_float: return "float";
507  case DeclSpec::TST_double: return "double";
508  case DeclSpec::TST_float128: return "__float128";
509  case DeclSpec::TST_bool: return Policy.Bool ? "bool" : "_Bool";
510  case DeclSpec::TST_decimal32: return "_Decimal32";
511  case DeclSpec::TST_decimal64: return "_Decimal64";
512  case DeclSpec::TST_decimal128: return "_Decimal128";
513  case DeclSpec::TST_enum: return "enum";
514  case DeclSpec::TST_class: return "class";
515  case DeclSpec::TST_union: return "union";
516  case DeclSpec::TST_struct: return "struct";
517  case DeclSpec::TST_interface: return "__interface";
518  case DeclSpec::TST_typename: return "type-name";
520  case DeclSpec::TST_typeofExpr: return "typeof";
521  case DeclSpec::TST_auto: return "auto";
522  case DeclSpec::TST_auto_type: return "__auto_type";
523  case DeclSpec::TST_decltype: return "(decltype)";
524  case DeclSpec::TST_decltype_auto: return "decltype(auto)";
525  case DeclSpec::TST_underlyingType: return "__underlying_type";
526  case DeclSpec::TST_unknown_anytype: return "__unknown_anytype";
527  case DeclSpec::TST_atomic: return "_Atomic";
528 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
529  case DeclSpec::TST_##ImgType##_t: \
530  return #ImgType "_t";
531 #include "clang/Basic/OpenCLImageTypes.def"
532  case DeclSpec::TST_error: return "(error)";
533  }
534  llvm_unreachable("Unknown typespec!");
535 }
536 
538  switch (T) {
539  case DeclSpec::TQ_unspecified: return "unspecified";
540  case DeclSpec::TQ_const: return "const";
541  case DeclSpec::TQ_restrict: return "restrict";
542  case DeclSpec::TQ_volatile: return "volatile";
543  case DeclSpec::TQ_atomic: return "_Atomic";
544  case DeclSpec::TQ_unaligned: return "__unaligned";
545  }
546  llvm_unreachable("Unknown typespec!");
547 }
548 
550  const char *&PrevSpec,
551  unsigned &DiagID,
552  const PrintingPolicy &Policy) {
553  // OpenCL v1.1 s6.8g: "The extern, static, auto and register storage-class
554  // specifiers are not supported.
555  // It seems sensible to prohibit private_extern too
556  // The cl_clang_storage_class_specifiers extension enables support for
557  // these storage-class specifiers.
558  // OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
559  // specifiers are not supported."
560  if (S.getLangOpts().OpenCL &&
561  !S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) {
562  switch (SC) {
563  case SCS_extern:
564  case SCS_private_extern:
565  case SCS_static:
566  if (S.getLangOpts().OpenCLVersion < 120) {
567  DiagID = diag::err_opencl_unknown_type_specifier;
568  PrevSpec = getSpecifierName(SC);
569  return true;
570  }
571  break;
572  case SCS_auto:
573  case SCS_register:
574  DiagID = diag::err_opencl_unknown_type_specifier;
575  PrevSpec = getSpecifierName(SC);
576  return true;
577  default:
578  break;
579  }
580  }
581 
582  if (StorageClassSpec != SCS_unspecified) {
583  // Maybe this is an attempt to use C++11 'auto' outside of C++11 mode.
584  bool isInvalid = true;
585  if (TypeSpecType == TST_unspecified && S.getLangOpts().CPlusPlus) {
586  if (SC == SCS_auto)
587  return SetTypeSpecType(TST_auto, Loc, PrevSpec, DiagID, Policy);
588  if (StorageClassSpec == SCS_auto) {
589  isInvalid = SetTypeSpecType(TST_auto, StorageClassSpecLoc,
590  PrevSpec, DiagID, Policy);
591  assert(!isInvalid && "auto SCS -> TST recovery failed");
592  }
593  }
594 
595  // Changing storage class is allowed only if the previous one
596  // was the 'extern' that is part of a linkage specification and
597  // the new storage class is 'typedef'.
598  if (isInvalid &&
599  !(SCS_extern_in_linkage_spec &&
600  StorageClassSpec == SCS_extern &&
601  SC == SCS_typedef))
602  return BadSpecifier(SC, (SCS)StorageClassSpec, PrevSpec, DiagID);
603  }
604  StorageClassSpec = SC;
605  StorageClassSpecLoc = Loc;
606  assert((unsigned)SC == StorageClassSpec && "SCS constants overflow bitfield");
607  return false;
608 }
609 
611  const char *&PrevSpec,
612  unsigned &DiagID) {
613  if (ThreadStorageClassSpec != TSCS_unspecified)
614  return BadSpecifier(TSC, (TSCS)ThreadStorageClassSpec, PrevSpec, DiagID);
615 
616  ThreadStorageClassSpec = TSC;
617  ThreadStorageClassSpecLoc = Loc;
618  return false;
619 }
620 
621 /// These methods set the specified attribute of the DeclSpec, but return true
622 /// and ignore the request if invalid (e.g. "extern" then "auto" is
623 /// specified).
625  const char *&PrevSpec,
626  unsigned &DiagID,
627  const PrintingPolicy &Policy) {
628  // Overwrite TSWRange.Begin only if TypeSpecWidth was unspecified, so that
629  // for 'long long' we will keep the source location of the first 'long'.
630  if (TypeSpecWidth == TSW_unspecified)
631  TSWRange.setBegin(Loc);
632  // Allow turning long -> long long.
633  else if (W != TSW_longlong || TypeSpecWidth != TSW_long)
634  return BadSpecifier(W, (TSW)TypeSpecWidth, PrevSpec, DiagID);
635  TypeSpecWidth = W;
636  // Remember location of the last 'long'
637  TSWRange.setEnd(Loc);
638  return false;
639 }
640 
642  const char *&PrevSpec,
643  unsigned &DiagID) {
644  if (TypeSpecComplex != TSC_unspecified)
645  return BadSpecifier(C, (TSC)TypeSpecComplex, PrevSpec, DiagID);
646  TypeSpecComplex = C;
647  TSCLoc = Loc;
648  return false;
649 }
650 
652  const char *&PrevSpec,
653  unsigned &DiagID) {
654  if (TypeSpecSign != TSS_unspecified)
655  return BadSpecifier(S, (TSS)TypeSpecSign, PrevSpec, DiagID);
656  TypeSpecSign = S;
657  TSSLoc = Loc;
658  return false;
659 }
660 
662  const char *&PrevSpec,
663  unsigned &DiagID,
664  ParsedType Rep,
665  const PrintingPolicy &Policy) {
666  return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Policy);
667 }
668 
670  SourceLocation TagNameLoc,
671  const char *&PrevSpec,
672  unsigned &DiagID,
673  ParsedType Rep,
674  const PrintingPolicy &Policy) {
675  assert(isTypeRep(T) && "T does not store a type");
676  assert(Rep && "no type provided!");
677  if (TypeSpecType != TST_unspecified) {
678  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
679  DiagID = diag::err_invalid_decl_spec_combination;
680  return true;
681  }
682  TypeSpecType = T;
683  TypeRep = Rep;
684  TSTLoc = TagKwLoc;
685  TSTNameLoc = TagNameLoc;
686  TypeSpecOwned = false;
687  return false;
688 }
689 
691  const char *&PrevSpec,
692  unsigned &DiagID,
693  Expr *Rep,
694  const PrintingPolicy &Policy) {
695  assert(isExprRep(T) && "T does not store an expr");
696  assert(Rep && "no expression provided!");
697  if (TypeSpecType != TST_unspecified) {
698  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
699  DiagID = diag::err_invalid_decl_spec_combination;
700  return true;
701  }
702  TypeSpecType = T;
703  ExprRep = Rep;
704  TSTLoc = Loc;
705  TSTNameLoc = Loc;
706  TypeSpecOwned = false;
707  return false;
708 }
709 
711  const char *&PrevSpec,
712  unsigned &DiagID,
713  Decl *Rep, bool Owned,
714  const PrintingPolicy &Policy) {
715  return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Owned, Policy);
716 }
717 
719  SourceLocation TagNameLoc,
720  const char *&PrevSpec,
721  unsigned &DiagID,
722  Decl *Rep, bool Owned,
723  const PrintingPolicy &Policy) {
724  assert(isDeclRep(T) && "T does not store a decl");
725  // Unlike the other cases, we don't assert that we actually get a decl.
726 
727  if (TypeSpecType != TST_unspecified) {
728  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
729  DiagID = diag::err_invalid_decl_spec_combination;
730  return true;
731  }
732  TypeSpecType = T;
733  DeclRep = Rep;
734  TSTLoc = TagKwLoc;
735  TSTNameLoc = TagNameLoc;
736  TypeSpecOwned = Owned && Rep != nullptr;
737  return false;
738 }
739 
741  const char *&PrevSpec,
742  unsigned &DiagID,
743  const PrintingPolicy &Policy) {
744  assert(!isDeclRep(T) && !isTypeRep(T) && !isExprRep(T) &&
745  "rep required for these type-spec kinds!");
746  if (TypeSpecType != TST_unspecified) {
747  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
748  DiagID = diag::err_invalid_decl_spec_combination;
749  return true;
750  }
751  TSTLoc = Loc;
752  TSTNameLoc = Loc;
753  if (TypeAltiVecVector && (T == TST_bool) && !TypeAltiVecBool) {
754  TypeAltiVecBool = true;
755  return false;
756  }
757  TypeSpecType = T;
758  TypeSpecOwned = false;
759  return false;
760 }
761 
762 bool DeclSpec::SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
763  const char *&PrevSpec, unsigned &DiagID,
764  const PrintingPolicy &Policy) {
765  if (TypeSpecType != TST_unspecified) {
766  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
767  DiagID = diag::err_invalid_vector_decl_spec_combination;
768  return true;
769  }
770  TypeAltiVecVector = isAltiVecVector;
771  AltiVecLoc = Loc;
772  return false;
773 }
774 
775 bool DeclSpec::SetTypePipe(bool isPipe, SourceLocation Loc,
776  const char *&PrevSpec, unsigned &DiagID,
777  const PrintingPolicy &Policy) {
778 
779  if (TypeSpecType != TST_unspecified) {
780  PrevSpec = DeclSpec::getSpecifierName((TST)TypeSpecType, Policy);
781  DiagID = diag::err_invalid_decl_spec_combination;
782  return true;
783  }
784 
785  if (isPipe) {
786  TypeSpecPipe = TSP_pipe;
787  }
788  return false;
789 }
790 
791 bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
792  const char *&PrevSpec, unsigned &DiagID,
793  const PrintingPolicy &Policy) {
794  if (!TypeAltiVecVector || TypeAltiVecPixel ||
795  (TypeSpecType != TST_unspecified)) {
796  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
797  DiagID = diag::err_invalid_pixel_decl_spec_combination;
798  return true;
799  }
800  TypeAltiVecPixel = isAltiVecPixel;
801  TSTLoc = Loc;
802  TSTNameLoc = Loc;
803  return false;
804 }
805 
806 bool DeclSpec::SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
807  const char *&PrevSpec, unsigned &DiagID,
808  const PrintingPolicy &Policy) {
809  if (!TypeAltiVecVector || TypeAltiVecBool ||
810  (TypeSpecType != TST_unspecified)) {
811  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
812  DiagID = diag::err_invalid_vector_bool_decl_spec;
813  return true;
814  }
815  TypeAltiVecBool = isAltiVecBool;
816  TSTLoc = Loc;
817  TSTNameLoc = Loc;
818  return false;
819 }
820 
822  TypeSpecType = TST_error;
823  TypeSpecOwned = false;
824  TSTLoc = SourceLocation();
825  TSTNameLoc = SourceLocation();
826  return false;
827 }
828 
829 bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
830  unsigned &DiagID, const LangOptions &Lang) {
831  // Duplicates are permitted in C99 onwards, but are not permitted in C89 or
832  // C++. However, since this is likely not what the user intended, we will
833  // always warn. We do not need to set the qualifier's location since we
834  // already have it.
835  if (TypeQualifiers & T) {
836  bool IsExtension = true;
837  if (Lang.C99)
838  IsExtension = false;
839  return BadSpecifier(T, T, PrevSpec, DiagID, IsExtension);
840  }
841  TypeQualifiers |= T;
842 
843  switch (T) {
844  case TQ_unspecified: break;
845  case TQ_const: TQ_constLoc = Loc; return false;
846  case TQ_restrict: TQ_restrictLoc = Loc; return false;
847  case TQ_volatile: TQ_volatileLoc = Loc; return false;
848  case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
849  case TQ_atomic: TQ_atomicLoc = Loc; return false;
850  }
851 
852  llvm_unreachable("Unknown type qualifier!");
853 }
854 
855 bool DeclSpec::setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
856  unsigned &DiagID) {
857  // 'inline inline' is ok. However, since this is likely not what the user
858  // intended, we will always warn, similar to duplicates of type qualifiers.
859  if (FS_inline_specified) {
860  DiagID = diag::warn_duplicate_declspec;
861  PrevSpec = "inline";
862  return true;
863  }
864  FS_inline_specified = true;
865  FS_inlineLoc = Loc;
866  return false;
867 }
868 
869 bool DeclSpec::setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec,
870  unsigned &DiagID) {
871  if (FS_forceinline_specified) {
872  DiagID = diag::warn_duplicate_declspec;
873  PrevSpec = "__forceinline";
874  return true;
875  }
876  FS_forceinline_specified = true;
877  FS_forceinlineLoc = Loc;
878  return false;
879 }
880 
882  const char *&PrevSpec,
883  unsigned &DiagID) {
884  // 'virtual virtual' is ok, but warn as this is likely not what the user
885  // intended.
886  if (FS_virtual_specified) {
887  DiagID = diag::warn_duplicate_declspec;
888  PrevSpec = "virtual";
889  return true;
890  }
891  FS_virtual_specified = true;
892  FS_virtualLoc = Loc;
893  return false;
894 }
895 
897  const char *&PrevSpec,
898  unsigned &DiagID) {
899  // 'explicit explicit' is ok, but warn as this is likely not what the user
900  // intended.
901  if (FS_explicit_specified) {
902  DiagID = diag::warn_duplicate_declspec;
903  PrevSpec = "explicit";
904  return true;
905  }
906  FS_explicit_specified = true;
907  FS_explicitLoc = Loc;
908  return false;
909 }
910 
912  const char *&PrevSpec,
913  unsigned &DiagID) {
914  // '_Noreturn _Noreturn' is ok, but warn as this is likely not what the user
915  // intended.
916  if (FS_noreturn_specified) {
917  DiagID = diag::warn_duplicate_declspec;
918  PrevSpec = "_Noreturn";
919  return true;
920  }
921  FS_noreturn_specified = true;
922  FS_noreturnLoc = Loc;
923  return false;
924 }
925 
926 bool DeclSpec::SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
927  unsigned &DiagID) {
928  if (Friend_specified) {
929  PrevSpec = "friend";
930  // Keep the later location, so that we can later diagnose ill-formed
931  // declarations like 'friend class X friend;'. Per [class.friend]p3,
932  // 'friend' must be the first token in a friend declaration that is
933  // not a function declaration.
934  FriendLoc = Loc;
935  DiagID = diag::warn_duplicate_declspec;
936  return true;
937  }
938 
939  Friend_specified = true;
940  FriendLoc = Loc;
941  return false;
942 }
943 
944 bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
945  unsigned &DiagID) {
946  if (isModulePrivateSpecified()) {
947  PrevSpec = "__module_private__";
948  DiagID = diag::ext_duplicate_declspec;
949  return true;
950  }
951 
952  ModulePrivateLoc = Loc;
953  return false;
954 }
955 
956 bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec,
957  unsigned &DiagID) {
958  // 'constexpr constexpr' is ok, but warn as this is likely not what the user
959  // intended.
960  if (Constexpr_specified) {
961  DiagID = diag::warn_duplicate_declspec;
962  PrevSpec = "constexpr";
963  return true;
964  }
965  Constexpr_specified = true;
966  ConstexprLoc = Loc;
967  return false;
968 }
969 
970 bool DeclSpec::SetConceptSpec(SourceLocation Loc, const char *&PrevSpec,
971  unsigned &DiagID) {
972  if (Concept_specified) {
973  DiagID = diag::ext_duplicate_declspec;
974  PrevSpec = "concept";
975  return true;
976  }
977  Concept_specified = true;
978  ConceptLoc = Loc;
979  return false;
980 }
981 
982 void DeclSpec::SaveWrittenBuiltinSpecs() {
983  writtenBS.Sign = getTypeSpecSign();
984  writtenBS.Width = getTypeSpecWidth();
985  writtenBS.Type = getTypeSpecType();
986  // Search the list of attributes for the presence of a mode attribute.
987  writtenBS.ModeAttr = false;
988  AttributeList* attrs = getAttributes().getList();
989  while (attrs) {
990  if (attrs->getKind() == AttributeList::AT_Mode) {
991  writtenBS.ModeAttr = true;
992  break;
993  }
994  attrs = attrs->getNext();
995  }
996 }
997 
998 /// Finish - This does final analysis of the declspec, rejecting things like
999 /// "_Imaginary" (lacking an FP type). This returns a diagnostic to issue or
1000 /// diag::NUM_DIAGNOSTICS if there is no error. After calling this method,
1001 /// DeclSpec is guaranteed self-consistent, even if an error occurred.
1002 void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
1003  // Before possibly changing their values, save specs as written.
1004  SaveWrittenBuiltinSpecs();
1005 
1006  // Check the type specifier components first.
1007 
1008  // If decltype(auto) is used, no other type specifiers are permitted.
1009  if (TypeSpecType == TST_decltype_auto &&
1010  (TypeSpecWidth != TSW_unspecified ||
1011  TypeSpecComplex != TSC_unspecified ||
1012  TypeSpecSign != TSS_unspecified ||
1013  TypeAltiVecVector || TypeAltiVecPixel || TypeAltiVecBool ||
1014  TypeQualifiers)) {
1015  const unsigned NumLocs = 9;
1016  SourceLocation ExtraLocs[NumLocs] = {
1017  TSWRange.getBegin(), TSCLoc, TSSLoc,
1018  AltiVecLoc, TQ_constLoc, TQ_restrictLoc,
1019  TQ_volatileLoc, TQ_atomicLoc, TQ_unalignedLoc};
1020  FixItHint Hints[NumLocs];
1021  SourceLocation FirstLoc;
1022  for (unsigned I = 0; I != NumLocs; ++I) {
1023  if (ExtraLocs[I].isValid()) {
1024  if (FirstLoc.isInvalid() ||
1026  FirstLoc))
1027  FirstLoc = ExtraLocs[I];
1028  Hints[I] = FixItHint::CreateRemoval(ExtraLocs[I]);
1029  }
1030  }
1031  TypeSpecWidth = TSW_unspecified;
1032  TypeSpecComplex = TSC_unspecified;
1033  TypeSpecSign = TSS_unspecified;
1034  TypeAltiVecVector = TypeAltiVecPixel = TypeAltiVecBool = false;
1035  TypeQualifiers = 0;
1036  S.Diag(TSTLoc, diag::err_decltype_auto_cannot_be_combined)
1037  << Hints[0] << Hints[1] << Hints[2] << Hints[3]
1038  << Hints[4] << Hints[5] << Hints[6] << Hints[7];
1039  }
1040 
1041  // Validate and finalize AltiVec vector declspec.
1042  if (TypeAltiVecVector) {
1043  if (TypeAltiVecBool) {
1044  // Sign specifiers are not allowed with vector bool. (PIM 2.1)
1045  if (TypeSpecSign != TSS_unspecified) {
1046  S.Diag(TSSLoc, diag::err_invalid_vector_bool_decl_spec)
1047  << getSpecifierName((TSS)TypeSpecSign);
1048  }
1049 
1050  // Only char/int are valid with vector bool. (PIM 2.1)
1051  if (((TypeSpecType != TST_unspecified) && (TypeSpecType != TST_char) &&
1052  (TypeSpecType != TST_int)) || TypeAltiVecPixel) {
1053  S.Diag(TSTLoc, diag::err_invalid_vector_bool_decl_spec)
1054  << (TypeAltiVecPixel ? "__pixel" :
1055  getSpecifierName((TST)TypeSpecType, Policy));
1056  }
1057 
1058  // Only 'short' and 'long long' are valid with vector bool. (PIM 2.1)
1059  if ((TypeSpecWidth != TSW_unspecified) && (TypeSpecWidth != TSW_short) &&
1060  (TypeSpecWidth != TSW_longlong))
1061  S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_bool_decl_spec)
1062  << getSpecifierName((TSW)TypeSpecWidth);
1063 
1064  // vector bool long long requires VSX support or ZVector.
1065  if ((TypeSpecWidth == TSW_longlong) &&
1066  (!S.Context.getTargetInfo().hasFeature("vsx")) &&
1067  (!S.Context.getTargetInfo().hasFeature("power8-vector")) &&
1068  !S.getLangOpts().ZVector)
1069  S.Diag(TSTLoc, diag::err_invalid_vector_long_long_decl_spec);
1070 
1071  // Elements of vector bool are interpreted as unsigned. (PIM 2.1)
1072  if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) ||
1073  (TypeSpecWidth != TSW_unspecified))
1074  TypeSpecSign = TSS_unsigned;
1075  } else if (TypeSpecType == TST_double) {
1076  // vector long double and vector long long double are never allowed.
1077  // vector double is OK for Power7 and later, and ZVector.
1078  if (TypeSpecWidth == TSW_long || TypeSpecWidth == TSW_longlong)
1079  S.Diag(TSWRange.getBegin(),
1080  diag::err_invalid_vector_long_double_decl_spec);
1081  else if (!S.Context.getTargetInfo().hasFeature("vsx") &&
1082  !S.getLangOpts().ZVector)
1083  S.Diag(TSTLoc, diag::err_invalid_vector_double_decl_spec);
1084  } else if (TypeSpecType == TST_float) {
1085  // vector float is unsupported for ZVector unless we have the
1086  // vector-enhancements facility 1 (ISA revision 12).
1087  if (S.getLangOpts().ZVector &&
1088  !S.Context.getTargetInfo().hasFeature("arch12"))
1089  S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec);
1090  } else if (TypeSpecWidth == TSW_long) {
1091  // vector long is unsupported for ZVector and deprecated for AltiVec.
1092  if (S.getLangOpts().ZVector)
1093  S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_decl_spec);
1094  else
1095  S.Diag(TSWRange.getBegin(),
1096  diag::warn_vector_long_decl_spec_combination)
1097  << getSpecifierName((TST)TypeSpecType, Policy);
1098  }
1099 
1100  if (TypeAltiVecPixel) {
1101  //TODO: perform validation
1102  TypeSpecType = TST_int;
1103  TypeSpecSign = TSS_unsigned;
1104  TypeSpecWidth = TSW_short;
1105  TypeSpecOwned = false;
1106  }
1107  }
1108 
1109  // signed/unsigned are only valid with int/char/wchar_t.
1110  if (TypeSpecSign != TSS_unspecified) {
1111  if (TypeSpecType == TST_unspecified)
1112  TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
1113  else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 &&
1114  TypeSpecType != TST_char && TypeSpecType != TST_wchar) {
1115  S.Diag(TSSLoc, diag::err_invalid_sign_spec)
1116  << getSpecifierName((TST)TypeSpecType, Policy);
1117  // signed double -> double.
1118  TypeSpecSign = TSS_unspecified;
1119  }
1120  }
1121 
1122  // Validate the width of the type.
1123  switch (TypeSpecWidth) {
1124  case TSW_unspecified: break;
1125  case TSW_short: // short int
1126  case TSW_longlong: // long long int
1127  if (TypeSpecType == TST_unspecified)
1128  TypeSpecType = TST_int; // short -> short int, long long -> long long int.
1129  else if (TypeSpecType != TST_int) {
1130  S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1131  << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1132  TypeSpecType = TST_int;
1133  TypeSpecOwned = false;
1134  }
1135  break;
1136  case TSW_long: // long double, long int
1137  if (TypeSpecType == TST_unspecified)
1138  TypeSpecType = TST_int; // long -> long int.
1139  else if (TypeSpecType != TST_int && TypeSpecType != TST_double) {
1140  S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1141  << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1142  TypeSpecType = TST_int;
1143  TypeSpecOwned = false;
1144  }
1145  break;
1146  }
1147 
1148  // TODO: if the implementation does not implement _Complex or _Imaginary,
1149  // disallow their use. Need information about the backend.
1150  if (TypeSpecComplex != TSC_unspecified) {
1151  if (TypeSpecType == TST_unspecified) {
1152  S.Diag(TSCLoc, diag::ext_plain_complex)
1155  " double");
1156  TypeSpecType = TST_double; // _Complex -> _Complex double.
1157  } else if (TypeSpecType == TST_int || TypeSpecType == TST_char) {
1158  // Note that this intentionally doesn't include _Complex _Bool.
1159  if (!S.getLangOpts().CPlusPlus)
1160  S.Diag(TSTLoc, diag::ext_integer_complex);
1161  } else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
1162  S.Diag(TSCLoc, diag::err_invalid_complex_spec)
1163  << getSpecifierName((TST)TypeSpecType, Policy);
1164  TypeSpecComplex = TSC_unspecified;
1165  }
1166  }
1167 
1168  // C11 6.7.1/3, C++11 [dcl.stc]p1, GNU TLS: __thread, thread_local and
1169  // _Thread_local can only appear with the 'static' and 'extern' storage class
1170  // specifiers. We also allow __private_extern__ as an extension.
1171  if (ThreadStorageClassSpec != TSCS_unspecified) {
1172  switch (StorageClassSpec) {
1173  case SCS_unspecified:
1174  case SCS_extern:
1175  case SCS_private_extern:
1176  case SCS_static:
1177  break;
1178  default:
1182  diag::err_invalid_decl_spec_combination)
1185  else
1187  diag::err_invalid_decl_spec_combination)
1190  // Discard the thread storage class specifier to recover.
1191  ThreadStorageClassSpec = TSCS_unspecified;
1192  ThreadStorageClassSpecLoc = SourceLocation();
1193  }
1194  }
1195 
1196  // If no type specifier was provided and we're parsing a language where
1197  // the type specifier is not optional, but we got 'auto' as a storage
1198  // class specifier, then assume this is an attempt to use C++0x's 'auto'
1199  // type specifier.
1200  if (S.getLangOpts().CPlusPlus &&
1201  TypeSpecType == TST_unspecified && StorageClassSpec == SCS_auto) {
1202  TypeSpecType = TST_auto;
1203  StorageClassSpec = SCS_unspecified;
1204  TSTLoc = TSTNameLoc = StorageClassSpecLoc;
1205  StorageClassSpecLoc = SourceLocation();
1206  }
1207  // Diagnose if we've recovered from an ill-formed 'auto' storage class
1208  // specifier in a pre-C++11 dialect of C++.
1209  if (!S.getLangOpts().CPlusPlus11 && TypeSpecType == TST_auto)
1210  S.Diag(TSTLoc, diag::ext_auto_type_specifier);
1211  if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11 &&
1212  StorageClassSpec == SCS_auto)
1213  S.Diag(StorageClassSpecLoc, diag::warn_auto_storage_class)
1214  << FixItHint::CreateRemoval(StorageClassSpecLoc);
1215  if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32)
1216  S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type)
1217  << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
1218  if (Constexpr_specified)
1219  S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr);
1220 
1221  // C++ [class.friend]p6:
1222  // No storage-class-specifier shall appear in the decl-specifier-seq
1223  // of a friend declaration.
1224  if (isFriendSpecified() &&
1226  SmallString<32> SpecName;
1227  SourceLocation SCLoc;
1228  FixItHint StorageHint, ThreadHint;
1229 
1230  if (DeclSpec::SCS SC = getStorageClassSpec()) {
1231  SpecName = getSpecifierName(SC);
1232  SCLoc = getStorageClassSpecLoc();
1233  StorageHint = FixItHint::CreateRemoval(SCLoc);
1234  }
1235 
1237  if (!SpecName.empty()) SpecName += " ";
1238  SpecName += getSpecifierName(TSC);
1239  SCLoc = getThreadStorageClassSpecLoc();
1240  ThreadHint = FixItHint::CreateRemoval(SCLoc);
1241  }
1242 
1243  S.Diag(SCLoc, diag::err_friend_decl_spec)
1244  << SpecName << StorageHint << ThreadHint;
1245 
1247  }
1248 
1249  // C++11 [dcl.fct.spec]p5:
1250  // The virtual specifier shall be used only in the initial
1251  // declaration of a non-static class member function;
1252  // C++11 [dcl.fct.spec]p6:
1253  // The explicit specifier shall be used only in the declaration of
1254  // a constructor or conversion function within its class
1255  // definition;
1257  StringRef Keyword;
1258  SourceLocation SCLoc;
1259 
1260  if (isVirtualSpecified()) {
1261  Keyword = "virtual";
1262  SCLoc = getVirtualSpecLoc();
1263  } else {
1264  Keyword = "explicit";
1265  SCLoc = getExplicitSpecLoc();
1266  }
1267 
1268  FixItHint Hint = FixItHint::CreateRemoval(SCLoc);
1269  S.Diag(SCLoc, diag::err_friend_decl_spec)
1270  << Keyword << Hint;
1271 
1272  FS_virtual_specified = FS_explicit_specified = false;
1273  FS_virtualLoc = FS_explicitLoc = SourceLocation();
1274  }
1275 
1276  assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
1277 
1278  // Okay, now we can infer the real type.
1279 
1280  // TODO: return "auto function" and other bad things based on the real type.
1281 
1282  // 'data definition has no type or storage class'?
1283 }
1284 
1286  TST tst = getTypeSpecType();
1287  return isDeclRep(tst) && getRepAsDecl() != nullptr &&
1288  StorageClassSpec != DeclSpec::SCS_typedef;
1289 }
1290 
1293  SourceLocation SymbolLocations[3]) {
1295  StartLocation = OperatorLoc;
1296  EndLocation = OperatorLoc;
1298  for (unsigned I = 0; I != 3; ++I) {
1299  OperatorFunctionId.SymbolLocations[I] = SymbolLocations[I].getRawEncoding();
1300 
1301  if (SymbolLocations[I].isValid())
1302  EndLocation = SymbolLocations[I];
1303  }
1304 }
1305 
1307  const char *&PrevSpec) {
1308  if (!FirstLocation.isValid())
1309  FirstLocation = Loc;
1310  LastLocation = Loc;
1311  LastSpecifier = VS;
1312 
1313  if (Specifiers & VS) {
1314  PrevSpec = getSpecifierName(VS);
1315  return true;
1316  }
1317 
1318  Specifiers |= VS;
1319 
1320  switch (VS) {
1321  default: llvm_unreachable("Unknown specifier!");
1322  case VS_Override: VS_overrideLoc = Loc; break;
1323  case VS_GNU_Final:
1324  case VS_Sealed:
1325  case VS_Final: VS_finalLoc = Loc; break;
1326  }
1327 
1328  return false;
1329 }
1330 
1332  switch (VS) {
1333  default: llvm_unreachable("Unknown specifier");
1334  case VS_Override: return "override";
1335  case VS_Final: return "final";
1336  case VS_GNU_Final: return "__final";
1337  case VS_Sealed: return "sealed";
1338  }
1339 }
SourceLocation getThreadStorageClassSpecLoc() const
Definition: DeclSpec.h:458
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
IdKind getKind() const
Determine what kind of name we have.
Definition: DeclSpec.h:1001
unsigned MutableLoc
The location of the 'mutable' qualifer in a lambda-declarator, if any.
Definition: DeclSpec.h:1308
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
Definition: DeclSpec.h:1252
no exception specification
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition: DeclSpec.cpp:107
A (possibly-)qualified type.
Definition: Type.h:616
bool isInvalid() const
Definition: Ownership.h:159
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceLocation getExplicitSpecLoc() const
Definition: DeclSpec.h:573
TSW getTypeSpecWidth() const
Definition: DeclSpec.h:477
static const TSS TSS_unsigned
Definition: DeclSpec.h:268
unsigned RestrictQualifierLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1304
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Definition: DeclSpec.h:978
TheContext getContext() const
Definition: DeclSpec.h:1874
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
static const TST TST_wchar
Definition: DeclSpec.h:275
Decl * getRepAsDecl() const
Definition: DeclSpec.h:492
const LangOptions & getLangOpts() const
Definition: Sema.h:1166
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
UnionParsedType TypeRep
Definition: DeclSpec.h:367
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
static const TST TST_typeofExpr
Definition: DeclSpec.h:295
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1243
static const TST TST_char16
Definition: DeclSpec.h:276
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
unsigned ExceptionSpecLocBeg
The beginning location of the exception specification, if any.
Definition: DeclSpec.h:1311
bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:956
unsigned EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
Definition: DeclSpec.h:1272
SCS getStorageClassSpec() const
Definition: DeclSpec.h:448
PtrTy get() const
Definition: Ownership.h:163
One instance of this struct is used for each type in a declarator that is parsed. ...
Definition: DeclSpec.h:1133
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:461
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
Definition: DeclSpec.h:1141
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:45
unsigned NumExceptionsOrDecls
NumExceptionsOrDecls - This is the number of types in the dynamic-exception-decl, if the function has...
Definition: DeclSpec.h:1284
NamedDecl ** DeclsInPrototype
Pointer to a new[]'d array of declarations that need to be available for lookup inside the function b...
Definition: DeclSpec.h:1338
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:494
static const char * getSpecifierName(Specifier VS)
Definition: DeclSpec.cpp:1331
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:806
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
Definition: DeclSpec.h:2123
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
unsigned RefQualifierLoc
The location of the ref-qualifier, if any.
Definition: DeclSpec.h:1289
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:125
static const TSCS TSCS_unspecified
Definition: DeclSpec.h:246
static const TST TST_underlyingType
Definition: DeclSpec.h:298
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1733
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:896
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:45
static const TST TST_interface
Definition: DeclSpec.h:291
static const TST TST_char
Definition: DeclSpec.h:274
void setBegin(SourceLocation b)
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:1167
Information about a template-id annotation token.
static const TST TST_unknown_anytype
Definition: DeclSpec.h:301
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:40
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
Definition: DeclSpec.h:972
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1329
One of these records is kept for each identifier that is lexed.
void setConstructorTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id that names a constructor.
Definition: DeclSpec.cpp:39
static const TST TST_decimal32
Definition: DeclSpec.h:285
AttributeList * getList() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
A C++ nested-name-specifier augmented with source location information.
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:33
unsigned VolatileQualifierLoc
The location of the volatile-qualifier, if any.
Definition: DeclSpec.h:1299
TSS getTypeSpecSign() const
Definition: DeclSpec.h:479
static const TST TST_class
Definition: DeclSpec.h:292
OverloadedOperatorKind Operator
The kind of overloaded operator.
Definition: DeclSpec.h:931
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
Definition: DeclSpec.h:1256
static const TST TST_double
Definition: DeclSpec.h:282
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
Definition: DeclSpec.h:952
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:881
static const TST TST_error
Definition: DeclSpec.h:306
static const TST TST_enum
Definition: DeclSpec.h:288
static const TSW TSW_unspecified
Definition: DeclSpec.h:253
void ClearStorageClassSpecs()
Definition: DeclSpec.h:462
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:791
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:169
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:643
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:869
SCS
storage-class-specifier
Definition: DeclSpec.h:232
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
Definition: DeclSpec.h:1266
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:926
unsigned RParenLoc
The location of the right parenthesis in the source.
Definition: DeclSpec.h:1275
enum clang::DeclaratorChunk::@196 Kind
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:775
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:911
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
Definition: DeclSpec.cpp:31
detail::InMemoryDirectory::const_iterator I
bool isInvalid() const
static const TST TST_float
Definition: DeclSpec.h:281
DecompositionDeclarator::Binding InlineBindings[16]
Definition: DeclSpec.h:1820
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covered by this nested-name-specifier.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:269
static const TSW TSW_long
Definition: DeclSpec.h:255
TST getTypeSpecType() const
Definition: DeclSpec.h:480
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: DeclSpec.cpp:119
Kind getKind() const
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
Definition: LocInfoType.h:29
bool isTypeRep() const
Definition: DeclSpec.h:485
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1279
ASTContext * Context
static bool isDeclRep(TST T)
Definition: DeclSpec.h:414
Expr - This represents one expression.
Definition: Expr.h:105
Defines the clang::LangOptions interface.
void setDecompositionBindings(SourceLocation LSquareLoc, ArrayRef< DecompositionDeclarator::Binding > Bindings, SourceLocation RSquareLoc)
Set the decomposition bindings for this declarator.
Definition: DeclSpec.cpp:276
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
Definition: DeclSpec.cpp:308
SourceLocation getTypeSpecComplexLoc() const
Definition: DeclSpec.h:509
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
unsigned SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new", "[", and "]" tokens in operator new [].
Definition: DeclSpec.h:940
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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:1819
static const TST TST_decimal64
Definition: DeclSpec.h:286
Defines the clang::TypeLoc interface and its subclasses.
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed...
Definition: DeclSpec.h:1333
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Definition: DeclSpec.h:592
SourceLocation Loc
Loc - The place where this type was defined.
Definition: DeclSpec.h:1139
static const TST TST_int
Definition: DeclSpec.h:278
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:651
static const TST TST_half
Definition: DeclSpec.h:280
Wraps an identifier and optional source location for the identifier.
Definition: AttributeList.h:73
SourceLocation getStorageClassSpecLoc() const
Definition: DeclSpec.h:457
static bool BadSpecifier(T TNew, T TPrev, const char *&PrevSpec, unsigned &DiagID, bool IsExtension=true)
Definition: DeclSpec.cpp:428
static const TSW TSW_short
Definition: DeclSpec.h:254
bool isVirtualSpecified() const
Definition: DeclSpec.h:569
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
Definition: DeclSpec.h:1343
bool SetTypeSpecWidth(TSW 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:624
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
Definition: DeclSpec.h:995
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Definition: DeclSpec.h:1325
static const TST TST_char32
Definition: DeclSpec.h:277
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool'...
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
Definition: DeclSpec.cpp:396
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
Definition: DeclSpec.cpp:136
bool SetConceptSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:970
Kind
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:145
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Encodes a location in the source.
static const TST TST_auto_type
Definition: DeclSpec.h:300
An overloaded operator name, e.g., operator+.
Definition: DeclSpec.h:910
Expr * getRepAsExpr() const
Definition: DeclSpec.h:496
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
Definition: DeclSpec.h:1868
bool isValid() const
Return true if this is a valid SourceLocation object.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Definition: DeclSpec.cpp:143
NestedNameSpecifierLoc getTemporary() const
Retrieve a nested-name-specifier with location information based on the information in this builder...
FunctionTypeInfo Fun
Definition: DeclSpec.h:1503
static const TST TST_union
Definition: DeclSpec.h:289
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, 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())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
Definition: DeclSpec.cpp:152
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:549
ParsedType getRepAsType() const
Definition: DeclSpec.h:488
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
static const TSS TSS_signed
Definition: DeclSpec.h:267
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
SourceLocation getVirtualSpecLoc() const
Definition: DeclSpec.h:570
static const TST TST_typeofType
Definition: DeclSpec.h:294
SourceLocation getBegin() const
PtrTy get() const
Definition: Ownership.h:74
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
Definition: DeclSpec.cpp:829
bool isStaticMember()
Returns true if this declares a static member.
Definition: DeclSpec.cpp:388
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:762
Decl * DeclRep
Definition: DeclSpec.h:368
A constructor named via a template-id.
Definition: DeclSpec.h:918
static const TST TST_decltype_auto
Definition: DeclSpec.h:297
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:944
bool isEnabled(llvm::StringRef Ext) const
Definition: OpenCLOptions.h:39
static bool isInvalid(LocType Loc, bool *Invalid)
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Definition: DeclCXX.h:1934
TSCS getThreadStorageClassSpec() const
Definition: DeclSpec.h:449
static const TSS TSS_unspecified
Definition: DeclSpec.h:266
static const TST TST_decltype
Definition: DeclSpec.h:296
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
static const TST TST_auto
Definition: DeclSpec.h:299
bool isFriendSpecified() const
Definition: DeclSpec.h:702
static const TST TST_void
Definition: DeclSpec.h:273
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
Definition: DeclSpec.h:1245
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
static const TST TST_int128
Definition: DeclSpec.h:279
unsigned DeleteParams
DeleteParams - If this is true, we need to delete[] Params.
Definition: DeclSpec.h:1262
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
Definition: DeclSpec.cpp:1285
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
Definition: Diagnostic.h:116
bool hasTagDefinition() const
Definition: DeclSpec.cpp:401
unsigned ConstQualifierLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1294
detail::InMemoryDirectory::const_iterator E
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Definition: DeclSpec.h:2104
static const TST TST_unspecified
Definition: DeclSpec.h:272
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
Definition: DeclSpec.cpp:1306
static const TST TST_decimal128
Definition: DeclSpec.h:287
SourceManager & getSourceManager() const
Definition: Sema.h:1171
static const TSCS TSCS___thread
Definition: DeclSpec.h:247
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
Definition: DeclSpec.h:1240
unsigned LParenLoc
The location of the left parenthesis in the source.
Definition: DeclSpec.h:1269
bool isFunctionType() const
Definition: Type.h:5709
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:610
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Definition: DeclSpec.cpp:1291
static const TST TST_typename
Definition: DeclSpec.h:293
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
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:90
A template-id, e.g., f<int>.
Definition: DeclSpec.h:922
bool isUsable() const
Definition: Ownership.h:160
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:740
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
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:47
unsigned ExceptionSpecType
ExceptionSpecType - An ExceptionSpecificationType value.
Definition: DeclSpec.h:1259
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:189
bool isExplicitSpecified() const
Definition: DeclSpec.h:572
void setEnd(SourceLocation e)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:267
static const TSCS TSCS_thread_local
Definition: DeclSpec.h:248
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:25
static const TST TST_float128
Definition: DeclSpec.h:283
static const TST TST_bool
Definition: DeclSpec.h:284
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: DeclSpec.cpp:97
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
Definition: DeclSpec.cpp:1002
Defines the clang::TargetInfo interface.
Expr * ExprRep
Definition: DeclSpec.h:369
static const TSW TSW_longlong
Definition: DeclSpec.h:256
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:897
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
Definition: DeclSpec.cpp:410
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
Definition: TargetInfo.h:911
static const TST TST_atomic
Definition: DeclSpec.h:302
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...
static const TST TST_struct
Definition: DeclSpec.h:290
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
Definition: Diagnostic.h:64
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
Definition: DeclSpec.h:1211
AttributeList * getNext() const
A trivial tuple used to represent a source range.
ASTContext & Context
Definition: Sema.h:305
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:641
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
bool SetTypeSpecError()
Definition: DeclSpec.cpp:821
unsigned ExceptionSpecLocEnd
The end location of the exception specification, if any.
Definition: DeclSpec.h:1314
bool isModulePrivateSpecified() const
Definition: DeclSpec.h:705
Represents a C++ namespace alias.
Definition: DeclCXX.h:2861
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
Definition: DeclSpec.h:981
static const TSCS TSCS__Thread_local
Definition: DeclSpec.h:249
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:683
enum clang::UnqualifiedId::IdKind Kind
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1319
ParsedAttributes & getAttributes()
Definition: DeclSpec.h:751
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:1849
AttributeList - Represents a syntactic attribute.
Definition: AttributeList.h:95
void Clear()
Clear out this builder, and prepare it to build another nested-name-specifier with source-location in...
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:855
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
Definition: DeclSpec.h:1248