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