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