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