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