clang  8.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.hasPrototype = hasProto;
190  I.Fun.isVariadic = EllipsisLoc.isValid();
191  I.Fun.isAmbiguous = isAmbiguous;
192  I.Fun.LParenLoc = LParenLoc.getRawEncoding();
193  I.Fun.EllipsisLoc = EllipsisLoc.getRawEncoding();
194  I.Fun.RParenLoc = RParenLoc.getRawEncoding();
195  I.Fun.DeleteParams = false;
196  I.Fun.TypeQuals = TypeQuals;
197  I.Fun.NumParams = NumParams;
198  I.Fun.Params = nullptr;
199  I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef;
200  I.Fun.RefQualifierLoc = RefQualifierLoc.getRawEncoding();
201  I.Fun.ConstQualifierLoc = ConstQualifierLoc.getRawEncoding();
202  I.Fun.VolatileQualifierLoc = VolatileQualifierLoc.getRawEncoding();
203  I.Fun.RestrictQualifierLoc = RestrictQualifierLoc.getRawEncoding();
204  I.Fun.MutableLoc = MutableLoc.getRawEncoding();
205  I.Fun.ExceptionSpecType = ESpecType;
206  I.Fun.ExceptionSpecLocBeg = ESpecRange.getBegin().getRawEncoding();
207  I.Fun.ExceptionSpecLocEnd = ESpecRange.getEnd().getRawEncoding();
209  I.Fun.Exceptions = nullptr;
210  I.Fun.NoexceptExpr = nullptr;
211  I.Fun.HasTrailingReturnType = TrailingReturnType.isUsable() ||
212  TrailingReturnType.isInvalid();
213  I.Fun.TrailingReturnType = TrailingReturnType.get();
214 
215  assert(I.Fun.TypeQuals == TypeQuals && "bitfield overflow");
216  assert(I.Fun.ExceptionSpecType == ESpecType && "bitfield overflow");
217 
218  // new[] a parameter array if needed.
219  if (NumParams) {
220  // If the 'InlineParams' in Declarator is unused and big enough, put our
221  // parameter list there (in an effort to avoid new/delete traffic). If it
222  // is already used (consider a function returning a function pointer) or too
223  // small (function with too many parameters), go to the heap.
224  if (!TheDeclarator.InlineStorageUsed &&
225  NumParams <= llvm::array_lengthof(TheDeclarator.InlineParams)) {
226  I.Fun.Params = TheDeclarator.InlineParams;
227  new (I.Fun.Params) ParamInfo[NumParams];
228  I.Fun.DeleteParams = false;
229  TheDeclarator.InlineStorageUsed = true;
230  } else {
231  I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams];
232  I.Fun.DeleteParams = true;
233  }
234  for (unsigned i = 0; i < NumParams; i++)
235  I.Fun.Params[i] = std::move(Params[i]);
236  }
237 
238  // Check what exception specification information we should actually store.
239  switch (ESpecType) {
240  default: break; // By default, save nothing.
241  case EST_Dynamic:
242  // new[] an exception array if needed
243  if (NumExceptions) {
244  I.Fun.NumExceptionsOrDecls = NumExceptions;
245  I.Fun.Exceptions = new DeclaratorChunk::TypeAndRange[NumExceptions];
246  for (unsigned i = 0; i != NumExceptions; ++i) {
247  I.Fun.Exceptions[i].Ty = Exceptions[i];
248  I.Fun.Exceptions[i].Range = ExceptionRanges[i];
249  }
250  }
251  break;
252 
254  case EST_NoexceptFalse:
255  case EST_NoexceptTrue:
256  I.Fun.NoexceptExpr = NoexceptExpr;
257  break;
258 
259  case EST_Unparsed:
260  I.Fun.ExceptionSpecTokens = ExceptionSpecTokens;
261  break;
262  }
263 
264  if (!DeclsInPrototype.empty()) {
265  assert(ESpecType == EST_None && NumExceptions == 0 &&
266  "cannot have exception specifiers and decls in prototype");
267  I.Fun.NumExceptionsOrDecls = DeclsInPrototype.size();
268  // Copy the array of decls into stable heap storage.
269  I.Fun.DeclsInPrototype = new NamedDecl *[DeclsInPrototype.size()];
270  for (size_t J = 0; J < DeclsInPrototype.size(); ++J)
271  I.Fun.DeclsInPrototype[J] = DeclsInPrototype[J];
272  }
273 
274  return I;
275 }
276 
278  SourceLocation LSquareLoc,
280  SourceLocation RSquareLoc) {
281  assert(!hasName() && "declarator given multiple names!");
282 
283  BindingGroup.LSquareLoc = LSquareLoc;
284  BindingGroup.RSquareLoc = RSquareLoc;
285  BindingGroup.NumBindings = Bindings.size();
286  Range.setEnd(RSquareLoc);
287 
288  // We're now past the identifier.
289  SetIdentifier(nullptr, LSquareLoc);
290  Name.EndLocation = RSquareLoc;
291 
292  // Allocate storage for bindings and stash them away.
293  if (Bindings.size()) {
294  if (!InlineStorageUsed &&
295  Bindings.size() <= llvm::array_lengthof(InlineBindings)) {
296  BindingGroup.Bindings = InlineBindings;
297  BindingGroup.DeleteBindings = false;
298  InlineStorageUsed = true;
299  } else {
300  BindingGroup.Bindings =
301  new DecompositionDeclarator::Binding[Bindings.size()];
302  BindingGroup.DeleteBindings = true;
303  }
304  std::uninitialized_copy(Bindings.begin(), Bindings.end(),
305  BindingGroup.Bindings);
306  }
307 }
308 
310  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
311  switch (DeclTypeInfo[i].Kind) {
313  return true;
315  continue;
322  return false;
323  }
324  llvm_unreachable("Invalid type chunk");
325  }
326 
327  switch (DS.getTypeSpecType()) {
328  case TST_atomic:
329  case TST_auto:
330  case TST_auto_type:
331  case TST_bool:
332  case TST_char:
333  case TST_char8:
334  case TST_char16:
335  case TST_char32:
336  case TST_class:
337  case TST_decimal128:
338  case TST_decimal32:
339  case TST_decimal64:
340  case TST_double:
341  case TST_Accum:
342  case TST_Fract:
343  case TST_Float16:
344  case TST_float128:
345  case TST_enum:
346  case TST_error:
347  case TST_float:
348  case TST_half:
349  case TST_int:
350  case TST_int128:
351  case TST_struct:
352  case TST_interface:
353  case TST_union:
354  case TST_unknown_anytype:
355  case TST_unspecified:
356  case TST_void:
357  case TST_wchar:
358 #define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
359 #include "clang/Basic/OpenCLImageTypes.def"
360  return false;
361 
362  case TST_decltype_auto:
363  // This must have an initializer, so can't be a function declaration,
364  // even if the initializer has function type.
365  return false;
366 
367  case TST_decltype:
368  case TST_typeofExpr:
369  if (Expr *E = DS.getRepAsExpr())
370  return E->getType()->isFunctionType();
371  return false;
372 
373  case TST_underlyingType:
374  case TST_typename:
375  case TST_typeofType: {
376  QualType QT = DS.getRepAsType().get();
377  if (QT.isNull())
378  return false;
379 
380  if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT))
381  QT = LIT->getType();
382 
383  if (QT.isNull())
384  return false;
385 
386  return QT->isFunctionType();
387  }
388  }
389 
390  llvm_unreachable("Invalid TypeSpecType!");
391 }
392 
394  assert(getContext() == DeclaratorContext::MemberContext);
395  return getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
399 }
400 
404 }
405 
407  if (!TypeSpecOwned)
408  return false;
409  return cast<TagDecl>(getRepAsDecl())->isCompleteDefinition();
410 }
411 
412 /// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
413 /// declaration specifier includes.
414 ///
416  unsigned Res = 0;
417  if (StorageClassSpec != SCS_unspecified ||
418  ThreadStorageClassSpec != TSCS_unspecified)
419  Res |= PQ_StorageClassSpecifier;
420 
421  if (TypeQualifiers != TQ_unspecified)
422  Res |= PQ_TypeQualifier;
423 
424  if (hasTypeSpecifier())
425  Res |= PQ_TypeSpecifier;
426 
427  if (FS_inline_specified || FS_virtual_specified || FS_explicit_specified ||
428  FS_noreturn_specified || FS_forceinline_specified)
429  Res |= PQ_FunctionSpecifier;
430  return Res;
431 }
432 
433 template <class T> static bool BadSpecifier(T TNew, T TPrev,
434  const char *&PrevSpec,
435  unsigned &DiagID,
436  bool IsExtension = true) {
437  PrevSpec = DeclSpec::getSpecifierName(TPrev);
438  if (TNew != TPrev)
439  DiagID = diag::err_invalid_decl_spec_combination;
440  else
441  DiagID = IsExtension ? diag::ext_warn_duplicate_declspec :
442  diag::warn_duplicate_declspec;
443  return true;
444 }
445 
447  switch (S) {
448  case DeclSpec::SCS_unspecified: return "unspecified";
449  case DeclSpec::SCS_typedef: return "typedef";
450  case DeclSpec::SCS_extern: return "extern";
451  case DeclSpec::SCS_static: return "static";
452  case DeclSpec::SCS_auto: return "auto";
453  case DeclSpec::SCS_register: return "register";
454  case DeclSpec::SCS_private_extern: return "__private_extern__";
455  case DeclSpec::SCS_mutable: return "mutable";
456  }
457  llvm_unreachable("Unknown typespec!");
458 }
459 
461  switch (S) {
462  case DeclSpec::TSCS_unspecified: return "unspecified";
463  case DeclSpec::TSCS___thread: return "__thread";
464  case DeclSpec::TSCS_thread_local: return "thread_local";
465  case DeclSpec::TSCS__Thread_local: return "_Thread_local";
466  }
467  llvm_unreachable("Unknown typespec!");
468 }
469 
471  switch (W) {
472  case TSW_unspecified: return "unspecified";
473  case TSW_short: return "short";
474  case TSW_long: return "long";
475  case TSW_longlong: return "long long";
476  }
477  llvm_unreachable("Unknown typespec!");
478 }
479 
481  switch (C) {
482  case TSC_unspecified: return "unspecified";
483  case TSC_imaginary: return "imaginary";
484  case TSC_complex: return "complex";
485  }
486  llvm_unreachable("Unknown typespec!");
487 }
488 
489 
491  switch (S) {
492  case TSS_unspecified: return "unspecified";
493  case TSS_signed: return "signed";
494  case TSS_unsigned: return "unsigned";
495  }
496  llvm_unreachable("Unknown typespec!");
497 }
498 
500  const PrintingPolicy &Policy) {
501  switch (T) {
502  case DeclSpec::TST_unspecified: return "unspecified";
503  case DeclSpec::TST_void: return "void";
504  case DeclSpec::TST_char: return "char";
505  case DeclSpec::TST_wchar: return Policy.MSWChar ? "__wchar_t" : "wchar_t";
506  case DeclSpec::TST_char8: return "char8_t";
507  case DeclSpec::TST_char16: return "char16_t";
508  case DeclSpec::TST_char32: return "char32_t";
509  case DeclSpec::TST_int: return "int";
510  case DeclSpec::TST_int128: return "__int128";
511  case DeclSpec::TST_half: return "half";
512  case DeclSpec::TST_float: return "float";
513  case DeclSpec::TST_double: return "double";
514  case DeclSpec::TST_accum: return "_Accum";
515  case DeclSpec::TST_fract: return "_Fract";
516  case DeclSpec::TST_float16: return "_Float16";
517  case DeclSpec::TST_float128: return "__float128";
518  case DeclSpec::TST_bool: return Policy.Bool ? "bool" : "_Bool";
519  case DeclSpec::TST_decimal32: return "_Decimal32";
520  case DeclSpec::TST_decimal64: return "_Decimal64";
521  case DeclSpec::TST_decimal128: return "_Decimal128";
522  case DeclSpec::TST_enum: return "enum";
523  case DeclSpec::TST_class: return "class";
524  case DeclSpec::TST_union: return "union";
525  case DeclSpec::TST_struct: return "struct";
526  case DeclSpec::TST_interface: return "__interface";
527  case DeclSpec::TST_typename: return "type-name";
529  case DeclSpec::TST_typeofExpr: return "typeof";
530  case DeclSpec::TST_auto: return "auto";
531  case DeclSpec::TST_auto_type: return "__auto_type";
532  case DeclSpec::TST_decltype: return "(decltype)";
533  case DeclSpec::TST_decltype_auto: return "decltype(auto)";
534  case DeclSpec::TST_underlyingType: return "__underlying_type";
535  case DeclSpec::TST_unknown_anytype: return "__unknown_anytype";
536  case DeclSpec::TST_atomic: return "_Atomic";
537 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
538  case DeclSpec::TST_##ImgType##_t: \
539  return #ImgType "_t";
540 #include "clang/Basic/OpenCLImageTypes.def"
541  case DeclSpec::TST_error: return "(error)";
542  }
543  llvm_unreachable("Unknown typespec!");
544 }
545 
547  switch (T) {
548  case DeclSpec::TQ_unspecified: return "unspecified";
549  case DeclSpec::TQ_const: return "const";
550  case DeclSpec::TQ_restrict: return "restrict";
551  case DeclSpec::TQ_volatile: return "volatile";
552  case DeclSpec::TQ_atomic: return "_Atomic";
553  case DeclSpec::TQ_unaligned: return "__unaligned";
554  }
555  llvm_unreachable("Unknown typespec!");
556 }
557 
559  const char *&PrevSpec,
560  unsigned &DiagID,
561  const PrintingPolicy &Policy) {
562  // OpenCL v1.1 s6.8g: "The extern, static, auto and register storage-class
563  // specifiers are not supported.
564  // It seems sensible to prohibit private_extern too
565  // The cl_clang_storage_class_specifiers extension enables support for
566  // these storage-class specifiers.
567  // OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
568  // specifiers are not supported."
569  if (S.getLangOpts().OpenCL &&
570  !S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) {
571  switch (SC) {
572  case SCS_extern:
573  case SCS_private_extern:
574  case SCS_static:
575  if (S.getLangOpts().OpenCLVersion < 120) {
576  DiagID = diag::err_opencl_unknown_type_specifier;
577  PrevSpec = getSpecifierName(SC);
578  return true;
579  }
580  break;
581  case SCS_auto:
582  case SCS_register:
583  DiagID = diag::err_opencl_unknown_type_specifier;
584  PrevSpec = getSpecifierName(SC);
585  return true;
586  default:
587  break;
588  }
589  }
590 
591  if (StorageClassSpec != SCS_unspecified) {
592  // Maybe this is an attempt to use C++11 'auto' outside of C++11 mode.
593  bool isInvalid = true;
594  if (TypeSpecType == TST_unspecified && S.getLangOpts().CPlusPlus) {
595  if (SC == SCS_auto)
596  return SetTypeSpecType(TST_auto, Loc, PrevSpec, DiagID, Policy);
597  if (StorageClassSpec == SCS_auto) {
598  isInvalid = SetTypeSpecType(TST_auto, StorageClassSpecLoc,
599  PrevSpec, DiagID, Policy);
600  assert(!isInvalid && "auto SCS -> TST recovery failed");
601  }
602  }
603 
604  // Changing storage class is allowed only if the previous one
605  // was the 'extern' that is part of a linkage specification and
606  // the new storage class is 'typedef'.
607  if (isInvalid &&
608  !(SCS_extern_in_linkage_spec &&
609  StorageClassSpec == SCS_extern &&
610  SC == SCS_typedef))
611  return BadSpecifier(SC, (SCS)StorageClassSpec, PrevSpec, DiagID);
612  }
613  StorageClassSpec = SC;
614  StorageClassSpecLoc = Loc;
615  assert((unsigned)SC == StorageClassSpec && "SCS constants overflow bitfield");
616  return false;
617 }
618 
620  const char *&PrevSpec,
621  unsigned &DiagID) {
622  if (ThreadStorageClassSpec != TSCS_unspecified)
623  return BadSpecifier(TSC, (TSCS)ThreadStorageClassSpec, PrevSpec, DiagID);
624 
625  ThreadStorageClassSpec = TSC;
626  ThreadStorageClassSpecLoc = Loc;
627  return false;
628 }
629 
630 /// These methods set the specified attribute of the DeclSpec, but return true
631 /// and ignore the request if invalid (e.g. "extern" then "auto" is
632 /// specified).
634  const char *&PrevSpec,
635  unsigned &DiagID,
636  const PrintingPolicy &Policy) {
637  // Overwrite TSWRange.Begin only if TypeSpecWidth was unspecified, so that
638  // for 'long long' we will keep the source location of the first 'long'.
639  if (TypeSpecWidth == TSW_unspecified)
640  TSWRange.setBegin(Loc);
641  // Allow turning long -> long long.
642  else if (W != TSW_longlong || TypeSpecWidth != TSW_long)
643  return BadSpecifier(W, (TSW)TypeSpecWidth, PrevSpec, DiagID);
644  TypeSpecWidth = W;
645  // Remember location of the last 'long'
646  TSWRange.setEnd(Loc);
647  return false;
648 }
649 
651  const char *&PrevSpec,
652  unsigned &DiagID) {
653  if (TypeSpecComplex != TSC_unspecified)
654  return BadSpecifier(C, (TSC)TypeSpecComplex, PrevSpec, DiagID);
655  TypeSpecComplex = C;
656  TSCLoc = Loc;
657  return false;
658 }
659 
661  const char *&PrevSpec,
662  unsigned &DiagID) {
663  if (TypeSpecSign != TSS_unspecified)
664  return BadSpecifier(S, (TSS)TypeSpecSign, PrevSpec, DiagID);
665  TypeSpecSign = S;
666  TSSLoc = Loc;
667  return false;
668 }
669 
671  const char *&PrevSpec,
672  unsigned &DiagID,
673  ParsedType Rep,
674  const PrintingPolicy &Policy) {
675  return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Policy);
676 }
677 
679  SourceLocation TagNameLoc,
680  const char *&PrevSpec,
681  unsigned &DiagID,
682  ParsedType Rep,
683  const PrintingPolicy &Policy) {
684  assert(isTypeRep(T) && "T does not store a type");
685  assert(Rep && "no type provided!");
686  if (TypeSpecType != TST_unspecified) {
687  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
688  DiagID = diag::err_invalid_decl_spec_combination;
689  return true;
690  }
691  TypeSpecType = T;
692  TypeRep = Rep;
693  TSTLoc = TagKwLoc;
694  TSTNameLoc = TagNameLoc;
695  TypeSpecOwned = false;
696  return false;
697 }
698 
700  const char *&PrevSpec,
701  unsigned &DiagID,
702  Expr *Rep,
703  const PrintingPolicy &Policy) {
704  assert(isExprRep(T) && "T does not store an expr");
705  assert(Rep && "no expression provided!");
706  if (TypeSpecType != TST_unspecified) {
707  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
708  DiagID = diag::err_invalid_decl_spec_combination;
709  return true;
710  }
711  TypeSpecType = T;
712  ExprRep = Rep;
713  TSTLoc = Loc;
714  TSTNameLoc = Loc;
715  TypeSpecOwned = false;
716  return false;
717 }
718 
720  const char *&PrevSpec,
721  unsigned &DiagID,
722  Decl *Rep, bool Owned,
723  const PrintingPolicy &Policy) {
724  return SetTypeSpecType(T, Loc, Loc, PrevSpec, DiagID, Rep, Owned, Policy);
725 }
726 
728  SourceLocation TagNameLoc,
729  const char *&PrevSpec,
730  unsigned &DiagID,
731  Decl *Rep, bool Owned,
732  const PrintingPolicy &Policy) {
733  assert(isDeclRep(T) && "T does not store a decl");
734  // Unlike the other cases, we don't assert that we actually get a decl.
735 
736  if (TypeSpecType != TST_unspecified) {
737  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
738  DiagID = diag::err_invalid_decl_spec_combination;
739  return true;
740  }
741  TypeSpecType = T;
742  DeclRep = Rep;
743  TSTLoc = TagKwLoc;
744  TSTNameLoc = TagNameLoc;
745  TypeSpecOwned = Owned && Rep != nullptr;
746  return false;
747 }
748 
750  const char *&PrevSpec,
751  unsigned &DiagID,
752  const PrintingPolicy &Policy) {
753  assert(!isDeclRep(T) && !isTypeRep(T) && !isExprRep(T) &&
754  "rep required for these type-spec kinds!");
755  if (TypeSpecType != TST_unspecified) {
756  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
757  DiagID = diag::err_invalid_decl_spec_combination;
758  return true;
759  }
760  TSTLoc = Loc;
761  TSTNameLoc = Loc;
762  if (TypeAltiVecVector && (T == TST_bool) && !TypeAltiVecBool) {
763  TypeAltiVecBool = true;
764  return false;
765  }
766  TypeSpecType = T;
767  TypeSpecOwned = false;
768  return false;
769 }
770 
771 bool DeclSpec::SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec,
772  unsigned &DiagID) {
773  // Cannot set twice
774  if (TypeSpecSat) {
775  DiagID = diag::warn_duplicate_declspec;
776  PrevSpec = "_Sat";
777  return true;
778  }
779  TypeSpecSat = true;
780  TSSatLoc = Loc;
781  return false;
782 }
783 
784 bool DeclSpec::SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
785  const char *&PrevSpec, unsigned &DiagID,
786  const PrintingPolicy &Policy) {
787  if (TypeSpecType != TST_unspecified) {
788  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
789  DiagID = diag::err_invalid_vector_decl_spec_combination;
790  return true;
791  }
792  TypeAltiVecVector = isAltiVecVector;
793  AltiVecLoc = Loc;
794  return false;
795 }
796 
797 bool DeclSpec::SetTypePipe(bool isPipe, SourceLocation Loc,
798  const char *&PrevSpec, unsigned &DiagID,
799  const PrintingPolicy &Policy) {
800 
801  if (TypeSpecType != TST_unspecified) {
802  PrevSpec = DeclSpec::getSpecifierName((TST)TypeSpecType, Policy);
803  DiagID = diag::err_invalid_decl_spec_combination;
804  return true;
805  }
806 
807  if (isPipe) {
808  TypeSpecPipe = TSP_pipe;
809  }
810  return false;
811 }
812 
813 bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
814  const char *&PrevSpec, unsigned &DiagID,
815  const PrintingPolicy &Policy) {
816  if (!TypeAltiVecVector || TypeAltiVecPixel ||
817  (TypeSpecType != TST_unspecified)) {
818  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
819  DiagID = diag::err_invalid_pixel_decl_spec_combination;
820  return true;
821  }
822  TypeAltiVecPixel = isAltiVecPixel;
823  TSTLoc = Loc;
824  TSTNameLoc = Loc;
825  return false;
826 }
827 
828 bool DeclSpec::SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
829  const char *&PrevSpec, unsigned &DiagID,
830  const PrintingPolicy &Policy) {
831  if (!TypeAltiVecVector || TypeAltiVecBool ||
832  (TypeSpecType != TST_unspecified)) {
833  PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType, Policy);
834  DiagID = diag::err_invalid_vector_bool_decl_spec;
835  return true;
836  }
837  TypeAltiVecBool = isAltiVecBool;
838  TSTLoc = Loc;
839  TSTNameLoc = Loc;
840  return false;
841 }
842 
844  TypeSpecType = TST_error;
845  TypeSpecOwned = false;
846  TSTLoc = SourceLocation();
847  TSTNameLoc = SourceLocation();
848  return false;
849 }
850 
851 bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
852  unsigned &DiagID, const LangOptions &Lang) {
853  // Duplicates are permitted in C99 onwards, but are not permitted in C89 or
854  // C++. However, since this is likely not what the user intended, we will
855  // always warn. We do not need to set the qualifier's location since we
856  // already have it.
857  if (TypeQualifiers & T) {
858  bool IsExtension = true;
859  if (Lang.C99)
860  IsExtension = false;
861  return BadSpecifier(T, T, PrevSpec, DiagID, IsExtension);
862  }
863  TypeQualifiers |= T;
864 
865  switch (T) {
866  case TQ_unspecified: break;
867  case TQ_const: TQ_constLoc = Loc; return false;
868  case TQ_restrict: TQ_restrictLoc = Loc; return false;
869  case TQ_volatile: TQ_volatileLoc = Loc; return false;
870  case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
871  case TQ_atomic: TQ_atomicLoc = Loc; return false;
872  }
873 
874  llvm_unreachable("Unknown type qualifier!");
875 }
876 
877 bool DeclSpec::setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
878  unsigned &DiagID) {
879  // 'inline inline' is ok. However, since this is likely not what the user
880  // intended, we will always warn, similar to duplicates of type qualifiers.
881  if (FS_inline_specified) {
882  DiagID = diag::warn_duplicate_declspec;
883  PrevSpec = "inline";
884  return true;
885  }
886  FS_inline_specified = true;
887  FS_inlineLoc = Loc;
888  return false;
889 }
890 
891 bool DeclSpec::setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec,
892  unsigned &DiagID) {
893  if (FS_forceinline_specified) {
894  DiagID = diag::warn_duplicate_declspec;
895  PrevSpec = "__forceinline";
896  return true;
897  }
898  FS_forceinline_specified = true;
899  FS_forceinlineLoc = Loc;
900  return false;
901 }
902 
904  const char *&PrevSpec,
905  unsigned &DiagID) {
906  // 'virtual virtual' is ok, but warn as this is likely not what the user
907  // intended.
908  if (FS_virtual_specified) {
909  DiagID = diag::warn_duplicate_declspec;
910  PrevSpec = "virtual";
911  return true;
912  }
913  FS_virtual_specified = true;
914  FS_virtualLoc = Loc;
915  return false;
916 }
917 
919  const char *&PrevSpec,
920  unsigned &DiagID) {
921  // 'explicit explicit' is ok, but warn as this is likely not what the user
922  // intended.
923  if (FS_explicit_specified) {
924  DiagID = diag::warn_duplicate_declspec;
925  PrevSpec = "explicit";
926  return true;
927  }
928  FS_explicit_specified = true;
929  FS_explicitLoc = Loc;
930  return false;
931 }
932 
934  const char *&PrevSpec,
935  unsigned &DiagID) {
936  // '_Noreturn _Noreturn' is ok, but warn as this is likely not what the user
937  // intended.
938  if (FS_noreturn_specified) {
939  DiagID = diag::warn_duplicate_declspec;
940  PrevSpec = "_Noreturn";
941  return true;
942  }
943  FS_noreturn_specified = true;
944  FS_noreturnLoc = Loc;
945  return false;
946 }
947 
948 bool DeclSpec::SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
949  unsigned &DiagID) {
950  if (Friend_specified) {
951  PrevSpec = "friend";
952  // Keep the later location, so that we can later diagnose ill-formed
953  // declarations like 'friend class X friend;'. Per [class.friend]p3,
954  // 'friend' must be the first token in a friend declaration that is
955  // not a function declaration.
956  FriendLoc = Loc;
957  DiagID = diag::warn_duplicate_declspec;
958  return true;
959  }
960 
961  Friend_specified = true;
962  FriendLoc = Loc;
963  return false;
964 }
965 
966 bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
967  unsigned &DiagID) {
968  if (isModulePrivateSpecified()) {
969  PrevSpec = "__module_private__";
970  DiagID = diag::ext_warn_duplicate_declspec;
971  return true;
972  }
973 
974  ModulePrivateLoc = Loc;
975  return false;
976 }
977 
978 bool DeclSpec::SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec,
979  unsigned &DiagID) {
980  // 'constexpr constexpr' is ok, but warn as this is likely not what the user
981  // intended.
982  if (Constexpr_specified) {
983  DiagID = diag::warn_duplicate_declspec;
984  PrevSpec = "constexpr";
985  return true;
986  }
987  Constexpr_specified = true;
988  ConstexprLoc = Loc;
989  return false;
990 }
991 
992 void DeclSpec::SaveWrittenBuiltinSpecs() {
993  writtenBS.Sign = getTypeSpecSign();
994  writtenBS.Width = getTypeSpecWidth();
995  writtenBS.Type = getTypeSpecType();
996  // Search the list of attributes for the presence of a mode attribute.
997  writtenBS.ModeAttr = getAttributes().hasAttribute(ParsedAttr::AT_Mode);
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  bool IsFixedPointType =
1112  TypeSpecType == TST_accum || TypeSpecType == TST_fract;
1113 
1114  // signed/unsigned are only valid with int/char/wchar_t/_Accum.
1115  if (TypeSpecSign != TSS_unspecified) {
1116  if (TypeSpecType == TST_unspecified)
1117  TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
1118  else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 &&
1119  TypeSpecType != TST_char && TypeSpecType != TST_wchar &&
1120  !IsFixedPointType) {
1121  S.Diag(TSSLoc, diag::err_invalid_sign_spec)
1122  << getSpecifierName((TST)TypeSpecType, Policy);
1123  // signed double -> double.
1124  TypeSpecSign = TSS_unspecified;
1125  }
1126  }
1127 
1128  // Validate the width of the type.
1129  switch (TypeSpecWidth) {
1130  case TSW_unspecified: break;
1131  case TSW_short: // short int
1132  case TSW_longlong: // long long int
1133  if (TypeSpecType == TST_unspecified)
1134  TypeSpecType = TST_int; // short -> short int, long long -> long long int.
1135  else if (!(TypeSpecType == TST_int ||
1136  (IsFixedPointType && TypeSpecWidth != TSW_longlong))) {
1137  S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1138  << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1139  TypeSpecType = TST_int;
1140  TypeSpecSat = false;
1141  TypeSpecOwned = false;
1142  }
1143  break;
1144  case TSW_long: // long double, long int
1145  if (TypeSpecType == TST_unspecified)
1146  TypeSpecType = TST_int; // long -> long int.
1147  else if (TypeSpecType != TST_int && TypeSpecType != TST_double &&
1148  !IsFixedPointType) {
1149  S.Diag(TSWRange.getBegin(), diag::err_invalid_width_spec)
1150  << (int)TypeSpecWidth << getSpecifierName((TST)TypeSpecType, Policy);
1151  TypeSpecType = TST_int;
1152  TypeSpecSat = false;
1153  TypeSpecOwned = false;
1154  }
1155  break;
1156  }
1157 
1158  // TODO: if the implementation does not implement _Complex or _Imaginary,
1159  // disallow their use. Need information about the backend.
1160  if (TypeSpecComplex != TSC_unspecified) {
1161  if (TypeSpecType == TST_unspecified) {
1162  S.Diag(TSCLoc, diag::ext_plain_complex)
1164  S.getLocForEndOfToken(getTypeSpecComplexLoc()),
1165  " double");
1166  TypeSpecType = TST_double; // _Complex -> _Complex double.
1167  } else if (TypeSpecType == TST_int || TypeSpecType == TST_char) {
1168  // Note that this intentionally doesn't include _Complex _Bool.
1169  if (!S.getLangOpts().CPlusPlus)
1170  S.Diag(TSTLoc, diag::ext_integer_complex);
1171  } else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
1172  S.Diag(TSCLoc, diag::err_invalid_complex_spec)
1173  << getSpecifierName((TST)TypeSpecType, Policy);
1174  TypeSpecComplex = TSC_unspecified;
1175  }
1176  }
1177 
1178  // C11 6.7.1/3, C++11 [dcl.stc]p1, GNU TLS: __thread, thread_local and
1179  // _Thread_local can only appear with the 'static' and 'extern' storage class
1180  // specifiers. We also allow __private_extern__ as an extension.
1181  if (ThreadStorageClassSpec != TSCS_unspecified) {
1182  switch (StorageClassSpec) {
1183  case SCS_unspecified:
1184  case SCS_extern:
1185  case SCS_private_extern:
1186  case SCS_static:
1187  break;
1188  default:
1190  getThreadStorageClassSpecLoc(), getStorageClassSpecLoc()))
1191  S.Diag(getStorageClassSpecLoc(),
1192  diag::err_invalid_decl_spec_combination)
1193  << DeclSpec::getSpecifierName(getThreadStorageClassSpec())
1194  << SourceRange(getThreadStorageClassSpecLoc());
1195  else
1196  S.Diag(getThreadStorageClassSpecLoc(),
1197  diag::err_invalid_decl_spec_combination)
1198  << DeclSpec::getSpecifierName(getStorageClassSpec())
1199  << SourceRange(getStorageClassSpecLoc());
1200  // Discard the thread storage class specifier to recover.
1201  ThreadStorageClassSpec = TSCS_unspecified;
1202  ThreadStorageClassSpecLoc = SourceLocation();
1203  }
1204  }
1205 
1206  // If no type specifier was provided and we're parsing a language where
1207  // the type specifier is not optional, but we got 'auto' as a storage
1208  // class specifier, then assume this is an attempt to use C++0x's 'auto'
1209  // type specifier.
1210  if (S.getLangOpts().CPlusPlus &&
1211  TypeSpecType == TST_unspecified && StorageClassSpec == SCS_auto) {
1212  TypeSpecType = TST_auto;
1213  StorageClassSpec = SCS_unspecified;
1214  TSTLoc = TSTNameLoc = StorageClassSpecLoc;
1215  StorageClassSpecLoc = SourceLocation();
1216  }
1217  // Diagnose if we've recovered from an ill-formed 'auto' storage class
1218  // specifier in a pre-C++11 dialect of C++.
1219  if (!S.getLangOpts().CPlusPlus11 && TypeSpecType == TST_auto)
1220  S.Diag(TSTLoc, diag::ext_auto_type_specifier);
1221  if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11 &&
1222  StorageClassSpec == SCS_auto)
1223  S.Diag(StorageClassSpecLoc, diag::warn_auto_storage_class)
1224  << FixItHint::CreateRemoval(StorageClassSpecLoc);
1225  if (TypeSpecType == TST_char8)
1226  S.Diag(TSTLoc, diag::warn_cxx17_compat_unicode_type);
1227  else if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32)
1228  S.Diag(TSTLoc, diag::warn_cxx98_compat_unicode_type)
1229  << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t");
1230  if (Constexpr_specified)
1231  S.Diag(ConstexprLoc, diag::warn_cxx98_compat_constexpr);
1232 
1233  // C++ [class.friend]p6:
1234  // No storage-class-specifier shall appear in the decl-specifier-seq
1235  // of a friend declaration.
1236  if (isFriendSpecified() &&
1237  (getStorageClassSpec() || getThreadStorageClassSpec())) {
1238  SmallString<32> SpecName;
1239  SourceLocation SCLoc;
1240  FixItHint StorageHint, ThreadHint;
1241 
1242  if (DeclSpec::SCS SC = getStorageClassSpec()) {
1243  SpecName = getSpecifierName(SC);
1244  SCLoc = getStorageClassSpecLoc();
1245  StorageHint = FixItHint::CreateRemoval(SCLoc);
1246  }
1247 
1248  if (DeclSpec::TSCS TSC = getThreadStorageClassSpec()) {
1249  if (!SpecName.empty()) SpecName += " ";
1250  SpecName += getSpecifierName(TSC);
1251  SCLoc = getThreadStorageClassSpecLoc();
1252  ThreadHint = FixItHint::CreateRemoval(SCLoc);
1253  }
1254 
1255  S.Diag(SCLoc, diag::err_friend_decl_spec)
1256  << SpecName << StorageHint << ThreadHint;
1257 
1258  ClearStorageClassSpecs();
1259  }
1260 
1261  // C++11 [dcl.fct.spec]p5:
1262  // The virtual specifier shall be used only in the initial
1263  // declaration of a non-static class member function;
1264  // C++11 [dcl.fct.spec]p6:
1265  // The explicit specifier shall be used only in the declaration of
1266  // a constructor or conversion function within its class
1267  // definition;
1268  if (isFriendSpecified() && (isVirtualSpecified() || isExplicitSpecified())) {
1269  StringRef Keyword;
1270  SourceLocation SCLoc;
1271 
1272  if (isVirtualSpecified()) {
1273  Keyword = "virtual";
1274  SCLoc = getVirtualSpecLoc();
1275  } else {
1276  Keyword = "explicit";
1277  SCLoc = getExplicitSpecLoc();
1278  }
1279 
1280  FixItHint Hint = FixItHint::CreateRemoval(SCLoc);
1281  S.Diag(SCLoc, diag::err_friend_decl_spec)
1282  << Keyword << Hint;
1283 
1284  FS_virtual_specified = FS_explicit_specified = false;
1285  FS_virtualLoc = FS_explicitLoc = SourceLocation();
1286  }
1287 
1288  assert(!TypeSpecOwned || isDeclRep((TST) TypeSpecType));
1289 
1290  // Okay, now we can infer the real type.
1291 
1292  // TODO: return "auto function" and other bad things based on the real type.
1293 
1294  // 'data definition has no type or storage class'?
1295 }
1296 
1298  TST tst = getTypeSpecType();
1299  return isDeclRep(tst) && getRepAsDecl() != nullptr &&
1300  StorageClassSpec != DeclSpec::SCS_typedef;
1301 }
1302 
1305  SourceLocation SymbolLocations[3]) {
1307  StartLocation = OperatorLoc;
1308  EndLocation = OperatorLoc;
1310  for (unsigned I = 0; I != 3; ++I) {
1311  OperatorFunctionId.SymbolLocations[I] = SymbolLocations[I].getRawEncoding();
1312 
1313  if (SymbolLocations[I].isValid())
1314  EndLocation = SymbolLocations[I];
1315  }
1316 }
1317 
1319  const char *&PrevSpec) {
1320  if (!FirstLocation.isValid())
1321  FirstLocation = Loc;
1322  LastLocation = Loc;
1323  LastSpecifier = VS;
1324 
1325  if (Specifiers & VS) {
1326  PrevSpec = getSpecifierName(VS);
1327  return true;
1328  }
1329 
1330  Specifiers |= VS;
1331 
1332  switch (VS) {
1333  default: llvm_unreachable("Unknown specifier!");
1334  case VS_Override: VS_overrideLoc = Loc; break;
1335  case VS_GNU_Final:
1336  case VS_Sealed:
1337  case VS_Final: VS_finalLoc = Loc; break;
1338  }
1339 
1340  return false;
1341 }
1342 
1344  switch (VS) {
1345  default: llvm_unreachable("Unknown specifier");
1346  case VS_Override: return "override";
1347  case VS_Final: return "final";
1348  case VS_GNU_Final: return "__final";
1349  case VS_Sealed: return "sealed";
1350  }
1351 }
Defines the clang::ASTContext interface.
unsigned MutableLoc
The location of the &#39;mutable&#39; qualifer in a lambda-declarator, if any.
Definition: DeclSpec.h:1307
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
Definition: DeclSpec.h:1251
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:642
unsigned RestrictQualifierLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1303
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:1297
static const TST TST_char16
Definition: DeclSpec.h:277
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:87
unsigned ExceptionSpecLocBeg
The beginning location of the exception specification, if any.
Definition: DeclSpec.h:1310
bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:978
unsigned EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
Definition: DeclSpec.h:1271
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:1283
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:1337
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:499
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:699
static const char * getSpecifierName(Specifier VS)
Definition: DeclSpec.cpp:1343
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:828
An overloaded operator name, e.g., operator+.
unsigned RefQualifierLoc
The location of the ref-qualifier, if any.
Definition: DeclSpec.h:1288
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:1748
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:918
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
Definition: DeclSpec.cpp:415
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:1221
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:57
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:1328
One of these records is kept for each identifier that is lexed.
void setConstructorTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id that names a constructor.
Definition: DeclSpec.cpp:39
static const TST TST_decimal32
Definition: DeclSpec.h: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:154
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:1298
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:1255
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:903
static const TST TST_error
Definition: DeclSpec.h:310
static const TST TST_enum
Definition: DeclSpec.h:292
bool hasTagDefinition() const
Definition: DeclSpec.cpp:406
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:813
PtrTy get() const
Definition: Ownership.h:174
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:891
SCS
storage-class-specifier
Definition: DeclSpec.h:232
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
Definition: DeclSpec.h:1265
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:948
unsigned RParenLoc
The location of the right parenthesis in the source.
Definition: DeclSpec.h:1274
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:797
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:933
const LangOptions & getLangOpts() const
Definition: Sema.h:1220
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:278
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:309
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1278
bool isEnabled(llvm::StringRef Ext) const
Definition: OpenCLOptions.h:39
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:190
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:277
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
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:1807
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:1332
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:660
static const TST TST_half
Definition: DeclSpec.h:281
enum clang::DeclaratorChunk::@213 Kind
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:95
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:433
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:707
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:1342
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:633
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:1324
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:401
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:1500
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:558
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:851
bool isStaticMember()
Returns true if this declares a static member.
Definition: DeclSpec.cpp:393
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:784
static const TST TST_decltype_auto
Definition: DeclSpec.h:301
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:966
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Definition: DeclCXX.h:2073
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:1244
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:1261
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
Definition: DeclSpec.cpp:1297
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:1293
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:1081
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
Definition: DeclSpec.cpp:1318
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:1239
unsigned LParenLoc
The location of the left parenthesis in the source.
Definition: DeclSpec.h:1268
bool isFunctionType() const
Definition: Type.h:6278
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:619
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Definition: DeclSpec.cpp:1303
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:749
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:1258
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:771
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:2485
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:1225
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:1004
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:1210
A trivial tuple used to represent a source range.
ASTContext & Context
Definition: Sema.h:320
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:650
This represents a decl that may have a name.
Definition: Decl.h:248
bool SetTypeSpecError()
Definition: DeclSpec.cpp:843
unsigned ExceptionSpecLocEnd
The end location of the exception specification, if any.
Definition: DeclSpec.h:1313
Represents a C++ namespace alias.
Definition: DeclCXX.h:3014
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:1318
noexcept(expression), evals to &#39;true&#39;
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:877
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
Definition: DeclSpec.h:1247