clang  6.0.0svn
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 
47 void CXXScopeSpec::Extend(ASTContext &Context, SourceLocation TemplateKWLoc,
48  TypeLoc TL, SourceLocation ColonColonLoc) {
49  Builder.Extend(Context, TemplateKWLoc, TL, ColonColonLoc);
50  if (Range.getBegin().isInvalid())
51  Range.setBegin(TL.getBeginLoc());
52  Range.setEnd(ColonColonLoc);
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 
71 void CXXScopeSpec::Extend(ASTContext &Context, NamespaceDecl *Namespace,
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 
185  DeclaratorChunk I;
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_Float16:
340  case TST_float128:
341  case TST_enum:
342  case TST_error:
343  case TST_float:
344  case TST_half:
345  case TST_int:
346  case TST_int128:
347  case TST_struct:
348  case TST_interface:
349  case TST_union:
350  case TST_unknown_anytype:
351  case TST_unspecified:
352  case TST_void:
353  case TST_wchar:
354 #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
355 #include "clang/Basic/OpenCLImageTypes.def"
356  return false;
357 
358  case TST_decltype_auto:
359  // This must have an initializer, so can't be a function declaration,
360  // even if the initializer has function type.
361  return false;
362 
363  case TST_decltype:
364  case TST_typeofExpr:
365  if (Expr *E = DS.getRepAsExpr())
366  return E->getType()->isFunctionType();
367  return false;
368 
369  case TST_underlyingType:
370  case TST_typename:
371  case TST_typeofType: {
372  QualType QT = DS.getRepAsType().get();
373  if (QT.isNull())
374  return false;
375 
376  if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT))
377  QT = LIT->getType();
378 
379  if (QT.isNull())
380  return false;
381 
382  return QT->isFunctionType();
383  }
384  }
385 
386  llvm_unreachable("Invalid TypeSpecType!");
387 }
388 
390  assert(getContext() == MemberContext);
391  return getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
392  (getName().Kind == UnqualifiedId::IK_OperatorFunctionId &&
394  getName().OperatorFunctionId.Operator));
395 }
396 
398  return (getName().getKind() == UnqualifiedId::IK_ConstructorName) ||
399  (getName().getKind() == UnqualifiedId::IK_DestructorName);
400 }
401 
403  if (!TypeSpecOwned)
404  return false;
405  return cast<TagDecl>(getRepAsDecl())->isCompleteDefinition();
406 }
407 
408 /// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
409 /// declaration specifier includes.
410 ///
412  unsigned Res = 0;
413  if (StorageClassSpec != SCS_unspecified ||
414  ThreadStorageClassSpec != TSCS_unspecified)
415  Res |= PQ_StorageClassSpecifier;
416 
417  if (TypeQualifiers != TQ_unspecified)
418  Res |= PQ_TypeQualifier;
419 
420  if (hasTypeSpecifier())
421  Res |= PQ_TypeSpecifier;
422 
423  if (FS_inline_specified || FS_virtual_specified || FS_explicit_specified ||
424  FS_noreturn_specified || FS_forceinline_specified)
425  Res |= PQ_FunctionSpecifier;
426  return Res;
427 }
428 
429 template <class T> static bool BadSpecifier(T TNew, T TPrev,
430  const char *&PrevSpec,
431  unsigned &DiagID,
432  bool IsExtension = true) {
433  PrevSpec = DeclSpec::getSpecifierName(TPrev);
434  if (TNew != TPrev)
435  DiagID = diag::err_invalid_decl_spec_combination;
436  else
437  DiagID = IsExtension ? diag::ext_duplicate_declspec :
438  diag::warn_duplicate_declspec;
439  return true;
440 }
441 
443  switch (S) {
444  case DeclSpec::SCS_unspecified: return "unspecified";
445  case DeclSpec::SCS_typedef: return "typedef";
446  case DeclSpec::SCS_extern: return "extern";
447  case DeclSpec::SCS_static: return "static";
448  case DeclSpec::SCS_auto: return "auto";
449  case DeclSpec::SCS_register: return "register";
450  case DeclSpec::SCS_private_extern: return "__private_extern__";
451  case DeclSpec::SCS_mutable: return "mutable";
452  }
453  llvm_unreachable("Unknown typespec!");
454 }
455 
457  switch (S) {
458  case DeclSpec::TSCS_unspecified: return "unspecified";
459  case DeclSpec::TSCS___thread: return "__thread";
460  case DeclSpec::TSCS_thread_local: return "thread_local";
461  case DeclSpec::TSCS__Thread_local: return "_Thread_local";
462  }
463  llvm_unreachable("Unknown typespec!");
464 }
465 
467  switch (W) {
468  case TSW_unspecified: return "unspecified";
469  case TSW_short: return "short";
470  case TSW_long: return "long";
471  case TSW_longlong: return "long long";
472  }
473  llvm_unreachable("Unknown typespec!");
474 }
475 
477  switch (C) {
478  case TSC_unspecified: return "unspecified";
479  case TSC_imaginary: return "imaginary";
480  case TSC_complex: return "complex";
481  }
482  llvm_unreachable("Unknown typespec!");
483 }
484 
485 
487  switch (S) {
488  case TSS_unspecified: return "unspecified";
489  case TSS_signed: return "signed";
490  case TSS_unsigned: return "unsigned";
491  }
492  llvm_unreachable("Unknown typespec!");
493 }
494 
496  const PrintingPolicy &Policy) {
497  switch (T) {
498  case DeclSpec::TST_unspecified: return "unspecified";
499  case DeclSpec::TST_void: return "void";
500  case DeclSpec::TST_char: return "char";
501  case DeclSpec::TST_wchar: return Policy.MSWChar ? "__wchar_t" : "wchar_t";
502  case DeclSpec::TST_char16: return "char16_t";
503  case DeclSpec::TST_char32: return "char32_t";
504  case DeclSpec::TST_int: return "int";
505  case DeclSpec::TST_int128: return "__int128";
506  case DeclSpec::TST_half: return "half";
507  case DeclSpec::TST_float: return "float";
508  case DeclSpec::TST_double: return "double";
509  case DeclSpec::TST_float16: return "_Float16";
510  case DeclSpec::TST_float128: return "__float128";
511  case DeclSpec::TST_bool: return Policy.Bool ? "bool" : "_Bool";
512  case DeclSpec::TST_decimal32: return "_Decimal32";
513  case DeclSpec::TST_decimal64: return "_Decimal64";
514  case DeclSpec::TST_decimal128: return "_Decimal128";
515  case DeclSpec::TST_enum: return "enum";
516  case DeclSpec::TST_class: return "class";
517  case DeclSpec::TST_union: return "union";
518  case DeclSpec::TST_struct: return "struct";
519  case DeclSpec::TST_interface: return "__interface";
520  case DeclSpec::TST_typename: return "type-name";
522  case DeclSpec::TST_typeofExpr: return "typeof";
523  case DeclSpec::TST_auto: return "auto";
524  case DeclSpec::TST_auto_type: return "__auto_type";
525  case DeclSpec::TST_decltype: return "(decltype)";
526  case DeclSpec::TST_decltype_auto: return "decltype(auto)";
527  case DeclSpec::TST_underlyingType: return "__underlying_type";
528  case DeclSpec::TST_unknown_anytype: return "__unknown_anytype";
529  case DeclSpec::TST_atomic: return "_Atomic";
530 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
531  case DeclSpec::TST_##ImgType##_t: \
532  return #ImgType "_t";
533 #include "clang/Basic/OpenCLImageTypes.def"
534  case DeclSpec::TST_error: return "(error)";
535  }
536  llvm_unreachable("Unknown typespec!");
537 }
538 
540  switch (T) {
541  case DeclSpec::TQ_unspecified: return "unspecified";
542  case DeclSpec::TQ_const: return "const";
543  case DeclSpec::TQ_restrict: return "restrict";
544  case DeclSpec::TQ_volatile: return "volatile";
545  case DeclSpec::TQ_atomic: return "_Atomic";
546  case DeclSpec::TQ_unaligned: return "__unaligned";
547  }
548  llvm_unreachable("Unknown typespec!");
549 }
550 
552  const char *&PrevSpec,
553  unsigned &DiagID,
554  const PrintingPolicy &Policy) {
555  // OpenCL v1.1 s6.8g: "The extern, static, auto and register storage-class
556  // specifiers are not supported.
557  // It seems sensible to prohibit private_extern too
558  // The cl_clang_storage_class_specifiers extension enables support for
559  // these storage-class specifiers.
560  // OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
561  // specifiers are not supported."
562  if (S.getLangOpts().OpenCL &&
563  !S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) {
564  switch (SC) {
565  case SCS_extern:
566  case SCS_private_extern:
567  case SCS_static:
568  if (S.getLangOpts().OpenCLVersion < 120) {
569  DiagID = diag::err_opencl_unknown_type_specifier;
570  PrevSpec = getSpecifierName(SC);
571  return true;
572  }
573  break;
574  case SCS_auto:
575  case SCS_register:
576  DiagID = diag::err_opencl_unknown_type_specifier;
577  PrevSpec = getSpecifierName(SC);
578  return true;
579  default:
580  break;
581  }
582  }
583 
584  if (StorageClassSpec != SCS_unspecified) {
585  // Maybe this is an attempt to use C++11 'auto' outside of C++11 mode.
586  bool isInvalid = true;
587  if (TypeSpecType == TST_unspecified && S.getLangOpts().CPlusPlus) {
588  if (SC == SCS_auto)
589  return SetTypeSpecType(TST_auto, Loc, PrevSpec, DiagID, Policy);
590  if (StorageClassSpec == SCS_auto) {
591  isInvalid = SetTypeSpecType(TST_auto, StorageClassSpecLoc,
592  PrevSpec, DiagID, Policy);
593  assert(!isInvalid && "auto SCS -> TST recovery failed");
594  }
595  }
596 
597  // Changing storage class is allowed only if the previous one
598  // was the 'extern' that is part of a linkage specification and
599  // the new storage class is 'typedef'.
600  if (isInvalid &&
601  !(SCS_extern_in_linkage_spec &&
602  StorageClassSpec == SCS_extern &&
603  SC == SCS_typedef))
604  return BadSpecifier(SC, (SCS)StorageClassSpec, PrevSpec, DiagID);
605  }
606  StorageClassSpec = SC;
607  StorageClassSpecLoc = Loc;
608  assert((unsigned)SC == StorageClassSpec && "SCS constants overflow bitfield");
609  return false;
610 }
611 
613  const char *&PrevSpec,
614  unsigned &DiagID) {
615  if (ThreadStorageClassSpec != TSCS_unspecified)
616  return BadSpecifier(TSC, (TSCS)ThreadStorageClassSpec, PrevSpec, DiagID);
617 
618  ThreadStorageClassSpec = TSC;
619  ThreadStorageClassSpecLoc = Loc;
620  return false;
621 }
622 
623 /// These methods set the specified attribute of the DeclSpec, but return true
624 /// and ignore the request if invalid (e.g. "extern" then "auto" is
625 /// specified).
627  const char *&PrevSpec,
628  unsigned &DiagID,
629  const PrintingPolicy &Policy) {
630  // Overwrite TSWRange.Begin only if TypeSpecWidth was unspecified, so that
631  // for 'long long' we will keep the source location of the first 'long'.
632  if (TypeSpecWidth == TSW_unspecified)
633  TSWRange.setBegin(Loc);
634  // Allow turning long -> long long.
635  else if (W != TSW_longlong || TypeSpecWidth != TSW_long)
636  return BadSpecifier(W, (TSW)TypeSpecWidth, PrevSpec, DiagID);
637  TypeSpecWidth = W;
638  // Remember location of the last 'long'
639  TSWRange.setEnd(Loc);
640  return false;
641 }
642 
644  const char *&PrevSpec,
645  unsigned &DiagID) {
646  if (TypeSpecComplex != TSC_unspecified)
647  return BadSpecifier(C, (TSC)TypeSpecComplex, PrevSpec, DiagID);
648  TypeSpecComplex = C;
649  TSCLoc = Loc;
650  return false;
651 }
652 
654  const char *&PrevSpec,
655  unsigned &DiagID) {
656  if (TypeSpecSign != TSS_unspecified)
657  return BadSpecifier(S, (TSS)TypeSpecSign, PrevSpec, DiagID);
658  TypeSpecSign = S;
659  TSSLoc = Loc;
660  return false;
661 }
662 
664  const char *&PrevSpec,
665  unsigned &DiagID,
666  ParsedType Rep,
667  const PrintingPolicy &Policy) {
668  return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Policy);
669 }
670 
672  SourceLocation TagNameLoc,
673  const char *&PrevSpec,
674  unsigned &DiagID,
675  ParsedType Rep,
676  const PrintingPolicy &Policy) {
677  assert(isTypeRep(T) && "T does not store a type");
678  assert(Rep && "no type provided!");
679  if (TypeSpecType != TST_unspecified) {
680  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
681  DiagID = diag::err_invalid_decl_spec_combination;
682  return true;
683  }
684  TypeSpecType = T;
685  TypeRep = Rep;
686  TSTLoc = TagKwLoc;
687  TSTNameLoc = TagNameLoc;
688  TypeSpecOwned = false;
689  return false;
690 }
691 
693  const char *&PrevSpec,
694  unsigned &DiagID,
695  Expr *Rep,
696  const PrintingPolicy &Policy) {
697  assert(isExprRep(T) && "T does not store an expr");
698  assert(Rep && "no expression provided!");
699  if (TypeSpecType != TST_unspecified) {
700  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
701  DiagID = diag::err_invalid_decl_spec_combination;
702  return true;
703  }
704  TypeSpecType = T;
705  ExprRep = Rep;
706  TSTLoc = Loc;
707  TSTNameLoc = Loc;
708  TypeSpecOwned = false;
709  return false;
710 }
711 
713  const char *&PrevSpec,
714  unsigned &DiagID,
715  Decl *Rep, bool Owned,
716  const PrintingPolicy &Policy) {
717  return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Owned, Policy);
718 }
719 
721  SourceLocation TagNameLoc,
722  const char *&PrevSpec,
723  unsigned &DiagID,
724  Decl *Rep, bool Owned,
725  const PrintingPolicy &Policy) {
726  assert(isDeclRep(T) && "T does not store a decl");
727  // Unlike the other cases, we don't assert that we actually get a decl.
728 
729  if (TypeSpecType != TST_unspecified) {
730  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
731  DiagID = diag::err_invalid_decl_spec_combination;
732  return true;
733  }
734  TypeSpecType = T;
735  DeclRep = Rep;
736  TSTLoc = TagKwLoc;
737  TSTNameLoc = TagNameLoc;
738  TypeSpecOwned = Owned && Rep != nullptr;
739  return false;
740 }
741 
743  const char *&PrevSpec,
744  unsigned &DiagID,
745  const PrintingPolicy &Policy) {
746  assert(!isDeclRep(T) && !isTypeRep(T) && !isExprRep(T) &&
747  "rep required for these type-spec kinds!");
748  if (TypeSpecType != TST_unspecified) {
749  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
750  DiagID = diag::err_invalid_decl_spec_combination;
751  return true;
752  }
753  TSTLoc = Loc;
754  TSTNameLoc = Loc;
755  if (TypeAltiVecVector && (T == TST_bool) && !TypeAltiVecBool) {
756  TypeAltiVecBool = true;
757  return false;
758  }
759  TypeSpecType = T;
760  TypeSpecOwned = false;
761  return false;
762 }
763 
764 bool DeclSpec::SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
765  const char *&PrevSpec, unsigned &DiagID,
766  const PrintingPolicy &Policy) {
767  if (TypeSpecType != TST_unspecified) {
768  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
769  DiagID = diag::err_invalid_vector_decl_spec_combination;
770  return true;
771  }
772  TypeAltiVecVector = isAltiVecVector;
773  AltiVecLoc = Loc;
774  return false;
775 }
776 
777 bool DeclSpec::SetTypePipe(bool isPipe, SourceLocation Loc,
778  const char *&PrevSpec, unsigned &DiagID,
779  const PrintingPolicy &Policy) {
780 
781  if (TypeSpecType != TST_unspecified) {
782  PrevSpec = DeclSpec::getSpecifierName((TST)TypeSpecType, Policy);
783  DiagID = diag::err_invalid_decl_spec_combination;
784  return true;
785  }
786 
787  if (isPipe) {
788  TypeSpecPipe = TSP_pipe;
789  }
790  return false;
791 }
792 
793 bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
794  const char *&PrevSpec, unsigned &DiagID,
795  const PrintingPolicy &Policy) {
796  if (!TypeAltiVecVector || TypeAltiVecPixel ||
797  (TypeSpecType != TST_unspecified)) {
798  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
799  DiagID = diag::err_invalid_pixel_decl_spec_combination;
800  return true;
801  }
802  TypeAltiVecPixel = isAltiVecPixel;
803  TSTLoc = Loc;
804  TSTNameLoc = Loc;
805  return false;
806 }
807 
808 bool DeclSpec::SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
809  const char *&PrevSpec, unsigned &DiagID,
810  const PrintingPolicy &Policy) {
811  if (!TypeAltiVecVector || TypeAltiVecBool ||
812  (TypeSpecType != TST_unspecified)) {
813  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
814  DiagID = diag::err_invalid_vector_bool_decl_spec;
815  return true;
816  }
817  TypeAltiVecBool = isAltiVecBool;
818  TSTLoc = Loc;
819  TSTNameLoc = Loc;
820  return false;
821 }
822 
824  TypeSpecType = TST_error;
825  TypeSpecOwned = false;
826  TSTLoc = SourceLocation();
827  TSTNameLoc = SourceLocation();
828  return false;
829 }
830 
831 bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
832  unsigned &DiagID, const LangOptions &Lang) {
833  // Duplicates are permitted in C99 onwards, but are not permitted in C89 or
834  // C++. However, since this is likely not what the user intended, we will
835  // always warn. We do not need to set the qualifier's location since we
836  // already have it.
837  if (TypeQualifiers & T) {
838  bool IsExtension = true;
839  if (Lang.C99)
840  IsExtension = false;
841  return BadSpecifier(T, T, PrevSpec, DiagID, IsExtension);
842  }
843  TypeQualifiers |= T;
844 
845  switch (T) {
846  case TQ_unspecified: break;
847  case TQ_const: TQ_constLoc = Loc; return false;
848  case TQ_restrict: TQ_restrictLoc = Loc; return false;
849  case TQ_volatile: TQ_volatileLoc = Loc; return false;
850  case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
851  case TQ_atomic: TQ_atomicLoc = Loc; return false;
852  }
853 
854  llvm_unreachable("Unknown type qualifier!");
855 }
856 
857 bool DeclSpec::setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
858  unsigned &DiagID) {
859  // 'inline inline' is ok. However, since this is likely not what the user
860  // intended, we will always warn, similar to duplicates of type qualifiers.
861  if (FS_inline_specified) {
862  DiagID = diag::warn_duplicate_declspec;
863  PrevSpec = "inline";
864  return true;
865  }
866  FS_inline_specified = true;
867  FS_inlineLoc = Loc;
868  return false;
869 }
870 
871 bool DeclSpec::setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec,
872  unsigned &DiagID) {
873  if (FS_forceinline_specified) {
874  DiagID = diag::warn_duplicate_declspec;
875  PrevSpec = "__forceinline";
876  return true;
877  }
878  FS_forceinline_specified = true;
879  FS_forceinlineLoc = Loc;
880  return false;
881 }
882 
884  const char *&PrevSpec,
885  unsigned &DiagID) {
886  // 'virtual virtual' is ok, but warn as this is likely not what the user
887  // intended.
888  if (FS_virtual_specified) {
889  DiagID = diag::warn_duplicate_declspec;
890  PrevSpec = "virtual";
891  return true;
892  }
893  FS_virtual_specified = true;
894  FS_virtualLoc = Loc;
895  return false;
896 }
897 
899  const char *&PrevSpec,
900  unsigned &DiagID) {
901  // 'explicit explicit' is ok, but warn as this is likely not what the user
902  // intended.
903  if (FS_explicit_specified) {
904  DiagID = diag::warn_duplicate_declspec;
905  PrevSpec = "explicit";
906  return true;
907  }
908  FS_explicit_specified = true;
909  FS_explicitLoc = Loc;
910  return false;
911 }
912 
914  const char *&PrevSpec,
915  unsigned &DiagID) {
916  // '_Noreturn _Noreturn' is ok, but warn as this is likely not what the user
917  // intended.
918  if (FS_noreturn_specified) {
919  DiagID = diag::warn_duplicate_declspec;
920  PrevSpec = "_Noreturn";
921  return true;
922  }
923  FS_noreturn_specified = true;
924  FS_noreturnLoc = Loc;
925  return false;
926 }
927 
928 bool DeclSpec::SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
929  unsigned &DiagID) {
930  if (Friend_specified) {
931  PrevSpec = "friend";
932  // Keep the later location, so that we can later diagnose ill-formed
933  // declarations like 'friend class X friend;'. Per [class.friend]p3,
934  // 'friend' must be the first token in a friend declaration that is
935  // not a function declaration.
936  FriendLoc = Loc;
937  DiagID = diag::warn_duplicate_declspec;
938  return true;
939  }
940 
941  Friend_specified = true;
942  FriendLoc = Loc;
943  return false;
944 }
945 
946 bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
947  unsigned &DiagID) {
948  if (isModulePrivateSpecified()) {
949  PrevSpec = "__module_private__";
950  DiagID = diag::ext_duplicate_declspec;
951  return true;
952  }
953 
954  ModulePrivateLoc = Loc;
955  return false;
956 }
957 
958 bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec,
959  unsigned &DiagID) {
960  // 'constexpr constexpr' is ok, but warn as this is likely not what the user
961  // intended.
962  if (Constexpr_specified) {
963  DiagID = diag::warn_duplicate_declspec;
964  PrevSpec = "constexpr";
965  return true;
966  }
967  Constexpr_specified = true;
968  ConstexprLoc = Loc;
969  return false;
970 }
971 
972 bool DeclSpec::SetConceptSpec(SourceLocation Loc, const char *&PrevSpec,
973  unsigned &DiagID) {
974  if (Concept_specified) {
975  DiagID = diag::ext_duplicate_declspec;
976  PrevSpec = "concept";
977  return true;
978  }
979  Concept_specified = true;
980  ConceptLoc = Loc;
981  return false;
982 }
983 
984 void DeclSpec::SaveWrittenBuiltinSpecs() {
985  writtenBS.Sign = getTypeSpecSign();
986  writtenBS.Width = getTypeSpecWidth();
987  writtenBS.Type = getTypeSpecType();
988  // Search the list of attributes for the presence of a mode attribute.
989  writtenBS.ModeAttr = false;
990  AttributeList* attrs = getAttributes().getList();
991  while (attrs) {
992  if (attrs->getKind() == AttributeList::AT_Mode) {
993  writtenBS.ModeAttr = true;
994  break;
995  }
996  attrs = attrs->getNext();
997  }
998 }
999 
1000 /// Finish - This does final analysis of the declspec, rejecting things like
1001 /// "_Imaginary" (lacking an FP type). This returns a diagnostic to issue or
1002 /// diag::NUM_DIAGNOSTICS if there is no error. After calling this method,
1003 /// DeclSpec is guaranteed self-consistent, even if an error occurred.
1004 void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
1005  // Before possibly changing their values, save specs as written.
1006  SaveWrittenBuiltinSpecs();
1007 
1008  // Check the type specifier components first.
1009 
1010  // If decltype(auto) is used, no other type specifiers are permitted.
1011  if (TypeSpecType == TST_decltype_auto &&
1012  (TypeSpecWidth != TSW_unspecified ||
1013  TypeSpecComplex != TSC_unspecified ||
1014  TypeSpecSign != TSS_unspecified ||
1015  TypeAltiVecVector || TypeAltiVecPixel || TypeAltiVecBool ||
1016  TypeQualifiers)) {
1017  const unsigned NumLocs = 9;
1018  SourceLocation ExtraLocs[NumLocs] = {
1019  TSWRange.getBegin(), TSCLoc, TSSLoc,
1020  AltiVecLoc, TQ_constLoc, TQ_restrictLoc,
1021  TQ_volatileLoc, TQ_atomicLoc, TQ_unalignedLoc};
1022  FixItHint Hints[NumLocs];
1023  SourceLocation FirstLoc;
1024  for (unsigned I = 0; I != NumLocs; ++I) {
1025  if (ExtraLocs[I].isValid()) {
1026  if (FirstLoc.isInvalid() ||
1028  FirstLoc))
1029  FirstLoc = ExtraLocs[I];
1030  Hints[I] = FixItHint::CreateRemoval(ExtraLocs[I]);
1031  }
1032  }
1033  TypeSpecWidth = TSW_unspecified;
1034  TypeSpecComplex = TSC_unspecified;
1035  TypeSpecSign = TSS_unspecified;
1036  TypeAltiVecVector = TypeAltiVecPixel = TypeAltiVecBool = false;
1037  TypeQualifiers = 0;
1038  S.Diag(TSTLoc, diag::err_decltype_auto_cannot_be_combined)
1039  << Hints[0] << Hints[1] << Hints[2] << Hints[3]
1040  << Hints[4] << Hints[5] << Hints[6] << Hints[7];
1041  }
1042 
1043  // Validate and finalize AltiVec vector declspec.
1044  if (TypeAltiVecVector) {
1045  if (TypeAltiVecBool) {
1046  // Sign specifiers are not allowed with vector bool. (PIM 2.1)
1047  if (TypeSpecSign != TSS_unspecified) {
1048  S.Diag(TSSLoc, diag::err_invalid_vector_bool_decl_spec)
1049  << getSpecifierName((TSS)TypeSpecSign);
1050  }
1051 
1052  // Only char/int are valid with vector bool. (PIM 2.1)
1053  if (((TypeSpecType != TST_unspecified) && (TypeSpecType != TST_char) &&
1054  (TypeSpecType != TST_int)) || TypeAltiVecPixel) {
1055  S.Diag(TSTLoc, diag::err_invalid_vector_bool_decl_spec)
1056  << (TypeAltiVecPixel ? "__pixel" :
1057  getSpecifierName((TST)TypeSpecType, Policy));
1058  }
1059 
1060  // Only 'short' and 'long long' are valid with vector bool. (PIM 2.1)
1061  if ((TypeSpecWidth != TSW_unspecified) && (TypeSpecWidth != TSW_short) &&
1062  (TypeSpecWidth != TSW_longlong))
1063  S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_bool_decl_spec)
1064  << getSpecifierName((TSW)TypeSpecWidth);
1065 
1066  // vector bool long long requires VSX support or ZVector.
1067  if ((TypeSpecWidth == TSW_longlong) &&
1068  (!S.Context.getTargetInfo().hasFeature("vsx")) &&
1069  (!S.Context.getTargetInfo().hasFeature("power8-vector")) &&
1070  !S.getLangOpts().ZVector)
1071  S.Diag(TSTLoc, diag::err_invalid_vector_long_long_decl_spec);
1072 
1073  // Elements of vector bool are interpreted as unsigned. (PIM 2.1)
1074  if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) ||
1075  (TypeSpecWidth != TSW_unspecified))
1076  TypeSpecSign = TSS_unsigned;
1077  } else if (TypeSpecType == TST_double) {
1078  // vector long double and vector long long double are never allowed.
1079  // vector double is OK for Power7 and later, and ZVector.
1080  if (TypeSpecWidth == TSW_long || TypeSpecWidth == TSW_longlong)
1081  S.Diag(TSWRange.getBegin(),
1082  diag::err_invalid_vector_long_double_decl_spec);
1083  else if (!S.Context.getTargetInfo().hasFeature("vsx") &&
1084  !S.getLangOpts().ZVector)
1085  S.Diag(TSTLoc, diag::err_invalid_vector_double_decl_spec);
1086  } else if (TypeSpecType == TST_float) {
1087  // vector float is unsupported for ZVector unless we have the
1088  // vector-enhancements facility 1 (ISA revision 12).
1089  if (S.getLangOpts().ZVector &&
1090  !S.Context.getTargetInfo().hasFeature("arch12"))
1091  S.Diag(TSTLoc, diag::err_invalid_vector_float_decl_spec);
1092  } else if (TypeSpecWidth == TSW_long) {
1093  // vector long is unsupported for ZVector and deprecated for AltiVec.
1094  if (S.getLangOpts().ZVector)
1095  S.Diag(TSWRange.getBegin(), diag::err_invalid_vector_long_decl_spec);
1096  else
1097  S.Diag(TSWRange.getBegin(),
1098  diag::warn_vector_long_decl_spec_combination)
1099  << getSpecifierName((TST)TypeSpecType, Policy);
1100  }
1101 
1102  if (TypeAltiVecPixel) {
1103  //TODO: perform validation
1104  TypeSpecType = TST_int;
1105  TypeSpecSign = TSS_unsigned;
1106  TypeSpecWidth = TSW_short;
1107  TypeSpecOwned = false;
1108  }
1109  }
1110 
1111  // signed/unsigned are only valid with int/char/wchar_t.
1112  if (TypeSpecSign != TSS_unspecified) {
1113  if (TypeSpecType == TST_unspecified)
1114  TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
1115  else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 &&
1116  TypeSpecType != TST_char && TypeSpecType != TST_wchar) {
1117  S.Diag(TSSLoc, diag::err_invalid_sign_spec)
1118  << getSpecifierName((TST)TypeSpecType, Policy);
1119  // signed double -> double.
1120  TypeSpecSign = TSS_unspecified;
1121  }
1122  }
1123 
1124  // Validate the width of the type.
1125  switch (TypeSpecWidth) {
1126  case TSW_unspecified: break;
1127  case TSW_short: // short int
1128  case TSW_longlong: // long long int
1129  if (TypeSpecType == TST_unspecified)
1130  TypeSpecType = TST_int; // short -> short int, long long -> long long int.
1131  else if (TypeSpecType != TST_int) {
1132  S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1133  << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1134  TypeSpecType = TST_int;
1135  TypeSpecOwned = false;
1136  }
1137  break;
1138  case TSW_long: // long double, long int
1139  if (TypeSpecType == TST_unspecified)
1140  TypeSpecType = TST_int; // long -> long int.
1141  else if (TypeSpecType != TST_int && TypeSpecType != TST_double) {
1142  S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1143  << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1144  TypeSpecType = TST_int;
1145  TypeSpecOwned = false;
1146  }
1147  break;
1148  }
1149 
1150  // TODO: if the implementation does not implement _Complex or _Imaginary,
1151  // disallow their use. Need information about the backend.
1152  if (TypeSpecComplex != TSC_unspecified) {
1153  if (TypeSpecType == TST_unspecified) {
1154  S.Diag(TSCLoc, diag::ext_plain_complex)
1156  S.getLocForEndOfToken(getTypeSpecComplexLoc()),
1157  " double");
1158  TypeSpecType = TST_double; // _Complex -> _Complex double.
1159  } else if (TypeSpecType == TST_int || TypeSpecType == TST_char) {
1160  // Note that this intentionally doesn't include _Complex _Bool.
1161  if (!S.getLangOpts().CPlusPlus)
1162  S.Diag(TSTLoc, diag::ext_integer_complex);
1163  } else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
1164  S.Diag(TSCLoc, diag::err_invalid_complex_spec)
1165  << getSpecifierName((TST)TypeSpecType, Policy);
1166  TypeSpecComplex = TSC_unspecified;
1167  }
1168  }
1169 
1170  // C11 6.7.1/3, C++11 [dcl.stc]p1, GNU TLS: __thread, thread_local and
1171  // _Thread_local can only appear with the 'static' and 'extern' storage class
1172  // specifiers. We also allow __private_extern__ as an extension.
1173  if (ThreadStorageClassSpec != TSCS_unspecified) {
1174  switch (StorageClassSpec) {
1175  case SCS_unspecified:
1176  case SCS_extern:
1177  case SCS_private_extern:
1178  case SCS_static:
1179  break;
1180  default:
1182  getThreadStorageClassSpecLoc(), getStorageClassSpecLoc()))
1183  S.Diag(getStorageClassSpecLoc(),
1184  diag::err_invalid_decl_spec_combination)
1185  << DeclSpec::getSpecifierName(getThreadStorageClassSpec())
1186  << SourceRange(getThreadStorageClassSpecLoc());
1187  else
1188  S.Diag(getThreadStorageClassSpecLoc(),
1189  diag::err_invalid_decl_spec_combination)
1190  << DeclSpec::getSpecifierName(getStorageClassSpec())
1191  << SourceRange(getStorageClassSpecLoc());
1192  // Discard the thread storage class specifier to recover.
1193  ThreadStorageClassSpec = TSCS_unspecified;
1194  ThreadStorageClassSpecLoc = SourceLocation();
1195  }
1196  }
1197 
1198  // If no type specifier was provided and we're parsing a language where
1199  // the type specifier is not optional, but we got 'auto' as a storage
1200  // class specifier, then assume this is an attempt to use C++0x's 'auto'
1201  // type specifier.
1202  if (S.getLangOpts().CPlusPlus &&
1203  TypeSpecType == TST_unspecified && StorageClassSpec == SCS_auto) {
1204  TypeSpecType = TST_auto;
1205  StorageClassSpec = SCS_unspecified;
1206  TSTLoc = TSTNameLoc = StorageClassSpecLoc;
1207  StorageClassSpecLoc = SourceLocation();
1208  }
1209  // Diagnose if we've recovered from an ill-formed 'auto' storage class
1210  // specifier in a pre-C++11 dialect of C++.
1211  if (!S.getLangOpts().CPlusPlus11 && TypeSpecType == TST_auto)
1212  S.Diag(TSTLoc, diag::ext_auto_type_specifier);
1213  if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11 &&
1214  StorageClassSpec == SCS_auto)
1215  S.Diag(StorageClassSpecLoc, diag::warn_auto_storage_class)
1216  << FixItHint::CreateRemoval(StorageClassSpecLoc);
1217  if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32)
1218  S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type)
1219  << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
1220  if (Constexpr_specified)
1221  S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr);
1222 
1223  // C++ [class.friend]p6:
1224  // No storage-class-specifier shall appear in the decl-specifier-seq
1225  // of a friend declaration.
1226  if (isFriendSpecified() &&
1227  (getStorageClassSpec() || getThreadStorageClassSpec())) {
1228  SmallString<32> SpecName;
1229  SourceLocation SCLoc;
1230  FixItHint StorageHint, ThreadHint;
1231 
1232  if (DeclSpec::SCS SC = getStorageClassSpec()) {
1233  SpecName = getSpecifierName(SC);
1234  SCLoc = getStorageClassSpecLoc();
1235  StorageHint = FixItHint::CreateRemoval(SCLoc);
1236  }
1237 
1238  if (DeclSpec::TSCS TSC = getThreadStorageClassSpec()) {
1239  if (!SpecName.empty()) SpecName += " ";
1240  SpecName += getSpecifierName(TSC);
1241  SCLoc = getThreadStorageClassSpecLoc();
1242  ThreadHint = FixItHint::CreateRemoval(SCLoc);
1243  }
1244 
1245  S.Diag(SCLoc, diag::err_friend_decl_spec)
1246  << SpecName << StorageHint << ThreadHint;
1247 
1248  ClearStorageClassSpecs();
1249  }
1250 
1251  // C++11 [dcl.fct.spec]p5:
1252  // The virtual specifier shall be used only in the initial
1253  // declaration of a non-static class member function;
1254  // C++11 [dcl.fct.spec]p6:
1255  // The explicit specifier shall be used only in the declaration of
1256  // a constructor or conversion function within its class
1257  // definition;
1258  if (isFriendSpecified() && (isVirtualSpecified() || isExplicitSpecified())) {
1259  StringRef Keyword;
1260  SourceLocation SCLoc;
1261 
1262  if (isVirtualSpecified()) {
1263  Keyword = "virtual";
1264  SCLoc = getVirtualSpecLoc();
1265  } else {
1266  Keyword = "explicit";
1267  SCLoc = getExplicitSpecLoc();
1268  }
1269 
1270  FixItHint Hint = FixItHint::CreateRemoval(SCLoc);
1271  S.Diag(SCLoc, diag::err_friend_decl_spec)
1272  << Keyword << Hint;
1273 
1274  FS_virtual_specified = FS_explicit_specified = false;
1275  FS_virtualLoc = FS_explicitLoc = SourceLocation();
1276  }
1277 
1278  assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
1279 
1280  // Okay, now we can infer the real type.
1281 
1282  // TODO: return "auto function" and other bad things based on the real type.
1283 
1284  // 'data definition has no type or storage class'?
1285 }
1286 
1288  TST tst = getTypeSpecType();
1289  return isDeclRep(tst) && getRepAsDecl() != nullptr &&
1290  StorageClassSpec != DeclSpec::SCS_typedef;
1291 }
1292 
1295  SourceLocation SymbolLocations[3]) {
1297  StartLocation = OperatorLoc;
1298  EndLocation = OperatorLoc;
1300  for (unsigned I = 0; I != 3; ++I) {
1301  OperatorFunctionId.SymbolLocations[I] = SymbolLocations[I].getRawEncoding();
1302 
1303  if (SymbolLocations[I].isValid())
1304  EndLocation = SymbolLocations[I];
1305  }
1306 }
1307 
1309  const char *&PrevSpec) {
1310  if (!FirstLocation.isValid())
1311  FirstLocation = Loc;
1312  LastLocation = Loc;
1313  LastSpecifier = VS;
1314 
1315  if (Specifiers & VS) {
1316  PrevSpec = getSpecifierName(VS);
1317  return true;
1318  }
1319 
1320  Specifiers |= VS;
1321 
1322  switch (VS) {
1323  default: llvm_unreachable("Unknown specifier!");
1324  case VS_Override: VS_overrideLoc = Loc; break;
1325  case VS_GNU_Final:
1326  case VS_Sealed:
1327  case VS_Final: VS_finalLoc = Loc; break;
1328  }
1329 
1330  return false;
1331 }
1332 
1334  switch (VS) {
1335  default: llvm_unreachable("Unknown specifier");
1336  case VS_Override: return "override";
1337  case VS_Final: return "final";
1338  case VS_GNU_Final: return "__final";
1339  case VS_Sealed: return "sealed";
1340  }
1341 }
Defines the clang::ASTContext interface.
unsigned MutableLoc
The location of the &#39;mutable&#39; qualifer in a lambda-declarator, if any.
Definition: DeclSpec.h:1309
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
Definition: DeclSpec.h:1253
no exception specification
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
Definition: DeclSpec.cpp:136
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into &#39;__super&#39; nested-name-specifier.
Definition: DeclSpec.cpp:107
A (possibly-)qualified type.
Definition: Type.h:614
AttributeList * getNext() const
unsigned RestrictQualifierLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1305
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Definition: DeclSpec.h:979
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
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Definition: DeclSpec.h:949
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
static const TST TST_typeofExpr
Definition: DeclSpec.h:296
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1270
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:1312
bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:958
unsigned EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
Definition: DeclSpec.h:1273
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
One instance of this struct is used for each type in a declarator that is parsed. ...
Definition: DeclSpec.h:1134
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:474
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
Definition: DeclSpec.h:1142
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:1285
NamedDecl ** DeclsInPrototype
Pointer to a new[]&#39;d array of declarations that need to be available for lookup inside the function b...
Definition: DeclSpec.h:1339
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:495
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:645
static const char * getSpecifierName(Specifier VS)
Definition: DeclSpec.cpp:1333
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:808
unsigned RefQualifierLoc
The location of the ref-qualifier, if any.
Definition: DeclSpec.h:1290
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:299
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1734
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:898
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
Definition: DeclSpec.cpp:411
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:45
static const TST TST_interface
Definition: DeclSpec.h:292
static const TST TST_char
Definition: DeclSpec.h:274
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:1194
Information about a template-id annotation token.
static const TST TST_unknown_anytype
Definition: DeclSpec.h:302
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:973
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1330
One of these records is kept for each identifier that is lexed.
Kind getKind() const
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:286
IdKind getKind() const
Determine what kind of name we have.
Definition: DeclSpec.h:1002
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:1300
static const TST TST_class
Definition: DeclSpec.h:293
OverloadedOperatorKind Operator
The kind of overloaded operator.
Definition: DeclSpec.h:932
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
Definition: DeclSpec.h:1257
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:953
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:883
static const TST TST_error
Definition: DeclSpec.h:307
static const TST TST_enum
Definition: DeclSpec.h:289
bool hasTagDefinition() const
Definition: DeclSpec.cpp:402
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:793
PtrTy get() const
Definition: Ownership.h:162
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:871
SCS
storage-class-specifier
Definition: DeclSpec.h:232
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
Definition: DeclSpec.h:1267
enum clang::DeclaratorChunk::@198 Kind
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:928
unsigned RParenLoc
The location of the right parenthesis in the source.
Definition: DeclSpec.h:1276
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:777
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:913
const LangOptions & getLangOpts() const
Definition: Sema.h:1193
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
Definition: DeclSpec.cpp:31
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Definition: DeclSpec.cpp:143
static const TST TST_float
Definition: DeclSpec.h:281
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:274
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: DeclSpec.cpp:119
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
Definition: LocInfoType.h:29
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
Definition: DeclSpec.cpp:308
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1280
bool isEnabled(llvm::StringRef Ext) const
Definition: OpenCLOptions.h:39
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:169
Expr - This represents one expression.
Definition: Expr.h:106
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
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
const FunctionProtoType * T
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:941
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:1820
static const TST TST_decimal64
Definition: DeclSpec.h:287
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:1334
SourceLocation Loc
Loc - The place where this type was defined.
Definition: DeclSpec.h:1140
static const TST TST_int
Definition: DeclSpec.h:278
bool isInvalid() const
Definition: Ownership.h:158
SourceLocation getEnd() const
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:653
static const TST TST_half
Definition: DeclSpec.h:280
Wraps an identifier and optional source location for the identifier.
Definition: AttributeList.h:73
bool isUsable() const
Definition: Ownership.h:159
static bool BadSpecifier(T TNew, T TPrev, const char *&PrevSpec, unsigned &DiagID, bool IsExtension=true)
Definition: DeclSpec.cpp:429
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:681
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
Definition: DeclSpec.h:996
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
Definition: DeclSpec.h:1344
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:626
TypeAndRange * Exceptions
Pointer to a new[]&#39;d array of TypeAndRange objects that contain the types in the function&#39;s dynamic e...
Definition: DeclSpec.h:1326
static const TST TST_char32
Definition: DeclSpec.h:277
unsigned Bool
Whether we can use &#39;bool&#39; rather than &#39;_Bool&#39; (even if the language doesn&#39;t actually have &#39;bool&#39;...
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
Definition: DeclSpec.cpp:397
bool SetConceptSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:972
Kind
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:144
static const TST TST_float16
Definition: DeclSpec.h:283
Encodes a location in the source.
static const TST TST_auto_type
Definition: DeclSpec.h:301
An overloaded operator name, e.g., operator+.
Definition: DeclSpec.h:911
FunctionTypeInfo Fun
Definition: DeclSpec.h:1504
static const TST TST_union
Definition: DeclSpec.h:290
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:551
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
static const TST TST_typeofType
Definition: DeclSpec.h:295
bool isInvalid() const
Determine whether this unqualified-id refers to an invalid name.
Definition: DeclSpec.h:999
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
Definition: DeclSpec.cpp:831
bool isStaticMember()
Returns true if this declares a static member.
Definition: DeclSpec.cpp:389
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:764
A constructor named via a template-id.
Definition: DeclSpec.h:919
static const TST TST_decltype_auto
Definition: DeclSpec.h:298
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:946
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Definition: DeclCXX.h:1949
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
static const TST TST_decltype
Definition: DeclSpec.h:297
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
static const TST TST_auto
Definition: DeclSpec.h:300
static const TST TST_void
Definition: DeclSpec.h:273
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with &#39;,...)&#39;, this is true.
Definition: DeclSpec.h:1246
SourceLocation RAngleLoc
The location of the &#39;>&#39; 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:1263
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
Definition: DeclSpec.cpp:1287
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
Definition: Diagnostic.h:116
unsigned ConstQualifierLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1295
static const TST TST_unspecified
Definition: DeclSpec.h:272
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
Definition: TargetInfo.h:911
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
Definition: DeclSpec.cpp:1308
static const TST TST_decimal128
Definition: DeclSpec.h:288
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:1241
unsigned LParenLoc
The location of the left parenthesis in the source.
Definition: DeclSpec.h:1270
bool isFunctionType() const
Definition: Type.h:5763
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:612
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Definition: DeclSpec.cpp:1293
static const TST TST_typename
Definition: DeclSpec.h:294
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:923
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:742
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 &#39;type...
Definition: DeclSpec.cpp:47
unsigned ExceptionSpecType
ExceptionSpecType - An ExceptionSpecificationType value.
Definition: DeclSpec.h:1260
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:190
Represents a C++ struct/union/class.
Definition: DeclCXX.h:266
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:284
internal::Matcher< NamedDecl > hasName(const std::string &Name)
Matches NamedDecl nodes that have the specified name.
Definition: ASTMatchers.h:2267
static const TST TST_bool
Definition: DeclSpec.h:285
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier &#39;::&#39;.
Definition: DeclSpec.cpp:97
SourceManager & getSourceManager() const
Definition: Sema.h:1198
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
Definition: DeclSpec.cpp:1004
Defines the clang::TargetInfo interface.
static const TST TST_atomic
Definition: DeclSpec.h:303
static const TST TST_struct
Definition: DeclSpec.h:291
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:1212
A trivial tuple used to represent a source range.
ASTContext & Context
Definition: Sema.h:316
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:643
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
bool SetTypeSpecError()
Definition: DeclSpec.cpp:823
unsigned ExceptionSpecLocEnd
The end location of the exception specification, if any.
Definition: DeclSpec.h:1315
Represents a C++ namespace alias.
Definition: DeclCXX.h:2882
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
Definition: DeclSpec.h:982
static const TSCS TSCS__Thread_local
Definition: DeclSpec.h:249
SourceLocation getBegin() const
ParamInfo * Params
Params - This is a pointer to a new[]&#39;d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1320
AttributeList - Represents a syntactic attribute.
Definition: AttributeList.h:95
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:857
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
Definition: DeclSpec.h:1249