clang  16.0.0git
Sema.cpp
Go to the documentation of this file.
1 //===--- Sema.cpp - AST Builder and Semantic Analysis Implementation ------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the actions class which performs semantic analysis and
10 // builds an AST out of a parse stream.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "UsedDeclVisitor.h"
15 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/AST/DeclFriend.h"
20 #include "clang/AST/DeclObjC.h"
21 #include "clang/AST/Expr.h"
22 #include "clang/AST/ExprCXX.h"
24 #include "clang/AST/StmtCXX.h"
29 #include "clang/Basic/Stack.h"
30 #include "clang/Basic/TargetInfo.h"
31 #include "clang/Lex/HeaderSearch.h"
33 #include "clang/Lex/Preprocessor.h"
41 #include "clang/Sema/Scope.h"
42 #include "clang/Sema/ScopeInfo.h"
48 #include "llvm/ADT/DenseMap.h"
49 #include "llvm/ADT/STLExtras.h"
50 #include "llvm/ADT/SmallPtrSet.h"
51 #include "llvm/Support/TimeProfiler.h"
52 
53 using namespace clang;
54 using namespace sema;
55 
57  return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts);
58 }
59 
60 ModuleLoader &Sema::getModuleLoader() const { return PP.getModuleLoader(); }
61 
64  StringRef Platform) {
65  auto *SDKInfo = getDarwinSDKInfoForAvailabilityChecking();
66  if (!SDKInfo && !WarnedDarwinSDKInfoMissing) {
67  Diag(Loc, diag::warn_missing_sdksettings_for_availability_checking)
68  << Platform;
69  WarnedDarwinSDKInfoMissing = true;
70  }
71  return SDKInfo;
72 }
73 
75  if (CachedDarwinSDKInfo)
76  return CachedDarwinSDKInfo->get();
77  auto SDKInfo = parseDarwinSDKInfo(
78  PP.getFileManager().getVirtualFileSystem(),
79  PP.getHeaderSearchInfo().getHeaderSearchOpts().Sysroot);
80  if (SDKInfo && *SDKInfo) {
81  CachedDarwinSDKInfo = std::make_unique<DarwinSDKInfo>(std::move(**SDKInfo));
82  return CachedDarwinSDKInfo->get();
83  }
84  if (!SDKInfo)
85  llvm::consumeError(SDKInfo.takeError());
86  CachedDarwinSDKInfo = std::unique_ptr<DarwinSDKInfo>();
87  return nullptr;
88 }
89 
92  unsigned int Index) {
93  std::string InventedName;
94  llvm::raw_string_ostream OS(InventedName);
95 
96  if (!ParamName)
97  OS << "auto:" << Index + 1;
98  else
99  OS << ParamName->getName() << ":auto";
100 
101  OS.flush();
102  return &Context.Idents.get(OS.str());
103 }
104 
106  const Preprocessor &PP) {
108  // In diagnostics, we print _Bool as bool if the latter is defined as the
109  // former.
110  Policy.Bool = Context.getLangOpts().Bool;
111  if (!Policy.Bool) {
112  if (const MacroInfo *BoolMacro = PP.getMacroInfo(Context.getBoolName())) {
113  Policy.Bool = BoolMacro->isObjectLike() &&
114  BoolMacro->getNumTokens() == 1 &&
115  BoolMacro->getReplacementToken(0).is(tok::kw__Bool);
116  }
117  }
118 
119  // Shorten the data output if needed
120  Policy.EntireContentsOfLargeArray = false;
121 
122  return Policy;
123 }
124 
126  TUScope = S;
127  PushDeclContext(S, Context.getTranslationUnitDecl());
128 }
129 
130 namespace clang {
131 namespace sema {
132 
133 class SemaPPCallbacks : public PPCallbacks {
134  Sema *S = nullptr;
136 
137 public:
138  void set(Sema &S) { this->S = &S; }
139 
140  void reset() { S = nullptr; }
141 
144  FileID PrevFID) override {
145  if (!S)
146  return;
147  switch (Reason) {
148  case EnterFile: {
150  SourceLocation IncludeLoc = SM.getIncludeLoc(SM.getFileID(Loc));
151  if (IncludeLoc.isValid()) {
152  if (llvm::timeTraceProfilerEnabled()) {
153  const FileEntry *FE = SM.getFileEntryForID(SM.getFileID(Loc));
154  llvm::timeTraceProfilerBegin(
155  "Source", FE != nullptr ? FE->getName() : StringRef("<unknown>"));
156  }
157 
158  IncludeStack.push_back(IncludeLoc);
161  IncludeLoc);
162  }
163  break;
164  }
165  case ExitFile:
166  if (!IncludeStack.empty()) {
167  if (llvm::timeTraceProfilerEnabled())
168  llvm::timeTraceProfilerEnd();
169 
172  IncludeStack.pop_back_val());
173  }
174  break;
175  default:
176  break;
177  }
178  }
179 };
180 
181 } // end namespace sema
182 } // end namespace clang
183 
184 const unsigned Sema::MaxAlignmentExponent;
186 
187 Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
188  TranslationUnitKind TUKind, CodeCompleteConsumer *CodeCompleter)
189  : ExternalSource(nullptr), CurFPFeatures(pp.getLangOpts()),
190  LangOpts(pp.getLangOpts()), PP(pp), Context(ctxt), Consumer(consumer),
191  Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
192  CollectStats(false), CodeCompleter(CodeCompleter), CurContext(nullptr),
193  OriginalLexicalContext(nullptr), MSStructPragmaOn(false),
194  MSPointerToMemberRepresentationMethod(
195  LangOpts.getMSPointerToMemberRepresentationMethod()),
196  VtorDispStack(LangOpts.getVtorDispMode()),
197  AlignPackStack(AlignPackInfo(getLangOpts().XLPragmaPack)),
198  DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr),
199  CodeSegStack(nullptr), StrictGuardStackCheckStack(false),
200  FpPragmaStack(FPOptionsOverride()), CurInitSeg(nullptr),
201  VisContext(nullptr), PragmaAttributeCurrentTargetDecl(nullptr),
202  IsBuildingRecoveryCallExpr(false), LateTemplateParser(nullptr),
203  LateTemplateParserCleanup(nullptr), OpaqueParser(nullptr), IdResolver(pp),
204  StdExperimentalNamespaceCache(nullptr), StdInitializerList(nullptr),
205  StdCoroutineTraitsCache(nullptr), CXXTypeInfoDecl(nullptr),
206  MSVCGuidDecl(nullptr), StdSourceLocationImplDecl(nullptr),
207  NSNumberDecl(nullptr), NSValueDecl(nullptr), NSStringDecl(nullptr),
208  StringWithUTF8StringMethod(nullptr),
209  ValueWithBytesObjCTypeMethod(nullptr), NSArrayDecl(nullptr),
210  ArrayWithObjectsMethod(nullptr), NSDictionaryDecl(nullptr),
211  DictionaryWithObjectsMethod(nullptr), GlobalNewDeleteDeclared(false),
212  TUKind(TUKind), NumSFINAEErrors(0),
213  FullyCheckedComparisonCategories(
214  static_cast<unsigned>(ComparisonCategoryType::Last) + 1),
215  SatisfactionCache(Context), AccessCheckingSFINAE(false),
216  InNonInstantiationSFINAEContext(false), NonInstantiationEntries(0),
217  ArgumentPackSubstitutionIndex(-1), CurrentInstantiationScope(nullptr),
218  DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this),
219  ThreadSafetyDeclCache(nullptr), VarDataSharingAttributesStack(nullptr),
220  CurScope(nullptr), Ident_super(nullptr), Ident___float128(nullptr) {
221  assert(pp.TUKind == TUKind);
222  TUScope = nullptr;
224 
225  LoadedExternalKnownNamespaces = false;
226  for (unsigned I = 0; I != NSAPI::NumNSNumberLiteralMethods; ++I)
227  NSNumberLiteralMethods[I] = nullptr;
228 
229  if (getLangOpts().ObjC)
230  NSAPIObj.reset(new NSAPI(Context));
231 
232  if (getLangOpts().CPlusPlus)
233  FieldCollector.reset(new CXXFieldCollector());
234 
235  // Tell diagnostics how to render things from the AST library.
237 
238  // This evaluation context exists to ensure that there's always at least one
239  // valid evaluation context available. It is never removed from the
240  // evaluation stack.
241  ExprEvalContexts.emplace_back(
244 
245  // Initialization of data sharing attributes stack for OpenMP
246  InitDataSharingAttributesStack();
247 
248  std::unique_ptr<sema::SemaPPCallbacks> Callbacks =
249  std::make_unique<sema::SemaPPCallbacks>();
250  SemaPPCallbackHandler = Callbacks.get();
251  PP.addPPCallbacks(std::move(Callbacks));
252  SemaPPCallbackHandler->set(*this);
253 
254  CurFPFeatures.setFPEvalMethod(PP.getCurrentFPEvalMethod());
255 }
256 
257 // Anchor Sema's type info to this TU.
258 void Sema::anchor() {}
259 
260 void Sema::addImplicitTypedef(StringRef Name, QualType T) {
261  DeclarationName DN = &Context.Idents.get(Name);
262  if (IdResolver.begin(DN) == IdResolver.end())
264 }
265 
267  if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
268  SC->InitializeSema(*this);
269 
270  // Tell the external Sema source about this Sema object.
271  if (ExternalSemaSource *ExternalSema
272  = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
273  ExternalSema->InitializeSema(*this);
274 
275  // This needs to happen after ExternalSemaSource::InitializeSema(this) or we
276  // will not be able to merge any duplicate __va_list_tag decls correctly.
277  VAListTagName = PP.getIdentifierInfo("__va_list_tag");
278 
279  if (!TUScope)
280  return;
281 
282  // Initialize predefined 128-bit integer types, if needed.
286  // If either of the 128-bit integer types are unavailable to name lookup,
287  // define them now.
288  DeclarationName Int128 = &Context.Idents.get("__int128_t");
289  if (IdResolver.begin(Int128) == IdResolver.end())
291 
292  DeclarationName UInt128 = &Context.Idents.get("__uint128_t");
293  if (IdResolver.begin(UInt128) == IdResolver.end())
295  }
296 
297 
298  // Initialize predefined Objective-C types:
299  if (getLangOpts().ObjC) {
300  // If 'SEL' does not yet refer to any declarations, make it refer to the
301  // predefined 'SEL'.
302  DeclarationName SEL = &Context.Idents.get("SEL");
303  if (IdResolver.begin(SEL) == IdResolver.end())
305 
306  // If 'id' does not yet refer to any declarations, make it refer to the
307  // predefined 'id'.
309  if (IdResolver.begin(Id) == IdResolver.end())
311 
312  // Create the built-in typedef for 'Class'.
313  DeclarationName Class = &Context.Idents.get("Class");
314  if (IdResolver.begin(Class) == IdResolver.end())
316 
317  // Create the built-in forward declaratino for 'Protocol'.
318  DeclarationName Protocol = &Context.Idents.get("Protocol");
319  if (IdResolver.begin(Protocol) == IdResolver.end())
321  }
322 
323  // Create the internal type for the *StringMakeConstantString builtins.
324  DeclarationName ConstantString = &Context.Idents.get("__NSConstantString");
325  if (IdResolver.begin(ConstantString) == IdResolver.end())
327 
328  // Initialize Microsoft "predefined C++ types".
329  if (getLangOpts().MSVCCompat) {
330  if (getLangOpts().CPlusPlus &&
331  IdResolver.begin(&Context.Idents.get("type_info")) == IdResolver.end())
333  TUScope);
334 
336  }
337 
338  // Initialize predefined OpenCL types and supported extensions and (optional)
339  // core features.
340  if (getLangOpts().OpenCL) {
345  auto OCLCompatibleVersion = getLangOpts().getOpenCLCompatibleVersion();
346  if (OCLCompatibleVersion >= 200) {
347  if (getLangOpts().OpenCLCPlusPlus || getLangOpts().Blocks) {
348  addImplicitTypedef("clk_event_t", Context.OCLClkEventTy);
350  }
351  if (getLangOpts().OpenCLPipes)
352  addImplicitTypedef("reserve_id_t", Context.OCLReserveIDTy);
354  addImplicitTypedef("atomic_uint",
356  addImplicitTypedef("atomic_float",
358  // OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as
359  // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
361 
362 
363  // OpenCL v2.0 s6.13.11.6:
364  // - The atomic_long and atomic_ulong types are supported if the
365  // cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics
366  // extensions are supported.
367  // - The atomic_double type is only supported if double precision
368  // is supported and the cl_khr_int64_base_atomics and
369  // cl_khr_int64_extended_atomics extensions are supported.
370  // - If the device address space is 64-bits, the data types
371  // atomic_intptr_t, atomic_uintptr_t, atomic_size_t and
372  // atomic_ptrdiff_t are supported if the cl_khr_int64_base_atomics and
373  // cl_khr_int64_extended_atomics extensions are supported.
374 
375  auto AddPointerSizeDependentTypes = [&]() {
376  auto AtomicSizeT = Context.getAtomicType(Context.getSizeType());
377  auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType());
378  auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType());
379  auto AtomicPtrDiffT =
381  addImplicitTypedef("atomic_size_t", AtomicSizeT);
382  addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT);
383  addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT);
384  addImplicitTypedef("atomic_ptrdiff_t", AtomicPtrDiffT);
385  };
386 
387  if (Context.getTypeSize(Context.getSizeType()) == 32) {
388  AddPointerSizeDependentTypes();
389  }
390 
391  if (getOpenCLOptions().isSupported("cl_khr_fp16", getLangOpts())) {
392  auto AtomicHalfT = Context.getAtomicType(Context.HalfTy);
393  addImplicitTypedef("atomic_half", AtomicHalfT);
394  }
395 
396  std::vector<QualType> Atomic64BitTypes;
397  if (getOpenCLOptions().isSupported("cl_khr_int64_base_atomics",
398  getLangOpts()) &&
399  getOpenCLOptions().isSupported("cl_khr_int64_extended_atomics",
400  getLangOpts())) {
401  if (getOpenCLOptions().isSupported("cl_khr_fp64", getLangOpts())) {
402  auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy);
403  addImplicitTypedef("atomic_double", AtomicDoubleT);
404  Atomic64BitTypes.push_back(AtomicDoubleT);
405  }
406  auto AtomicLongT = Context.getAtomicType(Context.LongTy);
407  auto AtomicULongT = Context.getAtomicType(Context.UnsignedLongTy);
408  addImplicitTypedef("atomic_long", AtomicLongT);
409  addImplicitTypedef("atomic_ulong", AtomicULongT);
410 
411 
412  if (Context.getTypeSize(Context.getSizeType()) == 64) {
413  AddPointerSizeDependentTypes();
414  }
415  }
416  }
417 
418 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
419  if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) { \
420  addImplicitTypedef(#ExtType, Context.Id##Ty); \
421  }
422 #include "clang/Basic/OpenCLExtensionTypes.def"
423  }
424 
426 #define SVE_TYPE(Name, Id, SingletonId) \
427  addImplicitTypedef(Name, Context.SingletonId);
428 #include "clang/Basic/AArch64SVEACLETypes.def"
429  }
430 
431  if (Context.getTargetInfo().getTriple().isPPC64()) {
432 #define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
433  addImplicitTypedef(#Name, Context.Id##Ty);
434 #include "clang/Basic/PPCTypes.def"
435 #define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
436  addImplicitTypedef(#Name, Context.Id##Ty);
437 #include "clang/Basic/PPCTypes.def"
438  }
439 
441 #define RVV_TYPE(Name, Id, SingletonId) \
442  addImplicitTypedef(Name, Context.SingletonId);
443 #include "clang/Basic/RISCVVTypes.def"
444  }
445 
447  DeclarationName MSVaList = &Context.Idents.get("__builtin_ms_va_list");
448  if (IdResolver.begin(MSVaList) == IdResolver.end())
450  }
451 
452  DeclarationName BuiltinVaList = &Context.Idents.get("__builtin_va_list");
453  if (IdResolver.begin(BuiltinVaList) == IdResolver.end())
455 }
456 
458  assert(InstantiatingSpecializations.empty() &&
459  "failed to clean up an InstantiatingTemplate?");
460 
461  if (VisContext) FreeVisContext();
462 
463  // Kill all the active scopes.
465  delete FSI;
466 
467  // Tell the SemaConsumer to forget about us; we're going out of scope.
468  if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
469  SC->ForgetSema();
470 
471  // Detach from the external Sema source.
472  if (ExternalSemaSource *ExternalSema
473  = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
474  ExternalSema->ForgetSema();
475 
476  // Delete cached satisfactions.
477  std::vector<ConstraintSatisfaction *> Satisfactions;
478  Satisfactions.reserve(Satisfactions.size());
479  for (auto &Node : SatisfactionCache)
480  Satisfactions.push_back(&Node);
481  for (auto *Node : Satisfactions)
482  delete Node;
483 
485 
486  // Destroys data sharing attributes stack for OpenMP
487  DestroyDataSharingAttributesStack();
488 
489  // Detach from the PP callback handler which outlives Sema since it's owned
490  // by the preprocessor.
491  SemaPPCallbackHandler->reset();
492 }
493 
495  // Only warn about this once.
496  if (!WarnedStackExhausted) {
497  Diag(Loc, diag::warn_stack_exhausted);
498  WarnedStackExhausted = true;
499  }
500 }
501 
503  llvm::function_ref<void()> Fn) {
505 }
506 
507 /// makeUnavailableInSystemHeader - There is an error in the current
508 /// context. If we're still in a system header, and we can plausibly
509 /// make the relevant declaration unavailable instead of erroring, do
510 /// so and return true.
512  UnavailableAttr::ImplicitReason reason) {
513  // If we're not in a function, it's an error.
514  FunctionDecl *fn = dyn_cast<FunctionDecl>(CurContext);
515  if (!fn) return false;
516 
517  // If we're in template instantiation, it's an error.
519  return false;
520 
521  // If that function's not in a system header, it's an error.
523  return false;
524 
525  // If the function is already unavailable, it's not an error.
526  if (fn->hasAttr<UnavailableAttr>()) return true;
527 
528  fn->addAttr(UnavailableAttr::CreateImplicit(Context, "", reason, loc));
529  return true;
530 }
531 
534 }
535 
536 ///Registers an external source. If an external source already exists,
537 /// creates a multiplex external source and appends to it.
538 ///
539 ///\param[in] E - A non-null external sema source.
540 ///
542  assert(E && "Cannot use with NULL ptr");
543 
544  if (!ExternalSource) {
545  ExternalSource = E;
546  return;
547  }
548 
549  if (auto *Ex = dyn_cast<MultiplexExternalSemaSource>(ExternalSource))
550  Ex->AddSource(E);
551  else
552  ExternalSource = new MultiplexExternalSemaSource(ExternalSource.get(), E);
553 }
554 
555 /// Print out statistics about the semantic analysis.
556 void Sema::PrintStats() const {
557  llvm::errs() << "\n*** Semantic Analysis Stats:\n";
558  llvm::errs() << NumSFINAEErrors << " SFINAE diagnostics trapped.\n";
559 
560  BumpAlloc.PrintStats();
562 }
563 
565  QualType SrcType,
566  SourceLocation Loc) {
567  Optional<NullabilityKind> ExprNullability = SrcType->getNullability(Context);
568  if (!ExprNullability || (*ExprNullability != NullabilityKind::Nullable &&
569  *ExprNullability != NullabilityKind::NullableResult))
570  return;
571 
572  Optional<NullabilityKind> TypeNullability = DstType->getNullability(Context);
573  if (!TypeNullability || *TypeNullability != NullabilityKind::NonNull)
574  return;
575 
576  Diag(Loc, diag::warn_nullability_lost) << SrcType << DstType;
577 }
578 
580  // nullptr only exists from C++11 on, so don't warn on its absence earlier.
581  if (!getLangOpts().CPlusPlus11)
582  return;
583 
584  if (Kind != CK_NullToPointer && Kind != CK_NullToMemberPointer)
585  return;
587  return;
588 
589  if (Diags.isIgnored(diag::warn_zero_as_null_pointer_constant,
590  E->getBeginLoc()))
591  return;
592 
593  // Don't diagnose the conversion from a 0 literal to a null pointer argument
594  // in a synthesized call to operator<=>.
595  if (!CodeSynthesisContexts.empty() &&
596  CodeSynthesisContexts.back().Kind ==
598  return;
599 
600  // If it is a macro from system header, and if the macro name is not "NULL",
601  // do not warn.
602  SourceLocation MaybeMacroLoc = E->getBeginLoc();
604  SourceMgr.isInSystemMacro(MaybeMacroLoc) &&
605  !findMacroSpelling(MaybeMacroLoc, "NULL"))
606  return;
607 
608  Diag(E->getBeginLoc(), diag::warn_zero_as_null_pointer_constant)
609  << FixItHint::CreateReplacement(E->getSourceRange(), "nullptr");
610 }
611 
612 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
613 /// If there is already an implicit cast, merge into the existing one.
614 /// The result is of the given category.
617  const CXXCastPath *BasePath,
618  CheckedConversionKind CCK) {
619 #ifndef NDEBUG
620  if (VK == VK_PRValue && !E->isPRValue()) {
621  switch (Kind) {
622  default:
623  llvm_unreachable(
624  ("can't implicitly cast glvalue to prvalue with this cast "
625  "kind: " +
627  .c_str());
628  case CK_Dependent:
629  case CK_LValueToRValue:
630  case CK_ArrayToPointerDecay:
631  case CK_FunctionToPointerDecay:
632  case CK_ToVoid:
633  case CK_NonAtomicToAtomic:
634  break;
635  }
636  }
637  assert((VK == VK_PRValue || Kind == CK_Dependent || !E->isPRValue()) &&
638  "can't cast prvalue to glvalue");
639 #endif
640 
643 
644  QualType ExprTy = Context.getCanonicalType(E->getType());
646 
647  if (ExprTy == TypeTy)
648  return E;
649 
650  if (Kind == CK_ArrayToPointerDecay) {
651  // C++1z [conv.array]: The temporary materialization conversion is applied.
652  // We also use this to fuel C++ DR1213, which applies to C++11 onwards.
653  if (getLangOpts().CPlusPlus && E->isPRValue()) {
654  // The temporary is an lvalue in C++98 and an xvalue otherwise.
656  E->getType(), E, !getLangOpts().CPlusPlus11);
657  if (Materialized.isInvalid())
658  return ExprError();
659  E = Materialized.get();
660  }
661  // C17 6.7.1p6 footnote 124: The implementation can treat any register
662  // declaration simply as an auto declaration. However, whether or not
663  // addressable storage is actually used, the address of any part of an
664  // object declared with storage-class specifier register cannot be
665  // computed, either explicitly(by use of the unary & operator as discussed
666  // in 6.5.3.2) or implicitly(by converting an array name to a pointer as
667  // discussed in 6.3.2.1).Thus, the only operator that can be applied to an
668  // array declared with storage-class specifier register is sizeof.
669  if (VK == VK_PRValue && !getLangOpts().CPlusPlus && !E->isPRValue()) {
670  if (const auto *DRE = dyn_cast<DeclRefExpr>(E)) {
671  if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
672  if (VD->getStorageClass() == SC_Register) {
673  Diag(E->getExprLoc(), diag::err_typecheck_address_of)
674  << /*register variable*/ 3 << E->getSourceRange();
675  return ExprError();
676  }
677  }
678  }
679  }
680  }
681 
682  if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(E)) {
683  if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
684  ImpCast->setType(Ty);
685  ImpCast->setValueKind(VK);
686  return E;
687  }
688  }
689 
690  return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK,
692 }
693 
694 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
695 /// to the conversion from scalar type ScalarTy to the Boolean type.
697  switch (ScalarTy->getScalarTypeKind()) {
698  case Type::STK_Bool: return CK_NoOp;
699  case Type::STK_CPointer: return CK_PointerToBoolean;
700  case Type::STK_BlockPointer: return CK_PointerToBoolean;
701  case Type::STK_ObjCObjectPointer: return CK_PointerToBoolean;
702  case Type::STK_MemberPointer: return CK_MemberPointerToBoolean;
703  case Type::STK_Integral: return CK_IntegralToBoolean;
704  case Type::STK_Floating: return CK_FloatingToBoolean;
705  case Type::STK_IntegralComplex: return CK_IntegralComplexToBoolean;
706  case Type::STK_FloatingComplex: return CK_FloatingComplexToBoolean;
707  case Type::STK_FixedPoint: return CK_FixedPointToBoolean;
708  }
709  llvm_unreachable("unknown scalar type kind");
710 }
711 
712 /// Used to prune the decls of Sema's UnusedFileScopedDecls vector.
713 static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) {
714  if (D->getMostRecentDecl()->isUsed())
715  return true;
716 
717  if (D->isExternallyVisible())
718  return true;
719 
720  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
721  // If this is a function template and none of its specializations is used,
722  // we should warn.
723  if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
724  for (const auto *Spec : Template->specializations())
725  if (ShouldRemoveFromUnused(SemaRef, Spec))
726  return true;
727 
728  // UnusedFileScopedDecls stores the first declaration.
729  // The declaration may have become definition so check again.
730  const FunctionDecl *DeclToCheck;
731  if (FD->hasBody(DeclToCheck))
732  return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
733 
734  // Later redecls may add new information resulting in not having to warn,
735  // so check again.
736  DeclToCheck = FD->getMostRecentDecl();
737  if (DeclToCheck != FD)
738  return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
739  }
740 
741  if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
742  // If a variable usable in constant expressions is referenced,
743  // don't warn if it isn't used: if the value of a variable is required
744  // for the computation of a constant expression, it doesn't make sense to
745  // warn even if the variable isn't odr-used. (isReferenced doesn't
746  // precisely reflect that, but it's a decent approximation.)
747  if (VD->isReferenced() &&
748  VD->mightBeUsableInConstantExpressions(SemaRef->Context))
749  return true;
750 
751  if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
752  // If this is a variable template and none of its specializations is used,
753  // we should warn.
754  for (const auto *Spec : Template->specializations())
755  if (ShouldRemoveFromUnused(SemaRef, Spec))
756  return true;
757 
758  // UnusedFileScopedDecls stores the first declaration.
759  // The declaration may have become definition so check again.
760  const VarDecl *DeclToCheck = VD->getDefinition();
761  if (DeclToCheck)
762  return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
763 
764  // Later redecls may add new information resulting in not having to warn,
765  // so check again.
766  DeclToCheck = VD->getMostRecentDecl();
767  if (DeclToCheck != VD)
768  return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
769  }
770 
771  return false;
772 }
773 
775  if (auto *FD = dyn_cast<FunctionDecl>(ND))
776  return FD->isExternC();
777  return cast<VarDecl>(ND)->isExternC();
778 }
779 
780 /// Determine whether ND is an external-linkage function or variable whose
781 /// type has no linkage.
783  // Note: it's not quite enough to check whether VD has UniqueExternalLinkage,
784  // because we also want to catch the case where its type has VisibleNoLinkage,
785  // which does not affect the linkage of VD.
786  return getLangOpts().CPlusPlus && VD->hasExternalFormalLinkage() &&
789 }
790 
791 /// Obtains a sorted list of functions and variables that are undefined but
792 /// ODR-used.
794  SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined) {
795  for (const auto &UndefinedUse : UndefinedButUsed) {
796  NamedDecl *ND = UndefinedUse.first;
797 
798  // Ignore attributes that have become invalid.
799  if (ND->isInvalidDecl()) continue;
800 
801  // __attribute__((weakref)) is basically a definition.
802  if (ND->hasAttr<WeakRefAttr>()) continue;
803 
804  if (isa<CXXDeductionGuideDecl>(ND))
805  continue;
806 
807  if (ND->hasAttr<DLLImportAttr>() || ND->hasAttr<DLLExportAttr>()) {
808  // An exported function will always be emitted when defined, so even if
809  // the function is inline, it doesn't have to be emitted in this TU. An
810  // imported function implies that it has been exported somewhere else.
811  continue;
812  }
813 
814  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
815  if (FD->isDefined())
816  continue;
817  if (FD->isExternallyVisible() &&
819  !FD->getMostRecentDecl()->isInlined() &&
820  !FD->hasAttr<ExcludeFromExplicitInstantiationAttr>())
821  continue;
822  if (FD->getBuiltinID())
823  continue;
824  } else {
825  auto *VD = cast<VarDecl>(ND);
826  if (VD->hasDefinition() != VarDecl::DeclarationOnly)
827  continue;
828  if (VD->isExternallyVisible() &&
830  !VD->getMostRecentDecl()->isInline() &&
831  !VD->hasAttr<ExcludeFromExplicitInstantiationAttr>())
832  continue;
833 
834  // Skip VarDecls that lack formal definitions but which we know are in
835  // fact defined somewhere.
836  if (VD->isKnownToBeDefined())
837  continue;
838  }
839 
840  Undefined.push_back(std::make_pair(ND, UndefinedUse.second));
841  }
842 }
843 
844 /// checkUndefinedButUsed - Check for undefined objects with internal linkage
845 /// or that are inline.
846 static void checkUndefinedButUsed(Sema &S) {
847  if (S.UndefinedButUsed.empty()) return;
848 
849  // Collect all the still-undefined entities with internal linkage.
851  S.getUndefinedButUsed(Undefined);
852  if (Undefined.empty()) return;
853 
854  for (auto Undef : Undefined) {
855  ValueDecl *VD = cast<ValueDecl>(Undef.first);
856  SourceLocation UseLoc = Undef.second;
857 
858  if (S.isExternalWithNoLinkageType(VD)) {
859  // C++ [basic.link]p8:
860  // A type without linkage shall not be used as the type of a variable
861  // or function with external linkage unless
862  // -- the entity has C language linkage
863  // -- the entity is not odr-used or is defined in the same TU
864  //
865  // As an extension, accept this in cases where the type is externally
866  // visible, since the function or variable actually can be defined in
867  // another translation unit in that case.
869  ? diag::ext_undefined_internal_type
870  : diag::err_undefined_internal_type)
871  << isa<VarDecl>(VD) << VD;
872  } else if (!VD->isExternallyVisible()) {
873  // FIXME: We can promote this to an error. The function or variable can't
874  // be defined anywhere else, so the program must necessarily violate the
875  // one definition rule.
876  bool IsImplicitBase = false;
877  if (const auto *BaseD = dyn_cast<FunctionDecl>(VD)) {
878  auto *DVAttr = BaseD->getAttr<OMPDeclareVariantAttr>();
879  if (DVAttr && !DVAttr->getTraitInfo().isExtensionActive(
880  llvm::omp::TraitProperty::
881  implementation_extension_disable_implicit_base)) {
882  const auto *Func = cast<FunctionDecl>(
883  cast<DeclRefExpr>(DVAttr->getVariantFuncRef())->getDecl());
884  IsImplicitBase = BaseD->isImplicit() &&
885  Func->getIdentifier()->isMangledOpenMPVariantName();
886  }
887  }
888  if (!S.getLangOpts().OpenMP || !IsImplicitBase)
889  S.Diag(VD->getLocation(), diag::warn_undefined_internal)
890  << isa<VarDecl>(VD) << VD;
891  } else if (auto *FD = dyn_cast<FunctionDecl>(VD)) {
892  (void)FD;
893  assert(FD->getMostRecentDecl()->isInlined() &&
894  "used object requires definition but isn't inline or internal?");
895  // FIXME: This is ill-formed; we should reject.
896  S.Diag(VD->getLocation(), diag::warn_undefined_inline) << VD;
897  } else {
898  assert(cast<VarDecl>(VD)->getMostRecentDecl()->isInline() &&
899  "used var requires definition but isn't inline or internal?");
900  S.Diag(VD->getLocation(), diag::err_undefined_inline_var) << VD;
901  }
902  if (UseLoc.isValid())
903  S.Diag(UseLoc, diag::note_used_here);
904  }
905 
906  S.UndefinedButUsed.clear();
907 }
908 
910  if (!ExternalSource)
911  return;
912 
914  ExternalSource->ReadWeakUndeclaredIdentifiers(WeakIDs);
915  for (auto &WeakID : WeakIDs)
916  (void)WeakUndeclaredIdentifiers[WeakID.first].insert(WeakID.second);
917 }
918 
919 
920 typedef llvm::DenseMap<const CXXRecordDecl*, bool> RecordCompleteMap;
921 
922 /// Returns true, if all methods and nested classes of the given
923 /// CXXRecordDecl are defined in this translation unit.
924 ///
925 /// Should only be called from ActOnEndOfTranslationUnit so that all
926 /// definitions are actually read.
928  RecordCompleteMap &MNCComplete) {
929  RecordCompleteMap::iterator Cache = MNCComplete.find(RD);
930  if (Cache != MNCComplete.end())
931  return Cache->second;
932  if (!RD->isCompleteDefinition())
933  return false;
934  bool Complete = true;
936  E = RD->decls_end();
937  I != E && Complete; ++I) {
938  if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
939  Complete = M->isDefined() || M->isDefaulted() ||
940  (M->isPure() && !isa<CXXDestructorDecl>(M));
941  else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
942  // If the template function is marked as late template parsed at this
943  // point, it has not been instantiated and therefore we have not
944  // performed semantic analysis on it yet, so we cannot know if the type
945  // can be considered complete.
946  Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
947  F->getTemplatedDecl()->isDefined();
948  else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
949  if (R->isInjectedClassName())
950  continue;
951  if (R->hasDefinition())
952  Complete = MethodsAndNestedClassesComplete(R->getDefinition(),
953  MNCComplete);
954  else
955  Complete = false;
956  }
957  }
958  MNCComplete[RD] = Complete;
959  return Complete;
960 }
961 
962 /// Returns true, if the given CXXRecordDecl is fully defined in this
963 /// translation unit, i.e. all methods are defined or pure virtual and all
964 /// friends, friend functions and nested classes are fully defined in this
965 /// translation unit.
966 ///
967 /// Should only be called from ActOnEndOfTranslationUnit so that all
968 /// definitions are actually read.
969 static bool IsRecordFullyDefined(const CXXRecordDecl *RD,
970  RecordCompleteMap &RecordsComplete,
971  RecordCompleteMap &MNCComplete) {
972  RecordCompleteMap::iterator Cache = RecordsComplete.find(RD);
973  if (Cache != RecordsComplete.end())
974  return Cache->second;
975  bool Complete = MethodsAndNestedClassesComplete(RD, MNCComplete);
977  E = RD->friend_end();
978  I != E && Complete; ++I) {
979  // Check if friend classes and methods are complete.
980  if (TypeSourceInfo *TSI = (*I)->getFriendType()) {
981  // Friend classes are available as the TypeSourceInfo of the FriendDecl.
982  if (CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl())
983  Complete = MethodsAndNestedClassesComplete(FriendD, MNCComplete);
984  else
985  Complete = false;
986  } else {
987  // Friend functions are available through the NamedDecl of FriendDecl.
988  if (const FunctionDecl *FD =
989  dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
990  Complete = FD->isDefined();
991  else
992  // This is a template friend, give up.
993  Complete = false;
994  }
995  }
996  RecordsComplete[RD] = Complete;
997  return Complete;
998 }
999 
1001  if (ExternalSource)
1002  ExternalSource->ReadUnusedLocalTypedefNameCandidates(
1005  if (TD->isReferenced())
1006  continue;
1007  Diag(TD->getLocation(), diag::warn_unused_local_typedef)
1008  << isa<TypeAliasDecl>(TD) << TD->getDeclName();
1009  }
1011 }
1012 
1013 /// This is called before the very first declaration in the translation unit
1014 /// is parsed. Note that the ASTContext may have already injected some
1015 /// declarations.
1017  if (getLangOpts().CPlusPlusModules &&
1018  getLangOpts().getCompilingModule() == LangOptions::CMK_HeaderUnit)
1019  HandleStartOfHeaderUnit();
1020  else if (getLangOpts().ModulesTS &&
1021  (getLangOpts().getCompilingModule() ==
1023  getLangOpts().getCompilingModule() == LangOptions::CMK_None)) {
1024  // We start in an implied global module fragment.
1025  SourceLocation StartOfTU =
1027  ActOnGlobalModuleFragmentDecl(StartOfTU);
1028  ModuleScopes.back().ImplicitGlobalModuleFragment = true;
1029  }
1030 }
1031 
1033  // No explicit actions are required at the end of the global module fragment.
1034  if (Kind == TUFragmentKind::Global)
1035  return;
1036 
1037  // Transfer late parsed template instantiations over to the pending template
1038  // instantiation list. During normal compilation, the late template parser
1039  // will be installed and instantiating these templates will succeed.
1040  //
1041  // If we are building a TU prefix for serialization, it is also safe to
1042  // transfer these over, even though they are not parsed. The end of the TU
1043  // should be outside of any eager template instantiation scope, so when this
1044  // AST is deserialized, these templates will not be parsed until the end of
1045  // the combined TU.
1047  LateParsedInstantiations.begin(),
1048  LateParsedInstantiations.end());
1049  LateParsedInstantiations.clear();
1050 
1051  // If DefinedUsedVTables ends up marking any virtual member functions it
1052  // might lead to more pending template instantiations, which we then need
1053  // to instantiate.
1055 
1056  // C++: Perform implicit template instantiations.
1057  //
1058  // FIXME: When we perform these implicit instantiations, we do not
1059  // carefully keep track of the point of instantiation (C++ [temp.point]).
1060  // This means that name lookup that occurs within the template
1061  // instantiation will always happen at the end of the translation unit,
1062  // so it will find some names that are not required to be found. This is
1063  // valid, but we could do better by diagnosing if an instantiation uses a
1064  // name that was not visible at its first point of instantiation.
1065  if (ExternalSource) {
1066  // Load pending instantiations from the external source.
1068  ExternalSource->ReadPendingInstantiations(Pending);
1069  for (auto PII : Pending)
1070  if (auto Func = dyn_cast<FunctionDecl>(PII.first))
1071  Func->setInstantiationIsPending(true);
1073  Pending.begin(), Pending.end());
1074  }
1075 
1076  {
1077  llvm::TimeTraceScope TimeScope("PerformPendingInstantiations");
1079  }
1080 
1082 
1083  assert(LateParsedInstantiations.empty() &&
1084  "end of TU template instantiation should not create more "
1085  "late-parsed templates");
1086 
1087  // Report diagnostics for uncorrected delayed typos. Ideally all of them
1088  // should have been corrected by that time, but it is very hard to cover all
1089  // cases in practice.
1090  for (const auto &Typo : DelayedTypos) {
1091  // We pass an empty TypoCorrection to indicate no correction was performed.
1092  Typo.second.DiagHandler(TypoCorrection());
1093  }
1094  DelayedTypos.clear();
1095 }
1096 
1097 /// ActOnEndOfTranslationUnit - This is called at the very end of the
1098 /// translation unit when EOF is reached and all but the top-level scope is
1099 /// popped.
1101  assert(DelayedDiagnostics.getCurrentPool() == nullptr
1102  && "reached end of translation unit with a pool attached?");
1103 
1104  // If code completion is enabled, don't perform any end-of-translation-unit
1105  // work.
1107  return;
1108 
1109  // Complete translation units and modules define vtables and perform implicit
1110  // instantiations. PCH files do not.
1111  if (TUKind != TU_Prefix) {
1113 
1115  !ModuleScopes.empty() && ModuleScopes.back().Module->Kind ==
1117  ? TUFragmentKind::Private
1118  : TUFragmentKind::Normal);
1119 
1122 
1124  } else {
1125  // If we are building a TU prefix for serialization, it is safe to transfer
1126  // these over, even though they are not parsed. The end of the TU should be
1127  // outside of any eager template instantiation scope, so when this AST is
1128  // deserialized, these templates will not be parsed until the end of the
1129  // combined TU.
1131  LateParsedInstantiations.begin(),
1132  LateParsedInstantiations.end());
1133  LateParsedInstantiations.clear();
1134 
1135  if (LangOpts.PCHInstantiateTemplates) {
1136  llvm::TimeTraceScope TimeScope("PerformPendingInstantiations");
1138  }
1139  }
1140 
1144 
1145  // All delayed member exception specs should be checked or we end up accepting
1146  // incompatible declarations.
1147  assert(DelayedOverridingExceptionSpecChecks.empty());
1148  assert(DelayedEquivalentExceptionSpecChecks.empty());
1149 
1150  // All dllexport classes should have been processed already.
1151  assert(DelayedDllExportClasses.empty());
1152  assert(DelayedDllExportMemberFunctions.empty());
1153 
1154  // Remove file scoped decls that turned out to be used.
1156  std::remove_if(UnusedFileScopedDecls.begin(nullptr, true),
1158  [this](const DeclaratorDecl *DD) {
1159  return ShouldRemoveFromUnused(this, DD);
1160  }),
1162 
1163  if (TUKind == TU_Prefix) {
1164  // Translation unit prefixes don't need any of the checking below.
1166  TUScope = nullptr;
1167  return;
1168  }
1169 
1170  // Check for #pragma weak identifiers that were never declared
1172  for (const auto &WeakIDs : WeakUndeclaredIdentifiers) {
1173  if (WeakIDs.second.empty())
1174  continue;
1175 
1176  Decl *PrevDecl = LookupSingleName(TUScope, WeakIDs.first, SourceLocation(),
1178  if (PrevDecl != nullptr &&
1179  !(isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl)))
1180  for (const auto &WI : WeakIDs.second)
1181  Diag(WI.getLocation(), diag::warn_attribute_wrong_decl_type)
1182  << "'weak'" << ExpectedVariableOrFunction;
1183  else
1184  for (const auto &WI : WeakIDs.second)
1185  Diag(WI.getLocation(), diag::warn_weak_identifier_undeclared)
1186  << WeakIDs.first;
1187  }
1188 
1189  if (LangOpts.CPlusPlus11 &&
1190  !Diags.isIgnored(diag::warn_delegating_ctor_cycle, SourceLocation()))
1192 
1193  if (!Diags.hasErrorOccurred()) {
1194  if (ExternalSource)
1195  ExternalSource->ReadUndefinedButUsed(UndefinedButUsed);
1196  checkUndefinedButUsed(*this);
1197  }
1198 
1199  // A global-module-fragment is only permitted within a module unit.
1200  bool DiagnosedMissingModuleDeclaration = false;
1201  if (!ModuleScopes.empty() &&
1202  ModuleScopes.back().Module->Kind == Module::GlobalModuleFragment &&
1203  !ModuleScopes.back().ImplicitGlobalModuleFragment) {
1204  Diag(ModuleScopes.back().BeginLoc,
1205  diag::err_module_declaration_missing_after_global_module_introducer);
1206  DiagnosedMissingModuleDeclaration = true;
1207  }
1208 
1209  if (TUKind == TU_Module) {
1210  // If we are building a module interface unit, we need to have seen the
1211  // module declaration by now.
1212  if (getLangOpts().getCompilingModule() ==
1214  !isCurrentModulePurview() && !DiagnosedMissingModuleDeclaration) {
1215  // FIXME: Make a better guess as to where to put the module declaration.
1216  Diag(getSourceManager().getLocForStartOfFile(
1217  getSourceManager().getMainFileID()),
1218  diag::err_module_declaration_missing);
1219  }
1220 
1221  // If we are building a module, resolve all of the exported declarations
1222  // now.
1223  if (Module *CurrentModule = PP.getCurrentModule()) {
1225 
1227  Stack.push_back(CurrentModule);
1228  while (!Stack.empty()) {
1229  Module *Mod = Stack.pop_back_val();
1230 
1231  // Resolve the exported declarations and conflicts.
1232  // FIXME: Actually complain, once we figure out how to teach the
1233  // diagnostic client to deal with complaints in the module map at this
1234  // point.
1235  ModMap.resolveExports(Mod, /*Complain=*/false);
1236  ModMap.resolveUses(Mod, /*Complain=*/false);
1237  ModMap.resolveConflicts(Mod, /*Complain=*/false);
1238 
1239  // Queue the submodules, so their exports will also be resolved.
1240  Stack.append(Mod->submodule_begin(), Mod->submodule_end());
1241  }
1242  }
1243 
1244  // Warnings emitted in ActOnEndOfTranslationUnit() should be emitted for
1245  // modules when they are built, not every time they are used.
1247  }
1248 
1249  // C++ standard modules. Diagnose cases where a function is declared inline
1250  // in the module purview but has no definition before the end of the TU or
1251  // the start of a Private Module Fragment (if one is present).
1252  if (!PendingInlineFuncDecls.empty()) {
1253  for (auto *D : PendingInlineFuncDecls) {
1254  if (auto *FD = dyn_cast<FunctionDecl>(D)) {
1255  bool DefInPMF = false;
1256  if (auto *FDD = FD->getDefinition()) {
1257  assert(FDD->getOwningModule() &&
1258  FDD->getOwningModule()->isModulePurview());
1259  DefInPMF = FDD->getOwningModule()->isPrivateModule();
1260  if (!DefInPMF)
1261  continue;
1262  }
1263  Diag(FD->getLocation(), diag::err_export_inline_not_defined)
1264  << DefInPMF;
1265  // If we have a PMF it should be at the end of the ModuleScopes.
1266  if (DefInPMF &&
1267  ModuleScopes.back().Module->Kind == Module::PrivateModuleFragment) {
1268  Diag(ModuleScopes.back().BeginLoc,
1269  diag::note_private_module_fragment);
1270  }
1271  }
1272  }
1273  PendingInlineFuncDecls.clear();
1274  }
1275 
1276  // C99 6.9.2p2:
1277  // A declaration of an identifier for an object that has file
1278  // scope without an initializer, and without a storage-class
1279  // specifier or with the storage-class specifier static,
1280  // constitutes a tentative definition. If a translation unit
1281  // contains one or more tentative definitions for an identifier,
1282  // and the translation unit contains no external definition for
1283  // that identifier, then the behavior is exactly as if the
1284  // translation unit contains a file scope declaration of that
1285  // identifier, with the composite type as of the end of the
1286  // translation unit, with an initializer equal to 0.
1287  llvm::SmallSet<VarDecl *, 32> Seen;
1288  for (TentativeDefinitionsType::iterator
1289  T = TentativeDefinitions.begin(ExternalSource.get()),
1290  TEnd = TentativeDefinitions.end();
1291  T != TEnd; ++T) {
1292  VarDecl *VD = (*T)->getActingDefinition();
1293 
1294  // If the tentative definition was completed, getActingDefinition() returns
1295  // null. If we've already seen this variable before, insert()'s second
1296  // return value is false.
1297  if (!VD || VD->isInvalidDecl() || !Seen.insert(VD).second)
1298  continue;
1299 
1300  if (const IncompleteArrayType *ArrayT
1302  // Set the length of the array to 1 (C99 6.9.2p5).
1303  Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
1305  QualType T = Context.getConstantArrayType(ArrayT->getElementType(), One,
1306  nullptr, ArrayType::Normal, 0);
1307  VD->setType(T);
1308  } else if (RequireCompleteType(VD->getLocation(), VD->getType(),
1309  diag::err_tentative_def_incomplete_type))
1310  VD->setInvalidDecl();
1311 
1312  // No initialization is performed for a tentative definition.
1314 
1315  // Notify the consumer that we've completed a tentative definition.
1316  if (!VD->isInvalidDecl())
1318  }
1319 
1320  for (auto *D : ExternalDeclarations) {
1321  if (!D || D->isInvalidDecl() || D->getPreviousDecl() || !D->isUsed())
1322  continue;
1323 
1325  }
1326 
1327  // If there were errors, disable 'unused' warnings since they will mostly be
1328  // noise. Don't warn for a use from a module: either we should warn on all
1329  // file-scope declarations in modules or not at all, but whether the
1330  // declaration is used is immaterial.
1331  if (!Diags.hasErrorOccurred() && TUKind != TU_Module) {
1332  // Output warning for unused file scoped decls.
1333  for (UnusedFileScopedDeclsType::iterator
1334  I = UnusedFileScopedDecls.begin(ExternalSource.get()),
1335  E = UnusedFileScopedDecls.end();
1336  I != E; ++I) {
1337  if (ShouldRemoveFromUnused(this, *I))
1338  continue;
1339 
1340  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
1341  const FunctionDecl *DiagD;
1342  if (!FD->hasBody(DiagD))
1343  DiagD = FD;
1344  if (DiagD->isDeleted())
1345  continue; // Deleted functions are supposed to be unused.
1346  if (DiagD->isReferenced()) {
1347  if (isa<CXXMethodDecl>(DiagD))
1348  Diag(DiagD->getLocation(), diag::warn_unneeded_member_function)
1349  << DiagD;
1350  else {
1351  if (FD->getStorageClass() == SC_Static &&
1352  !FD->isInlineSpecified() &&
1354  SourceMgr.getExpansionLoc(FD->getLocation())))
1355  Diag(DiagD->getLocation(),
1356  diag::warn_unneeded_static_internal_decl)
1357  << DiagD;
1358  else
1359  Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
1360  << /*function*/ 0 << DiagD;
1361  }
1362  } else {
1363  if (FD->getDescribedFunctionTemplate())
1364  Diag(DiagD->getLocation(), diag::warn_unused_template)
1365  << /*function*/ 0 << DiagD;
1366  else
1367  Diag(DiagD->getLocation(), isa<CXXMethodDecl>(DiagD)
1368  ? diag::warn_unused_member_function
1369  : diag::warn_unused_function)
1370  << DiagD;
1371  }
1372  } else {
1373  const VarDecl *DiagD = cast<VarDecl>(*I)->getDefinition();
1374  if (!DiagD)
1375  DiagD = cast<VarDecl>(*I);
1376  if (DiagD->isReferenced()) {
1377  Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
1378  << /*variable*/ 1 << DiagD;
1379  } else if (DiagD->getType().isConstQualified()) {
1380  const SourceManager &SM = SourceMgr;
1381  if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) ||
1383  Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
1384  << DiagD;
1385  } else {
1386  if (DiagD->getDescribedVarTemplate())
1387  Diag(DiagD->getLocation(), diag::warn_unused_template)
1388  << /*variable*/ 1 << DiagD;
1389  else
1390  Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD;
1391  }
1392  }
1393  }
1394 
1396  }
1397 
1398  if (!Diags.isIgnored(diag::warn_unused_private_field, SourceLocation())) {
1399  // FIXME: Load additional unused private field candidates from the external
1400  // source.
1401  RecordCompleteMap RecordsComplete;
1402  RecordCompleteMap MNCComplete;
1403  for (NamedDeclSetType::iterator I = UnusedPrivateFields.begin(),
1404  E = UnusedPrivateFields.end(); I != E; ++I) {
1405  const NamedDecl *D = *I;
1406  const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D->getDeclContext());
1407  if (RD && !RD->isUnion() &&
1408  IsRecordFullyDefined(RD, RecordsComplete, MNCComplete)) {
1409  Diag(D->getLocation(), diag::warn_unused_private_field)
1410  << D->getDeclName();
1411  }
1412  }
1413  }
1414 
1415  if (!Diags.isIgnored(diag::warn_mismatched_delete_new, SourceLocation())) {
1416  if (ExternalSource)
1417  ExternalSource->ReadMismatchingDeleteExpressions(DeleteExprs);
1418  for (const auto &DeletedFieldInfo : DeleteExprs) {
1419  for (const auto &DeleteExprLoc : DeletedFieldInfo.second) {
1420  AnalyzeDeleteExprMismatch(DeletedFieldInfo.first, DeleteExprLoc.first,
1421  DeleteExprLoc.second);
1422  }
1423  }
1424  }
1425 
1426  // Check we've noticed that we're no longer parsing the initializer for every
1427  // variable. If we miss cases, then at best we have a performance issue and
1428  // at worst a rejects-valid bug.
1429  assert(ParsingInitForAutoVars.empty() &&
1430  "Didn't unmark var as having its initializer parsed");
1431 
1433  TUScope = nullptr;
1434 }
1435 
1436 
1437 //===----------------------------------------------------------------------===//
1438 // Helper functions.
1439 //===----------------------------------------------------------------------===//
1440 
1442  DeclContext *DC = CurContext;
1443 
1444  while (true) {
1445  if (isa<BlockDecl>(DC) || isa<EnumDecl>(DC) || isa<CapturedDecl>(DC) ||
1446  isa<RequiresExprBodyDecl>(DC)) {
1447  DC = DC->getParent();
1448  } else if (!AllowLambda && isa<CXXMethodDecl>(DC) &&
1449  cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call &&
1450  cast<CXXRecordDecl>(DC->getParent())->isLambda()) {
1451  DC = DC->getParent()->getParent();
1452  } else break;
1453  }
1454 
1455  return DC;
1456 }
1457 
1458 /// getCurFunctionDecl - If inside of a function body, this returns a pointer
1459 /// to the function decl for the function being parsed. If we're currently
1460 /// in a 'block', this returns the containing context.
1462  DeclContext *DC = getFunctionLevelDeclContext(AllowLambda);
1463  return dyn_cast<FunctionDecl>(DC);
1464 }
1465 
1468  while (isa<RecordDecl>(DC))
1469  DC = DC->getParent();
1470  return dyn_cast<ObjCMethodDecl>(DC);
1471 }
1472 
1475  if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
1476  return cast<NamedDecl>(DC);
1477  return nullptr;
1478 }
1479 
1481  if (getLangOpts().OpenCL)
1483  return LangAS::Default;
1484 }
1485 
1486 void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
1487  // FIXME: It doesn't make sense to me that DiagID is an incoming argument here
1488  // and yet we also use the current diag ID on the DiagnosticsEngine. This has
1489  // been made more painfully obvious by the refactor that introduced this
1490  // function, but it is possible that the incoming argument can be
1491  // eliminated. If it truly cannot be (for example, there is some reentrancy
1492  // issue I am not seeing yet), then there should at least be a clarifying
1493  // comment somewhere.
1496  Diags.getCurrentDiagID())) {
1498  // We'll report the diagnostic below.
1499  break;
1500 
1502  // Count this failure so that we know that template argument deduction
1503  // has failed.
1504  ++NumSFINAEErrors;
1505 
1506  // Make a copy of this suppressed diagnostic and store it with the
1507  // template-deduction information.
1508  if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1509  Diagnostic DiagInfo(&Diags);
1510  (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
1512  }
1513 
1515  Diags.Clear();
1516  return;
1517 
1519  // Per C++ Core Issue 1170, access control is part of SFINAE.
1520  // Additionally, the AccessCheckingSFINAE flag can be used to temporarily
1521  // make access control a part of SFINAE for the purposes of checking
1522  // type traits.
1524  break;
1525 
1527 
1528  // Suppress this diagnostic.
1529  ++NumSFINAEErrors;
1530 
1531  // Make a copy of this suppressed diagnostic and store it with the
1532  // template-deduction information.
1533  if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1534  Diagnostic DiagInfo(&Diags);
1535  (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
1537  }
1538 
1540  Diags.Clear();
1541 
1542  // Now the diagnostic state is clear, produce a C++98 compatibility
1543  // warning.
1544  Diag(Loc, diag::warn_cxx98_compat_sfinae_access_control);
1545 
1546  // The last diagnostic which Sema produced was ignored. Suppress any
1547  // notes attached to it.
1549  return;
1550  }
1551 
1553  // Make a copy of this suppressed diagnostic and store it with the
1554  // template-deduction information;
1555  if (*Info) {
1556  Diagnostic DiagInfo(&Diags);
1557  (*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(),
1559  }
1560 
1561  // Suppress this diagnostic.
1563  Diags.Clear();
1564  return;
1565  }
1566  }
1567 
1568  // Copy the diagnostic printing policy over the ASTContext printing policy.
1569  // TODO: Stop doing that. See: https://reviews.llvm.org/D45093#1090292
1571 
1572  // Emit the diagnostic.
1574  return;
1575 
1576  // If this is not a note, and we're in a template instantiation
1577  // that is different from the last template instantiation where
1578  // we emitted an error, print a template instantiation
1579  // backtrace.
1580  if (!DiagnosticIDs::isBuiltinNote(DiagID))
1582 }
1583 
1585 Sema::Diag(SourceLocation Loc, const PartialDiagnostic &PD, bool DeferHint) {
1586  return Diag(Loc, PD.getDiagID(), DeferHint) << PD;
1587 }
1588 
1591  return true;
1592  auto *FD = dyn_cast<FunctionDecl>(CurContext);
1593  if (!FD)
1594  return false;
1595  auto Loc = DeviceDeferredDiags.find(FD);
1596  if (Loc == DeviceDeferredDiags.end())
1597  return false;
1598  for (auto PDAt : Loc->second) {
1599  if (DiagnosticIDs::isDefaultMappingAsError(PDAt.second.getDiagID()))
1600  return true;
1601  }
1602  return false;
1603 }
1604 
1605 // Print notes showing how we can reach FD starting from an a priori
1606 // known-callable function.
1607 static void emitCallStackNotes(Sema &S, FunctionDecl *FD) {
1608  auto FnIt = S.DeviceKnownEmittedFns.find(FD);
1609  while (FnIt != S.DeviceKnownEmittedFns.end()) {
1610  // Respect error limit.
1611  if (S.Diags.hasFatalErrorOccurred())
1612  return;
1613  DiagnosticBuilder Builder(
1614  S.Diags.Report(FnIt->second.Loc, diag::note_called_by));
1615  Builder << FnIt->second.FD;
1616  FnIt = S.DeviceKnownEmittedFns.find(FnIt->second.FD);
1617  }
1618 }
1619 
1620 namespace {
1621 
1622 /// Helper class that emits deferred diagnostic messages if an entity directly
1623 /// or indirectly using the function that causes the deferred diagnostic
1624 /// messages is known to be emitted.
1625 ///
1626 /// During parsing of AST, certain diagnostic messages are recorded as deferred
1627 /// diagnostics since it is unknown whether the functions containing such
1628 /// diagnostics will be emitted. A list of potentially emitted functions and
1629 /// variables that may potentially trigger emission of functions are also
1630 /// recorded. DeferredDiagnosticsEmitter recursively visits used functions
1631 /// by each function to emit deferred diagnostics.
1632 ///
1633 /// During the visit, certain OpenMP directives or initializer of variables
1634 /// with certain OpenMP attributes will cause subsequent visiting of any
1635 /// functions enter a state which is called OpenMP device context in this
1636 /// implementation. The state is exited when the directive or initializer is
1637 /// exited. This state can change the emission states of subsequent uses
1638 /// of functions.
1639 ///
1640 /// Conceptually the functions or variables to be visited form a use graph
1641 /// where the parent node uses the child node. At any point of the visit,
1642 /// the tree nodes traversed from the tree root to the current node form a use
1643 /// stack. The emission state of the current node depends on two factors:
1644 /// 1. the emission state of the root node
1645 /// 2. whether the current node is in OpenMP device context
1646 /// If the function is decided to be emitted, its contained deferred diagnostics
1647 /// are emitted, together with the information about the use stack.
1648 ///
1649 class DeferredDiagnosticsEmitter
1650  : public UsedDeclVisitor<DeferredDiagnosticsEmitter> {
1651 public:
1653 
1654  // Whether the function is already in the current use-path.
1656 
1657  // The current use-path.
1659 
1660  // Whether the visiting of the function has been done. Done[0] is for the
1661  // case not in OpenMP device context. Done[1] is for the case in OpenMP
1662  // device context. We need two sets because diagnostics emission may be
1663  // different depending on whether it is in OpenMP device context.
1665 
1666  // Emission state of the root node of the current use graph.
1667  bool ShouldEmitRootNode;
1668 
1669  // Current OpenMP device context level. It is initialized to 0 and each
1670  // entering of device context increases it by 1 and each exit decreases
1671  // it by 1. Non-zero value indicates it is currently in device context.
1672  unsigned InOMPDeviceContext;
1673 
1674  DeferredDiagnosticsEmitter(Sema &S)
1675  : Inherited(S), ShouldEmitRootNode(false), InOMPDeviceContext(0) {}
1676 
1677  bool shouldVisitDiscardedStmt() const { return false; }
1678 
1679  void VisitOMPTargetDirective(OMPTargetDirective *Node) {
1680  ++InOMPDeviceContext;
1681  Inherited::VisitOMPTargetDirective(Node);
1682  --InOMPDeviceContext;
1683  }
1684 
1685  void visitUsedDecl(SourceLocation Loc, Decl *D) {
1686  if (isa<VarDecl>(D))
1687  return;
1688  if (auto *FD = dyn_cast<FunctionDecl>(D))
1689  checkFunc(Loc, FD);
1690  else
1691  Inherited::visitUsedDecl(Loc, D);
1692  }
1693 
1694  void checkVar(VarDecl *VD) {
1695  assert(VD->isFileVarDecl() &&
1696  "Should only check file-scope variables");
1697  if (auto *Init = VD->getInit()) {
1698  auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
1699  bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
1700  *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
1701  if (IsDev)
1702  ++InOMPDeviceContext;
1703  this->Visit(Init);
1704  if (IsDev)
1705  --InOMPDeviceContext;
1706  }
1707  }
1708 
1709  void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
1710  auto &Done = DoneMap[InOMPDeviceContext > 0 ? 1 : 0];
1711  FunctionDecl *Caller = UsePath.empty() ? nullptr : UsePath.back();
1712  if ((!ShouldEmitRootNode && !S.getLangOpts().OpenMP && !Caller) ||
1713  S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD))
1714  return;
1715  // Finalize analysis of OpenMP-specific constructs.
1716  if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1 &&
1717  (ShouldEmitRootNode || InOMPDeviceContext))
1718  S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
1719  if (Caller)
1720  S.DeviceKnownEmittedFns[FD] = {Caller, Loc};
1721  // Always emit deferred diagnostics for the direct users. This does not
1722  // lead to explosion of diagnostics since each user is visited at most
1723  // twice.
1724  if (ShouldEmitRootNode || InOMPDeviceContext)
1725  emitDeferredDiags(FD, Caller);
1726  // Do not revisit a function if the function body has been completely
1727  // visited before.
1728  if (!Done.insert(FD).second)
1729  return;
1730  InUsePath.insert(FD);
1731  UsePath.push_back(FD);
1732  if (auto *S = FD->getBody()) {
1733  this->Visit(S);
1734  }
1735  UsePath.pop_back();
1736  InUsePath.erase(FD);
1737  }
1738 
1739  void checkRecordedDecl(Decl *D) {
1740  if (auto *FD = dyn_cast<FunctionDecl>(D)) {
1741  ShouldEmitRootNode = S.getEmissionStatus(FD, /*Final=*/true) ==
1743  checkFunc(SourceLocation(), FD);
1744  } else
1745  checkVar(cast<VarDecl>(D));
1746  }
1747 
1748  // Emit any deferred diagnostics for FD
1749  void emitDeferredDiags(FunctionDecl *FD, bool ShowCallStack) {
1750  auto It = S.DeviceDeferredDiags.find(FD);
1751  if (It == S.DeviceDeferredDiags.end())
1752  return;
1753  bool HasWarningOrError = false;
1754  bool FirstDiag = true;
1755  for (PartialDiagnosticAt &PDAt : It->second) {
1756  // Respect error limit.
1757  if (S.Diags.hasFatalErrorOccurred())
1758  return;
1759  const SourceLocation &Loc = PDAt.first;
1760  const PartialDiagnostic &PD = PDAt.second;
1761  HasWarningOrError |=
1762  S.getDiagnostics().getDiagnosticLevel(PD.getDiagID(), Loc) >=
1764  {
1765  DiagnosticBuilder Builder(S.Diags.Report(Loc, PD.getDiagID()));
1766  PD.Emit(Builder);
1767  }
1768  // Emit the note on the first diagnostic in case too many diagnostics
1769  // cause the note not emitted.
1770  if (FirstDiag && HasWarningOrError && ShowCallStack) {
1771  emitCallStackNotes(S, FD);
1772  FirstDiag = false;
1773  }
1774  }
1775  }
1776 };
1777 } // namespace
1778 
1780  if (ExternalSource)
1781  ExternalSource->ReadDeclsToCheckForDeferredDiags(
1782  DeclsToCheckForDeferredDiags);
1783 
1784  if ((DeviceDeferredDiags.empty() && !LangOpts.OpenMP) ||
1785  DeclsToCheckForDeferredDiags.empty())
1786  return;
1787 
1788  DeferredDiagnosticsEmitter DDE(*this);
1789  for (auto *D : DeclsToCheckForDeferredDiags)
1790  DDE.checkRecordedDecl(D);
1791 }
1792 
1793 // In CUDA, there are some constructs which may appear in semantically-valid
1794 // code, but trigger errors if we ever generate code for the function in which
1795 // they appear. Essentially every construct you're not allowed to use on the
1796 // device falls into this category, because you are allowed to use these
1797 // constructs in a __host__ __device__ function, but only if that function is
1798 // never codegen'ed on the device.
1799 //
1800 // To handle semantic checking for these constructs, we keep track of the set of
1801 // functions we know will be emitted, either because we could tell a priori that
1802 // they would be emitted, or because they were transitively called by a
1803 // known-emitted function.
1804 //
1805 // We also keep a partial call graph of which not-known-emitted functions call
1806 // which other not-known-emitted functions.
1807 //
1808 // When we see something which is illegal if the current function is emitted
1809 // (usually by way of CUDADiagIfDeviceCode, CUDADiagIfHostCode, or
1810 // CheckCUDACall), we first check if the current function is known-emitted. If
1811 // so, we immediately output the diagnostic.
1812 //
1813 // Otherwise, we "defer" the diagnostic. It sits in Sema::DeviceDeferredDiags
1814 // until we discover that the function is known-emitted, at which point we take
1815 // it out of this map and emit the diagnostic.
1816 
1818  unsigned DiagID,
1819  FunctionDecl *Fn, Sema &S)
1820  : S(S), Loc(Loc), DiagID(DiagID), Fn(Fn),
1821  ShowCallStack(K == K_ImmediateWithCallStack || K == K_Deferred) {
1822  switch (K) {
1823  case K_Nop:
1824  break;
1825  case K_Immediate:
1827  ImmediateDiag.emplace(
1828  ImmediateDiagBuilder(S.Diags.Report(Loc, DiagID), S, DiagID));
1829  break;
1830  case K_Deferred:
1831  assert(Fn && "Must have a function to attach the deferred diag to.");
1832  auto &Diags = S.DeviceDeferredDiags[Fn];
1833  PartialDiagId.emplace(Diags.size());
1834  Diags.emplace_back(Loc, S.PDiag(DiagID));
1835  break;
1836  }
1837 }
1838 
1840  : S(D.S), Loc(D.Loc), DiagID(D.DiagID), Fn(D.Fn),
1841  ShowCallStack(D.ShowCallStack), ImmediateDiag(D.ImmediateDiag),
1842  PartialDiagId(D.PartialDiagId) {
1843  // Clean the previous diagnostics.
1844  D.ShowCallStack = false;
1845  D.ImmediateDiag.reset();
1846  D.PartialDiagId.reset();
1847 }
1848 
1850  if (ImmediateDiag) {
1851  // Emit our diagnostic and, if it was a warning or error, output a callstack
1852  // if Fn isn't a priori known-emitted.
1853  bool IsWarningOrError = S.getDiagnostics().getDiagnosticLevel(
1854  DiagID, Loc) >= DiagnosticsEngine::Warning;
1855  ImmediateDiag.reset(); // Emit the immediate diag.
1856  if (IsWarningOrError && ShowCallStack)
1857  emitCallStackNotes(S, Fn);
1858  } else {
1859  assert((!PartialDiagId || ShowCallStack) &&
1860  "Must always show call stack for deferred diags.");
1861  }
1862 }
1863 
1865 Sema::targetDiag(SourceLocation Loc, unsigned DiagID, FunctionDecl *FD) {
1866  FD = FD ? FD : getCurFunctionDecl();
1867  if (LangOpts.OpenMP)
1868  return LangOpts.OpenMPIsDevice ? diagIfOpenMPDeviceCode(Loc, DiagID, FD)
1869  : diagIfOpenMPHostCode(Loc, DiagID, FD);
1870  if (getLangOpts().CUDA)
1871  return getLangOpts().CUDAIsDevice ? CUDADiagIfDeviceCode(Loc, DiagID)
1872  : CUDADiagIfHostCode(Loc, DiagID);
1873 
1874  if (getLangOpts().SYCLIsDevice)
1875  return SYCLDiagIfDeviceCode(Loc, DiagID);
1876 
1878  FD, *this);
1879 }
1880 
1882  bool DeferHint) {
1883  bool IsError = Diags.getDiagnosticIDs()->isDefaultMappingAsError(DiagID);
1884  bool ShouldDefer = getLangOpts().CUDA && LangOpts.GPUDeferDiag &&
1885  DiagnosticIDs::isDeferrable(DiagID) &&
1886  (DeferHint || DeferDiags || !IsError);
1887  auto SetIsLastErrorImmediate = [&](bool Flag) {
1888  if (IsError)
1889  IsLastErrorImmediate = Flag;
1890  };
1891  if (!ShouldDefer) {
1892  SetIsLastErrorImmediate(true);
1894  DiagID, getCurFunctionDecl(), *this);
1895  }
1896 
1897  SemaDiagnosticBuilder DB = getLangOpts().CUDAIsDevice
1898  ? CUDADiagIfDeviceCode(Loc, DiagID)
1899  : CUDADiagIfHostCode(Loc, DiagID);
1900  SetIsLastErrorImmediate(DB.isImmediate());
1901  return DB;
1902 }
1903 
1905  if (isUnevaluatedContext() || Ty.isNull())
1906  return;
1907 
1908  // The original idea behind checkTypeSupport function is that unused
1909  // declarations can be replaced with an array of bytes of the same size during
1910  // codegen, such replacement doesn't seem to be possible for types without
1911  // constant byte size like zero length arrays. So, do a deep check for SYCL.
1912  if (D && LangOpts.SYCLIsDevice) {
1913  llvm::DenseSet<QualType> Visited;
1914  deepTypeCheckForSYCLDevice(Loc, Visited, D);
1915  }
1916 
1917  Decl *C = cast<Decl>(getCurLexicalContext());
1918 
1919  // Memcpy operations for structs containing a member with unsupported type
1920  // are ok, though.
1921  if (const auto *MD = dyn_cast<CXXMethodDecl>(C)) {
1922  if ((MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) &&
1923  MD->isTrivial())
1924  return;
1925 
1926  if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(MD))
1927  if (Ctor->isCopyOrMoveConstructor() && Ctor->isTrivial())
1928  return;
1929  }
1930 
1931  // Try to associate errors with the lexical context, if that is a function, or
1932  // the value declaration otherwise.
1933  FunctionDecl *FD = isa<FunctionDecl>(C) ? cast<FunctionDecl>(C)
1934  : dyn_cast_or_null<FunctionDecl>(D);
1935 
1936  auto CheckDeviceType = [&](QualType Ty) {
1937  if (Ty->isDependentType())
1938  return;
1939 
1940  if (Ty->isBitIntType()) {
1941  if (!Context.getTargetInfo().hasBitIntType()) {
1942  PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type);
1943  if (D)
1944  PD << D;
1945  else
1946  PD << "expression";
1947  targetDiag(Loc, PD, FD)
1948  << false /*show bit size*/ << 0 /*bitsize*/ << false /*return*/
1949  << Ty << Context.getTargetInfo().getTriple().str();
1950  }
1951  return;
1952  }
1953 
1954  // Check if we are dealing with two 'long double' but with different
1955  // semantics.
1956  bool LongDoubleMismatched = false;
1957  if (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128) {
1958  const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(Ty);
1959  if ((&Sem != &llvm::APFloat::PPCDoubleDouble() &&
1961  (&Sem == &llvm::APFloat::PPCDoubleDouble() &&
1963  LongDoubleMismatched = true;
1964  }
1965 
1966  if ((Ty->isFloat16Type() && !Context.getTargetInfo().hasFloat16Type()) ||
1968  (Ty->isIbm128Type() && !Context.getTargetInfo().hasIbm128Type()) ||
1969  (Ty->isIntegerType() && Context.getTypeSize(Ty) == 128 &&
1971  LongDoubleMismatched) {
1972  PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type);
1973  if (D)
1974  PD << D;
1975  else
1976  PD << "expression";
1977 
1978  if (targetDiag(Loc, PD, FD)
1979  << true /*show bit size*/
1980  << static_cast<unsigned>(Context.getTypeSize(Ty)) << Ty
1981  << false /*return*/ << Context.getTargetInfo().getTriple().str()) {
1982  if (D)
1983  D->setInvalidDecl();
1984  }
1985  if (D)
1986  targetDiag(D->getLocation(), diag::note_defined_here, FD) << D;
1987  }
1988  };
1989 
1990  auto CheckType = [&](QualType Ty, bool IsRetTy = false) {
1991  if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice) ||
1992  LangOpts.CUDAIsDevice)
1993  CheckDeviceType(Ty);
1994 
1995  QualType UnqualTy = Ty.getCanonicalType().getUnqualifiedType();
1996  const TargetInfo &TI = Context.getTargetInfo();
1997  if (!TI.hasLongDoubleType() && UnqualTy == Context.LongDoubleTy) {
1998  PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type);
1999  if (D)
2000  PD << D;
2001  else
2002  PD << "expression";
2003 
2004  if (Diag(Loc, PD, FD)
2005  << false /*show bit size*/ << 0 << Ty << false /*return*/
2006  << Context.getTargetInfo().getTriple().str()) {
2007  if (D)
2008  D->setInvalidDecl();
2009  }
2010  if (D)
2011  targetDiag(D->getLocation(), diag::note_defined_here, FD) << D;
2012  }
2013 
2014  bool IsDouble = UnqualTy == Context.DoubleTy;
2015  bool IsFloat = UnqualTy == Context.FloatTy;
2016  if (IsRetTy && !TI.hasFPReturn() && (IsDouble || IsFloat)) {
2017  PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type);
2018  if (D)
2019  PD << D;
2020  else
2021  PD << "expression";
2022 
2023  if (Diag(Loc, PD, FD)
2024  << false /*show bit size*/ << 0 << Ty << true /*return*/
2025  << Context.getTargetInfo().getTriple().str()) {
2026  if (D)
2027  D->setInvalidDecl();
2028  }
2029  if (D)
2030  targetDiag(D->getLocation(), diag::note_defined_here, FD) << D;
2031  }
2032  };
2033 
2034  CheckType(Ty);
2035  if (const auto *FPTy = dyn_cast<FunctionProtoType>(Ty)) {
2036  for (const auto &ParamTy : FPTy->param_types())
2037  CheckType(ParamTy);
2038  CheckType(FPTy->getReturnType(), /*IsRetTy=*/true);
2039  }
2040  if (const auto *FNPTy = dyn_cast<FunctionNoProtoType>(Ty))
2041  CheckType(FNPTy->getReturnType(), /*IsRetTy=*/true);
2042 }
2043 
2044 /// Looks through the macro-expansion chain for the given
2045 /// location, looking for a macro expansion with the given name.
2046 /// If one is found, returns true and sets the location to that
2047 /// expansion loc.
2048 bool Sema::findMacroSpelling(SourceLocation &locref, StringRef name) {
2049  SourceLocation loc = locref;
2050  if (!loc.isMacroID()) return false;
2051 
2052  // There's no good way right now to look at the intermediate
2053  // expansions, so just jump to the expansion location.
2054  loc = getSourceManager().getExpansionLoc(loc);
2055 
2056  // If that's written with the name, stop here.
2057  SmallString<16> buffer;
2058  if (getPreprocessor().getSpelling(loc, buffer) == name) {
2059  locref = loc;
2060  return true;
2061  }
2062  return false;
2063 }
2064 
2065 /// Determines the active Scope associated with the given declaration
2066 /// context.
2067 ///
2068 /// This routine maps a declaration context to the active Scope object that
2069 /// represents that declaration context in the parser. It is typically used
2070 /// from "scope-less" code (e.g., template instantiation, lazy creation of
2071 /// declarations) that injects a name for name-lookup purposes and, therefore,
2072 /// must update the Scope.
2073 ///
2074 /// \returns The scope corresponding to the given declaraion context, or NULL
2075 /// if no such scope is open.
2077 
2078  if (!Ctx)
2079  return nullptr;
2080 
2081  Ctx = Ctx->getPrimaryContext();
2082  for (Scope *S = getCurScope(); S; S = S->getParent()) {
2083  // Ignore scopes that cannot have declarations. This is important for
2084  // out-of-line definitions of static class members.
2085  if (S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope))
2086  if (DeclContext *Entity = S->getEntity())
2087  if (Ctx == Entity->getPrimaryContext())
2088  return S;
2089  }
2090 
2091  return nullptr;
2092 }
2093 
2094 /// Enter a new function scope
2096  if (FunctionScopes.empty() && CachedFunctionScope) {
2097  // Use CachedFunctionScope to avoid allocating memory when possible.
2098  CachedFunctionScope->Clear();
2099  FunctionScopes.push_back(CachedFunctionScope.release());
2100  } else {
2102  }
2103  if (LangOpts.OpenMP)
2104  pushOpenMPFunctionRegion();
2105 }
2106 
2107 void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) {
2109  BlockScope, Block));
2110 }
2111 
2113  LambdaScopeInfo *const LSI = new LambdaScopeInfo(getDiagnostics());
2114  FunctionScopes.push_back(LSI);
2115  return LSI;
2116 }
2117 
2119  if (LambdaScopeInfo *const LSI = getCurLambda()) {
2120  LSI->AutoTemplateParameterDepth = Depth;
2121  return;
2122  }
2123  llvm_unreachable(
2124  "Remove assertion if intentionally called in a non-lambda context.");
2125 }
2126 
2127 // Check that the type of the VarDecl has an accessible copy constructor and
2128 // resolve its destructor's exception specification.
2129 // This also performs initialization of block variables when they are moved
2130 // to the heap. It uses the same rules as applicable for implicit moves
2131 // according to the C++ standard in effect ([class.copy.elision]p3).
2132 static void checkEscapingByref(VarDecl *VD, Sema &S) {
2133  QualType T = VD->getType();
2136  SourceLocation Loc = VD->getLocation();
2137  Expr *VarRef =
2138  new (S.Context) DeclRefExpr(S.Context, VD, false, T, VK_LValue, Loc);
2139  ExprResult Result;
2140  auto IE = InitializedEntity::InitializeBlock(Loc, T);
2141  if (S.getLangOpts().CPlusPlus2b) {
2142  auto *E = ImplicitCastExpr::Create(S.Context, T, CK_NoOp, VarRef, nullptr,
2144  Result = S.PerformCopyInitialization(IE, SourceLocation(), E);
2145  } else {
2148  VarRef);
2149  }
2150 
2151  if (!Result.isInvalid()) {
2152  Result = S.MaybeCreateExprWithCleanups(Result);
2153  Expr *Init = Result.getAs<Expr>();
2154  S.Context.setBlockVarCopyInit(VD, Init, S.canThrow(Init));
2155  }
2156 
2157  // The destructor's exception specification is needed when IRGen generates
2158  // block copy/destroy functions. Resolve it here.
2159  if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
2160  if (CXXDestructorDecl *DD = RD->getDestructor()) {
2161  auto *FPT = DD->getType()->getAs<FunctionProtoType>();
2162  S.ResolveExceptionSpec(Loc, FPT);
2163  }
2164 }
2165 
2166 static void markEscapingByrefs(const FunctionScopeInfo &FSI, Sema &S) {
2167  // Set the EscapingByref flag of __block variables captured by
2168  // escaping blocks.
2169  for (const BlockDecl *BD : FSI.Blocks) {
2170  for (const BlockDecl::Capture &BC : BD->captures()) {
2171  VarDecl *VD = BC.getVariable();
2172  if (VD->hasAttr<BlocksAttr>()) {
2173  // Nothing to do if this is a __block variable captured by a
2174  // non-escaping block.
2175  if (BD->doesNotEscape())
2176  continue;
2177  VD->setEscapingByref();
2178  }
2179  // Check whether the captured variable is or contains an object of
2180  // non-trivial C union type.
2181  QualType CapType = BC.getVariable()->getType();
2184  S.checkNonTrivialCUnion(BC.getVariable()->getType(),
2185  BD->getCaretLocation(),
2188  }
2189  }
2190 
2191  for (VarDecl *VD : FSI.ByrefBlockVars) {
2192  // __block variables might require us to capture a copy-initializer.
2193  if (!VD->isEscapingByref())
2194  continue;
2195  // It's currently invalid to ever have a __block variable with an
2196  // array type; should we diagnose that here?
2197  // Regardless, we don't want to ignore array nesting when
2198  // constructing this copy.
2199  if (VD->getType()->isStructureOrClassType())
2200  checkEscapingByref(VD, S);
2201  }
2202 }
2203 
2204 /// Pop a function (or block or lambda or captured region) scope from the stack.
2205 ///
2206 /// \param WP The warning policy to use for CFG-based warnings, or null if such
2207 /// warnings should not be produced.
2208 /// \param D The declaration corresponding to this function scope, if producing
2209 /// CFG-based warnings.
2210 /// \param BlockType The type of the block expression, if D is a BlockDecl.
2213  const Decl *D, QualType BlockType) {
2214  assert(!FunctionScopes.empty() && "mismatched push/pop!");
2215 
2216  markEscapingByrefs(*FunctionScopes.back(), *this);
2217 
2220 
2221  if (LangOpts.OpenMP)
2222  popOpenMPFunctionRegion(Scope.get());
2223 
2224  // Issue any analysis-based warnings.
2225  if (WP && D)
2226  AnalysisWarnings.IssueWarnings(*WP, Scope.get(), D, BlockType);
2227  else
2228  for (const auto &PUD : Scope->PossiblyUnreachableDiags)
2229  Diag(PUD.Loc, PUD.PD);
2230 
2231  return Scope;
2232 }
2233 
2236  // Stash the function scope for later reuse if it's for a normal function.
2237  if (Scope->isPlainFunction() && !Self->CachedFunctionScope)
2238  Self->CachedFunctionScope.reset(Scope);
2239  else
2240  delete Scope;
2241 }
2242 
2243 void Sema::PushCompoundScope(bool IsStmtExpr) {
2244  getCurFunction()->CompoundScopes.push_back(
2245  CompoundScopeInfo(IsStmtExpr, getCurFPFeatures()));
2246 }
2247 
2249  FunctionScopeInfo *CurFunction = getCurFunction();
2250  assert(!CurFunction->CompoundScopes.empty() && "mismatched push/pop");
2251 
2252  CurFunction->CompoundScopes.pop_back();
2253 }
2254 
2255 /// Determine whether any errors occurred within this function/method/
2256 /// block.
2259 }
2260 
2262  if (!FunctionScopes.empty())
2263  FunctionScopes.back()->setHasBranchIntoScope();
2264 }
2265 
2267  if (!FunctionScopes.empty())
2268  FunctionScopes.back()->setHasBranchProtectedScope();
2269 }
2270 
2272  if (!FunctionScopes.empty())
2273  FunctionScopes.back()->setHasIndirectGoto();
2274 }
2275 
2277  if (!FunctionScopes.empty())
2278  FunctionScopes.back()->setHasMustTail();
2279 }
2280 
2282  if (FunctionScopes.empty())
2283  return nullptr;
2284 
2285  auto CurBSI = dyn_cast<BlockScopeInfo>(FunctionScopes.back());
2286  if (CurBSI && CurBSI->TheDecl &&
2287  !CurBSI->TheDecl->Encloses(CurContext)) {
2288  // We have switched contexts due to template instantiation.
2289  assert(!CodeSynthesisContexts.empty());
2290  return nullptr;
2291  }
2292 
2293  return CurBSI;
2294 }
2295 
2297  if (FunctionScopes.empty())
2298  return nullptr;
2299 
2300  for (int e = FunctionScopes.size() - 1; e >= 0; --e) {
2301  if (isa<sema::BlockScopeInfo>(FunctionScopes[e]))
2302  continue;
2303  return FunctionScopes[e];
2304  }
2305  return nullptr;
2306 }
2307 
2309  for (auto *Scope : llvm::reverse(FunctionScopes)) {
2310  if (auto *LSI = dyn_cast<sema::LambdaScopeInfo>(Scope)) {
2311  if (LSI->Lambda && !LSI->Lambda->Encloses(CurContext)) {
2312  // We have switched contexts due to template instantiation.
2313  // FIXME: We should swap out the FunctionScopes during code synthesis
2314  // so that we don't need to check for this.
2315  assert(!CodeSynthesisContexts.empty());
2316  return nullptr;
2317  }
2318  return LSI;
2319  }
2320  }
2321  return nullptr;
2322 }
2323 
2324 LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) {
2325  if (FunctionScopes.empty())
2326  return nullptr;
2327 
2328  auto I = FunctionScopes.rbegin();
2329  if (IgnoreNonLambdaCapturingScope) {
2330  auto E = FunctionScopes.rend();
2331  while (I != E && isa<CapturingScopeInfo>(*I) && !isa<LambdaScopeInfo>(*I))
2332  ++I;
2333  if (I == E)
2334  return nullptr;
2335  }
2336  auto *CurLSI = dyn_cast<LambdaScopeInfo>(*I);
2337  if (CurLSI && CurLSI->Lambda &&
2338  !CurLSI->Lambda->Encloses(CurContext)) {
2339  // We have switched contexts due to template instantiation.
2340  assert(!CodeSynthesisContexts.empty());
2341  return nullptr;
2342  }
2343 
2344  return CurLSI;
2345 }
2346 
2347 // We have a generic lambda if we parsed auto parameters, or we have
2348 // an associated template parameter list.
2350  if (LambdaScopeInfo *LSI = getCurLambda()) {
2351  return (LSI->TemplateParams.size() ||
2352  LSI->GLTemplateParameterList) ? LSI : nullptr;
2353  }
2354  return nullptr;
2355 }
2356 
2357 
2359  if (!LangOpts.RetainCommentsFromSystemHeaders &&
2360  SourceMgr.isInSystemHeader(Comment.getBegin()))
2361  return;
2362  RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false);
2363  if (RC.isAlmostTrailingComment()) {
2364  SourceRange MagicMarkerRange(Comment.getBegin(),
2365  Comment.getBegin().getLocWithOffset(3));
2366  StringRef MagicMarkerText;
2367  switch (RC.getKind()) {
2369  MagicMarkerText = "///<";
2370  break;
2372  MagicMarkerText = "/**<";
2373  break;
2374  default:
2375  llvm_unreachable("if this is an almost Doxygen comment, "
2376  "it should be ordinary");
2377  }
2378  Diag(Comment.getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
2379  FixItHint::CreateReplacement(MagicMarkerRange, MagicMarkerText);
2380  }
2381  Context.addComment(RC);
2382 }
2383 
2384 // Pin this vtable to this file.
2386 char ExternalSemaSource::ID;
2387 
2390 
2392  SmallVectorImpl<NamespaceDecl *> &Namespaces) {
2393 }
2394 
2396  llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {}
2397 
2399  FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &) {}
2400 
2401 /// Figure out if an expression could be turned into a call.
2402 ///
2403 /// Use this when trying to recover from an error where the programmer may have
2404 /// written just the name of a function instead of actually calling it.
2405 ///
2406 /// \param E - The expression to examine.
2407 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
2408 /// with no arguments, this parameter is set to the type returned by such a
2409 /// call; otherwise, it is set to an empty QualType.
2410 /// \param OverloadSet - If the expression is an overloaded function
2411 /// name, this parameter is populated with the decls of the various overloads.
2412 bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
2413  UnresolvedSetImpl &OverloadSet) {
2414  ZeroArgCallReturnTy = QualType();
2415  OverloadSet.clear();
2416 
2417  const OverloadExpr *Overloads = nullptr;
2418  bool IsMemExpr = false;
2419  if (E.getType() == Context.OverloadTy) {
2420  OverloadExpr::FindResult FR = OverloadExpr::find(const_cast<Expr*>(&E));
2421 
2422  // Ignore overloads that are pointer-to-member constants.
2423  if (FR.HasFormOfMemberPointer)
2424  return false;
2425 
2426  Overloads = FR.Expression;
2427  } else if (E.getType() == Context.BoundMemberTy) {
2428  Overloads = dyn_cast<UnresolvedMemberExpr>(E.IgnoreParens());
2429  IsMemExpr = true;
2430  }
2431 
2432  bool Ambiguous = false;
2433  bool IsMV = false;
2434 
2435  if (Overloads) {
2436  for (OverloadExpr::decls_iterator it = Overloads->decls_begin(),
2437  DeclsEnd = Overloads->decls_end(); it != DeclsEnd; ++it) {
2438  OverloadSet.addDecl(*it);
2439 
2440  // Check whether the function is a non-template, non-member which takes no
2441  // arguments.
2442  if (IsMemExpr)
2443  continue;
2444  if (const FunctionDecl *OverloadDecl
2445  = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
2446  if (OverloadDecl->getMinRequiredArguments() == 0) {
2447  if (!ZeroArgCallReturnTy.isNull() && !Ambiguous &&
2448  (!IsMV || !(OverloadDecl->isCPUDispatchMultiVersion() ||
2449  OverloadDecl->isCPUSpecificMultiVersion()))) {
2450  ZeroArgCallReturnTy = QualType();
2451  Ambiguous = true;
2452  } else {
2453  ZeroArgCallReturnTy = OverloadDecl->getReturnType();
2454  IsMV = OverloadDecl->isCPUDispatchMultiVersion() ||
2455  OverloadDecl->isCPUSpecificMultiVersion();
2456  }
2457  }
2458  }
2459  }
2460 
2461  // If it's not a member, use better machinery to try to resolve the call
2462  if (!IsMemExpr)
2463  return !ZeroArgCallReturnTy.isNull();
2464  }
2465 
2466  // Attempt to call the member with no arguments - this will correctly handle
2467  // member templates with defaults/deduction of template arguments, overloads
2468  // with default arguments, etc.
2469  if (IsMemExpr && !E.isTypeDependent()) {
2470  Sema::TentativeAnalysisScope Trap(*this);
2472  None, SourceLocation());
2473  if (R.isUsable()) {
2474  ZeroArgCallReturnTy = R.get()->getType();
2475  return true;
2476  }
2477  return false;
2478  }
2479 
2480  if (const DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E.IgnoreParens())) {
2481  if (const FunctionDecl *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) {
2482  if (Fun->getMinRequiredArguments() == 0)
2483  ZeroArgCallReturnTy = Fun->getReturnType();
2484  return true;
2485  }
2486  }
2487 
2488  // We don't have an expression that's convenient to get a FunctionDecl from,
2489  // but we can at least check if the type is "function of 0 arguments".
2490  QualType ExprTy = E.getType();
2491  const FunctionType *FunTy = nullptr;
2492  QualType PointeeTy = ExprTy->getPointeeType();
2493  if (!PointeeTy.isNull())
2494  FunTy = PointeeTy->getAs<FunctionType>();
2495  if (!FunTy)
2496  FunTy = ExprTy->getAs<FunctionType>();
2497 
2498  if (const FunctionProtoType *FPT =
2499  dyn_cast_or_null<FunctionProtoType>(FunTy)) {
2500  if (FPT->getNumParams() == 0)
2501  ZeroArgCallReturnTy = FunTy->getReturnType();
2502  return true;
2503  }
2504  return false;
2505 }
2506 
2507 /// Give notes for a set of overloads.
2508 ///
2509 /// A companion to tryExprAsCall. In cases when the name that the programmer
2510 /// wrote was an overloaded function, we may be able to make some guesses about
2511 /// plausible overloads based on their return types; such guesses can be handed
2512 /// off to this method to be emitted as notes.
2513 ///
2514 /// \param Overloads - The overloads to note.
2515 /// \param FinalNoteLoc - If we've suppressed printing some overloads due to
2516 /// -fshow-overloads=best, this is the location to attach to the note about too
2517 /// many candidates. Typically this will be the location of the original
2518 /// ill-formed expression.
2519 static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads,
2520  const SourceLocation FinalNoteLoc) {
2521  unsigned ShownOverloads = 0;
2522  unsigned SuppressedOverloads = 0;
2523  for (UnresolvedSetImpl::iterator It = Overloads.begin(),
2524  DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
2525  if (ShownOverloads >= S.Diags.getNumOverloadCandidatesToShow()) {
2526  ++SuppressedOverloads;
2527  continue;
2528  }
2529 
2530  NamedDecl *Fn = (*It)->getUnderlyingDecl();
2531  // Don't print overloads for non-default multiversioned functions.
2532  if (const auto *FD = Fn->getAsFunction()) {
2533  if (FD->isMultiVersion() && FD->hasAttr<TargetAttr>() &&
2534  !FD->getAttr<TargetAttr>()->isDefaultVersion())
2535  continue;
2536  }
2537  S.Diag(Fn->getLocation(), diag::note_possible_target_of_call);
2538  ++ShownOverloads;
2539  }
2540 
2541  S.Diags.overloadCandidatesShown(ShownOverloads);
2542 
2543  if (SuppressedOverloads)
2544  S.Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates)
2545  << SuppressedOverloads;
2546 }
2547 
2549  const UnresolvedSetImpl &Overloads,
2550  bool (*IsPlausibleResult)(QualType)) {
2551  if (!IsPlausibleResult)
2552  return noteOverloads(S, Overloads, Loc);
2553 
2554  UnresolvedSet<2> PlausibleOverloads;
2555  for (OverloadExpr::decls_iterator It = Overloads.begin(),
2556  DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
2557  const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*It);
2558  QualType OverloadResultTy = OverloadDecl->getReturnType();
2559  if (IsPlausibleResult(OverloadResultTy))
2560  PlausibleOverloads.addDecl(It.getDecl());
2561  }
2562  noteOverloads(S, PlausibleOverloads, Loc);
2563 }
2564 
2565 /// Determine whether the given expression can be called by just
2566 /// putting parentheses after it. Notably, expressions with unary
2567 /// operators can't be because the unary operator will start parsing
2568 /// outside the call.
2569 static bool IsCallableWithAppend(Expr *E) {
2570  E = E->IgnoreImplicit();
2571  return (!isa<CStyleCastExpr>(E) &&
2572  !isa<UnaryOperator>(E) &&
2573  !isa<BinaryOperator>(E) &&
2574  !isa<CXXOperatorCallExpr>(E));
2575 }
2576 
2578  if (const auto *UO = dyn_cast<UnaryOperator>(E))
2579  E = UO->getSubExpr();
2580 
2581  if (const auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
2582  if (ULE->getNumDecls() == 0)
2583  return false;
2584 
2585  const NamedDecl *ND = *ULE->decls_begin();
2586  if (const auto *FD = dyn_cast<FunctionDecl>(ND))
2588  }
2589  return false;
2590 }
2591 
2593  bool ForceComplain,
2594  bool (*IsPlausibleResult)(QualType)) {
2595  SourceLocation Loc = E.get()->getExprLoc();
2596  SourceRange Range = E.get()->getSourceRange();
2597  UnresolvedSet<4> Overloads;
2598 
2599  // If this is a SFINAE context, don't try anything that might trigger ADL
2600  // prematurely.
2601  if (!isSFINAEContext()) {
2602  QualType ZeroArgCallTy;
2603  if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
2604  !ZeroArgCallTy.isNull() &&
2605  (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
2606  // At this point, we know E is potentially callable with 0
2607  // arguments and that it returns something of a reasonable type,
2608  // so we can emit a fixit and carry on pretending that E was
2609  // actually a CallExpr.
2610  SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
2611  bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
2612  Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range
2613  << (IsCallableWithAppend(E.get())
2614  ? FixItHint::CreateInsertion(ParenInsertionLoc,
2615  "()")
2616  : FixItHint());
2617  if (!IsMV)
2618  notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
2619 
2620  // FIXME: Try this before emitting the fixit, and suppress diagnostics
2621  // while doing so.
2622  E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None,
2623  Range.getEnd().getLocWithOffset(1));
2624  return true;
2625  }
2626  }
2627  if (!ForceComplain) return false;
2628 
2629  bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
2630  Diag(Loc, PD) << /*not zero-arg*/ 0 << IsMV << Range;
2631  if (!IsMV)
2632  notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
2633  E = ExprError();
2634  return true;
2635 }
2636 
2638  if (!Ident_super)
2639  Ident_super = &Context.Idents.get("super");
2640  return Ident_super;
2641 }
2642 
2644  if (!Ident___float128)
2645  Ident___float128 = &Context.Idents.get("__float128");
2646  return Ident___float128;
2647 }
2648 
2651  unsigned OpenMPCaptureLevel) {
2652  auto *CSI = new CapturedRegionScopeInfo(
2653  getDiagnostics(), S, CD, RD, CD->getContextParam(), K,
2654  (getLangOpts().OpenMP && K == CR_OpenMP) ? getOpenMPNestingLevel() : 0,
2655  OpenMPCaptureLevel);
2656  CSI->ReturnType = Context.VoidTy;
2657  FunctionScopes.push_back(CSI);
2658 }
2659 
2661  if (FunctionScopes.empty())
2662  return nullptr;
2663 
2664  return dyn_cast<CapturedRegionScopeInfo>(FunctionScopes.back());
2665 }
2666 
2667 const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
2669  return DeleteExprs;
2670 }
2671 
2673  : S(S), OldFPFeaturesState(S.CurFPFeatures),
2674  OldOverrides(S.FpPragmaStack.CurrentValue),
2675  OldEvalMethod(S.PP.getCurrentFPEvalMethod()),
2676  OldFPPragmaLocation(S.PP.getLastFPEvalPragmaLocation()) {}
2677 
2679  S.CurFPFeatures = OldFPFeaturesState;
2680  S.FpPragmaStack.CurrentValue = OldOverrides;
2681  S.PP.setCurrentFPEvalMethod(OldFPPragmaLocation, OldEvalMethod);
2682 }
2683 
2685  assert(D.getCXXScopeSpec().isSet() &&
2686  "can only be called for qualified names");
2687 
2688  auto LR = LookupResult(*this, D.getIdentifier(), D.getBeginLoc(),
2692  if (!DC)
2693  return false;
2694 
2695  LookupQualifiedName(LR, DC);
2696  bool Result = std::all_of(LR.begin(), LR.end(), [](Decl *Dcl) {
2697  if (NamedDecl *ND = dyn_cast<NamedDecl>(Dcl)) {
2698  ND = ND->getUnderlyingDecl();
2699  return isa<FunctionDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
2700  isa<UsingDecl>(ND);
2701  }
2702  return false;
2703  });
2704  return Result;
2705 }
clang::OpenCL
@ OpenCL
Definition: LangStandard.h:62
clang::ASTContext::getBuiltinVaListDecl
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
Definition: ASTContext.cpp:9084
clang::Type::STK_FixedPoint
@ STK_FixedPoint
Definition: Type.h:2281
clang::Sema::hasAnyUnrecoverableErrorsInThisFunction
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:2257
clang::Language::CUDA
@ CUDA
RecordCompleteMap
llvm::DenseMap< const CXXRecordDecl *, bool > RecordCompleteMap
Definition: Sema.cpp:920
clang::Sema::CheckDelayedMemberExceptionSpecs
void CheckDelayedMemberExceptionSpecs()
Definition: SemaDeclCXX.cpp:8882
clang::DiagnosticIDs::isDeferrable
static bool isDeferrable(unsigned DiagID)
Whether the diagnostic message can be deferred.
Definition: DiagnosticIDs.cpp:341
clang::ASTContext::OCLEventTy
CanQualType OCLEventTy
Definition: ASTContext.h:1143
clang::ASTContext::LongDoubleTy
CanQualType LongDoubleTy
Definition: ASTContext.h:1119
clang::Sema::CurContext
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:421
clang::Type::getNullability
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
Definition: Type.cpp:4128
clang::ModuleMap::resolveConflicts
bool resolveConflicts(Module *Mod, bool Complain)
Resolve all of the unresolved conflicts in the given module.
Definition: ModuleMap.cpp:1355
clang::Sema::getUndefinedButUsed
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
Definition: Sema.cpp:793
clang::Sema::setFunctionHasIndirectGoto
void setFunctionHasIndirectGoto()
Definition: Sema.cpp:2271
clang::Sema::VAListTagName
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:429
clang::Sema::warnStackExhausted
void warnStackExhausted(SourceLocation Loc)
Warn that the stack is nearly exhausted.
Definition: Sema.cpp:494
clang::Sema::ActOnGlobalModuleFragmentDecl
DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc)
The parser has processed a global-module-fragment declaration that begins the definition of the globa...
Definition: SemaModule.cpp:75
clang::Sema::DelayedDiagnostics
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition: Sema.h:942
clang::DeclContext::decls_end
decl_iterator decls_end() const
Definition: DeclBase.h:2180
clang::ExternalSemaSource::updateOutOfDateSelector
virtual void updateOutOfDateSelector(Selector Sel)
Load the contents of the global method pool for a given selector if necessary.
Definition: Sema.cpp:2389
clang::Preprocessor::getCurrentFPEvalMethod
LangOptions::FPEvalMethodKind getCurrentFPEvalMethod() const
Definition: Preprocessor.h:2191
clang::ModuleMap::resolveUses
bool resolveUses(Module *Mod, bool Complain)
Resolve all of the unresolved uses in the given module.
Definition: ModuleMap.cpp:1342
clang::Sema::ScalarTypeToBooleanCastKind
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition: Sema.cpp:696
clang::LangOptions::CMK_ModuleInterface
@ CMK_ModuleInterface
Compiling a C++ modules interface unit.
Definition: LangOptions.h:117
clang::Sema::runWithSufficientStackSpace
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
Definition: Sema.cpp:502
clang::QualType::hasNonTrivialToPrimitiveCopyCUnion
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
Definition: Type.h:6830
clang::ASTContext::getInt128Decl
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
Definition: ASTContext.cpp:1262
clang::Sema::PopCompoundScope
void PopCompoundScope()
Definition: Sema.cpp:2248
clang::DiagnosticsEngine::SetArgToStringFn
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie)
Definition: Diagnostic.h:884
clang::VarDecl::isFileVarDecl
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
Definition: Decl.h:1262
clang::interp::APInt
llvm::APInt APInt
Definition: Integral.h:27
clang::Sema::isExternalWithNoLinkageType
bool isExternalWithNoLinkageType(ValueDecl *VD)
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
Definition: Sema.cpp:782
clang::Sema::DelayedDllExportMemberFunctions
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition: Sema.h:13565
clang::DiagnosticBuilder
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1266
clang::ASTContext::OCLReserveIDTy
CanQualType OCLReserveIDTy
Definition: ASTContext.h:1144
clang::Sema::TUKind
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
Definition: Sema.h:1444
clang::Sema::DeferDiags
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition: Sema.h:1863
clang::FunctionDecl::getReturnType
QualType getReturnType() const
Definition: Decl.h:2598
clang::UnresolvedSetImpl
A set of unresolved declarations.
Definition: UnresolvedSet.h:61
clang::LangOptions::getOpenCLCompatibleVersion
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Definition: LangOptions.cpp:55
clang::UsedDeclVisitor
Definition: UsedDeclVisitor.h:21
clang::ASTContext::buildImplicitRecord
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=TTK_Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
Definition: ASTContext.cpp:1236
clang::ExternalSemaSource::ReadKnownNamespaces
virtual void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl * > &Namespaces)
Load the set of namespaces that are known to the external source, which will be used during typo corr...
Definition: Sema.cpp:2391
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::Sema::ActOnEndOfTranslationUnit
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition: Sema.cpp:1100
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:560
clang::TypoCorrection
Simple class containing the result of Sema::CorrectTypo.
Definition: TypoCorrection.h:42
clang::Type::isFloat16Type
bool isFloat16Type() const
Definition: Type.h:7234
clang::LazyVector::erase
void erase(iterator From, iterator To)
Definition: ExternalASTSource.h:553
clang::Preprocessor::isIncrementalProcessingEnabled
bool isIncrementalProcessingEnabled() const
Returns true if incremental processing is enabled.
Definition: Preprocessor.h:1788
clang::FixItHint::CreateInsertion
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Definition: Diagnostic.h:97
clang::ExpectedVariableOrFunction
@ ExpectedVariableOrFunction
Definition: ParsedAttr.h:1144
clang::Sema::getASTContext
ASTContext & getASTContext() const
Definition: Sema.h:1637
clang::Sema::FreeVisContext
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
Definition: SemaAttr.cpp:1258
clang::QualType::isConstQualified
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition: Type.h:6747
clang::Sema::getCurFunction
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:1962
clang::Decl::getAsFunction
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Definition: DeclBase.cpp:227
clang::Sema::SemaDiagnosticBuilder::Kind
Kind
Definition: Sema.h:1747
clang::Type::STK_IntegralComplex
@ STK_IntegralComplex
Definition: Type.h:2279
clang::Sema::SourceMgr
SourceManager & SourceMgr
Definition: Sema.h:412
clang::sema::SemaPPCallbacks::FileChanged
void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID) override
Callback invoked whenever a source file is entered or exited.
Definition: Sema.cpp:142
clang::IdentifierResolver::begin
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
Definition: IdentifierResolver.cpp:236
clang::sema::AnalysisBasedWarnings::PrintStats
void PrintStats() const
Definition: AnalysisBasedWarnings.cpp:2454
Diag
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Definition: LiteralSupport.cpp:79
clang::Sema::ThreadSafetyDeclCache
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition: Sema.h:9634
clang::SourceManager::isInMainFile
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
Definition: SourceManager.cpp:1592
clang::FunctionDecl::isDeleted
bool isDeleted() const
Whether this function has been deleted.
Definition: Decl.h:2382
clang::NamedDecl::isExternallyVisible
bool isExternallyVisible() const
Definition: Decl.h:405
SemaInternal.h
clang::sema::FunctionScopeInfo::ByrefBlockVars
llvm::TinyPtrVector< VarDecl * > ByrefBlockVars
The set of __block variables that are introduced in this function.
Definition: ScopeInfo.h:225
clang::Sema::forRedeclarationInCurContext
RedeclarationKind forRedeclarationInCurContext()
Definition: Sema.h:4293
clang::ASTContext::VoidTy
CanQualType VoidTy
Definition: ASTContext.h:1107
clang::Expr::IgnoreImplicit
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:3012
llvm::SmallVector
Definition: LLVM.h:38
clang::ASTContext::getAtomicType
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
Definition: ASTContext.cpp:5835
clang::IdentifierTable::get
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Definition: IdentifierTable.h:597
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::Sema::FunctionScopes
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:799
clang::Preprocessor::TUKind
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
Definition: Preprocessor.h:291
clang::DiagnosticsEngine::isIgnored
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Definition: Diagnostic.h:911
clang::Sema::AnalysisWarnings
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:9633
clang::SourceLocation::getLocWithOffset
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
Definition: SourceLocation.h:134
clang::PPCallbacks
This interface provides a way to observe the actions of the preprocessor as it does its thing.
Definition: PPCallbacks.h:35
clang::Type::STK_FloatingComplex
@ STK_FloatingComplex
Definition: Type.h:2280
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::DeclContext::getPrimaryContext
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1263
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::Sema::getEnclosingFunction
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition: Sema.cpp:2296
clang::CXXRecordDecl::friend_begin
friend_iterator friend_begin() const
Definition: DeclFriend.h:239
TargetInfo.h
clang::NamedDecl::getUnderlyingDecl
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:457
clang::Sema::DiagnoseUnterminatedPragmaAttribute
void DiagnoseUnterminatedPragmaAttribute()
Definition: SemaAttr.cpp:1152
clang::Sema::findMacroSpelling
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
Definition: Sema.cpp:2048
isFunctionOrVarDeclExternC
static bool isFunctionOrVarDeclExternC(NamedDecl *ND)
Definition: Sema.cpp:774
clang::Sema::FpPragmaStack
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:698
clang::ASTContext::getObjCClassDecl
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
Definition: ASTContext.cpp:8675
clang::Stmt::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:324
clang::TargetInfo::hasLongDoubleType
virtual bool hasLongDoubleType() const
Determine whether the long double type is supported on this target.
Definition: TargetInfo.h:655
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::Sema::LateTemplateParserCleanup
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:920
clang::Module::submodule_begin
submodule_iterator submodule_begin()
Definition: Module.h:707
clang::Declarator::getIdentifier
IdentifierInfo * getIdentifier() const
Definition: DeclSpec.h:2251
clang::ExternalSemaSource::ReadMismatchingDeleteExpressions
virtual void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &)
Definition: Sema.cpp:2398
clang::ASTContext::getFloatTypeSemantics
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
Definition: ASTContext.cpp:1704
clang::UnresolvedSetIterator
The iterator over UnresolvedSets.
Definition: UnresolvedSet.h:32
clang::QualType::getCanonicalType
QualType getCanonicalType() const
Definition: Type.h:6727
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2903
clang::LookupResult
Represents the results of name lookup.
Definition: Lookup.h:46
TypoCorrection.h
clang::Sema::Diag
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: Sema.cpp:1881
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:205
clang::Sema::TUScope
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Definition: Sema.h:1127
clang::Sema::CreateMaterializeTemporaryExpr
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
Definition: SemaInit.cpp:7994
DeclCXX.h
clang::VK_XValue
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
Definition: Specifiers.h:132
clang::ASTContext::getAuxTargetInfo
const TargetInfo * getAuxTargetInfo() const
Definition: ASTContext.h:774
clang::Decl::isUsed
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
Definition: DeclBase.cpp:458
clang::ASTContext::addComment
void addComment(const RawComment &RC)
Definition: ASTContext.cpp:311
clang::DiagnosticsEngine::getNumOverloadCandidatesToShow
unsigned getNumOverloadCandidatesToShow() const
When a call or operator fails, print out up to this many candidate overloads as suggestions.
Definition: Diagnostic.h:726
clang::Sema::CodeSynthesisContexts
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition: Sema.h:9231
clang::TargetInfo::hasFloat16Type
virtual bool hasFloat16Type() const
Determine whether the _Float16 type is supported on this target.
Definition: TargetInfo.h:646
clang::RawComment::getKind
CommentKind getKind() const LLVM_READONLY
Definition: RawCommentList.h:50
clang::Sema::getSourceManager
SourceManager & getSourceManager() const
Definition: Sema.h:1635
clang::Sema::LateParsedInstantiations
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition: Sema.h:9652
clang::DeclSpec::isFriendSpecified
FriendSpecified isFriendSpecified() const
Definition: DeclSpec.h:768
clang::Type::isRealFloatingType
bool isRealFloatingType() const
Floating point categories.
Definition: Type.cpp:2137
clang::Sema::LookupQualifiedName
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Definition: SemaLookup.cpp:2405
clang::CapturedRegionKind
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:16
clang::ASTContext::OverloadTy
CanQualType OverloadTy
Definition: ASTContext.h:1135
clang::Sema::CachedFunctionScope
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:795
clang::Sema::setFunctionHasMustTail
void setFunctionHasMustTail()
Definition: Sema.cpp:2276
llvm::Optional
Definition: LLVM.h:40
llvm::SmallPtrSet
Definition: ASTContext.h:82
clang::Expr::isPRValue
bool isPRValue() const
Definition: Expr.h:271
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
SourceManager.h
clang::DiagnosticsEngine::setLastDiagnosticIgnored
void setLastDiagnosticIgnored(bool Ignored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed,...
Definition: Diagnostic.h:756
clang::TypePropertyCache
The type-property cache.
Definition: Type.cpp:3872
emitCallStackNotes
static void emitCallStackNotes(Sema &S, FunctionDecl *FD)
Definition: Sema.cpp:1607
clang::SrcMgr::CharacteristicKind
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Definition: SourceManager.h:79
clang::Sema::BuildCallExpr
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
Definition: SemaExpr.cpp:6640
IsRecordFullyDefined
static bool IsRecordFullyDefined(const CXXRecordDecl *RD, RecordCompleteMap &RecordsComplete, RecordCompleteMap &MNCComplete)
Returns true, if the given CXXRecordDecl is fully defined in this translation unit,...
Definition: Sema.cpp:969
clang::Decl::getAttr
T * getAttr() const
Definition: DeclBase.h:556
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::Sema::BuildCallToMemberFunction
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
Definition: SemaOverload.cpp:14427
clang::DiagnosticIDs::isBuiltinNote
static bool isBuiltinNote(unsigned DiagID)
Determine whether the given built-in diagnostic ID is a Note.
Definition: DiagnosticIDs.cpp:434
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3672
clang::Sema::ExprEvalContexts
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:1378
clang::CapturedDecl
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4443
clang::sema::BlockScopeInfo
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:752
clang::Sema::getCurCapturedRegion
sema::CapturedRegionScopeInfo * getCurCapturedRegion()
Retrieve the current captured region, if any.
Definition: Sema.cpp:2660
clang::CXXFieldCollector
CXXFieldCollector - Used to keep track of CXXFieldDecls during parsing of C++ classes.
Definition: CXXFieldCollector.h:25
clang::Sema::ActOnEndOfTranslationUnitFragment
void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind)
Definition: Sema.cpp:1032
clang::TargetInfo::hasInt128Type
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
Definition: TargetInfo.h:606
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
clang::ASTContext::getSourceManager
SourceManager & getSourceManager()
Definition: ASTContext.h:721
clang::Sema::PendingInstantiations
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition: Sema.h:9648
clang::Sema::ExternalDeclarations
SmallVector< VarDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
Definition: Sema.h:879
clang::ASTContext::getTranslationUnitDecl
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1089
clang::OverloadExpr::decls_end
decls_iterator decls_end() const
Definition: ExprCXX.h:2992
clang::ArrayType::Normal
@ Normal
Definition: Type.h:3016
clang::Decl::isReferenced
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:483
clang::sema::CapturedRegionScopeInfo
Retains information about a captured region.
Definition: ScopeInfo.h:778
clang::Sema::isDeclaratorFunctionLike
bool isDeclaratorFunctionLike(Declarator &D)
Determine whether.
Definition: Sema.cpp:2684
clang::Sema::isUnevaluatedContext
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
Definition: Sema.h:9542
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:627
clang::Type::STK_Integral
@ STK_Integral
Definition: Type.h:2277
clang::Sema::ActOnTranslationUnitScope
void ActOnTranslationUnitScope(Scope *S)
Definition: Sema.cpp:125
clang::Preprocessor::getLangOpts
const LangOptions & getLangOpts() const
Definition: Preprocessor.h:1073
clang::Sema::Context
ASTContext & Context
Definition: Sema.h:409
Preprocessor.h
markEscapingByrefs
static void markEscapingByrefs(const FunctionScopeInfo &FSI, Sema &S)
Definition: Sema.cpp:2166
clang::Sema::FieldCollector
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Definition: Sema.h:837
clang::TU_Prefix
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:908
clang::ExprError
ExprResult ExprError()
Definition: Ownership.h:278
Decl.h
clang::OverloadExpr::find
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
Definition: ExprCXX.h:2957
clang::ExternalSemaSource::~ExternalSemaSource
~ExternalSemaSource() override
Definition: Sema.cpp:2385
DeclObjC.h
Offset
unsigned Offset
Definition: Format.cpp:2590
clang::ASTContext::getObjCSelDecl
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
Definition: ASTContext.cpp:8667
clang::Sema::WarnedStackExhausted
bool WarnedStackExhausted
Definition: Sema.h:1596
clang::CXXScopeSpec::isSet
bool isSet() const
Deprecated.
Definition: DeclSpec.h:211
checkEscapingByref
static void checkEscapingByref(VarDecl *VD, Sema &S)
Definition: Sema.cpp:2132
clang::Sema::CUDADiagIfDeviceCode
SemaDiagnosticBuilder CUDADiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
Definition: SemaCUDA.cpp:727
clang::FixItHint
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
Definition: Diagnostic.h:71
uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:24
clang::Diagnostic
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1561
clang::ASTContext::BoundMemberTy
CanQualType BoundMemberTy
Definition: ASTContext.h:1135
clang::Sema::getLangOpts
const LangOptions & getLangOpts() const
Definition: Sema.h:1630
clang::BlockDecl::captures
ArrayRef< Capture > captures() const
Definition: Decl.h:4381
clang::BlockDecl::doesNotEscape
bool doesNotEscape() const
Definition: Decl.h:4405
clang::Declarator::getDeclSpec
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:1969
clang::Sema::getSuperIdentifier
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:2637
clang::Sema::getCurLexicalContext
DeclContext * getCurLexicalContext() const
Definition: Sema.h:13533
clang::TargetInfo::getSupportedOpenCLOpts
llvm::StringMap< bool > & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
Definition: TargetInfo.h:1615
clang::OverloadExpr::FindResult
Definition: ExprCXX.h:2946
clang::Sema::getCurFunctionDecl
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false)
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
Definition: Sema.cpp:1461
clang::TU_Module
@ TU_Module
The translation unit is a module.
Definition: LangOptions.h:911
clang::TargetInfo::hasBitIntType
virtual bool hasBitIntType() const
Determine whether the _BitInt type is supported on this target.
Definition: TargetInfo.h:616
clang::isExternalFormalLinkage
bool isExternalFormalLinkage(Linkage L)
Definition: Linkage.h:108
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:991
clang::Sema::RequireCompleteType
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:8689
clang::ASTContext::getUIntPtrType
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
Definition: ASTContext.cpp:5930
clang::Type::STK_BlockPointer
@ STK_BlockPointer
Definition: Type.h:2273
clang::Sema::tryExprAsCall
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:2412
clang::ASTContext::getExternalSource
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Definition: ASTContext.h:1194
clang::ASTContext::getObjCIdDecl
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
Definition: ASTContext.cpp:8658
clang::Type::isBitIntType
bool isBitIntType() const
Definition: Type.h:7160
clang::Sema::getEnclosingLambda
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
Definition: Sema.cpp:2308
clang::Expr::isTypeDependent
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:185
clang::Sema::DelayedOverridingExceptionSpecChecks
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedOverridingExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
Definition: Sema.h:901
clang::SemaConsumer
An abstract interface that should be implemented by clients that read ASTs and then require further s...
Definition: SemaConsumer.h:25
clang::FunctionDecl::isCPUDispatchMultiVersion
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
Definition: Decl.cpp:3343
clang::sema::FunctionScopeInfo::Blocks
llvm::SmallPtrSet< const BlockDecl *, 1 > Blocks
The set of blocks that are introduced in this function.
Definition: ScopeInfo.h:222
clang::Module
Describes a module or submodule.
Definition: Module.h:98
clang::Sema::CurFPFeatures
FPOptions CurFPFeatures
Definition: Sema.h:405
clang::Sema::inTemplateInstantiation
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
Definition: Sema.h:9513
clang::OverloadExpr::decls_begin
decls_iterator decls_begin() const
Definition: ExprCXX.h:2989
clang::PartialDiagnosticAt
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
Definition: PartialDiagnostic.h:205
clang::Sema::TentativeDefinitions
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:876
clang::Sema::getDiagnostics
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:1634
clang::ASTContext::OCLSamplerTy
CanQualType OCLSamplerTy
Definition: ASTContext.h:1143
clang::Declarator::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclSpec.h:2005
HeaderSearchOptions.h
clang::Sema::CurFPFeatureOverrides
FPOptionsOverride CurFPFeatureOverrides()
Definition: Sema.h:699
Node
DynTypedNode Node
Definition: ASTMatchFinder.cpp:68
DeclFriend.h
clang::BlockDecl
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4254
clang::LangOptions::CMK_None
@ CMK_None
Not compiling a module interface at all.
Definition: LangOptions.h:105
clang::ASTContext::getAsIncompleteArrayType
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Definition: ASTContext.h:2726
clang::Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder
~SemaDiagnosticBuilder()
Definition: Sema.cpp:1849
clang::DiagnosticsEngine::hasFatalErrorOccurred
bool hasFatalErrorOccurred() const
Definition: Diagnostic.h:845
clang::Sema::DeviceDeferredDiags
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, std::vector< PartialDiagnosticAt > > DeviceDeferredDiags
Diagnostics that are emitted only if we discover that the given function must be codegen'ed.
Definition: Sema.h:12734
clang::Sema::SemaDiagnosticBuilder::isImmediate
bool isImmediate() const
Definition: Sema.h:1768
Id
int Id
Definition: ASTDiff.cpp:191
clang::Sema::hasUncompilableErrorOccurred
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
Definition: Sema.cpp:1589
clang::ASTContext::getUInt128Decl
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
Definition: ASTContext.cpp:1268
clang::Type::isNullPtrType
bool isNullPtrType() const
Definition: Type.h:7250
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
clang::Sema::SemaDiagnosticBuilder::K_Nop
@ K_Nop
Emit no diagnostics.
Definition: Sema.h:1749
PrettyDeclStackTrace.h
MultiplexExternalSemaSource.h
clang::Sema::VisContext
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:733
clang::sema::FunctionScopeInfo::hasUnrecoverableErrorOccurred
bool hasUnrecoverableErrorOccurred() const
Determine whether an unrecoverable error has occurred within this function.
Definition: ScopeInfo.h:399
clang::Sema::SemaDiagnosticBuilder::K_Immediate
@ K_Immediate
Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
Definition: Sema.h:1751
clang::DiagnosticsEngine::hasErrorOccurred
bool hasErrorOccurred() const
Definition: Diagnostic.h:838
clang::DiagnosticIDs::isDefaultMappingAsError
static bool isDefaultMappingAsError(unsigned DiagID)
Return true if the specified diagnostic is mapped to errors by default.
Definition: DiagnosticIDs.cpp:455
clang::FPOptionsOverride
Represents difference between two FPOptions values.
Definition: LangOptions.h:791
clang::Sema::AccessCheckingSFINAE
bool AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors.
Definition: Sema.h:7804
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::ASTContext::getSizeType
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Definition: ASTContext.cpp:5892
clang::SourceManager::getMainFileID
FileID getMainFileID() const
Returns the FileID of the main source file.
Definition: SourceManager.h:841
clang::CPlusPlus
@ CPlusPlus
Definition: LangStandard.h:53
CXXFieldCollector.h
clang::Sema::getCurFunctionOrMethodDecl
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
Definition: Sema.cpp:1473
clang::DiagnosticsEngine::Clear
void Clear()
Clear out the current diagnostic.
Definition: Diagnostic.h:977
clang::LazyVector::end
iterator end()
Definition: ExternalASTSource.h:545
clang::DiagnosticsEngine::EmitCurrentDiagnostic
bool EmitCurrentDiagnostic(bool Force=false)
Emit the current diagnostic and clear the diagnostic state.
Definition: Diagnostic.cpp:530
clang::FunctionDecl::getBody
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:3099
Depth
int Depth
Definition: ASTDiff.cpp:191
clang::FunctionDecl::isCPUSpecificMultiVersion
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
Definition: Decl.cpp:3347
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7431
clang::Decl::isInvalidDecl
bool isInvalidDecl() const
Definition: DeclBase.h:571
clang::ASTConsumer
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition: ASTConsumer.h:33
clang::Sema::Initialize
void Initialize()
Perform initialization that occurs after the parser has been initialized but before it parses anythin...
Definition: Sema.cpp:266
clang::Sema::MaximumAlignment
static const uint64_t MaximumAlignment
Definition: Sema.h:398
clang::Sema::AlignPackInfo
Definition: Sema.h:487
clang::ASTMutationListener
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Definition: ASTMutationListener.h:46
TemplateInstCallback.h
clang::Module::GlobalModuleFragment
@ GlobalModuleFragment
This is a fragment of the global module within some C++ module.
Definition: Module.h:124
clang::TargetInfo::hasFloat128Type
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
Definition: TargetInfo.h:643
clang::VarDecl::isEscapingByref
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
Definition: Decl.cpp:2574
clang::DiagnosticIDs::getDiagnosticSFINAEResponse
static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID)
Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs d...
Definition: DiagnosticIDs.cpp:335
clang::runWithSufficientStackSpace
void runWithSufficientStackSpace(llvm::function_ref< void()> Diag, llvm::function_ref< void()> Fn)
Run a given function on a stack with "sufficient" space.
Definition: Stack.h:40
ObjCMethodList.h
clang::Sema::Diags
DiagnosticsEngine & Diags
Definition: Sema.h:411
clang::ExternalSemaSource
An abstract interface that should be implemented by external AST sources that also provide informatio...
Definition: ExternalSemaSource.h:50
clang::Sema::diagIfOpenMPHostCode
SemaDiagnosticBuilder diagIfOpenMPHostCode(SourceLocation Loc, unsigned DiagID, FunctionDecl *FD)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host cod...
Definition: SemaOpenMP.cpp:2035
clang::RISCV::Policy
Policy
Definition: RISCVVIntrinsicUtils.h:94
clang::Sema::PushBlockScope
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition: Sema.cpp:2107
clang::MultiplexExternalSemaSource
An abstract interface that should be implemented by external AST sources that also provide informatio...
Definition: MultiplexExternalSemaSource.h:38
clang::DiagnosticIDs::SFINAE_Suppress
@ SFINAE_Suppress
The diagnostic should be suppressed entirely.
Definition: DiagnosticIDs.h:278
clang::DiagnosticsEngine::getCurrentDiagLoc
SourceLocation getCurrentDiagLoc() const
Definition: Diagnostic.h:1059
DelayedDiagnostic.h
clang::ComparisonCategoryType
ComparisonCategoryType
An enumeration representing the different comparison categories types.
Definition: ComparisonCategories.h:44
clang::isExternallyVisible
bool isExternallyVisible(Linkage L)
Definition: Linkage.h:91
clang::DiagnosticsEngine::getDiagnosticIDs
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
Definition: Diagnostic.h:552
clang::DeclContext::decl_iterator
decl_iterator - Iterates through the declarations stored within this context.
Definition: DeclBase.h:2135
clang::NSAPI
Definition: NSAPI.h:23
clang::Sema::PDiag
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaInternal.h:24
clang::ASTContext::getTypeSize
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2299
clang::Sema::NTCUK_Destruct
@ NTCUK_Destruct
Definition: Sema.h:2994
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2703
clang::ImplicitCastExpr::Create
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Definition: Expr.cpp:2051
clang::Sema::getCurLambda
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2324
clang::Sema::IsLastErrorImmediate
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition: Sema.h:1849
clang::CR_OpenMP
@ CR_OpenMP
Definition: CapturedStmt.h:19
Expr.h
llvm::SmallString< 16 >
clang::RawComment
Definition: RawCommentList.h:32
ASTContext.h
clang::UnresolvedSet
A set of unresolved declarations.
Definition: UnresolvedSet.h:148
clang::DiagnosticsEngine::overloadCandidatesShown
void overloadCandidatesShown(unsigned N)
Call this after showing N overload candidates.
Definition: Diagnostic.h:741
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:879
clang::ASTContext::FloatTy
CanQualType FloatTy
Definition: ASTContext.h:1119
clang::Sema::ImmediateDiagBuilder
Helper class that creates diagnostics with optional template instantiation stacks.
Definition: Sema.h:1674
clang::Type::getPointeeType
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:625
clang::Sema::deepTypeCheckForSYCLDevice
void deepTypeCheckForSYCLDevice(SourceLocation UsedAt, llvm::DenseSet< QualType > Visited, ValueDecl *DeclToCheck)
Definition: SemaSYCL.cpp:58
clang::DiagnosticIDs::SFINAE_SubstitutionFailure
@ SFINAE_SubstitutionFailure
The diagnostic should not be reported, but it should cause template argument deduction to fail.
Definition: DiagnosticIDs.h:273
clang::ASTContext::getBoolName
IdentifierInfo * getBoolName() const
Retrieve the identifier 'bool'.
Definition: ASTContext.h:1908
clang::ExternalSemaSource::ReadMethodPool
virtual void ReadMethodPool(Selector Sel)
Load the contents of the global method pool for a given selector.
Definition: Sema.cpp:2388
clang::ASTContext::getDefaultOpenCLPointeeAddrSpace
LangAS getDefaultOpenCLPointeeAddrSpace()
Returns default address space based on OpenCL version and enabled features.
Definition: ASTContext.h:1411
clang::TTK_Class
@ TTK_Class
The "class" keyword.
Definition: Type.h:5573
clang::ASTContext::getCanonicalType
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2522
llvm::DenseSet
Definition: Sema.h:77
clang::Type::getAsCXXRecordDecl
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1759
clang::Preprocessor::getMacroInfo
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
Definition: Preprocessor.h:1266
clang::TagDecl::isUnion
bool isUnion() const
Definition: Decl.h:3602
clang::Sema::getLocForEndOfToken
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:56
clang::SC_Register
@ SC_Register
Definition: Specifiers.h:245
clang::Sema::getCurFPFeatures
FPOptions & getCurFPFeatures()
Definition: Sema.h:1632
clang::Sema::checkTypeSupport
void checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D=nullptr)
Check if the type is allowed to be used for the current target.
Definition: Sema.cpp:1904
clang::SourceManager::isInSystemMacro
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
Definition: SourceManager.h:1514
clang::LangOptions::IsHeaderFile
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
Definition: LangOptions.h:459
clang::Sema::TentativeAnalysisScope
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:9597
ExprCXX.h
clang::Sema::CUDADiagIfHostCode
SemaDiagnosticBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host cod...
Definition: SemaCUDA.cpp:757
clang::Sema::canThrow
CanThrowResult canThrow(const Stmt *E)
Definition: SemaExceptionSpec.cpp:1124
clang::Sema::getDefaultCXXMethodAddrSpace
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
Definition: Sema.cpp:1480
clang::OverloadExpr::FindResult::HasFormOfMemberPointer
bool HasFormOfMemberPointer
Definition: ExprCXX.h:2949
clang::TagDecl::isCompleteDefinition
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3501
clang::ASTContext::getObjCProtocolDecl
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
Definition: ASTContext.cpp:8684
clang::Sema::ResolveExceptionSpec
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
Definition: SemaExceptionSpec.cpp:209
checkUndefinedButUsed
static void checkUndefinedButUsed(Sema &S)
checkUndefinedButUsed - Check for undefined objects with internal linkage or that are inline.
Definition: Sema.cpp:846
clang::IdentifierResolver::end
iterator end()
end - Returns an iterator that has 'finished'.
Definition: IdentifierResolver.h:141
ASTDiagnostic.h
clang::Sema::InstantiatingSpecializations
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:9234
clang::Sema::getASTMutationListener
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:532
clang::QualType::hasNonTrivialToPrimitiveDestructCUnion
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Definition: Type.h:6824
clang::Sema::NamedReturnInfo
Definition: Sema.h:5106
clang::Sema::getOpenCLOptions
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:1631
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system).
Definition: FileEntry.h:349
clang::sema::SemaPPCallbacks
Definition: Sema.cpp:133
clang::ModuleMap
Definition: ModuleMap.h:75
clang::ASTConsumer::CompleteTentativeDefinition
virtual void CompleteTentativeDefinition(VarDecl *D)
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
Definition: ASTConsumer.h:103
clang::Sema::PoppedFunctionScopeDeleter
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
Definition: Sema.h:1946
clang::Sema::addExternalSource
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Definition: Sema.cpp:541
clang::IncompleteArrayType
Represents a C array with an unspecified size.
Definition: Type.h:3115
clang::SC_Static
@ SC_Static
Definition: Specifiers.h:240
clang::Sema::LangOpts
const LangOptions & LangOpts
Definition: Sema.h:407
clang::Sema::LoadExternalWeakUndeclaredIdentifiers
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition: Sema.cpp:909
clang::QualType::getUnqualifiedType
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:6768
clang::Sema::PushLambdaScope
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:2112
clang::NamedDecl::getMostRecentDecl
NamedDecl * getMostRecentDecl()
Definition: Decl.h:471
clang::VarDecl::getDescribedVarTemplate
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2686
clang::ExternalSemaSource::ReadUndefinedButUsed
virtual void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined)
Load the set of used but not defined functions or variables with internal linkage,...
Definition: Sema.cpp:2395
clang::OpaquePtr< QualType >
clang::SourceManager::getLocForStartOfFile
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
Definition: SourceManager.h:1123
clang::Sema::UnusedPrivateFields
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:842
clang::Sema::UnusedLocalTypedefNameCandidates
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:846
clang::LangAS
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
clang::NSAPI::NumNSNumberLiteralMethods
static const unsigned NumNSNumberLiteralMethods
Definition: NSAPI.h:191
clang::sema::FunctionScopeInfo
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:102
clang::Sema::SemaDiagnosticBuilder::K_Deferred
@ K_Deferred
Create a deferred diagnostic, which is emitted only if the function it's attached to is codegen'ed.
Definition: Sema.h:1759
clang::TargetInfo::hasIbm128Type
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
Definition: TargetInfo.h:652
clang::VK_LValue
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:127
clang::Sema::getCurGenericLambda
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition: Sema.cpp:2349
clang::Sema::DeleteExprLoc
std::pair< SourceLocation, bool > DeleteExprLoc
Delete-expressions to be analyzed at the end of translation unit.
Definition: Sema.h:853
IsCPUDispatchCPUSpecificMultiVersion
static bool IsCPUDispatchCPUSpecificMultiVersion(const Expr *E)
Definition: Sema.cpp:2577
clang::UnresolvedSetImpl::clear
void clear()
Definition: UnresolvedSet.h:123
clang::TargetInfo::getTriple
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:1195
clang::ASTContext::UnsignedLongTy
CanQualType UnsignedLongTy
Definition: ASTContext.h:1117
clang::Sema::PerformPendingInstantiations
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
Definition: SemaTemplateInstantiateDecl.cpp:6295
clang::Sema::DeviceKnownEmittedFns
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, FunctionDeclAndLoc > DeviceKnownEmittedFns
An inverse call graph, mapping known-emitted functions to one of their known-emitted callers (plus th...
Definition: Sema.h:12755
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::Sema::FPFeaturesStateRAII::FPFeaturesStateRAII
FPFeaturesStateRAII(Sema &S)
Definition: Sema.cpp:2672
clang::sema::AnalysisBasedWarnings::Policy
Definition: AnalysisBasedWarnings.h:33
clang::Sema::SYCLDiagIfDeviceCode
SemaDiagnosticBuilder SYCLDiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
Definition: SemaSYCL.cpp:21
clang::Sema::FPFeaturesStateRAII::~FPFeaturesStateRAII
~FPFeaturesStateRAII()
Definition: Sema.cpp:2678
clang::Sema::InventAbbreviatedTemplateParameterTypeName
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition: Sema.cpp:91
clang::Sema::computeDeclContext
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Definition: SemaCXXScopeSpec.cpp:53
clang::Type::STK_CPointer
@ STK_CPointer
Definition: Type.h:2272
clang::Declarator::getCXXScopeSpec
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
Definition: DeclSpec.h:1984
clang::Sema::UnusedFileScopedDecls
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used.
Definition: Sema.h:887
clang::Type::isDependentType
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2298
clang::VK_PRValue
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:123
clang::Sema::getCurBlock
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition: Sema.cpp:2281
clang::ASTContext::UnsignedIntTy
CanQualType UnsignedIntTy
Definition: ASTContext.h:1117
clang::PPCallbacks::FileChangeReason
FileChangeReason
Definition: PPCallbacks.h:39
clang::VarDecl::setEscapingByref
void setEscapingByref()
Definition: Decl.h:1524
clang::Sema::getFloat128Identifier
IdentifierInfo * getFloat128Identifier() const
Definition: Sema.cpp:2643
clang::Sema::ImpCastExprToType
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
Definition: Sema.cpp:615
clang::Sema::diagIfOpenMPDeviceCode
SemaDiagnosticBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned DiagID, FunctionDecl *FD)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
Definition: SemaOpenMP.cpp:1997
clang::ASTContext::DoubleTy
CanQualType DoubleTy
Definition: ASTContext.h:1119
clang::Scope::TemplateParamScope
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
Definition: Scope.h:77
clang::ASTContext::getCFConstantStringDecl
TypedefDecl * getCFConstantStringDecl() const
Definition: ASTContext.cpp:7246
clang::RawComment::RCK_OrdinaryC
@ RCK_OrdinaryC
Any normal C comment.
Definition: RawCommentList.h:37
false
#define false
Definition: stdbool.h:22
clang::NamedDecl::hasExternalFormalLinkage
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
Definition: Decl.h:401
ExternalSemaSource.h
clang::PartialDiagnostic::Emit
void Emit(const DiagnosticBuilder &DB) const
Definition: PartialDiagnostic.h:144
clang::Sema::PerformCopyInitialization
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Definition: SemaInit.cpp:9980
clang::Sema::IdResolver
IdentifierResolver IdResolver
Definition: Sema.h:1122
clang::ActionResult::get
PtrTy get() const
Definition: Ownership.h:169
clang::Sema::PushCapturedRegionScope
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
Definition: Sema.cpp:2649
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:674
clang::ASTContext::IntTy
CanQualType IntTy
Definition: ASTContext.h:1116
clang::Sema::tryToRecoverWithCall
bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)
Try to recover by turning the given expression into a call.
Definition: Sema.cpp:2592
clang::Sema::getMismatchingDeleteExpressions
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit.
Definition: Sema.cpp:2668
clang::Diagnostic::getLocation
const SourceLocation & getLocation() const
Definition: Diagnostic.h:1572
clang::ASTContext::setBlockVarCopyInit
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
Definition: ASTContext.cpp:2965
clang::Preprocessor::isCodeCompletionEnabled
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
Definition: Preprocessor.h:1813
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4013
clang::ASTConsumer::CompleteExternalDeclaration
virtual void CompleteExternalDeclaration(VarDecl *D)
CompleteExternalDeclaration - Callback invoked at the end of a translation unit to notify the consume...
Definition: ASTConsumer.h:108
clang::ASTContext::Idents
IdentifierTable & Idents
Definition: ASTContext.h:660
notePlausibleOverloads
static void notePlausibleOverloads(Sema &S, SourceLocation Loc, const UnresolvedSetImpl &Overloads, bool(*IsPlausibleResult)(QualType))
Definition: Sema.cpp:2548
clang::FunctionDecl::isMultiVersion
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Definition: Decl.h:2479
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1923
clang::Sema::shouldIgnoreInHostDeviceCheck
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
Definition: SemaDecl.cpp:19585
clang::Expr::getExprLoc
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:318
clang::ASTContext::getPrintingPolicy
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:713
TemplateDeduction.h
clang::ASTContext::getIntPtrType
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
Definition: ASTContext.cpp:5926
clang::Sema::PerformMoveOrCopyInitialization
ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr *Value, bool SupressSimplerImplicitMoves=false)
Perform the initialization of a potentially-movable value, which is the result of return value.
Definition: SemaStmt.cpp:3528
clang::VarDecl::getDefinition
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
Definition: Decl.cpp:2275
clang::VarDecl::getActingDefinition
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
Definition: Decl.cpp:2254
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:802
clang::Sema::DiagnoseNonDefaultPragmaAlignPack
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition: SemaAttr.cpp:437
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::Sema::PopFunctionScopeInfo
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Definition: Sema.cpp:2212
Scope.h
clang::EnterExpressionEvaluationContext
RAII object that enters a new expression evaluation context.
Definition: Sema.h:13692
clang::DeclaratorDecl
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:731
clang::Expr::IgnoreParenImpCasts
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Definition: Expr.cpp:3024
clang::ASTContext::LongTy
CanQualType LongTy
Definition: ASTContext.h:1116
HeaderSearch.h
clang::Type::isFloat128Type
bool isFloat128Type() const
Definition: Type.h:7242
clang::Sema::Consumer
ASTConsumer & Consumer
Definition: Sema.h:410
clang::DarwinSDKInfo
The information about the darwin SDK that was used during this compilation.
Definition: DarwinSDKInfo.h:28
clang::Type::STK_Floating
@ STK_Floating
Definition: Type.h:2278
clang::Sema::ActOnComment
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:2358
clang::Module::PrivateModuleFragment
@ PrivateModuleFragment
This is the private module fragment within some C++ module.
Definition: Module.h:127
clang::Sema::SemaDiagnosticBuilder::K_ImmediateWithCallStack
@ K_ImmediateWithCallStack
Emit the diagnostic immediately, and, if it's a warning or error, also emit a call stack showing how ...
Definition: Sema.h:1755
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
clang::ActionResult::isInvalid
bool isInvalid() const
Definition: Ownership.h:165
clang::sema::SemaPPCallbacks::set
void set(Sema &S)
Definition: Sema.cpp:138
clang::ASTContext::getDiagAllocator
PartialDiagnostic::DiagStorageAllocator & getDiagAllocator()
Definition: ASTContext.h:769
clang::CodeCompleteConsumer
Abstract interface for a consumer of code-completion information.
Definition: CodeCompleteConsumer.h:1003
clang::Sema::diagnoseNullableToNonnullConversion
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
Definition: Sema.cpp:564
clang::Preprocessor::setCurrentFPEvalMethod
void setCurrentFPEvalMethod(SourceLocation PragmaLoc, LangOptions::FPEvalMethodKind Val)
Definition: Preprocessor.h:2214
clang::Sema::DiagnoseUseOfUnimplementedSelectors
void DiagnoseUseOfUnimplementedSelectors()
Definition: SemaDeclObjC.cpp:5242
clang::ASTContext::HalfTy
CanQualType HalfTy
Definition: ASTContext.h:1131
clang::LazyVector::begin
iterator begin(Source *source, bool LocalOnly=false)
Definition: ExternalASTSource.h:536
clang::Sema::~Sema
~Sema()
Definition: Sema.cpp:457
clang::Sema::DelayedDllExportClasses
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition: Sema.h:13564
clang::Sema::DeleteExprs
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Definition: Sema.h:855
clang::OverloadExpr
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition: ExprCXX.h:2897
clang::ASTContext::setPrintingPolicy
void setPrintingPolicy(const clang::PrintingPolicy &Policy)
Definition: ASTContext.h:717
clang::Type::STK_MemberPointer
@ STK_MemberPointer
Definition: Type.h:2275
clang::CXXRecordDecl::friend_end
friend_iterator friend_end() const
Definition: DeclFriend.h:243
clang::Sema::PushOnScopeChains
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
Definition: SemaDecl.cpp:1534
clang::Preprocessor::getCurrentModule
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
Definition: Preprocessor.cpp:530
clang::Sema::emitDeferredDiags
void emitDeferredDiags()
Definition: Sema.cpp:1779
clang::Redeclarable::getMostRecentDecl
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:226
clang::Sema::LookupSingleName
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
Definition: SemaLookup.cpp:3276
clang::VarDecl::getInit
const Expr * getInit() const
Definition: Decl.h:1288
clang::Sema::getCurMethodDecl
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Definition: Sema.cpp:1466
clang::Sema::PrintStats
void PrintStats() const
Print out statistics about the semantic analysis.
Definition: Sema.cpp:556
clang::ExprValueKind
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:120
clang::ModuleLoader
Abstract interface for a module loader.
Definition: ModuleLoader.h:82
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::Sema::addImplicitTypedef
void addImplicitTypedef(StringRef Name, QualType T)
Definition: Sema.cpp:260
clang::Sema::getModuleLoader
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition: Sema.cpp:60
clang::Sema::PrintContextStack
void PrintContextStack()
Definition: Sema.h:9517
clang::Sema::ActOnStartOfTranslationUnit
void ActOnStartOfTranslationUnit()
This is called before the very first declaration in the translation unit is parsed.
Definition: Sema.cpp:1016
clang::Sema::getFunctionLevelDeclContext
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false)
If AllowLambda is true, treat lambda as function.
Definition: Sema.cpp:1441
clang::ASTContext::getTargetInfo
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:773
clang::Sema::DiagnoseUnterminatedPragmaAlignPack
void DiagnoseUnterminatedPragmaAlignPack()
Definition: SemaAttr.cpp:476
clang::PartialDiagnostic::getDiagID
unsigned getDiagID() const
Definition: PartialDiagnostic.h:141
clang::SourceLocation::isMacroID
bool isMacroID() const
Definition: SourceLocation.h:103
clang::Sema::anchor
virtual void anchor()
This virtual key function only exists to limit the emission of debug info describing the Sema class.
Definition: Sema.cpp:258
clang::PartialDiagnostic
Definition: PartialDiagnostic.h:31
clang::Type::isStructureOrClassType
bool isStructureOrClassType() const
Definition: Type.cpp:581
clang::Type::getScalarTypeKind
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
Definition: Type.cpp:2168
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::Sema::MaybeCreateExprWithCleanups
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
Definition: SemaExprCXX.cpp:7232
clang::Sema::SemaDiagnosticBuilder
A generic diagnostic builder for errors which may or may not be deferred.
Definition: Sema.h:1745
RISCVIntrinsicManager.h
clang::Sema::RecordParsingTemplateParameterDepth
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
Definition: Sema.cpp:2118
clang::ActionResult< Expr * >
clang::Sema::getPreprocessor
Preprocessor & getPreprocessor() const
Definition: Sema.h:1636
clang::Sema::DelayedDiagnostics::getCurrentPool
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:957
clang::Sema::getEmissionStatus
FunctionEmissionStatus getEmissionStatus(FunctionDecl *Decl, bool Final=false)
Definition: SemaDecl.cpp:19505
clang::UnresolvedSetImpl::end
iterator end()
Definition: UnresolvedSet.h:84
clang::Sema::targetDiag
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, FunctionDecl *FD=nullptr)
Definition: Sema.cpp:1865
clang::TranslationUnitKind
TranslationUnitKind
Describes the kind of translation unit being processed.
Definition: LangOptions.h:902
clang::sema::LambdaScopeInfo
Definition: ScopeInfo.h:829
clang::ObjCMethodDecl
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
clang::ModuleMap::resolveExports
bool resolveExports(Module *Mod, bool Complain)
Resolve all of the unresolved exports in the given module.
Definition: ModuleMap.cpp:1329
clang::ASTContext::buildImplicitTypedef
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
Definition: ASTContext.cpp:1252
ScopeInfo.h
clang::LangAS::Default
@ Default
clang::Sema::emitAndClearUnusedLocalTypedefWarnings
void emitAndClearUnusedLocalTypedefWarnings()
Definition: Sema.cpp:1000
clang::Sema::finalizeOpenMPDelayedAnalysis
void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller, const FunctionDecl *Callee, SourceLocation Loc)
Finishes analysis of the deferred functions calls that may be declared as host/nohost during device/h...
Definition: SemaOpenMP.cpp:2664
clang::Sema::getCurScope
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition: Sema.h:13522
clang::Sema::FunctionEmissionStatus::Emitted
@ Emitted
clang::Sema::DiagnoseUnterminatedOpenMPDeclareTarget
void DiagnoseUnterminatedOpenMPDeclareTarget()
Report unterminated 'omp declare target' or 'omp begin declare target' at the end of a compilation un...
Definition: SemaOpenMP.cpp:22533
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:196
clang::Sema::CheckCompleteVariableDeclaration
void CheckCompleteVariableDeclaration(VarDecl *VD)
Definition: SemaDecl.cpp:13633
clang::Expr::IgnoreParens
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Definition: Expr.cpp:3020
PartialDiagnostic.h
clang
Definition: CalledOnceCheck.h:17
clang::Sema::PushFunctionScope
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:2095
clang::Preprocessor::addPPCallbacks
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
Definition: Preprocessor.h:1171
clang::sema::FunctionScopeInfo::CompoundScopes
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound stamement scopes in the function.
Definition: ScopeInfo.h:219
clang::RawComment::isAlmostTrailingComment
bool isAlmostTrailingComment() const LLVM_READONLY
Returns true if it is a probable typo:
Definition: RawCommentList.h:83
clang::Sema::isConstantEvaluatedOverride
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition: Sema.h:1042
clang::VarDecl::DeclarationOnly
@ DeclarationOnly
This declaration is only a declaration.
Definition: Decl.h:1215
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:759
clang::sema::CompoundScopeInfo
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:67
clang::UnresolvedSetImpl::addDecl
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:91
clang::DeclaratorContext::Block
@ Block
clang::Sema::PragmaAlignPackDiagnoseKind::NonDefaultStateAtInclude
@ NonDefaultStateAtInclude
clang::Sema::getScopeForContext
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:2076
clang::ComparisonCategoryType::Last
@ Last
clang::Sema::TUFragmentKind
TUFragmentKind
Definition: Sema.h:1911
clang::Declarator
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1834
clang::threadSafety::threadSafetyCleanup
void threadSafetyCleanup(BeforeSet *Cache)
Definition: ThreadSafety.cpp:2490
clang::OverloadExpr::FindResult::Expression
OverloadExpr * Expression
Definition: ExprCXX.h:2947
clang::SourceManager::isInSystemHeader
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
Definition: SourceManager.h:1502
clang::ASTContext::getBuiltinMSVaListDecl
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type.
Definition: ASTContext.cpp:9102
clang::Sema::diagnoseZeroToNullptrConversion
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
Definition: Sema.cpp:579
clang::FileEntry::getName
StringRef getName() const
Definition: FileEntry.h:380
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang::ASTContext::OCLClkEventTy
CanQualType OCLClkEventTy
Definition: ASTContext.h:1143
clang::Expr::getType
QualType getType() const
Definition: Expr.h:141
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::NullabilityKind::NullableResult
@ NullableResult
noteOverloads
static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads, const SourceLocation FinalNoteLoc)
Give notes for a set of overloads.
Definition: Sema.cpp:2519
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6646
clang::FunctionType::getReturnType
QualType getReturnType() const
Definition: Type.h:3937
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:311
clang::Sema::BumpAlloc
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:1446
clang::Module::submodule_end
submodule_iterator submodule_end()
Definition: Module.h:709
unsigned
clang::Stmt::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:336
clang::Type::isIbm128Type
bool isIbm128Type() const
Definition: Type.h:7246
clang::Sema::checkNonTrivialCUnion
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
Definition: SemaDecl.cpp:12733
clang::Sema::PushCompoundScope
void PushCompoundScope(bool IsStmtExpr)
Definition: Sema.cpp:2243
clang::ASTContext::getPointerDiffType
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Definition: ASTContext.cpp:5936
clang::Sema::isSFINAEContext
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
Definition: SemaTemplateInstantiate.cpp:981
MethodsAndNestedClassesComplete
static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD, RecordCompleteMap &MNCComplete)
Returns true, if all methods and nested classes of the given CXXRecordDecl are defined in this transl...
Definition: Sema.cpp:927
clang::OMPTargetDirective
This represents '#pragma omp target' directive.
Definition: StmtOpenMP.h:3096
clang::Sema::CodeSynthesisContext::RewritingOperatorAsSpaceship
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:9147
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3248
clang::DiagnosticsEngine::getCurrentDiagID
unsigned getCurrentDiagID() const
Definition: Diagnostic.h:1057
IsCallableWithAppend
static bool IsCallableWithAppend(Expr *E)
Determine whether the given expression can be called by just putting parentheses after it.
Definition: Sema.cpp:2569
clang::NullabilityKind::Nullable
@ Nullable
Values of this type can be null.
DarwinSDKInfo.h
clang::InitializedEntity::InitializeBlock
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type)
Definition: Initialization.h:309
clang::TargetInfo::hasAArch64SVETypes
bool hasAArch64SVETypes() const
Returns whether or not the AArch64 SVE built-in types are available on this target.
Definition: TargetInfo.h:979
UsedDeclVisitor.h
DiagnosticOptions.h
clang::ASTContext::OCLQueueTy
CanQualType OCLQueueTy
Definition: ASTContext.h:1144
clang::ImplicitCastExpr
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3623
clang::Sema::MaxAlignmentExponent
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
Definition: Sema.h:397
clang::Sema::WeakUndeclaredIdentifiers
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Definition: Sema.h:1103
clang::OpenCLOptions::addSupport
void addSupport(const llvm::StringMap< bool > &FeaturesMap, const LangOptions &Opts)
Definition: OpenCLOptions.cpp:108
clang::ASTConsumer::GetASTMutationListener
virtual ASTMutationListener * GetASTMutationListener()
If the consumer is interested in entities getting modified after their initial creation,...
Definition: ASTConsumer.h:128
clang::CPlusPlus11
@ CPlusPlus11
Definition: LangStandard.h:54
clang::Sema::NTCUK_Copy
@ NTCUK_Copy
Definition: Sema.h:2995
clang::Sema::ShouldWarnIfUnusedFileScopedDecl
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Definition: SemaDecl.cpp:1880
clang::LangOptions::CommentOpts
CommentOptions CommentOpts
Options for parsing comments.
Definition: LangOptions.h:431
clang::Sema::getDarwinSDKInfoForAvailabilityChecking
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition: Sema.cpp:74
clang::Sema::setFunctionHasBranchIntoScope
void setFunctionHasBranchIntoScope()
Definition: Sema.cpp:2261
clang::SourceManager::getExpansionLoc
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
Definition: SourceManager.h:1163
clang::Decl::setInvalidDecl
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Definition: DeclBase.cpp:132
clang::Lexer::getLocForEndOfToken
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
Definition: Lexer.cpp:787
clang::DiagnosticsEngine::getDiagnosticLevel
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
Definition: Diagnostic.h:926
clang::Sema::LookupOrdinaryName
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:4230
clang::Sema::NSNumberLiteralMethods
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
Definition: Sema.h:1182
clang::CastExpr::getCastKindName
const char * getCastKindName() const
Definition: Expr.h:3527
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::Scope::DeclScope
@ DeclScope
This is a scope that can contain a declaration.
Definition: Scope.h:59
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:685
clang::FormatASTNodeDiagnosticArgument
void FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind Kind, intptr_t Val, StringRef Modifier, StringRef Argument, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, void *Cookie, ArrayRef< intptr_t > QualTypeVals)
DiagnosticsEngine argument formatting function for diagnostics that involve AST nodes.
Definition: ASTDiagnostic.cpp:356
clang::CastKind
CastKind
CastKind - The kind of operation required for a conversion.
Definition: OperationKinds.h:20
clang::Type::isIntegerType
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:7257
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3109
clang::Sema::getPrintingPolicy
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition: Sema.h:3222
clang::Type::STK_Bool
@ STK_Bool
Definition: Type.h:2276
clang::Sema::ExpressionEvaluationContextRecord::EK_Other
@ EK_Other
Definition: Sema.h:1325
clang::Sema::ParsingInitForAutoVars
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
Definition: Sema.h:866
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:129
clang::CXXRecordDecl::friend_iterator
An iterator over the friend declarations of a class.
Definition: DeclFriend.h:187
SM
#define SM(sm)
Definition: Cuda.cpp:81
clang::sema::SemaPPCallbacks::reset
void reset()
Definition: Sema.cpp:140
clang::Preprocessor::getHeaderSearchInfo
HeaderSearch & getHeaderSearchInfo() const
Definition: Preprocessor.h:1078
clang::CleanupInfo
Definition: CleanupInfo.h:19
clang::BlockDecl::Capture
A class which contains all the information about a particular captured value.
Definition: Decl.h:4260
clang::Sema::DefineUsedVTables
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
Definition: SemaDeclCXX.cpp:17967
clang::transformer::name
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr, CxxCtorInitializer, and TypeLoc) selects th...
Definition: RangeSelector.cpp:200
clang::Sema::SemaDiagnosticBuilder::SemaDiagnosticBuilder
SemaDiagnosticBuilder(Kind K, SourceLocation Loc, unsigned DiagID, FunctionDecl *Fn, Sema &S)
Definition: Sema.cpp:1817
clang::Sema::PP
Preprocessor & PP
Definition: Sema.h:408
clang::Sema::EmitCurrentDiagnostic
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
Definition: Sema.cpp:1486
clang::Type::STK_ObjCObjectPointer
@ STK_ObjCObjectPointer
Definition: Type.h:2274
clang::Sema::NamedReturnInfo::MoveEligible
@ MoveEligible
Definition: Sema.h:5109
clang::DiagnosticsEngine::Warning
@ Warning
Definition: Diagnostic.h:199
clang::Sema::CheckDelegatingCtorCycles
void CheckDelegatingCtorCycles()
Definition: SemaDeclCXX.cpp:18219
clang::ASTContext::getConstantArrayType
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
Definition: ASTContext.cpp:3518
clang::Sema::NSAPIObj
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
Definition: Sema.h:1167
clang::NullabilityKind::NonNull
@ NonNull
Values of this type can never be null.
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:432
SemaConsumer.h
clang::Sema::CheckedConversionKind
CheckedConversionKind
The kind of conversion being performed.
Definition: Sema.h:11988
clang::Decl::addAttr
void addAttr(Attr *A)
Definition: DeclBase.cpp:902
clang::TargetInfo::hasFPReturn
virtual bool hasFPReturn() const
Determine whether return of a floating point value is supported on this target.
Definition: TargetInfo.h:659
clang::DeclRefExpr
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1231
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1877
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3954
clang::BlockDecl::getCaretLocation
SourceLocation getCaretLocation() const
Definition: Decl.h:4327
clang::Sema::UndefinedButUsed
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
Definition: Sema.h:1469
clang::RawComment::RCK_OrdinaryBCPL
@ RCK_OrdinaryBCPL
Any normal BCPL comments.
Definition: RawCommentList.h:36
clang::Sema::OpaqueParser
void * OpaqueParser
Definition: Sema.h:921
clang::HeaderSearch::getModuleMap
ModuleMap & getModuleMap()
Retrieve the module map.
Definition: HeaderSearch.h:779
StmtCXX.h
clang::CapturedDecl::getContextParam
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
Definition: Decl.h:4508
clang::Sema::PragmaAlignPackDiagnoseKind::ChangedStateAtExit
@ ChangedStateAtExit
clang::Sema::PoppedFunctionScopeDeleter::operator()
void operator()(sema::FunctionScopeInfo *Scope) const
Definition: Sema.cpp:2235
clang::ActionResult::isUsable
bool isUsable() const
Definition: Ownership.h:166
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:791
clang::Sema::setFunctionHasBranchProtectedScope
void setFunctionHasBranchProtectedScope()
Definition: Sema.cpp:2266
clang::Preprocessor::getIdentifierInfo
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Definition: Preprocessor.h:1390
clang::LangOptions::CMK_HeaderUnit
@ CMK_HeaderUnit
Compiling a module header unit.
Definition: LangOptions.h:114
clang::Type::getLinkage
Linkage getLinkage() const
Determine the linkage of this type.
Definition: Type.cpp:4017
clang::FixItHint::CreateReplacement
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
Definition: Diagnostic.h:134
clang::DiagnosticIDs::SFINAE_Report
@ SFINAE_Report
The diagnostic should be reported.
Definition: DiagnosticIDs.h:284
clang::DiagnosticsEngine::getSuppressSystemWarnings
bool getSuppressSystemWarnings() const
Definition: Diagnostic.h:685
clang::Sema::NumSFINAEErrors
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
Definition: Sema.h:1449
clang::Sema::PoppedFunctionScopePtr
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Definition: Sema.h:1955
clang::DiagnosticIDs::SFINAE_AccessControl
@ SFINAE_AccessControl
The diagnostic is an access-control diagnostic, which will be substitution failures in some contexts ...
Definition: DiagnosticIDs.h:288
clang::TargetInfo::hasBuiltinMSVaList
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
Definition: TargetInfo.h:972
Stack.h
clang::Sema::NTCUC_BlockCapture
@ NTCUC_BlockCapture
Definition: Sema.h:2980
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1537
clang::TargetInfo::hasRISCVVTypes
bool hasRISCVVTypes() const
Returns whether or not the RISC-V V built-in types are available on this target.
Definition: TargetInfo.h:983
clang::UnresolvedSetImpl::begin
iterator begin()
Definition: UnresolvedSet.h:83
clang::Sema::makeUnavailableInSystemHeader
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
Definition: Sema.cpp:511
clang::ValueDecl::setType
void setType(QualType newType)
Definition: Decl.h:686
clang::parseDarwinSDKInfo
Expected< Optional< DarwinSDKInfo > > parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath)
Parse the SDK information from the SDKSettings.json file.
Definition: DarwinSDKInfo.cpp:130
Initialization.h
clang::sema::AnalysisBasedWarnings::IssueWarnings
void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D, QualType BlockType)
Definition: AnalysisBasedWarnings.cpp:2205
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1983
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:441
clang::Sema::getASTConsumer
ASTConsumer & getASTConsumer() const
Definition: Sema.h:1638
clang::Sema::DelayedEquivalentExceptionSpecChecks
SmallVector< std::pair< FunctionDecl *, FunctionDecl * >, 2 > DelayedEquivalentExceptionSpecChecks
All the function redeclarations seen during a class definition that had their exception spec checks d...
Definition: Sema.h:909
ShouldRemoveFromUnused
static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D)
Used to prune the decls of Sema's UnusedFileScopedDecls vector.
Definition: Sema.cpp:713
clang::Sema::ExpressionEvaluationContext::PotentiallyEvaluated
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
clang::DeclContext::decls_begin
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1462