clang 20.0.0git
Sema.h
Go to the documentation of this file.
1//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
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 defines the Sema class, which performs semantic analysis and
10// builds ASTs.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SEMA_SEMA_H
15#define LLVM_CLANG_SEMA_SEMA_H
16
18#include "clang/AST/ASTFwd.h"
19#include "clang/AST/Attr.h"
21#include "clang/AST/CharUnits.h"
22#include "clang/AST/DeclBase.h"
23#include "clang/AST/DeclCXX.h"
26#include "clang/AST/Expr.h"
27#include "clang/AST/ExprCXX.h"
32#include "clang/AST/StmtCXX.h"
33#include "clang/AST/Type.h"
34#include "clang/AST/TypeLoc.h"
38#include "clang/Basic/Cuda.h"
42#include "clang/Basic/LLVM.h"
43#include "clang/Basic/Lambda.h"
45#include "clang/Basic/Module.h"
56#include "clang/Sema/Attr.h"
58#include "clang/Sema/DeclSpec.h"
64#include "clang/Sema/Scope.h"
65#include "clang/Sema/SemaBase.h"
67#include "clang/Sema/Weak.h"
68#include "llvm/ADT/APInt.h"
69#include "llvm/ADT/ArrayRef.h"
70#include "llvm/ADT/BitmaskEnum.h"
71#include "llvm/ADT/DenseMap.h"
72#include "llvm/ADT/DenseSet.h"
73#include "llvm/ADT/FloatingPointMode.h"
74#include "llvm/ADT/FoldingSet.h"
75#include "llvm/ADT/MapVector.h"
76#include "llvm/ADT/PointerIntPair.h"
77#include "llvm/ADT/PointerUnion.h"
78#include "llvm/ADT/STLExtras.h"
79#include "llvm/ADT/STLForwardCompat.h"
80#include "llvm/ADT/STLFunctionalExtras.h"
81#include "llvm/ADT/SetVector.h"
82#include "llvm/ADT/SmallBitVector.h"
83#include "llvm/ADT/SmallPtrSet.h"
84#include "llvm/ADT/SmallSet.h"
85#include "llvm/ADT/SmallVector.h"
86#include "llvm/ADT/StringExtras.h"
87#include "llvm/ADT/StringMap.h"
88#include "llvm/ADT/TinyPtrVector.h"
89#include "llvm/Support/Allocator.h"
90#include "llvm/Support/Compiler.h"
91#include "llvm/Support/Error.h"
92#include "llvm/Support/ErrorHandling.h"
93#include <cassert>
94#include <climits>
95#include <cstddef>
96#include <cstdint>
97#include <deque>
98#include <functional>
99#include <iterator>
100#include <memory>
101#include <optional>
102#include <string>
103#include <tuple>
104#include <type_traits>
105#include <utility>
106#include <vector>
107
108namespace llvm {
109struct InlineAsmIdentifierInfo;
110} // namespace llvm
111
112namespace clang {
113class ADLResult;
114class APValue;
115struct ASTConstraintSatisfaction;
116class ASTConsumer;
117class ASTContext;
118class ASTDeclReader;
119class ASTMutationListener;
120class ASTReader;
121class ASTWriter;
122class CXXBasePath;
123class CXXBasePaths;
124class CXXFieldCollector;
125class CodeCompleteConsumer;
126enum class ComparisonCategoryType : unsigned char;
127class ConstraintSatisfaction;
128class DarwinSDKInfo;
129class DeclGroupRef;
130class DeducedTemplateArgument;
131struct DeductionFailureInfo;
132class DependentDiagnostic;
133class Designation;
134class IdentifierInfo;
135class ImplicitConversionSequence;
136typedef MutableArrayRef<ImplicitConversionSequence> ConversionSequenceList;
137class InitializationKind;
138class InitializationSequence;
139class InitializedEntity;
140enum class LangAS : unsigned int;
141class LocalInstantiationScope;
142class LookupResult;
143class MangleNumberingContext;
144typedef ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> ModuleIdPath;
145class ModuleLoader;
146class MultiLevelTemplateArgumentList;
147struct NormalizedConstraint;
148class ObjCInterfaceDecl;
149class ObjCMethodDecl;
150struct OverloadCandidate;
151enum class OverloadCandidateParamOrder : char;
153class OverloadCandidateSet;
154class Preprocessor;
155class SemaAMDGPU;
156class SemaARM;
157class SemaAVR;
158class SemaBPF;
159class SemaCodeCompletion;
160class SemaCUDA;
161class SemaHLSL;
162class SemaHexagon;
163class SemaLoongArch;
164class SemaM68k;
165class SemaMIPS;
166class SemaMSP430;
167class SemaNVPTX;
168class SemaObjC;
169class SemaOpenACC;
170class SemaOpenCL;
171class SemaOpenMP;
172class SemaPPC;
173class SemaPseudoObject;
174class SemaRISCV;
175class SemaSYCL;
176class SemaSwift;
177class SemaSystemZ;
178class SemaWasm;
179class SemaX86;
180class StandardConversionSequence;
181class TemplateArgument;
182class TemplateArgumentLoc;
183class TemplateInstantiationCallback;
184class TemplatePartialOrderingContext;
185class TemplateSpecCandidateSet;
186class Token;
187class TypeConstraint;
188class TypoCorrectionConsumer;
189class UnresolvedSetImpl;
190class UnresolvedSetIterator;
191class VisibleDeclConsumer;
192
193namespace sema {
194class BlockScopeInfo;
195class Capture;
196class CapturedRegionScopeInfo;
197class CapturingScopeInfo;
198class CompoundScopeInfo;
199class DelayedDiagnostic;
200class DelayedDiagnosticPool;
201class FunctionScopeInfo;
202class LambdaScopeInfo;
203class SemaPPCallbacks;
204class TemplateDeductionInfo;
205} // namespace sema
206
207namespace threadSafety {
208class BeforeSet;
209void threadSafetyCleanup(BeforeSet *Cache);
210} // namespace threadSafety
211
212// FIXME: No way to easily map from TemplateTypeParmTypes to
213// TemplateTypeParmDecls, so we have this horrible PointerUnion.
214typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *>,
215 SourceLocation>
217
218/// Describes whether we've seen any nullability information for the given
219/// file.
221 /// The first pointer declarator (of any pointer kind) in the file that does
222 /// not have a corresponding nullability annotation.
224
225 /// The end location for the first pointer declarator in the file. Used for
226 /// placing fix-its.
228
229 /// Which kind of pointer declarator we saw.
230 uint8_t PointerKind;
231
232 /// Whether we saw any type nullability annotations in the given file.
233 bool SawTypeNullability = false;
234};
235
236/// A mapping from file IDs to a record of whether we've seen nullability
237/// information in that file.
239 /// A mapping from file IDs to the nullability information for each file ID.
240 llvm::DenseMap<FileID, FileNullability> Map;
241
242 /// A single-element cache based on the file ID.
243 struct {
246 } Cache;
247
248public:
250 // Check the single-element cache.
251 if (file == Cache.File)
252 return Cache.Nullability;
253
254 // It's not in the single-element cache; flush the cache if we have one.
255 if (!Cache.File.isInvalid()) {
256 Map[Cache.File] = Cache.Nullability;
257 }
258
259 // Pull this entry into the cache.
260 Cache.File = file;
261 Cache.Nullability = Map[file];
262 return Cache.Nullability;
263 }
264};
265
266/// Tracks expected type during expression parsing, for use in code completion.
267/// The type is tied to a particular token, all functions that update or consume
268/// the type take a start location of the token they are looking at as a
269/// parameter. This avoids updating the type on hot paths in the parser.
271public:
272 PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {}
273
274 void enterCondition(Sema &S, SourceLocation Tok);
275 void enterReturn(Sema &S, SourceLocation Tok);
277 /// Handles e.g. BaseType{ .D = Tok...
279 const Designation &D);
280 /// Computing a type for the function argument may require running
281 /// overloading, so we postpone its computation until it is actually needed.
282 ///
283 /// Clients should be very careful when using this function, as it stores a
284 /// function_ref, clients should make sure all calls to get() with the same
285 /// location happen while function_ref is alive.
286 ///
287 /// The callback should also emit signature help as a side-effect, but only
288 /// if the completion point has been reached.
290 llvm::function_ref<QualType()> ComputeType);
291
293 void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
294 SourceLocation OpLoc);
295 void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
297 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
298 /// Handles all type casts, including C-style cast, C++ casts, etc.
300
301 /// Get the expected type associated with this location, if any.
302 ///
303 /// If the location is a function argument, determining the expected type
304 /// involves considering all function overloads and the arguments so far.
305 /// In this case, signature help for these function overloads will be reported
306 /// as a side-effect (only if the completion point has been reached).
308 if (!Enabled || Tok != ExpectedLoc)
309 return QualType();
310 if (!Type.isNull())
311 return Type;
312 if (ComputeType)
313 return ComputeType();
314 return QualType();
315 }
316
317private:
318 bool Enabled;
319 /// Start position of a token for which we store expected type.
320 SourceLocation ExpectedLoc;
321 /// Expected type for a token starting at ExpectedLoc.
323 /// A function to compute expected type at ExpectedLoc. It is only considered
324 /// if Type is null.
325 llvm::function_ref<QualType()> ComputeType;
326};
327
329 SkipBodyInfo() = default;
330 bool ShouldSkip = false;
332 NamedDecl *Previous = nullptr;
333 NamedDecl *New = nullptr;
334};
335
336/// Describes the result of template argument deduction.
337///
338/// The TemplateDeductionResult enumeration describes the result of
339/// template argument deduction, as returned from
340/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
341/// structure provides additional information about the results of
342/// template argument deduction, e.g., the deduced template argument
343/// list (if successful) or the specific template parameters or
344/// deduced arguments that were involved in the failure.
346 /// Template argument deduction was successful.
347 Success = 0,
348 /// The declaration was invalid; do nothing.
349 Invalid,
350 /// Template argument deduction exceeded the maximum template
351 /// instantiation depth (which has already been diagnosed).
353 /// Template argument deduction did not deduce a value
354 /// for every template parameter.
356 /// Template argument deduction did not deduce a value for every
357 /// expansion of an expanded template parameter pack.
359 /// Template argument deduction produced inconsistent
360 /// deduced values for the given template parameter.
362 /// Template argument deduction failed due to inconsistent
363 /// cv-qualifiers on a template parameter type that would
364 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
365 /// but were given a non-const "X".
367 /// Substitution of the deduced template argument values
368 /// resulted in an error.
370 /// After substituting deduced template arguments, a dependent
371 /// parameter type did not match the corresponding argument.
373 /// After substituting deduced template arguments, an element of
374 /// a dependent parameter type did not match the corresponding element
375 /// of the corresponding argument (when deducing from an initializer list).
377 /// A non-depnedent component of the parameter did not match the
378 /// corresponding component of the argument.
380 /// When performing template argument deduction for a function
381 /// template, there were too many call arguments.
383 /// When performing template argument deduction for a function
384 /// template, there were too few call arguments.
386 /// The explicitly-specified template arguments were not valid
387 /// template arguments for the given template.
389 /// Checking non-dependent argument conversions failed.
391 /// The deduced arguments did not satisfy the constraints associated
392 /// with the template.
394 /// Deduction failed; that's all we know.
396 /// CUDA Target attributes do not match.
398 /// Some error which was already diagnosed.
400};
401
402/// Kinds of C++ special members.
410 Invalid
411};
412
413/// The kind of conversion being performed.
415 /// An implicit conversion.
416 Implicit,
417 /// A C-style cast.
419 /// A functional-style cast.
421 /// A cast other than a C-style cast.
422 OtherCast,
423 /// A conversion for an operand of a builtin overloaded operator.
425};
426
427enum class TagUseKind {
428 Reference, // Reference to a tag: 'struct foo *X;'
429 Declaration, // Fwd decl of a tag: 'struct foo;'
430 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
431 Friend // Friend declaration: 'friend struct foo;'
432};
433
434/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
435enum class FunctionEffectMode : uint8_t {
436 None, // effect is not present.
437 False, // effect(false).
438 True, // effect(true).
439 Dependent // effect(expr) where expr is dependent.
440};
441
444
447 FunctionEffectWithCondition Old; // invalid when Added.
448 FunctionEffectWithCondition New; // invalid when Removed.
449
450 StringRef effectName() const {
452 return Old.Effect.name();
453 return New.Effect.name();
454 }
455
456 /// Describes the result of effects differing between a base class's virtual
457 /// method and an overriding method in a subclass.
458 enum class OverrideResult {
459 NoAction,
460 Warn,
461 Merge // Merge missing effect from base to derived.
462 };
463
464 /// Return true if adding or removing the effect as part of a type conversion
465 /// should generate a diagnostic.
467 const FunctionEffectsRef &SrcFX,
468 QualType DstType,
469 const FunctionEffectsRef &DstFX) const;
470
471 /// Return true if adding or removing the effect in a redeclaration should
472 /// generate a diagnostic.
473 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
474 const FunctionEffectsRef &OldFX,
475 const FunctionDecl &NewFunction,
476 const FunctionEffectsRef &NewFX) const;
477
478 /// Return true if adding or removing the effect in a C++ virtual method
479 /// override should generate a diagnostic.
481 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
482 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
483};
484
485struct FunctionEffectDifferences : public SmallVector<FunctionEffectDiff> {
486 /// Caller should short-circuit by checking for equality first.
488 const FunctionEffectsRef &New);
489};
490
491/// Sema - This implements semantic analysis and AST building for C.
492/// \nosubgrouping
493class Sema final : public SemaBase {
494 // Table of Contents
495 // -----------------
496 // 1. Semantic Analysis (Sema.cpp)
497 // 2. API Notes (SemaAPINotes.cpp)
498 // 3. C++ Access Control (SemaAccess.cpp)
499 // 4. Attributes (SemaAttr.cpp)
500 // 5. Availability Attribute Handling (SemaAvailability.cpp)
501 // 6. Bounds Safety (SemaBoundsSafety.cpp)
502 // 7. Casts (SemaCast.cpp)
503 // 8. Extra Semantic Checking (SemaChecking.cpp)
504 // 9. C++ Coroutines (SemaCoroutine.cpp)
505 // 10. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
506 // 11. Declarations (SemaDecl.cpp)
507 // 12. Declaration Attribute Handling (SemaDeclAttr.cpp)
508 // 13. C++ Declarations (SemaDeclCXX.cpp)
509 // 14. C++ Exception Specifications (SemaExceptionSpec.cpp)
510 // 15. Expressions (SemaExpr.cpp)
511 // 16. C++ Expressions (SemaExprCXX.cpp)
512 // 17. Member Access Expressions (SemaExprMember.cpp)
513 // 18. Initializers (SemaInit.cpp)
514 // 19. C++ Lambda Expressions (SemaLambda.cpp)
515 // 20. Name Lookup (SemaLookup.cpp)
516 // 21. Modules (SemaModule.cpp)
517 // 22. C++ Overloading (SemaOverload.cpp)
518 // 23. Statements (SemaStmt.cpp)
519 // 24. `inline asm` Statement (SemaStmtAsm.cpp)
520 // 25. Statement Attribute Handling (SemaStmtAttr.cpp)
521 // 26. C++ Templates (SemaTemplate.cpp)
522 // 27. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
523 // 28. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
524 // 29. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
525 // 30. C++ Template Declaration Instantiation
526 // (SemaTemplateInstantiateDecl.cpp)
527 // 31. C++ Variadic Templates (SemaTemplateVariadic.cpp)
528 // 32. Constraints and Concepts (SemaConcept.cpp)
529 // 33. Types (SemaType.cpp)
530 // 34. FixIt Helpers (SemaFixItUtils.cpp)
531
532 /// \name Semantic Analysis
533 /// Implementations are in Sema.cpp
534 ///@{
535
536public:
537 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
539 CodeCompleteConsumer *CompletionConsumer = nullptr);
540 ~Sema();
541
542 /// Perform initialization that occurs after the parser has been
543 /// initialized but before it parses anything.
544 void Initialize();
545
546 /// This virtual key function only exists to limit the emission of debug info
547 /// describing the Sema class. GCC and Clang only emit debug info for a class
548 /// with a vtable when the vtable is emitted. Sema is final and not
549 /// polymorphic, but the debug info size savings are so significant that it is
550 /// worth adding a vtable just to take advantage of this optimization.
551 virtual void anchor();
552
553 const LangOptions &getLangOpts() const { return LangOpts; }
556
559 Preprocessor &getPreprocessor() const { return PP; }
560 ASTContext &getASTContext() const { return Context; }
564
566 StringRef Platform);
568
569 /// Registers an external source. If an external source already exists,
570 /// creates a multiplex external source and appends to it.
571 ///
572 ///\param[in] E - A non-null external sema source.
573 ///
575
576 /// Print out statistics about the semantic analysis.
577 void PrintStats() const;
578
579 /// Warn that the stack is nearly exhausted.
581
582 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
583 /// guaranteed). Produces a warning if we're low on stack space and allocates
584 /// more in that case. Use this in code that may recurse deeply (for example,
585 /// in template instantiation) to avoid stack overflow.
587 llvm::function_ref<void()> Fn);
588
589 /// Returns default addr space for method qualifiers.
591
592 /// Load weak undeclared identifiers from the external source.
594
595 /// Determine if VD, which must be a variable or function, is an external
596 /// symbol that nonetheless can't be referenced from outside this translation
597 /// unit because its type has no linkage and it's not extern "C".
598 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
599
600 /// Obtain a sorted list of functions that are undefined but ODR-used.
602 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
603
604 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
606 /// Retrieves list of suspicious delete-expressions that will be checked at
607 /// the end of translation unit.
608 const llvm::MapVector<FieldDecl *, DeleteLocs> &
610
611 /// Cause the active diagnostic on the DiagosticsEngine to be
612 /// emitted. This is closely coupled to the SemaDiagnosticBuilder class and
613 /// should not be used elsewhere.
614 void EmitCurrentDiagnostic(unsigned DiagID);
615
616 void addImplicitTypedef(StringRef Name, QualType T);
617
618 /// Whether uncompilable error has occurred. This includes error happens
619 /// in deferred diagnostics.
620 bool hasUncompilableErrorOccurred() const;
621
622 /// Looks through the macro-expansion chain for the given
623 /// location, looking for a macro expansion with the given name.
624 /// If one is found, returns true and sets the location to that
625 /// expansion loc.
626 bool findMacroSpelling(SourceLocation &loc, StringRef name);
627
628 /// Calls \c Lexer::getLocForEndOfToken()
630
631 /// Retrieve the module loader associated with the preprocessor.
633
634 /// Invent a new identifier for parameters of abbreviated templates.
637 unsigned Index);
638
640
641 // Emit all deferred diagnostics.
642 void emitDeferredDiags();
643
645 /// The global module fragment, between 'module;' and a module-declaration.
647 /// A normal translation unit fragment. For a non-module unit, this is the
648 /// entire translation unit. Otherwise, it runs from the module-declaration
649 /// to the private-module-fragment (if any) or the end of the TU (if not).
651 /// The private module fragment, between 'module :private;' and the end of
652 /// the translation unit.
653 Private
654 };
655
656 /// This is called before the very first declaration in the translation unit
657 /// is parsed. Note that the ASTContext may have already injected some
658 /// declarations.
660 /// ActOnEndOfTranslationUnit - This is called at the very end of the
661 /// translation unit when EOF is reached and all but the top-level scope is
662 /// popped.
665
666 /// Determines the active Scope associated with the given declaration
667 /// context.
668 ///
669 /// This routine maps a declaration context to the active Scope object that
670 /// represents that declaration context in the parser. It is typically used
671 /// from "scope-less" code (e.g., template instantiation, lazy creation of
672 /// declarations) that injects a name for name-lookup purposes and, therefore,
673 /// must update the Scope.
674 ///
675 /// \returns The scope corresponding to the given declaraion context, or NULL
676 /// if no such scope is open.
678
679 void PushFunctionScope();
680 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
682
683 /// This is used to inform Sema what the current TemplateParameterDepth
684 /// is during Parsing. Currently it is used to pass on the depth
685 /// when parsing generic lambda 'auto' parameters.
686 void RecordParsingTemplateParameterDepth(unsigned Depth);
687
688 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
690 unsigned OpenMPCaptureLevel = 0);
691
692 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
693 /// time after they've been popped.
695 Sema *Self;
696
697 public:
698 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
700 };
701
703 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
704
705 /// Pop a function (or block or lambda or captured region) scope from the
706 /// stack.
707 ///
708 /// \param WP The warning policy to use for CFG-based warnings, or null if
709 /// such warnings should not be produced.
710 /// \param D The declaration corresponding to this function scope, if
711 /// producing CFG-based warnings.
712 /// \param BlockType The type of the block expression, if D is a BlockDecl.
715 const Decl *D = nullptr,
716 QualType BlockType = QualType());
717
719
724
725 void PushCompoundScope(bool IsStmtExpr);
726 void PopCompoundScope();
727
728 /// Determine whether any errors occurred within this function/method/
729 /// block.
731
732 /// Retrieve the current block, if any.
734
735 /// Get the innermost lambda enclosing the current location, if any. This
736 /// looks through intervening non-lambda scopes such as local functions and
737 /// blocks.
739
740 /// Retrieve the current lambda scope info, if any.
741 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
742 /// lambda scope info ignoring all inner capturing scopes that are not
743 /// lambda scopes.
745 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
746
747 /// Retrieve the current generic lambda info, if any.
749
750 /// Retrieve the current captured region, if any.
752
753 void ActOnComment(SourceRange Comment);
754
755 /// Retrieve the parser's current scope.
756 ///
757 /// This routine must only be used when it is certain that semantic analysis
758 /// and the parser are in precisely the same context, which is not the case
759 /// when, e.g., we are performing any kind of template instantiation.
760 /// Therefore, the only safe places to use this scope are in the parser
761 /// itself and in routines directly invoked from the parser and *never* from
762 /// template substitution or instantiation.
763 Scope *getCurScope() const { return CurScope; }
764
766
769 }
770
771 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
772 const FunctionDecl *FD = nullptr);
774 const PartialDiagnostic &PD,
775 const FunctionDecl *FD = nullptr) {
776 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
777 }
778
779 /// Check if the type is allowed to be used for the current target.
781 ValueDecl *D = nullptr);
782
783 // /// The kind of conversion being performed.
784 // enum CheckedConversionKind {
785 // /// An implicit conversion.
786 // CCK_ImplicitConversion,
787 // /// A C-style cast.
788 // CCK_CStyleCast,
789 // /// A functional-style cast.
790 // CCK_FunctionalCast,
791 // /// A cast other than a C-style cast.
792 // CCK_OtherCast,
793 // /// A conversion for an operand of a builtin overloaded operator.
794 // CCK_ForBuiltinOverloadedOp
795 // };
796
797 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
798 /// cast. If there is already an implicit cast, merge into the existing one.
799 /// If isLvalue, the result of the cast is an lvalue.
802 const CXXCastPath *BasePath = nullptr,
804
805 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
806 /// to the conversion from scalar type ScalarTy to the Boolean type.
808
809 /// If \p AllowLambda is true, treat lambda as function.
810 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
811
812 /// Returns a pointer to the innermost enclosing function, or nullptr if the
813 /// current context is not inside a function. If \p AllowLambda is true,
814 /// this can return the call operator of an enclosing lambda, otherwise
815 /// lambdas are skipped when looking for an enclosing function.
816 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
817
818 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
819 /// the method decl for the method being parsed. If we're currently
820 /// in a 'block', this returns the containing context.
822
823 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
824 /// or C function we're in, otherwise return null. If we're currently
825 /// in a 'block', this returns the containing context.
827
828 /// Warn if we're implicitly casting from a _Nullable pointer type to a
829 /// _Nonnull one.
832
833 /// Warn when implicitly casting 0 to nullptr.
835
836 // ----- function effects ---
837
838 /// Warn when implicitly changing function effects.
841
842 /// Warn and return true if adding an effect to a set would create a conflict.
845 SourceLocation NewAttrLoc);
846
847 // Report a failure to merge function effects between declarations due to a
848 // conflict.
849 void
851 SourceLocation NewLoc,
852 SourceLocation OldLoc);
853
854 /// Try to parse the conditional expression attached to an effect attribute
855 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
856 /// optional on error.
857 std::optional<FunctionEffectMode>
858 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
859
860 /// makeUnavailableInSystemHeader - There is an error in the current
861 /// context. If we're still in a system header, and we can plausibly
862 /// make the relevant declaration unavailable instead of erroring, do
863 /// so and return true.
865 UnavailableAttr::ImplicitReason reason);
866
867 /// Retrieve a suitable printing policy for diagnostics.
870 }
871
872 /// Retrieve a suitable printing policy for diagnostics.
874 const Preprocessor &PP);
875
876 /// Scope actions.
878
879 /// Determine whether \param D is function like (function or function
880 /// template) for parsing.
882
883 /// The maximum alignment, same as in llvm::Value. We duplicate them here
884 /// because that allows us not to duplicate the constants in clang code,
885 /// which we must to since we can't directly use the llvm constants.
886 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
887 ///
888 /// This is the greatest alignment value supported by load, store, and alloca
889 /// instructions, and global values.
890 static const unsigned MaxAlignmentExponent = 32;
891 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
892
893 /// Flag indicating whether or not to collect detailed statistics.
895
896 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
897
898 /// Stack containing information about each of the nested
899 /// function, block, and method scopes that are currently active.
901
902 /// The index of the first FunctionScope that corresponds to the current
903 /// context.
905
906 /// Track the number of currently active capturing scopes.
908
909 llvm::BumpPtrAllocator BumpAlloc;
910
911 /// The kind of translation unit we are processing.
912 ///
913 /// When we're processing a complete translation unit, Sema will perform
914 /// end-of-translation-unit semantic tasks (such as creating
915 /// initializers for tentative definitions in C) once parsing has
916 /// completed. Modules and precompiled headers perform different kinds of
917 /// checks.
919
920 /// Translation Unit Scope - useful to Objective-C actions that need
921 /// to lookup file scope declarations in the "ordinary" C decl namespace.
922 /// For example, user-defined classes, built-in "id" type, etc.
924
926
928 return CurScope->incrementMSManglingNumber();
929 }
930
931 /// Try to recover by turning the given expression into a
932 /// call. Returns true if recovery was attempted or an error was
933 /// emitted; this may also leave the ExprResult invalid.
935 bool ForceComplain = false,
936 bool (*IsPlausibleResult)(QualType) = nullptr);
937
938 /// Figure out if an expression could be turned into a call.
939 ///
940 /// Use this when trying to recover from an error where the programmer may
941 /// have written just the name of a function instead of actually calling it.
942 ///
943 /// \param E - The expression to examine.
944 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
945 /// with no arguments, this parameter is set to the type returned by such a
946 /// call; otherwise, it is set to an empty QualType.
947 /// \param OverloadSet - If the expression is an overloaded function
948 /// name, this parameter is populated with the decls of the various
949 /// overloads.
950 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
951 UnresolvedSetImpl &NonTemplateOverloads);
952
956
959
967
968 /// A RAII object to enter scope of a compound statement.
970 public:
971 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
972 S.ActOnStartOfCompoundStmt(IsStmtExpr);
973 }
974
976
977 private:
978 Sema &S;
979 };
980
981 /// An RAII helper that pops function a function scope on exit.
984 bool Active;
987 if (Active)
989 }
990 void disable() { Active = false; }
991 };
992
994 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
995 }
996
997 /// Worker object for performing CFG-based warnings.
1000
1001 /// Callback to the parser to parse templated functions when needed.
1002 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
1003 typedef void LateTemplateParserCleanupCB(void *P);
1007
1009 LateTemplateParserCleanupCB *LTPCleanup, void *P) {
1010 LateTemplateParser = LTP;
1011 LateTemplateParserCleanup = LTPCleanup;
1012 OpaqueParser = P;
1013 }
1014
1015 /// Callback to the parser to parse a type expressed as a string.
1016 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
1018
1019 /// VAListTagName - The declaration name corresponding to __va_list_tag.
1020 /// This is used as part of a hack to omit that class from ADL results.
1022
1023 /// Is the last error level diagnostic immediate. This is used to determined
1024 /// whether the next info diagnostic should be immediate.
1026
1027 class DelayedDiagnostics;
1028
1030 sema::DelayedDiagnosticPool *SavedPool = nullptr;
1032 };
1035
1036 /// A class which encapsulates the logic for delaying diagnostics
1037 /// during parsing and other processing.
1039 /// The current pool of diagnostics into which delayed
1040 /// diagnostics should go.
1041 sema::DelayedDiagnosticPool *CurPool = nullptr;
1042
1043 public:
1045
1046 /// Adds a delayed diagnostic.
1047 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
1048
1049 /// Determines whether diagnostics should be delayed.
1050 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
1051
1052 /// Returns the current delayed-diagnostics pool.
1053 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1054
1055 /// Enter a new scope. Access and deprecation diagnostics will be
1056 /// collected in this pool.
1059 state.SavedPool = CurPool;
1060 CurPool = &pool;
1061 return state;
1062 }
1063
1064 /// Leave a delayed-diagnostic state that was previously pushed.
1065 /// Do not emit any of the diagnostics. This is performed as part
1066 /// of the bookkeeping of popping a pool "properly".
1068 CurPool = state.SavedPool;
1069 }
1070
1071 /// Enter a new scope where access and deprecation diagnostics are
1072 /// not delayed.
1075 state.SavedPool = CurPool;
1076 CurPool = nullptr;
1077 return state;
1078 }
1079
1080 /// Undo a previous pushUndelayed().
1082 assert(CurPool == nullptr);
1083 CurPool = state.SavedPool;
1084 }
1085 } DelayedDiagnostics;
1086
1088 return DelayedDiagnostics.push(pool);
1089 }
1090
1091 /// Diagnostics that are emitted only if we discover that the given function
1092 /// must be codegen'ed. Because handling these correctly adds overhead to
1093 /// compilation, this is currently only enabled for CUDA compilations.
1094 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1095
1096 /// CurContext - This is the current declaration context of parsing.
1098
1100 assert(AMDGPUPtr);
1101 return *AMDGPUPtr;
1102 }
1103
1105 assert(ARMPtr);
1106 return *ARMPtr;
1107 }
1108
1110 assert(AVRPtr);
1111 return *AVRPtr;
1112 }
1113
1115 assert(BPFPtr);
1116 return *BPFPtr;
1117 }
1118
1120 assert(CodeCompletionPtr);
1121 return *CodeCompletionPtr;
1122 }
1123
1125 assert(CUDAPtr);
1126 return *CUDAPtr;
1127 }
1128
1130 assert(HLSLPtr);
1131 return *HLSLPtr;
1132 }
1133
1135 assert(HexagonPtr);
1136 return *HexagonPtr;
1137 }
1138
1140 assert(LoongArchPtr);
1141 return *LoongArchPtr;
1142 }
1143
1145 assert(M68kPtr);
1146 return *M68kPtr;
1147 }
1148
1150 assert(MIPSPtr);
1151 return *MIPSPtr;
1152 }
1153
1155 assert(MSP430Ptr);
1156 return *MSP430Ptr;
1157 }
1158
1160 assert(NVPTXPtr);
1161 return *NVPTXPtr;
1162 }
1163
1165 assert(ObjCPtr);
1166 return *ObjCPtr;
1167 }
1168
1170 assert(OpenACCPtr);
1171 return *OpenACCPtr;
1172 }
1173
1175 assert(OpenCLPtr);
1176 return *OpenCLPtr;
1177 }
1178
1180 assert(OpenMPPtr && "SemaOpenMP is dead");
1181 return *OpenMPPtr;
1182 }
1183
1185 assert(PPCPtr);
1186 return *PPCPtr;
1187 }
1188
1190 assert(PseudoObjectPtr);
1191 return *PseudoObjectPtr;
1192 }
1193
1195 assert(RISCVPtr);
1196 return *RISCVPtr;
1197 }
1198
1200 assert(SYCLPtr);
1201 return *SYCLPtr;
1202 }
1203
1205 assert(SwiftPtr);
1206 return *SwiftPtr;
1207 }
1208
1210 assert(SystemZPtr);
1211 return *SystemZPtr;
1212 }
1213
1215 assert(WasmPtr);
1216 return *WasmPtr;
1217 }
1218
1220 assert(X86Ptr);
1221 return *X86Ptr;
1222 }
1223
1224 /// Source of additional semantic information.
1226
1227protected:
1228 friend class Parser;
1230 friend class ASTReader;
1231 friend class ASTDeclReader;
1232 friend class ASTWriter;
1233
1234private:
1235 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1236 bool WarnedDarwinSDKInfoMissing = false;
1237
1238 Sema(const Sema &) = delete;
1239 void operator=(const Sema &) = delete;
1240
1241 /// The handler for the FileChanged preprocessor events.
1242 ///
1243 /// Used for diagnostics that implement custom semantic analysis for #include
1244 /// directives, like -Wpragma-pack.
1245 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1246
1247 /// The parser's current scope.
1248 ///
1249 /// The parser maintains this state here.
1250 Scope *CurScope;
1251
1252 mutable IdentifierInfo *Ident_super;
1253
1254 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1255 std::unique_ptr<SemaARM> ARMPtr;
1256 std::unique_ptr<SemaAVR> AVRPtr;
1257 std::unique_ptr<SemaBPF> BPFPtr;
1258 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1259 std::unique_ptr<SemaCUDA> CUDAPtr;
1260 std::unique_ptr<SemaHLSL> HLSLPtr;
1261 std::unique_ptr<SemaHexagon> HexagonPtr;
1262 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1263 std::unique_ptr<SemaM68k> M68kPtr;
1264 std::unique_ptr<SemaMIPS> MIPSPtr;
1265 std::unique_ptr<SemaMSP430> MSP430Ptr;
1266 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1267 std::unique_ptr<SemaObjC> ObjCPtr;
1268 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1269 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1270 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1271 std::unique_ptr<SemaPPC> PPCPtr;
1272 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1273 std::unique_ptr<SemaRISCV> RISCVPtr;
1274 std::unique_ptr<SemaSYCL> SYCLPtr;
1275 std::unique_ptr<SemaSwift> SwiftPtr;
1276 std::unique_ptr<SemaSystemZ> SystemZPtr;
1277 std::unique_ptr<SemaWasm> WasmPtr;
1278 std::unique_ptr<SemaX86> X86Ptr;
1279
1280 ///@}
1281
1282 //
1283 //
1284 // -------------------------------------------------------------------------
1285 //
1286 //
1287
1288 /// \name API Notes
1289 /// Implementations are in SemaAPINotes.cpp
1290 ///@{
1291
1292public:
1293 /// Map any API notes provided for this declaration to attributes on the
1294 /// declaration.
1295 ///
1296 /// Triggered by declaration-attribute processing.
1297 void ProcessAPINotes(Decl *D);
1298
1299 ///@}
1300
1301 //
1302 //
1303 // -------------------------------------------------------------------------
1304 //
1305 //
1306
1307 /// \name C++ Access Control
1308 /// Implementations are in SemaAccess.cpp
1309 ///@{
1310
1311public:
1318
1319 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1320 /// Returns true on error (when the previous member decl access specifier
1321 /// is different from the new member decl access specifier).
1322 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1323 NamedDecl *PrevMemberDecl,
1324 AccessSpecifier LexicalAS);
1325
1326 /// Perform access-control checking on a previously-unresolved member
1327 /// access which has now been resolved to a member.
1329 DeclAccessPair FoundDecl);
1331 DeclAccessPair FoundDecl);
1332
1333 /// Checks access to an overloaded operator new or delete.
1335 SourceRange PlacementRange,
1336 CXXRecordDecl *NamingClass,
1337 DeclAccessPair FoundDecl,
1338 bool Diagnose = true);
1339
1340 /// Checks access to a constructor.
1342 DeclAccessPair FoundDecl,
1343 const InitializedEntity &Entity,
1344 bool IsCopyBindingRefToTemp = false);
1345
1346 /// Checks access to a constructor.
1348 DeclAccessPair FoundDecl,
1349 const InitializedEntity &Entity,
1350 const PartialDiagnostic &PDiag);
1352 CXXDestructorDecl *Dtor,
1353 const PartialDiagnostic &PDiag,
1354 QualType objectType = QualType());
1355
1356 /// Checks access to the target of a friend declaration.
1358
1359 /// Checks access to a member.
1361 CXXRecordDecl *NamingClass,
1363
1364 /// Checks implicit access to a member in a structured binding.
1367 CXXRecordDecl *DecomposedClass,
1368 DeclAccessPair Field);
1370 const SourceRange &,
1371 DeclAccessPair FoundDecl);
1372
1373 /// Checks access to an overloaded member operator, including
1374 /// conversion operators.
1376 Expr *ArgExpr,
1377 DeclAccessPair FoundDecl);
1379 ArrayRef<Expr *> ArgExprs,
1380 DeclAccessPair FoundDecl);
1382 DeclAccessPair FoundDecl);
1383
1384 /// Checks access for a hierarchy conversion.
1385 ///
1386 /// \param ForceCheck true if this check should be performed even if access
1387 /// control is disabled; some things rely on this for semantics
1388 /// \param ForceUnprivileged true if this check should proceed as if the
1389 /// context had no special privileges
1391 QualType Derived, const CXXBasePath &Path,
1392 unsigned DiagID, bool ForceCheck = false,
1393 bool ForceUnprivileged = false);
1394
1395 /// Checks access to all the declarations in the given result set.
1396 void CheckLookupAccess(const LookupResult &R);
1397
1398 /// Checks access to Target from the given class. The check will take access
1399 /// specifiers into account, but no member access expressions and such.
1400 ///
1401 /// \param Target the declaration to check if it can be accessed
1402 /// \param NamingClass the class in which the lookup was started.
1403 /// \param BaseType type of the left side of member access expression.
1404 /// \p BaseType and \p NamingClass are used for C++ access control.
1405 /// Depending on the lookup case, they should be set to the following:
1406 /// - lhs.target (member access without a qualifier):
1407 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1408 /// - lhs.X::target (member access with a qualifier):
1409 /// BaseType is the type of 'lhs', NamingClass is 'X'
1410 /// - X::target (qualified lookup without member access):
1411 /// BaseType is null, NamingClass is 'X'.
1412 /// - target (unqualified lookup).
1413 /// BaseType is null, NamingClass is the parent class of 'target'.
1414 /// \return true if the Target is accessible from the Class, false otherwise.
1415 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1416 QualType BaseType);
1417
1418 /// Is the given member accessible for the purposes of deciding whether to
1419 /// define a special member function as deleted?
1421 DeclAccessPair Found, QualType ObjectType,
1423 const PartialDiagnostic &Diag);
1426 QualType ObjectType) {
1427 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1428 SourceLocation(), PDiag());
1429 }
1430
1432 const DependentDiagnostic &DD,
1433 const MultiLevelTemplateArgumentList &TemplateArgs);
1435
1436 ///@}
1437
1438 //
1439 //
1440 // -------------------------------------------------------------------------
1441 //
1442 //
1443
1444 /// \name Attributes
1445 /// Implementations are in SemaAttr.cpp
1446 ///@{
1447
1448public:
1449 /// Controls member pointer representation format under the MS ABI.
1452
1453 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1454
1455 /// Source location for newly created implicit MSInheritanceAttrs
1457
1458 /// pragma clang section kind
1465 PCSK_Relro = 5
1467
1469
1471 std::string SectionName;
1472 bool Valid = false;
1474 };
1475
1481
1483 PSK_Reset = 0x0, // #pragma ()
1484 PSK_Set = 0x1, // #pragma (value)
1485 PSK_Push = 0x2, // #pragma (push[, id])
1486 PSK_Pop = 0x4, // #pragma (pop[, id])
1487 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1488 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1489 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1490 };
1491
1494 StringRef SlotLabel;
1496 };
1497
1498 // #pragma pack and align.
1500 public:
1501 // `Native` represents default align mode, which may vary based on the
1502 // platform.
1503 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1504
1505 // #pragma pack info constructor
1506 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1507 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1508 assert(Num == PackNumber && "The pack number has been truncated.");
1509 }
1510
1511 // #pragma align info constructor
1513 : PackAttr(false), AlignMode(M),
1514 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1515
1516 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1517
1519
1520 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1521 // integer encoding for it. This should only be passed to
1522 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1523 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1524 std::uint32_t Encoding{};
1525 if (Info.IsXLStack())
1526 Encoding |= IsXLMask;
1527
1528 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1529
1530 if (Info.IsPackAttr())
1531 Encoding |= PackAttrMask;
1532
1533 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1534
1535 return Encoding;
1536 }
1537
1538 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1539 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1541 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1542 int PackNumber = (Encoding & PackNumMask) >> 4;
1543
1544 if (Encoding & PackAttrMask)
1545 return AlignPackInfo(M, PackNumber, IsXL);
1546
1547 return AlignPackInfo(M, IsXL);
1548 }
1549
1550 bool IsPackAttr() const { return PackAttr; }
1551
1552 bool IsAlignAttr() const { return !PackAttr; }
1553
1554 Mode getAlignMode() const { return AlignMode; }
1555
1556 unsigned getPackNumber() const { return PackNumber; }
1557
1558 bool IsPackSet() const {
1559 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1560 // attriute on a decl.
1561 return PackNumber != UninitPackVal && PackNumber != 0;
1562 }
1563
1564 bool IsXLStack() const { return XLStack; }
1565
1566 bool operator==(const AlignPackInfo &Info) const {
1567 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1568 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1569 Info.XLStack);
1570 }
1571
1572 bool operator!=(const AlignPackInfo &Info) const {
1573 return !(*this == Info);
1574 }
1575
1576 private:
1577 /// \brief True if this is a pragma pack attribute,
1578 /// not a pragma align attribute.
1579 bool PackAttr;
1580
1581 /// \brief The alignment mode that is in effect.
1582 Mode AlignMode;
1583
1584 /// \brief The pack number of the stack.
1585 unsigned char PackNumber;
1586
1587 /// \brief True if it is a XL #pragma align/pack stack.
1588 bool XLStack;
1589
1590 /// \brief Uninitialized pack value.
1591 static constexpr unsigned char UninitPackVal = -1;
1592
1593 // Masks to encode and decode an AlignPackInfo.
1594 static constexpr uint32_t IsXLMask{0x0000'0001};
1595 static constexpr uint32_t AlignModeMask{0x0000'0006};
1596 static constexpr uint32_t PackAttrMask{0x00000'0008};
1597 static constexpr uint32_t PackNumMask{0x0000'01F0};
1598 };
1599
1600 template <typename ValueType> struct PragmaStack {
1601 struct Slot {
1602 llvm::StringRef StackSlotLabel;
1603 ValueType Value;
1606 Slot(llvm::StringRef StackSlotLabel, ValueType Value,
1611 };
1612
1613 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1614 llvm::StringRef StackSlotLabel, ValueType Value) {
1615 if (Action == PSK_Reset) {
1617 CurrentPragmaLocation = PragmaLocation;
1618 return;
1619 }
1620 if (Action & PSK_Push)
1621 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1622 PragmaLocation);
1623 else if (Action & PSK_Pop) {
1624 if (!StackSlotLabel.empty()) {
1625 // If we've got a label, try to find it and jump there.
1626 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1627 return x.StackSlotLabel == StackSlotLabel;
1628 });
1629 // If we found the label so pop from there.
1630 if (I != Stack.rend()) {
1631 CurrentValue = I->Value;
1632 CurrentPragmaLocation = I->PragmaLocation;
1633 Stack.erase(std::prev(I.base()), Stack.end());
1634 }
1635 } else if (!Stack.empty()) {
1636 // We do not have a label, just pop the last entry.
1637 CurrentValue = Stack.back().Value;
1638 CurrentPragmaLocation = Stack.back().PragmaLocation;
1639 Stack.pop_back();
1640 }
1641 }
1642 if (Action & PSK_Set) {
1644 CurrentPragmaLocation = PragmaLocation;
1645 }
1646 }
1647
1648 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1649 // method body to restore the stacks on exit, so it works like this:
1650 //
1651 // struct S {
1652 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1653 // void Method {}
1654 // #pragma <name>(pop, InternalPragmaSlot)
1655 // };
1656 //
1657 // It works even with #pragma vtordisp, although MSVC doesn't support
1658 // #pragma vtordisp(push [, id], n)
1659 // syntax.
1660 //
1661 // Push / pop a named sentinel slot.
1662 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
1663 assert((Action == PSK_Push || Action == PSK_Pop) &&
1664 "Can only push / pop #pragma stack sentinels!");
1666 }
1667
1668 // Constructors.
1669 explicit PragmaStack(const ValueType &Default)
1671
1672 bool hasValue() const { return CurrentValue != DefaultValue; }
1673
1675 ValueType DefaultValue; // Value used for PSK_Reset action.
1676 ValueType CurrentValue;
1678 };
1679 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
1680 // we shouldn't do so if they're in a module).
1681
1682 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
1683 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
1684 ///
1685 /// 0: Suppress all vtordisps
1686 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
1687 /// structors
1688 /// 2: Always insert vtordisps to support RTTI on partially constructed
1689 /// objects
1692 // The current #pragma align/pack values and locations at each #include.
1697 };
1699 // Segment #pragmas.
1704
1705 // #pragma strict_gs_check.
1707
1708 // This stack tracks the current state of Sema.CurFPFeatures.
1711 FPOptionsOverride result;
1712 if (!FpPragmaStack.hasValue()) {
1713 result = FPOptionsOverride();
1714 } else {
1715 result = FpPragmaStack.CurrentValue;
1716 }
1717 return result;
1718 }
1719
1725 };
1726
1727 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
1728 // Actions should be performed only if we enter / exit a C++ method body.
1730 public:
1731 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
1733
1734 private:
1735 Sema &S;
1736 StringRef SlotLabel;
1737 bool ShouldAct;
1738 };
1739
1740 /// Last section used with #pragma init_seg.
1743
1744 /// Sections used with #pragma alloc_text.
1745 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
1746
1747 /// VisContext - Manages the stack for \#pragma GCC visibility.
1748 void *VisContext; // Really a "PragmaVisStack*"
1749
1750 /// This an attribute introduced by \#pragma clang attribute.
1756 };
1757
1758 /// A push'd group of PragmaAttributeEntries.
1760 /// The location of the push attribute.
1762 /// The namespace of this push group.
1765 };
1766
1768
1769 /// The declaration that is currently receiving an attribute from the
1770 /// #pragma attribute stack.
1772
1773 /// This represents the last location of a "#pragma clang optimize off"
1774 /// directive if such a directive has not been closed by an "on" yet. If
1775 /// optimizations are currently "on", this is set to an invalid location.
1777
1778 /// Get the location for the currently active "\#pragma clang optimize
1779 /// off". If this location is invalid, then the state of the pragma is "on".
1782 }
1783
1784 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
1785 /// whether the optimizations in the list passed to the pragma should be
1786 /// turned off or on. This boolean is true by default because command line
1787 /// options are honored when `#pragma optimize("", on)`.
1788 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
1790
1791 /// Set of no-builtin functions listed by \#pragma function.
1793
1794 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
1795 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
1797
1798 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
1800
1801 /// Add gsl::Pointer attribute to std::container::iterator
1802 /// \param ND The declaration that introduces the name
1803 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
1804 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
1805
1806 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
1808
1809 /// Add [[gsl::Pointer]] attributes for std:: types.
1811
1812 /// Add _Nullable attributes for std:: types.
1814
1816 POAK_Native, // #pragma options align=native
1817 POAK_Natural, // #pragma options align=natural
1818 POAK_Packed, // #pragma options align=packed
1819 POAK_Power, // #pragma options align=power
1820 POAK_Mac68k, // #pragma options align=mac68k
1821 POAK_Reset // #pragma options align=reset
1823
1824 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
1827 PragmaClangSectionKind SecKind,
1828 StringRef SecName);
1829
1830 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
1832 SourceLocation PragmaLoc);
1833
1834 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
1835 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
1836 StringRef SlotLabel, Expr *Alignment);
1837
1838 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
1839 /// (unless they are value dependent or type dependent). Returns false
1840 /// and emits a diagnostic if one or more of the arguments could not be
1841 /// folded into a constant.
1844
1848 };
1849
1851 SourceLocation IncludeLoc);
1853
1854 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
1856
1857 /// ActOnPragmaMSComment - Called on well formed
1858 /// \#pragma comment(kind, "arg").
1860 StringRef Arg);
1861
1862 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
1863 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
1864 StringRef Value);
1865
1866 /// Are precise floating point semantics currently enabled?
1868 return !CurFPFeatures.getAllowFPReassociate() &&
1869 !CurFPFeatures.getNoSignedZero() &&
1870 !CurFPFeatures.getAllowReciprocal() &&
1871 !CurFPFeatures.getAllowApproxFunc();
1872 }
1873
1876
1877 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
1880
1881 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
1882 /// pointers_to_members(representation method[, general purpose
1883 /// representation]).
1886 SourceLocation PragmaLoc);
1887
1888 /// Called on well formed \#pragma vtordisp().
1891
1892 bool UnifySection(StringRef SectionName, int SectionFlags,
1893 NamedDecl *TheDecl);
1894 bool UnifySection(StringRef SectionName, int SectionFlags,
1895 SourceLocation PragmaSectionLocation);
1896
1897 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
1898 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
1899 PragmaMsStackAction Action,
1900 llvm::StringRef StackSlotLabel,
1901 StringLiteral *SegmentName, llvm::StringRef PragmaName);
1902
1903 /// Called on well formed \#pragma section().
1904 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
1905 StringLiteral *SegmentName);
1906
1907 /// Called on well-formed \#pragma init_seg().
1908 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
1909 StringLiteral *SegmentName);
1910
1911 /// Called on well-formed \#pragma alloc_text().
1913 SourceLocation PragmaLocation, StringRef Section,
1914 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
1915 &Functions);
1916
1917 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
1918 /// strict_gs_check.
1920 PragmaMsStackAction Action,
1921 bool Value);
1922
1923 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
1924 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
1925 SourceLocation PragmaLoc);
1926
1928 SourceLocation PragmaLoc,
1931 const IdentifierInfo *Namespace);
1932
1933 /// Called on well-formed '\#pragma clang attribute pop'.
1935 const IdentifierInfo *Namespace);
1936
1937 /// Adds the attributes that have been specified using the
1938 /// '\#pragma clang attribute push' directives to the given declaration.
1939 void AddPragmaAttributes(Scope *S, Decl *D);
1940
1942
1944
1945 /// Called on well formed \#pragma clang optimize.
1946 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
1947
1948 /// #pragma optimize("[optimization-list]", on | off).
1949 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
1950
1951 /// Call on well formed \#pragma function.
1952 void
1954 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
1955
1956 /// Only called on function definitions; if there is a pragma in scope
1957 /// with the effect of a range-based optnone, consider marking the function
1958 /// with attribute optnone.
1960
1961 /// Only called on function definitions; if there is a `#pragma alloc_text`
1962 /// that decides which code section the function should be in, add
1963 /// attribute section to the function.
1965
1966 /// Adds the 'optnone' attribute to the function declaration if there
1967 /// are no conflicts; Loc represents the location causing the 'optnone'
1968 /// attribute to be added (usually because of a pragma).
1970
1971 /// Only called on function definitions; if there is a MSVC #pragma optimize
1972 /// in scope, consider changing the function's attributes based on the
1973 /// optimization list passed to the pragma.
1975
1976 /// Only called on function definitions; if there is a pragma in scope
1977 /// with the effect of a range-based no_builtin, consider marking the function
1978 /// with attribute no_builtin.
1980
1981 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
1982 /// add an appropriate visibility attribute.
1984
1985 /// FreeVisContext - Deallocate and null out VisContext.
1986 void FreeVisContext();
1987
1988 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
1989 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
1990 SourceLocation PragmaLoc);
1991
1992 /// ActOnPragmaFPContract - Called on well formed
1993 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
1994 /// \#pragma clang fp contract
1996
1997 /// Called on well formed
1998 /// \#pragma clang fp reassociate
1999 /// or
2000 /// \#pragma clang fp reciprocal
2002 bool IsEnabled);
2003
2004 /// ActOnPragmaFenvAccess - Called on well formed
2005 /// \#pragma STDC FENV_ACCESS
2006 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
2007
2008 /// ActOnPragmaCXLimitedRange - Called on well formed
2009 /// \#pragma STDC CX_LIMITED_RANGE
2012
2013 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
2016
2017 /// Called to set constant rounding mode for floating point operations.
2018 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
2019
2020 /// Called to set exception behavior for floating point operations.
2022
2023 /// PushNamespaceVisibilityAttr - Note that we've entered a
2024 /// namespace with a visibility attribute.
2025 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
2027
2028 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
2029 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2030 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2031
2032 /// Handles semantic checking for features that are common to all attributes,
2033 /// such as checking whether a parameter was properly specified, or the
2034 /// correct number of arguments were passed, etc. Returns true if the
2035 /// attribute has been diagnosed.
2036 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2037 bool SkipArgCountCheck = false);
2038 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2039 bool SkipArgCountCheck = false);
2040
2041 ///@}
2042
2043 //
2044 //
2045 // -------------------------------------------------------------------------
2046 //
2047 //
2048
2049 /// \name Availability Attribute Handling
2050 /// Implementations are in SemaAvailability.cpp
2051 ///@{
2052
2053public:
2054 /// Issue any -Wunguarded-availability warnings in \c FD
2056
2058
2059 /// Retrieve the current function, if any, that should be analyzed for
2060 /// potential availability violations.
2062
2064 const ObjCInterfaceDecl *UnknownObjCClass,
2065 bool ObjCPropertyAccess,
2066 bool AvoidPartialAvailabilityChecks = false,
2067 ObjCInterfaceDecl *ClassReceiver = nullptr);
2068
2069 ///@}
2070
2071 //
2072 //
2073 // -------------------------------------------------------------------------
2074 //
2075 //
2076
2077 /// \name Bounds Safety
2078 /// Implementations are in SemaBoundsSafety.cpp
2079 ///@{
2080public:
2081 /// Check if applying the specified attribute variant from the "counted by"
2082 /// family of attributes to FieldDecl \p FD is semantically valid. If
2083 /// semantically invalid diagnostics will be emitted explaining the problems.
2084 ///
2085 /// \param FD The FieldDecl to apply the attribute to
2086 /// \param E The count expression on the attribute
2087 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2088 /// attributes. If the false the attribute is from
2089 /// "counted_by" family of attributes.
2090 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2091 /// of attributes. If false the attribute does not have the
2092 /// suffix.
2093 ///
2094 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2095 /// \p CountInBytes and \p OrNull both being true indicates the
2096 /// `counted_by_or_null` attribute.
2097 ///
2098 /// \returns false iff semantically valid.
2099 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2100 bool OrNull);
2101
2102 ///@}
2103
2104 //
2105 //
2106 // -------------------------------------------------------------------------
2107 //
2108 //
2109
2110 /// \name Casts
2111 /// Implementations are in SemaCast.cpp
2112 ///@{
2113
2114public:
2116 return CCK == CheckedConversionKind::CStyleCast ||
2119 }
2120
2121 /// ActOnCXXNamedCast - Parse
2122 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2124 SourceLocation LAngleBracketLoc, Declarator &D,
2125 SourceLocation RAngleBracketLoc,
2126 SourceLocation LParenLoc, Expr *E,
2127 SourceLocation RParenLoc);
2128
2130 TypeSourceInfo *Ty, Expr *E,
2131 SourceRange AngleBrackets, SourceRange Parens);
2132
2134 ExprResult Operand,
2135 SourceLocation RParenLoc);
2136
2138 Expr *Operand, SourceLocation RParenLoc);
2139
2140 // Checks that reinterpret casts don't have undefined behavior.
2141 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2142 bool IsDereference, SourceRange Range);
2143
2144 // Checks that the vector type should be initialized from a scalar
2145 // by splatting the value rather than populating a single element.
2146 // This is the case for AltiVecVector types as well as with
2147 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2148 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2149
2150 // Checks if the -faltivec-src-compat=gcc option is specified.
2151 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2152 // treated the same way as they are when trying to initialize
2153 // these vectors on gcc (an error is emitted).
2155 QualType SrcTy);
2156
2158 SourceLocation RParenLoc, Expr *Op);
2159
2161 SourceLocation LParenLoc,
2162 Expr *CastExpr,
2163 SourceLocation RParenLoc);
2164
2165 ///@}
2166
2167 //
2168 //
2169 // -------------------------------------------------------------------------
2170 //
2171 //
2172
2173 /// \name Extra Semantic Checking
2174 /// Implementations are in SemaChecking.cpp
2175 ///@{
2176
2177public:
2178 /// Used to change context to isConstantEvaluated without pushing a heavy
2179 /// ExpressionEvaluationContextRecord object.
2181
2185 }
2186
2188 unsigned ByteNo) const;
2189
2191 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2192 FAPK_Variadic, // values to format are passed as variadic arguments
2193 FAPK_VAList, // values to format are passed in a va_list
2194 };
2195
2196 // Used to grab the relevant information from a FormatAttr and a
2197 // FunctionDeclaration.
2199 unsigned FormatIdx;
2202 };
2203
2204 /// Given a FunctionDecl's FormatAttr, attempts to populate the
2205 /// FomatStringInfo parameter with the FormatAttr's correct format_idx and
2206 /// firstDataArg. Returns true when the format fits the function and the
2207 /// FormatStringInfo has been populated.
2208 static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
2209 bool IsVariadic, FormatStringInfo *FSI);
2210
2211 // Used by C++ template instantiation.
2213
2214 /// ConvertVectorExpr - Handle __builtin_convertvector
2216 SourceLocation BuiltinLoc,
2217 SourceLocation RParenLoc);
2218
2232 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2233
2234 bool FormatStringHasSArg(const StringLiteral *FExpr);
2235
2236 /// Check for comparisons of floating-point values using == and !=. Issue a
2237 /// warning if the comparison is not likely to do what the programmer
2238 /// intended.
2240 BinaryOperatorKind Opcode);
2241
2242 /// Register a magic integral constant to be used as a type tag.
2243 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2244 uint64_t MagicValue, QualType Type,
2245 bool LayoutCompatible, bool MustBeNull);
2246
2249
2253
2255
2256 /// If true, \c Type should be compared with other expression's types for
2257 /// layout-compatibility.
2258 LLVM_PREFERRED_TYPE(bool)
2260 LLVM_PREFERRED_TYPE(bool)
2261 unsigned MustBeNull : 1;
2262 };
2263
2264 /// A pair of ArgumentKind identifier and magic value. This uniquely
2265 /// identifies the magic value.
2266 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2267
2268 /// Diagnoses the current set of gathered accesses. This typically
2269 /// happens at full expression level. The set is cleared after emitting the
2270 /// diagnostics.
2272
2273 /// This function checks if the expression is in the sef of potentially
2274 /// misaligned members and it is converted to some pointer type T with lower
2275 /// or equal alignment requirements. If so it removes it. This is used when
2276 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2277 /// void*).
2279
2280 /// This function calls Action when it determines that E designates a
2281 /// misaligned member due to the packed attribute. This is used to emit
2282 /// local diagnostics like in reference binding.
2284 Expr *E,
2285 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2286 Action);
2287
2288 enum class AtomicArgumentOrder { API, AST };
2290 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2291 SourceLocation RParenLoc, MultiExprArg Args,
2294
2295 /// Check to see if a given expression could have '.c_str()' called on it.
2296 bool hasCStrMethod(const Expr *E);
2297
2298 /// Diagnose pointers that are always non-null.
2299 /// \param E the expression containing the pointer
2300 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2301 /// compared to a null pointer
2302 /// \param IsEqual True when the comparison is equal to a null pointer
2303 /// \param Range Extra SourceRange to highlight in the diagnostic
2306 bool IsEqual, SourceRange Range);
2307
2308 /// CheckParmsForFunctionDef - Check that the parameters of the given
2309 /// function are appropriate for the definition of a function. This
2310 /// takes care of any checks that cannot be performed on the
2311 /// declaration itself, e.g., that the types of each of the function
2312 /// parameters are complete.
2314 bool CheckParameterNames);
2315
2316 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2317 /// pointer cast increases the alignment requirements.
2318 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2319
2320 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2321 /// to weak/__unsafe_unretained type.
2323
2324 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2325 /// to weak/__unsafe_unretained expression.
2327
2328 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2329 /// statement as a \p Body, and it is located on the same line.
2330 ///
2331 /// This helps prevent bugs due to typos, such as:
2332 /// if (condition);
2333 /// do_stuff();
2334 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2335 unsigned DiagID);
2336
2337 /// Warn if a for/while loop statement \p S, which is followed by
2338 /// \p PossibleBody, has a suspicious null statement as a body.
2339 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2340
2341 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2342 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2343 SourceLocation OpLoc);
2344
2345 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
2353
2354 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2356 const TypeSourceInfo *Derived);
2357
2358 /// CheckFunctionCall - Check a direct function call for various correctness
2359 /// and safety properties not strictly enforced by the C type system.
2360 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2361 const FunctionProtoType *Proto);
2362
2363 bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res);
2364 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2365
2366 /// Handles the checks for format strings, non-POD arguments to vararg
2367 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2368 /// attributes and AArch64 SME attributes.
2369 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2370 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2371 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2372 VariadicCallType CallType);
2373
2374 /// \brief Enforce the bounds of a TCB
2375 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2376 /// directly calls other functions in the same TCB as marked by the
2377 /// enforce_tcb and enforce_tcb_leaf attributes.
2378 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2379 const NamedDecl *Callee);
2380
2381 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2382
2383 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2384 /// TheCall is a constant expression.
2385 bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result);
2386
2387 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2388 /// TheCall is a constant expression in the range [Low, High].
2389 bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High,
2390 bool RangeIsError = true);
2391
2392 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2393 /// TheCall is a constant expression is a multiple of Num..
2394 bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
2395 unsigned Multiple);
2396
2397 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2398 /// constant expression representing a power of 2.
2399 bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum);
2400
2401 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2402 /// a constant expression representing an arbitrary byte value shifted left by
2403 /// a multiple of 8 bits.
2404 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
2405 unsigned ArgBits);
2406
2407 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2408 /// TheCall is a constant expression representing either a shifted byte value,
2409 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2410 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2411 /// Arm MVE intrinsics.
2412 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
2413 unsigned ArgBits);
2414
2415 /// Checks that a call expression's argument count is at least the desired
2416 /// number. This is useful when doing custom type-checking on a variadic
2417 /// function. Returns true on error.
2418 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2419
2420 /// Checks that a call expression's argument count is at most the desired
2421 /// number. This is useful when doing custom type-checking on a variadic
2422 /// function. Returns true on error.
2423 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2424
2425 /// Checks that a call expression's argument count is in the desired range.
2426 /// This is useful when doing custom type-checking on a variadic function.
2427 /// Returns true on error.
2428 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2429 unsigned MaxArgCount);
2430
2431 /// Checks that a call expression's argument count is the desired number.
2432 /// This is useful when doing custom type-checking. Returns true on error.
2433 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2434
2435 /// Returns true if the argument consists of one contiguous run of 1s with any
2436 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2437 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2438 /// since all 1s are not contiguous.
2439 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2440
2442 bool *ICContext = nullptr,
2443 bool IsListInit = false);
2444
2446 bool CheckForFloatArgs = true);
2448
2449private:
2450 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2451 const ArraySubscriptExpr *ASE = nullptr,
2452 bool AllowOnePastEnd = true, bool IndexNegated = false);
2453 void CheckArrayAccess(const Expr *E);
2454
2455 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2456 const FunctionProtoType *Proto);
2457
2458 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
2459 /// such as function pointers returned from functions.
2460 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2461
2462 /// CheckConstructorCall - Check a constructor call for correctness and safety
2463 /// properties not enforced by the C type system.
2464 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2466 const FunctionProtoType *Proto, SourceLocation Loc);
2467
2468 /// Warn if a pointer or reference argument passed to a function points to an
2469 /// object that is less aligned than the parameter. This can happen when
2470 /// creating a typedef with a lower alignment than the original type and then
2471 /// calling functions defined in terms of the original type.
2472 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2473 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2474
2475 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2476
2477 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2478 CallExpr *TheCall);
2479
2480 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2481 CallExpr *TheCall);
2482
2483 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2484
2485 /// Check the arguments to '__builtin_va_start' or '__builtin_ms_va_start'
2486 /// for validity. Emit an error and return true on failure; return false
2487 /// on success.
2488 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2489 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2490
2491 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
2492 /// friends. This is declared to take (...), so we have to check everything.
2493 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2494
2495 /// BuiltinSemaBuiltinFPClassification - Handle functions like
2496 /// __builtin_isnan and friends. This is declared to take (...), so we have
2497 /// to check everything.
2498 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2499 unsigned BuiltinID);
2500
2501 /// Perform semantic analysis for a call to __builtin_complex.
2502 bool BuiltinComplex(CallExpr *TheCall);
2503 bool BuiltinOSLogFormat(CallExpr *TheCall);
2504
2505 /// BuiltinPrefetch - Handle __builtin_prefetch.
2506 /// This is declared to take (const void*, ...) and can take two
2507 /// optional constant int args.
2508 bool BuiltinPrefetch(CallExpr *TheCall);
2509
2510 /// Handle __builtin_alloca_with_align. This is declared
2511 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
2512 /// than 8.
2513 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2514
2515 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
2516 bool BuiltinArithmeticFence(CallExpr *TheCall);
2517
2518 /// BuiltinAssume - Handle __assume (MS Extension).
2519 /// __assume does not evaluate its arguments, and should warn if its argument
2520 /// has side effects.
2521 bool BuiltinAssume(CallExpr *TheCall);
2522
2523 /// Handle __builtin_assume_aligned. This is declared
2524 /// as (const void*, size_t, ...) and can take one optional constant int arg.
2525 bool BuiltinAssumeAligned(CallExpr *TheCall);
2526
2527 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
2528 /// This checks that the target supports __builtin_longjmp and
2529 /// that val is a constant 1.
2530 bool BuiltinLongjmp(CallExpr *TheCall);
2531
2532 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
2533 /// This checks that the target supports __builtin_setjmp.
2534 bool BuiltinSetjmp(CallExpr *TheCall);
2535
2536 /// We have a call to a function like __sync_fetch_and_add, which is an
2537 /// overloaded function based on the pointer type of its first argument.
2538 /// The main BuildCallExpr routines have already promoted the types of
2539 /// arguments because all of these calls are prototyped as void(...).
2540 ///
2541 /// This function goes through and does final semantic checking for these
2542 /// builtins, as well as generating any warnings.
2543 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2544
2545 /// BuiltinNontemporalOverloaded - We have a call to
2546 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
2547 /// overloaded function based on the pointer type of its last argument.
2548 ///
2549 /// This function goes through and does final semantic checking for these
2550 /// builtins.
2551 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2552 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2554
2555 bool BuiltinElementwiseMath(CallExpr *TheCall);
2556 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
2557
2558 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
2559
2560 // Matrix builtin handling.
2561 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
2562 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
2563 ExprResult CallResult);
2564 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
2565 ExprResult CallResult);
2566
2567 /// CheckFormatArguments - Check calls to printf and scanf (and similar
2568 /// functions) for correct use of format strings.
2569 /// Returns true if a format string has been fully checked.
2570 bool CheckFormatArguments(const FormatAttr *Format,
2571 ArrayRef<const Expr *> Args, bool IsCXXMember,
2574 llvm::SmallBitVector &CheckedVarArgs);
2575 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
2576 FormatArgumentPassingKind FAPK, unsigned format_idx,
2577 unsigned firstDataArg, FormatStringType Type,
2579 SourceRange range,
2580 llvm::SmallBitVector &CheckedVarArgs);
2581
2582 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
2583
2584 /// Warn when using the wrong abs() function.
2585 void CheckAbsoluteValueFunction(const CallExpr *Call,
2586 const FunctionDecl *FDecl);
2587
2588 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
2589
2590 /// Check for dangerous or invalid arguments to memset().
2591 ///
2592 /// This issues warnings on known problematic, dangerous or unspecified
2593 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
2594 /// function calls.
2595 ///
2596 /// \param Call The call expression to diagnose.
2597 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
2598 IdentifierInfo *FnName);
2599
2600 // Warn if the user has made the 'size' argument to strlcpy or strlcat
2601 // be the size of the source, instead of the destination.
2602 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2603
2604 // Warn on anti-patterns as the 'size' argument to strncat.
2605 // The correct size argument should look like following:
2606 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
2607 void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2608
2609 /// Alerts the user that they are attempting to free a non-malloc'd object.
2610 void CheckFreeArguments(const CallExpr *E);
2611
2612 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
2613 SourceLocation ReturnLoc, bool isObjCMethod = false,
2614 const AttrVec *Attrs = nullptr,
2615 const FunctionDecl *FD = nullptr);
2616
2617 /// Diagnoses "dangerous" implicit conversions within the given
2618 /// expression (which is a full expression). Implements -Wconversion
2619 /// and -Wsign-compare.
2620 ///
2621 /// \param CC the "context" location of the implicit conversion, i.e.
2622 /// the most location of the syntactic entity requiring the implicit
2623 /// conversion
2624 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
2625
2626 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
2627 /// Input argument E is a logical expression.
2628 void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
2629
2630 /// Diagnose when expression is an integer constant expression and its
2631 /// evaluation results in integer overflow
2632 void CheckForIntOverflow(const Expr *E);
2633 void CheckUnsequencedOperations(const Expr *E);
2634
2635 /// Perform semantic checks on a completed expression. This will either
2636 /// be a full-expression or a default argument expression.
2637 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
2638 bool IsConstexpr = false);
2639
2640 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
2641 Expr *Init);
2642
2643 /// A map from magic value to type information.
2644 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
2645 TypeTagForDatatypeMagicValues;
2646
2647 /// Peform checks on a call of a function with argument_with_type_tag
2648 /// or pointer_with_type_tag attributes.
2649 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
2650 const ArrayRef<const Expr *> ExprArgs,
2651 SourceLocation CallSiteLoc);
2652
2653 /// Check if we are taking the address of a packed field
2654 /// as this may be a problem if the pointer value is dereferenced.
2655 void CheckAddressOfPackedMember(Expr *rhs);
2656
2657 /// Helper class that collects misaligned member designations and
2658 /// their location info for delayed diagnostics.
2659 struct MisalignedMember {
2660 Expr *E;
2661 RecordDecl *RD;
2662 ValueDecl *MD;
2663 CharUnits Alignment;
2664
2665 MisalignedMember() : E(), RD(), MD() {}
2666 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
2667 CharUnits Alignment)
2668 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
2669 explicit MisalignedMember(Expr *E)
2670 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
2671
2672 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
2673 };
2674 /// Small set of gathered accesses to potentially misaligned members
2675 /// due to the packed attribute.
2676 SmallVector<MisalignedMember, 4> MisalignedMembers;
2677
2678 /// Adds an expression to the set of gathered misaligned members.
2679 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
2680 CharUnits Alignment);
2681 ///@}
2682
2683 //
2684 //
2685 // -------------------------------------------------------------------------
2686 //
2687 //
2688
2689 /// \name C++ Coroutines
2690 /// Implementations are in SemaCoroutine.cpp
2691 ///@{
2692
2693public:
2694 /// The C++ "std::coroutine_traits" template, which is defined in
2695 /// <coroutine_traits>
2697
2699 StringRef Keyword);
2703
2706 UnresolvedLookupExpr *Lookup);
2708 Expr *Awaiter, bool IsImplicit = false);
2710 UnresolvedLookupExpr *Lookup);
2713 bool IsImplicit = false);
2718
2719 // As a clang extension, enforces that a non-coroutine function must be marked
2720 // with [[clang::coro_wrapper]] if it returns a type marked with
2721 // [[clang::coro_return_type]].
2722 // Expects that FD is not a coroutine.
2724 /// Lookup 'coroutine_traits' in std namespace and std::experimental
2725 /// namespace. The namespace found is recorded in Namespace.
2727 SourceLocation FuncLoc);
2728 /// Check that the expression co_await promise.final_suspend() shall not be
2729 /// potentially-throwing.
2730 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
2731
2732 ///@}
2733
2734 //
2735 //
2736 // -------------------------------------------------------------------------
2737 //
2738 //
2739
2740 /// \name C++ Scope Specifiers
2741 /// Implementations are in SemaCXXScopeSpec.cpp
2742 ///@{
2743
2744public:
2745 // Marks SS invalid if it represents an incomplete type.
2747 // Complete an enum decl, maybe without a scope spec.
2749 CXXScopeSpec *SS = nullptr);
2750
2751 /// Compute the DeclContext that is associated with the given type.
2752 ///
2753 /// \param T the type for which we are attempting to find a DeclContext.
2754 ///
2755 /// \returns the declaration context represented by the type T,
2756 /// or NULL if the declaration context cannot be computed (e.g., because it is
2757 /// dependent and not the current instantiation).
2759
2760 /// Compute the DeclContext that is associated with the given
2761 /// scope specifier.
2762 ///
2763 /// \param SS the C++ scope specifier as it appears in the source
2764 ///
2765 /// \param EnteringContext when true, we will be entering the context of
2766 /// this scope specifier, so we can retrieve the declaration context of a
2767 /// class template or class template partial specialization even if it is
2768 /// not the current instantiation.
2769 ///
2770 /// \returns the declaration context represented by the scope specifier @p SS,
2771 /// or NULL if the declaration context cannot be computed (e.g., because it is
2772 /// dependent and not the current instantiation).
2774 bool EnteringContext = false);
2776
2777 /// If the given nested name specifier refers to the current
2778 /// instantiation, return the declaration that corresponds to that
2779 /// current instantiation (C++0x [temp.dep.type]p1).
2780 ///
2781 /// \param NNS a dependent nested name specifier.
2783
2784 /// The parser has parsed a global nested-name-specifier '::'.
2785 ///
2786 /// \param CCLoc The location of the '::'.
2787 ///
2788 /// \param SS The nested-name-specifier, which will be updated in-place
2789 /// to reflect the parsed nested-name-specifier.
2790 ///
2791 /// \returns true if an error occurred, false otherwise.
2793
2794 /// The parser has parsed a '__super' nested-name-specifier.
2795 ///
2796 /// \param SuperLoc The location of the '__super' keyword.
2797 ///
2798 /// \param ColonColonLoc The location of the '::'.
2799 ///
2800 /// \param SS The nested-name-specifier, which will be updated in-place
2801 /// to reflect the parsed nested-name-specifier.
2802 ///
2803 /// \returns true if an error occurred, false otherwise.
2805 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
2806
2807 /// Determines whether the given declaration is an valid acceptable
2808 /// result for name lookup of a nested-name-specifier.
2809 /// \param SD Declaration checked for nested-name-specifier.
2810 /// \param IsExtension If not null and the declaration is accepted as an
2811 /// extension, the pointed variable is assigned true.
2813 bool *CanCorrect = nullptr);
2814
2815 /// If the given nested-name-specifier begins with a bare identifier
2816 /// (e.g., Base::), perform name lookup for that identifier as a
2817 /// nested-name-specifier within the given scope, and return the result of
2818 /// that name lookup.
2820
2821 /// Keeps information about an identifier in a nested-name-spec.
2822 ///
2824 /// The type of the object, if we're parsing nested-name-specifier in
2825 /// a member access expression.
2827
2828 /// The identifier preceding the '::'.
2830
2831 /// The location of the identifier.
2833
2834 /// The location of the '::'.
2836
2837 /// Creates info object for the most typical case.
2839 SourceLocation ColonColonLoc,
2840 ParsedType ObjectType = ParsedType())
2841 : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
2842 CCLoc(ColonColonLoc) {}
2843
2845 SourceLocation ColonColonLoc, QualType ObjectType)
2846 : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
2847 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
2848 };
2849
2850 /// Build a new nested-name-specifier for "identifier::", as described
2851 /// by ActOnCXXNestedNameSpecifier.
2852 ///
2853 /// \param S Scope in which the nested-name-specifier occurs.
2854 /// \param IdInfo Parser information about an identifier in the
2855 /// nested-name-spec.
2856 /// \param EnteringContext If true, enter the context specified by the
2857 /// nested-name-specifier.
2858 /// \param SS Optional nested name specifier preceding the identifier.
2859 /// \param ScopeLookupResult Provides the result of name lookup within the
2860 /// scope of the nested-name-specifier that was computed at template
2861 /// definition time.
2862 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
2863 /// error recovery and what kind of recovery is performed.
2864 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
2865 /// are allowed. The bool value pointed by this parameter is set to
2866 /// 'true' if the identifier is treated as if it was followed by ':',
2867 /// not '::'.
2868 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2869 ///
2870 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
2871 /// that it contains an extra parameter \p ScopeLookupResult, which provides
2872 /// the result of name lookup within the scope of the nested-name-specifier
2873 /// that was computed at template definition time.
2874 ///
2875 /// If ErrorRecoveryLookup is true, then this call is used to improve error
2876 /// recovery. This means that it should not emit diagnostics, it should
2877 /// just return true on failure. It also means it should only return a valid
2878 /// scope if it *knows* that the result is correct. It should not return in a
2879 /// dependent context, for example. Nor will it extend \p SS with the scope
2880 /// specifier.
2881 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2882 bool EnteringContext, CXXScopeSpec &SS,
2883 NamedDecl *ScopeLookupResult,
2884 bool ErrorRecoveryLookup,
2885 bool *IsCorrectedToColon = nullptr,
2886 bool OnlyNamespace = false);
2887
2888 /// The parser has parsed a nested-name-specifier 'identifier::'.
2889 ///
2890 /// \param S The scope in which this nested-name-specifier occurs.
2891 ///
2892 /// \param IdInfo Parser information about an identifier in the
2893 /// nested-name-spec.
2894 ///
2895 /// \param EnteringContext Whether we're entering the context nominated by
2896 /// this nested-name-specifier.
2897 ///
2898 /// \param SS The nested-name-specifier, which is both an input
2899 /// parameter (the nested-name-specifier before this type) and an
2900 /// output parameter (containing the full nested-name-specifier,
2901 /// including this new type).
2902 ///
2903 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
2904 /// are allowed. The bool value pointed by this parameter is set to 'true'
2905 /// if the identifier is treated as if it was followed by ':', not '::'.
2906 ///
2907 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2908 ///
2909 /// \returns true if an error occurred, false otherwise.
2910 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2911 bool EnteringContext, CXXScopeSpec &SS,
2912 bool *IsCorrectedToColon = nullptr,
2913 bool OnlyNamespace = false);
2914
2915 /// The parser has parsed a nested-name-specifier
2916 /// 'template[opt] template-name < template-args >::'.
2917 ///
2918 /// \param S The scope in which this nested-name-specifier occurs.
2919 ///
2920 /// \param SS The nested-name-specifier, which is both an input
2921 /// parameter (the nested-name-specifier before this type) and an
2922 /// output parameter (containing the full nested-name-specifier,
2923 /// including this new type).
2924 ///
2925 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
2926 /// \param TemplateName the template name.
2927 /// \param TemplateNameLoc The location of the template name.
2928 /// \param LAngleLoc The location of the opening angle bracket ('<').
2929 /// \param TemplateArgs The template arguments.
2930 /// \param RAngleLoc The location of the closing angle bracket ('>').
2931 /// \param CCLoc The location of the '::'.
2932 ///
2933 /// \param EnteringContext Whether we're entering the context of the
2934 /// nested-name-specifier.
2935 ///
2936 ///
2937 /// \returns true if an error occurred, false otherwise.
2939 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
2940 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
2941 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
2942 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
2943
2945 SourceLocation ColonColonLoc);
2946
2948 const DeclSpec &DS,
2949 SourceLocation ColonColonLoc,
2950 QualType Type);
2951
2952 /// IsInvalidUnlessNestedName - This method is used for error recovery
2953 /// purposes to determine whether the specified identifier is only valid as
2954 /// a nested name specifier, for example a namespace name. It is
2955 /// conservatively correct to always return false from this method.
2956 ///
2957 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
2959 NestedNameSpecInfo &IdInfo,
2960 bool EnteringContext);
2961
2962 /// Given a C++ nested-name-specifier, produce an annotation value
2963 /// that the parser can use later to reconstruct the given
2964 /// nested-name-specifier.
2965 ///
2966 /// \param SS A nested-name-specifier.
2967 ///
2968 /// \returns A pointer containing all of the information in the
2969 /// nested-name-specifier \p SS.
2971
2972 /// Given an annotation pointer for a nested-name-specifier, restore
2973 /// the nested-name-specifier structure.
2974 ///
2975 /// \param Annotation The annotation pointer, produced by
2976 /// \c SaveNestedNameSpecifierAnnotation().
2977 ///
2978 /// \param AnnotationRange The source range corresponding to the annotation.
2979 ///
2980 /// \param SS The nested-name-specifier that will be updated with the contents
2981 /// of the annotation pointer.
2982 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
2983 SourceRange AnnotationRange,
2984 CXXScopeSpec &SS);
2985
2986 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2987
2988 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2989 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2990 /// After this method is called, according to [C++ 3.4.3p3], names should be
2991 /// looked up in the declarator-id's scope, until the declarator is parsed and
2992 /// ActOnCXXExitDeclaratorScope is called.
2993 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2995
2996 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2997 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2998 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2999 /// Used to indicate that names should revert to being looked up in the
3000 /// defining scope.
3002
3003 ///@}
3004
3005 //
3006 //
3007 // -------------------------------------------------------------------------
3008 //
3009 //
3010
3011 /// \name Declarations
3012 /// Implementations are in SemaDecl.cpp
3013 ///@{
3014
3015public:
3017
3018 /// The index of the first InventedParameterInfo that refers to the current
3019 /// context.
3021
3022 /// A RAII object to temporarily push a declaration context.
3024 private:
3025 Sema &S;
3026 DeclContext *SavedContext;
3027 ProcessingContextState SavedContextState;
3028 QualType SavedCXXThisTypeOverride;
3029 unsigned SavedFunctionScopesStart;
3030 unsigned SavedInventedParameterInfosStart;
3031
3032 public:
3033 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3034 : S(S), SavedContext(S.CurContext),
3035 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3036 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3037 SavedFunctionScopesStart(S.FunctionScopesStart),
3038 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3039 assert(ContextToPush && "pushing null context");
3040 S.CurContext = ContextToPush;
3041 if (NewThisContext)
3042 S.CXXThisTypeOverride = QualType();
3043 // Any saved FunctionScopes do not refer to this context.
3044 S.FunctionScopesStart = S.FunctionScopes.size();
3045 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3046 }
3047
3048 void pop() {
3049 if (!SavedContext)
3050 return;
3051 S.CurContext = SavedContext;
3052 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3053 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3054 S.FunctionScopesStart = SavedFunctionScopesStart;
3055 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3056 SavedContext = nullptr;
3057 }
3058
3059 ~ContextRAII() { pop(); }
3060 };
3061
3062 void DiagnoseInvalidJumps(Stmt *Body);
3063
3064 /// The function definitions which were renamed as part of typo-correction
3065 /// to match their respective declarations. We want to keep track of them
3066 /// to ensure that we don't emit a "redefinition" error if we encounter a
3067 /// correctly named definition after the renamed definition.
3069
3070 /// A cache of the flags available in enumerations with the flag_bits
3071 /// attribute.
3072 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3073
3074 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3075 /// declared. Rare. May alias another identifier, declared or undeclared.
3076 ///
3077 /// For aliases, the target identifier is used as a key for eventual
3078 /// processing when the target is declared. For the single-identifier form,
3079 /// the sole identifier is used as the key. Each entry is a `SetVector`
3080 /// (ordered by parse order) of aliases (identified by the alias name) in case
3081 /// of multiple aliases to the same undeclared identifier.
3082 llvm::MapVector<
3084 llvm::SetVector<
3086 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3088
3089 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3090 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3091 /// to define functions that occur in multiple standards to call the version
3092 /// in the currently selected standard.
3093 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
3094
3095 /// Set containing all typedefs that are likely unused.
3098
3102
3103 /// The set of file scoped decls seen so far that have not been used
3104 /// and must warn if not used. Only contains the first declaration.
3106
3110
3111 /// All the tentative definitions encountered in the TU.
3113
3114 /// All the external declarations encoutered and used in the TU.
3116
3117 /// Generally null except when we temporarily switch decl contexts,
3118 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3120
3121 /// Is the module scope we are in a C++ Header Unit?
3123 return ModuleScopes.empty() ? false
3124 : ModuleScopes.back().Module->isHeaderUnit();
3125 }
3126
3127 /// Get the module owning an entity.
3128 Module *getOwningModule(const Decl *Entity) {
3129 return Entity->getOwningModule();
3130 }
3131
3132 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3133
3134 /// If the identifier refers to a type name within this scope,
3135 /// return the declaration of that type.
3136 ///
3137 /// This routine performs ordinary name lookup of the identifier II
3138 /// within the given scope, with optional C++ scope specifier SS, to
3139 /// determine whether the name refers to a type. If so, returns an
3140 /// opaque pointer (actually a QualType) corresponding to that
3141 /// type. Otherwise, returns NULL.
3143 Scope *S, CXXScopeSpec *SS = nullptr,
3144 bool isClassName = false, bool HasTrailingDot = false,
3145 ParsedType ObjectType = nullptr,
3146 bool IsCtorOrDtorName = false,
3147 bool WantNontrivialTypeSourceInfo = false,
3148 bool IsClassTemplateDeductionContext = true,
3149 ImplicitTypenameContext AllowImplicitTypename =
3151 IdentifierInfo **CorrectedII = nullptr);
3152
3153 /// isTagName() - This method is called *for error recovery purposes only*
3154 /// to determine if the specified name is a valid tag name ("struct foo"). If
3155 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3156 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3157 /// diagnose cases in C where the user forgot to specify the tag.
3159
3160 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3161 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3162 /// then downgrade the missing typename error to a warning.
3163 /// This is needed for MSVC compatibility; Example:
3164 /// @code
3165 /// template<class T> class A {
3166 /// public:
3167 /// typedef int TYPE;
3168 /// };
3169 /// template<class T> class B : public A<T> {
3170 /// public:
3171 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3172 /// };
3173 /// @endcode
3174 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3176 Scope *S, CXXScopeSpec *SS,
3177 ParsedType &SuggestedType,
3178 bool IsTemplateName = false);
3179
3180 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3181 /// type name has failed in a dependent context. In these situations, we
3182 /// automatically form a DependentTypeName that will retry lookup in a related
3183 /// scope during instantiation.
3185 SourceLocation NameLoc,
3186 bool IsTemplateTypeArg);
3187
3188 /// Describes the result of the name lookup and resolution performed
3189 /// by \c ClassifyName().
3191 /// This name is not a type or template in this context, but might be
3192 /// something else.
3194 /// Classification failed; an error has been produced.
3196 /// The name has been typo-corrected to a keyword.
3198 /// The name was classified as a type.
3200 /// The name was classified as a specific non-type, non-template
3201 /// declaration. ActOnNameClassifiedAsNonType should be called to
3202 /// convert the declaration to an expression.
3204 /// The name was classified as an ADL-only function name.
3205 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
3206 /// result to an expression.
3208 /// The name denotes a member of a dependent type that could not be
3209 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
3210 /// convert the result to an expression.
3212 /// The name was classified as an overload set, and an expression
3213 /// representing that overload set has been formed.
3214 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
3215 /// expression referencing the overload set.
3217 /// The name was classified as a template whose specializations are types.
3219 /// The name was classified as a variable template name.
3221 /// The name was classified as a function template name.
3223 /// The name was classified as an ADL-only function template name.
3225 /// The name was classified as a concept name.
3227 };
3228
3231 union {
3236 };
3237
3239
3240 public:
3242
3243 NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
3244
3245 static NameClassification Error() { return NameClassification(NC_Error); }
3246
3248 return NameClassification(NC_Unknown);
3249 }
3250
3252 NameClassification Result(NC_OverloadSet);
3253 Result.Expr = E;
3254 return Result;
3255 }
3256
3258 NameClassification Result(NC_NonType);
3259 Result.NonTypeDecl = D;
3260 return Result;
3261 }
3262
3264 return NameClassification(NC_UndeclaredNonType);
3265 }
3266
3268 return NameClassification(NC_DependentNonType);
3269 }
3270
3272 NameClassification Result(NC_TypeTemplate);
3273 Result.Template = Name;
3274 return Result;
3275 }
3276
3278 NameClassification Result(NC_VarTemplate);
3279 Result.Template = Name;
3280 return Result;
3281 }
3282
3284 NameClassification Result(NC_FunctionTemplate);
3285 Result.Template = Name;
3286 return Result;
3287 }
3288
3290 NameClassification Result(NC_Concept);
3291 Result.Template = Name;
3292 return Result;
3293 }
3294
3296 NameClassification Result(NC_UndeclaredTemplate);
3297 Result.Template = Name;
3298 return Result;
3299 }
3300
3302
3304 assert(Kind == NC_OverloadSet);
3305 return Expr;
3306 }
3307
3309 assert(Kind == NC_Type);
3310 return Type;
3311 }
3312
3314 assert(Kind == NC_NonType);
3315 return NonTypeDecl;
3316 }
3317
3319 assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
3320 Kind == NC_VarTemplate || Kind == NC_Concept ||
3321 Kind == NC_UndeclaredTemplate);
3322 return Template;
3323 }
3324
3326 switch (Kind) {
3327 case NC_TypeTemplate:
3328 return TNK_Type_template;
3329 case NC_FunctionTemplate:
3330 return TNK_Function_template;
3331 case NC_VarTemplate:
3332 return TNK_Var_template;
3333 case NC_Concept:
3334 return TNK_Concept_template;
3335 case NC_UndeclaredTemplate:
3337 default:
3338 llvm_unreachable("unsupported name classification.");
3339 }
3340 }
3341 };
3342
3343 /// Perform name lookup on the given name, classifying it based on
3344 /// the results of name lookup and the following token.
3345 ///
3346 /// This routine is used by the parser to resolve identifiers and help direct
3347 /// parsing. When the identifier cannot be found, this routine will attempt
3348 /// to correct the typo and classify based on the resulting name.
3349 ///
3350 /// \param S The scope in which we're performing name lookup.
3351 ///
3352 /// \param SS The nested-name-specifier that precedes the name.
3353 ///
3354 /// \param Name The identifier. If typo correction finds an alternative name,
3355 /// this pointer parameter will be updated accordingly.
3356 ///
3357 /// \param NameLoc The location of the identifier.
3358 ///
3359 /// \param NextToken The token following the identifier. Used to help
3360 /// disambiguate the name.
3361 ///
3362 /// \param CCC The correction callback, if typo correction is desired.
3363 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3364 IdentifierInfo *&Name, SourceLocation NameLoc,
3365 const Token &NextToken,
3366 CorrectionCandidateCallback *CCC = nullptr);
3367
3368 /// Act on the result of classifying a name as an undeclared (ADL-only)
3369 /// non-type declaration.
3371 SourceLocation NameLoc);
3372 /// Act on the result of classifying a name as an undeclared member of a
3373 /// dependent base class.
3375 IdentifierInfo *Name,
3376 SourceLocation NameLoc,
3377 bool IsAddressOfOperand);
3378 /// Act on the result of classifying a name as a specific non-type
3379 /// declaration.
3382 SourceLocation NameLoc,
3383 const Token &NextToken);
3384 /// Act on the result of classifying a name as an overload set.
3386
3387 /// Describes the detailed kind of a template name. Used in diagnostics.
3394 Concept,
3396 };
3399
3400 /// Determine whether it's plausible that E was intended to be a
3401 /// template-name.
3403 if (!getLangOpts().CPlusPlus || E.isInvalid())
3404 return false;
3405 Dependent = false;
3406 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3407 return !DRE->hasExplicitTemplateArgs();
3408 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3409 return !ME->hasExplicitTemplateArgs();
3410 Dependent = true;
3411 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3412 return !DSDRE->hasExplicitTemplateArgs();
3413 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3414 return !DSME->hasExplicitTemplateArgs();
3415 // Any additional cases recognized here should also be handled by
3416 // diagnoseExprIntendedAsTemplateName.
3417 return false;
3418 }
3419
3421
3423
3425 MultiTemplateParamsArg TemplateParameterLists);
3426
3427 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3428 /// true if we were successful.
3431 unsigned FailedFoldDiagID);
3432
3433 /// Register the given locally-scoped extern "C" declaration so
3434 /// that it can be found later for redeclarations. We include any extern "C"
3435 /// declaration that is not visible in the translation unit here, not just
3436 /// function-scope declarations.
3438
3439 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3440 /// If T is the name of a class, then each of the following shall have a
3441 /// name different from T:
3442 /// - every static data member of class T;
3443 /// - every member function of class T
3444 /// - every member of class T that is itself a type;
3445 /// \returns true if the declaration name violates these rules.
3447
3448 /// Diagnose a declaration whose declarator-id has the given
3449 /// nested-name-specifier.
3450 ///
3451 /// \param SS The nested-name-specifier of the declarator-id.
3452 ///
3453 /// \param DC The declaration context to which the nested-name-specifier
3454 /// resolves.
3455 ///
3456 /// \param Name The name of the entity being declared.
3457 ///
3458 /// \param Loc The location of the name of the entity being declared.
3459 ///
3460 /// \param IsMemberSpecialization Whether we are declaring a member
3461 /// specialization.
3462 ///
3463 /// \param TemplateId The template-id, if any.
3464 ///
3465 /// \returns true if we cannot safely recover from this error, false
3466 /// otherwise.
3469 TemplateIdAnnotation *TemplateId,
3470 bool IsMemberSpecialization);
3471
3473
3474 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
3475
3476 /// Diagnose function specifiers on a declaration of an identifier that
3477 /// does not identify a function.
3478 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
3479
3480 /// Return the declaration shadowed by the given typedef \p D, or null
3481 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3483 const LookupResult &R);
3484
3485 /// Return the declaration shadowed by the given variable \p D, or null
3486 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3488
3489 /// Return the declaration shadowed by the given variable \p D, or null
3490 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3492 const LookupResult &R);
3493 /// Diagnose variable or built-in function shadowing. Implements
3494 /// -Wshadow.
3495 ///
3496 /// This method is called whenever a VarDecl is added to a "useful"
3497 /// scope.
3498 ///
3499 /// \param ShadowedDecl the declaration that is shadowed by the given variable
3500 /// \param R the lookup of the name
3501 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
3502 const LookupResult &R);
3503
3504 /// Check -Wshadow without the advantage of a previous lookup.
3505 void CheckShadow(Scope *S, VarDecl *D);
3506
3507 /// Warn if 'E', which is an expression that is about to be modified, refers
3508 /// to a shadowing declaration.
3510
3511 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
3512 /// when these variables are captured by the lambda.
3514
3515 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
3516 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
3517 TypedefNameDecl *NewTD);
3520 TypeSourceInfo *TInfo,
3522
3523 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
3524 /// declares a typedef-name, either using the 'typedef' type specifier or via
3525 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
3527 LookupResult &Previous, bool &Redeclaration);
3529 Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo,
3530 LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists,
3531 bool &AddToScope, ArrayRef<BindingDecl *> Bindings = std::nullopt);
3532
3533 /// Perform semantic checking on a newly-created variable
3534 /// declaration.
3535 ///
3536 /// This routine performs all of the type-checking required for a
3537 /// variable declaration once it has been built. It is used both to
3538 /// check variables after they have been parsed and their declarators
3539 /// have been translated into a declaration, and to check variables
3540 /// that have been instantiated from a template.
3541 ///
3542 /// Sets NewVD->isInvalidDecl() if an error was encountered.
3543 ///
3544 /// Returns true if the variable declaration is a redeclaration.
3548
3550 TypeSourceInfo *TInfo,
3552 MultiTemplateParamsArg TemplateParamLists,
3553 bool &AddToScope);
3554
3555 /// AddOverriddenMethods - See if a method overrides any in the base classes,
3556 /// and if so, check that it's a valid override and remember it.
3558
3559 /// Perform semantic checking of a new function declaration.
3560 ///
3561 /// Performs semantic analysis of the new function declaration
3562 /// NewFD. This routine performs all semantic checking that does not
3563 /// require the actual declarator involved in the declaration, and is
3564 /// used both for the declaration of functions as they are parsed
3565 /// (called via ActOnDeclarator) and for the declaration of functions
3566 /// that have been instantiated via C++ template instantiation (called
3567 /// via InstantiateDecl).
3568 ///
3569 /// \param IsMemberSpecialization whether this new function declaration is
3570 /// a member specialization (that replaces any definition provided by the
3571 /// previous declaration).
3572 ///
3573 /// This sets NewFD->isInvalidDecl() to true if there was an error.
3574 ///
3575 /// \returns true if the function declaration is a redeclaration.
3578 bool IsMemberSpecialization, bool DeclIsDefn);
3579
3580 /// Checks if the new declaration declared in dependent context must be
3581 /// put in the same redeclaration chain as the specified declaration.
3582 ///
3583 /// \param D Declaration that is checked.
3584 /// \param PrevDecl Previous declaration found with proper lookup method for
3585 /// the same declaration name.
3586 /// \returns True if D must be added to the redeclaration chain which PrevDecl
3587 /// belongs to.
3589
3590 /// Determines if we can perform a correct type check for \p D as a
3591 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
3592 /// best-effort check.
3593 ///
3594 /// \param NewD The new declaration.
3595 /// \param OldD The old declaration.
3596 /// \param NewT The portion of the type of the new declaration to check.
3597 /// \param OldT The portion of the type of the old declaration to check.
3599 QualType NewT, QualType OldT);
3600 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
3602
3603 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
3604 /// containing class. Otherwise it will return implicit SectionAttr if the
3605 /// function is a definition and there is an active value on CodeSegStack
3606 /// (from the current #pragma code-seg value).
3607 ///
3608 /// \param FD Function being declared.
3609 /// \param IsDefinition Whether it is a definition or just a declaration.
3610 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
3611 /// nullptr if no attribute should be added.
3613 bool IsDefinition);
3614
3615 /// Common checks for a parameter-declaration that should apply to both
3616 /// function parameters and non-type template parameters.
3618
3619 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
3620 /// to introduce parameters into function prototype scope.
3622 SourceLocation ExplicitThisLoc = {});
3623
3624 /// Synthesizes a variable for a parameter arising from a
3625 /// typedef.
3626 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
3627 QualType T);
3628 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
3629 SourceLocation NameLoc,
3630 const IdentifierInfo *Name, QualType T,
3631 TypeSourceInfo *TSInfo, StorageClass SC);
3632
3633 // Contexts where using non-trivial C union types can be disallowed. This is
3634 // passed to err_non_trivial_c_union_in_invalid_context.
3636 // Function parameter.
3638 // Function return.
3640 // Default-initialized object.
3642 // Variable with automatic storage duration.
3644 // Initializer expression that might copy from another object.
3646 // Assignment.
3648 // Compound literal.
3650 // Block capture.
3652 // lvalue-to-rvalue conversion of volatile type.
3654 };
3655
3656 /// Emit diagnostics if the initializer or any of its explicit or
3657 /// implicitly-generated subexpressions require copying or
3658 /// default-initializing a type that is or contains a C union type that is
3659 /// non-trivial to copy or default-initialize.
3661
3662 // These flags are passed to checkNonTrivialCUnion.
3667 };
3668
3669 /// Emit diagnostics if a non-trivial C union type or a struct that contains
3670 /// a non-trivial C union is used in an invalid context.
3672 NonTrivialCUnionContext UseContext,
3673 unsigned NonTrivialKind);
3674
3675 /// AddInitializerToDecl - Adds the initializer Init to the
3676 /// declaration dcl. If DirectInit is true, this is C++ direct
3677 /// initialization rather than copy initialization.
3678 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
3679 void ActOnUninitializedDecl(Decl *dcl);
3680
3681 /// ActOnInitializerError - Given that there was an error parsing an
3682 /// initializer for the given declaration, try to at least re-establish
3683 /// invariants such as whether a variable's type is either dependent or
3684 /// complete.
3685 void ActOnInitializerError(Decl *Dcl);
3686
3689 IdentifierInfo *Ident,
3690 ParsedAttributes &Attrs);
3691
3692 /// Check if VD needs to be dllexport/dllimport due to being in a
3693 /// dllexport/import function.
3696
3697 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
3698 /// any semantic actions necessary after any initializer has been attached.
3699 void FinalizeDeclaration(Decl *D);
3701 ArrayRef<Decl *> Group);
3702
3703 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
3704 /// group, performing any necessary semantic checking.
3706
3707 /// Should be called on all declarations that might have attached
3708 /// documentation comments.
3711
3712 enum class FnBodyKind {
3713 /// C++26 [dcl.fct.def.general]p1
3714 /// function-body:
3715 /// ctor-initializer[opt] compound-statement
3716 /// function-try-block
3717 Other,
3718 /// = default ;
3719 Default,
3720 /// deleted-function-body
3721 ///
3722 /// deleted-function-body:
3723 /// = delete ;
3724 /// = delete ( unevaluated-string ) ;
3725 Delete
3726 };
3727
3729 SourceLocation LocAfterDecls);
3731 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
3732 SkipBodyInfo *SkipBody = nullptr);
3734 MultiTemplateParamsArg TemplateParamLists,
3735 SkipBodyInfo *SkipBody = nullptr,
3736 FnBodyKind BodyKind = FnBodyKind::Other);
3738 SkipBodyInfo *SkipBody = nullptr,
3739 FnBodyKind BodyKind = FnBodyKind::Other);
3741
3742 /// Determine whether we can delay parsing the body of a function or
3743 /// function template until it is used, assuming we don't care about emitting
3744 /// code for that function.
3745 ///
3746 /// This will be \c false if we may need the body of the function in the
3747 /// middle of parsing an expression (where it's impractical to switch to
3748 /// parsing a different function), for instance, if it's constexpr in C++11
3749 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
3750 bool canDelayFunctionBody(const Declarator &D);
3751
3752 /// Determine whether we can skip parsing the body of a function
3753 /// definition, assuming we don't care about analyzing its body or emitting
3754 /// code for that function.
3755 ///
3756 /// This will be \c false only if we may need the body of the function in
3757 /// order to parse the rest of the program (for instance, if it is
3758 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
3759 bool canSkipFunctionBody(Decl *D);
3760
3761 /// Given the set of return statements within a function body,
3762 /// compute the variables that are subject to the named return value
3763 /// optimization.
3764 ///
3765 /// Each of the variables that is subject to the named return value
3766 /// optimization will be marked as NRVO variables in the AST, and any
3767 /// return statement that has a marked NRVO variable as its NRVO candidate can
3768 /// use the named return value optimization.
3769 ///
3770 /// This function applies a very simplistic algorithm for NRVO: if every
3771 /// return statement in the scope of a variable has the same NRVO candidate,
3772 /// that candidate is an NRVO variable.
3775 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
3778
3779 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
3780 /// attribute for which parsing is delayed.
3782
3783 /// Diagnose any unused parameters in the given sequence of
3784 /// ParmVarDecl pointers.
3786
3787 /// Diagnose whether the size of parameters or return value of a
3788 /// function or obj-c method definition is pass-by-value and larger than a
3789 /// specified threshold.
3790 void
3792 QualType ReturnTy, NamedDecl *D);
3793
3795 SourceLocation RParenLoc);
3796
3799
3801
3802 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3803 /// no declarator (e.g. "struct foo;") is parsed.
3805 const ParsedAttributesView &DeclAttrs,
3806 RecordDecl *&AnonRecord);
3807
3808 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3809 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
3810 /// parameters to cope with template friend declarations.
3812 const ParsedAttributesView &DeclAttrs,
3813 MultiTemplateParamsArg TemplateParams,
3814 bool IsExplicitInstantiation,
3815 RecordDecl *&AnonRecord,
3816 SourceLocation EllipsisLoc = {});
3817
3818 /// BuildAnonymousStructOrUnion - Handle the declaration of an
3819 /// anonymous structure or union. Anonymous unions are a C++ feature
3820 /// (C++ [class.union]) and a C11 feature; anonymous structures
3821 /// are a C11 feature and GNU C++ extension.
3822 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
3823 RecordDecl *Record,
3824 const PrintingPolicy &Policy);
3825
3826 /// Called once it is known whether
3827 /// a tag declaration is an anonymous union or struct.
3829
3830 /// Emit diagnostic warnings for placeholder members.
3831 /// We can only do that after the class is fully constructed,
3832 /// as anonymous union/structs can insert placeholders
3833 /// in their parent scope (which might be a Record).
3835
3836 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
3837 /// Microsoft C anonymous structure.
3838 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
3839 /// Example:
3840 ///
3841 /// struct A { int a; };
3842 /// struct B { struct A; int b; };
3843 ///
3844 /// void foo() {
3845 /// B var;
3846 /// var.a = 3;
3847 /// }
3848 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
3849 RecordDecl *Record);
3850
3851 /// Common ways to introduce type names without a tag for use in diagnostics.
3852 /// Keep in sync with err_tag_reference_non_tag.
3863 };
3864
3865 /// Given a non-tag type declaration, returns an enum useful for indicating
3866 /// what kind of non-tag type this is.
3868
3869 /// Determine whether a tag with a given kind is acceptable
3870 /// as a redeclaration of the given tag declaration.
3871 ///
3872 /// \returns true if the new tag kind is acceptable, false otherwise.
3874 bool isDefinition, SourceLocation NewTagLoc,
3875 const IdentifierInfo *Name);
3876
3878 // Not parsing a type within __builtin_offsetof.
3880 // Parsing a type within __builtin_offsetof.
3882 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
3883 // To improve our diagnostic message.
3885 };
3886
3887 /// This is invoked when we see 'struct foo' or 'struct {'. In the
3888 /// former case, Name will be non-null. In the later case, Name will be null.
3889 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
3890 /// a reference/declaration/definition of a tag.
3891 ///
3892 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
3893 /// trailing-type-specifier) other than one in an alias-declaration.
3894 ///
3895 /// \param SkipBody If non-null, will be set to indicate if the caller should
3896 /// skip the definition of this tag and treat it as if it were a declaration.
3897 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
3898 SourceLocation KWLoc, CXXScopeSpec &SS,
3899 IdentifierInfo *Name, SourceLocation NameLoc,
3901 SourceLocation ModulePrivateLoc,
3902 MultiTemplateParamsArg TemplateParameterLists,
3903 bool &OwnedDecl, bool &IsDependent,
3904 SourceLocation ScopedEnumKWLoc,
3905 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
3906 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
3907 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
3908
3909 /// ActOnField - Each field of a C struct/union is passed into this in order
3910 /// to create a FieldDecl object for it.
3911 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
3912 Declarator &D, Expr *BitfieldWidth);
3913
3914 /// HandleField - Analyze a field of a C struct or a C++ data member.
3915 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
3916 Declarator &D, Expr *BitfieldWidth,
3917 InClassInitStyle InitStyle, AccessSpecifier AS);
3918
3919 /// Build a new FieldDecl and check its well-formedness.
3920 ///
3921 /// This routine builds a new FieldDecl given the fields name, type,
3922 /// record, etc. \p PrevDecl should refer to any previous declaration
3923 /// with the same name and in the same scope as the field to be
3924 /// created.
3925 ///
3926 /// \returns a new FieldDecl.
3927 ///
3928 /// \todo The Declarator argument is a hack. It will be removed once
3931 SourceLocation Loc, bool Mutable,
3932 Expr *BitfieldWidth, InClassInitStyle InitStyle,
3934 NamedDecl *PrevDecl, Declarator *D = nullptr);
3935
3937
3938 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
3939 /// class and class extensions. For every class \@interface and class
3940 /// extension \@interface, if the last ivar is a bitfield of any type,
3941 /// then add an implicit `char :0` ivar to the end of that interface.
3942 void ActOnLastBitfield(SourceLocation DeclStart,
3943 SmallVectorImpl<Decl *> &AllIvarDecls);
3944
3945 // This is used for both record definitions and ObjC interface declarations.
3946 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
3947 ArrayRef<Decl *> Fields, SourceLocation LBrac,
3948 SourceLocation RBrac, const ParsedAttributesView &AttrList);
3949
3950 /// ActOnTagStartDefinition - Invoked when we have entered the
3951 /// scope of a tag's definition (e.g., for an enumeration, class,
3952 /// struct, or union).
3954
3955 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
3956 /// Differently from C++, actually parse the body and reject / error out
3957 /// in case of a structural mismatch.
3958 bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody);
3959
3961
3962 /// Invoked when we enter a tag definition that we're skipping.
3964
3965 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
3966 /// C++ record definition's base-specifiers clause and are starting its
3967 /// member declarations.
3969 SourceLocation FinalLoc,
3970 bool IsFinalSpelledSealed,
3971 bool IsAbstract,
3972 SourceLocation LBraceLoc);
3973
3974 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
3975 /// the definition of a tag (enumeration, class, struct, or union).
3977 SourceRange BraceRange);
3978
3980
3981 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
3982 /// error parsing the definition of a tag.
3984
3986 EnumConstantDecl *LastEnumConst,
3988 Expr *val);
3989
3990 /// Check that this is a valid underlying type for an enum declaration.
3992
3993 /// Check whether this is a valid redeclaration of a previous enumeration.
3994 /// \return true if the redeclaration was invalid.
3995 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
3996 QualType EnumUnderlyingTy, bool IsFixed,
3997 const EnumDecl *Prev);
3998
3999 /// Determine whether the body of an anonymous enumeration should be skipped.
4000 /// \param II The name of the first enumerator.
4002 SourceLocation IILoc);
4003
4004 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
4006 const ParsedAttributesView &Attrs,
4007 SourceLocation EqualLoc, Expr *Val);
4008 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
4009 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
4010 const ParsedAttributesView &Attr);
4011
4012 /// Set the current declaration context until it gets popped.
4013 void PushDeclContext(Scope *S, DeclContext *DC);
4014 void PopDeclContext();
4015
4016 /// EnterDeclaratorContext - Used when we must lookup names in the context
4017 /// of a declarator's nested name specifier.
4020
4021 /// Enter a template parameter scope, after it's been associated with a
4022 /// particular DeclContext. Causes lookup within the scope to chain through
4023 /// enclosing contexts in the correct order.
4025
4026 /// Push the parameters of D, which must be a function, into scope.
4029
4030 /// Add this decl to the scope shadowed decl chains.
4031 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4032
4033 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4034 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4035 /// true if 'D' belongs to the given declaration context.
4036 ///
4037 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4038 /// enclosing namespace set of the context, rather than contained
4039 /// directly within it.
4040 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4041 bool AllowInlineNamespace = false) const;
4042
4043 /// Finds the scope corresponding to the given decl context, if it
4044 /// happens to be an enclosing scope. Otherwise return NULL.
4046
4047 /// Subroutines of ActOnDeclarator().
4049 TypeSourceInfo *TInfo);
4050 bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New);
4051
4052 /// Describes the kind of merge to perform for availability
4053 /// attributes (including "deprecated", "unavailable", and "availability").
4055 /// Don't merge availability attributes at all.
4057 /// Merge availability attributes for a redeclaration, which requires
4058 /// an exact match.
4060 /// Merge availability attributes for an override, which requires
4061 /// an exact match or a weakening of constraints.
4063 /// Merge availability attributes for an implementation of
4064 /// a protocol requirement.
4066 /// Merge availability attributes for an implementation of
4067 /// an optional protocol requirement.
4070
4071 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4072 void mergeDeclAttributes(NamedDecl *New, Decl *Old,
4074
4075 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4076 /// same name and scope as a previous declaration 'Old'. Figure out
4077 /// how to resolve this situation, merging decls or emitting
4078 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4080 LookupResult &OldDecls);
4081
4082 /// MergeFunctionDecl - We just parsed a function 'New' from
4083 /// declarator D which has the same name and scope as a previous
4084 /// declaration 'Old'. Figure out how to resolve this situation,
4085 /// merging decls or emitting diagnostics as appropriate.
4086 ///
4087 /// In C++, New and Old must be declarations that are not
4088 /// overloaded. Use IsOverload to determine whether New and Old are
4089 /// overloaded, and to select the Old declaration that New should be
4090 /// merged with.
4091 ///
4092 /// Returns true if there was an error, false otherwise.
4093 bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
4094 bool MergeTypeWithOld, bool NewDeclIsDefn);
4095
4096 /// Completes the merge of two function declarations that are
4097 /// known to be compatible.
4098 ///
4099 /// This routine handles the merging of attributes and other
4100 /// properties of function declarations from the old declaration to
4101 /// the new declaration, once we know that New is in fact a
4102 /// redeclaration of Old.
4103 ///
4104 /// \returns false
4106 Scope *S, bool MergeTypeWithOld);
4108
4109 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4110 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4111 /// situation, merging decls or emitting diagnostics as appropriate.
4112 ///
4113 /// Tentative definition rules (C99 6.9.2p2) are checked by
4114 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4115 /// definitions here, since the initializer hasn't been attached.
4117
4118 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4119 /// scope as a previous declaration 'Old'. Figure out how to merge their
4120 /// types, emitting diagnostics as appropriate.
4121 ///
4122 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4123 /// back to here in AddInitializerToDecl. We can't check them before the
4124 /// initializer is attached.
4125 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4126
4127 /// We've just determined that \p Old and \p New both appear to be definitions
4128 /// of the same variable. Either diagnose or fix the problem.
4129 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4130 void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
4131
4132 /// Filters out lookup results that don't fall within the given scope
4133 /// as determined by isDeclInScope.
4135 bool ConsiderLinkage, bool AllowInlineNamespace);
4136
4137 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4138 /// have compatible owning modules.
4140
4141 /// [module.interface]p6:
4142 /// A redeclaration of an entity X is implicitly exported if X was introduced
4143 /// by an exported declaration; otherwise it shall not be exported.
4145
4146 /// A wrapper function for checking the semantic restrictions of
4147 /// a redeclaration within a module.
4149
4150 /// Check the redefinition in C++20 Modules.
4151 ///
4152 /// [basic.def.odr]p14:
4153 /// For any definable item D with definitions in multiple translation units,
4154 /// - if D is a non-inline non-templated function or variable, or
4155 /// - if the definitions in different translation units do not satisfy the
4156 /// following requirements,
4157 /// the program is ill-formed; a diagnostic is required only if the
4158 /// definable item is attached to a named module and a prior definition is
4159 /// reachable at the point where a later definition occurs.
4160 /// - Each such definition shall not be attached to a named module
4161 /// ([module.unit]).
4162 /// - Each such definition shall consist of the same sequence of tokens, ...
4163 /// ...
4164 ///
4165 /// Return true if the redefinition is not allowed. Return false otherwise.
4166 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4167
4169
4170 /// If it's a file scoped decl that must warn if not used, keep track
4171 /// of it.
4173
4174 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4176
4179 DiagReceiverTy DiagReceiver);
4180 void DiagnoseUnusedDecl(const NamedDecl *ND);
4181
4182 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4183 /// unless they are marked attr(unused).
4184 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4185
4186 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4187 /// variable.
4188 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4189
4190 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4191 /// from S, where a non-field would be declared. This routine copes
4192 /// with the difference between C and C++ scoping rules in structs and
4193 /// unions. For example, the following code is well-formed in C but
4194 /// ill-formed in C++:
4195 /// @code
4196 /// struct S6 {
4197 /// enum { BAR } e;
4198 /// };
4199 ///
4200 /// void test_S6() {
4201 /// struct S6 a;
4202 /// a.e = BAR;
4203 /// }
4204 /// @endcode
4205 /// For the declaration of BAR, this routine will return a different
4206 /// scope. The scope S will be the scope of the unnamed enumeration
4207 /// within S6. In C++, this routine will return the scope associated
4208 /// with S6, because the enumeration's scope is a transparent
4209 /// context but structures can contain non-field names. In C, this
4210 /// routine will return the translation unit scope, since the
4211 /// enumeration's scope is a transparent context and structures cannot
4212 /// contain non-field names.
4214
4217
4218 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4219 /// file scope. lazily create a decl for it. ForRedeclaration is true
4220 /// if we're creating this built-in in anticipation of redeclaring the
4221 /// built-in.
4223 bool ForRedeclaration, SourceLocation Loc);
4224
4225 /// Get the outermost AttributedType node that sets a calling convention.
4226 /// Valid types should not have multiple attributes with different CCs.
4228
4229 /// GetNameForDeclarator - Determine the full declaration name for the
4230 /// given Declarator.
4232
4233 /// Retrieves the declaration name from a parsed unqualified-id.
4235
4236 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4237 /// we are currently parsing the initializer.
4239
4240 /// Look for a locally scoped extern "C" declaration by the given name.
4242
4244
4245 /// Adjust the \c DeclContext for a function or variable that might be a
4246 /// function-local external declaration.
4248
4250
4251 /// Checks if the variant/multiversion functions are compatible.
4253 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4254 const PartialDiagnostic &NoProtoDiagID,
4255 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4256 const PartialDiagnosticAt &NoSupportDiagIDAt,
4257 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4258 bool ConstexprSupported, bool CLinkageMayDiffer);
4259
4260 /// type checking declaration initializers (C99 6.7.8)
4262 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4263
4267 Expr *Init);
4268
4270 Expr *Init);
4271
4273
4274 // Heuristically tells if the function is `get_return_object` member of a
4275 // coroutine promise_type by matching the function name.
4276 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4277 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4278
4279 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4280 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4282 Scope *S);
4283
4284 /// If this function is a C++ replaceable global allocation function
4285 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4286 /// adds any function attributes that we know a priori based on the standard.
4287 ///
4288 /// We need to check for duplicate attributes both here and where user-written
4289 /// attributes are applied to declarations.
4291 FunctionDecl *FD);
4292
4293 /// Adds any function attributes that we know a priori based on
4294 /// the declaration of this function.
4295 ///
4296 /// These attributes can apply both to implicitly-declared builtins
4297 /// (like __builtin___printf_chk) or to library-declared functions
4298 /// like NSLog or printf.
4299 ///
4300 /// We need to check for duplicate attributes both here and where user-written
4301 /// attributes are applied to declarations.
4303
4304 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4305 /// the correct width, and that the field type is valid.
4306 /// Returns false on success.
4308 const IdentifierInfo *FieldName, QualType FieldTy,
4309 bool IsMsStruct, Expr *BitWidth);
4310
4311 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4312 /// enum. If AllowMask is true, then we also allow the complement of a valid
4313 /// value, to be used as a mask.
4314 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4315 bool AllowMask) const;
4316
4317 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4318 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4319 SourceLocation WeakNameLoc);
4320
4321 /// ActOnPragmaRedefineExtname - Called on well formed
4322 /// \#pragma redefine_extname oldname newname.
4324 IdentifierInfo *AliasName,
4325 SourceLocation PragmaLoc,
4326 SourceLocation WeakNameLoc,
4327 SourceLocation AliasNameLoc);
4328
4329 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4330 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4331 SourceLocation PragmaLoc,
4332 SourceLocation WeakNameLoc,
4333 SourceLocation AliasNameLoc);
4334
4335 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4337 Emitted,
4338 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4339 OMPDiscarded, // Discarded due to OpenMP hostness
4340 TemplateDiscarded, // Discarded due to uninstantiated templates
4341 Unknown,
4342 };
4343 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4344 bool Final = false);
4345
4346 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4348
4349private:
4350 /// Function or variable declarations to be checked for whether the deferred
4351 /// diagnostics should be emitted.
4352 llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
4353
4354 /// Map of current shadowing declarations to shadowed declarations. Warn if
4355 /// it looks like the user is trying to modify the shadowing declaration.
4356 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4357
4358 // We need this to handle
4359 //
4360 // typedef struct {
4361 // void *foo() { return 0; }
4362 // } A;
4363 //
4364 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4365 // for example. If 'A', foo will have external linkage. If we have '*A',
4366 // foo will have no linkage. Since we can't know until we get to the end
4367 // of the typedef, this function finds out if D might have non-external
4368 // linkage. Callers should verify at the end of the TU if it D has external
4369 // linkage or not.
4370 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4371
4372 ///@}
4373
4374 //
4375 //
4376 // -------------------------------------------------------------------------
4377 //
4378 //
4379
4380 /// \name Declaration Attribute Handling
4381 /// Implementations are in SemaDeclAttr.cpp
4382 ///@{
4383
4384public:
4385 /// Describes the kind of priority given to an availability attribute.
4386 ///
4387 /// The sum of priorities deteremines the final priority of the attribute.
4388 /// The final priority determines how the attribute will be merged.
4389 /// An attribute with a lower priority will always remove higher priority
4390 /// attributes for the specified platform when it is being applied. An
4391 /// attribute with a higher priority will not be applied if the declaration
4392 /// already has an availability attribute with a lower priority for the
4393 /// specified platform. The final prirority values are not expected to match
4394 /// the values in this enumeration, but instead should be treated as a plain
4395 /// integer value. This enumeration just names the priority weights that are
4396 /// used to calculate that final vaue.
4398 /// The availability attribute was specified explicitly next to the
4399 /// declaration.
4401
4402 /// The availability attribute was applied using '#pragma clang attribute'.
4404
4405 /// The availability attribute for a specific platform was inferred from
4406 /// an availability attribute for another platform.
4409
4410 /// Describes the reason a calling convention specification was ignored, used
4411 /// for diagnostics.
4413 ForThisTarget = 0,
4417 };
4418
4419 /// A helper function to provide Attribute Location for the Attr types
4420 /// AND the ParsedAttr.
4421 template <typename AttrInfo>
4422 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4423 getAttrLoc(const AttrInfo &AL) {
4424 return AL.getLocation();
4425 }
4427
4428 /// If Expr is a valid integer constant, get the value of the integer
4429 /// expression and return success or failure. May output an error.
4430 ///
4431 /// Negative argument is implicitly converted to unsigned, unless
4432 /// \p StrictlyUnsigned is true.
4433 template <typename AttrInfo>
4434 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4435 unsigned Idx = UINT_MAX,
4436 bool StrictlyUnsigned = false) {
4437 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4438 if (Expr->isTypeDependent() ||
4440 if (Idx != UINT_MAX)
4441 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4442 << &AI << Idx << AANT_ArgumentIntegerConstant
4443 << Expr->getSourceRange();
4444 else
4445 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4447 return false;
4448 }
4449
4450 if (!I->isIntN(32)) {
4451 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4452 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4453 return false;
4454 }
4455
4456 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
4457 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
4458 << &AI << /*non-negative*/ 1;
4459 return false;
4460 }
4461
4462 Val = (uint32_t)I->getZExtValue();
4463 return true;
4464 }
4465
4466 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
4467 /// \#pragma weak during processing of other Decls.
4468 /// I couldn't figure out a clean way to generate these in-line, so
4469 /// we store them here and handle separately -- which is a hack.
4470 /// It would be best to refactor this.
4472
4473 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
4475
4479
4480 /// ExtVectorDecls - This is a list all the extended vector types. This allows
4481 /// us to associate a raw vector type with one of the ext_vector type names.
4482 /// This is only necessary for issuing pretty diagnostics.
4484
4485 /// Check if the argument \p E is a ASCII string literal. If not emit an error
4486 /// and return false, otherwise set \p Str to the value of the string literal
4487 /// and return true.
4489 const Expr *E, StringRef &Str,
4490 SourceLocation *ArgLocation = nullptr);
4491
4492 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
4493 /// If not emit an error and return false. If the argument is an identifier it
4494 /// will emit an error with a fixit hint and treat it as if it was a string
4495 /// literal.
4496 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
4497 StringRef &Str,
4498 SourceLocation *ArgLocation = nullptr);
4499
4500 /// Determine if type T is a valid subject for a nonnull and similar
4501 /// attributes. By default, we look through references (the behavior used by
4502 /// nonnull), but if the second parameter is true, then we treat a reference
4503 /// type as valid.
4504 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
4505
4506 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
4507 /// declaration.
4509 Expr *OE);
4510
4511 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
4512 /// declaration.
4514 Expr *ParamExpr);
4515
4516 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
4517 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
4518
4519 AvailabilityAttr *mergeAvailabilityAttr(
4520 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform,
4521 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
4522 VersionTuple Obsoleted, bool IsUnavailable, StringRef Message,
4523 bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK,
4524 int Priority, IdentifierInfo *IIEnvironment);
4525
4526 TypeVisibilityAttr *
4528 TypeVisibilityAttr::VisibilityType Vis);
4529 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
4530 VisibilityAttr::VisibilityType Vis);
4531 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
4532 StringRef Name);
4533
4534 /// Used to implement to perform semantic checking on
4535 /// attribute((section("foo"))) specifiers.
4536 ///
4537 /// In this case, "foo" is passed in to be checked. If the section
4538 /// specifier is invalid, return an Error that indicates the problem.
4539 ///
4540 /// This is a simple quality of implementation feature to catch errors
4541 /// and give good diagnostics in cases when the assembler or code generator
4542 /// would otherwise reject the section specifier.
4543 llvm::Error isValidSectionSpecifier(StringRef Str);
4544 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
4545 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
4546 StringRef Name);
4547
4548 // Check for things we'd like to warn about. Multiversioning issues are
4549 // handled later in the process, once we know how many exist.
4550 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
4551
4552 /// Check Target Version attrs
4553 bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
4555 SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
4556 Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
4557 SmallVectorImpl<SmallString<64>> &StringsBuffer);
4558
4559 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
4560 StringRef NewUserDiagnostic);
4561 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
4562 IdentifierInfo *Format, int FormatIdx,
4563 int FirstArg);
4564
4565 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4566 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4567 bool IsPackExpansion);
4569 bool IsPackExpansion);
4570
4571 /// AddAlignValueAttr - Adds an align_value attribute to a particular
4572 /// declaration.
4573 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
4574
4575 /// AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
4577 StringRef Annot, MutableArrayRef<Expr *> Args);
4578
4580 bool BestCase,
4581 MSInheritanceModel SemanticSpelling);
4582
4584
4585 /// AddModeAttr - Adds a mode attribute to a particular declaration.
4586 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
4587 bool InInstantiation = false);
4588 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
4589 const AttributeCommonInfo &CI,
4590 const IdentifierInfo *Ident);
4591 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
4592 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
4593 const AttributeCommonInfo &CI);
4594 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
4595 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
4596 const InternalLinkageAttr &AL);
4597
4598 /// Check validaty of calling convention attribute \p attr. If \p FD
4599 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
4600 /// target. Otherwise, it is specified by \p CFT.
4602 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
4604
4605 /// Checks a regparm attribute, returning true if it is ill-formed and
4606 /// otherwise setting numParams to the appropriate value.
4607 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
4608
4609 /// Create an CUDALaunchBoundsAttr attribute.
4610 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
4611 Expr *MaxThreads,
4612 Expr *MinBlocks,
4613 Expr *MaxBlocks);
4614
4615 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
4616 /// declaration.
4618 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
4619
4620 enum class RetainOwnershipKind { NS, CF, OS };
4621
4622 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
4623 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
4624
4625 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
4626
4627 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
4628 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
4629 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
4630 const AttributeCommonInfo &CI,
4631 bool BestCase,
4632 MSInheritanceModel Model);
4633
4634 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
4635 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
4636 const EnforceTCBLeafAttr &AL);
4637
4638 /// Helper for delayed processing TransparentUnion or
4639 /// BPFPreserveAccessIndexAttr attribute.
4641 const ParsedAttributesView &AttrList);
4642
4643 // Options for ProcessDeclAttributeList().
4646 : IncludeCXX11Attributes(true), IgnoreTypeAttributes(false) {}
4647
4649 ProcessDeclAttributeOptions Result = *this;
4650 Result.IncludeCXX11Attributes = Val;
4651 return Result;
4652 }
4653
4655 ProcessDeclAttributeOptions Result = *this;
4656 Result.IgnoreTypeAttributes = Val;
4657 return Result;
4658 }
4659
4660 // Should C++11 attributes be processed?
4662
4663 // Should any type attributes encountered be ignored?
4664 // If this option is false, a diagnostic will be emitted for any type
4665 // attributes of a kind that does not "slide" from the declaration to
4666 // the decl-specifier-seq.
4668 };
4669
4670 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
4671 /// attribute list to the specified decl, ignoring any type attributes.
4673 const ParsedAttributesView &AttrList,
4674 const ProcessDeclAttributeOptions &Options =
4676
4677 /// Annotation attributes are the only attributes allowed after an access
4678 /// specifier.
4680 const ParsedAttributesView &AttrList);
4681
4682 /// checkUnusedDeclAttributes - Given a declarator which is not being
4683 /// used to build a declaration, complain about any decl attributes
4684 /// which might be lying around on it.
4686
4687 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
4688 /// \#pragma weak needs a non-definition decl and source may not have one.
4691
4692 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
4693 /// applied to it, possibly with an alias.
4694 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
4695
4696 void ProcessPragmaWeak(Scope *S, Decl *D);
4697 // Decl attributes - this routine is the top level dispatcher.
4698 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
4699
4701
4702 /// Given a set of delayed diagnostics, re-emit them as if they had
4703 /// been delayed in the current context instead of in the given pool.
4704 /// Essentially, this just moves them to the current pool.
4706
4707 /// Check if IdxExpr is a valid parameter index for a function or
4708 /// instance method D. May output an error.
4709 ///
4710 /// \returns true if IdxExpr is a valid index.
4711 template <typename AttrInfo>
4712 bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI,
4713 unsigned AttrArgNum,
4714 const Expr *IdxExpr, ParamIdx &Idx,
4715 bool CanIndexImplicitThis = false) {
4717
4718 // In C++ the implicit 'this' function parameter also counts.
4719 // Parameters are counted from one.
4720 bool HP = hasFunctionProto(D);
4721 bool HasImplicitThisParam = isInstanceMethod(D);
4722 bool IV = HP && isFunctionOrMethodVariadic(D);
4723 unsigned NumParams =
4724 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
4725
4726 std::optional<llvm::APSInt> IdxInt;
4727 if (IdxExpr->isTypeDependent() ||
4728 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
4729 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4730 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
4731 << IdxExpr->getSourceRange();
4732 return false;
4733 }
4734
4735 unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX);
4736 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
4737 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
4738 << &AI << AttrArgNum << IdxExpr->getSourceRange();
4739 return false;
4740 }
4741 if (HasImplicitThisParam && !CanIndexImplicitThis) {
4742 if (IdxSource == 1) {
4743 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
4744 << &AI << IdxExpr->getSourceRange();
4745 return false;
4746 }
4747 }
4748
4749 Idx = ParamIdx(IdxSource, D);
4750 return true;
4751 }
4752
4753 ///@}
4754
4755 //
4756 //
4757 // -------------------------------------------------------------------------
4758 //
4759 //
4760
4761 /// \name C++ Declarations
4762 /// Implementations are in SemaDeclCXX.cpp
4763 ///@{
4764
4765public:
4767
4768 /// Called before parsing a function declarator belonging to a function
4769 /// declaration.
4771 unsigned TemplateParameterDepth);
4772
4773 /// Called after parsing a function declarator belonging to a function
4774 /// declaration.
4776
4777 // Act on C++ namespaces
4779 SourceLocation NamespaceLoc,
4780 SourceLocation IdentLoc, IdentifierInfo *Ident,
4781 SourceLocation LBrace,
4782 const ParsedAttributesView &AttrList,
4783 UsingDirectiveDecl *&UsingDecl, bool IsNested);
4784
4785 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
4786 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
4787 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
4788
4790
4791 /// Retrieve the special "std" namespace, which may require us to
4792 /// implicitly define the namespace.
4794
4796 EnumDecl *getStdAlignValT() const;
4797
4799 const IdentifierInfo *MemberOrBase);
4800
4802 /// The '<=>' operator was used in an expression and a builtin operator
4803 /// was selected.
4805 /// A defaulted 'operator<=>' needed the comparison category. This
4806 /// typically only applies to 'std::strong_ordering', due to the implicit
4807 /// fallback return value.
4809 };
4810
4811 /// Lookup the specified comparison category types in the standard
4812 /// library, an check the VarDecls possibly returned by the operator<=>
4813 /// builtins for that type.
4814 ///
4815 /// \return The type of the comparison category type corresponding to the
4816 /// specified Kind, or a null type if an error occurs
4820
4821 /// Tests whether Ty is an instance of std::initializer_list and, if
4822 /// it is and Element is not NULL, assigns the element type to Element.
4823 bool isStdInitializerList(QualType Ty, QualType *Element);
4824
4825 /// Looks for the std::initializer_list template and instantiates it
4826 /// with Element, or emits an error if it's not found.
4827 ///
4828 /// \returns The instantiated template, or null on error.
4830
4831 /// Determine whether Ctor is an initializer-list constructor, as
4832 /// defined in [dcl.init.list]p2.
4833 bool isInitListConstructor(const FunctionDecl *Ctor);
4834
4835 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
4836 SourceLocation NamespcLoc, CXXScopeSpec &SS,
4837 SourceLocation IdentLoc,
4838 IdentifierInfo *NamespcName,
4839 const ParsedAttributesView &AttrList);
4840
4842
4843 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
4844 SourceLocation AliasLoc, IdentifierInfo *Alias,
4845 CXXScopeSpec &SS, SourceLocation IdentLoc,
4846 IdentifierInfo *Ident);
4847
4848 /// Remove decls we can't actually see from a lookup being used to declare
4849 /// shadow using decls.
4850 ///
4851 /// \param S - The scope of the potential shadow decl
4852 /// \param Previous - The lookup of a potential shadow decl's name.
4853 void FilterUsingLookup(Scope *S, LookupResult &lookup);
4854
4855 /// Hides a using shadow declaration. This is required by the current
4856 /// using-decl implementation when a resolvable using declaration in a
4857 /// class is followed by a declaration which would hide or override
4858 /// one or more of the using decl's targets; for example:
4859 ///
4860 /// struct Base { void foo(int); };
4861 /// struct Derived : Base {
4862 /// using Base::foo;
4863 /// void foo(int);
4864 /// };
4865 ///
4866 /// The governing language is C++03 [namespace.udecl]p12:
4867 ///
4868 /// When a using-declaration brings names from a base class into a
4869 /// derived class scope, member functions in the derived class
4870 /// override and/or hide member functions with the same name and
4871 /// parameter types in a base class (rather than conflicting).
4872 ///
4873 /// There are two ways to implement this:
4874 /// (1) optimistically create shadow decls when they're not hidden
4875 /// by existing declarations, or
4876 /// (2) don't create any shadow decls (or at least don't make them
4877 /// visible) until we've fully parsed/instantiated the class.
4878 /// The problem with (1) is that we might have to retroactively remove
4879 /// a shadow decl, which requires several O(n) operations because the
4880 /// decl structures are (very reasonably) not designed for removal.
4881 /// (2) avoids this but is very fiddly and phase-dependent.
4882 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
4883
4884 /// Determines whether to create a using shadow decl for a particular
4885 /// decl, given the set of decls existing prior to this using lookup.
4887 const LookupResult &PreviousDecls,
4888 UsingShadowDecl *&PrevShadow);
4889
4890 /// Builds a shadow declaration corresponding to a 'using' declaration.
4893 UsingShadowDecl *PrevDecl);
4894
4895 /// Checks that the given using declaration is not an invalid
4896 /// redeclaration. Note that this is checking only for the using decl
4897 /// itself, not for any ill-formedness among the UsingShadowDecls.
4899 bool HasTypenameKeyword,
4900 const CXXScopeSpec &SS,
4901 SourceLocation NameLoc,
4902 const LookupResult &Previous);
4903
4904 /// Checks that the given nested-name qualifier used in a using decl
4905 /// in the current context is appropriately related to the current
4906 /// scope. If an error is found, diagnoses it and returns true.
4907 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
4908 /// the result of that lookup. UD is likewise nullptr, except when we have an
4909 /// already-populated UsingDecl whose shadow decls contain the same
4910 /// information (i.e. we're instantiating a UsingDecl with non-dependent
4911 /// scope).
4912 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
4913 const CXXScopeSpec &SS,
4914 const DeclarationNameInfo &NameInfo,
4915 SourceLocation NameLoc,
4916 const LookupResult *R = nullptr,
4917 const UsingDecl *UD = nullptr);
4918
4919 /// Builds a using declaration.
4920 ///
4921 /// \param IsInstantiation - Whether this call arises from an
4922 /// instantiation of an unresolved using declaration. We treat
4923 /// the lookup differently for these declarations.
4925 SourceLocation UsingLoc,
4926 bool HasTypenameKeyword,
4927 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4928 DeclarationNameInfo NameInfo,
4929 SourceLocation EllipsisLoc,
4930 const ParsedAttributesView &AttrList,
4931 bool IsInstantiation, bool IsUsingIfExists);
4933 SourceLocation UsingLoc,
4934 SourceLocation EnumLoc,
4935 SourceLocation NameLoc,
4937 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
4938 ArrayRef<NamedDecl *> Expansions);
4939
4940 /// Additional checks for a using declaration referring to a constructor name.
4942
4943 /// Given a derived-class using shadow declaration for a constructor and the
4944 /// correspnding base class constructor, find or create the implicit
4945 /// synthesized derived class constructor to use for this initialization.
4948 ConstructorUsingShadowDecl *DerivedShadow);
4949
4951 SourceLocation UsingLoc,
4952 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4953 UnqualifiedId &Name, SourceLocation EllipsisLoc,
4954 const ParsedAttributesView &AttrList);
4956 SourceLocation UsingLoc,
4957 SourceLocation EnumLoc, SourceRange TyLoc,
4958 const IdentifierInfo &II, ParsedType Ty,
4959 CXXScopeSpec *SS = nullptr);
4961 MultiTemplateParamsArg TemplateParams,
4962 SourceLocation UsingLoc, UnqualifiedId &Name,
4963 const ParsedAttributesView &AttrList,
4964 TypeResult Type, Decl *DeclFromDeclSpec);
4965
4966 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
4967 /// including handling of its default argument expressions.
4968 ///
4969 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
4971 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4972 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
4973 bool HadMultipleCandidates, bool IsListInitialization,
4974 bool IsStdInitListInitialization, bool RequiresZeroInit,
4975 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4976
4977 /// Build a CXXConstructExpr whose constructor has already been resolved if
4978 /// it denotes an inherited constructor.
4980 SourceLocation ConstructLoc, QualType DeclInitType,
4981 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4982 bool HadMultipleCandidates, bool IsListInitialization,
4983 bool IsStdInitListInitialization, bool RequiresZeroInit,
4984 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4985
4986 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4987 // the constructor can be elidable?
4989 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4990 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4991 bool HadMultipleCandidates, bool IsListInitialization,
4992 bool IsStdInitListInitialization, bool RequiresZeroInit,
4993 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4994
4996 SourceLocation InitLoc);
4997
4998 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4999 /// constructed variable.
5000 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
5001
5002 /// Helper class that collects exception specifications for
5003 /// implicitly-declared special member functions.
5005 // Pointer to allow copying
5006 Sema *Self;
5007 // We order exception specifications thus:
5008 // noexcept is the most restrictive, but is only used in C++11.
5009 // throw() comes next.
5010 // Then a throw(collected exceptions)
5011 // Finally no specification, which is expressed as noexcept(false).
5012 // throw(...) is used instead if any called function uses it.
5013 ExceptionSpecificationType ComputedEST;
5014 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5015 SmallVector<QualType, 4> Exceptions;
5016
5017 void ClearExceptions() {
5018 ExceptionsSeen.clear();
5019 Exceptions.clear();
5020 }
5021
5022 public:
5024 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5025 if (!Self.getLangOpts().CPlusPlus11)
5026 ComputedEST = EST_DynamicNone;
5027 }
5028
5029 /// Get the computed exception specification type.
5031 assert(!isComputedNoexcept(ComputedEST) &&
5032 "noexcept(expr) should not be a possible result");
5033 return ComputedEST;
5034 }
5035
5036 /// The number of exceptions in the exception specification.
5037 unsigned size() const { return Exceptions.size(); }
5038
5039 /// The set of exceptions in the exception specification.
5040 const QualType *data() const { return Exceptions.data(); }
5041
5042 /// Integrate another called method into the collected data.
5043 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5044
5045 /// Integrate an invoked expression into the collected data.
5046 void CalledExpr(Expr *E) { CalledStmt(E); }
5047
5048 /// Integrate an invoked statement into the collected data.
5049 void CalledStmt(Stmt *S);
5050
5051 /// Overwrite an EPI's exception specification with this
5052 /// computed exception specification.
5055 ESI.Type = getExceptionSpecType();
5056 if (ESI.Type == EST_Dynamic) {
5057 ESI.Exceptions = Exceptions;
5058 } else if (ESI.Type == EST_None) {
5059 /// C++11 [except.spec]p14:
5060 /// The exception-specification is noexcept(false) if the set of
5061 /// potential exceptions of the special member function contains "any"
5062 ESI.Type = EST_NoexceptFalse;
5063 ESI.NoexceptExpr =
5064 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5065 }
5066 return ESI;
5067 }
5068 };
5069
5070 /// Evaluate the implicit exception specification for a defaulted
5071 /// special member function.
5073
5074 /// Check the given exception-specification and update the
5075 /// exception specification information with the results.
5076 void checkExceptionSpecification(bool IsTopLevel,
5078 ArrayRef<ParsedType> DynamicExceptions,
5079 ArrayRef<SourceRange> DynamicExceptionRanges,
5080 Expr *NoexceptExpr,
5081 SmallVectorImpl<QualType> &Exceptions,
5083
5084 /// Add an exception-specification to the given member or friend function
5085 /// (or function template). The exception-specification was parsed
5086 /// after the function itself was declared.
5088 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5089 ArrayRef<ParsedType> DynamicExceptions,
5090 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5091
5092 class InheritedConstructorInfo;
5093
5094 /// Determine if a special member function should have a deleted
5095 /// definition when it is defaulted.
5097 InheritedConstructorInfo *ICI = nullptr,
5098 bool Diagnose = false);
5099
5100 /// Produce notes explaining why a defaulted function was defined as deleted.
5102
5103 /// Declare the implicit default constructor for the given class.
5104 ///
5105 /// \param ClassDecl The class declaration into which the implicit
5106 /// default constructor will be added.
5107 ///
5108 /// \returns The implicitly-declared default constructor.
5111
5112 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5113 /// defining this constructor as the default constructor.
5115 CXXConstructorDecl *Constructor);
5116
5117 /// Declare the implicit destructor for the given class.
5118 ///
5119 /// \param ClassDecl The class declaration into which the implicit
5120 /// destructor will be added.
5121 ///
5122 /// \returns The implicitly-declared destructor.
5124
5125 /// DefineImplicitDestructor - Checks for feasibility of
5126 /// defining this destructor as the default destructor.
5127 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5129
5130 /// Build an exception spec for destructors that don't have one.
5131 ///
5132 /// C++11 says that user-defined destructors with no exception spec get one
5133 /// that looks as if the destructor was implicitly declared.
5135
5136 /// Define the specified inheriting constructor.
5138 CXXConstructorDecl *Constructor);
5139
5140 /// Declare the implicit copy constructor for the given class.
5141 ///
5142 /// \param ClassDecl The class declaration into which the implicit
5143 /// copy constructor will be added.
5144 ///
5145 /// \returns The implicitly-declared copy constructor.
5147
5148 /// DefineImplicitCopyConstructor - Checks for feasibility of
5149 /// defining this constructor as the copy constructor.
5150 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5151 CXXConstructorDecl *Constructor);
5152
5153 /// Declare the implicit move constructor for the given class.
5154 ///
5155 /// \param ClassDecl The Class declaration into which the implicit
5156 /// move constructor will be added.
5157 ///
5158 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5159 /// declared.
5161
5162 /// DefineImplicitMoveConstructor - Checks for feasibility of
5163 /// defining this constructor as the move constructor.
5164 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5165 CXXConstructorDecl *Constructor);
5166
5167 /// Declare the implicit copy assignment operator for the given class.
5168 ///
5169 /// \param ClassDecl The class declaration into which the implicit
5170 /// copy assignment operator will be added.
5171 ///
5172 /// \returns The implicitly-declared copy assignment operator.
5174
5175 /// Defines an implicitly-declared copy assignment operator.
5176 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5177 CXXMethodDecl *MethodDecl);
5178
5179 /// Declare the implicit move assignment operator for the given class.
5180 ///
5181 /// \param ClassDecl The Class declaration into which the implicit
5182 /// move assignment operator will be added.
5183 ///
5184 /// \returns The implicitly-declared move assignment operator, or NULL if it
5185 /// wasn't declared.
5187
5188 /// Defines an implicitly-declared move assignment operator.
5189 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5190 CXXMethodDecl *MethodDecl);
5191
5192 /// Check a completed declaration of an implicit special member.
5194
5195 /// Determine whether the given function is an implicitly-deleted
5196 /// special member function.
5198
5199 /// Check whether 'this' shows up in the type of a static member
5200 /// function after the (naturally empty) cv-qualifier-seq would be.
5201 ///
5202 /// \returns true if an error occurred.
5204
5205 /// Whether this' shows up in the exception specification of a static
5206 /// member function.
5208
5209 /// Check whether 'this' shows up in the attributes of the given
5210 /// static member function.
5211 ///
5212 /// \returns true if an error occurred.
5214
5216 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5217
5219
5220 /// Given a constructor and the set of arguments provided for the
5221 /// constructor, convert the arguments and add any required default arguments
5222 /// to form a proper call to this constructor.
5223 ///
5224 /// \returns true if an error occurred, false otherwise.
5226 QualType DeclInitType, MultiExprArg ArgsPtr,
5228 SmallVectorImpl<Expr *> &ConvertedArgs,
5229 bool AllowExplicit = false,
5230 bool IsListInitialization = false);
5231
5232 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5233 /// initializer for the declaration 'Dcl'.
5234 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5235 /// static data member of class X, names should be looked up in the scope of
5236 /// class X.
5238
5239 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5240 /// initializer for the declaration 'Dcl'.
5241 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5242
5243 /// Define the "body" of the conversion from a lambda object to a
5244 /// function pointer.
5245 ///
5246 /// This routine doesn't actually define a sensible body; rather, it fills
5247 /// in the initialization expression needed to copy the lambda object into
5248 /// the block, and IR generation actually generates the real body of the
5249 /// block pointer conversion.
5250 void
5252 CXXConversionDecl *Conv);
5253
5254 /// Define the "body" of the conversion from a lambda object to a
5255 /// block pointer.
5256 ///
5257 /// This routine doesn't actually define a sensible body; rather, it fills
5258 /// in the initialization expression needed to copy the lambda object into
5259 /// the block, and IR generation actually generates the real body of the
5260 /// block pointer conversion.
5262 CXXConversionDecl *Conv);
5263
5264 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5265 /// linkage specification, including the language and (if present)
5266 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5267 /// language string literal. LBraceLoc, if valid, provides the location of
5268 /// the '{' brace. Otherwise, this linkage specification does not
5269 /// have any braces.
5271 Expr *LangStr, SourceLocation LBraceLoc);
5272
5273 /// ActOnFinishLinkageSpecification - Complete the definition of
5274 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5275 /// valid, it's the position of the closing '}' brace in a linkage
5276 /// specification that uses braces.
5278 SourceLocation RBraceLoc);
5279
5280 //===--------------------------------------------------------------------===//
5281 // C++ Classes
5282 //
5283
5284 /// Get the class that is directly named by the current context. This is the
5285 /// class for which an unqualified-id in this scope could name a constructor
5286 /// or destructor.
5287 ///
5288 /// If the scope specifier denotes a class, this will be that class.
5289 /// If the scope specifier is empty, this will be the class whose
5290 /// member-specification we are currently within. Otherwise, there
5291 /// is no such class.
5293
5294 /// isCurrentClassName - Determine whether the identifier II is the
5295 /// name of the class type currently being defined. In the case of
5296 /// nested classes, this will only return true if II is the name of
5297 /// the innermost class.
5298 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5299 const CXXScopeSpec *SS = nullptr);
5300
5301 /// Determine whether the identifier II is a typo for the name of
5302 /// the class type currently being defined. If so, update it to the identifier
5303 /// that should have been used.
5305
5306 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5308 SourceLocation ColonLoc,
5309 const ParsedAttributesView &Attrs);
5310
5311 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5312 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5313 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5314 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5315 /// present (but parsing it has been deferred).
5316 NamedDecl *
5318 MultiTemplateParamsArg TemplateParameterLists,
5319 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5320 InClassInitStyle InitStyle);
5321
5322 /// Enter a new C++ default initializer scope. After calling this, the
5323 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5324 /// parsing or instantiating the initializer failed.
5326
5327 /// This is invoked after parsing an in-class initializer for a
5328 /// non-static C++ class member, and after instantiating an in-class
5329 /// initializer in a class template. Such actions are deferred until the class
5330 /// is complete.
5332 SourceLocation EqualLoc,
5333 Expr *Init);
5334
5335 /// Handle a C++ member initializer using parentheses syntax.
5337 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5338 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5339 const DeclSpec &DS, SourceLocation IdLoc,
5340 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5341 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5342
5343 /// Handle a C++ member initializer using braced-init-list syntax.
5344 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5345 CXXScopeSpec &SS,
5346 IdentifierInfo *MemberOrBase,
5347 ParsedType TemplateTypeTy,
5348 const DeclSpec &DS, SourceLocation IdLoc,
5349 Expr *InitList, SourceLocation EllipsisLoc);
5350
5351 /// Handle a C++ member initializer.
5352 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5353 CXXScopeSpec &SS,
5354 IdentifierInfo *MemberOrBase,
5355 ParsedType TemplateTypeTy,
5356 const DeclSpec &DS, SourceLocation IdLoc,
5357 Expr *Init, SourceLocation EllipsisLoc);
5358
5360 SourceLocation IdLoc);
5361
5363 TypeSourceInfo *BaseTInfo, Expr *Init,
5364 CXXRecordDecl *ClassDecl,
5365 SourceLocation EllipsisLoc);
5366
5368 CXXRecordDecl *ClassDecl);
5369
5372
5374 CXXConstructorDecl *Constructor, bool AnyErrors,
5375 ArrayRef<CXXCtorInitializer *> Initializers = std::nullopt);
5376
5377 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5378 /// mark all the non-trivial destructors of its members and bases as
5379 /// referenced.
5382
5383 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5384 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5385 /// class. In the Microsoft C++ ABI, this is done any time a class's
5386 /// destructor is referenced.
5388 SourceLocation Location, CXXRecordDecl *ClassDecl,
5389 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases = nullptr);
5390
5391 /// Do semantic checks to allow the complete destructor variant to be emitted
5392 /// when the destructor is defined in another translation unit. In the Itanium
5393 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
5394 /// can be emitted in separate TUs. To emit the complete variant, run a subset
5395 /// of the checks performed when emitting a regular destructor.
5397 CXXDestructorDecl *Dtor);
5398
5399 /// The list of classes whose vtables have been used within
5400 /// this translation unit, and the source locations at which the
5401 /// first use occurred.
5402 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
5403
5404 /// The list of vtables that are required but have not yet been
5405 /// materialized.
5407
5408 /// The set of classes whose vtables have been used within
5409 /// this translation unit, and a bit that will be true if the vtable is
5410 /// required to be emitted (otherwise, it should be emitted only if needed
5411 /// by code generation).
5412 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5413
5414 /// Load any externally-stored vtable uses.
5416
5417 /// Note that the vtable for the given class was used at the
5418 /// given location.
5420 bool DefinitionRequired = false);
5421
5422 /// Mark the exception specifications of all virtual member functions
5423 /// in the given class as needed.
5425 const CXXRecordDecl *RD);
5426
5427 /// MarkVirtualMembersReferenced - Will mark all members of the given
5428 /// CXXRecordDecl referenced.
5430 bool ConstexprOnly = false);
5431
5432 /// Define all of the vtables that have been used in this
5433 /// translation unit and reference any virtual members used by those
5434 /// vtables.
5435 ///
5436 /// \returns true if any work was done, false otherwise.
5437 bool DefineUsedVTables();
5438
5439 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
5440 /// special functions, such as the default constructor, copy
5441 /// constructor, or destructor, to the given C++ class (C++
5442 /// [special]p1). This routine can only be executed just before the
5443 /// definition of the class is complete.
5445
5446 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5447 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
5449 bool AnyErrors);
5450
5451 /// Check class-level dllimport/dllexport attribute. The caller must
5452 /// ensure that referenceDLLExportedClassMethods is called some point later
5453 /// when all outer classes of Class are complete.
5456
5458
5459 /// Perform propagation of DLL attributes from a derived class to a
5460 /// templated base class for MS compatibility.
5462 CXXRecordDecl *Class, Attr *ClassAttr,
5463 ClassTemplateSpecializationDecl *BaseTemplateSpec,
5464 SourceLocation BaseLoc);
5465
5466 /// Perform semantic checks on a class definition that has been
5467 /// completing, introducing implicitly-declared members, checking for
5468 /// abstract types, etc.
5469 ///
5470 /// \param S The scope in which the class was parsed. Null if we didn't just
5471 /// parse a class definition.
5472 /// \param Record The completed class.
5474
5475 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
5476 /// conditions that are needed for the attribute to have an effect.
5478
5479 /// Check that VTable Pointer authentication is only being set on the first
5480 /// first instantiation of the vtable
5482
5484 Decl *TagDecl, SourceLocation LBrac,
5485 SourceLocation RBrac,
5486 const ParsedAttributesView &AttrList);
5487
5488 /// Perform any semantic analysis which needs to be delayed until all
5489 /// pending class member declarations have been parsed.
5492
5493 /// This is used to implement the constant expression evaluation part of the
5494 /// attribute enable_if extension. There is nothing in standard C++ which
5495 /// would require reentering parameters.
5497 unsigned ActOnReenterTemplateScope(Decl *Template,
5498 llvm::function_ref<Scope *()> EnterScope);
5500
5501 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
5502 /// parsing a top-level (non-nested) C++ class, and we are now
5503 /// parsing those parts of the given Method declaration that could
5504 /// not be parsed earlier (C++ [class.mem]p2), such as default
5505 /// arguments. This action should enter the scope of the given
5506 /// Method declaration as if we had just parsed the qualified method
5507 /// name. However, it should not bring the parameters into scope;
5508 /// that will be performed by ActOnDelayedCXXMethodParameter.
5510 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
5512
5513 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
5514 /// processing the delayed method declaration for Method. The method
5515 /// declaration is now considered finished. There may be a separate
5516 /// ActOnStartOfFunctionDef action later (not necessarily
5517 /// immediately!) for this method, if it was also defined inside the
5518 /// class body.
5521
5522 bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result,
5523 ASTContext &Ctx,
5524 bool ErrorOnInvalidMessage);
5526 Expr *AssertExpr, Expr *AssertMessageExpr,
5527 SourceLocation RParenLoc);
5529 Expr *AssertExpr, Expr *AssertMessageExpr,
5530 SourceLocation RParenLoc, bool Failed);
5531
5532 /// Try to print more useful information about a failed static_assert
5533 /// with expression \E
5534 void DiagnoseStaticAssertDetails(const Expr *E);
5535
5536 /// Handle a friend type declaration. This works in tandem with
5537 /// ActOnTag.
5538 ///
5539 /// Notes on friend class templates:
5540 ///
5541 /// We generally treat friend class declarations as if they were
5542 /// declaring a class. So, for example, the elaborated type specifier
5543 /// in a friend declaration is required to obey the restrictions of a
5544 /// class-head (i.e. no typedefs in the scope chain), template
5545 /// parameters are required to match up with simple template-ids, &c.
5546 /// However, unlike when declaring a template specialization, it's
5547 /// okay to refer to a template specialization without an empty
5548 /// template parameter declaration, e.g.
5549 /// friend class A<T>::B<unsigned>;
5550 /// We permit this as a special case; if there are any template
5551 /// parameters present at all, require proper matching, i.e.
5552 /// template <> template <class T> friend class A<int>::B;
5553 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
5554 MultiTemplateParamsArg TemplateParams,
5555 SourceLocation EllipsisLoc);
5557 MultiTemplateParamsArg TemplateParams);
5558
5559 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
5560 /// the well-formedness of the constructor declarator @p D with type @p
5561 /// R. If there are any errors in the declarator, this routine will
5562 /// emit diagnostics and set the invalid bit to true. In any case, the type
5563 /// will be updated to reflect a well-formed type for the constructor and
5564 /// returned.
5566 StorageClass &SC);
5567
5568 /// CheckConstructor - Checks a fully-formed constructor for
5569 /// well-formedness, issuing any diagnostics required. Returns true if
5570 /// the constructor declarator is invalid.
5571 void CheckConstructor(CXXConstructorDecl *Constructor);
5572
5573 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
5574 /// the well-formednes of the destructor declarator @p D with type @p
5575 /// R. If there are any errors in the declarator, this routine will
5576 /// emit diagnostics and set the declarator to invalid. Even if this happens,
5577 /// will be updated to reflect a well-formed type for the destructor and
5578 /// returned.
5580 StorageClass &SC);
5581
5582 /// CheckDestructor - Checks a fully-formed destructor definition for
5583 /// well-formedness, issuing any diagnostics required. Returns true
5584 /// on error.
5586
5587 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
5588 /// well-formednes of the conversion function declarator @p D with
5589 /// type @p R. If there are any errors in the declarator, this routine
5590 /// will emit diagnostics and return true. Otherwise, it will return
5591 /// false. Either way, the type @p R will be updated to reflect a
5592 /// well-formed type for the conversion operator.
5594
5595 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
5596 /// the declaration of the given C++ conversion function. This routine
5597 /// is responsible for recording the conversion function in the C++
5598 /// class, if possible.
5600
5601 /// Check the validity of a declarator that we parsed for a deduction-guide.
5602 /// These aren't actually declarators in the grammar, so we need to check that
5603 /// the user didn't specify any pieces that are not part of the
5604 /// deduction-guide grammar. Return true on invalid deduction-guide.
5606 StorageClass &SC);
5607
5609
5612 SourceLocation DefaultLoc);
5614
5615 /// Kinds of defaulted comparison operator functions.
5616 enum class DefaultedComparisonKind : unsigned char {
5617 /// This is not a defaultable comparison operator.
5618 None,
5619 /// This is an operator== that should be implemented as a series of
5620 /// subobject comparisons.
5621 Equal,
5622 /// This is an operator<=> that should be implemented as a series of
5623 /// subobject comparisons.
5624 ThreeWay,
5625 /// This is an operator!= that should be implemented as a rewrite in terms
5626 /// of a == comparison.
5627 NotEqual,
5628 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
5629 /// terms of a <=> comparison.
5630 Relational,
5631 };
5632
5636 FunctionDecl *Spaceship);
5639
5641 QualType R, bool IsLambda,
5642 DeclContext *DC = nullptr);
5644 DeclarationName Name, QualType R);
5646
5647 //===--------------------------------------------------------------------===//
5648 // C++ Derived Classes
5649 //
5650
5651 /// Check the validity of a C++ base class specifier.
5652 ///
5653 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
5654 /// and returns NULL otherwise.
5656 SourceRange SpecifierRange, bool Virtual,
5657 AccessSpecifier Access,
5658 TypeSourceInfo *TInfo,
5659 SourceLocation EllipsisLoc);
5660
5661 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
5662 /// one entry in the base class list of a class specifier, for
5663 /// example:
5664 /// class foo : public bar, virtual private baz {
5665 /// 'public bar' and 'virtual private baz' are each base-specifiers.
5666 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
5667 const ParsedAttributesView &Attrs, bool Virtual,
5668 AccessSpecifier Access, ParsedType basetype,
5669 SourceLocation BaseLoc,
5670 SourceLocation EllipsisLoc);
5671
5672 /// Performs the actual work of attaching the given base class
5673 /// specifiers to a C++ class.
5676
5677 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
5678 /// class, after checking whether there are any duplicate base
5679 /// classes.
5680 void ActOnBaseSpecifiers(Decl *ClassDecl,
5682
5683 /// Determine whether the type \p Derived is a C++ class that is
5684 /// derived from the type \p Base.
5686
5687 /// Determine whether the type \p Derived is a C++ class that is
5688 /// derived from the type \p Base.
5690 CXXBasePaths &Paths);
5691
5692 // FIXME: I don't like this name.
5693 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
5694
5697 CXXCastPath *BasePath = nullptr,
5698 bool IgnoreAccess = false);
5699
5700 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
5701 /// conversion (where Derived and Base are class types) is
5702 /// well-formed, meaning that the conversion is unambiguous (and
5703 /// that all of the base classes are accessible). Returns true
5704 /// and emits a diagnostic if the code is ill-formed, returns false
5705 /// otherwise. Loc is the location where this routine should point to
5706 /// if there is an error, and Range is the source range to highlight
5707 /// if there is an error.
5708 ///
5709 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
5710 /// diagnostic for the respective type of error will be suppressed, but the
5711 /// check for ill-formed code will still be performed.
5713 unsigned InaccessibleBaseID,
5714 unsigned AmbiguousBaseConvID,
5716 DeclarationName Name, CXXCastPath *BasePath,
5717 bool IgnoreAccess = false);
5718
5719 /// Builds a string representing ambiguous paths from a
5720 /// specific derived class to different subobjects of the same base
5721 /// class.
5722 ///
5723 /// This function builds a string that can be used in error messages
5724 /// to show the different paths that one can take through the
5725 /// inheritance hierarchy to go from the derived class to different
5726 /// subobjects of a base class. The result looks something like this:
5727 /// @code
5728 /// struct D -> struct B -> struct A
5729 /// struct D -> struct C -> struct A
5730 /// @endcode
5731 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
5732
5734 const CXXMethodDecl *Old);
5735
5736 /// CheckOverridingFunctionReturnType - Checks whether the return types are
5737 /// covariant, according to C++ [class.virtual]p5.
5739 const CXXMethodDecl *Old);
5740
5741 // Check that the overriding method has no explicit object parameter.
5743 const CXXMethodDecl *Old);
5744
5745 /// Mark the given method pure.
5746 ///
5747 /// \param Method the method to be marked pure.
5748 ///
5749 /// \param InitRange the source range that covers the "0" initializer.
5750 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
5751
5752 /// CheckOverrideControl - Check C++11 override control semantics.
5754
5755 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
5756 /// not used in the declaration of an overriding method.
5758
5759 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
5760 /// function overrides a virtual member function marked 'final', according to
5761 /// C++11 [class.virtual]p4.
5763 const CXXMethodDecl *Old);
5764
5775
5776 struct TypeDiagnoser;
5777
5780 TypeDiagnoser &Diagnoser);
5781 template <typename... Ts>
5783 const Ts &...Args) {
5784 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
5785 return RequireNonAbstractType(Loc, T, Diagnoser);
5786 }
5787
5788 void DiagnoseAbstractType(const CXXRecordDecl *RD);
5789
5790 //===--------------------------------------------------------------------===//
5791 // C++ Overloaded Operators [C++ 13.5]
5792 //
5793
5794 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
5795 /// of this overloaded operator is well-formed. If so, returns false;
5796 /// otherwise, emits appropriate diagnostics and returns true.
5798
5799 /// CheckLiteralOperatorDeclaration - Check whether the declaration
5800 /// of this literal operator function is well-formed. If so, returns
5801 /// false; otherwise, emits appropriate diagnostics and returns true.
5803
5804 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
5805 /// found in an explicit(bool) specifier.
5807
5808 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
5809 /// Returns true if the explicit specifier is now resolved.
5811
5812 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
5813 /// C++ if/switch/while/for statement.
5814 /// e.g: "if (int x = f()) {...}"
5816
5817 // Emitting members of dllexported classes is delayed until the class
5818 // (including field initializers) is fully parsed.
5821
5822 /// Merge the exception specifications of two variable declarations.
5823 ///
5824 /// This is called when there's a redeclaration of a VarDecl. The function
5825 /// checks if the redeclaration might have an exception specification and
5826 /// validates compatibility and merges the specs if necessary.
5828
5829 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
5830 /// function, once we already know that they have the same
5831 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
5832 /// error, false otherwise.
5834
5835 /// Helpers for dealing with blocks and functions.
5837
5838 /// CheckExtraCXXDefaultArguments - Check for any extra default
5839 /// arguments in the declarator, which is not a function declaration
5840 /// or definition and therefore is not permitted to have default
5841 /// arguments. This routine should be invoked for every declarator
5842 /// that is not a function declaration or definition.
5844
5847 }
5848
5849 /// Perform semantic analysis for the variable declaration that
5850 /// occurs within a C++ catch clause, returning the newly-created
5851 /// variable.
5853 SourceLocation StartLoc,
5854 SourceLocation IdLoc,
5855 const IdentifierInfo *Id);
5856
5857 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
5858 /// handler.
5860
5862
5863 /// Handle a friend tag declaration where the scope specifier was
5864 /// templated.
5866 unsigned TagSpec, SourceLocation TagLoc,
5867 CXXScopeSpec &SS, IdentifierInfo *Name,
5868 SourceLocation NameLoc,
5869 SourceLocation EllipsisLoc,
5871 MultiTemplateParamsArg TempParamLists);
5872
5874 SourceLocation DeclStart, Declarator &D,
5875 Expr *BitfieldWidth,
5876 InClassInitStyle InitStyle,
5877 AccessSpecifier AS,
5878 const ParsedAttr &MSPropertyAttr);
5879
5880 /// Diagnose why the specified class does not have a trivial special member of
5881 /// the given kind.
5884
5886 /// The triviality of a method unaffected by "trivial_abi".
5888
5889 /// The triviality of a method affected by "trivial_abi".
5892
5893 /// Determine whether a defaulted or deleted special member function is
5894 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
5895 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
5898 bool Diagnose = false);
5899
5900 /// For a defaulted function, the kind of defaulted function that it is.
5902 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
5903 unsigned SpecialMember : 8;
5904 unsigned Comparison : 8;
5905
5906 public:
5908 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5909 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5911 : SpecialMember(llvm::to_underlying(CSM)),
5912 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5914 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5915 Comparison(llvm::to_underlying(Comp)) {}
5916
5917 bool isSpecialMember() const {
5918 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
5919 CXXSpecialMemberKind::Invalid;
5920 }
5921 bool isComparison() const {
5922 return static_cast<DefaultedComparisonKind>(Comparison) !=
5923 DefaultedComparisonKind::None;
5924 }
5925
5926 explicit operator bool() const {
5927 return isSpecialMember() || isComparison();
5928 }
5929
5931 return static_cast<CXXSpecialMemberKind>(SpecialMember);
5932 }
5934 return static_cast<DefaultedComparisonKind>(Comparison);
5935 }
5936
5937 /// Get the index of this function kind for use in diagnostics.
5938 unsigned getDiagnosticIndex() const {
5939 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
5940 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
5941 "invalid should have highest index");
5942 static_assert((unsigned)DefaultedComparisonKind::None == 0,
5943 "none should be equal to zero");
5944 return SpecialMember + Comparison;
5945 }
5946 };
5947
5948 /// Determine the kind of defaulting that would be done for a given function.
5949 ///
5950 /// If the function is both a default constructor and a copy / move
5951 /// constructor (due to having a default argument for the first parameter),
5952 /// this picks CXXSpecialMemberKind::DefaultConstructor.
5953 ///
5954 /// FIXME: Check that case is properly handled by all callers.
5955 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
5956
5957 /// Handle a C++11 empty-declaration and attribute-declaration.
5959 SourceLocation SemiLoc);
5960
5962 /// Diagnose issues that are non-constant or that are extensions.
5963 Diagnose,
5964 /// Identify whether this function satisfies the formal rules for constexpr
5965 /// functions in the current lanugage mode (with no extensions).
5967 };
5968
5969 // Check whether a function declaration satisfies the requirements of a
5970 // constexpr function definition or a constexpr constructor definition. If so,
5971 // return true. If not, produce appropriate diagnostics (unless asked not to
5972 // by Kind) and return false.
5973 //
5974 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
5977
5978 /// Diagnose methods which overload virtual methods in a base class
5979 /// without overriding any.
5981
5982 /// Check if a method overloads virtual methods in a base class without
5983 /// overriding any.
5984 void
5986 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5987 void
5989 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5990
5991 /// ActOnParamDefaultArgument - Check whether the default argument
5992 /// provided for a function parameter is well-formed. If so, attach it
5993 /// to the parameter declaration.
5994 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
5995 Expr *defarg);
5996
5997 /// ActOnParamUnparsedDefaultArgument - We've seen a default
5998 /// argument for a function parameter, but we can't parse it yet
5999 /// because we're inside a class definition. Note that this default
6000 /// argument will be parsed later.
6002 SourceLocation ArgLoc);
6003
6004 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
6005 /// the default argument for the parameter param failed.
6007 Expr *DefaultArg);
6009 SourceLocation EqualLoc);
6010 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
6011 SourceLocation EqualLoc);
6012
6013 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
6014 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
6015 StringLiteral *Message = nullptr);
6016 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6017
6019 StringLiteral *DeletedMessage = nullptr);
6023
6024 NamedDecl *
6026 MultiTemplateParamsArg TemplateParamLists);
6029 RecordDecl *ClassDecl,
6030 const IdentifierInfo *Name);
6031
6033
6034 /// Stack containing information needed when in C++2a an 'auto' is encountered
6035 /// in a function declaration parameter type specifier in order to invent a
6036 /// corresponding template parameter in the enclosing abbreviated function
6037 /// template. This information is also present in LambdaScopeInfo, stored in
6038 /// the FunctionScopes stack.
6040
6041 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6042 std::unique_ptr<CXXFieldCollector> FieldCollector;
6043
6045 /// Set containing all declared private fields that are not used.
6047
6049
6050 /// PureVirtualClassDiagSet - a set of class declarations which we have
6051 /// emitted a list of pure virtual functions. Used to prevent emitting the
6052 /// same list more than once.
6053 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6054
6058
6059 /// All the delegating constructors seen so far in the file, used for
6060 /// cycle detection at the end of the TU.
6062
6063 /// The C++ "std" namespace, where the standard library resides.
6065
6066 /// The C++ "std::initializer_list" template, which is defined in
6067 /// <initializer_list>.
6069
6070 // Contains the locations of the beginning of unparsed default
6071 // argument locations.
6072 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6073
6074 /// UndefinedInternals - all the used, undefined objects which require a
6075 /// definition in this translation unit.
6076 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6077
6078 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6080
6081 /// The C++ special members which we are currently in the process of
6082 /// declaring. If this process recursively triggers the declaration of the
6083 /// same special member, we should act as if it is not yet declared.
6085
6087
6088 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6089
6092 ParsingClassDepth++;
6094 }
6096 ParsingClassDepth--;
6098 }
6099
6101 CXXScopeSpec &SS,
6102 ParsedType TemplateTypeTy,
6103 IdentifierInfo *MemberOrBase);
6104
6105private:
6106 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6107 QualType ResultTy,
6108 ArrayRef<QualType> Args);
6109
6110 // A cache representing if we've fully checked the various comparison category
6111 // types stored in ASTContext. The bit-index corresponds to the integer value
6112 // of a ComparisonCategoryType enumerator.
6113 llvm::SmallBitVector FullyCheckedComparisonCategories;
6114
6115 /// Check if there is a field shadowing.
6116 void CheckShadowInheritedFields(const SourceLocation &Loc,
6117 DeclarationName FieldName,
6118 const CXXRecordDecl *RD,
6119 bool DeclIsField = true);
6120
6121 ///@}
6122
6123 //
6124 //
6125 // -------------------------------------------------------------------------
6126 //
6127 //
6128
6129 /// \name C++ Exception Specifications
6130 /// Implementations are in SemaExceptionSpec.cpp
6131 ///@{
6132
6133public:
6134 /// All the overriding functions seen during a class definition
6135 /// that had their exception spec checks delayed, plus the overridden
6136 /// function.
6139
6140 /// All the function redeclarations seen during a class definition that had
6141 /// their exception spec checks delayed, plus the prior declaration they
6142 /// should be checked against. Except during error recovery, the new decl
6143 /// should always be a friend declaration, as that's the only valid way to
6144 /// redeclare a special member before its class is complete.
6147
6148 /// Determine if we're in a case where we need to (incorrectly) eagerly
6149 /// parse an exception specification to work around a libstdc++ bug.
6151
6152 /// Check the given noexcept-specifier, convert its expression, and compute
6153 /// the appropriate ExceptionSpecificationType.
6154 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6156
6157 CanThrowResult canThrow(const Stmt *E);
6158 /// Determine whether the callee of a particular function call can throw.
6159 /// E, D and Loc are all optional.
6160 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6163 const FunctionProtoType *FPT);
6166
6167 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6168 /// exception specification. Incomplete types, or pointers to incomplete types
6169 /// other than void are not allowed.
6170 ///
6171 /// \param[in,out] T The exception type. This will be decayed to a pointer
6172 /// type
6173 /// when the input is an array or a function type.
6175
6176 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6177 /// pointer to member to a function with an exception specification. This
6178 /// means that it is invalid to add another level of indirection.
6181
6182 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6183 /// exception specifications. Exception specifications are equivalent if
6184 /// they allow exactly the same set of exception types. It does not matter how
6185 /// that is achieved. See C++ [except.spec]p2.
6187 SourceLocation OldLoc,
6188 const FunctionProtoType *New,
6189 SourceLocation NewLoc);
6191 const PartialDiagnostic &NoteID,
6192 const FunctionProtoType *Old,
6193 SourceLocation OldLoc,
6194 const FunctionProtoType *New,
6195 SourceLocation NewLoc);
6196 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6197
6198 /// CheckExceptionSpecSubset - Check whether the second function type's
6199 /// exception specification is a subset (or equivalent) of the first function
6200 /// type. This is used by override and pointer assignment checks.
6202 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6203 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6204 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6205 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6206 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6207
6208 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6209 /// two functions have equivalent exception specs. This is part of the
6210 /// assignment and override compatibility check. We do not check the
6211 /// parameters of parameter function pointers recursively, as no sane
6212 /// programmer would even be able to write such a function type.
6214 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6215 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6216 SourceLocation TargetLoc, const FunctionProtoType *Source,
6217 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6218
6219 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6220
6221 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6222 /// spec is a subset of base spec.
6224 const CXXMethodDecl *Old);
6225
6226 ///@}
6227
6228 //
6229 //
6230 // -------------------------------------------------------------------------
6231 //
6232 //
6233
6234 /// \name Expressions
6235 /// Implementations are in SemaExpr.cpp
6236 ///@{
6237
6238public:
6239 /// Describes how the expressions currently being parsed are
6240 /// evaluated at run-time, if at all.
6242 /// The current expression and its subexpressions occur within an
6243 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6244 /// \c sizeof, where the type of the expression may be significant but
6245 /// no code will be generated to evaluate the value of the expression at
6246 /// run time.
6248
6249 /// The current expression occurs within a braced-init-list within
6250 /// an unevaluated operand. This is mostly like a regular unevaluated
6251 /// context, except that we still instantiate constexpr functions that are
6252 /// referenced here so that we can perform narrowing checks correctly.
6254
6255 /// The current expression occurs within a discarded statement.
6256 /// This behaves largely similarly to an unevaluated operand in preventing
6257 /// definitions from being required, but not in other ways.
6259
6260 /// The current expression occurs within an unevaluated
6261 /// operand that unconditionally permits abstract references to
6262 /// fields, such as a SIZE operator in MS-style inline assembly.
6264
6265 /// The current context is "potentially evaluated" in C++11 terms,
6266 /// but the expression is evaluated at compile-time (like the values of
6267 /// cases in a switch statement).
6269
6270 /// In addition of being constant evaluated, the current expression
6271 /// occurs in an immediate function context - either a consteval function
6272 /// or a consteval if statement.
6274
6275 /// The current expression is potentially evaluated at run time,
6276 /// which means that code may be generated to evaluate the value of the
6277 /// expression at run time.
6279
6280 /// The current expression is potentially evaluated, but any
6281 /// declarations referenced inside that expression are only used if
6282 /// in fact the current expression is used.
6283 ///
6284 /// This value is used when parsing default function arguments, for which
6285 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6286 /// through varargs) but do not want to mark declarations as "referenced"
6287 /// until the default argument is used.
6289 };
6290
6291 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6292 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6293 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6294 /// have been applied to all subexpressions of the enclosing full expression.
6295 /// This is cleared at the end of each full expression.
6298
6299 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6300
6301 /// Data structure used to record current or nested
6302 /// expression evaluation contexts.
6304 /// The expression evaluation context.
6306
6307 /// Whether the enclosing context needed a cleanup.
6309
6310 /// The number of active cleanup objects when we entered
6311 /// this expression evaluation context.
6313
6314 /// The number of typos encountered during this expression evaluation
6315 /// context (i.e. the number of TypoExprs created).
6316 unsigned NumTypos;
6317
6319
6320 /// The lambdas that are present within this context, if it
6321 /// is indeed an unevaluated context.
6323
6324 /// The declaration that provides context for lambda expressions
6325 /// and block literals if the normal declaration context does not
6326 /// suffice, e.g., in a default function argument.
6328
6329 /// If we are processing a decltype type, a set of call expressions
6330 /// for which we have deferred checking the completeness of the return type.
6332
6333 /// If we are processing a decltype type, a set of temporary binding
6334 /// expressions for which we have deferred checking the destructor.
6336
6338
6339 /// Expressions appearing as the LHS of a volatile assignment in this
6340 /// context. We produce a warning for these when popping the context if
6341 /// they are not discarded-value expressions nor unevaluated operands.
6343
6344 /// Set of candidates for starting an immediate invocation.
6347
6348 /// Set of DeclRefExprs referencing a consteval function when used in a
6349 /// context not already known to be immediately invoked.
6351
6352 /// P2718R0 - Lifetime extension in range-based for loops.
6353 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6354 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6355 /// InLifetimeExtendingContext is true.
6357
6358 /// \brief Describes whether we are in an expression constext which we have
6359 /// to handle differently.
6364 EK_Other
6365 } ExprContext;
6366
6367 // A context can be nested in both a discarded statement context and
6368 // an immediate function context, so they need to be tracked independently.
6372
6373 bool IsCurrentlyCheckingDefaultArgumentOrInitializer = false;
6374
6375 // We are in a constant context, but we also allow
6376 // non constant expressions, for example for array bounds (which may be
6377 // VLAs).
6378 bool InConditionallyConstantEvaluateContext = false;
6379
6380 /// Whether we are currently in a context in which all temporaries must be
6381 /// lifetime-extended, even if they're not bound to a reference (for
6382 /// example, in a for-range initializer).
6383 bool InLifetimeExtendingContext = false;
6384
6385 // When evaluating immediate functions in the initializer of a default
6386 // argument or default member initializer, this is the declaration whose
6387 // default initializer is being evaluated and the location of the call
6388 // or constructor definition.
6391 DeclContext *Context)
6392 : Loc(Loc), Decl(Decl), Context(Context) {
6393 assert(Decl && Context && "invalid initialization context");
6394 }
6395
6397 ValueDecl *Decl = nullptr;
6398 DeclContext *Context = nullptr;
6399 };
6400 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6401
6403 unsigned NumCleanupObjects,
6404 CleanupInfo ParentCleanup,
6405 Decl *ManglingContextDecl,
6406 ExpressionKind ExprContext)
6407 : Context(Context), ParentCleanup(ParentCleanup),
6408 NumCleanupObjects(NumCleanupObjects), NumTypos(0),
6409 ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext),
6410 InDiscardedStatement(false), InImmediateFunctionContext(false),
6411 InImmediateEscalatingFunctionContext(false) {}
6412
6413 bool isUnevaluated() const {
6414 return Context == ExpressionEvaluationContext::Unevaluated ||
6415 Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
6416 Context == ExpressionEvaluationContext::UnevaluatedList;
6417 }
6418
6420 return Context == ExpressionEvaluationContext::PotentiallyEvaluated ||
6421 Context ==
6422 ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed ||
6423 Context == ExpressionEvaluationContext::ConstantEvaluated;
6424 }
6425
6426 bool isConstantEvaluated() const {
6427 return Context == ExpressionEvaluationContext::ConstantEvaluated ||
6428 Context == ExpressionEvaluationContext::ImmediateFunctionContext;
6429 }
6430
6432 return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
6433 (Context == ExpressionEvaluationContext::DiscardedStatement &&
6434 InImmediateFunctionContext) ||
6435 // C++23 [expr.const]p14:
6436 // An expression or conversion is in an immediate function
6437 // context if it is potentially evaluated and either:
6438 // * its innermost enclosing non-block scope is a function
6439 // parameter scope of an immediate function, or
6440 // * its enclosing statement is enclosed by the compound-
6441 // statement of a consteval if statement.
6442 (Context == ExpressionEvaluationContext::PotentiallyEvaluated &&
6443 InImmediateFunctionContext);
6444 }
6445
6447 return Context == ExpressionEvaluationContext::DiscardedStatement ||
6448 (Context ==
6449 ExpressionEvaluationContext::ImmediateFunctionContext &&
6450 InDiscardedStatement);
6451 }
6452 };
6453
6455 assert(!ExprEvalContexts.empty() &&
6456 "Must be in an expression evaluation context");
6457 return ExprEvalContexts.back();
6458 };
6459
6461 assert(!ExprEvalContexts.empty() &&
6462 "Must be in an expression evaluation context");
6463 return ExprEvalContexts.back();
6464 };
6465
6467 assert(ExprEvalContexts.size() >= 2 &&
6468 "Must be in an expression evaluation context");
6469 return ExprEvalContexts[ExprEvalContexts.size() - 2];
6470 };
6471
6473 return const_cast<Sema *>(this)->parentEvaluationContext();
6474 };
6475
6476 bool isAttrContext() const {
6477 return ExprEvalContexts.back().ExprContext ==
6479 }
6480
6481 /// Increment when we find a reference; decrement when we find an ignored
6482 /// assignment. Ultimately the value is 0 if every reference is an ignored
6483 /// assignment.
6484 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
6485
6486 /// Used to control the generation of ExprWithCleanups.
6488
6489 /// ExprCleanupObjects - This is the stack of objects requiring
6490 /// cleanup that are created by the current full expression.
6492
6493 // AssignmentAction - This is used by all the assignment diagnostic functions
6494 // to represent what is actually causing the operation
6505
6506 /// Determine whether the use of this declaration is valid, without
6507 /// emitting diagnostics.
6508 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
6509 // A version of DiagnoseUseOfDecl that should be used if overload resolution
6510 // has been used to find this declaration, which means we don't have to bother
6511 // checking the trailing requires clause.
6513 return DiagnoseUseOfDecl(
6514 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
6515 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
6516 /*SkipTrailingRequiresClause=*/true);
6517 }
6518
6519 /// Determine whether the use of this declaration is valid, and
6520 /// emit any corresponding diagnostics.
6521 ///
6522 /// This routine diagnoses various problems with referencing
6523 /// declarations that can occur when using a declaration. For example,
6524 /// it might warn if a deprecated or unavailable declaration is being
6525 /// used, or produce an error (and return true) if a C++0x deleted
6526 /// function is being used.
6527 ///
6528 /// \returns true if there was an error (this declaration cannot be
6529 /// referenced), false otherwise.
6531 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
6532 bool ObjCPropertyAccess = false,
6533 bool AvoidPartialAvailabilityChecks = false,
6534 ObjCInterfaceDecl *ClassReciever = nullptr,
6535 bool SkipTrailingRequiresClause = false);
6536
6537 /// Emit a note explaining that this function is deleted.
6539
6540 /// DiagnoseSentinelCalls - This routine checks whether a call or
6541 /// message-send is to a declaration with the sentinel attribute, and
6542 /// if so, it checks that the requirements of the sentinel are
6543 /// satisfied.
6545 ArrayRef<Expr *> Args);
6546
6548 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
6557
6559
6563
6564 /// Check whether E, which is either a discarded-value expression or an
6565 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
6566 /// lvalue, and if so, remove it from the list of volatile-qualified
6567 /// assignments that we are going to warn are deprecated.
6569
6571
6572 // Functions for marking a declaration referenced. These functions also
6573 // contain the relevant logic for marking if a reference to a function or
6574 // variable is an odr-use (in the C++11 sense). There are separate variants
6575 // for expressions referring to a decl; these exist because odr-use marking
6576 // needs to be delayed for some constant variables when we build one of the
6577 // named expressions.
6578 //
6579 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
6580 // should usually be true. This only needs to be set to false if the lack of
6581 // odr-use cannot be determined from the current context (for instance,
6582 // because the name denotes a virtual function and was written without an
6583 // explicit nested-name-specifier).
6584 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
6585
6586 /// Mark a function referenced, and check whether it is odr-used
6587 /// (C++ [basic.def.odr]p2, C99 6.9p3)
6589 bool MightBeOdrUse = true);
6590
6591 /// Mark a variable referenced, and check whether it is odr-used
6592 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
6593 /// used directly for normal expressions referring to VarDecl.
6595
6596 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
6597 ///
6598 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
6599 /// be handled with care if the DeclRefExpr is not newly-created.
6600 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
6601
6602 /// Perform reference-marking and odr-use handling for a MemberExpr.
6604
6605 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
6608 unsigned CapturingScopeIndex);
6609
6611 void CleanupVarDeclMarking();
6612
6618
6619 /// Try to capture the given variable.
6620 ///
6621 /// \param Var The variable to capture.
6622 ///
6623 /// \param Loc The location at which the capture occurs.
6624 ///
6625 /// \param Kind The kind of capture, which may be implicit (for either a
6626 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
6627 ///
6628 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
6629 /// an explicit lambda capture.
6630 ///
6631 /// \param BuildAndDiagnose Whether we are actually supposed to add the
6632 /// captures or diagnose errors. If false, this routine merely check whether
6633 /// the capture can occur without performing the capture itself or complaining
6634 /// if the variable cannot be captured.
6635 ///
6636 /// \param CaptureType Will be set to the type of the field used to capture
6637 /// this variable in the innermost block or lambda. Only valid when the
6638 /// variable can be captured.
6639 ///
6640 /// \param DeclRefType Will be set to the type of a reference to the capture
6641 /// from within the current scope. Only valid when the variable can be
6642 /// captured.
6643 ///
6644 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
6645 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
6646 /// This is useful when enclosing lambdas must speculatively capture
6647 /// variables that may or may not be used in certain specializations of
6648 /// a nested generic lambda.
6649 ///
6650 /// \returns true if an error occurred (i.e., the variable cannot be
6651 /// captured) and false if the capture succeeded.
6653 TryCaptureKind Kind, SourceLocation EllipsisLoc,
6654 bool BuildAndDiagnose, QualType &CaptureType,
6655 QualType &DeclRefType,
6656 const unsigned *const FunctionScopeIndexToStopAt);
6657
6658 /// Try to capture the given variable.
6661 SourceLocation EllipsisLoc = SourceLocation());
6662
6663 /// Checks if the variable must be captured.
6665
6666 /// Given a variable, determine the type that a reference to that
6667 /// variable will have in the given scope.
6669
6670 /// Mark all of the declarations referenced within a particular AST node as
6671 /// referenced. Used when template instantiation instantiates a non-dependent
6672 /// type -- entities referenced by the type are now referenced.
6674
6675 /// Mark any declarations that appear within this expression or any
6676 /// potentially-evaluated subexpressions as "referenced".
6677 ///
6678 /// \param SkipLocalVariables If true, don't mark local variables as
6679 /// 'referenced'.
6680 /// \param StopAt Subexpressions that we shouldn't recurse into.
6682 Expr *E, bool SkipLocalVariables = false,
6683 ArrayRef<const Expr *> StopAt = std::nullopt);
6684
6685 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
6686 /// conversion.
6688
6689 /// Conditionally issue a diagnostic based on the statements's reachability
6690 /// analysis.
6691 ///
6692 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
6693 /// the function body is parsed, and then do a basic reachability analysis to
6694 /// determine if the statement is reachable. If it is unreachable, the
6695 /// diagnostic will not be emitted.
6697 const PartialDiagnostic &PD);
6698
6699 /// Conditionally issue a diagnostic based on the current
6700 /// evaluation context.
6701 ///
6702 /// \param Statement If Statement is non-null, delay reporting the
6703 /// diagnostic until the function body is parsed, and then do a basic
6704 /// reachability analysis to determine if the statement is reachable.
6705 /// If it is unreachable, the diagnostic will not be emitted.
6706 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
6707 const PartialDiagnostic &PD);
6708 /// Similar, but diagnostic is only produced if all the specified statements
6709 /// are reachable.
6711 const PartialDiagnostic &PD);
6712
6713 // Primary Expressions.
6715
6717 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
6718 bool HasTrailingLParen, bool IsAddressOfOperand,
6719 CorrectionCandidateCallback *CCC = nullptr,
6720 bool IsInlineAsmIdentifier = false,
6721 Token *KeywordReplacement = nullptr);
6722
6723 /// Decomposes the given name into a DeclarationNameInfo, its location, and
6724 /// possibly a list of template arguments.
6725 ///
6726 /// If this produces template arguments, it is permitted to call
6727 /// DecomposeTemplateName.
6728 ///
6729 /// This actually loses a lot of source location information for
6730 /// non-standard name kinds; we should consider preserving that in
6731 /// some way.
6734 DeclarationNameInfo &NameInfo,
6735 const TemplateArgumentListInfo *&TemplateArgs);
6736
6737 /// Diagnose a lookup that found results in an enclosing class during error
6738 /// recovery. This usually indicates that the results were found in a
6739 /// dependent base class that could not be searched as part of a template
6740 /// definition. Always issues a diagnostic (though this may be only a warning
6741 /// in MS compatibility mode).
6742 ///
6743 /// Return \c true if the error is unrecoverable, or \c false if the caller
6744 /// should attempt to recover using these lookup results.
6746
6747 /// Diagnose an empty lookup.
6748 ///
6749 /// \return false if new lookup candidates were found
6750 bool
6753 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
6754 ArrayRef<Expr *> Args = std::nullopt,
6755 DeclContext *LookupCtx = nullptr,
6756 TypoExpr **Out = nullptr);
6757
6758 /// If \p D cannot be odr-used in the current expression evaluation context,
6759 /// return a reason explaining why. Otherwise, return NOUR_None.
6761
6764 const CXXScopeSpec *SS = nullptr);
6765 DeclRefExpr *
6767 const DeclarationNameInfo &NameInfo,
6768 const CXXScopeSpec *SS = nullptr,
6769 NamedDecl *FoundD = nullptr,
6770 SourceLocation TemplateKWLoc = SourceLocation(),
6771 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6772
6773 /// BuildDeclRefExpr - Build an expression that references a
6774 /// declaration that does not require a closure capture.
6775 DeclRefExpr *
6777 const DeclarationNameInfo &NameInfo,
6778 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
6779 SourceLocation TemplateKWLoc = SourceLocation(),
6780 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6781
6782 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
6783 bool HasTrailingLParen);
6784
6785 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
6786 /// declaration name, generally during template instantiation.
6787 /// There's a large number of things which don't need to be done along
6788 /// this path.
6790 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
6791 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
6792
6794 bool NeedsADL,
6795 bool AcceptInvalidDecl = false);
6796
6797 /// Complete semantic analysis for a reference to the given declaration.
6799 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
6800 NamedDecl *FoundD = nullptr,
6801 const TemplateArgumentListInfo *TemplateArgs = nullptr,
6802 bool AcceptInvalidDecl = false);
6803
6804 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
6805 // where Tokens representing function local predefined macros (such as
6806 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
6808
6812
6813 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
6814
6815 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
6817 Scope *UDLScope = nullptr);
6820 MultiExprArg Val);
6821
6822 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
6823 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
6824 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
6825 /// from multiple tokens. However, the common case is that StringToks points
6826 /// to one string.
6828 Scope *UDLScope = nullptr);
6829
6831
6832 /// ControllingExprOrType is either an opaque pointer coming out of a
6833 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
6834 /// into two so we don't take a void *, but that's awkward because one of
6835 /// the operands is either a ParsedType or an Expr *, which doesn't lend
6836 /// itself to generic code very well.
6838 SourceLocation DefaultLoc,
6839 SourceLocation RParenLoc,
6840 bool PredicateIsExpr,
6841 void *ControllingExprOrType,
6842 ArrayRef<ParsedType> ArgTypes,
6843 ArrayRef<Expr *> ArgExprs);
6844 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
6845 /// it'd be better to split this interface into two so we don't take a
6846 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
6847 /// isn't a trivial change.
6849 SourceLocation DefaultLoc,
6850 SourceLocation RParenLoc,
6851 bool PredicateIsExpr,
6852 void *ControllingExprOrType,
6854 ArrayRef<Expr *> Exprs);
6855
6856 // Binary/Unary Operators. 'Tok' is the token for the operator.
6858 Expr *InputExpr, bool IsAfterAmp = false);
6860 Expr *Input, bool IsAfterAmp = false);
6861
6862 /// Unary Operators. 'Tok' is the token for the operator.
6864 Expr *Input, bool IsAfterAmp = false);
6865
6866 /// Determine whether the given expression is a qualified member
6867 /// access expression, of a form that could be turned into a pointer to member
6868 /// with the address-of operator.
6871 const Expr *Op,
6872 const CXXMethodDecl *MD);
6873
6874 /// CheckAddressOfOperand - The operand of & must be either a function
6875 /// designator or an lvalue designating an object. If it is an lvalue, the
6876 /// object cannot be declared with storage class register or be a bit field.
6877 /// Note: The usual conversions are *not* applied to the operand of the &
6878 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
6879 /// In C++, the operand might be an overloaded function name, in which case
6880 /// we allow the '&' but retain the overloaded-function type.
6882
6883 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
6884 /// _Alignas(type-name) .
6885 /// [dcl.align] An alignment-specifier of the form
6886 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
6887 ///
6888 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
6889 /// _Alignas(_Alignof(type-name)).
6890 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
6891 SourceLocation OpLoc, SourceRange R);
6892 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
6893 SourceLocation OpLoc, SourceRange R);
6894
6895 /// Build a sizeof or alignof expression given a type operand.
6897 SourceLocation OpLoc,
6898 UnaryExprOrTypeTrait ExprKind,
6899 SourceRange R);
6900
6901 /// Build a sizeof or alignof expression given an expression
6902 /// operand.
6904 UnaryExprOrTypeTrait ExprKind);
6905
6906 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
6907 /// expr and the same for @c alignof and @c __alignof
6908 /// Note that the ArgRange is invalid if isType is false.
6910 UnaryExprOrTypeTrait ExprKind,
6911 bool IsType, void *TyOrEx,
6912 SourceRange ArgRange);
6913
6914 /// Check for operands with placeholder types and complain if found.
6915 /// Returns ExprError() if there was an error and no recovery was possible.
6917 bool CheckVecStepExpr(Expr *E);
6918
6919 /// Check the constraints on expression operands to unary type expression
6920 /// and type traits.
6921 ///
6922 /// Completes any types necessary and validates the constraints on the operand
6923 /// expression. The logic mostly mirrors the type-based overload, but may
6924 /// modify the expression as it completes the type for that expression through
6925 /// template instantiation, etc.
6927
6928 /// Check the constraints on operands to unary expression and type
6929 /// traits.
6930 ///
6931 /// This will complete any types necessary, and validate the various
6932 /// constraints on those operands.
6933 ///
6934 /// The UsualUnaryConversions() function is *not* called by this routine.
6935 /// C99 6.3.2.1p[2-4] all state:
6936 /// Except when it is the operand of the sizeof operator ...
6937 ///
6938 /// C++ [expr.sizeof]p4
6939 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
6940 /// standard conversions are not applied to the operand of sizeof.
6941 ///
6942 /// This policy is followed for all of the unary trait expressions.
6944 SourceRange ExprRange,
6945 UnaryExprOrTypeTrait ExprKind,
6946 StringRef KWName);
6947
6949 tok::TokenKind Kind, Expr *Input);
6950
6952 MultiExprArg ArgExprs,
6953 SourceLocation RLoc);
6955 Expr *Idx, SourceLocation RLoc);
6956
6958 Expr *ColumnIdx,
6959 SourceLocation RBLoc);
6960
6961 /// ConvertArgumentsForCall - Converts the arguments specified in
6962 /// Args/NumArgs to the parameter types of the function FDecl with
6963 /// function prototype Proto. Call is the call expression itself, and
6964 /// Fn is the function expression. For a C++ member function, this
6965 /// routine does not attempt to convert the object argument. Returns
6966 /// true if the call is ill-formed.
6968 const FunctionProtoType *Proto,
6969 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
6970 bool ExecConfig = false);
6971
6972 /// CheckStaticArrayArgument - If the given argument corresponds to a static
6973 /// array parameter, check that it is non-null, and that if it is formed by
6974 /// array-to-pointer decay, the underlying array is sufficiently large.
6975 ///
6976 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
6977 /// the array type derivation, then for each call to the function, the value
6978 /// of the corresponding actual argument shall provide access to the first
6979 /// element of an array with at least as many elements as specified by the
6980 /// size expression.
6982 const Expr *ArgExpr);
6983
6984 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
6985 /// This provides the location of the left/right parens and a list of comma
6986 /// locations.
6988 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6989 Expr *ExecConfig = nullptr);
6990
6991 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
6992 /// This provides the location of the left/right parens and a list of comma
6993 /// locations.
6995 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6996 Expr *ExecConfig = nullptr,
6997 bool IsExecConfig = false,
6998 bool AllowRecovery = false);
6999
7000 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
7001 // with the specified CallArgs
7003 MultiExprArg CallArgs);
7004
7006
7007 /// BuildResolvedCallExpr - Build a call to a resolved expression,
7008 /// i.e. an expression not of \p OverloadTy. The expression should
7009 /// unary-convert to an expression of function-pointer or
7010 /// block-pointer type.
7011 ///
7012 /// \param NDecl the declaration being called, if available
7014 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
7015 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
7016 Expr *Config = nullptr, bool IsExecConfig = false,
7017 ADLCallKind UsesADL = ADLCallKind::NotADL);
7018
7020 ParsedType &Ty, SourceLocation RParenLoc,
7021 Expr *CastExpr);
7022
7023 /// Prepares for a scalar cast, performing all the necessary stages
7024 /// except the final cast and returning the kind required.
7026
7027 /// Build an altivec or OpenCL literal.
7029 SourceLocation RParenLoc, Expr *E,
7030 TypeSourceInfo *TInfo);
7031
7032 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7033 /// the ParenListExpr into a sequence of comma binary operators.
7035
7037 SourceLocation RParenLoc, Expr *InitExpr);
7038
7040 TypeSourceInfo *TInfo,
7041 SourceLocation RParenLoc,
7042 Expr *LiteralExpr);
7043
7044 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7045 SourceLocation RBraceLoc);
7046
7047 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7048 SourceLocation RBraceLoc);
7049
7050 /// Binary Operators. 'Tok' is the token for the operator.
7052 Expr *LHSExpr, Expr *RHSExpr);
7054 Expr *LHSExpr, Expr *RHSExpr);
7055
7056 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7057 /// operator @p Opc at location @c TokLoc. This routine only supports
7058 /// built-in operations; ActOnBinOp handles overloaded operators.
7060 Expr *LHSExpr, Expr *RHSExpr);
7062 UnresolvedSetImpl &Functions);
7063
7064 /// Look for instances where it is likely the comma operator is confused with
7065 /// another operator. There is an explicit list of acceptable expressions for
7066 /// the left hand side of the comma operator, otherwise emit a warning.
7067 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7068
7069 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7070 /// in the case of a the GNU conditional expr extension.
7072 SourceLocation ColonLoc, Expr *CondExpr,
7073 Expr *LHSExpr, Expr *RHSExpr);
7074
7075 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7077 LabelDecl *TheDecl);
7078
7079 void ActOnStartStmtExpr();
7080 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7081 SourceLocation RPLoc);
7083 SourceLocation RPLoc, unsigned TemplateDepth);
7084 // Handle the final expression in a statement expression.
7086 void ActOnStmtExprError();
7087
7088 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
7091 bool isBrackets; // true if [expr], false if .ident
7092 union {
7095 } U;
7096 };
7097
7098 /// __builtin_offsetof(type, a.b[123][456].c)
7100 TypeSourceInfo *TInfo,
7101 ArrayRef<OffsetOfComponent> Components,
7102 SourceLocation RParenLoc);
7105 ParsedType ParsedArgTy,
7106 ArrayRef<OffsetOfComponent> Components,
7107 SourceLocation RParenLoc);
7108
7109 // __builtin_choose_expr(constExpr, expr1, expr2)
7110 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7111 Expr *LHSExpr, Expr *RHSExpr,
7112 SourceLocation RPLoc);
7113
7114 // __builtin_va_arg(expr, type)
7116 SourceLocation RPLoc);
7118 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7119
7120 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7121 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7123 SourceLocation BuiltinLoc,
7124 SourceLocation RPLoc);
7125
7126 // #embed
7128 StringLiteral *BinaryData);
7129
7130 // Build a potentially resolved SourceLocExpr.
7132 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7133 DeclContext *ParentContext);
7134
7135 // __null
7137
7138 bool CheckCaseExpression(Expr *E);
7139
7140 //===------------------------- "Block" Extension ------------------------===//
7141
7142 /// ActOnBlockStart - This callback is invoked when a block literal is
7143 /// started.
7144 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7145
7146 /// ActOnBlockArguments - This callback allows processing of block arguments.
7147 /// If there are no arguments, this is still invoked.
7148 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7149 Scope *CurScope);
7150
7151 /// ActOnBlockError - If there is an error parsing a block, this callback
7152 /// is invoked to pop the information about the block from the action impl.
7153 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7154
7155 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7156 /// literal was successfully completed. ^(int x){...}
7158 Scope *CurScope);
7159
7160 //===---------------------------- Clang Extensions ----------------------===//
7161
7162 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7163 /// provided arguments.
7164 ///
7165 /// __builtin_convertvector( value, dst type )
7166 ///
7168 SourceLocation BuiltinLoc,
7169 SourceLocation RParenLoc);
7170
7171 //===---------------------------- OpenCL Features -----------------------===//
7172
7173 /// Parse a __builtin_astype expression.
7174 ///
7175 /// __builtin_astype( value, dst type )
7176 ///
7178 SourceLocation BuiltinLoc,
7179 SourceLocation RParenLoc);
7180
7181 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7183 SourceLocation BuiltinLoc,
7184 SourceLocation RParenLoc);
7185
7186 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7188 ArrayRef<Expr *> SubExprs,
7189 QualType T = QualType());
7190
7191 /// Cast a base object to a member's actual type.
7192 ///
7193 /// There are two relevant checks:
7194 ///
7195 /// C++ [class.access.base]p7:
7196 ///
7197 /// If a class member access operator [...] is used to access a non-static
7198 /// data member or non-static member function, the reference is ill-formed
7199 /// if the left operand [...] cannot be implicitly converted to a pointer to
7200 /// the naming class of the right operand.
7201 ///
7202 /// C++ [expr.ref]p7:
7203 ///
7204 /// If E2 is a non-static data member or a non-static member function, the
7205 /// program is ill-formed if the class of which E2 is directly a member is
7206 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7207 ///
7208 /// Note that the latter check does not consider access; the access of the
7209 /// "real" base class is checked as appropriate when checking the access of
7210 /// the member name.
7212 NestedNameSpecifier *Qualifier,
7213 NamedDecl *FoundDecl,
7214 NamedDecl *Member);
7215
7216 /// CheckCallReturnType - Checks that a call expression's return type is
7217 /// complete. Returns true on failure. The location passed in is the location
7218 /// that best represents the call.
7220 CallExpr *CE, FunctionDecl *FD);
7221
7222 /// Emit a warning for all pending noderef expressions that we recorded.
7223 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
7224
7226
7227 /// Instantiate or parse a C++ default argument expression as necessary.
7228 /// Return true on error.
7230 ParmVarDecl *Param, Expr *Init = nullptr,
7231 bool SkipImmediateInvocations = true);
7232
7233 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7234 /// the default expr if needed.
7236 ParmVarDecl *Param, Expr *Init = nullptr);
7237
7238 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7239 /// invocation.
7241
7243
7244 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7245 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7246
7247 /// Abstract base class used for diagnosing integer constant
7248 /// expression violations.
7250 public:
7252
7253 VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {}
7254
7255 virtual SemaDiagnosticBuilder
7256 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7258 SourceLocation Loc) = 0;
7259 virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc);
7261 };
7262
7266 };
7267
7268 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7269 /// and reports the appropriate diagnostics. Returns false on success.
7270 /// Can optionally return the value of the expression.
7272 VerifyICEDiagnoser &Diagnoser,
7273 AllowFoldKind CanFold = NoFold);
7275 unsigned DiagID,
7276 AllowFoldKind CanFold = NoFold);
7278 llvm::APSInt *Result = nullptr,
7279 AllowFoldKind CanFold = NoFold);
7281 AllowFoldKind CanFold = NoFold) {
7282 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7283 }
7284
7285 /// DiagnoseAssignmentAsCondition - Given that an expression is
7286 /// being used as a boolean condition, warn if it's an assignment.
7288
7289 /// Redundant parentheses over an equality comparison can indicate
7290 /// that the user intended an assignment used as condition.
7292
7294 public:
7295 FullExprArg() : E(nullptr) {}
7296 FullExprArg(Sema &actions) : E(nullptr) {}
7297
7298 ExprResult release() { return E; }
7299
7300 Expr *get() const { return E; }
7301
7302 Expr *operator->() { return E; }
7303
7304 private:
7305 // FIXME: No need to make the entire Sema class a friend when it's just
7306 // Sema::MakeFullExpr that needs access to the constructor below.
7307 friend class Sema;
7308
7309 explicit FullExprArg(Expr *expr) : E(expr) {}
7310
7311 Expr *E;
7312 };
7313
7315 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7316 }
7318 return FullExprArg(
7319 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7320 }
7322 ExprResult FE =
7323 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7324 /*DiscardedValue*/ true);
7325 return FullExprArg(FE.get());
7326 }
7327
7329 Decl *ConditionVar;
7331 bool Invalid;
7332 std::optional<bool> KnownValue;
7333
7334 friend class Sema;
7335 ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
7336 bool IsConstexpr)
7337 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7338 if (IsConstexpr && Condition.get()) {
7339 if (std::optional<llvm::APSInt> Val =
7340 Condition.get()->getIntegerConstantExpr(S.Context)) {
7341 KnownValue = !!(*Val);
7342 }
7343 }
7344 }
7345 explicit ConditionResult(bool Invalid)
7346 : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
7347 KnownValue(std::nullopt) {}
7348
7349 public:
7351 bool isInvalid() const { return Invalid; }
7352 std::pair<VarDecl *, Expr *> get() const {
7353 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7354 Condition.get());
7355 }
7356 std::optional<bool> getKnownValue() const { return KnownValue; }
7357 };
7359
7360 /// CheckBooleanCondition - Diagnose problems involving the use of
7361 /// the given expression as a boolean condition (e.g. in an if
7362 /// statement). Also performs the standard function and array
7363 /// decays, possibly changing the input variable.
7364 ///
7365 /// \param Loc - A location associated with the condition, e.g. the
7366 /// 'if' keyword.
7367 /// \return true iff there were any errors
7369 bool IsConstexpr = false);
7370
7371 enum class ConditionKind {
7372 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7373 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7374 Switch ///< An integral condition for a 'switch' statement.
7375 };
7376
7377 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7378 ConditionKind CK, bool MissingOK = false);
7379
7380 QualType CheckConditionalOperands( // C99 6.5.15
7381 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
7382 ExprObjectKind &OK, SourceLocation QuestionLoc);
7383
7384 /// Emit a specialized diagnostic when one expression is a null pointer
7385 /// constant and the other is not a pointer. Returns true if a diagnostic is
7386 /// emitted.
7387 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7388 SourceLocation QuestionLoc);
7389
7390 /// type checking for vector binary operators.
7392 SourceLocation Loc, bool IsCompAssign,
7393 bool AllowBothBool, bool AllowBoolConversion,
7394 bool AllowBoolOperation, bool ReportInvalid);
7395
7396 /// Return a signed ext_vector_type that is of identical size and number of
7397 /// elements. For floating point vectors, return an integer type of identical
7398 /// size and number of elements. In the non ext_vector_type case, search from
7399 /// the largest type to the smallest type to avoid cases where long long ==
7400 /// long, where long gets picked over long long.
7403
7404 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7405 /// operates on extended vector types. Instead of producing an IntTy result,
7406 /// like a scalar comparison, a vector comparison produces a vector of integer
7407 /// types.
7410 BinaryOperatorKind Opc);
7413 BinaryOperatorKind Opc);
7416
7417 /// Context in which we're performing a usual arithmetic conversion.
7419 /// An arithmetic operation.
7421 /// A bitwise operation.
7423 /// A comparison.
7425 /// A conditional (?:) operator.
7427 /// A compound assignment expression.
7429 };
7430
7431 // type checking for sizeless vector binary operators.
7433 SourceLocation Loc, bool IsCompAssign,
7434 ArithConvKind OperationKind);
7435
7436 /// Type checking for matrix binary operators.
7439 bool IsCompAssign);
7441 SourceLocation Loc, bool IsCompAssign);
7442
7443 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
7444 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
7445 /// VLST) allowed?
7446 ///
7447 /// This will also return false if the two given types do not make sense from
7448 /// the perspective of SVE bitcasts.
7449 bool isValidSveBitcast(QualType srcType, QualType destType);
7450
7451 /// Are the two types matrix types and do they have the same dimensions i.e.
7452 /// do they have the same number of rows and the same number of columns?
7454
7455 bool areVectorTypesSameSize(QualType srcType, QualType destType);
7456
7457 /// Are the two types lax-compatible vector types? That is, given
7458 /// that one of them is a vector, do they have equal storage sizes,
7459 /// where the storage size is the number of elements times the element
7460 /// size?
7461 ///
7462 /// This will also return false if either of the types is neither a
7463 /// vector nor a real type.
7464 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
7465
7466 /// Is this a legal conversion between two types, one of which is
7467 /// known to be a vector type?
7468 bool isLaxVectorConversion(QualType srcType, QualType destType);
7469
7470 // This returns true if at least one of the types is an altivec vector.
7471 bool anyAltivecTypes(QualType srcType, QualType destType);
7472
7473 // type checking C++ declaration initializers (C++ [dcl.init]).
7474
7475 /// Check a cast of an unknown-any type. We intentionally only
7476 /// trigger this for C-style casts.
7480
7481 /// Force an expression with unknown-type to an expression of the
7482 /// given type.
7484
7485 /// Type-check an expression that's being passed to an
7486 /// __unknown_anytype parameter.
7488 QualType &paramType);
7489
7490 // CheckMatrixCast - Check type constraints for matrix casts.
7491 // We allow casting between matrixes of the same dimensions i.e. when they
7492 // have the same number of rows and column. Returns true if the cast is
7493 // invalid.
7494 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
7495 CastKind &Kind);
7496
7497 // CheckVectorCast - check type constraints for vectors.
7498 // Since vectors are an extension, there are no C standard reference for this.
7499 // We allow casting between vectors and integer datatypes of the same size.
7500 // returns true if the cast is invalid
7501 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
7502 CastKind &Kind);
7503
7504 /// Prepare `SplattedExpr` for a vector splat operation, adding
7505 /// implicit casts if necessary.
7506 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
7507
7508 // CheckExtVectorCast - check type constraints for extended vectors.
7509 // Since vectors are an extension, there are no C standard reference for this.
7510 // We allow casting between vectors and integer datatypes of the same size,
7511 // or vectors and the element type of that vector.
7512 // returns the cast expr
7514 CastKind &Kind);
7515
7518 }
7519
7520 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
7521 // functions and arrays to their respective pointers (C99 6.3.2.1).
7523
7524 /// CallExprUnaryConversions - a special case of an unary conversion
7525 /// performed on a function designator of a call expression.
7527
7528 // DefaultFunctionArrayConversion - converts functions and arrays
7529 // to their respective pointers (C99 6.3.2.1).
7531
7532 // DefaultFunctionArrayLvalueConversion - converts functions and
7533 // arrays to their respective pointers and performs the
7534 // lvalue-to-rvalue conversion.
7536 bool Diagnose = true);
7537
7538 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
7539 // the operand. This function is a no-op if the operand has a function type
7540 // or an array type.
7542
7543 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
7544 // do not have a prototype. Integer promotions are performed on each
7545 // argument, and arguments that have type float are promoted to double.
7547
7549 const FunctionProtoType *Proto,
7550 Expr *Fn);
7551
7552 // Used for determining in which context a type is allowed to be passed to a
7553 // vararg function.
7561
7562 /// Determine the degree of POD-ness for an expression.
7563 /// Incomplete types are considered POD, since this check can be performed
7564 /// when we're in an unevaluated context.
7566
7567 /// Check to see if the given expression is a valid argument to a variadic
7568 /// function, issuing a diagnostic if not.
7570
7571 /// GatherArgumentsForCall - Collector argument expressions for various
7572 /// form of call prototypes.
7574 const FunctionProtoType *Proto,
7575 unsigned FirstParam, ArrayRef<Expr *> Args,
7576 SmallVectorImpl<Expr *> &AllArgs,
7578 bool AllowExplicit = false,
7579 bool IsListInitialization = false);
7580
7581 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
7582 // will create a runtime trap if the resulting type is not a POD type.
7584 FunctionDecl *FDecl);
7585
7586 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
7587 // operands and then handles various conversions that are common to binary
7588 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
7589 // routine returns the first non-arithmetic type found. The client is
7590 // responsible for emitting appropriate error diagnostics.
7593
7594 /// AssignConvertType - All of the 'assignment' semantic checks return this
7595 /// enum to indicate whether the assignment was allowed. These checks are
7596 /// done for simple assignments, as well as initialization, return from
7597 /// function, argument passing, etc. The query is phrased in terms of a
7598 /// source and destination type.
7600 /// Compatible - the types are compatible according to the standard.
7602
7603 /// PointerToInt - The assignment converts a pointer to an int, which we
7604 /// accept as an extension.
7606
7607 /// IntToPointer - The assignment converts an int to a pointer, which we
7608 /// accept as an extension.
7610
7611 /// FunctionVoidPointer - The assignment is between a function pointer and
7612 /// void*, which the standard doesn't allow, but we accept as an extension.
7614
7615 /// IncompatiblePointer - The assignment is between two pointers types that
7616 /// are not compatible, but we accept them as an extension.
7618
7619 /// IncompatibleFunctionPointer - The assignment is between two function
7620 /// pointers types that are not compatible, but we accept them as an
7621 /// extension.
7623
7624 /// IncompatibleFunctionPointerStrict - The assignment is between two
7625 /// function pointer types that are not identical, but are compatible,
7626 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
7627 /// may trip an indirect call runtime check.
7629
7630 /// IncompatiblePointerSign - The assignment is between two pointers types
7631 /// which point to integers which have a different sign, but are otherwise
7632 /// identical. This is a subset of the above, but broken out because it's by
7633 /// far the most common case of incompatible pointers.
7635
7636 /// CompatiblePointerDiscardsQualifiers - The assignment discards
7637 /// c/v/r qualifiers, which we accept as an extension.
7639
7640 /// IncompatiblePointerDiscardsQualifiers - The assignment
7641 /// discards qualifiers that we don't permit to be discarded,
7642 /// like address spaces.
7644
7645 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
7646 /// changes address spaces in nested pointer types which is not allowed.
7647 /// For instance, converting __private int ** to __generic int ** is
7648 /// illegal even though __private could be converted to __generic.
7650
7651 /// IncompatibleNestedPointerQualifiers - The assignment is between two
7652 /// nested pointer types, and the qualifiers other than the first two
7653 /// levels differ e.g. char ** -> const char **, but we accept them as an
7654 /// extension.
7656
7657 /// IncompatibleVectors - The assignment is between two vector types that
7658 /// have the same size, which we accept as an extension.
7660
7661 /// IntToBlockPointer - The assignment converts an int to a block
7662 /// pointer. We disallow this.
7664
7665 /// IncompatibleBlockPointer - The assignment is between two block
7666 /// pointers types that are not compatible.
7668
7669 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
7670 /// id type and something else (that is incompatible with it). For example,
7671 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
7673
7674 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
7675 /// object with __weak qualifier.
7677
7678 /// Incompatible - We reject this conversion outright, it is invalid to
7679 /// represent it in the AST.
7682
7683 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
7684 /// assignment conversion type specified by ConvTy. This returns true if the
7685 /// conversion was invalid or false if the conversion was accepted.
7687 QualType DstType, QualType SrcType,
7688 Expr *SrcExpr, AssignmentAction Action,
7689 bool *Complained = nullptr);
7690
7691 /// CheckAssignmentConstraints - Perform type checking for assignment,
7692 /// argument passing, variable initialization, and function return values.
7693 /// C99 6.5.16.
7695 QualType LHSType,
7696 QualType RHSType);
7697
7698 /// Check assignment constraints and optionally prepare for a conversion of
7699 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
7700 /// is true.
7702 ExprResult &RHS, CastKind &Kind,
7703 bool ConvertRHS = true);
7704
7705 /// Check assignment constraints for an assignment of RHS to LHSType.
7706 ///
7707 /// \param LHSType The destination type for the assignment.
7708 /// \param RHS The source expression for the assignment.
7709 /// \param Diagnose If \c true, diagnostics may be produced when checking
7710 /// for assignability. If a diagnostic is produced, \p RHS will be
7711 /// set to ExprError(). Note that this function may still return
7712 /// without producing a diagnostic, even for an invalid assignment.
7713 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
7714 /// in an audited Core Foundation API and does not need to be checked
7715 /// for ARC retain issues.
7716 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
7717 /// conversions necessary to perform the assignment. If \c false,
7718 /// \p Diagnose must also be \c false.
7720 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
7721 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
7722
7723 // If the lhs type is a transparent union, check whether we
7724 // can initialize the transparent union with the given expression.
7726 ExprResult &RHS);
7727
7728 /// the following "Check" methods will return a valid/converted QualType
7729 /// or a null QualType (indicating an error diagnostic was issued).
7730
7731 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
7733 ExprResult &RHS);
7734
7735 /// Diagnose cases where a scalar was implicitly converted to a vector and
7736 /// diagnose the underlying types. Otherwise, diagnose the error
7737 /// as invalid vector logical operands for non-C++ cases.
7739 ExprResult &RHS);
7740
7742 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
7743 bool IsDivide);
7744 QualType CheckRemainderOperands( // C99 6.5.5
7746 bool IsCompAssign = false);
7747 QualType CheckAdditionOperands( // C99 6.5.6
7749 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
7752 QualType *CompLHSTy = nullptr);
7753 QualType CheckShiftOperands( // C99 6.5.7
7755 BinaryOperatorKind Opc, bool IsCompAssign = false);
7757 QualType CheckCompareOperands( // C99 6.5.8/9
7759 BinaryOperatorKind Opc);
7760 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
7762 BinaryOperatorKind Opc);
7763 QualType CheckLogicalOperands( // C99 6.5.[13,14]
7765 BinaryOperatorKind Opc);
7766 // CheckAssignmentOperands is used for both simple and compound assignment.
7767 // For simple assignment, pass both expressions and a null converted type.
7768 // For compound assignment, pass both expressions and the converted type.
7769 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
7770 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
7771 BinaryOperatorKind Opc);
7772
7773 /// To be used for checking whether the arguments being passed to
7774 /// function exceeds the number of parameters expected for it.
7775 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
7776 bool PartialOverloading = false) {
7777 // We check whether we're just after a comma in code-completion.
7778 if (NumArgs > 0 && PartialOverloading)
7779 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
7780 return NumArgs > NumParams;
7781 }
7782
7783 /// Whether the AST is currently being rebuilt to correct immediate
7784 /// invocations. Immediate invocation candidates and references to consteval
7785 /// functions aren't tracked when this is set.
7787
7792 }
7793
7794 /// Determines whether we are currently in a context that
7795 /// is not evaluated as per C++ [expr] p5.
7798 }
7799
7802 }
7803
7805 assert(!ExprEvalContexts.empty() &&
7806 "Must be in an expression evaluation context");
7807 return ExprEvalContexts.back().InLifetimeExtendingContext;
7808 }
7809
7812 return (Ctx.Context ==
7815 }
7816
7817 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7819 assert(!ExprEvalContexts.empty() &&
7820 "Must be in an expression evaluation context");
7821 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7823 Ctx.DelayedDefaultInitializationContext)
7824 return Ctx.DelayedDefaultInitializationContext;
7825 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7826 Ctx.isUnevaluated())
7827 break;
7828 }
7829 return std::nullopt;
7830 }
7831
7832 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7834 assert(!ExprEvalContexts.empty() &&
7835 "Must be in an expression evaluation context");
7836 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
7837 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7839 !Ctx.DelayedDefaultInitializationContext && Res)
7840 break;
7841 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7842 Ctx.isUnevaluated())
7843 break;
7844 Res = Ctx.DelayedDefaultInitializationContext;
7845 }
7846 return Res;
7847 }
7848
7849 /// keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext
7850 /// flag from previous context.
7852 if (ExprEvalContexts.size() > 2 &&
7853 parentEvaluationContext().InLifetimeExtendingContext) {
7854 auto &LastRecord = ExprEvalContexts.back();
7855 auto &PrevRecord = parentEvaluationContext();
7856 LastRecord.InLifetimeExtendingContext =
7857 PrevRecord.InLifetimeExtendingContext;
7858 }
7859 }
7860
7863 }
7864
7865 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
7866 /// SelfAssigned when inside a CXXMethodDecl.
7867 const FieldDecl *
7869
7871
7872 template <typename... Ts>
7874 const Ts &...Args) {
7875 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7877 }
7878
7879 template <typename... Ts>
7880 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
7881 const Ts &...Args) {
7882 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7884 }
7885
7886 /// Abstract class used to diagnose incomplete types.
7889
7890 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
7891 virtual ~TypeDiagnoser() {}
7892 };
7893
7894 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
7895 protected:
7896 unsigned DiagID;
7897 std::tuple<const Ts &...> Args;
7898
7899 template <std::size_t... Is>
7901 std::index_sequence<Is...>) const {
7902 // Apply all tuple elements to the builder in order.
7903 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
7904 (void)Dummy;
7905 }
7906
7907 public:
7908 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7909 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
7910 assert(DiagID != 0 && "no diagnostic for type diagnoser");
7911 }
7912
7913 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7914 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
7915 emit(DB, std::index_sequence_for<Ts...>());
7916 DB << T;
7917 }
7918 };
7919
7920 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
7921 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
7922 /// For example, a diagnostic with no other parameters would generally have
7923 /// the form "...%select{incomplete|sizeless}0 type %1...".
7924 template <typename... Ts>
7926 public:
7927 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7928 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
7929
7930 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7931 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
7932 this->emit(DB, std::index_sequence_for<Ts...>());
7933 DB << T->isSizelessType() << T;
7934 }
7935 };
7936
7937 /// Check an argument list for placeholders that we won't try to
7938 /// handle later.
7940
7941 /// The C++ "std::source_location::__impl" struct, defined in
7942 /// <source_location>.
7944
7945 /// A stack of expression evaluation contexts.
7947
7948 // Set of failed immediate invocations to avoid double diagnosing.
7950
7951 /// List of SourceLocations where 'self' is implicitly retained inside a
7952 /// block.
7955
7956 /// Do an explicit extend of the given block pointer if we're in ARC.
7958
7959private:
7960 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
7961
7962 /// Methods for marking which expressions involve dereferencing a pointer
7963 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
7964 /// they are parsed, meaning that a noderef pointer may not be accessed. For
7965 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
7966 /// `*p`, but need to check that `address of` is called on it. This requires
7967 /// keeping a container of all pending expressions and checking if the address
7968 /// of them are eventually taken.
7969 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
7970 void CheckAddressOfNoDeref(const Expr *E);
7971
7972 ///@}
7973
7974 //
7975 //
7976 // -------------------------------------------------------------------------
7977 //
7978 //
7979
7980 /// \name C++ Expressions
7981 /// Implementations are in SemaExprCXX.cpp
7982 ///@{
7983
7984public:
7985 /// The C++ "std::bad_alloc" class, which is defined by the C++
7986 /// standard library.
7988
7989 /// The C++ "std::align_val_t" enum class, which is defined by the C++
7990 /// standard library.
7992
7993 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
7995
7996 /// A flag to remember whether the implicit forms of operator new and delete
7997 /// have been declared.
7999
8000 /// Delete-expressions to be analyzed at the end of translation unit
8001 ///
8002 /// This list contains class members, and locations of delete-expressions
8003 /// that could not be proven as to whether they mismatch with new-expression
8004 /// used in initializer of the field.
8005 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
8006
8007 /// Handle the result of the special case name lookup for inheriting
8008 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
8009 /// constructor names in member using declarations, even if 'X' is not the
8010 /// name of the corresponding type.
8012 SourceLocation NameLoc,
8013 const IdentifierInfo &Name);
8014
8016 SourceLocation NameLoc, Scope *S,
8017 CXXScopeSpec &SS, bool EnteringContext);
8019 Scope *S, CXXScopeSpec &SS,
8020 ParsedType ObjectType, bool EnteringContext);
8021
8023 ParsedType ObjectType);
8024
8025 /// Build a C++ typeid expression with a type operand.
8026 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8027 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8028
8029 /// Build a C++ typeid expression with an expression operand.
8030 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8031 Expr *Operand, SourceLocation RParenLoc);
8032
8033 /// ActOnCXXTypeid - Parse typeid( something ).
8035 bool isType, void *TyOrExpr,
8036 SourceLocation RParenLoc);
8037
8038 /// Build a Microsoft __uuidof expression with a type operand.
8039 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8040 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8041
8042 /// Build a Microsoft __uuidof expression with an expression operand.
8043 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8044 Expr *Operand, SourceLocation RParenLoc);
8045
8046 /// ActOnCXXUuidof - Parse __uuidof( something ).
8048 bool isType, void *TyOrExpr,
8049 SourceLocation RParenLoc);
8050
8051 //// ActOnCXXThis - Parse 'this' pointer.
8053
8054 /// Check whether the type of 'this' is valid in the current context.
8056
8057 /// Build a CXXThisExpr and mark it referenced in the current context.
8059 void MarkThisReferenced(CXXThisExpr *This);
8060
8061 /// Try to retrieve the type of the 'this' pointer.
8062 ///
8063 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8065
8066 /// When non-NULL, the C++ 'this' expression is allowed despite the
8067 /// current context not being a non-static member function. In such cases,
8068 /// this provides the type used for 'this'.
8070
8071 /// RAII object used to temporarily allow the C++ 'this' expression
8072 /// to be used, with the given qualifiers on the current class type.
8074 Sema &S;
8075 QualType OldCXXThisTypeOverride;
8076 bool Enabled;
8077
8078 public:
8079 /// Introduce a new scope where 'this' may be allowed (when enabled),
8080 /// using the given declaration (which is either a class template or a
8081 /// class) along with the given qualifiers.
8082 /// along with the qualifiers placed on '*this'.
8083 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8084 bool Enabled = true);
8085
8087 };
8088
8089 /// Make sure the value of 'this' is actually available in the current
8090 /// context, if it is a potentially evaluated context.
8091 ///
8092 /// \param Loc The location at which the capture of 'this' occurs.
8093 ///
8094 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8095 /// capture list.
8096 ///
8097 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8098 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8099 /// This is useful when enclosing lambdas must speculatively capture
8100 /// 'this' that may or may not be used in certain specializations of
8101 /// a nested generic lambda (depending on whether the name resolves to
8102 /// a non-static member function or a static function).
8103 /// \return returns 'true' if failed, 'false' if success.
8105 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8106 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8107 bool ByCopy = false);
8108
8109 /// Determine whether the given type is the type of *this that is used
8110 /// outside of the body of a member function for a type that is currently
8111 /// being defined.
8113
8114 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8116
8117 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8119
8120 //// ActOnCXXThrow - Parse throw expressions.
8123 bool IsThrownVarInScope);
8124
8125 /// CheckCXXThrowOperand - Validate the operand of a throw.
8126 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8127
8128 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8129 /// Can be interpreted either as function-style casting ("int(x)")
8130 /// or class type construction ("ClassType(x,y,z)")
8131 /// or creation of a value-initialized type ("int()").
8133 SourceLocation LParenOrBraceLoc,
8134 MultiExprArg Exprs,
8135 SourceLocation RParenOrBraceLoc,
8136 bool ListInitialization);
8137
8139 SourceLocation LParenLoc,
8140 MultiExprArg Exprs,
8141 SourceLocation RParenLoc,
8142 bool ListInitialization);
8143
8144 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8145 ///
8146 /// E.g.:
8147 /// @code new (memory) int[size][4] @endcode
8148 /// or
8149 /// @code ::new Foo(23, "hello") @endcode
8150 ///
8151 /// \param StartLoc The first location of the expression.
8152 /// \param UseGlobal True if 'new' was prefixed with '::'.
8153 /// \param PlacementLParen Opening paren of the placement arguments.
8154 /// \param PlacementArgs Placement new arguments.
8155 /// \param PlacementRParen Closing paren of the placement arguments.
8156 /// \param TypeIdParens If the type is in parens, the source range.
8157 /// \param D The type to be allocated, as well as array dimensions.
8158 /// \param Initializer The initializing expression or initializer-list, or
8159 /// null if there is none.
8160 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8161 SourceLocation PlacementLParen,
8162 MultiExprArg PlacementArgs,
8163 SourceLocation PlacementRParen,
8164 SourceRange TypeIdParens, Declarator &D,
8165 Expr *Initializer);
8167 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8168 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8169 SourceRange TypeIdParens, QualType AllocType,
8170 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8171 SourceRange DirectInitRange, Expr *Initializer);
8172
8173 /// Determine whether \p FD is an aligned allocation or deallocation
8174 /// function that is unavailable.
8176
8177 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8178 /// function that is unavailable.
8181
8182 /// Checks that a type is suitable as the allocated type
8183 /// in a new-expression.
8185 SourceRange R);
8186
8187 /// The scope in which to find allocation functions.
8189 /// Only look for allocation functions in the global scope.
8191 /// Only look for allocation functions in the scope of the
8192 /// allocated class.
8194 /// Look for allocation functions in both the global scope
8195 /// and in the scope of the allocated class.
8196 AFS_Both
8198
8199 /// Finds the overloads of operator new and delete that are appropriate
8200 /// for the allocation.
8202 AllocationFunctionScope NewScope,
8203 AllocationFunctionScope DeleteScope,
8204 QualType AllocType, bool IsArray,
8205 bool &PassAlignment, MultiExprArg PlaceArgs,
8206 FunctionDecl *&OperatorNew,
8207 FunctionDecl *&OperatorDelete,
8208 bool Diagnose = true);
8209
8210 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8211 /// delete. These are:
8212 /// @code
8213 /// // C++03:
8214 /// void* operator new(std::size_t) throw(std::bad_alloc);
8215 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8216 /// void operator delete(void *) throw();
8217 /// void operator delete[](void *) throw();
8218 /// // C++11:
8219 /// void* operator new(std::size_t);
8220 /// void* operator new[](std::size_t);
8221 /// void operator delete(void *) noexcept;
8222 /// void operator delete[](void *) noexcept;
8223 /// // C++1y:
8224 /// void* operator new(std::size_t);
8225 /// void* operator new[](std::size_t);
8226 /// void operator delete(void *) noexcept;
8227 /// void operator delete[](void *) noexcept;
8228 /// void operator delete(void *, std::size_t) noexcept;
8229 /// void operator delete[](void *, std::size_t) noexcept;
8230 /// @endcode
8231 /// Note that the placement and nothrow forms of new are *not* implicitly
8232 /// declared. Their use requires including <new>.
8235 ArrayRef<QualType> Params);
8236
8238 DeclarationName Name, FunctionDecl *&Operator,
8239 bool Diagnose = true, bool WantSize = false,
8240 bool WantAligned = false);
8242 bool CanProvideSize,
8243 bool Overaligned,
8244 DeclarationName Name);
8246 CXXRecordDecl *RD);
8247
8248 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8249 /// @code ::delete ptr; @endcode
8250 /// or
8251 /// @code delete [] ptr; @endcode
8252 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8253 bool ArrayForm, Expr *Operand);
8255 bool IsDelete, bool CallCanBeVirtual,
8256 bool WarnOnNonAbstractTypes,
8257 SourceLocation DtorLoc);
8258
8260 Expr *Operand, SourceLocation RParen);
8262 SourceLocation RParen);
8263
8265 SourceLocation OpLoc,
8266 tok::TokenKind OpKind,
8267 ParsedType &ObjectType,
8268 bool &MayBePseudoDestructor);
8269
8271 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8272 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8273 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8274
8276 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8277 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8278 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8279
8281 SourceLocation OpLoc,
8282 tok::TokenKind OpKind,
8283 SourceLocation TildeLoc,
8284 const DeclSpec &DS);
8285
8286 /// MaybeCreateExprWithCleanups - If the current full-expression
8287 /// requires any cleanups, surround it with a ExprWithCleanups node.
8288 /// Otherwise, just returns the passed-in expression.
8292
8293 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8294 return ActOnFinishFullExpr(
8295 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8296 }
8298 bool DiscardedValue, bool IsConstexpr = false,
8299 bool IsTemplateArgument = false);
8301
8302 /// Process the expression contained within a decltype. For such expressions,
8303 /// certain semantic checks on temporaries are delayed until this point, and
8304 /// are omitted for the 'topmost' call in the decltype expression. If the
8305 /// topmost call bound a temporary, strip that temporary off the expression.
8307
8308 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8309 bool IsUDSuffix);
8310
8312
8313 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8314 SourceLocation StmtLoc,
8315 ConditionKind CK);
8316
8317 /// Check the use of the given variable as a C++ condition in an if,
8318 /// while, do-while, or switch statement.
8320 SourceLocation StmtLoc, ConditionKind CK);
8321
8322 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8323 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8324
8325 /// Helper function to determine whether this is the (deprecated) C++
8326 /// conversion from a string literal to a pointer to non-const char or
8327 /// non-const wchar_t (for narrow and wide string literals,
8328 /// respectively).
8330
8331 /// PerformImplicitConversion - Perform an implicit conversion of the
8332 /// expression From to the type ToType using the pre-computed implicit
8333 /// conversion sequence ICS. Returns the converted
8334 /// expression. Action is the kind of conversion we're performing,
8335 /// used in the error message.
8337 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8338 AssignmentAction Action,
8340
8341 /// PerformImplicitConversion - Perform an implicit conversion of the
8342 /// expression From to the type ToType by following the standard
8343 /// conversion sequence SCS. Returns the converted
8344 /// expression. Flavor is the context in which we're performing this
8345 /// conversion, for use in error messages.
8347 const StandardConversionSequence &SCS,
8348 AssignmentAction Action,
8350
8351 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8352
8353 /// Parsed one of the type trait support pseudo-functions.
8356 SourceLocation RParenLoc);
8359 SourceLocation RParenLoc);
8360
8361 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8362 /// pseudo-functions.
8364 ParsedType LhsTy, Expr *DimExpr,
8365 SourceLocation RParen);
8366
8368 TypeSourceInfo *TSInfo, Expr *DimExpr,
8369 SourceLocation RParen);
8370
8371 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8372 /// pseudo-functions.
8374 Expr *Queried, SourceLocation RParen);
8375
8377 Expr *Queried, SourceLocation RParen);
8378
8380 ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc,
8381 bool isIndirect);
8383 ExprResult &RHS,
8384 SourceLocation QuestionLoc);
8385
8387 ExprResult &LHS, ExprResult &RHS,
8388 SourceLocation QuestionLoc);
8389
8390 /// Check the operands of ?: under C++ semantics.
8391 ///
8392 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8393 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8394 ///
8395 /// This function also implements GCC's vector extension and the
8396 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8397 /// permit the use of a?b:c where the type of a is that of a integer vector
8398 /// with the same number of elements and size as the vectors of b and c. If
8399 /// one of either b or c is a scalar it is implicitly converted to match the
8400 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8401 /// c are scalars, then b and c are checked and converted to the type of a if
8402 /// possible.
8403 ///
8404 /// The expressions are evaluated differently for GCC's and OpenCL's
8405 /// extensions. For the GCC extension, the ?: operator is evaluated as
8406 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8407 /// For the OpenCL extensions, the ?: operator is evaluated as
8408 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8409 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8411 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8412 ExprObjectKind &OK, SourceLocation questionLoc);
8413
8414 /// Find a merged pointer type and convert the two expressions to it.
8415 ///
8416 /// This finds the composite pointer type for \p E1 and \p E2 according to
8417 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8418 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8419 /// ConvertArgs is \c true).
8420 ///
8421 /// \param Loc The location of the operator requiring these two expressions to
8422 /// be converted to the composite pointer type.
8423 ///
8424 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8425 /// type.
8427 bool ConvertArgs = true);
8429 ExprResult &E2, bool ConvertArgs = true) {
8430 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8431 QualType Composite =
8432 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8433 E1 = E1Tmp;
8434 E2 = E2Tmp;
8435 return Composite;
8436 }
8437
8438 /// MaybeBindToTemporary - If the passed in expression has a record type with
8439 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8440 /// it simply returns the passed in expression.
8442
8443 /// IgnoredValueConversions - Given that an expression's result is
8444 /// syntactically ignored, perform any conversions that are
8445 /// required.
8447
8449
8450 /// Process any TypoExprs in the given Expr and its children,
8451 /// generating diagnostics as appropriate and returning a new Expr if there
8452 /// were typos that were all successfully corrected and ExprError if one or
8453 /// more typos could not be corrected.
8454 ///
8455 /// \param E The Expr to check for TypoExprs.
8456 ///
8457 /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
8458 /// initializer.
8459 ///
8460 /// \param RecoverUncorrectedTypos If true, when typo correction fails, it
8461 /// will rebuild the given Expr with all TypoExprs degraded to RecoveryExprs.
8462 ///
8463 /// \param Filter A function applied to a newly rebuilt Expr to determine if
8464 /// it is an acceptable/usable result from a single combination of typo
8465 /// corrections. As long as the filter returns ExprError, different
8466 /// combinations of corrections will be tried until all are exhausted.
8468 Expr *E, VarDecl *InitDecl = nullptr,
8469 bool RecoverUncorrectedTypos = false,
8470 llvm::function_ref<ExprResult(Expr *)> Filter =
8471 [](Expr *E) -> ExprResult { return E; });
8472
8474 ExprResult ER, VarDecl *InitDecl = nullptr,
8475 bool RecoverUncorrectedTypos = false,
8476 llvm::function_ref<ExprResult(Expr *)> Filter =
8477 [](Expr *E) -> ExprResult { return E; }) {
8478 return ER.isInvalid()
8479 ? ER
8480 : CorrectDelayedTyposInExpr(ER.get(), InitDecl,
8481 RecoverUncorrectedTypos, Filter);
8482 }
8483
8484 /// Describes the result of an "if-exists" condition check.
8486 /// The symbol exists.
8488
8489 /// The symbol does not exist.
8491
8492 /// The name is a dependent name, so the results will differ
8493 /// from one instantiation to the next.
8495
8496 /// An error occurred.
8497 IER_Error
8499
8502 const DeclarationNameInfo &TargetNameInfo);
8503
8505 SourceLocation KeywordLoc,
8506 bool IsIfExists, CXXScopeSpec &SS,
8507 UnqualifiedId &Name);
8508
8511 ArrayRef<ParmVarDecl *> LocalParameters,
8512 Scope *BodyScope);
8516 CXXScopeSpec &SS,
8517 SourceLocation NameLoc,
8518 const IdentifierInfo *TypeName,
8519 TemplateIdAnnotation *TemplateId);
8521 SourceLocation NoexceptLoc);
8523 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8524 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8527 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8531 bool IsSatisfied, SourceLocation NoexceptLoc,
8538 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8539 const ASTConstraintSatisfaction &Satisfaction);
8542 SourceLocation LParenLoc,
8543 ArrayRef<ParmVarDecl *> LocalParameters,
8544 SourceLocation RParenLoc,
8546 SourceLocation ClosingBraceLoc);
8547
8548private:
8549 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8550 bool IsDelete);
8551
8552 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8553 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8554 bool DeleteWasArrayForm);
8555
8556 ///@}
8557
8558 //
8559 //
8560 // -------------------------------------------------------------------------
8561 //
8562 //
8563
8564 /// \name Member Access Expressions
8565 /// Implementations are in SemaExprMember.cpp
8566 ///@{
8567
8568public:
8569 /// Check whether an expression might be an implicit class member access.
8571 bool IsAddressOfOperand);
8572
8573 /// Builds an expression which might be an implicit member expression.
8575 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
8576 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
8577
8578 /// Builds an implicit member access expression. The current context
8579 /// is known to be an instance method, and the given unqualified lookup
8580 /// set is known to contain only instance members, at least one of which
8581 /// is from an appropriate type.
8583 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8584 LookupResult &R,
8585 const TemplateArgumentListInfo *TemplateArgs,
8586 bool IsDefiniteInstance, const Scope *S);
8587
8589 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
8590 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8591 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8592 const TemplateArgumentListInfo *TemplateArgs);
8593
8594 /// The main callback when the parser finds something like
8595 /// expression . [nested-name-specifier] identifier
8596 /// expression -> [nested-name-specifier] identifier
8597 /// where 'identifier' encompasses a fairly broad spectrum of
8598 /// possibilities, including destructor and operator references.
8599 ///
8600 /// \param OpKind either tok::arrow or tok::period
8601 /// \param ObjCImpDecl the current Objective-C \@implementation
8602 /// decl; this is an ugly hack around the fact that Objective-C
8603 /// \@implementations aren't properly put in the context chain
8605 tok::TokenKind OpKind, CXXScopeSpec &SS,
8606 SourceLocation TemplateKWLoc,
8607 UnqualifiedId &Member, Decl *ObjCImpDecl);
8608
8609 MemberExpr *
8610 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
8611 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
8612 ValueDecl *Member, DeclAccessPair FoundDecl,
8613 bool HadMultipleCandidates,
8614 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
8616 const TemplateArgumentListInfo *TemplateArgs = nullptr);
8617
8618 // Check whether the declarations we found through a nested-name
8619 // specifier in a member expression are actually members of the base
8620 // type. The restriction here is:
8621 //
8622 // C++ [expr.ref]p2:
8623 // ... In these cases, the id-expression shall name a
8624 // member of the class or of one of its base classes.
8625 //
8626 // So it's perfectly legitimate for the nested-name specifier to name
8627 // an unrelated class, and for us to find an overload set including
8628 // decls from classes which are not superclasses, as long as the decl
8629 // we actually pick through overload resolution is from a superclass.
8630 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
8631 const CXXScopeSpec &SS,
8632 const LookupResult &R);
8633
8634 // This struct is for use by ActOnMemberAccess to allow
8635 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
8636 // changing the access operator from a '.' to a '->' (to see if that is the
8637 // change needed to fix an error about an unknown member, e.g. when the class
8638 // defines a custom operator->).
8643 };
8644
8646 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
8647 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8648 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8649 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
8650 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8651
8654 bool IsArrow, const CXXScopeSpec &SS,
8655 SourceLocation TemplateKWLoc,
8656 NamedDecl *FirstQualifierInScope, LookupResult &R,
8657 const TemplateArgumentListInfo *TemplateArgs,
8658 const Scope *S, bool SuppressQualifierCheck = false,
8659 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8660
8661 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
8662 SourceLocation OpLoc,
8663 const CXXScopeSpec &SS, FieldDecl *Field,
8664 DeclAccessPair FoundDecl,
8665 const DeclarationNameInfo &MemberNameInfo);
8666
8667 /// Perform conversions on the LHS of a member access expression.
8669
8671 const CXXScopeSpec &SS, SourceLocation nameLoc,
8672 IndirectFieldDecl *indirectField,
8673 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
8674 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
8675
8676private:
8677 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
8678
8679 ///@}
8680
8681 //
8682 //
8683 // -------------------------------------------------------------------------
8684 //
8685 //
8686
8687 /// \name Initializers
8688 /// Implementations are in SemaInit.cpp
8689 ///@{
8690
8691public:
8692 /// Stack of types that correspond to the parameter entities that are
8693 /// currently being copy-initialized. Can be empty.
8695
8696 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
8698
8699 bool IsStringInit(Expr *Init, const ArrayType *AT);
8700
8701 /// Determine whether we can perform aggregate initialization for the purposes
8702 /// of overload resolution.
8704 const InitializedEntity &Entity, InitListExpr *From);
8705
8707 SourceLocation EqualOrColonLoc,
8708 bool GNUSyntax, ExprResult Init);
8709
8710 /// Check that the lifetime of the initializer (and its subobjects) is
8711 /// sufficient for initializing the entity, and perform lifetime extension
8712 /// (when permitted) if not.
8714
8717 bool BoundToLvalueReference);
8718
8719 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
8720 /// it as an xvalue. In C++98, the result will still be a prvalue, because
8721 /// we don't have xvalues there.
8723
8727
8731 SourceLocation EqualLoc, ExprResult Init,
8732 bool TopLevelOfInitList = false,
8733 bool AllowExplicit = false);
8734
8736 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
8738
8739 ///@}
8740
8741 //
8742 //
8743 // -------------------------------------------------------------------------
8744 //
8745 //
8746
8747 /// \name C++ Lambda Expressions
8748 /// Implementations are in SemaLambda.cpp
8749 ///@{
8750
8751public:
8752 /// Create a new lambda closure type.
8754 TypeSourceInfo *Info,
8755 unsigned LambdaDependencyKind,
8756 LambdaCaptureDefault CaptureDefault);
8757
8758 /// Number lambda for linkage purposes if necessary.
8760 std::optional<CXXRecordDecl::LambdaNumbering>
8761 NumberingOverride = std::nullopt);
8762
8763 /// Endow the lambda scope info with the relevant properties.
8764 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
8765 SourceRange IntroducerRange,
8766 LambdaCaptureDefault CaptureDefault,
8767 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
8768 bool Mutable);
8769
8772
8774 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
8775 TemplateParameterList *TemplateParams);
8776
8778 CXXMethodDecl *Method, SourceLocation LambdaLoc,
8779 SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause,
8780 TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind,
8782 bool HasExplicitResultType);
8783
8784 /// Returns true if the explicit object parameter was invalid.
8786 SourceLocation CallLoc);
8787
8788 /// Perform initialization analysis of the init-capture and perform
8789 /// any implicit conversions such as an lvalue-to-rvalue conversion if
8790 /// not being used to initialize a reference.
8792 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8795 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
8797 }
8799 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8800 std::optional<unsigned> NumExpansions, IdentifierInfo *Id,
8801 bool DirectInit, Expr *&Init);
8802
8803 /// Create a dummy variable within the declcontext of the lambda's
8804 /// call operator, for name lookup purposes for a lambda init capture.
8805 ///
8806 /// CodeGen handles emission of lambda captures, ignoring these dummy
8807 /// variables appropriately.
8809 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
8810 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
8811
8812 /// Add an init-capture to a lambda scope.
8813 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
8814
8815 /// Note that we have finished the explicit captures for the
8816 /// given lambda.
8818
8819 /// Deduce a block or lambda's return type based on the return
8820 /// statements present in the body.
8822
8823 /// Once the Lambdas capture are known, we can start to create the closure,
8824 /// call operator method, and keep track of the captures.
8825 /// We do the capture lookup here, but they are not actually captured until
8826 /// after we know what the qualifiers of the call operator are.
8828 Scope *CurContext);
8829
8830 /// This is called after parsing the explicit template parameter list
8831 /// on a lambda (if it exists) in C++2a.
8833 SourceLocation LAngleLoc,
8834 ArrayRef<NamedDecl *> TParams,
8835 SourceLocation RAngleLoc,
8836 ExprResult RequiresClause);
8837
8839 SourceLocation MutableLoc);
8840
8842 Scope *LambdaScope,
8844
8845 /// ActOnStartOfLambdaDefinition - This is called just before we start
8846 /// parsing the body of a lambda; it analyzes the explicit captures and
8847 /// arguments, and sets up various data-structures for the body of the
8848 /// lambda.
8850 Declarator &ParamInfo, const DeclSpec &DS);
8851
8852 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
8853 /// is invoked to pop the information about the lambda.
8854 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
8855 bool IsInstantiation = false);
8856
8857 /// ActOnLambdaExpr - This is called when the body of a lambda expression
8858 /// was successfully completed.
8860
8861 /// Does copying/destroying the captured variable have side effects?
8862 bool CaptureHasSideEffects(const sema::Capture &From);
8863
8864 /// Diagnose if an explicit lambda capture is unused. Returns true if a
8865 /// diagnostic is emitted.
8866 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
8867 const sema::Capture &From);
8868
8869 /// Build a FieldDecl suitable to hold the given capture.
8871
8872 /// Initialize the given capture with a suitable expression.
8874 SourceLocation ImplicitCaptureLoc,
8875 bool IsOpenMPMapping = false);
8876
8877 /// Complete a lambda-expression having processed and attached the
8878 /// lambda body.
8881
8882 /// Get the return type to use for a lambda's conversion function(s) to
8883 /// function pointer type, given the type of the call operator.
8884 QualType
8886 CallingConv CC);
8887
8889 SourceLocation ConvLocation,
8890 CXXConversionDecl *Conv, Expr *Src);
8891
8893 : private FunctionScopeRAII {
8894 public:
8896 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
8898 bool ShouldAddDeclsFromParentScope = true);
8899 };
8900
8901 /// Compute the mangling number context for a lambda expression or
8902 /// block literal. Also return the extra mangling decl if any.
8903 ///
8904 /// \param DC - The DeclContext containing the lambda expression or
8905 /// block literal.
8906 std::tuple<MangleNumberingContext *, Decl *>
8908
8909 ///@}
8910
8911 //
8912 //
8913 // -------------------------------------------------------------------------
8914 //
8915 //
8916
8917 /// \name Name Lookup
8918 ///
8919 /// These routines provide name lookup that is used during semantic
8920 /// analysis to resolve the various kinds of names (identifiers,
8921 /// overloaded operator names, constructor names, etc.) into zero or
8922 /// more declarations within a particular scope. The major entry
8923 /// points are LookupName, which performs unqualified name lookup,
8924 /// and LookupQualifiedName, which performs qualified name lookup.
8925 ///
8926 /// All name lookup is performed based on some specific criteria,
8927 /// which specify what names will be visible to name lookup and how
8928 /// far name lookup should work. These criteria are important both
8929 /// for capturing language semantics (certain lookups will ignore
8930 /// certain names, for example) and for performance, since name
8931 /// lookup is often a bottleneck in the compilation of C++. Name
8932 /// lookup criteria is specified via the LookupCriteria enumeration.
8933 ///
8934 /// The results of name lookup can vary based on the kind of name
8935 /// lookup performed, the current language, and the translation
8936 /// unit. In C, for example, name lookup will either return nothing
8937 /// (no entity found) or a single declaration. In C++, name lookup
8938 /// can additionally refer to a set of overloaded functions or
8939 /// result in an ambiguity. All of the possible results of name
8940 /// lookup are captured by the LookupResult class, which provides
8941 /// the ability to distinguish among them.
8942 ///
8943 /// Implementations are in SemaLookup.cpp
8944 ///@{
8945
8946public:
8947 /// Tracks whether we are in a context where typo correction is
8948 /// disabled.
8950
8951 /// The number of typos corrected by CorrectTypo.
8953
8954 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
8955 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
8956
8957 /// A cache containing identifiers for which typo correction failed and
8958 /// their locations, so that repeated attempts to correct an identifier in a
8959 /// given location are ignored if typo correction already failed for it.
8961
8962 /// SpecialMemberOverloadResult - The overloading result for a special member
8963 /// function.
8964 ///
8965 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
8966 /// integer are used to determine whether overload resolution succeeded.
8968 public:
8969 enum Kind { NoMemberOrDeleted, Ambiguous, Success };
8970
8971 private:
8972 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
8973
8974 public:
8977 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
8978
8979 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
8980 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
8981
8982 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
8983 void setKind(Kind K) { Pair.setInt(K); }
8984 };
8985
8986 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
8988 public:
8989 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
8990 : FastFoldingSetNode(ID) {}
8991 };
8992
8993 /// A cache of special member function overload resolution results
8994 /// for C++ records.
8995 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
8996
8997 /// Holds TypoExprs that are created from `createDelayedTypo`. This is used by
8998 /// `TransformTypos` in order to keep track of any TypoExprs that are created
8999 /// recursively during typo correction and wipe them away if the correction
9000 /// fails.
9002
9004
9005 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
9006 // TODO: make this is a typesafe union.
9009
9010 /// Describes the kind of name lookup to perform.
9012 /// Ordinary name lookup, which finds ordinary names (functions,
9013 /// variables, typedefs, etc.) in C and most kinds of names
9014 /// (functions, variables, members, types, etc.) in C++.
9016 /// Tag name lookup, which finds the names of enums, classes,
9017 /// structs, and unions.
9019 /// Label name lookup.
9021 /// Member name lookup, which finds the names of
9022 /// class/struct/union members.
9024 /// Look up of an operator name (e.g., operator+) for use with
9025 /// operator overloading. This lookup is similar to ordinary name
9026 /// lookup, but will ignore any declarations that are class members.
9028 /// Look up a name following ~ in a destructor name. This is an ordinary
9029 /// lookup, but prefers tags to typedefs.
9031 /// Look up of a name that precedes the '::' scope resolution
9032 /// operator in C++. This lookup completely ignores operator, object,
9033 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9035 /// Look up a namespace name within a C++ using directive or
9036 /// namespace alias definition, ignoring non-namespace names (C++
9037 /// [basic.lookup.udir]p1).
9039 /// Look up all declarations in a scope with the given name,
9040 /// including resolved using declarations. This is appropriate
9041 /// for checking redeclarations for a using declaration.
9043 /// Look up an ordinary name that is going to be redeclared as a
9044 /// name with linkage. This lookup ignores any declarations that
9045 /// are outside of the current scope unless they have linkage. See
9046 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9048 /// Look up a friend of a local class. This lookup does not look
9049 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9051 /// Look up the name of an Objective-C protocol.
9053 /// Look up implicit 'self' parameter of an objective-c method.
9055 /// Look up the name of an OpenMP user-defined reduction operation.
9057 /// Look up the name of an OpenMP user-defined mapper.
9059 /// Look up any declaration with any name.
9062
9063 /// The possible outcomes of name lookup for a literal operator.
9065 /// The lookup resulted in an error.
9067 /// The lookup found no match but no diagnostic was issued.
9069 /// The lookup found a single 'cooked' literal operator, which
9070 /// expects a normal literal to be built and passed to it.
9072 /// The lookup found a single 'raw' literal operator, which expects
9073 /// a string literal containing the spelling of the literal token.
9075 /// The lookup found an overload set of literal operator templates,
9076 /// which expect the characters of the spelling of the literal token to be
9077 /// passed as a non-type template argument pack.
9079 /// The lookup found an overload set of literal operator templates,
9080 /// which expect the character type and characters of the spelling of the
9081 /// string literal token to be passed as template arguments.
9083 };
9084
9085 SpecialMemberOverloadResult
9087 bool VolatileArg, bool RValueThis, bool ConstThis,
9088 bool VolatileThis);
9089
9090 typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
9091 typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
9093
9095
9096 /// Look up a name, looking for a single declaration. Return
9097 /// null if the results were absent, ambiguous, or overloaded.
9098 ///
9099 /// It is preferable to use the elaborated form and explicitly handle
9100 /// ambiguity and overloaded.
9103 LookupNameKind NameKind,
9104 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
9105
9106 /// Lookup a builtin function, when name lookup would otherwise
9107 /// fail.
9108 bool LookupBuiltin(LookupResult &R);
9109 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9110
9111 /// Perform unqualified name lookup starting from a given
9112 /// scope.
9113 ///
9114 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9115 /// used to find names within the current scope. For example, 'x' in
9116 /// @code
9117 /// int x;
9118 /// int f() {
9119 /// return x; // unqualified name look finds 'x' in the global scope
9120 /// }
9121 /// @endcode
9122 ///
9123 /// Different lookup criteria can find different names. For example, a
9124 /// particular scope can have both a struct and a function of the same
9125 /// name, and each can be found by certain lookup criteria. For more
9126 /// information about lookup criteria, see the documentation for the
9127 /// class LookupCriteria.
9128 ///
9129 /// @param S The scope from which unqualified name lookup will
9130 /// begin. If the lookup criteria permits, name lookup may also search
9131 /// in the parent scopes.
9132 ///
9133 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9134 /// look up and the lookup kind), and is updated with the results of lookup
9135 /// including zero or more declarations and possibly additional information
9136 /// used to diagnose ambiguities.
9137 ///
9138 /// @returns \c true if lookup succeeded and false otherwise.
9139 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9140 bool ForceNoCPlusPlus = false);
9141
9142 /// Perform qualified name lookup into a given context.
9143 ///
9144 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9145 /// names when the context of those names is explicit specified, e.g.,
9146 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9147 ///
9148 /// Different lookup criteria can find different names. For example, a
9149 /// particular scope can have both a struct and a function of the same
9150 /// name, and each can be found by certain lookup criteria. For more
9151 /// information about lookup criteria, see the documentation for the
9152 /// class LookupCriteria.
9153 ///
9154 /// \param R captures both the lookup criteria and any lookup results found.
9155 ///
9156 /// \param LookupCtx The context in which qualified name lookup will
9157 /// search. If the lookup criteria permits, name lookup may also search
9158 /// in the parent contexts or (for C++ classes) base classes.
9159 ///
9160 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9161 /// occurs as part of unqualified name lookup.
9162 ///
9163 /// \returns true if lookup succeeded, false if it failed.
9164 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9165 bool InUnqualifiedLookup = false);
9166
9167 /// Performs qualified name lookup or special type of lookup for
9168 /// "__super::" scope specifier.
9169 ///
9170 /// This routine is a convenience overload meant to be called from contexts
9171 /// that need to perform a qualified name lookup with an optional C++ scope
9172 /// specifier that might require special kind of lookup.
9173 ///
9174 /// \param R captures both the lookup criteria and any lookup results found.
9175 ///
9176 /// \param LookupCtx The context in which qualified name lookup will
9177 /// search.
9178 ///
9179 /// \param SS An optional C++ scope-specifier.
9180 ///
9181 /// \returns true if lookup succeeded, false if it failed.
9182 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9183 CXXScopeSpec &SS);
9184
9185 /// Performs name lookup for a name that was parsed in the
9186 /// source code, and may contain a C++ scope specifier.
9187 ///
9188 /// This routine is a convenience routine meant to be called from
9189 /// contexts that receive a name and an optional C++ scope specifier
9190 /// (e.g., "N::M::x"). It will then perform either qualified or
9191 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9192 /// respectively) on the given name and return those results. It will
9193 /// perform a special type of lookup for "__super::" scope specifier.
9194 ///
9195 /// @param S The scope from which unqualified name lookup will
9196 /// begin.
9197 ///
9198 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9199 ///
9200 /// @param EnteringContext Indicates whether we are going to enter the
9201 /// context of the scope-specifier SS (if present).
9202 ///
9203 /// @returns True if any decls were found (but possibly ambiguous)
9205 QualType ObjectType, bool AllowBuiltinCreation = false,
9206 bool EnteringContext = false);
9207
9208 /// Perform qualified name lookup into all base classes of the given
9209 /// class.
9210 ///
9211 /// \param R captures both the lookup criteria and any lookup results found.
9212 ///
9213 /// \param Class The context in which qualified name lookup will
9214 /// search. Name lookup will search in all base classes merging the results.
9215 ///
9216 /// @returns True if any decls were found (but possibly ambiguous)
9218
9220 UnresolvedSetImpl &Functions);
9221
9222 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9223 /// If GnuLabelLoc is a valid source location, then this is a definition
9224 /// of an __label__ label name, otherwise it is a normal label definition
9225 /// or use.
9227 SourceLocation GnuLabelLoc = SourceLocation());
9228
9229 /// Look up the constructors for the given class.
9231
9232 /// Look up the default constructor for the given class.
9234
9235 /// Look up the copying constructor for the given class.
9237 unsigned Quals);
9238
9239 /// Look up the copying assignment operator for the given class.
9241 bool RValueThis, unsigned ThisQuals);
9242
9243 /// Look up the moving constructor for the given class.
9245 unsigned Quals);
9246
9247 /// Look up the moving assignment operator for the given class.
9249 bool RValueThis, unsigned ThisQuals);
9250
9251 /// Look for the destructor of the given class.
9252 ///
9253 /// During semantic analysis, this routine should be used in lieu of
9254 /// CXXRecordDecl::getDestructor().
9255 ///
9256 /// \returns The destructor for this class.
9258
9259 /// Force the declaration of any implicitly-declared members of this
9260 /// class.
9262
9263 /// Make a merged definition of an existing hidden definition \p ND
9264 /// visible at the specified location.
9266
9267 /// Check ODR hashes for C/ObjC when merging types from modules.
9268 /// Differently from C++, actually parse the body and reject in case
9269 /// of a mismatch.
9270 template <typename T,
9271 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9273 if (Duplicate->getODRHash() != Previous->getODRHash())
9274 return false;
9275
9276 // Make the previous decl visible.
9278 return true;
9279 }
9280
9281 /// Get the set of additional modules that should be checked during
9282 /// name lookup. A module and its imports become visible when instanting a
9283 /// template defined within it.
9284 llvm::DenseSet<Module *> &getLookupModules();
9285
9286 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9288
9289 /// Determine if the template parameter \p D has a visible default argument.
9290 bool
9292 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9293 /// Determine if the template parameter \p D has a reachable default argument.
9295 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9296 /// Determine if the template parameter \p D has a reachable default argument.
9300
9301 /// Determine if there is a visible declaration of \p D that is an explicit
9302 /// specialization declaration for a specialization of a template. (For a
9303 /// member specialization, use hasVisibleMemberSpecialization.)
9305 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9306 /// Determine if there is a reachable declaration of \p D that is an explicit
9307 /// specialization declaration for a specialization of a template. (For a
9308 /// member specialization, use hasReachableMemberSpecialization.)
9310 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9311
9312 /// Determine if there is a visible declaration of \p D that is a member
9313 /// specialization declaration (as opposed to an instantiated declaration).
9315 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9316 /// Determine if there is a reachable declaration of \p D that is a member
9317 /// specialization declaration (as opposed to an instantiated declaration).
9319 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9320
9321 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9322
9323 /// Determine whether any declaration of an entity is visible.
9324 bool
9326 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9327 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9328 }
9329
9332 /// Determine whether any declaration of an entity is reachable.
9333 bool
9335 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9336 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9337 }
9339 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9340
9341 void diagnoseTypo(const TypoCorrection &Correction,
9342 const PartialDiagnostic &TypoDiag,
9343 bool ErrorRecovery = true);
9344
9345 /// Diagnose a successfully-corrected typo. Separated from the correction
9346 /// itself to allow external validation of the result, etc.
9347 ///
9348 /// \param Correction The result of performing typo correction.
9349 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9350 /// string added to it (and usually also a fixit).
9351 /// \param PrevNote A note to use when indicating the location of the entity
9352 /// to which we are correcting. Will have the correction string added
9353 /// to it.
9354 /// \param ErrorRecovery If \c true (the default), the caller is going to
9355 /// recover from the typo as if the corrected string had been typed.
9356 /// In this case, \c PDiag must be an error, and we will attach a fixit
9357 /// to it.
9358 void diagnoseTypo(const TypoCorrection &Correction,
9359 const PartialDiagnostic &TypoDiag,
9360 const PartialDiagnostic &PrevNote,
9361 bool ErrorRecovery = true);
9362
9363 /// Find the associated classes and namespaces for
9364 /// argument-dependent lookup for a call with the given set of
9365 /// arguments.
9366 ///
9367 /// This routine computes the sets of associated classes and associated
9368 /// namespaces searched by argument-dependent lookup
9369 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9371 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9372 AssociatedNamespaceSet &AssociatedNamespaces,
9373 AssociatedClassSet &AssociatedClasses);
9374
9375 /// Produce a diagnostic describing the ambiguity that resulted
9376 /// from name lookup.
9377 ///
9378 /// \param Result The result of the ambiguous lookup to be diagnosed.
9380
9381 /// LookupLiteralOperator - Determine which literal operator should be used
9382 /// for a user-defined literal, per C++11 [lex.ext].
9383 ///
9384 /// Normal overload resolution is not used to select which literal operator to
9385 /// call for a user-defined literal. Look up the provided literal operator
9386 /// name, and filter the results to the appropriate set for the given argument
9387 /// types.
9390 bool AllowRaw, bool AllowTemplate,
9391 bool AllowStringTemplate, bool DiagnoseMissing,
9392 StringLiteral *StringLit = nullptr);
9393
9395 ArrayRef<Expr *> Args, ADLResult &Functions);
9396
9399 bool IncludeGlobalScope = true,
9400 bool LoadExternal = true);
9403 bool IncludeGlobalScope = true,
9404 bool IncludeDependentBases = false,
9405 bool LoadExternal = true);
9406
9408 CTK_NonError, // CorrectTypo used in a non error recovery situation.
9409 CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
9411
9412 /// Try to "correct" a typo in the source code by finding
9413 /// visible declarations whose names are similar to the name that was
9414 /// present in the source code.
9415 ///
9416 /// \param TypoName the \c DeclarationNameInfo structure that contains
9417 /// the name that was present in the source code along with its location.
9418 ///
9419 /// \param LookupKind the name-lookup criteria used to search for the name.
9420 ///
9421 /// \param S the scope in which name lookup occurs.
9422 ///
9423 /// \param SS the nested-name-specifier that precedes the name we're
9424 /// looking for, if present.
9425 ///
9426 /// \param CCC A CorrectionCandidateCallback object that provides further
9427 /// validation of typo correction candidates. It also provides flags for
9428 /// determining the set of keywords permitted.
9429 ///
9430 /// \param MemberContext if non-NULL, the context in which to look for
9431 /// a member access expression.
9432 ///
9433 /// \param EnteringContext whether we're entering the context described by
9434 /// the nested-name-specifier SS.
9435 ///
9436 /// \param OPT when non-NULL, the search for visible declarations will
9437 /// also walk the protocols in the qualified interfaces of \p OPT.
9438 ///
9439 /// \returns a \c TypoCorrection containing the corrected name if the typo
9440 /// along with information such as the \c NamedDecl where the corrected name
9441 /// was declared, and any additional \c NestedNameSpecifier needed to access
9442 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9444 Sema::LookupNameKind LookupKind, Scope *S,
9446 CorrectTypoKind Mode,
9447 DeclContext *MemberContext = nullptr,
9448 bool EnteringContext = false,
9449 const ObjCObjectPointerType *OPT = nullptr,
9450 bool RecordFailure = true);
9451
9452 /// Try to "correct" a typo in the source code by finding
9453 /// visible declarations whose names are similar to the name that was
9454 /// present in the source code.
9455 ///
9456 /// \param TypoName the \c DeclarationNameInfo structure that contains
9457 /// the name that was present in the source code along with its location.
9458 ///
9459 /// \param LookupKind the name-lookup criteria used to search for the name.
9460 ///
9461 /// \param S the scope in which name lookup occurs.
9462 ///
9463 /// \param SS the nested-name-specifier that precedes the name we're
9464 /// looking for, if present.
9465 ///
9466 /// \param CCC A CorrectionCandidateCallback object that provides further
9467 /// validation of typo correction candidates. It also provides flags for
9468 /// determining the set of keywords permitted.
9469 ///
9470 /// \param TDG A TypoDiagnosticGenerator functor that will be used to print
9471 /// diagnostics when the actual typo correction is attempted.
9472 ///
9473 /// \param TRC A TypoRecoveryCallback functor that will be used to build an
9474 /// Expr from a typo correction candidate.
9475 ///
9476 /// \param MemberContext if non-NULL, the context in which to look for
9477 /// a member access expression.
9478 ///
9479 /// \param EnteringContext whether we're entering the context described by
9480 /// the nested-name-specifier SS.
9481 ///
9482 /// \param OPT when non-NULL, the search for visible declarations will
9483 /// also walk the protocols in the qualified interfaces of \p OPT.
9484 ///
9485 /// \returns a new \c TypoExpr that will later be replaced in the AST with an
9486 /// Expr representing the result of performing typo correction, or nullptr if
9487 /// typo correction is not possible. If nullptr is returned, no diagnostics
9488 /// will be emitted and it is the responsibility of the caller to emit any
9489 /// that are needed.
9491 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9494 CorrectTypoKind Mode, DeclContext *MemberContext = nullptr,
9495 bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr);
9496
9497 /// Kinds of missing import. Note, the values of these enumerators correspond
9498 /// to %select values in diagnostics.
9501 Definition,
9505 };
9506
9507 /// Diagnose that the specified declaration needs to be visible but
9508 /// isn't, and suggest a module import that would resolve the problem.
9510 MissingImportKind MIK, bool Recover = true);
9512 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9513 MissingImportKind MIK, bool Recover);
9514
9516 std::unique_ptr<TypoCorrectionConsumer> Consumer;
9519 TypoExprState();
9520 TypoExprState(TypoExprState &&other) noexcept;
9521 TypoExprState &operator=(TypoExprState &&other) noexcept;
9522 };
9523
9524 const TypoExprState &getTypoExprState(TypoExpr *TE) const;
9525
9526 /// Clears the state of the given TypoExpr.
9527 void clearDelayedTypo(TypoExpr *TE);
9528
9529 /// Called on #pragma clang __debug dump II
9531
9532 /// Called on #pragma clang __debug dump E
9533 void ActOnPragmaDump(Expr *E);
9534
9535private:
9536 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9537 //
9538 // The boolean value will be true to indicate that the namespace was loaded
9539 // from an AST/PCH file, or false otherwise.
9540 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9541
9542 /// Whether we have already loaded known namespaces from an extenal
9543 /// source.
9544 bool LoadedExternalKnownNamespaces;
9545
9546 bool CppLookupName(LookupResult &R, Scope *S);
9547
9548 /// Determine if we could use all the declarations in the module.
9549 bool isUsableModule(const Module *M);
9550
9551 /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
9552 /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
9553 /// should be skipped entirely.
9554 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9555 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9557 DeclContext *MemberContext, bool EnteringContext,
9558 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9559
9560 /// The set of unhandled TypoExprs and their associated state.
9561 llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
9562
9563 /// Creates a new TypoExpr AST node.
9564 TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
9567
9568 /// Cache for module units which is usable for current module.
9569 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9570
9571 /// Record the typo correction failure and return an empty correction.
9572 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9573 bool RecordFailure = true) {
9574 if (RecordFailure)
9575 TypoCorrectionFailures[Typo].insert(TypoLoc);
9576 return TypoCorrection();
9577 }
9578
9579 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9580
9581 /// Determine whether two declarations should be linked together, given that
9582 /// the old declaration might not be visible and the new declaration might
9583 /// not have external linkage.
9584 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9585 const NamedDecl *New) {
9586 if (isVisible(Old))
9587 return true;
9588 // See comment in below overload for why it's safe to compute the linkage
9589 // of the new declaration here.
9590 if (New->isExternallyDeclarable()) {
9591 assert(Old->isExternallyDeclarable() &&
9592 "should not have found a non-externally-declarable previous decl");
9593 return true;
9594 }
9595 return false;
9596 }
9597 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9598
9599 ///@}
9600
9601 //
9602 //
9603 // -------------------------------------------------------------------------
9604 //
9605 //
9606
9607 /// \name Modules
9608 /// Implementations are in SemaModule.cpp
9609 ///@{
9610
9611public:
9612 /// Get the module unit whose scope we are currently within.
9614 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9615 }
9616
9617 /// Is the module scope we are an implementation unit?
9619 return ModuleScopes.empty()
9620 ? false
9621 : ModuleScopes.back().Module->isModuleImplementation();
9622 }
9623
9624 // When loading a non-modular PCH files, this is used to restore module
9625 // visibility.
9627 VisibleModules.setVisible(Mod, ImportLoc);
9628 }
9629
9630 enum class ModuleDeclKind {
9631 Interface, ///< 'export module X;'
9632 Implementation, ///< 'module X;'
9633 PartitionInterface, ///< 'export module X:Y;'
9634 PartitionImplementation, ///< 'module X:Y;'
9635 };
9636
9637 /// An enumeration to represent the transition of states in parsing module
9638 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9639 /// an error in state transition, the state is set to NotACXX20Module.
9641 FirstDecl, ///< Parsing the first decl in a TU.
9642 GlobalFragment, ///< after 'module;' but before 'module X;'
9643 ImportAllowed, ///< after 'module X;' but before any non-import decl.
9644 ImportFinished, ///< after any non-import decl.
9645 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
9646 ///< non-import decl.
9647 PrivateFragmentImportFinished, ///< after 'module :private;' but a
9648 ///< non-import decl has already been seen.
9649 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
9650 };
9651
9652 /// The parser has processed a module-declaration that begins the definition
9653 /// of a module interface or implementation.
9655 SourceLocation ModuleLoc, ModuleDeclKind MDK,
9656 ModuleIdPath Path, ModuleIdPath Partition,
9657 ModuleImportState &ImportState);
9658
9659 /// The parser has processed a global-module-fragment declaration that begins
9660 /// the definition of the global module fragment of the current module unit.
9661 /// \param ModuleLoc The location of the 'module' keyword.
9663
9664 /// The parser has processed a private-module-fragment declaration that begins
9665 /// the definition of the private module fragment of the current module unit.
9666 /// \param ModuleLoc The location of the 'module' keyword.
9667 /// \param PrivateLoc The location of the 'private' keyword.
9669 SourceLocation PrivateLoc);
9670
9671 /// The parser has processed a module import declaration.
9672 ///
9673 /// \param StartLoc The location of the first token in the declaration. This
9674 /// could be the location of an '@', 'export', or 'import'.
9675 /// \param ExportLoc The location of the 'export' keyword, if any.
9676 /// \param ImportLoc The location of the 'import' keyword.
9677 /// \param Path The module toplevel name as an access path.
9678 /// \param IsPartition If the name is for a partition.
9680 SourceLocation ExportLoc,
9681 SourceLocation ImportLoc, ModuleIdPath Path,
9682 bool IsPartition = false);
9684 SourceLocation ExportLoc,
9685 SourceLocation ImportLoc, Module *M,
9686 ModuleIdPath Path = {});
9687
9688 /// The parser has processed a module import translated from a
9689 /// #include or similar preprocessing directive.
9690 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9691 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9692
9693 /// The parsed has entered a submodule.
9694 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
9695 /// The parser has left a submodule.
9696 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
9697
9698 /// Create an implicit import of the given module at the given
9699 /// source location, for error recovery, if possible.
9700 ///
9701 /// This routine is typically used when an entity found by name lookup
9702 /// is actually hidden within a module that we know about but the user
9703 /// has forgotten to import.
9705 Module *Mod);
9706
9707 /// We have parsed the start of an export declaration, including the '{'
9708 /// (if present).
9709 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
9710 SourceLocation LBraceLoc);
9711
9712 /// Complete the definition of an export declaration.
9713 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
9714 SourceLocation RBraceLoc);
9715
9716private:
9717 /// The parser has begun a translation unit to be compiled as a C++20
9718 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
9719 void HandleStartOfHeaderUnit();
9720
9721 struct ModuleScope {
9722 SourceLocation BeginLoc;
9723 clang::Module *Module = nullptr;
9724 VisibleModuleSet OuterVisibleModules;
9725 };
9726 /// The modules we're currently parsing.
9728
9729 /// For an interface unit, this is the implicitly imported interface unit.
9730 clang::Module *ThePrimaryInterface = nullptr;
9731
9732 /// The explicit global module fragment of the current translation unit.
9733 /// The explicit Global Module Fragment, as specified in C++
9734 /// [module.global.frag].
9735 clang::Module *TheGlobalModuleFragment = nullptr;
9736
9737 /// The implicit global module fragments of the current translation unit.
9738 ///
9739 /// The contents in the implicit global module fragment can't be discarded.
9740 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
9741
9742 /// Namespace definitions that we will export when they finish.
9743 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
9744
9745 /// In a C++ standard module, inline declarations require a definition to be
9746 /// present at the end of a definition domain. This set holds the decls to
9747 /// be checked at the end of the TU.
9748 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
9749
9750 /// Helper function to judge if we are in module purview.
9751 /// Return false if we are not in a module.
9752 bool isCurrentModulePurview() const;
9753
9754 /// Enter the scope of the explicit global module fragment.
9755 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
9756 /// Leave the scope of the explicit global module fragment.
9757 void PopGlobalModuleFragment();
9758
9759 /// Enter the scope of an implicit global module fragment.
9760 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
9761 /// Leave the scope of an implicit global module fragment.
9762 void PopImplicitGlobalModuleFragment();
9763
9764 VisibleModuleSet VisibleModules;
9765
9766 ///@}
9767
9768 //
9769 //
9770 // -------------------------------------------------------------------------
9771 //
9772 //
9773
9774 /// \name C++ Overloading
9775 /// Implementations are in SemaOverload.cpp
9776 ///@{
9777
9778public:
9779 /// Whether deferrable diagnostics should be deferred.
9780 bool DeferDiags = false;
9781
9782 /// RAII class to control scope of DeferDiags.
9784 Sema &S;
9785 bool SavedDeferDiags = false;
9786
9787 public:
9788 DeferDiagsRAII(Sema &S, bool DeferDiags)
9789 : S(S), SavedDeferDiags(S.DeferDiags) {
9790 S.DeferDiags = DeferDiags;
9791 }
9792 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
9793 };
9794
9795 /// Flag indicating if Sema is building a recovery call expression.
9796 ///
9797 /// This flag is used to avoid building recovery call expressions
9798 /// if Sema is already doing so, which would cause infinite recursions.
9800
9802 /// This is a legitimate overload: the existing declarations are
9803 /// functions or function templates with different signatures.
9805
9806 /// This is not an overload because the signature exactly matches
9807 /// an existing declaration.
9809
9810 /// This is not an overload because the lookup results contain a
9811 /// non-function.
9814
9815 /// Determine whether the given New declaration is an overload of the
9816 /// declarations in Old. This routine returns Ovl_Match or Ovl_NonFunction if
9817 /// New and Old cannot be overloaded, e.g., if New has the same signature as
9818 /// some function in Old (C++ 1.3.10) or if the Old declarations aren't
9819 /// functions (or function templates) at all. When it does return Ovl_Match or
9820 /// Ovl_NonFunction, MatchedDecl will point to the decl that New cannot be
9821 /// overloaded with. This decl may be a UsingShadowDecl on top of the
9822 /// underlying declaration.
9823 ///
9824 /// Example: Given the following input:
9825 ///
9826 /// void f(int, float); // #1
9827 /// void f(int, int); // #2
9828 /// int f(int, int); // #3
9829 ///
9830 /// When we process #1, there is no previous declaration of "f", so IsOverload
9831 /// will not be used.
9832 ///
9833 /// When we process #2, Old contains only the FunctionDecl for #1. By
9834 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
9835 /// they have different signatures), so this routine returns Ovl_Overload;
9836 /// MatchedDecl is unchanged.
9837 ///
9838 /// When we process #3, Old is an overload set containing #1 and #2. We
9839 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
9840 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
9841 /// types of functions are not part of the signature), IsOverload returns
9842 /// Ovl_Match and MatchedDecl will be set to point to the FunctionDecl for #2.
9843 ///
9844 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
9845 /// class by a using declaration. The rules for whether to hide shadow
9846 /// declarations ignore some properties which otherwise figure into a function
9847 /// template's signature.
9849 const LookupResult &OldDecls, NamedDecl *&OldDecl,
9850 bool UseMemberUsingDeclRules);
9851 bool IsOverload(FunctionDecl *New, FunctionDecl *Old,
9852 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9853
9854 // Checks whether MD constitutes an override the base class method BaseMD.
9855 // When checking for overrides, the object object members are ignored.
9856 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
9857 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9858
9859 enum class AllowedExplicit {
9860 /// Allow no explicit functions to be used.
9861 None,
9862 /// Allow explicit conversion functions but not explicit constructors.
9864 /// Allow both explicit conversion functions and explicit constructors.
9865 All
9866 };
9867
9869 Expr *From, QualType ToType, bool SuppressUserConversions,
9870 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
9871 bool AllowObjCWritebackConversion);
9872
9873 /// PerformImplicitConversion - Perform an implicit conversion of the
9874 /// expression From to the type ToType. Returns the
9875 /// converted expression. Flavor is the kind of conversion we're
9876 /// performing, used in the error message. If @p AllowExplicit,
9877 /// explicit user-defined conversions are permitted.
9879 AssignmentAction Action,
9880 bool AllowExplicit = false);
9881
9882 /// IsIntegralPromotion - Determines whether the conversion from the
9883 /// expression From (whose potentially-adjusted type is FromType) to
9884 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
9885 /// sets PromotedType to the promoted type.
9886 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
9887
9888 /// IsFloatingPointPromotion - Determines whether the conversion from
9889 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
9890 /// returns true and sets PromotedType to the promoted type.
9891 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
9892
9893 /// Determine if a conversion is a complex promotion.
9894 ///
9895 /// A complex promotion is defined as a complex -> complex conversion
9896 /// where the conversion between the underlying real types is a
9897 /// floating-point or integral promotion.
9898 bool IsComplexPromotion(QualType FromType, QualType ToType);
9899
9900 /// IsPointerConversion - Determines whether the conversion of the
9901 /// expression From, which has the (possibly adjusted) type FromType,
9902 /// can be converted to the type ToType via a pointer conversion (C++
9903 /// 4.10). If so, returns true and places the converted type (that
9904 /// might differ from ToType in its cv-qualifiers at some level) into
9905 /// ConvertedType.
9906 ///
9907 /// This routine also supports conversions to and from block pointers
9908 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
9909 /// pointers to interfaces. FIXME: Once we've determined the
9910 /// appropriate overloading rules for Objective-C, we may want to
9911 /// split the Objective-C checks into a different routine; however,
9912 /// GCC seems to consider all of these conversions to be pointer
9913 /// conversions, so for now they live here. IncompatibleObjC will be
9914 /// set if the conversion is an allowed Objective-C conversion that
9915 /// should result in a warning.
9916 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
9917 bool InOverloadResolution, QualType &ConvertedType,
9918 bool &IncompatibleObjC);
9919
9920 /// isObjCPointerConversion - Determines whether this is an
9921 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
9922 /// with the same arguments and return values.
9923 bool isObjCPointerConversion(QualType FromType, QualType ToType,
9924 QualType &ConvertedType, bool &IncompatibleObjC);
9925 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
9926 QualType &ConvertedType);
9927
9928 /// FunctionParamTypesAreEqual - This routine checks two function proto types
9929 /// for equality of their parameter types. Caller has already checked that
9930 /// they have same number of parameters. If the parameters are different,
9931 /// ArgPos will have the parameter index of the first different parameter.
9932 /// If `Reversed` is true, the parameters of `NewType` will be compared in
9933 /// reverse order. That's useful if one of the functions is being used as a
9934 /// C++20 synthesized operator overload with a reversed parameter order.
9937 unsigned *ArgPos = nullptr,
9938 bool Reversed = false);
9939
9941 const FunctionProtoType *NewType,
9942 unsigned *ArgPos = nullptr,
9943 bool Reversed = false);
9944
9945 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
9946 const FunctionDecl *NewFunction,
9947 unsigned *ArgPos = nullptr,
9948 bool Reversed = false);
9949
9950 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
9951 /// function types. Catches different number of parameter, mismatch in
9952 /// parameter types, and different return types.
9954 QualType ToType);
9955
9956 /// CheckPointerConversion - Check the pointer conversion from the
9957 /// expression From to the type ToType. This routine checks for
9958 /// ambiguous or inaccessible derived-to-base pointer
9959 /// conversions for which IsPointerConversion has already returned
9960 /// true. It returns true and produces a diagnostic if there was an
9961 /// error, or returns false otherwise.
9962 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
9963 CXXCastPath &BasePath, bool IgnoreBaseAccess,
9964 bool Diagnose = true);
9965
9966 /// IsMemberPointerConversion - Determines whether the conversion of the
9967 /// expression From, which has the (possibly adjusted) type FromType, can be
9968 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
9969 /// If so, returns true and places the converted type (that might differ from
9970 /// ToType in its cv-qualifiers at some level) into ConvertedType.
9971 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
9972 bool InOverloadResolution,
9973 QualType &ConvertedType);
9974
9975 /// CheckMemberPointerConversion - Check the member pointer conversion from
9976 /// the expression From to the type ToType. This routine checks for ambiguous
9977 /// or virtual or inaccessible base-to-derived member pointer conversions for
9978 /// which IsMemberPointerConversion has already returned true. It returns true
9979 /// and produces a diagnostic if there was an error, or returns false
9980 /// otherwise.
9982 CXXCastPath &BasePath,
9983 bool IgnoreBaseAccess);
9984
9985 /// IsQualificationConversion - Determines whether the conversion from
9986 /// an rvalue of type FromType to ToType is a qualification conversion
9987 /// (C++ 4.4).
9988 ///
9989 /// \param ObjCLifetimeConversion Output parameter that will be set to
9990 /// indicate when the qualification conversion involves a change in the
9991 /// Objective-C object lifetime.
9992 bool IsQualificationConversion(QualType FromType, QualType ToType,
9993 bool CStyle, bool &ObjCLifetimeConversion);
9994
9995 /// Determine whether the conversion from FromType to ToType is a valid
9996 /// conversion that strips "noexcept" or "noreturn" off the nested function
9997 /// type.
9998 bool IsFunctionConversion(QualType FromType, QualType ToType,
9999 QualType &ResultTy);
10002 DeclarationName Name,
10003 OverloadCandidateSet &CandidateSet,
10004 FunctionDecl *Fn, MultiExprArg Args,
10005 bool IsMember = false);
10006
10008 FunctionDecl *Fun);
10010 Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl,
10011 CXXMethodDecl *Method);
10012
10013 /// PerformContextuallyConvertToBool - Perform a contextual conversion
10014 /// of the expression From to bool (C++0x [conv]p3).
10016
10017 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
10018 /// conversion of the expression From to an Objective-C pointer type.
10019 /// Returns a valid but null ExprResult if no conversion sequence exists.
10021
10022 /// Contexts in which a converted constant expression is required.
10023 enum CCEKind {
10024 CCEK_CaseValue, ///< Expression in a case label.
10025 CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
10026 CCEK_TemplateArg, ///< Value of a non-type template parameter.
10027 CCEK_ArrayBound, ///< Array bound in array declarator or new-expression.
10028 CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier.
10029 CCEK_Noexcept, ///< Condition in a noexcept(bool) specifier.
10030 CCEK_StaticAssertMessageSize, ///< Call to size() in a static assert
10031 ///< message.
10032 CCEK_StaticAssertMessageData, ///< Call to data() in a static assert
10033 ///< message.
10034 };
10035
10037 CCEKind CCE,
10038 NamedDecl *Dest = nullptr);
10039
10041 llvm::APSInt &Value, CCEKind CCE);
10043 APValue &Value, CCEKind CCE,
10044 NamedDecl *Dest = nullptr);
10045
10046 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10047 /// That is a converted constant expression
10048 /// (which was built with BuildConvertedConstantExpression)
10051 CCEKind CCE, bool RequireInt,
10052 const APValue &PreNarrowingValue);
10053
10054 /// Abstract base class used to perform a contextual implicit
10055 /// conversion from an expression to any type passing a filter.
10057 public:
10060
10061 ContextualImplicitConverter(bool Suppress = false,
10062 bool SuppressConversion = false)
10063 : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
10064
10065 /// Determine whether the specified type is a valid destination type
10066 /// for this conversion.
10067 virtual bool match(QualType T) = 0;
10068
10069 /// Emits a diagnostic complaining that the expression does not have
10070 /// integral or enumeration type.
10072 QualType T) = 0;
10073
10074 /// Emits a diagnostic when the expression has incomplete class type.
10075 virtual SemaDiagnosticBuilder
10077
10078 /// Emits a diagnostic when the only matching conversion function
10079 /// is explicit.
10082 QualType T,
10083 QualType ConvTy) = 0;
10084
10085 /// Emits a note for the explicit conversion function.
10086 virtual SemaDiagnosticBuilder
10088
10089 /// Emits a diagnostic when there are multiple possible conversion
10090 /// functions.
10092 QualType T) = 0;
10093
10094 /// Emits a note for one of the candidate conversions.
10095 virtual SemaDiagnosticBuilder
10097
10098 /// Emits a diagnostic when we picked a conversion function
10099 /// (for cases when we are not allowed to pick a conversion function).
10102 QualType T,
10103 QualType ConvTy) = 0;
10104
10106 };
10107
10109 bool AllowScopedEnumerations;
10110
10111 public:
10112 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10113 bool SuppressConversion)
10114 : ContextualImplicitConverter(Suppress, SuppressConversion),
10115 AllowScopedEnumerations(AllowScopedEnumerations) {}
10116
10117 /// Match an integral or (possibly scoped) enumeration type.
10118 bool match(QualType T) override;
10119
10121 QualType T) override {
10122 return diagnoseNotInt(S, Loc, T);
10123 }
10124
10125 /// Emits a diagnostic complaining that the expression does not have
10126 /// integral or enumeration type.
10128 QualType T) = 0;
10129 };
10130
10131 /// Perform a contextual implicit conversion.
10134 ContextualImplicitConverter &Converter);
10135
10136 /// ReferenceCompareResult - Expresses the result of comparing two
10137 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10138 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10140 /// Ref_Incompatible - The two types are incompatible, so direct
10141 /// reference binding is not possible.
10143 /// Ref_Related - The two types are reference-related, which means
10144 /// that their unqualified forms (T1 and T2) are either the same
10145 /// or T1 is a base class of T2.
10147 /// Ref_Compatible - The two types are reference-compatible.
10150
10151 // Fake up a scoped enumeration that still contextually converts to bool.
10153 /// The conversions that would be performed on an lvalue of type T2 when
10154 /// binding a reference of type T1 to it, as determined when evaluating
10155 /// whether T1 is reference-compatible with T2.
10157 Qualification = 0x1,
10158 NestedQualification = 0x2,
10160 DerivedToBase = 0x8,
10161 ObjC = 0x10,
10162 ObjCLifetime = 0x20,
10163
10164 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
10165 };
10166 };
10168
10169 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10170 /// determine whether they are reference-compatible,
10171 /// reference-related, or incompatible, for use in C++ initialization by
10172 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10173 /// type, and the first type (T1) is the pointee type of the reference
10174 /// type being initialized.
10177 ReferenceConversions *Conv = nullptr);
10178
10179 /// AddOverloadCandidate - Adds the given function to the set of
10180 /// candidate functions, using the given function call arguments. If
10181 /// @p SuppressUserConversions, then don't allow user-defined
10182 /// conversions via constructors or conversion operators.
10183 ///
10184 /// \param PartialOverloading true if we are performing "partial" overloading
10185 /// based on an incomplete set of function arguments. This feature is used by
10186 /// code completion.
10189 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10190 bool PartialOverloading = false, bool AllowExplicit = true,
10191 bool AllowExplicitConversion = false,
10192 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10193 ConversionSequenceList EarlyConversions = std::nullopt,
10195 bool AggregateCandidateDeduction = false);
10196
10197 /// Add all of the function declarations in the given function set to
10198 /// the overload candidate set.
10200 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10201 OverloadCandidateSet &CandidateSet,
10202 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10203 bool SuppressUserConversions = false, bool PartialOverloading = false,
10204 bool FirstArgumentIsBase = false);
10205
10206 /// AddMethodCandidate - Adds a named decl (which is some kind of
10207 /// method) as a method candidate to the given overload set.
10208 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10209 Expr::Classification ObjectClassification,
10210 ArrayRef<Expr *> Args,
10211 OverloadCandidateSet &CandidateSet,
10212 bool SuppressUserConversion = false,
10214
10215 /// AddMethodCandidate - Adds the given C++ member function to the set
10216 /// of candidate functions, using the given function call arguments
10217 /// and the object argument (@c Object). For example, in a call
10218 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10219 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10220 /// allow user-defined conversions via constructors or conversion
10221 /// operators.
10222 void
10223 AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10224 CXXRecordDecl *ActingContext, QualType ObjectType,
10225 Expr::Classification ObjectClassification,
10226 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10227 bool SuppressUserConversions = false,
10228 bool PartialOverloading = false,
10229 ConversionSequenceList EarlyConversions = std::nullopt,
10231
10232 /// Add a C++ member function template as a candidate to the candidate
10233 /// set, using template argument deduction to produce an appropriate member
10234 /// function template specialization.
10236 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10237 CXXRecordDecl *ActingContext,
10238 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10239 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10240 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10241 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10242
10243 /// Add a C++ function template specialization as a candidate
10244 /// in the candidate set, using template argument deduction to produce
10245 /// an appropriate function template specialization.
10247 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10248 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10249 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10250 bool PartialOverloading = false, bool AllowExplicit = true,
10251 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10253 bool AggregateCandidateDeduction = false);
10254
10255 /// Check that implicit conversion sequences can be formed for each argument
10256 /// whose corresponding parameter has a non-dependent type, per DR1391's
10257 /// [temp.deduct.call]p10.
10259 FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes,
10260 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10261 ConversionSequenceList &Conversions, bool SuppressUserConversions,
10262 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10263 Expr::Classification ObjectClassification = {},
10265
10266 /// AddConversionCandidate - Add a C++ conversion function as a
10267 /// candidate in the candidate set (C++ [over.match.conv],
10268 /// C++ [over.match.copy]). From is the expression we're converting from,
10269 /// and ToType is the type that we're eventually trying to convert to
10270 /// (which may or may not be the same type as the type that the
10271 /// conversion function produces).
10273 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10274 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10275 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10276 bool AllowExplicit, bool AllowResultConversion = true);
10277
10278 /// Adds a conversion function template specialization
10279 /// candidate to the overload set, using template argument deduction
10280 /// to deduce the template arguments of the conversion function
10281 /// template from the type that we are converting to (C++
10282 /// [temp.deduct.conv]).
10284 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10285 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10286 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10287 bool AllowExplicit, bool AllowResultConversion = true);
10288
10289 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10290 /// converts the given @c Object to a function pointer via the
10291 /// conversion function @c Conversion, and then attempts to call it
10292 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10293 /// the type of function that we'll eventually be calling.
10294 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10295 DeclAccessPair FoundDecl,
10296 CXXRecordDecl *ActingContext,
10297 const FunctionProtoType *Proto, Expr *Object,
10298 ArrayRef<Expr *> Args,
10299 OverloadCandidateSet &CandidateSet);
10300
10301 /// Add all of the non-member operator function declarations in the given
10302 /// function set to the overload candidate set.
10304 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10305 OverloadCandidateSet &CandidateSet,
10306 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10307
10308 /// Add overload candidates for overloaded operators that are
10309 /// member functions.
10310 ///
10311 /// Add the overloaded operator candidates that are member functions
10312 /// for the operator Op that was used in an operator expression such
10313 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10314 /// CandidateSet will store the added overload candidates. (C++
10315 /// [over.match.oper]).
10317 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10318 OverloadCandidateSet &CandidateSet,
10320
10321 /// AddBuiltinCandidate - Add a candidate for a built-in
10322 /// operator. ResultTy and ParamTys are the result and parameter types
10323 /// of the built-in candidate, respectively. Args and NumArgs are the
10324 /// arguments being passed to the candidate. IsAssignmentOperator
10325 /// should be true when this built-in candidate is an assignment
10326 /// operator. NumContextualBoolArguments is the number of arguments
10327 /// (at the beginning of the argument list) that will be contextually
10328 /// converted to bool.
10329 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10330 OverloadCandidateSet &CandidateSet,
10331 bool IsAssignmentOperator = false,
10332 unsigned NumContextualBoolArguments = 0);
10333
10334 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10335 /// operator overloads to the candidate set (C++ [over.built]), based
10336 /// on the operator @p Op and the arguments given. For example, if the
10337 /// operator is a binary '+', this routine might add "int
10338 /// operator+(int, int)" to cover integer addition.
10340 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10341 OverloadCandidateSet &CandidateSet);
10342
10343 /// Add function candidates found via argument-dependent lookup
10344 /// to the set of overloading candidates.
10345 ///
10346 /// This routine performs argument-dependent name lookup based on the
10347 /// given function name (which may also be an operator name) and adds
10348 /// all of the overload candidates found by ADL to the overload
10349 /// candidate set (C++ [basic.lookup.argdep]).
10351 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10352 TemplateArgumentListInfo *ExplicitTemplateArgs,
10353 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10354
10355 /// Check the enable_if expressions on the given function. Returns the first
10356 /// failing attribute, or NULL if they were all successful.
10357 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10358 ArrayRef<Expr *> Args,
10359 bool MissingImplicitThis = false);
10360
10361 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10362 /// non-ArgDependent DiagnoseIfAttrs.
10363 ///
10364 /// Argument-dependent diagnose_if attributes should be checked each time a
10365 /// function is used as a direct callee of a function call.
10366 ///
10367 /// Returns true if any errors were emitted.
10368 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10369 const Expr *ThisArg,
10370 ArrayRef<const Expr *> Args,
10371 SourceLocation Loc);
10372
10373 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10374 /// ArgDependent DiagnoseIfAttrs.
10375 ///
10376 /// Argument-independent diagnose_if attributes should be checked on every use
10377 /// of a function.
10378 ///
10379 /// Returns true if any errors were emitted.
10380 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10381 SourceLocation Loc);
10382
10383 /// Determine if \p A and \p B are equivalent internal linkage declarations
10384 /// from different modules, and thus an ambiguity error can be downgraded to
10385 /// an extension warning.
10386 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10387 const NamedDecl *B);
10389 SourceLocation Loc, const NamedDecl *D,
10390 ArrayRef<const NamedDecl *> Equiv);
10391
10392 // Emit as a 'note' the specific overload candidate
10394 const NamedDecl *Found, const FunctionDecl *Fn,
10396 QualType DestType = QualType(), bool TakingAddress = false);
10397
10398 // Emit as a series of 'note's all template and non-templates identified by
10399 // the expression Expr
10400 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10401 bool TakingAddress = false);
10402
10403 /// Returns whether the given function's address can be taken or not,
10404 /// optionally emitting a diagnostic if the address can't be taken.
10405 ///
10406 /// Returns false if taking the address of the function is illegal.
10407 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10408 bool Complain = false,
10409 SourceLocation Loc = SourceLocation());
10410
10411 // [PossiblyAFunctionType] --> [Return]
10412 // NonFunctionType --> NonFunctionType
10413 // R (A) --> R(A)
10414 // R (*)(A) --> R (A)
10415 // R (&)(A) --> R (A)
10416 // R (S::*)(A) --> R (A)
10417 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10418
10419 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10420 /// an overloaded function (C++ [over.over]), where @p From is an
10421 /// expression with overloaded function type and @p ToType is the type
10422 /// we're trying to resolve to. For example:
10423 ///
10424 /// @code
10425 /// int f(double);
10426 /// int f(int);
10427 ///
10428 /// int (*pfd)(double) = f; // selects f(double)
10429 /// @endcode
10430 ///
10431 /// This routine returns the resulting FunctionDecl if it could be
10432 /// resolved, and NULL otherwise. When @p Complain is true, this
10433 /// routine will emit diagnostics if there is an error.
10434 FunctionDecl *
10435 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10436 bool Complain, DeclAccessPair &Found,
10437 bool *pHadMultipleCandidates = nullptr);
10438
10439 /// Given an expression that refers to an overloaded function, try to
10440 /// resolve that function to a single function that can have its address
10441 /// taken. This will modify `Pair` iff it returns non-null.
10442 ///
10443 /// This routine can only succeed if from all of the candidates in the
10444 /// overload set for SrcExpr that can have their addresses taken, there is one
10445 /// candidate that is more constrained than the rest.
10446 FunctionDecl *
10447 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10448
10449 /// Given an overloaded function, tries to turn it into a non-overloaded
10450 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10451 /// will perform access checks, diagnose the use of the resultant decl, and,
10452 /// if requested, potentially perform a function-to-pointer decay.
10453 ///
10454 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10455 /// Otherwise, returns true. This may emit diagnostics and return true.
10457 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10458
10459 /// Given an expression that refers to an overloaded function, try to
10460 /// resolve that overloaded function expression down to a single function.
10461 ///
10462 /// This routine can only resolve template-ids that refer to a single function
10463 /// template, where that template-id refers to a single template whose
10464 /// template arguments are either provided by the template-id or have
10465 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10466 ///
10467 /// If no template-ids are found, no diagnostics are emitted and NULL is
10468 /// returned.
10470 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10471 TemplateSpecCandidateSet *FailedTSC = nullptr);
10472
10473 // Resolve and fix an overloaded expression that can be resolved
10474 // because it identifies a single function template specialization.
10475 //
10476 // Last three arguments should only be supplied if Complain = true
10477 //
10478 // Return true if it was logically possible to so resolve the
10479 // expression, regardless of whether or not it succeeded. Always
10480 // returns true if 'complain' is set.
10482 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10483 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10484 QualType DestTypeForComplaining = QualType(),
10485 unsigned DiagIDForComplaining = 0);
10486
10487 /// Add the overload candidates named by callee and/or found by argument
10488 /// dependent lookup to the given overload set.
10489 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10490 ArrayRef<Expr *> Args,
10491 OverloadCandidateSet &CandidateSet,
10492 bool PartialOverloading = false);
10493
10494 /// Add the call candidates from the given set of lookup results to the given
10495 /// overload set. Non-function lookup results are ignored.
10497 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10498 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10499
10500 // An enum used to represent the different possible results of building a
10501 // range-based for loop.
10507
10508 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10509 /// given LookupResult is non-empty, it is assumed to describe a member which
10510 /// will be invoked. Otherwise, the function will be found via argument
10511 /// dependent lookup.
10512 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10513 /// otherwise CallExpr is set to ExprError() and some non-success value
10514 /// is returned.
10516 SourceLocation RangeLoc,
10517 const DeclarationNameInfo &NameInfo,
10518 LookupResult &MemberLookup,
10519 OverloadCandidateSet *CandidateSet,
10521
10522 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10523 /// (which eventually refers to the declaration Func) and the call
10524 /// arguments Args/NumArgs, attempt to resolve the function call down
10525 /// to a specific function. If overload resolution succeeds, returns
10526 /// the call expression produced by overload resolution.
10527 /// Otherwise, emits diagnostics and returns ExprError.
10529 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10530 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10531 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10532
10533 /// Constructs and populates an OverloadedCandidateSet from
10534 /// the given function.
10535 /// \returns true when an the ExprResult output parameter has been set.
10537 MultiExprArg Args, SourceLocation RParenLoc,
10538 OverloadCandidateSet *CandidateSet,
10540
10544 const UnresolvedSetImpl &Fns,
10545 bool PerformADL = true);
10546
10547 /// Create a unary operation that may resolve to an overloaded
10548 /// operator.
10549 ///
10550 /// \param OpLoc The location of the operator itself (e.g., '*').
10551 ///
10552 /// \param Opc The UnaryOperatorKind that describes this operator.
10553 ///
10554 /// \param Fns The set of non-member functions that will be
10555 /// considered by overload resolution. The caller needs to build this
10556 /// set based on the context using, e.g.,
10557 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10558 /// set should not contain any member functions; those will be added
10559 /// by CreateOverloadedUnaryOp().
10560 ///
10561 /// \param Input The input argument.
10564 const UnresolvedSetImpl &Fns, Expr *input,
10565 bool RequiresADL = true);
10566
10567 /// Perform lookup for an overloaded binary operator.
10570 const UnresolvedSetImpl &Fns,
10571 ArrayRef<Expr *> Args, bool RequiresADL = true);
10572
10573 /// Create a binary operation that may resolve to an overloaded
10574 /// operator.
10575 ///
10576 /// \param OpLoc The location of the operator itself (e.g., '+').
10577 ///
10578 /// \param Opc The BinaryOperatorKind that describes this operator.
10579 ///
10580 /// \param Fns The set of non-member functions that will be
10581 /// considered by overload resolution. The caller needs to build this
10582 /// set based on the context using, e.g.,
10583 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10584 /// set should not contain any member functions; those will be added
10585 /// by CreateOverloadedBinOp().
10586 ///
10587 /// \param LHS Left-hand argument.
10588 /// \param RHS Right-hand argument.
10589 /// \param PerformADL Whether to consider operator candidates found by ADL.
10590 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10591 /// C++20 operator rewrites.
10592 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
10593 /// the function in question. Such a function is never a candidate in
10594 /// our overload resolution. This also enables synthesizing a three-way
10595 /// comparison from < and == as described in C++20 [class.spaceship]p1.
10597 const UnresolvedSetImpl &Fns, Expr *LHS,
10598 Expr *RHS, bool RequiresADL = true,
10599 bool AllowRewrittenCandidates = true,
10600 FunctionDecl *DefaultedFn = nullptr);
10602 const UnresolvedSetImpl &Fns,
10603 Expr *LHS, Expr *RHS,
10604 FunctionDecl *DefaultedFn);
10605
10607 SourceLocation RLoc, Expr *Base,
10608 MultiExprArg Args);
10609
10610 /// BuildCallToMemberFunction - Build a call to a member
10611 /// function. MemExpr is the expression that refers to the member
10612 /// function (and includes the object parameter), Args/NumArgs are the
10613 /// arguments to the function call (not including the object
10614 /// parameter). The caller needs to validate that the member
10615 /// expression refers to a non-static member function or an overloaded
10616 /// member function.
10618 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
10619 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
10620 bool IsExecConfig = false, bool AllowRecovery = false);
10621
10622 /// BuildCallToObjectOfClassType - Build a call to an object of class
10623 /// type (C++ [over.call.object]), which can end up invoking an
10624 /// overloaded function call operator (@c operator()) or performing a
10625 /// user-defined conversion on the object argument.
10627 SourceLocation LParenLoc,
10628 MultiExprArg Args,
10629 SourceLocation RParenLoc);
10630
10631 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
10632 /// (if one exists), where @c Base is an expression of class type and
10633 /// @c Member is the name of the member we're trying to find.
10635 SourceLocation OpLoc,
10636 bool *NoArrowOperatorFound = nullptr);
10637
10639 CXXConversionDecl *Method,
10640 bool HadMultipleCandidates);
10641
10642 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
10643 /// to a literal operator described by the provided lookup results.
10646 SourceLocation LitEndLoc,
10647 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10648
10649 /// FixOverloadedFunctionReference - E is an expression that refers to
10650 /// a C++ overloaded function (possibly with some parentheses and
10651 /// perhaps a '&' around it). We have resolved the overloaded function
10652 /// to the function declaration Fn, so patch up the expression E to
10653 /// refer (possibly indirectly) to Fn. Returns the new expr.
10655 FunctionDecl *Fn);
10657 DeclAccessPair FoundDecl,
10658 FunctionDecl *Fn);
10659
10660 /// - Returns a selector which best matches given argument list or
10661 /// nullptr if none could be found
10663 bool IsInstance,
10665
10666 ///@}
10667
10668 //
10669 //
10670 // -------------------------------------------------------------------------
10671 //
10672 //
10673
10674 /// \name Statements
10675 /// Implementations are in SemaStmt.cpp
10676 ///@{
10677
10678public:
10679 /// Stack of active SEH __finally scopes. Can be empty.
10681
10682 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
10684
10686 bool HasLeadingEmptyMacro = false);
10687
10689 SourceLocation EndLoc);
10691
10692 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
10693 /// whose result is unused, warn.
10694 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
10695
10696 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
10700 ArrayRef<Stmt *> Elts, bool isStmtExpr);
10701
10703
10706 SourceLocation DotDotDotLoc, ExprResult RHS,
10707 SourceLocation ColonLoc);
10708
10709 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
10710 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
10711
10713 SourceLocation ColonLoc, Stmt *SubStmt,
10714 Scope *CurScope);
10716 SourceLocation ColonLoc, Stmt *SubStmt);
10717
10719 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
10721 Stmt *SubStmt);
10722
10723 /// Check whether the given statement can have musttail applied to it,
10724 /// issuing a diagnostic and returning false if not. In the success case,
10725 /// the statement is rewritten to remove implicit nodes from the return
10726 /// value.
10727 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
10728
10730 SourceLocation LParenLoc, Stmt *InitStmt,
10731 ConditionResult Cond, SourceLocation RParenLoc,
10732 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10734 SourceLocation LParenLoc, Stmt *InitStmt,
10735 ConditionResult Cond, SourceLocation RParenLoc,
10736 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10737
10739
10741 SourceLocation LParenLoc, Stmt *InitStmt,
10742 ConditionResult Cond,
10743 SourceLocation RParenLoc);
10745 Stmt *Body);
10746
10747 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
10748 /// integer not in the range of enum values.
10749 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
10750 Expr *SrcExpr);
10751
10753 ConditionResult Cond, SourceLocation RParenLoc,
10754 Stmt *Body);
10756 SourceLocation WhileLoc, SourceLocation CondLParen,
10757 Expr *Cond, SourceLocation CondRParen);
10758
10760 Stmt *First, ConditionResult Second,
10761 FullExprArg Third, SourceLocation RParenLoc,
10762 Stmt *Body);
10763
10764 /// In an Objective C collection iteration statement:
10765 /// for (x in y)
10766 /// x can be an arbitrary l-value expression. Bind it up as a
10767 /// full-expression.
10769
10771 /// Initial building of a for-range statement.
10773 /// Instantiation or recovery rebuild of a for-range statement. Don't
10774 /// attempt any typo-correction.
10776 /// Determining whether a for-range statement could be built. Avoid any
10777 /// unnecessary or irreversible actions.
10780
10781 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
10782 ///
10783 /// C++11 [stmt.ranged]:
10784 /// A range-based for statement is equivalent to
10785 ///
10786 /// {
10787 /// auto && __range = range-init;
10788 /// for ( auto __begin = begin-expr,
10789 /// __end = end-expr;
10790 /// __begin != __end;
10791 /// ++__begin ) {
10792 /// for-range-declaration = *__begin;
10793 /// statement
10794 /// }
10795 /// }
10796 ///
10797 /// The body of the loop is not available yet, since it cannot be analysed
10798 /// until we have determined the type of the for-range-declaration.
10800 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
10801 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
10803 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10804
10805 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
10807 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
10808 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
10809 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
10811 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10812
10813 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
10814 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
10815 /// body cannot be performed until after the type of the range variable is
10816 /// determined.
10817 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
10818
10819 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
10820 LabelDecl *TheDecl);
10821 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
10822 SourceLocation StarLoc, Expr *DestExp);
10823 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
10824 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
10825
10828
10829 enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
10831
10832 bool isMoveEligible() const { return S != None; };
10833 bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
10834 };
10836
10837 /// Determine whether the given expression might be move-eligible or
10838 /// copy-elidable in either a (co_)return statement or throw expression,
10839 /// without considering function return type, if applicable.
10840 ///
10841 /// \param E The expression being returned from the function or block,
10842 /// being thrown, or being co_returned from a coroutine. This expression
10843 /// might be modified by the implementation.
10844 ///
10845 /// \param Mode Overrides detection of current language mode
10846 /// and uses the rules for C++23.
10847 ///
10848 /// \returns An aggregate which contains the Candidate and isMoveEligible
10849 /// and isCopyElidable methods. If Candidate is non-null, it means
10850 /// isMoveEligible() would be true under the most permissive language
10851 /// standard.
10852 NamedReturnInfo getNamedReturnInfo(
10854
10855 /// Determine whether the given NRVO candidate variable is move-eligible or
10856 /// copy-elidable, without considering function return type.
10857 ///
10858 /// \param VD The NRVO candidate variable.
10859 ///
10860 /// \returns An aggregate which contains the Candidate and isMoveEligible
10861 /// and isCopyElidable methods. If Candidate is non-null, it means
10862 /// isMoveEligible() would be true under the most permissive language
10863 /// standard.
10864 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
10865
10866 /// Updates given NamedReturnInfo's move-eligible and
10867 /// copy-elidable statuses, considering the function
10868 /// return type criteria as applicable to return statements.
10869 ///
10870 /// \param Info The NamedReturnInfo object to update.
10871 ///
10872 /// \param ReturnType This is the return type of the function.
10873 /// \returns The copy elision candidate, in case the initial return expression
10874 /// was copy elidable, or nullptr otherwise.
10875 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
10876 QualType ReturnType);
10877
10878 /// Perform the initialization of a potentially-movable value, which
10879 /// is the result of return value.
10880 ///
10881 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
10882 /// treat returned lvalues as rvalues in certain cases (to prefer move
10883 /// construction), then falls back to treating them as lvalues if that failed.
10886 const NamedReturnInfo &NRInfo, Expr *Value,
10887 bool SupressSimplerImplicitMoves = false);
10888
10890
10891 /// Deduce the return type for a function from a returned expression, per
10892 /// C++1y [dcl.spec.auto]p6.
10894 SourceLocation ReturnLoc, Expr *RetExpr,
10895 const AutoType *AT);
10896
10897 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10898 Scope *CurScope);
10899 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10900 bool AllowRecovery = false);
10901
10902 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
10903 /// for capturing scopes.
10905 NamedReturnInfo &NRInfo,
10906 bool SupressSimplerImplicitMoves);
10907
10908 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
10909 /// and creates a proper catch handler from them.
10911 Stmt *HandlerBlock);
10912
10913 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
10914 /// handlers and creates a try statement from them.
10916 ArrayRef<Stmt *> Handlers);
10917
10918 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
10919 SourceLocation TryLoc, Stmt *TryBlock,
10920 Stmt *Handler);
10922 Stmt *Block);
10927
10929 bool IsIfExists,
10930 NestedNameSpecifierLoc QualifierLoc,
10931 DeclarationNameInfo NameInfo,
10932 Stmt *Nested);
10934 bool IsIfExists, CXXScopeSpec &SS,
10935 UnqualifiedId &Name, Stmt *Nested);
10936
10938 CapturedRegionKind Kind, unsigned NumParams);
10939 typedef std::pair<StringRef, QualType> CapturedParamNameType;
10943 unsigned OpenMPCaptureLevel = 0);
10948 unsigned NumParams);
10949
10950private:
10951 /// Check whether the given statement can have musttail applied to it,
10952 /// issuing a diagnostic and returning false if not.
10953 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
10954
10955 /// Check if the given expression contains 'break' or 'continue'
10956 /// statement that produces control flow different from GCC.
10957 void CheckBreakContinueBinding(Expr *E);
10958
10959 ///@}
10960
10961 //
10962 //
10963 // -------------------------------------------------------------------------
10964 //
10965 //
10966
10967 /// \name `inline asm` Statement
10968 /// Implementations are in SemaStmtAsm.cpp
10969 ///@{
10970
10971public:
10972 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
10973 bool IsVolatile, unsigned NumOutputs,
10974 unsigned NumInputs, IdentifierInfo **Names,
10975 MultiExprArg Constraints, MultiExprArg Exprs,
10976 Expr *AsmString, MultiExprArg Clobbers,
10977 unsigned NumLabels, SourceLocation RParenLoc);
10978
10980 llvm::InlineAsmIdentifierInfo &Info);
10982 SourceLocation TemplateKWLoc,
10984 bool IsUnevaluatedContext);
10985 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
10986 SourceLocation AsmLoc);
10988 SourceLocation AsmLoc);
10990 ArrayRef<Token> AsmToks, StringRef AsmString,
10991 unsigned NumOutputs, unsigned NumInputs,
10992 ArrayRef<StringRef> Constraints,
10993 ArrayRef<StringRef> Clobbers,
10994 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
10995 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
10996 SourceLocation Location, bool AlwaysCreate);
10997
10998 ///@}
10999
11000 //
11001 //
11002 // -------------------------------------------------------------------------
11003 //
11004 //
11005
11006 /// \name Statement Attribute Handling
11007 /// Implementations are in SemaStmtAttr.cpp
11008 ///@{
11009
11010public:
11011 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11012 const AttributeCommonInfo &A);
11013 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11014 const AttributeCommonInfo &A);
11015
11016 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11018
11019 /// Process the attributes before creating an attributed statement. Returns
11020 /// the semantic attributes that have been processed.
11021 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11023
11027 const IdentifierInfo *AttrName,
11029
11030 ///@}
11031
11032 //
11033 //
11034 // -------------------------------------------------------------------------
11035 //
11036 //
11037
11038 /// \name C++ Templates
11039 /// Implementations are in SemaTemplate.cpp
11040 ///@{
11041
11042public:
11043 // Saves the current floating-point pragma stack and clear it in this Sema.
11045 public:
11047 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11048 S.FpPragmaStack.Stack.clear();
11049 }
11050 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11051
11052 private:
11053 Sema &S;
11055 };
11056
11058 CurFPFeatures = FPO;
11059 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11060 }
11061
11063 return llvm::ArrayRef(InventedParameterInfos.begin() +
11066 }
11067
11068 /// The number of SFINAE diagnostics that have been trapped.
11070
11073 FunctionScopes.end());
11074 }
11075
11076 typedef llvm::MapVector<const FunctionDecl *,
11077 std::unique_ptr<LateParsedTemplate>>
11080
11081 /// Determine the number of levels of enclosing template parameters. This is
11082 /// only usable while parsing. Note that this does not include dependent
11083 /// contexts in which no template parameters have yet been declared, such as
11084 /// in a terse function template or generic lambda before the first 'auto' is
11085 /// encountered.
11086 unsigned getTemplateDepth(Scope *S) const;
11087
11089 bool AllowFunctionTemplates = true,
11090 bool AllowDependent = true);
11092 bool AllowFunctionTemplates = true,
11093 bool AllowDependent = true,
11094 bool AllowNonTemplateFunctions = false);
11095 /// Try to interpret the lookup result D as a template-name.
11096 ///
11097 /// \param D A declaration found by name lookup.
11098 /// \param AllowFunctionTemplates Whether function templates should be
11099 /// considered valid results.
11100 /// \param AllowDependent Whether unresolved using declarations (that might
11101 /// name templates) should be considered valid results.
11103 bool AllowFunctionTemplates = true,
11104 bool AllowDependent = true);
11105
11107 /// Whether and why a template name is required in this lookup.
11109 public:
11110 /// Template name is required if TemplateKWLoc is valid.
11112 : TemplateKW(TemplateKWLoc) {}
11113 /// Template name is unconditionally required.
11115
11117 return TemplateKW.value_or(SourceLocation());
11118 }
11119 bool hasTemplateKeyword() const {
11120 return getTemplateKeywordLoc().isValid();
11121 }
11122 bool isRequired() const { return TemplateKW != SourceLocation(); }
11123 explicit operator bool() const { return isRequired(); }
11124
11125 private:
11126 std::optional<SourceLocation> TemplateKW;
11127 };
11128
11130 /// This is not assumed to be a template name.
11131 None,
11132 /// This is assumed to be a template name because lookup found nothing.
11134 /// This is assumed to be a template name because lookup found one or more
11135 /// functions (but no function templates).
11137 };
11138
11139 bool
11141 QualType ObjectType, bool EnteringContext,
11142 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11143 AssumedTemplateKind *ATK = nullptr,
11144 bool AllowTypoCorrection = true);
11145
11147 bool hasTemplateKeyword,
11148 const UnqualifiedId &Name,
11149 ParsedType ObjectType, bool EnteringContext,
11150 TemplateTy &Template,
11151 bool &MemberOfUnknownSpecialization,
11152 bool Disambiguation = false);
11153
11154 /// Try to resolve an undeclared template name as a type template.
11155 ///
11156 /// Sets II to the identifier corresponding to the template name, and updates
11157 /// Name to a corresponding (typo-corrected) type template name and TNK to
11158 /// the corresponding kind, if possible.
11160 TemplateNameKind &TNK,
11161 SourceLocation NameLoc,
11162 IdentifierInfo *&II);
11163
11165 SourceLocation NameLoc,
11166 bool Diagnose = true);
11167
11168 /// Determine whether a particular identifier might be the name in a C++1z
11169 /// deduction-guide declaration.
11170 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11171 SourceLocation NameLoc, CXXScopeSpec &SS,
11172 ParsedTemplateTy *Template = nullptr);
11173
11175 SourceLocation IILoc, Scope *S,
11176 const CXXScopeSpec *SS,
11177 TemplateTy &SuggestedTemplate,
11178 TemplateNameKind &SuggestedKind);
11179
11180 /// Determine whether we would be unable to instantiate this template (because
11181 /// it either has no definition, or is in the process of being instantiated).
11182 bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
11183 NamedDecl *Instantiation,
11184 bool InstantiatedFromMember,
11185 const NamedDecl *Pattern,
11186 const NamedDecl *PatternDef,
11188 bool Complain = true);
11189
11190 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11191 /// that the template parameter 'PrevDecl' is being shadowed by a new
11192 /// declaration at location Loc. Returns true to indicate that this is
11193 /// an error, and false otherwise.
11194 ///
11195 /// \param Loc The location of the declaration that shadows a template
11196 /// parameter.
11197 ///
11198 /// \param PrevDecl The template parameter that the declaration shadows.
11199 ///
11200 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11201 /// a warning for compatibility with older versions of clang.
11202 /// Ignored when MSVC compatibility is enabled.
11204 bool SupportedForCompatibility = false);
11205
11206 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11207 /// the parameter D to reference the templated declaration and return a
11208 /// pointer to the template declaration. Otherwise, do nothing to D and return
11209 /// null.
11211
11212 /// ActOnTypeParameter - Called when a C++ template type parameter
11213 /// (e.g., "typename T") has been parsed. Typename specifies whether
11214 /// the keyword "typename" was used to declare the type parameter
11215 /// (otherwise, "class" was used), and KeyLoc is the location of the
11216 /// "class" or "typename" keyword. ParamName is the name of the
11217 /// parameter (NULL indicates an unnamed template parameter) and
11218 /// ParamNameLoc is the location of the parameter name (if any).
11219 /// If the type parameter has a default argument, it will be added
11220 /// later via ActOnTypeParameterDefault.
11222 SourceLocation EllipsisLoc,
11223 SourceLocation KeyLoc,
11224 IdentifierInfo *ParamName,
11225 SourceLocation ParamNameLoc, unsigned Depth,
11226 unsigned Position, SourceLocation EqualLoc,
11227 ParsedType DefaultArg, bool HasTypeConstraint);
11228
11230
11231 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11233 TemplateTypeParmDecl *ConstrainedParameter,
11234 SourceLocation EllipsisLoc);
11235 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11237 TemplateTypeParmDecl *ConstrainedParameter,
11238 SourceLocation EllipsisLoc,
11239 bool AllowUnexpandedPack);
11240
11241 /// Attach a type-constraint to a template parameter.
11242 /// \returns true if an error occurred. This can happen if the
11243 /// immediately-declared constraint could not be formed (e.g. incorrect number
11244 /// of arguments for the named concept).
11246 DeclarationNameInfo NameInfo,
11247 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
11248 const TemplateArgumentListInfo *TemplateArgs,
11249 TemplateTypeParmDecl *ConstrainedParameter,
11250 SourceLocation EllipsisLoc);
11251
11253 NonTypeTemplateParmDecl *NewConstrainedParm,
11254 NonTypeTemplateParmDecl *OrigConstrainedParm,
11255 SourceLocation EllipsisLoc);
11256
11257 /// Require the given type to be a structural type, and diagnose if it is not.
11258 ///
11259 /// \return \c true if an error was produced.
11261
11262 /// Check that the type of a non-type template parameter is
11263 /// well-formed.
11264 ///
11265 /// \returns the (possibly-promoted) parameter type if valid;
11266 /// otherwise, produces a diagnostic and returns a NULL type.
11270
11272 unsigned Depth, unsigned Position,
11273 SourceLocation EqualLoc,
11274 Expr *DefaultArg);
11275
11276 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11277 /// parameter (e.g. T in template <template <typename> class T> class array)
11278 /// has been parsed. S is the current scope.
11280 Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params,
11281 bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11282 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11283 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11284
11285 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11286 /// constrained by RequiresClause, that contains the template parameters in
11287 /// Params.
11289 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11290 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11291 SourceLocation RAngleLoc, Expr *RequiresClause);
11292
11293 /// The context in which we are checking a template parameter list.
11304
11305 /// Checks the validity of a template parameter list, possibly
11306 /// considering the template parameter list from a previous
11307 /// declaration.
11308 ///
11309 /// If an "old" template parameter list is provided, it must be
11310 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11311 /// template parameter list.
11312 ///
11313 /// \param NewParams Template parameter list for a new template
11314 /// declaration. This template parameter list will be updated with any
11315 /// default arguments that are carried through from the previous
11316 /// template parameter list.
11317 ///
11318 /// \param OldParams If provided, template parameter list from a
11319 /// previous declaration of the same template. Default template
11320 /// arguments will be merged from the old template parameter list to
11321 /// the new template parameter list.
11322 ///
11323 /// \param TPC Describes the context in which we are checking the given
11324 /// template parameter list.
11325 ///
11326 /// \param SkipBody If we might have already made a prior merged definition
11327 /// of this template visible, the corresponding body-skipping information.
11328 /// Default argument redefinition is not an error when skipping such a body,
11329 /// because (under the ODR) we can assume the default arguments are the same
11330 /// as the prior merged definition.
11331 ///
11332 /// \returns true if an error occurred, false otherwise.
11334 TemplateParameterList *OldParams,
11336 SkipBodyInfo *SkipBody = nullptr);
11337
11338 /// Match the given template parameter lists to the given scope
11339 /// specifier, returning the template parameter list that applies to the
11340 /// name.
11341 ///
11342 /// \param DeclStartLoc the start of the declaration that has a scope
11343 /// specifier or a template parameter list.
11344 ///
11345 /// \param DeclLoc The location of the declaration itself.
11346 ///
11347 /// \param SS the scope specifier that will be matched to the given template
11348 /// parameter lists. This scope specifier precedes a qualified name that is
11349 /// being declared.
11350 ///
11351 /// \param TemplateId The template-id following the scope specifier, if there
11352 /// is one. Used to check for a missing 'template<>'.
11353 ///
11354 /// \param ParamLists the template parameter lists, from the outermost to the
11355 /// innermost template parameter lists.
11356 ///
11357 /// \param IsFriend Whether to apply the slightly different rules for
11358 /// matching template parameters to scope specifiers in friend
11359 /// declarations.
11360 ///
11361 /// \param IsMemberSpecialization will be set true if the scope specifier
11362 /// denotes a fully-specialized type, and therefore this is a declaration of
11363 /// a member specialization.
11364 ///
11365 /// \returns the template parameter list, if any, that corresponds to the
11366 /// name that is preceded by the scope specifier @p SS. This template
11367 /// parameter list may have template parameters (if we're declaring a
11368 /// template) or may have no template parameters (if we're declaring a
11369 /// template specialization), or may be NULL (if what we're declaring isn't
11370 /// itself a template).
11372 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11373 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11374 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11375 bool &IsMemberSpecialization, bool &Invalid,
11376 bool SuppressDiagnostic = false);
11377
11378 /// Returns the template parameter list with all default template argument
11379 /// information.
11381
11383 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11384 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11385 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11386 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11387 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11388 TemplateParameterList **OuterTemplateParamLists,
11389 SkipBodyInfo *SkipBody = nullptr);
11390
11391 /// Translates template arguments as provided by the parser
11392 /// into template arguments used by semantic analysis.
11395
11396 /// Convert a parsed type into a parsed template argument. This is mostly
11397 /// trivial, except that we may have parsed a C++17 deduced class template
11398 /// specialization type, in which case we should form a template template
11399 /// argument instead of a type template argument.
11401
11403
11405 SourceLocation TemplateLoc,
11406 TemplateArgumentListInfo &TemplateArgs);
11407
11410 TemplateTy Template, const IdentifierInfo *TemplateII,
11411 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11412 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11413 bool IsCtorOrDtorName = false, bool IsClassName = false,
11414 ImplicitTypenameContext AllowImplicitTypename =
11416
11417 /// Parsed an elaborated-type-specifier that refers to a template-id,
11418 /// such as \c class T::template apply<U>.
11420 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11421 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11422 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11423 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11424
11427 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11429
11430 /// Get the specialization of the given variable template corresponding to
11431 /// the specified argument list, or a null-but-valid result if the arguments
11432 /// are dependent.
11434 SourceLocation TemplateLoc,
11435 SourceLocation TemplateNameLoc,
11436 const TemplateArgumentListInfo &TemplateArgs);
11437
11438 /// Form a reference to the specialization of the given variable template
11439 /// corresponding to the specified argument list, or a null-but-valid result
11440 /// if the arguments are dependent.
11442 const DeclarationNameInfo &NameInfo,
11443 VarTemplateDecl *Template, NamedDecl *FoundD,
11444 SourceLocation TemplateLoc,
11445 const TemplateArgumentListInfo *TemplateArgs);
11446
11448 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11449 const DeclarationNameInfo &ConceptNameInfo,
11450 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
11451 const TemplateArgumentListInfo *TemplateArgs);
11452
11455 bool TemplateKeyword, TemplateDecl *TD,
11457
11459 SourceLocation TemplateKWLoc, LookupResult &R,
11460 bool RequiresADL,
11461 const TemplateArgumentListInfo *TemplateArgs);
11462
11463 // We actually only call this from template instantiation.
11466 const DeclarationNameInfo &NameInfo,
11467 const TemplateArgumentListInfo *TemplateArgs,
11468 bool IsAddressOfOperand);
11469
11470 /// Form a template name from a name that is syntactically required to name a
11471 /// template, either due to use of the 'template' keyword or because a name in
11472 /// this syntactic context is assumed to name a template (C++
11473 /// [temp.names]p2-4).
11474 ///
11475 /// This action forms a template name given the name of the template and its
11476 /// optional scope specifier. This is used when the 'template' keyword is used
11477 /// or when the parsing context unambiguously treats a following '<' as
11478 /// introducing a template argument list. Note that this may produce a
11479 /// non-dependent template name if we can perform the lookup now and identify
11480 /// the named template.
11481 ///
11482 /// For example, given "x.MetaFun::template apply", the scope specifier
11483 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11484 /// of the "template" keyword, and "apply" is the \p Name.
11486 SourceLocation TemplateKWLoc,
11487 const UnqualifiedId &Name,
11488 ParsedType ObjectType,
11489 bool EnteringContext, TemplateTy &Template,
11490 bool AllowInjectedClassName = false);
11491
11493 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11494 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11496 MultiTemplateParamsArg TemplateParameterLists,
11497 SkipBodyInfo *SkipBody = nullptr);
11498
11499 /// Check the non-type template arguments of a class template
11500 /// partial specialization according to C++ [temp.class.spec]p9.
11501 ///
11502 /// \param TemplateNameLoc the location of the template name.
11503 /// \param PrimaryTemplate the template parameters of the primary class
11504 /// template.
11505 /// \param NumExplicit the number of explicitly-specified template arguments.
11506 /// \param TemplateArgs the template arguments of the class template
11507 /// partial specialization.
11508 ///
11509 /// \returns \c true if there was an error, \c false otherwise.
11511 TemplateDecl *PrimaryTemplate,
11512 unsigned NumExplicitArgs,
11518
11520 MultiTemplateParamsArg TemplateParameterLists,
11521 Declarator &D);
11522
11523 /// Diagnose cases where we have an explicit template specialization
11524 /// before/after an explicit template instantiation, producing diagnostics
11525 /// for those cases where they are required and determining whether the
11526 /// new specialization/instantiation will have any effect.
11527 ///
11528 /// \param NewLoc the location of the new explicit specialization or
11529 /// instantiation.
11530 ///
11531 /// \param NewTSK the kind of the new explicit specialization or
11532 /// instantiation.
11533 ///
11534 /// \param PrevDecl the previous declaration of the entity.
11535 ///
11536 /// \param PrevTSK the kind of the old explicit specialization or
11537 /// instantiatin.
11538 ///
11539 /// \param PrevPointOfInstantiation if valid, indicates where the previous
11540 /// declaration was instantiated (either implicitly or explicitly).
11541 ///
11542 /// \param HasNoEffect will be set to true to indicate that the new
11543 /// specialization or instantiation has no effect and should be ignored.
11544 ///
11545 /// \returns true if there was an error that should prevent the introduction
11546 /// of the new declaration into the AST, false otherwise.
11548 SourceLocation NewLoc,
11549 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
11550 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
11551 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
11552
11553 /// Perform semantic analysis for the given dependent function
11554 /// template specialization.
11555 ///
11556 /// The only possible way to get a dependent function template specialization
11557 /// is with a friend declaration, like so:
11558 ///
11559 /// \code
11560 /// template <class T> void foo(T);
11561 /// template <class T> class A {
11562 /// friend void foo<>(T);
11563 /// };
11564 /// \endcode
11565 ///
11566 /// There really isn't any useful analysis we can do here, so we
11567 /// just store the information.
11569 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
11571
11572 /// Perform semantic analysis for the given function template
11573 /// specialization.
11574 ///
11575 /// This routine performs all of the semantic analysis required for an
11576 /// explicit function template specialization. On successful completion,
11577 /// the function declaration \p FD will become a function template
11578 /// specialization.
11579 ///
11580 /// \param FD the function declaration, which will be updated to become a
11581 /// function template specialization.
11582 ///
11583 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
11584 /// if any. Note that this may be valid info even when 0 arguments are
11585 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
11586 /// as it anyway contains info on the angle brackets locations.
11587 ///
11588 /// \param Previous the set of declarations that may be specialized by
11589 /// this function specialization.
11590 ///
11591 /// \param QualifiedFriend whether this is a lookup for a qualified friend
11592 /// declaration with no explicit template argument list that might be
11593 /// befriending a function template specialization.
11595 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
11596 LookupResult &Previous, bool QualifiedFriend = false);
11597
11598 /// Perform semantic analysis for the given non-template member
11599 /// specialization.
11600 ///
11601 /// This routine performs all of the semantic analysis required for an
11602 /// explicit member function specialization. On successful completion,
11603 /// the function declaration \p FD will become a member function
11604 /// specialization.
11605 ///
11606 /// \param Member the member declaration, which will be updated to become a
11607 /// specialization.
11608 ///
11609 /// \param Previous the set of declarations, one of which may be specialized
11610 /// by this function specialization; the set will be modified to contain the
11611 /// redeclared member.
11614
11615 // Explicit instantiation of a class template specialization
11617 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
11618 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
11619 TemplateTy Template, SourceLocation TemplateNameLoc,
11620 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
11621 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
11622
11623 // Explicit instantiation of a member class of a class template.
11625 SourceLocation TemplateLoc,
11626 unsigned TagSpec, SourceLocation KWLoc,
11627 CXXScopeSpec &SS, IdentifierInfo *Name,
11628 SourceLocation NameLoc,
11629 const ParsedAttributesView &Attr);
11630
11632 SourceLocation TemplateLoc,
11633 Declarator &D);
11634
11635 /// If the given template parameter has a default template
11636 /// argument, substitute into that default template argument and
11637 /// return the corresponding template argument.
11639 TemplateDecl *Template, SourceLocation TemplateLoc,
11640 SourceLocation RAngleLoc, Decl *Param,
11641 ArrayRef<TemplateArgument> SugaredConverted,
11642 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
11643
11644 /// Returns the top most location responsible for the definition of \p N.
11645 /// If \p N is a a template specialization, this is the location
11646 /// of the top of the instantiation stack.
11647 /// Otherwise, the location of \p N is returned.
11649
11650 /// Specifies the context in which a particular template
11651 /// argument is being checked.
11653 /// The template argument was specified in the code or was
11654 /// instantiated with some deduced template arguments.
11656
11657 /// The template argument was deduced via template argument
11658 /// deduction.
11660
11661 /// The template argument was deduced from an array bound
11662 /// via template argument deduction.
11665
11666 /// Check that the given template argument corresponds to the given
11667 /// template parameter.
11668 ///
11669 /// \param Param The template parameter against which the argument will be
11670 /// checked.
11671 ///
11672 /// \param Arg The template argument, which may be updated due to conversions.
11673 ///
11674 /// \param Template The template in which the template argument resides.
11675 ///
11676 /// \param TemplateLoc The location of the template name for the template
11677 /// whose argument list we're matching.
11678 ///
11679 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
11680 /// the template argument list.
11681 ///
11682 /// \param ArgumentPackIndex The index into the argument pack where this
11683 /// argument will be placed. Only valid if the parameter is a parameter pack.
11684 ///
11685 /// \param Converted The checked, converted argument will be added to the
11686 /// end of this small vector.
11687 ///
11688 /// \param CTAK Describes how we arrived at this particular template argument:
11689 /// explicitly written, deduced, etc.
11690 ///
11691 /// \returns true on error, false otherwise.
11692 bool
11694 NamedDecl *Template, SourceLocation TemplateLoc,
11695 SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
11696 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11697 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11699
11700 /// Check that the given template arguments can be provided to
11701 /// the given template, converting the arguments along the way.
11702 ///
11703 /// \param Template The template to which the template arguments are being
11704 /// provided.
11705 ///
11706 /// \param TemplateLoc The location of the template name in the source.
11707 ///
11708 /// \param TemplateArgs The list of template arguments. If the template is
11709 /// a template template parameter, this function may extend the set of
11710 /// template arguments to also include substituted, defaulted template
11711 /// arguments.
11712 ///
11713 /// \param PartialTemplateArgs True if the list of template arguments is
11714 /// intentionally partial, e.g., because we're checking just the initial
11715 /// set of template arguments.
11716 ///
11717 /// \param Converted Will receive the converted, canonicalized template
11718 /// arguments.
11719 ///
11720 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
11721 /// contain the converted forms of the template arguments as written.
11722 /// Otherwise, \p TemplateArgs will not be modified.
11723 ///
11724 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
11725 /// receive true if the cause for the error is the associated constraints of
11726 /// the template not being satisfied by the template arguments.
11727 ///
11728 /// \param PartialOrderingTTP If true, assume these template arguments are
11729 /// the injected template arguments for a template template parameter.
11730 /// This will relax the requirement that all its possible uses are valid:
11731 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11732 /// during instantiation.
11733 ///
11734 /// \returns true if an error occurred, false otherwise.
11736 TemplateDecl *Template, SourceLocation TemplateLoc,
11737 TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs,
11738 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11739 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11740 bool UpdateArgsWithConversions = true,
11741 bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false);
11742
11745 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11746 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
11747
11748 /// Check a template argument against its corresponding
11749 /// template type parameter.
11750 ///
11751 /// This routine implements the semantics of C++ [temp.arg.type]. It
11752 /// returns true if an error occurred, and false otherwise.
11754
11755 /// Check a template argument against its corresponding
11756 /// non-type template parameter.
11757 ///
11758 /// This routine implements the semantics of C++ [temp.arg.nontype].
11759 /// If an error occurred, it returns ExprError(); otherwise, it
11760 /// returns the converted template argument. \p ParamType is the
11761 /// type of the non-type template parameter after it has been instantiated.
11763 QualType InstantiatedParamType, Expr *Arg,
11764 TemplateArgument &SugaredConverted,
11765 TemplateArgument &CanonicalConverted,
11767
11768 /// Check a template argument against its corresponding
11769 /// template template parameter.
11770 ///
11771 /// This routine implements the semantics of C++ [temp.arg.template].
11772 /// It returns true if an error occurred, and false otherwise.
11774 TemplateParameterList *Params,
11775 TemplateArgumentLoc &Arg, bool IsDeduced);
11776
11778 std::optional<SourceRange> ParamRange = {});
11779 void NoteTemplateParameterLocation(const NamedDecl &Decl);
11780
11781 /// Given a non-type template argument that refers to a
11782 /// declaration and the type of its corresponding non-type template
11783 /// parameter, produce an expression that properly refers to that
11784 /// declaration.
11786 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
11787 NamedDecl *TemplateParam = nullptr);
11789 BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg,
11790 SourceLocation Loc);
11791
11792 /// Enumeration describing how template parameter lists are compared
11793 /// for equality.
11795 /// We are matching the template parameter lists of two templates
11796 /// that might be redeclarations.
11797 ///
11798 /// \code
11799 /// template<typename T> struct X;
11800 /// template<typename T> struct X;
11801 /// \endcode
11803
11804 /// We are matching the template parameter lists of two template
11805 /// template parameters as part of matching the template parameter lists
11806 /// of two templates that might be redeclarations.
11807 ///
11808 /// \code
11809 /// template<template<int I> class TT> struct X;
11810 /// template<template<int Value> class Other> struct X;
11811 /// \endcode
11813
11814 /// We are matching the template parameter lists of a template
11815 /// template argument against the template parameter lists of a template
11816 /// template parameter.
11817 ///
11818 /// \code
11819 /// template<template<int Value> class Metafun> struct X;
11820 /// template<int Value> struct integer_c;
11821 /// X<integer_c> xic;
11822 /// \endcode
11824
11825 /// We are determining whether the template-parameters are equivalent
11826 /// according to C++ [temp.over.link]/6. This comparison does not consider
11827 /// constraints.
11828 ///
11829 /// \code
11830 /// template<C1 T> void f(T);
11831 /// template<C2 T> void f(T);
11832 /// \endcode
11834 };
11835
11836 // A struct to represent the 'new' declaration, which is either itself just
11837 // the named decl, or the important information we need about it in order to
11838 // do constraint comparisons.
11840 const NamedDecl *ND = nullptr;
11841 const DeclContext *DC = nullptr;
11842 const DeclContext *LexicalDC = nullptr;
11844
11845 public:
11848 const DeclContext *LexicalDeclCtx,
11850
11851 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
11852 assert(DC && LexicalDC &&
11853 "Constructor only for cases where we have the information to put "
11854 "in here");
11855 }
11856
11857 // If this was constructed with no information, we cannot do substitution
11858 // for constraint comparison, so make sure we can check that.
11859 bool isInvalid() const { return !ND && !DC; }
11860
11861 const NamedDecl *getDecl() const { return ND; }
11862
11863 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
11864
11866 return ND ? ND->getLexicalDeclContext() : LexicalDC;
11867 }
11868
11870 return ND ? ND->getDeclContext() : DC;
11871 }
11872
11873 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
11874 };
11875
11876 /// Determine whether the given template parameter lists are
11877 /// equivalent.
11878 ///
11879 /// \param New The new template parameter list, typically written in the
11880 /// source code as part of a new template declaration.
11881 ///
11882 /// \param Old The old template parameter list, typically found via
11883 /// name lookup of the template declared with this template parameter
11884 /// list.
11885 ///
11886 /// \param Complain If true, this routine will produce a diagnostic if
11887 /// the template parameter lists are not equivalent.
11888 ///
11889 /// \param Kind describes how we are to match the template parameter lists.
11890 ///
11891 /// \param TemplateArgLoc If this source location is valid, then we
11892 /// are actually checking the template parameter list of a template
11893 /// argument (New) against the template parameter list of its
11894 /// corresponding template template parameter (Old). We produce
11895 /// slightly different diagnostics in this scenario.
11896 ///
11897 /// \returns True if the template parameter lists are equal, false
11898 /// otherwise.
11900 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
11901 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
11903 SourceLocation TemplateArgLoc = SourceLocation());
11904
11906 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
11908 SourceLocation TemplateArgLoc = SourceLocation()) {
11909 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
11910 Kind, TemplateArgLoc);
11911 }
11912
11913 /// Check whether a template can be declared within this scope.
11914 ///
11915 /// If the template declaration is valid in this scope, returns
11916 /// false. Otherwise, issues a diagnostic and returns true.
11917 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
11918
11919 /// Called when the parser has parsed a C++ typename
11920 /// specifier, e.g., "typename T::type".
11921 ///
11922 /// \param S The scope in which this typename type occurs.
11923 /// \param TypenameLoc the location of the 'typename' keyword
11924 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11925 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
11926 /// \param IdLoc the location of the identifier.
11927 /// \param IsImplicitTypename context where T::type refers to a type.
11929 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
11930 const IdentifierInfo &II, SourceLocation IdLoc,
11932
11933 /// Called when the parser has parsed a C++ typename
11934 /// specifier that ends in a template-id, e.g.,
11935 /// "typename MetaFun::template apply<T1, T2>".
11936 ///
11937 /// \param S The scope in which this typename type occurs.
11938 /// \param TypenameLoc the location of the 'typename' keyword
11939 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11940 /// \param TemplateLoc the location of the 'template' keyword, if any.
11941 /// \param TemplateName The template name.
11942 /// \param TemplateII The identifier used to name the template.
11943 /// \param TemplateIILoc The location of the template name.
11944 /// \param LAngleLoc The location of the opening angle bracket ('<').
11945 /// \param TemplateArgs The template arguments.
11946 /// \param RAngleLoc The location of the closing angle bracket ('>').
11948 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
11949 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
11950 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
11951 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11952 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
11953
11955 SourceLocation KeywordLoc,
11956 NestedNameSpecifierLoc QualifierLoc,
11957 const IdentifierInfo &II, SourceLocation IILoc,
11958 TypeSourceInfo **TSI, bool DeducedTSTContext);
11959
11961 SourceLocation KeywordLoc,
11962 NestedNameSpecifierLoc QualifierLoc,
11963 const IdentifierInfo &II, SourceLocation IILoc,
11964 bool DeducedTSTContext = true);
11965
11966 /// Rebuilds a type within the context of the current instantiation.
11967 ///
11968 /// The type \p T is part of the type of an out-of-line member definition of
11969 /// a class template (or class template partial specialization) that was
11970 /// parsed and constructed before we entered the scope of the class template
11971 /// (or partial specialization thereof). This routine will rebuild that type
11972 /// now that we have entered the declarator's scope, which may produce
11973 /// different canonical types, e.g.,
11974 ///
11975 /// \code
11976 /// template<typename T>
11977 /// struct X {
11978 /// typedef T* pointer;
11979 /// pointer data();
11980 /// };
11981 ///
11982 /// template<typename T>
11983 /// typename X<T>::pointer X<T>::data() { ... }
11984 /// \endcode
11985 ///
11986 /// Here, the type "typename X<T>::pointer" will be created as a
11987 /// DependentNameType, since we do not know that we can look into X<T> when we
11988 /// parsed the type. This function will rebuild the type, performing the
11989 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
11990 /// canonical type is the same as the canonical type of T*, allowing the
11991 /// return types of the out-of-line definition and the declaration to match.
11994 DeclarationName Name);
11996
11998
11999 /// Rebuild the template parameters now that we know we're in a current
12000 /// instantiation.
12001 bool
12003
12004 /// Produces a formatted string that describes the binding of
12005 /// template parameters to template arguments.
12006 std::string
12008 const TemplateArgumentList &Args);
12009
12010 std::string
12012 const TemplateArgument *Args,
12013 unsigned NumArgs);
12014
12018
12019 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12020 /// was just parsed. This is only possible with an explicit scope
12021 /// specifier naming a dependent type.
12023 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12024 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12025 const TemplateArgumentListInfo *TemplateArgs);
12026
12029 SourceLocation TemplateKWLoc,
12030 const DeclarationNameInfo &NameInfo,
12031 const TemplateArgumentListInfo *TemplateArgs);
12032
12033 // Calculates whether the expression Constraint depends on an enclosing
12034 // template, for the purposes of [temp.friend] p9.
12035 // TemplateDepth is the 'depth' of the friend function, which is used to
12036 // compare whether a declaration reference is referring to a containing
12037 // template, or just the current friend function. A 'lower' TemplateDepth in
12038 // the AST refers to a 'containing' template. As the constraint is
12039 // uninstantiated, this is relative to the 'top' of the TU.
12040 bool
12042 unsigned TemplateDepth,
12043 const Expr *Constraint);
12044
12045 /// Find the failed Boolean condition within a given Boolean
12046 /// constant expression, and describe it with a string.
12047 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12048
12050
12052 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12053 const IdentifierInfo *Name, SourceLocation NameLoc);
12054
12056 Expr *ConstraintExpr,
12057 const ParsedAttributesView &Attrs);
12058
12060 bool &AddToScope);
12062
12063 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12064 const CXXScopeSpec &SS,
12065 const IdentifierInfo *Name,
12066 SourceLocation TagLoc, SourceLocation NameLoc);
12067
12069 CachedTokens &Toks);
12072
12073 /// We've found a use of a templated declaration that would trigger an
12074 /// implicit instantiation. Check that any relevant explicit specializations
12075 /// and partial specializations are visible/reachable, and diagnose if not.
12078
12079 ///@}
12080
12081 //
12082 //
12083 // -------------------------------------------------------------------------
12084 //
12085 //
12086
12087 /// \name C++ Template Argument Deduction
12088 /// Implementations are in SemaTemplateDeduction.cpp
12089 ///@{
12090
12091public:
12092 /// When true, access checking violations are treated as SFINAE
12093 /// failures rather than hard errors.
12095
12096 /// RAII class used to determine whether SFINAE has
12097 /// trapped any errors that occur during template argument
12098 /// deduction.
12100 Sema &SemaRef;
12101 unsigned PrevSFINAEErrors;
12102 bool PrevInNonInstantiationSFINAEContext;
12103 bool PrevAccessCheckingSFINAE;
12104 bool PrevLastDiagnosticIgnored;
12105
12106 public:
12107 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
12108 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
12109 PrevInNonInstantiationSFINAEContext(
12110 SemaRef.InNonInstantiationSFINAEContext),
12111 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
12112 PrevLastDiagnosticIgnored(
12113 SemaRef.getDiagnostics().isLastDiagnosticIgnored()) {
12114 if (!SemaRef.isSFINAEContext())
12115 SemaRef.InNonInstantiationSFINAEContext = true;
12116 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
12117 }
12118
12120 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
12122 PrevInNonInstantiationSFINAEContext;
12123 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
12125 PrevLastDiagnosticIgnored);
12126 }
12127
12128 /// Determine whether any SFINAE errors have been trapped.
12129 bool hasErrorOccurred() const {
12130 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
12131 }
12132 };
12133
12134 /// RAII class used to indicate that we are performing provisional
12135 /// semantic analysis to determine the validity of a construct, so
12136 /// typo-correction and diagnostics in the immediate context (not within
12137 /// implicitly-instantiated templates) should be suppressed.
12139 Sema &SemaRef;
12140 // FIXME: Using a SFINAETrap for this is a hack.
12141 SFINAETrap Trap;
12142 bool PrevDisableTypoCorrection;
12143
12144 public:
12145 explicit TentativeAnalysisScope(Sema &SemaRef)
12146 : SemaRef(SemaRef), Trap(SemaRef, true),
12147 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12148 SemaRef.DisableTypoCorrection = true;
12149 }
12151 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12152 }
12153 };
12154
12155 /// For each declaration that involved template argument deduction, the
12156 /// set of diagnostics that were suppressed during that template argument
12157 /// deduction.
12158 ///
12159 /// FIXME: Serialize this structure to the AST file.
12160 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12163
12164 /// Compare types for equality with respect to possibly compatible
12165 /// function types (noreturn adjustment, implicit calling conventions). If any
12166 /// of parameter and argument is not a function, just perform type comparison.
12167 ///
12168 /// \param P the template parameter type.
12169 ///
12170 /// \param A the argument type.
12172
12173 /// Allocate a TemplateArgumentLoc where all locations have
12174 /// been initialized to the given location.
12175 ///
12176 /// \param Arg The template argument we are producing template argument
12177 /// location information for.
12178 ///
12179 /// \param NTTPType For a declaration template argument, the type of
12180 /// the non-type template parameter that corresponds to this template
12181 /// argument. Can be null if no type sugar is available to add to the
12182 /// type from the template argument.
12183 ///
12184 /// \param Loc The source location to use for the resulting template
12185 /// argument.
12189 NamedDecl *TemplateParam = nullptr);
12190
12191 /// Get a template argument mapping the given template parameter to itself,
12192 /// e.g. for X in \c template<int X>, this would return an expression template
12193 /// argument referencing X.
12195 SourceLocation Location);
12196
12197 /// Adjust the type \p ArgFunctionType to match the calling convention,
12198 /// noreturn, and optionally the exception specification of \p FunctionType.
12199 /// Deduction often wants to ignore these properties when matching function
12200 /// types.
12202 bool AdjustExceptionSpec = false);
12203
12206 ArrayRef<TemplateArgument> TemplateArgs,
12208
12211 ArrayRef<TemplateArgument> TemplateArgs,
12213
12214 /// Deduce the template arguments of the given template from \p FromType.
12215 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12216 /// [over.match.class.deduct]p4.
12217 ///
12218 /// It only supports class or type alias templates.
12222
12227 bool NumberOfArgumentsMustMatch);
12228
12229 /// Substitute the explicitly-provided template arguments into the
12230 /// given function template according to C++ [temp.arg.explicit].
12231 ///
12232 /// \param FunctionTemplate the function template into which the explicit
12233 /// template arguments will be substituted.
12234 ///
12235 /// \param ExplicitTemplateArgs the explicitly-specified template
12236 /// arguments.
12237 ///
12238 /// \param Deduced the deduced template arguments, which will be populated
12239 /// with the converted and checked explicit template arguments.
12240 ///
12241 /// \param ParamTypes will be populated with the instantiated function
12242 /// parameters.
12243 ///
12244 /// \param FunctionType if non-NULL, the result type of the function template
12245 /// will also be instantiated and the pointed-to value will be updated with
12246 /// the instantiated function type.
12247 ///
12248 /// \param Info if substitution fails for any reason, this object will be
12249 /// populated with more information about the failure.
12250 ///
12251 /// \returns TemplateDeductionResult::Success if substitution was successful,
12252 /// or some failure condition.
12255 TemplateArgumentListInfo &ExplicitTemplateArgs,
12259
12260 /// brief A function argument from which we performed template argument
12261 // deduction for a call.
12263 OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
12264 unsigned ArgIdx, QualType OriginalArgType)
12265 : OriginalParamType(OriginalParamType),
12266 DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
12267 OriginalArgType(OriginalArgType) {}
12268
12271 unsigned ArgIdx;
12273 };
12274
12275 /// Finish template argument deduction for a function template,
12276 /// checking the deduced template arguments for completeness and forming
12277 /// the function template specialization.
12278 ///
12279 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12280 /// which the deduced argument types should be compared.
12284 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12286 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
12287 bool PartialOverloading = false,
12288 llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
12289
12290 /// Perform template argument deduction from a function call
12291 /// (C++ [temp.deduct.call]).
12292 ///
12293 /// \param FunctionTemplate the function template for which we are performing
12294 /// template argument deduction.
12295 ///
12296 /// \param ExplicitTemplateArgs the explicit template arguments provided
12297 /// for this call.
12298 ///
12299 /// \param Args the function call arguments
12300 ///
12301 /// \param Specialization if template argument deduction was successful,
12302 /// this will be set to the function template specialization produced by
12303 /// template argument deduction.
12304 ///
12305 /// \param Info the argument will be updated to provide additional information
12306 /// about template argument deduction.
12307 ///
12308 /// \param CheckNonDependent A callback to invoke to check conversions for
12309 /// non-dependent parameters, between deduction and substitution, per DR1391.
12310 /// If this returns true, substitution will be skipped and we return
12311 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12312 /// passed the parameter types (after substituting explicit template
12313 /// arguments).
12314 ///
12315 /// \returns the result of template argument deduction.
12318 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12320 bool PartialOverloading, bool AggregateDeductionCandidate,
12321 QualType ObjectType, Expr::Classification ObjectClassification,
12322 llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
12323
12324 /// Deduce template arguments when taking the address of a function
12325 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12326 /// a template.
12327 ///
12328 /// \param FunctionTemplate the function template for which we are performing
12329 /// template argument deduction.
12330 ///
12331 /// \param ExplicitTemplateArgs the explicitly-specified template
12332 /// arguments.
12333 ///
12334 /// \param ArgFunctionType the function type that will be used as the
12335 /// "argument" type (A) when performing template argument deduction from the
12336 /// function template's function type. This type may be NULL, if there is no
12337 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12338 ///
12339 /// \param Specialization if template argument deduction was successful,
12340 /// this will be set to the function template specialization produced by
12341 /// template argument deduction.
12342 ///
12343 /// \param Info the argument will be updated to provide additional information
12344 /// about template argument deduction.
12345 ///
12346 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12347 /// the address of a function template per [temp.deduct.funcaddr] and
12348 /// [over.over]. If \c false, we are looking up a function template
12349 /// specialization based on its signature, per [temp.deduct.decl].
12350 ///
12351 /// \returns the result of template argument deduction.
12354 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12356 bool IsAddressOfFunction = false);
12357
12358 /// Deduce template arguments for a templated conversion
12359 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12360 /// conversion function template specialization.
12363 Expr::Classification ObjectClassification, QualType ToType,
12365
12366 /// Deduce template arguments for a function template when there is
12367 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12368 ///
12369 /// \param FunctionTemplate the function template for which we are performing
12370 /// template argument deduction.
12371 ///
12372 /// \param ExplicitTemplateArgs the explicitly-specified template
12373 /// arguments.
12374 ///
12375 /// \param Specialization if template argument deduction was successful,
12376 /// this will be set to the function template specialization produced by
12377 /// template argument deduction.
12378 ///
12379 /// \param Info the argument will be updated to provide additional information
12380 /// about template argument deduction.
12381 ///
12382 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12383 /// the address of a function template in a context where we do not have a
12384 /// target type, per [over.over]. If \c false, we are looking up a function
12385 /// template specialization based on its signature, which only happens when
12386 /// deducing a function parameter type from an argument that is a template-id
12387 /// naming a function template specialization.
12388 ///
12389 /// \returns the result of template argument deduction.
12392 TemplateArgumentListInfo *ExplicitTemplateArgs,
12395 bool IsAddressOfFunction = false);
12396
12397 /// Substitute Replacement for \p auto in \p TypeWithAuto
12398 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12399 /// Substitute Replacement for auto in TypeWithAuto
12401 QualType Replacement);
12402
12403 // Substitute auto in TypeWithAuto for a Dependent auto type
12405
12406 // Substitute auto in TypeWithAuto for a Dependent auto type
12409
12410 /// Completely replace the \c auto in \p TypeWithAuto by
12411 /// \p Replacement. This does not retain any \c auto type sugar.
12412 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12414 QualType Replacement);
12415
12416 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12417 ///
12418 /// Note that this is done even if the initializer is dependent. (This is
12419 /// necessary to support partial ordering of templates using 'auto'.)
12420 /// A dependent type will be produced when deducing from a dependent type.
12421 ///
12422 /// \param Type the type pattern using the auto type-specifier.
12423 /// \param Init the initializer for the variable whose type is to be deduced.
12424 /// \param Result if type deduction was successful, this will be set to the
12425 /// deduced type.
12426 /// \param Info the argument will be updated to provide additional information
12427 /// about template argument deduction.
12428 /// \param DependentDeduction Set if we should permit deduction in
12429 /// dependent cases. This is necessary for template partial ordering
12430 /// with 'auto' template parameters. The template parameter depth to be
12431 /// used should be specified in the 'Info' parameter.
12432 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12433 /// does not satisfy the type-constraint in the auto
12434 /// type.
12438 bool DependentDeduction = false,
12439 bool IgnoreConstraints = false,
12440 TemplateSpecCandidateSet *FailedTSC = nullptr);
12441 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12443 bool Diagnose = true);
12444
12447
12448 /// Returns the more specialized class template partial specialization
12449 /// according to the rules of partial ordering of class template partial
12450 /// specializations (C++ [temp.class.order]).
12451 ///
12452 /// \param PS1 the first class template partial specialization
12453 ///
12454 /// \param PS2 the second class template partial specialization
12455 ///
12456 /// \returns the more specialized class template partial specialization. If
12457 /// neither partial specialization is more specialized, returns NULL.
12462
12465
12469
12472
12475 bool IsDeduced);
12476
12477 /// Mark which template parameters are used in a given expression.
12478 ///
12479 /// \param E the expression from which template parameters will be deduced.
12480 ///
12481 /// \param Used a bit vector whose elements will be set to \c true
12482 /// to indicate when the corresponding template parameter will be
12483 /// deduced.
12484 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12485 unsigned Depth, llvm::SmallBitVector &Used);
12486
12487 /// Mark which template parameters can be deduced from a given
12488 /// template argument list.
12489 ///
12490 /// \param TemplateArgs the template argument list from which template
12491 /// parameters will be deduced.
12492 ///
12493 /// \param Used a bit vector whose elements will be set to \c true
12494 /// to indicate when the corresponding template parameter will be
12495 /// deduced.
12496 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
12497 bool OnlyDeduced, unsigned Depth,
12498 llvm::SmallBitVector &Used);
12499 void
12501 llvm::SmallBitVector &Deduced) {
12503 }
12504
12505 /// Marks all of the template parameters that will be deduced by a
12506 /// call to the given function template.
12507 static void
12510 llvm::SmallBitVector &Deduced);
12511
12512 /// Returns the more specialized function template according
12513 /// to the rules of function template partial ordering (C++
12514 /// [temp.func.order]).
12515 ///
12516 /// \param FT1 the first function template
12517 ///
12518 /// \param FT2 the second function template
12519 ///
12520 /// \param TPOC the context in which we are performing partial ordering of
12521 /// function templates.
12522 ///
12523 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
12524 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
12525 /// when calling a member function.
12526 ///
12527 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
12528 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
12529 /// template from a member function
12530 ///
12531 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
12532 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
12533 /// template from a member function
12534 ///
12535 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
12536 /// candidate with a reversed parameter order. In this case, the corresponding
12537 /// P/A pairs between FT1 and FT2 are reversed.
12538 ///
12539 /// \returns the more specialized function template. If neither
12540 /// template is more specialized, returns NULL.
12543 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
12544 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false);
12545
12546 /// Retrieve the most specialized of the given function template
12547 /// specializations.
12548 ///
12549 /// \param SpecBegin the start iterator of the function template
12550 /// specializations that we will be comparing.
12551 ///
12552 /// \param SpecEnd the end iterator of the function template
12553 /// specializations, paired with \p SpecBegin.
12554 ///
12555 /// \param Loc the location where the ambiguity or no-specializations
12556 /// diagnostic should occur.
12557 ///
12558 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
12559 /// no matching candidates.
12560 ///
12561 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
12562 /// occurs.
12563 ///
12564 /// \param CandidateDiag partial diagnostic used for each function template
12565 /// specialization that is a candidate in the ambiguous ordering. One
12566 /// parameter in this diagnostic should be unbound, which will correspond to
12567 /// the string describing the template arguments for the function template
12568 /// specialization.
12569 ///
12570 /// \returns the most specialized function template specialization, if
12571 /// found. Otherwise, returns SpecEnd.
12572 UnresolvedSetIterator
12573 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
12574 TemplateSpecCandidateSet &FailedCandidates,
12575 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
12576 const PartialDiagnostic &AmbigDiag,
12577 const PartialDiagnostic &CandidateDiag,
12578 bool Complain = true, QualType TargetType = QualType());
12579
12580 /// Returns the more constrained function according to the rules of
12581 /// partial ordering by constraints (C++ [temp.constr.order]).
12582 ///
12583 /// \param FD1 the first function
12584 ///
12585 /// \param FD2 the second function
12586 ///
12587 /// \returns the more constrained function. If neither function is
12588 /// more constrained, returns NULL.
12589 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
12590 FunctionDecl *FD2);
12591
12592 ///@}
12593
12594 //
12595 //
12596 // -------------------------------------------------------------------------
12597 //
12598 //
12599
12600 /// \name C++ Template Deduction Guide
12601 /// Implementations are in SemaTemplateDeductionGuide.cpp
12602 ///@{
12603
12604 /// Declare implicit deduction guides for a class template if we've
12605 /// not already done so.
12606 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12607 SourceLocation Loc);
12608
12609 FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12610 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12611 SourceLocation Loc);
12612
12613 ///@}
12614
12615 //
12616 //
12617 // -------------------------------------------------------------------------
12618 //
12619 //
12620
12621 /// \name C++ Template Instantiation
12622 /// Implementations are in SemaTemplateInstantiate.cpp
12623 ///@{
12624
12625public:
12626 /// A helper class for building up ExtParameterInfos.
12629 bool HasInteresting = false;
12630
12631 public:
12632 /// Set the ExtParameterInfo for the parameter at the given index,
12633 ///
12634 void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
12635 assert(Infos.size() <= index);
12636 Infos.resize(index);
12637 Infos.push_back(info);
12638
12639 if (!HasInteresting)
12640 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
12641 }
12642
12643 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
12644 /// ExtParameterInfo array we've built up.
12646 getPointerOrNull(unsigned numParams) {
12647 if (!HasInteresting)
12648 return nullptr;
12649 Infos.resize(numParams);
12650 return Infos.data();
12651 }
12652 };
12653
12654 /// The current instantiation scope used to store local
12655 /// variables.
12657
12658 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
12660
12661 /// A mapping from parameters with unparsed default arguments to the
12662 /// set of instantiations of each parameter.
12663 ///
12664 /// This mapping is a temporary data structure used when parsing
12665 /// nested class templates or nested classes of class templates,
12666 /// where we might end up instantiating an inner class before the
12667 /// default arguments of its methods have been parsed.
12669
12670 /// A context in which code is being synthesized (where a source location
12671 /// alone is not sufficient to identify the context). This covers template
12672 /// instantiation and various forms of implicitly-generated functions.
12674 /// The kind of template instantiation we are performing
12676 /// We are instantiating a template declaration. The entity is
12677 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
12679
12680 /// We are instantiating a default argument for a template
12681 /// parameter. The Entity is the template parameter whose argument is
12682 /// being instantiated, the Template is the template, and the
12683 /// TemplateArgs/NumTemplateArguments provide the template arguments as
12684 /// specified.
12686
12687 /// We are instantiating a default argument for a function.
12688 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
12689 /// provides the template arguments as specified.
12691
12692 /// We are substituting explicit template arguments provided for
12693 /// a function template. The entity is a FunctionTemplateDecl.
12695
12696 /// We are substituting template argument determined as part of
12697 /// template argument deduction for either a class template
12698 /// partial specialization or a function template. The
12699 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
12700 /// a TemplateDecl.
12702
12703 /// We are substituting into a lambda expression.
12705
12706 /// We are substituting prior template arguments into a new
12707 /// template parameter. The template parameter itself is either a
12708 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
12710
12711 /// We are checking the validity of a default template argument that
12712 /// has been used when naming a template-id.
12714
12715 /// We are computing the exception specification for a defaulted special
12716 /// member function.
12718
12719 /// We are instantiating the exception specification for a function
12720 /// template which was deferred until it was needed.
12722
12723 /// We are instantiating a requirement of a requires expression.
12725
12726 /// We are checking the satisfaction of a nested requirement of a requires
12727 /// expression.
12729
12730 /// We are declaring an implicit special member function.
12732
12733 /// We are declaring an implicit 'operator==' for a defaulted
12734 /// 'operator<=>'.
12736
12737 /// We are defining a synthesized function (such as a defaulted special
12738 /// member).
12740
12741 // We are checking the constraints associated with a constrained entity or
12742 // the constraint expression of a concept. This includes the checks that
12743 // atomic constraints have the type 'bool' and that they can be constant
12744 // evaluated.
12746
12747 // We are substituting template arguments into a constraint expression.
12749
12750 // We are normalizing a constraint expression.
12752
12753 // Instantiating a Requires Expression parameter clause.
12755
12756 // We are substituting into the parameter mapping of an atomic constraint
12757 // during normalization.
12759
12760 /// We are rewriting a comparison operator in terms of an operator<=>.
12762
12763 /// We are initializing a structured binding.
12765
12766 /// We are marking a class as __dllexport.
12768
12769 /// We are building an implied call from __builtin_dump_struct. The
12770 /// arguments are in CallArgs.
12772
12773 /// Added for Template instantiation observation.
12774 /// Memoization means we are _not_ instantiating a template because
12775 /// it is already instantiated (but we entered a context where we
12776 /// would have had to if it was not already instantiated).
12778
12779 /// We are building deduction guides for a class.
12781
12782 /// We are instantiating a type alias template declaration.
12785
12786 /// Was the enclosing context a non-instantiation SFINAE context?
12788
12789 /// The point of instantiation or synthesis within the source code.
12791
12792 /// The entity that is being synthesized.
12794
12795 /// The template (or partial specialization) in which we are
12796 /// performing the instantiation, for substitutions of prior template
12797 /// arguments.
12799
12800 union {
12801 /// The list of template arguments we are substituting, if they
12802 /// are not part of the entity.
12804
12805 /// The list of argument expressions in a synthesized call.
12806 const Expr *const *CallArgs;
12807 };
12808
12809 // FIXME: Wrap this union around more members, or perhaps store the
12810 // kind-specific members in the RAII object owning the context.
12811 union {
12812 /// The number of template arguments in TemplateArgs.
12814
12815 /// The number of expressions in CallArgs.
12816 unsigned NumCallArgs;
12817
12818 /// The special member being declared or defined.
12820 };
12821
12823 assert(Kind != DeclaringSpecialMember);
12824 return {TemplateArgs, NumTemplateArgs};
12825 }
12826
12827 /// The template deduction info object associated with the
12828 /// substitution or checking of explicit or deduced template arguments.
12830
12831 /// The source range that covers the construct that cause
12832 /// the instantiation, e.g., the template-id that causes a class
12833 /// template instantiation.
12835
12837 : Kind(TemplateInstantiation),
12838 SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
12839 Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
12840 DeductionInfo(nullptr) {}
12841
12842 /// Determines whether this template is an actual instantiation
12843 /// that should be counted toward the maximum instantiation depth.
12844 bool isInstantiationRecord() const;
12845 };
12846
12847 /// A stack object to be created when performing template
12848 /// instantiation.
12849 ///
12850 /// Construction of an object of type \c InstantiatingTemplate
12851 /// pushes the current instantiation onto the stack of active
12852 /// instantiations. If the size of this stack exceeds the maximum
12853 /// number of recursive template instantiations, construction
12854 /// produces an error and evaluates true.
12855 ///
12856 /// Destruction of this object will pop the named instantiation off
12857 /// the stack.
12859 /// Note that we are instantiating a class template,
12860 /// function template, variable template, alias template,
12861 /// or a member thereof.
12862 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12863 Decl *Entity,
12864 SourceRange InstantiationRange = SourceRange());
12865
12867 /// Note that we are instantiating an exception specification
12868 /// of a function template.
12869 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12871 SourceRange InstantiationRange = SourceRange());
12872
12873 /// Note that we are instantiating a type alias template declaration.
12874 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12875 TypeAliasTemplateDecl *Entity,
12876 ArrayRef<TemplateArgument> TemplateArgs,
12877 SourceRange InstantiationRange = SourceRange());
12878
12879 /// Note that we are instantiating a default argument in a
12880 /// template-id.
12881 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12882 TemplateParameter Param, TemplateDecl *Template,
12883 ArrayRef<TemplateArgument> TemplateArgs,
12884 SourceRange InstantiationRange = SourceRange());
12885
12886 /// Note that we are substituting either explicitly-specified or
12887 /// deduced template arguments during function template argument deduction.
12888 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12889 FunctionTemplateDecl *FunctionTemplate,
12890 ArrayRef<TemplateArgument> TemplateArgs,
12892 sema::TemplateDeductionInfo &DeductionInfo,
12893 SourceRange InstantiationRange = SourceRange());
12894
12895 /// Note that we are instantiating as part of template
12896 /// argument deduction for a class template declaration.
12897 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12898 TemplateDecl *Template,
12899 ArrayRef<TemplateArgument> TemplateArgs,
12900 sema::TemplateDeductionInfo &DeductionInfo,
12901 SourceRange InstantiationRange = SourceRange());
12902
12903 /// Note that we are instantiating as part of template
12904 /// argument deduction for a class template partial
12905 /// specialization.
12906 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12908 ArrayRef<TemplateArgument> TemplateArgs,
12909 sema::TemplateDeductionInfo &DeductionInfo,
12910 SourceRange InstantiationRange = SourceRange());
12911
12912 /// Note that we are instantiating as part of template
12913 /// argument deduction for a variable template partial
12914 /// specialization.
12915 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12917 ArrayRef<TemplateArgument> TemplateArgs,
12918 sema::TemplateDeductionInfo &DeductionInfo,
12919 SourceRange InstantiationRange = SourceRange());
12920
12921 /// Note that we are instantiating a default argument for a function
12922 /// parameter.
12923 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12924 ParmVarDecl *Param,
12925 ArrayRef<TemplateArgument> TemplateArgs,
12926 SourceRange InstantiationRange = SourceRange());
12927
12928 /// Note that we are substituting prior template arguments into a
12929 /// non-type parameter.
12930 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12931 NamedDecl *Template, NonTypeTemplateParmDecl *Param,
12932 ArrayRef<TemplateArgument> TemplateArgs,
12933 SourceRange InstantiationRange);
12934
12935 /// Note that we are substituting prior template arguments into a
12936 /// template template parameter.
12937 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12938 NamedDecl *Template, TemplateTemplateParmDecl *Param,
12939 ArrayRef<TemplateArgument> TemplateArgs,
12940 SourceRange InstantiationRange);
12941
12942 /// Note that we are checking the default template argument
12943 /// against the template parameter for a given template-id.
12944 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12945 TemplateDecl *Template, NamedDecl *Param,
12946 ArrayRef<TemplateArgument> TemplateArgs,
12947 SourceRange InstantiationRange);
12948
12950 /// \brief Note that we are checking the constraints associated with some
12951 /// constrained entity (a concept declaration or a template with associated
12952 /// constraints).
12953 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12954 ConstraintsCheck, NamedDecl *Template,
12955 ArrayRef<TemplateArgument> TemplateArgs,
12956 SourceRange InstantiationRange);
12957
12959 /// \brief Note that we are checking a constraint expression associated
12960 /// with a template declaration or as part of the satisfaction check of a
12961 /// concept.
12962 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12964 sema::TemplateDeductionInfo &DeductionInfo,
12965 SourceRange InstantiationRange);
12966
12968 /// \brief Note that we are normalizing a constraint expression.
12969 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12971 SourceRange InstantiationRange);
12972
12974 /// \brief Note that we are subtituting into the parameter mapping of an
12975 /// atomic constraint during constraint normalization.
12976 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12978 SourceRange InstantiationRange);
12979
12980 /// \brief Note that we are substituting template arguments into a part of
12981 /// a requirement of a requires expression.
12982 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12984 sema::TemplateDeductionInfo &DeductionInfo,
12985 SourceRange InstantiationRange = SourceRange());
12986
12987 /// \brief Note that we are checking the satisfaction of the constraint
12988 /// expression inside of a nested requirement.
12989 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12991 SourceRange InstantiationRange = SourceRange());
12992
12993 /// \brief Note that we are checking a requires clause.
12994 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12995 const RequiresExpr *E,
12996 sema::TemplateDeductionInfo &DeductionInfo,
12997 SourceRange InstantiationRange);
12998
13000 /// \brief Note that we are building deduction guides.
13001 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13003 SourceRange InstantiationRange = SourceRange());
13004
13005 /// Note that we have finished instantiating this template.
13006 void Clear();
13007
13009
13010 /// Determines whether we have exceeded the maximum
13011 /// recursive template instantiations.
13012 bool isInvalid() const { return Invalid; }
13013
13014 /// Determine whether we are already instantiating this
13015 /// specialization in some surrounding active instantiation.
13016 bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
13017
13018 private:
13019 Sema &SemaRef;
13020 bool Invalid;
13021 bool AlreadyInstantiating;
13022 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
13023 SourceRange InstantiationRange);
13024
13027 SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
13028 Decl *Entity, NamedDecl *Template = nullptr,
13029 ArrayRef<TemplateArgument> TemplateArgs = std::nullopt,
13030 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
13031
13033
13034 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13035 };
13036
13038 const MultiLevelTemplateArgumentList &TemplateArgs,
13039 TemplateArgumentLoc &Output,
13040 SourceLocation Loc = {},
13041 const DeclarationName &Entity = {});
13042 bool
13043 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13044 const MultiLevelTemplateArgumentList &TemplateArgs,
13045 TemplateArgumentListInfo &Outputs);
13046
13047 /// Retrieve the template argument list(s) that should be used to
13048 /// instantiate the definition of the given declaration.
13049 ///
13050 /// \param ND the declaration for which we are computing template
13051 /// instantiation arguments.
13052 ///
13053 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13054 /// the decl context where it will be created. In this case, the `Innermost`
13055 /// should likely be provided. If ND is non-null, this is ignored.
13056 ///
13057 /// \param Innermost if non-NULL, specifies a template argument list for the
13058 /// template declaration passed as ND.
13059 ///
13060 /// \param RelativeToPrimary true if we should get the template
13061 /// arguments relative to the primary template, even when we're
13062 /// dealing with a specialization. This is only relevant for function
13063 /// template specializations.
13064 ///
13065 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13066 /// instantiating the definition of the given declaration, \p ND. This is
13067 /// used to determine the proper set of template instantiation arguments for
13068 /// friend function template specializations.
13069 ///
13070 /// \param ForConstraintInstantiation when collecting arguments,
13071 /// ForConstraintInstantiation indicates we should continue looking when
13072 /// encountering a lambda generic call operator, and continue looking for
13073 /// arguments on an enclosing class template.
13074 ///
13075 /// \param SkipForSpecialization when specified, any template specializations
13076 /// in a traversal would be ignored.
13077 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13078 /// when encountering a specialized member function template, rather than
13079 /// returning immediately.
13080 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13081 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13082 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13083 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13084 bool ForConstraintInstantiation = false,
13085 bool SkipForSpecialization = false,
13086 bool ForDefaultArgumentSubstitution = false);
13087
13088 /// RAII object to handle the state changes required to synthesize
13089 /// a function body.
13091 Sema &S;
13092 Sema::ContextRAII SavedContext;
13093 bool PushedCodeSynthesisContext = false;
13094
13095 public:
13097 : S(S), SavedContext(S, DC) {
13098 auto *FD = dyn_cast<FunctionDecl>(DC);
13099 S.PushFunctionScope();
13100 S.PushExpressionEvaluationContext(
13101 (FD && FD->isConsteval())
13102 ? ExpressionEvaluationContext::ImmediateFunctionContext
13103 : ExpressionEvaluationContext::PotentiallyEvaluated);
13104 if (FD) {
13105 FD->setWillHaveBody(true);
13106 S.ExprEvalContexts.back().InImmediateFunctionContext =
13107 FD->isImmediateFunction() ||
13108 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
13109 .isConstantEvaluated() ||
13110 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
13111 .isImmediateFunctionContext();
13112 S.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
13113 S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating();
13114 } else
13115 assert(isa<ObjCMethodDecl>(DC));
13116 }
13117
13119 assert(!PushedCodeSynthesisContext);
13120
13122 Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
13123 Ctx.PointOfInstantiation = UseLoc;
13124 Ctx.Entity = cast<Decl>(S.CurContext);
13125 S.pushCodeSynthesisContext(Ctx);
13126
13127 PushedCodeSynthesisContext = true;
13128 }
13129
13131 if (PushedCodeSynthesisContext)
13132 S.popCodeSynthesisContext();
13133 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13134 FD->setWillHaveBody(false);
13135 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13136 }
13137 S.PopExpressionEvaluationContext();
13138 S.PopFunctionScopeInfo();
13139 }
13140 };
13141
13142 /// List of active code synthesis contexts.
13143 ///
13144 /// This vector is treated as a stack. As synthesis of one entity requires
13145 /// synthesis of another, additional contexts are pushed onto the stack.
13147
13148 /// Specializations whose definitions are currently being instantiated.
13149 llvm::DenseSet<std::pair<Decl *, unsigned>> InstantiatingSpecializations;
13150
13151 /// Non-dependent types used in templates that have already been instantiated
13152 /// by some template instantiation.
13153 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13154
13155 /// Extra modules inspected when performing a lookup during a template
13156 /// instantiation. Computed lazily.
13158
13159 /// Cache of additional modules that should be used for name lookup
13160 /// within the current template instantiation. Computed lazily; use
13161 /// getLookupModules() to get a complete set.
13162 llvm::DenseSet<Module *> LookupModulesCache;
13163
13164 /// Map from the most recent declaration of a namespace to the most
13165 /// recent visible declaration of that namespace.
13166 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13167
13168 /// Whether we are in a SFINAE context that is not associated with
13169 /// template instantiation.
13170 ///
13171 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
13172 /// of a template instantiation or template argument deduction.
13174
13175 /// The number of \p CodeSynthesisContexts that are not template
13176 /// instantiations and, therefore, should not be counted as part of the
13177 /// instantiation depth.
13178 ///
13179 /// When the instantiation depth reaches the user-configurable limit
13180 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13181 // FIXME: Should we have a similar limit for other forms of synthesis?
13183
13184 /// The depth of the context stack at the point when the most recent
13185 /// error or warning was produced.
13186 ///
13187 /// This value is used to suppress printing of redundant context stacks
13188 /// when there are multiple errors or warnings in the same instantiation.
13189 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13191
13192 /// The template instantiation callbacks to trace or track
13193 /// instantiations (objects can be chained).
13194 ///
13195 /// This callbacks is used to print, trace or track template
13196 /// instantiations as they are being constructed.
13197 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
13199
13200 /// The current index into pack expansion arguments that will be
13201 /// used for substitution of parameter packs.
13202 ///
13203 /// The pack expansion index will be -1 to indicate that parameter packs
13204 /// should be instantiated as themselves. Otherwise, the index specifies
13205 /// which argument within the parameter pack will be used for substitution.
13207
13208 /// RAII object used to change the argument pack substitution index
13209 /// within a \c Sema object.
13210 ///
13211 /// See \c ArgumentPackSubstitutionIndex for more information.
13213 Sema &Self;
13214 int OldSubstitutionIndex;
13215
13216 public:
13217 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
13218 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
13219 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
13220 }
13221
13223 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
13224 }
13225 };
13226
13228
13231
13233 if (!CodeSynthesisContexts.empty() &&
13237 }
13240 }
13241 /// Prints the current instantiation stack through a series of
13242 /// notes.
13244
13245 /// Determines whether we are currently in a context where
13246 /// template argument substitution failures are not considered
13247 /// errors.
13248 ///
13249 /// \returns An empty \c Optional if we're not in a SFINAE context.
13250 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
13251 /// template-deduction context object, which can be used to capture
13252 /// diagnostics that will be suppressed.
13253 std::optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
13254
13255 /// Perform substitution on the type T with a given set of template
13256 /// arguments.
13257 ///
13258 /// This routine substitutes the given template arguments into the
13259 /// type T and produces the instantiated type.
13260 ///
13261 /// \param T the type into which the template arguments will be
13262 /// substituted. If this type is not dependent, it will be returned
13263 /// immediately.
13264 ///
13265 /// \param Args the template arguments that will be
13266 /// substituted for the top-level template parameters within T.
13267 ///
13268 /// \param Loc the location in the source code where this substitution
13269 /// is being performed. It will typically be the location of the
13270 /// declarator (if we're instantiating the type of some declaration)
13271 /// or the location of the type in the source code (if, e.g., we're
13272 /// instantiating the type of a cast expression).
13273 ///
13274 /// \param Entity the name of the entity associated with a declaration
13275 /// being instantiated (if any). May be empty to indicate that there
13276 /// is no such entity (if, e.g., this is a type that occurs as part of
13277 /// a cast expression) or that the entity has no name (e.g., an
13278 /// unnamed function parameter).
13279 ///
13280 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13281 /// acceptable as the top level type of the result.
13282 ///
13283 /// \returns If the instantiation succeeds, the instantiated
13284 /// type. Otherwise, produces diagnostics and returns a NULL type.
13286 const MultiLevelTemplateArgumentList &TemplateArgs,
13288 bool AllowDeducedTST = false);
13289
13291 const MultiLevelTemplateArgumentList &TemplateArgs,
13293
13295 const MultiLevelTemplateArgumentList &TemplateArgs,
13297
13298 /// A form of SubstType intended specifically for instantiating the
13299 /// type of a FunctionDecl. Its purpose is solely to force the
13300 /// instantiation of default-argument expressions and to avoid
13301 /// instantiating an exception-specification.
13303 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13304 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13305 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13306 void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
13307 const MultiLevelTemplateArgumentList &Args);
13310 SmallVectorImpl<QualType> &ExceptionStorage,
13311 const MultiLevelTemplateArgumentList &Args);
13312 ParmVarDecl *
13314 const MultiLevelTemplateArgumentList &TemplateArgs,
13315 int indexAdjustment, std::optional<unsigned> NumExpansions,
13316 bool ExpectParameterPack, bool EvaluateConstraints = true);
13317
13318 /// Substitute the given template arguments into the given set of
13319 /// parameters, producing the set of parameter types that would be generated
13320 /// from such a substitution.
13322 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13323 const MultiLevelTemplateArgumentList &TemplateArgs,
13324 SmallVectorImpl<QualType> &ParamTypes,
13326 ExtParameterInfoBuilder &ParamInfos);
13327
13328 /// Substitute the given template arguments into the default argument.
13330 const MultiLevelTemplateArgumentList &TemplateArgs,
13331 bool ForCallExpr = false);
13333 const MultiLevelTemplateArgumentList &TemplateArgs);
13334
13335 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
13336 // to disable constraint evaluation, then restore the state.
13337 template <typename InstTy> struct ConstraintEvalRAII {
13338 InstTy &TI;
13340
13342 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
13343 TI.setEvaluateConstraints(false);
13344 }
13345 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
13346 };
13347
13348 // Must be used instead of SubstExpr at 'constraint checking' time.
13351 const MultiLevelTemplateArgumentList &TemplateArgs);
13352 // Unlike the above, this does not evaluates constraints.
13354 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13355
13356 /// Substitute the given template arguments into a list of
13357 /// expressions, expanding pack expansions if required.
13358 ///
13359 /// \param Exprs The list of expressions to substitute into.
13360 ///
13361 /// \param IsCall Whether this is some form of call, in which case
13362 /// default arguments will be dropped.
13363 ///
13364 /// \param TemplateArgs The set of template arguments to substitute.
13365 ///
13366 /// \param Outputs Will receive all of the substituted arguments.
13367 ///
13368 /// \returns true if an error occurred, false otherwise.
13369 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13370 const MultiLevelTemplateArgumentList &TemplateArgs,
13371 SmallVectorImpl<Expr *> &Outputs);
13372
13374 const MultiLevelTemplateArgumentList &TemplateArgs);
13375
13378 bool CXXDirectInit);
13379
13380 /// Perform substitution on the base class specifiers of the
13381 /// given class template specialization.
13382 ///
13383 /// Produces a diagnostic and returns true on error, returns false and
13384 /// attaches the instantiated base classes to the class template
13385 /// specialization if successful.
13386 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13387 const MultiLevelTemplateArgumentList &TemplateArgs);
13388
13389 /// Instantiate the definition of a class from a given pattern.
13390 ///
13391 /// \param PointOfInstantiation The point of instantiation within the
13392 /// source code.
13393 ///
13394 /// \param Instantiation is the declaration whose definition is being
13395 /// instantiated. This will be either a class template specialization
13396 /// or a member class of a class template specialization.
13397 ///
13398 /// \param Pattern is the pattern from which the instantiation
13399 /// occurs. This will be either the declaration of a class template or
13400 /// the declaration of a member class of a class template.
13401 ///
13402 /// \param TemplateArgs The template arguments to be substituted into
13403 /// the pattern.
13404 ///
13405 /// \param TSK the kind of implicit or explicit instantiation to perform.
13406 ///
13407 /// \param Complain whether to complain if the class cannot be instantiated
13408 /// due to the lack of a definition.
13409 ///
13410 /// \returns true if an error occurred, false otherwise.
13411 bool InstantiateClass(SourceLocation PointOfInstantiation,
13412 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13413 const MultiLevelTemplateArgumentList &TemplateArgs,
13414 TemplateSpecializationKind TSK, bool Complain = true);
13415
13416 /// Instantiate the definition of an enum from a given pattern.
13417 ///
13418 /// \param PointOfInstantiation The point of instantiation within the
13419 /// source code.
13420 /// \param Instantiation is the declaration whose definition is being
13421 /// instantiated. This will be a member enumeration of a class
13422 /// temploid specialization, or a local enumeration within a
13423 /// function temploid specialization.
13424 /// \param Pattern The templated declaration from which the instantiation
13425 /// occurs.
13426 /// \param TemplateArgs The template arguments to be substituted into
13427 /// the pattern.
13428 /// \param TSK The kind of implicit or explicit instantiation to perform.
13429 ///
13430 /// \return \c true if an error occurred, \c false otherwise.
13431 bool InstantiateEnum(SourceLocation PointOfInstantiation,
13432 EnumDecl *Instantiation, EnumDecl *Pattern,
13433 const MultiLevelTemplateArgumentList &TemplateArgs,
13435
13436 /// Instantiate the definition of a field from the given pattern.
13437 ///
13438 /// \param PointOfInstantiation The point of instantiation within the
13439 /// source code.
13440 /// \param Instantiation is the declaration whose definition is being
13441 /// instantiated. This will be a class of a class temploid
13442 /// specialization, or a local enumeration within a function temploid
13443 /// specialization.
13444 /// \param Pattern The templated declaration from which the instantiation
13445 /// occurs.
13446 /// \param TemplateArgs The template arguments to be substituted into
13447 /// the pattern.
13448 ///
13449 /// \return \c true if an error occurred, \c false otherwise.
13451 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
13452 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
13453
13456
13458 SourceLocation PointOfInstantiation,
13459 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13460 TemplateSpecializationKind TSK, bool Complain = true);
13461
13462 /// Instantiates the definitions of all of the member
13463 /// of the given class, which is an instantiation of a class template
13464 /// or a member class of a template.
13465 void
13466 InstantiateClassMembers(SourceLocation PointOfInstantiation,
13467 CXXRecordDecl *Instantiation,
13468 const MultiLevelTemplateArgumentList &TemplateArgs,
13470
13471 /// Instantiate the definitions of all of the members of the
13472 /// given class template specialization, which was named as part of an
13473 /// explicit instantiation.
13475 SourceLocation PointOfInstantiation,
13476 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13478
13481 const MultiLevelTemplateArgumentList &TemplateArgs);
13482
13483 /// Do template substitution on declaration name info.
13486 const MultiLevelTemplateArgumentList &TemplateArgs);
13490 const MultiLevelTemplateArgumentList &TemplateArgs);
13491
13493 const MultiLevelTemplateArgumentList &TemplateArgs,
13494 bool EvaluateConstraint);
13495
13496 /// Determine whether we are currently performing template instantiation.
13499 }
13500
13501 ///@}
13502
13503 //
13504 //
13505 // -------------------------------------------------------------------------
13506 //
13507 //
13508
13509 /// \name C++ Template Declaration Instantiation
13510 /// Implementations are in SemaTemplateInstantiateDecl.cpp
13511 ///@{
13512
13513public:
13514 /// An entity for which implicit template instantiation is required.
13515 ///
13516 /// The source location associated with the declaration is the first place in
13517 /// the source code where the declaration was "used". It is not necessarily
13518 /// the point of instantiation (which will be either before or after the
13519 /// namespace-scope declaration that triggered this implicit instantiation),
13520 /// However, it is the location that diagnostics should generally refer to,
13521 /// because users will need to know what code triggered the instantiation.
13522 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
13523
13524 /// The queue of implicit template instantiations that are required
13525 /// but have not yet been performed.
13526 std::deque<PendingImplicitInstantiation> PendingInstantiations;
13527
13528 /// Queue of implicit template instantiations that cannot be performed
13529 /// eagerly.
13531
13535
13536 /// The queue of implicit template instantiations that are required
13537 /// and must be performed within the current local scope.
13538 ///
13539 /// This queue is only used for member functions of local classes in
13540 /// templates, which must be instantiated in the same scope as their
13541 /// enclosing function, so that they can reference function-local
13542 /// types, static variables, enumerators, etc.
13543 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
13544
13546 public:
13548 SavedPendingLocalImplicitInstantiations.swap(
13549 S.PendingLocalImplicitInstantiations);
13550 }
13551
13552 void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
13553
13555 assert(S.PendingLocalImplicitInstantiations.empty() &&
13556 "there shouldn't be any pending local implicit instantiations");
13557 SavedPendingLocalImplicitInstantiations.swap(
13558 S.PendingLocalImplicitInstantiations);
13559 }
13560
13561 private:
13562 Sema &S;
13563 std::deque<PendingImplicitInstantiation>
13564 SavedPendingLocalImplicitInstantiations;
13565 };
13566
13567 /// Records and restores the CurFPFeatures state on entry/exit of compound
13568 /// statements.
13570 public:
13573 FPOptionsOverride getOverrides() { return OldOverrides; }
13574
13575 private:
13576 Sema &S;
13577 FPOptions OldFPFeaturesState;
13578 FPOptionsOverride OldOverrides;
13579 LangOptions::FPEvalMethodKind OldEvalMethod;
13580 SourceLocation OldFPPragmaLocation;
13581 };
13582
13584 public:
13586 : S(S), Enabled(Enabled) {
13587 if (!Enabled)
13588 return;
13589
13590 S.SavedPendingInstantiations.emplace_back();
13591 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
13592
13593 S.SavedVTableUses.emplace_back();
13594 S.SavedVTableUses.back().swap(S.VTableUses);
13595 }
13596
13597 void perform() {
13598 if (Enabled) {
13599 S.DefineUsedVTables();
13600 S.PerformPendingInstantiations();
13601 }
13602 }
13603
13605 if (!Enabled)
13606 return;
13607
13608 // Restore the set of pending vtables.
13609 assert(S.VTableUses.empty() &&
13610 "VTableUses should be empty before it is discarded.");
13611 S.VTableUses.swap(S.SavedVTableUses.back());
13612 S.SavedVTableUses.pop_back();
13613
13614 // Restore the set of pending implicit instantiations.
13615 if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
13616 assert(S.PendingInstantiations.empty() &&
13617 "PendingInstantiations should be empty before it is discarded.");
13618 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13619 S.SavedPendingInstantiations.pop_back();
13620 } else {
13621 // Template instantiations in the PCH may be delayed until the TU.
13622 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13623 S.PendingInstantiations.insert(
13624 S.PendingInstantiations.end(),
13625 S.SavedPendingInstantiations.back().begin(),
13626 S.SavedPendingInstantiations.back().end());
13627 S.SavedPendingInstantiations.pop_back();
13628 }
13629 }
13630
13631 private:
13632 Sema &S;
13633 bool Enabled;
13634 };
13635
13637 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
13638
13643
13645 Decl *D)
13646 : TmplAttr(A), Scope(S), NewDecl(D) {}
13647 };
13649
13650 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
13651 const Decl *Pattern, Decl *Inst,
13652 LateInstantiatedAttrVec *LateAttrs = nullptr,
13653 LocalInstantiationScope *OuterMostScope = nullptr);
13654
13655 /// Update instantiation attributes after template was late parsed.
13656 ///
13657 /// Some attributes are evaluated based on the body of template. If it is
13658 /// late parsed, such attributes cannot be evaluated when declaration is
13659 /// instantiated. This function is used to update instantiation attributes
13660 /// when template definition is ready.
13661 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
13662
13663 void
13665 const Decl *Pattern, Decl *Inst,
13666 LateInstantiatedAttrVec *LateAttrs = nullptr,
13667 LocalInstantiationScope *OuterMostScope = nullptr);
13668
13669 /// In the MS ABI, we need to instantiate default arguments of dllexported
13670 /// default constructors along with the constructor definition. This allows IR
13671 /// gen to emit a constructor closure which calls the default constructor with
13672 /// its default arguments.
13674
13676 ParmVarDecl *Param);
13677 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
13679
13680 /// Instantiate (or find existing instantiation of) a function template with a
13681 /// given set of template arguments.
13682 ///
13683 /// Usually this should not be used, and template argument deduction should be
13684 /// used in its place.
13690
13691 /// Instantiate the definition of the given function from its
13692 /// template.
13693 ///
13694 /// \param PointOfInstantiation the point at which the instantiation was
13695 /// required. Note that this is not precisely a "point of instantiation"
13696 /// for the function, but it's close.
13697 ///
13698 /// \param Function the already-instantiated declaration of a
13699 /// function template specialization or member function of a class template
13700 /// specialization.
13701 ///
13702 /// \param Recursive if true, recursively instantiates any functions that
13703 /// are required by this instantiation.
13704 ///
13705 /// \param DefinitionRequired if true, then we are performing an explicit
13706 /// instantiation where the body of the function is required. Complain if
13707 /// there is no such body.
13708 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
13710 bool Recursive = false,
13711 bool DefinitionRequired = false,
13712 bool AtEndOfTU = false);
13715 const TemplateArgumentList *PartialSpecArgs,
13716 const TemplateArgumentListInfo &TemplateArgsInfo,
13718 SourceLocation PointOfInstantiation,
13719 LateInstantiatedAttrVec *LateAttrs = nullptr,
13720 LocalInstantiationScope *StartingScope = nullptr);
13721
13722 /// Instantiates a variable template specialization by completing it
13723 /// with appropriate type information and initializer.
13725 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
13726 const MultiLevelTemplateArgumentList &TemplateArgs);
13727
13728 /// BuildVariableInstantiation - Used after a new variable has been created.
13729 /// Sets basic variable data and decides whether to postpone the
13730 /// variable instantiation.
13731 void
13733 const MultiLevelTemplateArgumentList &TemplateArgs,
13734 LateInstantiatedAttrVec *LateAttrs,
13735 DeclContext *Owner,
13736 LocalInstantiationScope *StartingScope,
13737 bool InstantiatingVarTemplate = false,
13738 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
13739
13740 /// Instantiate the initializer of a variable.
13742 VarDecl *Var, VarDecl *OldVar,
13743 const MultiLevelTemplateArgumentList &TemplateArgs);
13744
13745 /// Instantiate the definition of the given variable from its
13746 /// template.
13747 ///
13748 /// \param PointOfInstantiation the point at which the instantiation was
13749 /// required. Note that this is not precisely a "point of instantiation"
13750 /// for the variable, but it's close.
13751 ///
13752 /// \param Var the already-instantiated declaration of a templated variable.
13753 ///
13754 /// \param Recursive if true, recursively instantiates any functions that
13755 /// are required by this instantiation.
13756 ///
13757 /// \param DefinitionRequired if true, then we are performing an explicit
13758 /// instantiation where a definition of the variable is required. Complain
13759 /// if there is no such definition.
13760 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
13761 VarDecl *Var, bool Recursive = false,
13762 bool DefinitionRequired = false,
13763 bool AtEndOfTU = false);
13764
13766 CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl,
13767 const MultiLevelTemplateArgumentList &TemplateArgs);
13768
13769 /// Find the instantiation of the given declaration within the
13770 /// current instantiation.
13771 ///
13772 /// This routine is intended to be used when \p D is a declaration
13773 /// referenced from within a template, that needs to mapped into the
13774 /// corresponding declaration within an instantiation. For example,
13775 /// given:
13776 ///
13777 /// \code
13778 /// template<typename T>
13779 /// struct X {
13780 /// enum Kind {
13781 /// KnownValue = sizeof(T)
13782 /// };
13783 ///
13784 /// bool getKind() const { return KnownValue; }
13785 /// };
13786 ///
13787 /// template struct X<int>;
13788 /// \endcode
13789 ///
13790 /// In the instantiation of X<int>::getKind(), we need to map the \p
13791 /// EnumConstantDecl for \p KnownValue (which refers to
13792 /// X<T>::<Kind>::KnownValue) to its instantiation
13793 /// (X<int>::<Kind>::KnownValue).
13794 /// \p FindInstantiatedDecl performs this mapping from within the
13795 /// instantiation of X<int>.
13796 NamedDecl *
13798 const MultiLevelTemplateArgumentList &TemplateArgs,
13799 bool FindingInstantiatedContext = false);
13800
13801 /// Finds the instantiation of the given declaration context
13802 /// within the current instantiation.
13803 ///
13804 /// \returns NULL if there was an error
13805 DeclContext *
13807 const MultiLevelTemplateArgumentList &TemplateArgs);
13808
13809 Decl *SubstDecl(Decl *D, DeclContext *Owner,
13810 const MultiLevelTemplateArgumentList &TemplateArgs);
13811
13812 /// Substitute the name and return type of a defaulted 'operator<=>' to form
13813 /// an implicit 'operator=='.
13815 FunctionDecl *Spaceship);
13816
13817 /// Performs template instantiation for all implicit template
13818 /// instantiations we have seen until this point.
13819 void PerformPendingInstantiations(bool LocalOnly = false);
13820
13823 const MultiLevelTemplateArgumentList &TemplateArgs,
13824 bool EvaluateConstraints = true);
13825
13827 const DeclContext *Pattern,
13828 const MultiLevelTemplateArgumentList &TemplateArgs);
13829
13830private:
13831 /// Introduce the instantiated local variables into the local
13832 /// instantiation scope.
13833 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
13834 const FunctionDecl *PatternDecl,
13836 /// Introduce the instantiated function parameters into the local
13837 /// instantiation scope, and set the parameter names to those used
13838 /// in the template.
13839 bool addInstantiatedParametersToScope(
13840 FunctionDecl *Function, const FunctionDecl *PatternDecl,
13842 const MultiLevelTemplateArgumentList &TemplateArgs);
13843
13844 int ParsingClassDepth = 0;
13845
13846 class SavePendingParsedClassStateRAII {
13847 public:
13848 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
13849
13850 ~SavePendingParsedClassStateRAII() {
13851 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
13852 "there shouldn't be any pending delayed exception spec checks");
13853 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
13854 "there shouldn't be any pending delayed exception spec checks");
13855 swapSavedState();
13856 }
13857
13858 private:
13859 Sema &S;
13860 decltype(DelayedOverridingExceptionSpecChecks)
13861 SavedOverridingExceptionSpecChecks;
13862 decltype(DelayedEquivalentExceptionSpecChecks)
13863 SavedEquivalentExceptionSpecChecks;
13864
13865 void swapSavedState() {
13866 SavedOverridingExceptionSpecChecks.swap(
13867 S.DelayedOverridingExceptionSpecChecks);
13868 SavedEquivalentExceptionSpecChecks.swap(
13869 S.DelayedEquivalentExceptionSpecChecks);
13870 }
13871 };
13872
13873 ///@}
13874
13875 //
13876 //
13877 // -------------------------------------------------------------------------
13878 //
13879 //
13880
13881 /// \name C++ Variadic Templates
13882 /// Implementations are in SemaTemplateVariadic.cpp
13883 ///@{
13884
13885public:
13886 /// Determine whether an unexpanded parameter pack might be permitted in this
13887 /// location. Useful for error recovery.
13889
13890 /// The context in which an unexpanded parameter pack is
13891 /// being diagnosed.
13892 ///
13893 /// Note that the values of this enumeration line up with the first
13894 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
13896 /// An arbitrary expression.
13898
13899 /// The base type of a class type.
13901
13902 /// The type of an arbitrary declaration.
13904
13905 /// The type of a data member.
13907
13908 /// The size of a bit-field.
13910
13911 /// The expression in a static assertion.
13913
13914 /// The fixed underlying type of an enumeration.
13916
13917 /// The enumerator value.
13919
13920 /// A using declaration.
13922
13923 /// A friend declaration.
13925
13926 /// A declaration qualifier.
13928
13929 /// An initializer.
13931
13932 /// A default argument.
13934
13935 /// The type of a non-type template parameter.
13937
13938 /// The type of an exception.
13940
13941 /// Explicit specialization.
13943
13944 /// Partial specialization.
13946
13947 /// Microsoft __if_exists.
13949
13950 /// Microsoft __if_not_exists.
13952
13953 /// Lambda expression.
13955
13956 /// Block expression.
13958
13959 /// A type constraint.
13961
13962 // A requirement in a requires-expression.
13964
13965 // A requires-clause.
13967 };
13968
13969 /// Diagnose unexpanded parameter packs.
13970 ///
13971 /// \param Loc The location at which we should emit the diagnostic.
13972 ///
13973 /// \param UPPC The context in which we are diagnosing unexpanded
13974 /// parameter packs.
13975 ///
13976 /// \param Unexpanded the set of unexpanded parameter packs.
13977 ///
13978 /// \returns true if an error occurred, false otherwise.
13982
13983 /// If the given type contains an unexpanded parameter pack,
13984 /// diagnose the error.
13985 ///
13986 /// \param Loc The source location where a diagnostc should be emitted.
13987 ///
13988 /// \param T The type that is being checked for unexpanded parameter
13989 /// packs.
13990 ///
13991 /// \returns true if an error occurred, false otherwise.
13994
13995 /// If the given expression contains an unexpanded parameter
13996 /// pack, diagnose the error.
13997 ///
13998 /// \param E The expression that is being checked for unexpanded
13999 /// parameter packs.
14000 ///
14001 /// \returns true if an error occurred, false otherwise.
14004
14005 /// If the given requirees-expression contains an unexpanded reference to one
14006 /// of its own parameter packs, diagnose the error.
14007 ///
14008 /// \param RE The requiress-expression that is being checked for unexpanded
14009 /// parameter packs.
14010 ///
14011 /// \returns true if an error occurred, false otherwise.
14013
14014 /// If the given nested-name-specifier contains an unexpanded
14015 /// parameter pack, diagnose the error.
14016 ///
14017 /// \param SS The nested-name-specifier that is being checked for
14018 /// unexpanded parameter packs.
14019 ///
14020 /// \returns true if an error occurred, false otherwise.
14023
14024 /// If the given name contains an unexpanded parameter pack,
14025 /// diagnose the error.
14026 ///
14027 /// \param NameInfo The name (with source location information) that
14028 /// is being checked for unexpanded parameter packs.
14029 ///
14030 /// \returns true if an error occurred, false otherwise.
14033
14034 /// If the given template name contains an unexpanded parameter pack,
14035 /// diagnose the error.
14036 ///
14037 /// \param Loc The location of the template name.
14038 ///
14039 /// \param Template The template name that is being checked for unexpanded
14040 /// parameter packs.
14041 ///
14042 /// \returns true if an error occurred, false otherwise.
14044 TemplateName Template,
14046
14047 /// If the given template argument contains an unexpanded parameter
14048 /// pack, diagnose the error.
14049 ///
14050 /// \param Arg The template argument that is being checked for unexpanded
14051 /// parameter packs.
14052 ///
14053 /// \returns true if an error occurred, false otherwise.
14056
14057 /// Collect the set of unexpanded parameter packs within the given
14058 /// template argument.
14059 ///
14060 /// \param Arg The template argument that will be traversed to find
14061 /// unexpanded parameter packs.
14063 TemplateArgument Arg,
14065
14066 /// Collect the set of unexpanded parameter packs within the given
14067 /// template argument.
14068 ///
14069 /// \param Arg The template argument that will be traversed to find
14070 /// unexpanded parameter packs.
14074
14075 /// Collect the set of unexpanded parameter packs within the given
14076 /// type.
14077 ///
14078 /// \param T The type that will be traversed to find
14079 /// unexpanded parameter packs.
14082
14083 /// Collect the set of unexpanded parameter packs within the given
14084 /// type.
14085 ///
14086 /// \param TL The type that will be traversed to find
14087 /// unexpanded parameter packs.
14090
14091 /// Collect the set of unexpanded parameter packs within the given
14092 /// nested-name-specifier.
14093 ///
14094 /// \param NNS The nested-name-specifier that will be traversed to find
14095 /// unexpanded parameter packs.
14099
14100 /// Collect the set of unexpanded parameter packs within the given
14101 /// name.
14102 ///
14103 /// \param NameInfo The name that will be traversed to find
14104 /// unexpanded parameter packs.
14106 const DeclarationNameInfo &NameInfo,
14108
14109 /// Collect the set of unexpanded parameter packs within the given
14110 /// expression.
14113
14114 /// Invoked when parsing a template argument followed by an
14115 /// ellipsis, which creates a pack expansion.
14116 ///
14117 /// \param Arg The template argument preceding the ellipsis, which
14118 /// may already be invalid.
14119 ///
14120 /// \param EllipsisLoc The location of the ellipsis.
14122 SourceLocation EllipsisLoc);
14123
14124 /// Invoked when parsing a type followed by an ellipsis, which
14125 /// creates a pack expansion.
14126 ///
14127 /// \param Type The type preceding the ellipsis, which will become
14128 /// the pattern of the pack expansion.
14129 ///
14130 /// \param EllipsisLoc The location of the ellipsis.
14132
14133 /// Construct a pack expansion type from the pattern of the pack
14134 /// expansion.
14136 SourceLocation EllipsisLoc,
14137 std::optional<unsigned> NumExpansions);
14138
14139 /// Construct a pack expansion type from the pattern of the pack
14140 /// expansion.
14141 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14142 SourceLocation EllipsisLoc,
14143 std::optional<unsigned> NumExpansions);
14144
14145 /// Invoked when parsing an expression followed by an ellipsis, which
14146 /// creates a pack expansion.
14147 ///
14148 /// \param Pattern The expression preceding the ellipsis, which will become
14149 /// the pattern of the pack expansion.
14150 ///
14151 /// \param EllipsisLoc The location of the ellipsis.
14152 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14153
14154 /// Invoked when parsing an expression followed by an ellipsis, which
14155 /// creates a pack expansion.
14156 ///
14157 /// \param Pattern The expression preceding the ellipsis, which will become
14158 /// the pattern of the pack expansion.
14159 ///
14160 /// \param EllipsisLoc The location of the ellipsis.
14161 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14162 std::optional<unsigned> NumExpansions);
14163
14164 /// Determine whether we could expand a pack expansion with the
14165 /// given set of parameter packs into separate arguments by repeatedly
14166 /// transforming the pattern.
14167 ///
14168 /// \param EllipsisLoc The location of the ellipsis that identifies the
14169 /// pack expansion.
14170 ///
14171 /// \param PatternRange The source range that covers the entire pattern of
14172 /// the pack expansion.
14173 ///
14174 /// \param Unexpanded The set of unexpanded parameter packs within the
14175 /// pattern.
14176 ///
14177 /// \param ShouldExpand Will be set to \c true if the transformer should
14178 /// expand the corresponding pack expansions into separate arguments. When
14179 /// set, \c NumExpansions must also be set.
14180 ///
14181 /// \param RetainExpansion Whether the caller should add an unexpanded
14182 /// pack expansion after all of the expanded arguments. This is used
14183 /// when extending explicitly-specified template argument packs per
14184 /// C++0x [temp.arg.explicit]p9.
14185 ///
14186 /// \param NumExpansions The number of separate arguments that will be in
14187 /// the expanded form of the corresponding pack expansion. This is both an
14188 /// input and an output parameter, which can be set by the caller if the
14189 /// number of expansions is known a priori (e.g., due to a prior substitution)
14190 /// and will be set by the callee when the number of expansions is known.
14191 /// The callee must set this value when \c ShouldExpand is \c true; it may
14192 /// set this value in other cases.
14193 ///
14194 /// \returns true if an error occurred (e.g., because the parameter packs
14195 /// are to be instantiated with arguments of different lengths), false
14196 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14197 /// must be set.
14199 SourceLocation EllipsisLoc, SourceRange PatternRange,
14201 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
14202 bool &RetainExpansion, std::optional<unsigned> &NumExpansions);
14203
14204 /// Determine the number of arguments in the given pack expansion
14205 /// type.
14206 ///
14207 /// This routine assumes that the number of arguments in the expansion is
14208 /// consistent across all of the unexpanded parameter packs in its pattern.
14209 ///
14210 /// Returns an empty Optional if the type can't be expanded.
14211 std::optional<unsigned> getNumArgumentsInExpansion(
14212 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14213
14214 std::optional<unsigned> getNumArgumentsInExpansionFromUnexpanded(
14216 const MultiLevelTemplateArgumentList &TemplateArgs);
14217
14218 /// Determine whether the given declarator contains any unexpanded
14219 /// parameter packs.
14220 ///
14221 /// This routine is used by the parser to disambiguate function declarators
14222 /// with an ellipsis prior to the ')', e.g.,
14223 ///
14224 /// \code
14225 /// void f(T...);
14226 /// \endcode
14227 ///
14228 /// To determine whether we have an (unnamed) function parameter pack or
14229 /// a variadic function.
14230 ///
14231 /// \returns true if the declarator contains any unexpanded parameter packs,
14232 /// false otherwise.
14234
14235 /// Returns the pattern of the pack expansion for a template argument.
14236 ///
14237 /// \param OrigLoc The template argument to expand.
14238 ///
14239 /// \param Ellipsis Will be set to the location of the ellipsis.
14240 ///
14241 /// \param NumExpansions Will be set to the number of expansions that will
14242 /// be generated from this pack expansion, if known a priori.
14244 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
14245 std::optional<unsigned> &NumExpansions) const;
14246
14247 /// Given a template argument that contains an unexpanded parameter pack, but
14248 /// which has already been substituted, attempt to determine the number of
14249 /// elements that will be produced once this argument is fully-expanded.
14250 ///
14251 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14252 /// avoid actually expanding the pack where possible.
14253 std::optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
14254
14255 /// Called when an expression computing the size of a parameter pack
14256 /// is parsed.
14257 ///
14258 /// \code
14259 /// template<typename ...Types> struct count {
14260 /// static const unsigned value = sizeof...(Types);
14261 /// };
14262 /// \endcode
14263 ///
14264 //
14265 /// \param OpLoc The location of the "sizeof" keyword.
14266 /// \param Name The name of the parameter pack whose size will be determined.
14267 /// \param NameLoc The source location of the name of the parameter pack.
14268 /// \param RParenLoc The location of the closing parentheses.
14270 IdentifierInfo &Name,
14271 SourceLocation NameLoc,
14272 SourceLocation RParenLoc);
14273
14274 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14275 SourceLocation EllipsisLoc,
14276 SourceLocation LSquareLoc, Expr *IndexExpr,
14277 SourceLocation RSquareLoc);
14278
14279 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14280 SourceLocation EllipsisLoc, Expr *IndexExpr,
14281 SourceLocation RSquareLoc,
14282 ArrayRef<Expr *> ExpandedExprs = {},
14283 bool EmptyPack = false);
14284
14285 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
14286 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14287 tok::TokenKind Operator,
14288 SourceLocation EllipsisLoc, Expr *RHS,
14289 SourceLocation RParenLoc);
14290 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
14291 SourceLocation LParenLoc, Expr *LHS,
14292 BinaryOperatorKind Operator,
14293 SourceLocation EllipsisLoc, Expr *RHS,
14294 SourceLocation RParenLoc,
14295 std::optional<unsigned> NumExpansions);
14296 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
14297 BinaryOperatorKind Operator);
14298
14299 ///@}
14300
14301 //
14302 //
14303 // -------------------------------------------------------------------------
14304 //
14305 //
14306
14307 /// \name Constraints and Concepts
14308 /// Implementations are in SemaConcept.cpp
14309 ///@{
14310
14311public:
14313 const llvm::FoldingSetNodeID &ID) {
14314 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14315 SatisfactionStack.emplace_back(Can, ID);
14316 }
14317
14318 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
14319
14321 const llvm::FoldingSetNodeID &ID) const {
14322 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14323 return llvm::find(SatisfactionStack, SatisfactionStackEntryTy{Can, ID}) !=
14324 SatisfactionStack.end();
14325 }
14326
14328 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
14329
14330 // Resets the current SatisfactionStack for cases where we are instantiating
14331 // constraints as a 'side effect' of normal instantiation in a way that is not
14332 // indicative of recursive definition.
14335 Sema &SemaRef;
14336
14337 public:
14339 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14340 }
14341
14343 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14344 }
14345 };
14346
14349 SatisfactionStack.swap(NewSS);
14350 }
14351
14352 /// Check whether the given expression is a valid constraint expression.
14353 /// A diagnostic is emitted if it is not, false is returned, and
14354 /// PossibleNonPrimary will be set to true if the failure might be due to a
14355 /// non-primary expression being used as an atomic constraint.
14356 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
14357 bool *PossibleNonPrimary = nullptr,
14358 bool IsTrailingRequiresClause = false);
14359
14360 /// \brief Check whether the given list of constraint expressions are
14361 /// satisfied (as if in a 'conjunction') given template arguments.
14362 /// \param Template the template-like entity that triggered the constraints
14363 /// check (either a concept or a constrained entity).
14364 /// \param ConstraintExprs a list of constraint expressions, treated as if
14365 /// they were 'AND'ed together.
14366 /// \param TemplateArgLists the list of template arguments to substitute into
14367 /// the constraint expression.
14368 /// \param TemplateIDRange The source range of the template id that
14369 /// caused the constraints check.
14370 /// \param Satisfaction if true is returned, will contain details of the
14371 /// satisfaction, with enough information to diagnose an unsatisfied
14372 /// expression.
14373 /// \returns true if an error occurred and satisfaction could not be checked,
14374 /// false otherwise.
14376 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14377 const MultiLevelTemplateArgumentList &TemplateArgLists,
14378 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
14380 return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted,
14381 TemplateArgLists, TemplateIDRange,
14382 Satisfaction);
14383 }
14384
14385 /// \brief Check whether the given list of constraint expressions are
14386 /// satisfied (as if in a 'conjunction') given template arguments.
14387 /// Additionally, takes an empty list of Expressions which is populated with
14388 /// the instantiated versions of the ConstraintExprs.
14389 /// \param Template the template-like entity that triggered the constraints
14390 /// check (either a concept or a constrained entity).
14391 /// \param ConstraintExprs a list of constraint expressions, treated as if
14392 /// they were 'AND'ed together.
14393 /// \param ConvertedConstraints a out parameter that will get populated with
14394 /// the instantiated version of the ConstraintExprs if we successfully checked
14395 /// satisfaction.
14396 /// \param TemplateArgList the multi-level list of template arguments to
14397 /// substitute into the constraint expression. This should be relative to the
14398 /// top-level (hence multi-level), since we need to instantiate fully at the
14399 /// time of checking.
14400 /// \param TemplateIDRange The source range of the template id that
14401 /// caused the constraints check.
14402 /// \param Satisfaction if true is returned, will contain details of the
14403 /// satisfaction, with enough information to diagnose an unsatisfied
14404 /// expression.
14405 /// \returns true if an error occurred and satisfaction could not be checked,
14406 /// false otherwise.
14408 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14409 llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
14410 const MultiLevelTemplateArgumentList &TemplateArgList,
14411 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
14412
14413 /// \brief Check whether the given non-dependent constraint expression is
14414 /// satisfied. Returns false and updates Satisfaction with the satisfaction
14415 /// verdict if successful, emits a diagnostic and returns true if an error
14416 /// occurred and satisfaction could not be determined.
14417 ///
14418 /// \returns true if an error occurred, false otherwise.
14419 bool CheckConstraintSatisfaction(const Expr *ConstraintExpr,
14420 ConstraintSatisfaction &Satisfaction);
14421
14422 /// Check whether the given function decl's trailing requires clause is
14423 /// satisfied, if any. Returns false and updates Satisfaction with the
14424 /// satisfaction verdict if successful, emits a diagnostic and returns true if
14425 /// an error occurred and satisfaction could not be determined.
14426 ///
14427 /// \returns true if an error occurred, false otherwise.
14429 ConstraintSatisfaction &Satisfaction,
14430 SourceLocation UsageLoc = SourceLocation(),
14431 bool ForOverloadResolution = false);
14432
14433 // Calculates whether two constraint expressions are equal irrespective of a
14434 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
14435 // 'New', which are the "source" of the constraint, since this is necessary
14436 // for figuring out the relative 'depth' of the constraint. The depth of the
14437 // 'primary template' and the 'instantiated from' templates aren't necessarily
14438 // the same, such as a case when one is a 'friend' defined in a class.
14440 const Expr *OldConstr,
14441 const TemplateCompareNewDeclInfo &New,
14442 const Expr *NewConstr);
14443
14444 // Calculates whether the friend function depends on an enclosing template for
14445 // the purposes of [temp.friend] p9.
14447
14448 /// \brief Ensure that the given template arguments satisfy the constraints
14449 /// associated with the given template, emitting a diagnostic if they do not.
14450 ///
14451 /// \param Template The template to which the template arguments are being
14452 /// provided.
14453 ///
14454 /// \param TemplateArgs The converted, canonicalized template arguments.
14455 ///
14456 /// \param TemplateIDRange The source range of the template id that
14457 /// caused the constraints check.
14458 ///
14459 /// \returns true if the constrains are not satisfied or could not be checked
14460 /// for satisfaction, false if the constraints are satisfied.
14462 TemplateDecl *Template,
14463 const MultiLevelTemplateArgumentList &TemplateArgs,
14464 SourceRange TemplateIDRange);
14465
14467 SourceLocation PointOfInstantiation, FunctionDecl *Decl,
14468 ArrayRef<TemplateArgument> TemplateArgs,
14469 ConstraintSatisfaction &Satisfaction);
14470
14471 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14472 /// unsatisfied.
14473 /// \param First whether this is the first time an unsatisfied constraint is
14474 /// diagnosed for this error.
14476 bool First = true);
14477
14478 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14479 /// unsatisfied.
14480 void
14482 bool First = true);
14483
14485 NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints);
14486
14487 /// \brief Check whether the given declaration's associated constraints are
14488 /// at least as constrained than another declaration's according to the
14489 /// partial ordering of constraints.
14490 ///
14491 /// \param Result If no error occurred, receives the result of true if D1 is
14492 /// at least constrained than D2, and false otherwise.
14493 ///
14494 /// \returns true if an error occurred, false otherwise.
14497 bool &Result);
14498
14499 /// If D1 was not at least as constrained as D2, but would've been if a pair
14500 /// of atomic constraints involved had been declared in a concept and not
14501 /// repeated in two separate places in code.
14502 /// \returns true if such a diagnostic was emitted, false otherwise.
14506
14507private:
14508 /// Caches pairs of template-like decls whose associated constraints were
14509 /// checked for subsumption and whether or not the first's constraints did in
14510 /// fact subsume the second's.
14511 llvm::DenseMap<std::pair<NamedDecl *, NamedDecl *>, bool> SubsumptionCache;
14512 /// Caches the normalized associated constraints of declarations (concepts or
14513 /// constrained declarations). If an error occurred while normalizing the
14514 /// associated constraints of the template or concept, nullptr will be cached
14515 /// here.
14516 llvm::DenseMap<NamedDecl *, NormalizedConstraint *> NormalizationCache;
14517
14518 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
14519 SatisfactionCache;
14520
14521 // The current stack of constraint satisfactions, so we can exit-early.
14523
14524 /// Introduce the instantiated captures of the lambda into the local
14525 /// instantiation scope.
14526 bool addInstantiatedCapturesToScope(
14527 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14529 const MultiLevelTemplateArgumentList &TemplateArgs);
14530
14531 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in
14532 /// the case of lambdas) set up the LocalInstantiationScope of the current
14533 /// function.
14534 bool
14535 SetupConstraintScope(FunctionDecl *FD,
14536 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14537 const MultiLevelTemplateArgumentList &MLTAL,
14539
14540 /// Used during constraint checking, sets up the constraint template argument
14541 /// lists, and calls SetupConstraintScope to set up the
14542 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
14543 std::optional<MultiLevelTemplateArgumentList>
14544 SetupConstraintCheckingTemplateArgumentsAndScope(
14545 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14547
14548 ///@}
14549
14550 //
14551 //
14552 // -------------------------------------------------------------------------
14553 //
14554 //
14555
14556 /// \name Types
14557 /// Implementations are in SemaType.cpp
14558 ///@{
14559
14560public:
14561 /// A mapping that describes the nullability we've seen in each header file.
14563
14564 static int getPrintable(int I) { return I; }
14565 static unsigned getPrintable(unsigned I) { return I; }
14566 static bool getPrintable(bool B) { return B; }
14567 static const char *getPrintable(const char *S) { return S; }
14568 static StringRef getPrintable(StringRef S) { return S; }
14569 static const std::string &getPrintable(const std::string &S) { return S; }
14570 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
14571 return II;
14572 }
14574 static QualType getPrintable(QualType T) { return T; }
14575 static SourceRange getPrintable(SourceRange R) { return R; }
14577 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
14579
14580 enum class CompleteTypeKind {
14581 /// Apply the normal rules for complete types. In particular,
14582 /// treat all sizeless types as incomplete.
14583 Normal,
14584
14585 /// Relax the normal rules for complete types so that they include
14586 /// sizeless built-in types.
14588
14589 // FIXME: Eventually we should flip the default to Normal and opt in
14590 // to AcceptSizeless rather than opt out of it.
14592 };
14593
14595 const DeclSpec *DS = nullptr);
14597 const DeclSpec *DS = nullptr);
14598
14599 /// Build a pointer type.
14600 ///
14601 /// \param T The type to which we'll be building a pointer.
14602 ///
14603 /// \param Loc The location of the entity whose type involves this
14604 /// pointer type or, if there is no such entity, the location of the
14605 /// type that will have pointer type.
14606 ///
14607 /// \param Entity The name of the entity that involves the pointer
14608 /// type, if known.
14609 ///
14610 /// \returns A suitable pointer type, if there are no
14611 /// errors. Otherwise, returns a NULL type.
14613 DeclarationName Entity);
14614
14615 /// Build a reference type.
14616 ///
14617 /// \param T The type to which we'll be building a reference.
14618 ///
14619 /// \param Loc The location of the entity whose type involves this
14620 /// reference type or, if there is no such entity, the location of the
14621 /// type that will have reference type.
14622 ///
14623 /// \param Entity The name of the entity that involves the reference
14624 /// type, if known.
14625 ///
14626 /// \returns A suitable reference type, if there are no
14627 /// errors. Otherwise, returns a NULL type.
14629 DeclarationName Entity);
14630
14631 /// Build an array type.
14632 ///
14633 /// \param T The type of each element in the array.
14634 ///
14635 /// \param ASM C99 array size modifier (e.g., '*', 'static').
14636 ///
14637 /// \param ArraySize Expression describing the size of the array.
14638 ///
14639 /// \param Brackets The range from the opening '[' to the closing ']'.
14640 ///
14641 /// \param Entity The name of the entity that involves the array
14642 /// type, if known.
14643 ///
14644 /// \returns A suitable array type, if there are no errors. Otherwise,
14645 /// returns a NULL type.
14647 unsigned Quals, SourceRange Brackets,
14648 DeclarationName Entity);
14650
14651 /// Build an ext-vector type.
14652 ///
14653 /// Run the required checks for the extended vector type.
14655 SourceLocation AttrLoc);
14656 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
14657 SourceLocation AttrLoc);
14658
14660 Expr *CountExpr,
14661 bool CountInBytes,
14662 bool OrNull);
14663
14664 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
14665 /// expression is uninstantiated. If instantiated it will apply the
14666 /// appropriate address space to the type. This function allows dependent
14667 /// template variables to be used in conjunction with the address_space
14668 /// attribute
14669 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
14670 SourceLocation AttrLoc);
14671
14672 /// Same as above, but constructs the AddressSpace index if not provided.
14674 SourceLocation AttrLoc);
14675
14677
14679
14680 /// Build a function type.
14681 ///
14682 /// This routine checks the function type according to C++ rules and
14683 /// under the assumption that the result type and parameter types have
14684 /// just been instantiated from a template. It therefore duplicates
14685 /// some of the behavior of GetTypeForDeclarator, but in a much
14686 /// simpler form that is only suitable for this narrow use case.
14687 ///
14688 /// \param T The return type of the function.
14689 ///
14690 /// \param ParamTypes The parameter types of the function. This array
14691 /// will be modified to account for adjustments to the types of the
14692 /// function parameters.
14693 ///
14694 /// \param Loc The location of the entity whose type involves this
14695 /// function type or, if there is no such entity, the location of the
14696 /// type that will have function type.
14697 ///
14698 /// \param Entity The name of the entity that involves the function
14699 /// type, if known.
14700 ///
14701 /// \param EPI Extra information about the function type. Usually this will
14702 /// be taken from an existing function with the same prototype.
14703 ///
14704 /// \returns A suitable function type, if there are no errors. The
14705 /// unqualified type will always be a FunctionProtoType.
14706 /// Otherwise, returns a NULL type.
14710
14711 /// Build a member pointer type \c T Class::*.
14712 ///
14713 /// \param T the type to which the member pointer refers.
14714 /// \param Class the class type into which the member pointer points.
14715 /// \param Loc the location where this type begins
14716 /// \param Entity the name of the entity that will have this member pointer
14717 /// type
14718 ///
14719 /// \returns a member pointer type, if successful, or a NULL type if there was
14720 /// an error.
14723
14724 /// Build a block pointer type.
14725 ///
14726 /// \param T The type to which we'll be building a block pointer.
14727 ///
14728 /// \param Loc The source location, used for diagnostics.
14729 ///
14730 /// \param Entity The name of the entity that involves the block pointer
14731 /// type, if known.
14732 ///
14733 /// \returns A suitable block pointer type, if there are no
14734 /// errors. Otherwise, returns a NULL type.
14736 DeclarationName Entity);
14737
14738 /// Build a paren type including \p T.
14741
14742 /// Build a Read-only Pipe type.
14743 ///
14744 /// \param T The type to which we'll be building a Pipe.
14745 ///
14746 /// \param Loc We do not use it for now.
14747 ///
14748 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14749 /// a NULL type.
14751
14752 /// Build a Write-only Pipe type.
14753 ///
14754 /// \param T The type to which we'll be building a Pipe.
14755 ///
14756 /// \param Loc We do not use it for now.
14757 ///
14758 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14759 /// a NULL type.
14761
14762 /// Build a bit-precise integer type.
14763 ///
14764 /// \param IsUnsigned Boolean representing the signedness of the type.
14765 ///
14766 /// \param BitWidth Size of this int type in bits, or an expression
14767 /// representing that.
14768 ///
14769 /// \param Loc Location of the keyword.
14770 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
14771
14772 /// GetTypeForDeclarator - Convert the type for the specified
14773 /// declarator to Type instances.
14774 ///
14775 /// The result of this call will never be null, but the associated
14776 /// type may be a null type if there's an unrecoverable error.
14779
14780 /// Package the given type and TSI into a ParsedType.
14783 TypeSourceInfo **TInfo = nullptr);
14784
14786
14787 // Check whether the size of array element of type \p EltTy is a multiple of
14788 // its alignment and return false if it isn't.
14790
14791 void
14792 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
14793 SourceLocation FallbackLoc,
14794 SourceLocation ConstQualLoc = SourceLocation(),
14795 SourceLocation VolatileQualLoc = SourceLocation(),
14796 SourceLocation RestrictQualLoc = SourceLocation(),
14797 SourceLocation AtomicQualLoc = SourceLocation(),
14798 SourceLocation UnalignedQualLoc = SourceLocation());
14799
14800 /// Retrieve the keyword associated
14802
14803 /// Adjust the calling convention of a method to be the ABI default if it
14804 /// wasn't specified explicitly. This handles method types formed from
14805 /// function type typedefs and typename template arguments.
14806 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
14807 bool IsCtorOrDtor, SourceLocation Loc);
14808
14809 // Check if there is an explicit attribute, but only look through parens.
14810 // The intent is to look for an attribute on the current declarator, but not
14811 // one that came from a typedef.
14813
14814 /// Check whether a nullability type specifier can be added to the given
14815 /// type through some means not written in source (e.g. API notes).
14816 ///
14817 /// \param Type The type to which the nullability specifier will be
14818 /// added. On success, this type will be updated appropriately.
14819 ///
14820 /// \param Nullability The nullability specifier to add.
14821 ///
14822 /// \param DiagLoc The location to use for diagnostics.
14823 ///
14824 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
14825 /// array type (e.g., because it will decay to a pointer).
14826 ///
14827 /// \param OverrideExisting Whether to override an existing, locally-specified
14828 /// nullability specifier rather than complaining about the conflict.
14829 ///
14830 /// \returns true if nullability cannot be applied, false otherwise.
14832 NullabilityKind Nullability,
14833 SourceLocation DiagLoc,
14834 bool AllowArrayTypes,
14835 bool OverrideExisting);
14836
14837 /// Get the type of expression E, triggering instantiation to complete the
14838 /// type if necessary -- that is, if the expression refers to a templated
14839 /// static data member of incomplete array type.
14840 ///
14841 /// May still return an incomplete type if instantiation was not possible or
14842 /// if the type is incomplete for a different reason. Use
14843 /// RequireCompleteExprType instead if a diagnostic is expected for an
14844 /// incomplete expression type.
14846
14848
14849 /// Ensure that the type of the given expression is complete.
14850 ///
14851 /// This routine checks whether the expression \p E has a complete type. If
14852 /// the expression refers to an instantiable construct, that instantiation is
14853 /// performed as needed to complete its type. Furthermore
14854 /// Sema::RequireCompleteType is called for the expression's type (or in the
14855 /// case of a reference type, the referred-to type).
14856 ///
14857 /// \param E The expression whose type is required to be complete.
14858 /// \param Kind Selects which completeness rules should be applied.
14859 /// \param Diagnoser The object that will emit a diagnostic if the type is
14860 /// incomplete.
14861 ///
14862 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
14863 /// otherwise.
14865 TypeDiagnoser &Diagnoser);
14866 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
14867
14868 template <typename... Ts>
14869 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
14870 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14872 }
14873
14874 /// Retrieve a version of the type 'T' that is elaborated by Keyword,
14875 /// qualified by the nested-name-specifier contained in SS, and that is
14876 /// (re)declared by OwnedTagDecl, which is nullptr if this is not a
14877 /// (re)declaration.
14879 const CXXScopeSpec &SS, QualType T,
14880 TagDecl *OwnedTagDecl = nullptr);
14881
14882 // Returns the underlying type of a decltype with the given expression.
14884
14886 /// If AsUnevaluated is false, E is treated as though it were an evaluated
14887 /// context, such as when building a type for decltype(auto).
14888 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
14889
14890 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
14892 SourceLocation EllipsisLoc);
14893 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
14894 SourceLocation Loc, SourceLocation EllipsisLoc,
14895 bool FullySubstituted = false,
14896 ArrayRef<QualType> Expansions = {});
14897
14915
14916 /// Ensure that the type T is a literal type.
14917 ///
14918 /// This routine checks whether the type @p T is a literal type. If @p T is an
14919 /// incomplete type, an attempt is made to complete it. If @p T is a literal
14920 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
14921 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
14922 /// it the type @p T), along with notes explaining why the type is not a
14923 /// literal type, and returns true.
14924 ///
14925 /// @param Loc The location in the source that the non-literal type
14926 /// diagnostic should refer to.
14927 ///
14928 /// @param T The type that this routine is examining for literalness.
14929 ///
14930 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
14931 ///
14932 /// @returns @c true if @p T is not a literal type and a diagnostic was
14933 /// emitted, @c false otherwise.
14935 TypeDiagnoser &Diagnoser);
14936 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
14937
14938 template <typename... Ts>
14940 const Ts &...Args) {
14941 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14942 return RequireLiteralType(Loc, T, Diagnoser);
14943 }
14944
14947 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
14948 }
14949
14950 /// Ensure that the type T is a complete type.
14951 ///
14952 /// This routine checks whether the type @p T is complete in any
14953 /// context where a complete type is required. If @p T is a complete
14954 /// type, returns false. If @p T is a class template specialization,
14955 /// this routine then attempts to perform class template
14956 /// instantiation. If instantiation fails, or if @p T is incomplete
14957 /// and cannot be completed, issues the diagnostic @p diag (giving it
14958 /// the type @p T) and returns true.
14959 ///
14960 /// @param Loc The location in the source that the incomplete type
14961 /// diagnostic should refer to.
14962 ///
14963 /// @param T The type that this routine is examining for completeness.
14964 ///
14965 /// @param Kind Selects which completeness rules should be applied.
14966 ///
14967 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
14968 /// @c false otherwise.
14970 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
14972 CompleteTypeKind Kind, unsigned DiagID);
14973
14975 TypeDiagnoser &Diagnoser) {
14977 }
14980 }
14981
14982 template <typename... Ts>
14984 const Ts &...Args) {
14985 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14986 return RequireCompleteType(Loc, T, Diagnoser);
14987 }
14988
14989 /// Determine whether a declaration is visible to name lookup.
14990 bool isVisible(const NamedDecl *D) {
14991 return D->isUnconditionallyVisible() ||
14992 isAcceptableSlow(D, AcceptableKind::Visible);
14993 }
14994
14995 /// Determine whether a declaration is reachable.
14996 bool isReachable(const NamedDecl *D) {
14997 // All visible declarations are reachable.
14998 return D->isUnconditionallyVisible() ||
14999 isAcceptableSlow(D, AcceptableKind::Reachable);
15000 }
15001
15002 /// Determine whether a declaration is acceptable (visible/reachable).
15005 }
15006
15007 /// Determine if \p D and \p Suggested have a structurally compatible
15008 /// layout as described in C11 6.2.7/1.
15009 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15010
15011 /// Determine if \p D has a visible definition. If not, suggest a declaration
15012 /// that should be made visible to expose the definition.
15013 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15014 bool OnlyNeedComplete = false);
15016 NamedDecl *Hidden;
15017 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15018 }
15019
15020 /// Determine if \p D has a reachable definition. If not, suggest a
15021 /// declaration that should be made reachable to expose the definition.
15022 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15023 bool OnlyNeedComplete = false);
15025 NamedDecl *Hidden;
15026 return hasReachableDefinition(D, &Hidden);
15027 }
15028
15029 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15031 bool OnlyNeedComplete = false);
15033 NamedDecl *Hidden;
15034 return hasAcceptableDefinition(D, &Hidden, Kind);
15035 }
15036
15037private:
15038 /// The implementation of RequireCompleteType
15039 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15040 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15041
15042 /// Nullability type specifiers.
15043 IdentifierInfo *Ident__Nonnull = nullptr;
15044 IdentifierInfo *Ident__Nullable = nullptr;
15045 IdentifierInfo *Ident__Nullable_result = nullptr;
15046 IdentifierInfo *Ident__Null_unspecified = nullptr;
15047
15048 ///@}
15049
15050 //
15051 //
15052 // -------------------------------------------------------------------------
15053 //
15054 //
15055
15056 /// \name FixIt Helpers
15057 /// Implementations are in SemaFixItUtils.cpp
15058 ///@{
15059
15060public:
15061 /// Get a string to suggest for zero-initialization of a type.
15063 SourceLocation Loc) const;
15065
15066 ///@}
15067};
15068
15069DeductionFailureInfo
15071 sema::TemplateDeductionInfo &Info);
15072
15073/// Contains a late templated function.
15074/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15077 /// The template function declaration to be late parsed.
15079 /// Floating-point options in the point of definition.
15081};
15082
15083template <>
15085 PragmaMsStackAction Action,
15086 llvm::StringRef StackSlotLabel,
15088} // end namespace clang
15089
15090#endif
#define V(N, I)
Definition: ASTContext.h:3341
Forward declaration of all AST node types.
MatchType Type
StringRef P
static char ID
Definition: Arena.cpp:183
#define SM(sm)
Definition: Cuda.cpp:83
Defines enum values for all the target-independent builtin functions.
static void emit(Program &P, std::vector< std::byte > &Code, const T &Val, bool &Success)
Helper to write bytecode and bail out if 32-bit offsets become invalid.
const Decl * D
IndirectLocalPath & Path
enum clang::sema::@1656::IndirectLocalPathEntry::EntryKind Kind
const LambdaCapture * Capture
Expr * E
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
Defines enumerations for expression traits intrinsics.
int Priority
Definition: Format.cpp:3018
StringRef Identifier
Definition: Format.cpp:3022
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
Definition: MachO.h:51
llvm::MachO::Record Record
Definition: MachO.h:31
Defines the clang::Module class, which describes a module in the source code.
Defines the clang::OpenCLOptions class.
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
Definition: Redeclaration.h:18
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
uint32_t Id
Definition: SemaARM.cpp:1144
AccessResult
A copy of Sema's enum without AR_delayed.
Definition: SemaAccess.cpp:31
CastType
Definition: SemaCast.cpp:49
SourceRange Range
Definition: SemaObjC.cpp:758
SourceLocation Loc
Definition: SemaObjC.cpp:759
Sema::AllowedExplicit AllowedExplicit
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TemplateNameKind enum.
Defines the clang::TokenKind enum and support functions.
Defines the clang::TypeLoc interface and its subclasses.
Defines enumerations for the type traits support.
TypePropertyCache< Private > Cache
Definition: Type.cpp:4483
C Language Family Type Representation.
SourceLocation Begin
StateNode * Previous
std::string Label
__device__ int
A class for storing results from argument-dependent lookup.
Definition: Lookup.h:869
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition: ASTConsumer.h:34
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:187
CanQualType BoolTy
Definition: ASTContext.h:1120
CanQualType IntTy
Definition: ASTContext.h:1128
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:378
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:89
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:86
PtrTy get() const
Definition: Ownership.h:170
bool isInvalid() const
Definition: Ownership.h:166
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2674
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:3571
Attr - This represents one attribute.
Definition: Attr.h:42
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:6025
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:6380
Represents a C++ declaration that introduces decls from somewhere else.
Definition: DeclCXX.h:3421
A binding in a decomposition declaration.
Definition: DeclCXX.h:4111
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4471
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2539
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2866
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2304
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2498
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2803
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2064
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:74
Represents the this expression in C++.
Definition: ExprCXX.h:1152
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:69
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2830
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4670
CaseStmt - Represent a case statement.
Definition: Stmt.h:1811
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3498
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
Abstract interface for a consumer of code-completion information.
Declaration of a C++20 concept.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:35
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3602
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4533
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
The information about the darwin SDK that was used during this compilation.
Definition: DarwinSDKInfo.h:29
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1369
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1436
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1265
Captures information about "declaration specifiers".
Definition: DeclSpec.h:247
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:836
SourceLocation getLocation() const
Definition: DeclBase.h:446
DeclContext * getDeclContext()
Definition: DeclBase.h:455
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:908
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:731
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1903
A decomposition declaration.
Definition: DeclCXX.h:4170
A dependently-generated diagnostic.
Designation - Represent a full designation, which is a sequence of designators.
Definition: Designator.h:208
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:192
void setLastDiagnosticIgnored(bool Ignored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed,...
Definition: Diagnostic.h:761
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3274
Represents an enum.
Definition: Decl.h:3844
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:5996
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1901
The return type of classify().
Definition: Expr.h:330
This represents one expression.
Definition: Expr.h:110
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:192
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
Definition: Expr.h:797
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
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
An abstract interface that should be implemented by external AST sources that also provide informatio...
virtual void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs)
Read the set of tentative definitions known to the external Sema source.
virtual void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls)
Read the set of unused file-scope declarations known to the external Sema source.
virtual void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls)
Read the set of ext_vector type declarations known to the external Sema source.
virtual void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls)
Read the set of delegating constructors known to the external Sema source.
Represents difference between two FPOptions values.
Definition: LangOptions.h:947
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
Definition: LangOptions.h:1054
Represents a member of a struct/union/class.
Definition: Decl.h:3030
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
A mapping from file IDs to a record of whether we've seen nullability information in that file.
Definition: Sema.h:238
FileNullability & operator[](FileID file)
Definition: Sema.h:249
FileNullability Nullability
Definition: Sema.h:245
Represents a function declaration or definition.
Definition: Decl.h:1932
Kind kind() const
The kind of the effect.
Definition: Type.h:4748
Kind
Identifies the particular effect.
Definition: Type.h:4711
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition: Type.cpp:5124
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition: Type.h:4887
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4648
Represents a prototype with parameter type info, e.g.
Definition: Type.h:5007
Declaration of a template function.
Definition: DeclTemplate.h:957
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition: Type.h:4339
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4313
One of these records is kept for each identifier that is lexed.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Definition: Overload.h:567
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3318
Describes an C or C++ initializer list.
Definition: Expr.h:5039
Describes the kind of initialization being performed, along with location information for tokens rela...
Describes the sequence of initializations required to initialize a given object or reference with a s...
Describes an entity that is being initialized.
Represents the declaration of a label.
Definition: Decl.h:499
ComplexRangeKind
Controls the various implementations for complex multiplication and.
Definition: LangOptions.h:428
FPEvalMethodKind
Possible float expression evaluation method choices.
Definition: LangOptions.h:288
FPExceptionModeKind
Possible floating point exception behavior.
Definition: LangOptions.h:276
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:476
Represents a lazily-loaded vector of data.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
Definition: Template.h:365
Represents the results of name lookup.
Definition: Lookup.h:46
A global _GUID constant.
Definition: DeclCXX.h:4293
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4239
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4728
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3187
Abstract interface for a module loader.
Definition: ModuleLoader.h:82
Describes a module or submodule.
Definition: Module.h:105
Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit, unsigned VisibilityID)
Construct a new module or submodule.
Definition: Module.cpp:37
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition: Template.h:76
This represents a decl that may have a name.
Definition: Decl.h:249
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
Definition: Decl.h:414
Represent a C++ namespace.
Definition: Decl.h:547
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition: Type.h:7404
Wrapper for void* pointer.
Definition: Ownership.h:50
static OpaquePtr make(QualType P)
Definition: Ownership.h:60
OpenCL supported extensions and optional core features.
Definition: OpenCLOptions.h:69
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
Definition: Overload.h:1008
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Definition: Attr.h:250
ParenExpr - This represents a parenthesized expression, e.g.
Definition: Expr.h:2135
Represents a parameter to a function.
Definition: Decl.h:1722
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:129
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:958
Represents the parsed form of a C++ template argument.
Parser - This implements a parser for the C family of languages.
Definition: Parser.h:58
Tracks expected type during expression parsing, for use in code completion.
Definition: Sema.h:270
void enterFunctionArgument(SourceLocation Tok, llvm::function_ref< QualType()> ComputeType)
Computing a type for the function argument may require running overloading, so we postpone its comput...
void enterCondition(Sema &S, SourceLocation Tok)
void enterTypeCast(SourceLocation Tok, QualType CastType)
Handles all type casts, including C-style cast, C++ casts, etc.
void enterMemAccess(Sema &S, SourceLocation Tok, Expr *Base)
void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS)
void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc)
void enterReturn(Sema &S, SourceLocation Tok)
void enterDesignatedInitializer(SourceLocation Tok, QualType BaseType, const Designation &D)
Handles e.g. BaseType{ .D = Tok...
void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)
void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc)
PreferredTypeBuilder(bool Enabled)
Definition: Sema.h:272
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
Definition: Sema.h:307
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:137
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2566
A (possibly-)qualified type.
Definition: Type.h:941
The collection of all-type qualifiers we support.
Definition: Type.h:319
Represents a struct/union/class.
Definition: Decl.h:4145
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:5970
Represents the body of a requires-expression.
Definition: DeclCXX.h:2033
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:510
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:41
void incrementMSManglingNumber()
Definition: Scope.h:355
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
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
AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
Definition: Sema.h:1506
bool operator==(const AlignPackInfo &Info) const
Definition: Sema.h:1566
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:1538
unsigned getPackNumber() const
Definition: Sema.h:1556
bool IsXLStack() const
Definition: Sema.h:1564
bool IsPackSet() const
Definition: Sema.h:1558
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition: Sema.h:1512
bool IsAlignAttr() const
Definition: Sema.h:1552
bool IsPackAttr() const
Definition: Sema.h:1550
bool operator!=(const AlignPackInfo &Info) const
Definition: Sema.h:1572
AlignPackInfo(bool IsXL)
Definition: Sema.h:1516
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition: Sema.h:1523
Mode getAlignMode() const
Definition: Sema.h:1554
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:13212
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:13217
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7908
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7913
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition: Sema.h:7900
std::tuple< const Ts &... > Args
Definition: Sema.h:7897
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:8073
A RAII object to enter scope of a compound statement.
Definition: Sema.h:969
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:971
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:7352
bool isInvalid() const
Definition: Sema.h:7351
std::optional< bool > getKnownValue() const
Definition: Sema.h:7356
A RAII object to temporarily push a declaration context.
Definition: Sema.h:3023
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition: Sema.h:3033
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:10056
virtual SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for one of the candidate conversions.
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when there are multiple possible conversion functions.
ContextualImplicitConverter(bool Suppress=false, bool SuppressConversion=false)
Definition: Sema.h:10061
virtual bool match(QualType T)=0
Determine whether the specified type is a valid destination type for this conversion.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
For a defaulted function, the kind of defaulted function that it is.
Definition: Sema.h:5901
DefaultedComparisonKind asComparison() const
Definition: Sema.h:5933
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition: Sema.h:5910
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition: Sema.h:5938
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition: Sema.h:5913
CXXSpecialMemberKind asSpecialMember() const
Definition: Sema.h:5930
RAII class to control scope of DeferDiags.
Definition: Sema.h:9783
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition: Sema.h:9788
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition: Sema.h:1038
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:1057
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:1081
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:1050
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:1053
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
void popWithoutEmitting(DelayedDiagnosticsState state)
Leave a delayed-diagnostic state that was previously pushed.
Definition: Sema.h:1067
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:1073
A helper class for building up ExtParameterInfos.
Definition: Sema.h:12627
const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams)
Return a pointer (suitable for setting in an ExtProtoInfo) to the ExtParameterInfo array we've built ...
Definition: Sema.h:12646
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:12634
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:13569
FPOptionsOverride getOverrides()
Definition: Sema.h:13573
FullExprArg(Sema &actions)
Definition: Sema.h:7296
ExprResult release()
Definition: Sema.h:7298
Expr * get() const
Definition: Sema.h:7300
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:13585
SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) override
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
Definition: Sema.h:10120
virtual SemaDiagnosticBuilder diagnoseNotInt(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress, bool SuppressConversion)
Definition: Sema.h:10112
Helper class that collects exception specifications for implicitly-declared special member functions.
Definition: Sema.h:5004
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:5037
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:5030
const QualType * data() const
The set of exceptions in the exception specification.
Definition: Sema.h:5040
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
Definition: Sema.h:5046
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition: Sema.h:5053
static NameClassification DependentNonType()
Definition: Sema.h:3267
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:3277
ExprResult getExpression() const
Definition: Sema.h:3303
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:3243
static NameClassification Unknown()
Definition: Sema.h:3247
static NameClassification OverloadSet(ExprResult E)
Definition: Sema.h:3251
NameClassificationKind getKind() const
Definition: Sema.h:3301
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition: Sema.h:3295
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:3283
NamedDecl * getNonTypeDecl() const
Definition: Sema.h:3313
NameClassification(ParsedType Type)
Definition: Sema.h:3241
TemplateName getTemplateName() const
Definition: Sema.h:3318
ParsedType getType() const
Definition: Sema.h:3308
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:3325
static NameClassification NonType(NamedDecl *D)
Definition: Sema.h:3257
static NameClassification Concept(TemplateName Name)
Definition: Sema.h:3289
static NameClassification UndeclaredNonType()
Definition: Sema.h:3263
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:3271
static NameClassification Error()
Definition: Sema.h:3245
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
Definition: Sema.h:694
void operator()(sema::FunctionScopeInfo *Scope) const
Definition: Sema.cpp:2319
Whether and why a template name is required in this lookup.
Definition: Sema.h:11108
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition: Sema.h:11114
SourceLocation getTemplateKeywordLoc() const
Definition: Sema.h:11116
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition: Sema.h:11111
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:12099
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:12129
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:12107
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition: Sema.h:7925
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7930
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7927
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:8989
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:8967
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:8976
CXXMethodDecl * getMethod() const
Definition: Sema.h:8979
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:8980
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:13090
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:13118
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:13096
SourceLocation getLocation() const
Definition: Sema.h:11873
bool ContainsDecl(const NamedDecl *ND) const
Definition: Sema.h:11863
const DeclContext * getDeclContext() const
Definition: Sema.h:11869
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition: Sema.h:11847
const NamedDecl * getDecl() const
Definition: Sema.h:11861
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition: Sema.h:11846
const DeclContext * getLexicalDeclContext() const
Definition: Sema.h:11865
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:12138
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:12145
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:7249
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition: Sema.h:7253
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:493
FunctionDecl * FindUsualDeallocationFunction(SourceLocation StartLoc, bool CanProvideSize, bool Overaligned, DeclarationName Name)
const FieldDecl * getSelfAssignmentClassMemberCandidate(const ValueDecl *SelfAssigned)
Returns a field in a CXXRecordDecl that has the same name as the decl SelfAssigned when inside a CXXM...
Definition: SemaExpr.cpp:14386
void DeclareGlobalNewDelete()
DeclareGlobalNewDelete - Declare the global forms of operator new and delete.
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs)
Definition: SemaDecl.cpp:14182
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
bool CheckInstantiatedFunctionTemplateConstraints(SourceLocation PointOfInstantiation, FunctionDecl *Decl, ArrayRef< TemplateArgument > TemplateArgs, ConstraintSatisfaction &Satisfaction)
QualType CheckSizelessVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
Definition: SemaType.cpp:9046
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
Attr * getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition)
Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a containing class.
Definition: SemaDecl.cpp:10923
ExprResult PerformImplicitObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
QualType BuildParenType(QualType T)
Build a paren type including T.
Definition: SemaType.cpp:1662
SemaAMDGPU & AMDGPU()
Definition: Sema.h:1099
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6329
SmallVector< DeclaratorDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
Definition: Sema.h:3115
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
Definition: SemaDecl.cpp:6666
ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXTypeid - Parse typeid( something ).
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
Definition: Sema.h:13162
void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn)
#pragma optimize("[optimization-list]", on | off).
Definition: SemaAttr.cpp:1143
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, const TemplateArgumentListInfo &TemplateArgsInfo, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraint)
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, CXXScopeSpec &SS, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
ExprResult ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXUuidof - Parse __uuidof( something ).
bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result, ASTContext &Ctx, bool ErrorOnInvalidMessage)
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
ExprResult BuildOperatorCoawaitCall(SourceLocation Loc, Expr *E, UnresolvedLookupExpr *Lookup)
Build a call to 'operator co_await' if there is a suitable operator for the given expression.
ConceptDecl * ActOnStartConceptDefinition(Scope *S, MultiTemplateParamsArg TemplateParameterLists, const IdentifierInfo *Name, SourceLocation NameLoc)
std::optional< ExpressionEvaluationContextRecord::InitializationContext > InnermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:7818
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
Definition: SemaAttr.cpp:401
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition: Sema.h:13146
bool IsPointerInterconvertibleBaseOf(const TypeSourceInfo *Base, const TypeSourceInfo *Derived)
bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function, const Expr *ThisArg, ArrayRef< const Expr * > Args, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any non-ArgDependent DiagnoseIf...
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result)
Constructs and populates an OverloadedCandidateSet from the given function.
SmallVector< Scope *, 2 > CurrentSEHFinally
Stack of active SEH __finally scopes. Can be empty.
Definition: Sema.h:10680
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:12656
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition: Sema.h:763
void MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New, LookupResult &OldDecls)
MergeTypedefNameDecl - We just parsed a typedef 'New' which has the same name and scope as a previous...
Definition: SemaDecl.cpp:2468
TemplateDeductionResult DeduceTemplateArgumentsFromType(TemplateDecl *TD, QualType FromType, sema::TemplateDeductionInfo &Info)
Deduce the template arguments of the given template from FromType.
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
Definition: SemaType.cpp:8921
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
Definition: SemaDecl.cpp:6586
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
SmallVector< SmallVector< VTableUse, 16 >, 8 > SavedVTableUses
Definition: Sema.h:13532
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Definition: SemaDecl.cpp:9695
void PopParsingClass(ParsingClassState state)
Definition: Sema.h:6095
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=std::nullopt, DeclContext *LookupCtx=nullptr, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
Definition: SemaExpr.cpp:2446
void DiagnoseAbstractType(const CXXRecordDecl *RD)
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc, const LookupResult *R=nullptr, const UsingDecl *UD=nullptr)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
Definition: Sema.h:9799
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition: Sema.cpp:997
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
bool CheckExplicitObjectOverride(CXXMethodDecl *New, const CXXMethodDecl *Old)
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
Definition: Sema.h:6084
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
QualType CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
Definition: SemaType.cpp:2018
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs, SmallVectorImpl< const Attr * > &OutAttrs)
Process the attributes before creating an attributed statement.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
Unary Operators. 'Tok' is the token for the operator.
Definition: SemaExpr.cpp:15610
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7880
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
Definition: SemaDecl.cpp:1558
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
Definition: SemaExpr.cpp:3590
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
Definition: SemaExpr.cpp:15287
llvm::DenseSet< Module * > & getLookupModules()
Get the set of additional modules that should be checked during name lookup.
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
bool isAlwaysConstantEvaluatedContext() const
Definition: Sema.h:7788
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:871
bool isAttrContext() const
Definition: Sema.h:6476
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
Definition: SemaDecl.cpp:15060
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Definition: SemaStmt.cpp:4386
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, bool &RetainExpansion, std::optional< unsigned > &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Definition: SemaAttr.cpp:1052
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
NamedDecl * FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS)
If the given nested-name-specifier begins with a bare identifier (e.g., Base::), perform name lookup ...
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7873
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:2491
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition: Sema.h:5845
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:9011
@ LookupLabel
Label name lookup.
Definition: Sema.h:9020
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:9015
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition: Sema.h:9042
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition: Sema.h:9034
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:9056
@ LookupLocalFriendName
Look up a friend of a local class.
Definition: Sema.h:9050
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition: Sema.h:9052
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:9047
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:9027
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition: Sema.h:9054
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition: Sema.h:9038
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:9023
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition: Sema.h:9030
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:9018
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition: Sema.h:9058
@ LookupAnyName
Look up any declaration with any name.
Definition: Sema.h:9060
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
Definition: SemaExpr.cpp:412
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition: Sema.h:8955
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:4478
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
Definition: SemaDecl.cpp:6602
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
Definition: SemaType.cpp:6432
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
Definition: SemaAttr.cpp:1059
void ActOnPopScope(SourceLocation Loc, Scope *S)
Definition: SemaDecl.cpp:2179
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
Definition: SemaDecl.cpp:5295
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
Definition: SemaExpr.cpp:19400
void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
ActOnPragmaDetectMismatch - Call on well-formed #pragma detect_mismatch.
Definition: SemaAttr.cpp:527
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13002
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
Definition: SemaDecl.cpp:15741
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:5782
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS=nullptr)
VariadicCallType
Definition: Sema.h:2346
@ VariadicDoesNotApply
Definition: Sema.h:2351
@ VariadicFunction
Definition: Sema.h:2347
@ VariadicMethod
Definition: Sema.h:2349
@ VariadicConstructor
Definition: Sema.h:2350
@ VariadicBlock
Definition: Sema.h:2348
SemaM68k & M68k()
Definition: Sema.h:1144
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
Definition: SemaDecl.cpp:12828
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
void EvaluateImplicitExceptionSpec(SourceLocation Loc, FunctionDecl *FD)
Evaluate the implicit exception specification for a defaulted special member function.
bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount)
Checks that a call expression's argument count is at most the desired number.
void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
Definition: SemaModule.cpp:761
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, std::optional< unsigned > NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true)
ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E)
ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression found in an explicit(bool)...
bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum)
Returns true if the argument consists of one contiguous run of 1s with any number of 0s on either sid...
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
Definition: SemaExpr.cpp:6967
VarDecl * createLambdaInitCaptureVarDecl(SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc, IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx)
Create a dummy variable within the declcontext of the lambda's call operator, for name lookup purpose...
Definition: SemaLambda.cpp:850
bool DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc, RecordDecl *ClassDecl, const IdentifierInfo *Name)
bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum)
BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a constant expression representing ...
void ActOnFinishCXXNonNestedClass()
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body)
ActOnLambdaExpr - This is called when the body of a lambda expression was successfully completed.
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
DelayedDiagnosticsState ParsingDeclState
Definition: Sema.h:1033
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
Definition: SemaAccess.cpp:37
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
bool BuildTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc, bool AllowUnexpandedPack)
NonTrivialCUnionContext
Definition: Sema.h:3635
@ NTCUC_CopyInit
Definition: Sema.h:3645
@ NTCUC_AutoVar
Definition: Sema.h:3643
@ NTCUC_CompoundLiteral
Definition: Sema.h:3649
@ NTCUC_DefaultInitializedObject
Definition: Sema.h:3641
@ NTCUC_Assignment
Definition: Sema.h:3647
@ NTCUC_BlockCapture
Definition: Sema.h:3651
@ NTCUC_FunctionReturn
Definition: Sema.h:3639
@ NTCUC_LValueToRValueVolatile
Definition: Sema.h:3653
@ NTCUC_FunctionParam
Definition: Sema.h:3637
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
const Decl * PragmaAttributeCurrentTargetDecl
The declaration that is currently receiving an attribute from the #pragma attribute stack.
Definition: Sema.h:1771
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs)
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld, bool NewDeclIsDefn)
MergeFunctionDecl - We just parsed a function 'New' from declarator D which has the same name and sco...
Definition: SemaDecl.cpp:3536
void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, uint64_t MagicValue, QualType Type, bool LayoutCompatible, bool MustBeNull)
Register a magic integral constant to be used as a type tag.
bool hasReachableDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
MissingImportKind
Kinds of missing import.
Definition: Sema.h:9499
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E)
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc, Expr *DefaultArg)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
bool areVectorTypesSameSize(QualType srcType, QualType destType)
Definition: SemaExpr.cpp:7471
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, TemplateIdAnnotation *TemplateId, bool IsMemberSpecialization)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
Definition: SemaDecl.cpp:6079
bool hasVisibleDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
static std::enable_if_t< std::is_base_of_v< Attr, AttrInfo >, SourceLocation > getAttrLoc(const AttrInfo &AL)
A helper function to provide Attribute Location for the Attr types AND the ParsedAttr.
Definition: Sema.h:4423
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID)
Definition: SemaLookup.cpp:991
void DiagnoseStaticAssertDetails(const Expr *E)
Try to print more useful information about a failed static_assert with expression \E.
void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
The parser has processed a module import translated from a #include or similar preprocessing directiv...
Definition: SemaModule.cpp:722
bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum, unsigned Multiple)
BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr TheCall is a constant expr...
RetainOwnershipKind
Definition: Sema.h:4620
OpaquePtr< QualType > TypeTy
Definition: Sema.h:955
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
Definition: SemaDecl.cpp:18154
void DiagnoseAlwaysNonNullPointer(Expr *E, Expr::NullPointerConstantKind NullType, bool IsEqual, SourceRange Range)
Diagnose pointers that are always non-null.
bool IsStringInit(Expr *Init, const ArrayType *AT)
Definition: SemaInit.cpp:169
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
bool CheckCXXThisType(SourceLocation Loc, QualType Type)
Check whether the type of 'this' is valid in the current context.
void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body)
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class)
Perform qualified name lookup into all base classes of the given class.
void addImplicitTypedef(StringRef Name, QualType T)
Definition: Sema.cpp:307
void PrintContextStack()
Definition: Sema.h:13232
TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, const IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
Definition: SemaExpr.cpp:2332
bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc, StringRef Keyword)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
Definition: SemaType.cpp:2303
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:607
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e....
SemaOpenMP & OpenMP()
Definition: Sema.h:1179
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:8485
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:8490
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:8494
@ IER_Error
An error occurred.
Definition: Sema.h:8497
@ IER_Exists
The symbol exists.
Definition: Sema.h:8487
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:8954
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:15629
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, sema::LambdaScopeInfo *LSI)
Complete a lambda-expression having processed and attached the lambda body.
bool ActOnTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, MultiExprArg Args)
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition: Sema.h:5820
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:9325
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
Definition: SemaExpr.cpp:17246
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
Definition: SemaExpr.cpp:15635
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition: Sema.h:1025
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
Definition: SemaStmt.cpp:4375
void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
Definition: SemaAttr.cpp:1319
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
void CheckExplicitObjectMemberFunction(Declarator &D, DeclarationName Name, QualType R, bool IsLambda, DeclContext *DC=nullptr)
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
Definition: SemaDecl.cpp:6064
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6....
Definition: SemaExpr.cpp:1551
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition: Sema.h:14570
StmtResult ActOnForEachLValueExpr(Expr *E)
In an Objective C collection iteration statement: for (x in y) x can be an arbitrary l-value expressi...
Definition: SemaStmt.cpp:2223
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
Definition: Sema.h:918
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Definition: SemaDecl.cpp:18086
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
Definition: Sema.h:4336
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:3097
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:1478
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
std::optional< FunctionEffectMode > ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName)
Try to parse the conditional expression attached to an effect attribute (e.g.
Definition: SemaType.cpp:7496
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
Definition: SemaExpr.cpp:12022
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
void NoteAllFoundTemplates(TemplateName Name)
CXXRecordDecl * createLambdaClosureType(SourceRange IntroducerRange, TypeSourceInfo *Info, unsigned LambdaDependencyKind, LambdaCaptureDefault CaptureDefault)
Create a new lambda closure type.
Definition: SemaLambda.cpp:249
bool hasVisibleDefinition(const NamedDecl *D)
Definition: Sema.h:15015
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
Definition: Sema.h:6061
void emitAndClearUnusedLocalTypedefWarnings()
Definition: Sema.cpp:1088
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
Definition: SemaDecl.cpp:16280
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Definition: Sema.h:6042
static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember, bool IsVariadic, FormatStringInfo *FSI)
Given a FunctionDecl's FormatAttr, attempts to populate the FomatStringInfo parameter with the Format...
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
Definition: SemaStmt.cpp:89
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
Definition: SemaDecl.cpp:14939
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
VarDecl * buildCoroutinePromise(SourceLocation Loc)
unsigned CapturingFunctionScopes
Track the number of currently active capturing scopes.
Definition: Sema.h:907
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
Definition: SemaAttr.cpp:1094
ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
ActOnExpressionTrait - Parsed one of the unary type trait support pseudo-functions.
SemaCUDA & CUDA()
Definition: Sema.h:1124
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD)
Check a completed declaration of an implicit special member.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
Definition: SemaExpr.cpp:17181
bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A, bool SkipArgCountCheck=false)
Handles semantic checking for features that are common to all attributes, such as checking whether a ...
Definition: SemaAttr.cpp:1453
PragmaClangSectionAction
Definition: Sema.h:1468
@ PCSA_Set
Definition: Sema.h:1468
@ PCSA_Clear
Definition: Sema.h:1468
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, QualType DeclInitType, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
Definition: SemaExpr.cpp:20132
void InstantiateClassTemplateSpecializationMembers(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Instantiate the definitions of all of the members of the given class template specialization,...
void Initialize()
Perform initialization that occurs after the parser has been initialized but before it parses anythin...
Definition: Sema.cpp:313
ConditionKind
Definition: Sema.h:7371
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
@ Switch
An integral condition for a 'switch' statement.
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition: Sema.h:1002
void AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc)
Adds the 'optnone' attribute to the function declaration if there are no conflicts; Loc represents th...
Definition: SemaAttr.cpp:1192
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Definition: Sema.h:14974
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:14576
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
Definition: SemaExpr.cpp:2662
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
ModuleDeclKind
Definition: Sema.h:9630
@ PartitionImplementation
'module X:Y;'
@ Interface
'export module X;'
@ PartitionInterface
'export module X:Y;'
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, Decl *Param, ArrayRef< TemplateArgument > SugaredConverted, ArrayRef< TemplateArgument > CanonicalConverted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:900
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
void ActOnExitFunctionContext()
Definition: SemaDecl.cpp:1454
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
Definition: Sema.h:9272
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition: Sema.h:10139
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition: Sema.h:10142
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition: Sema.h:10148
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition: Sema.h:10146
bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum, unsigned ArgBits)
BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is a constant expression represen...
void RefersToMemberWithReducedAlignment(Expr *E, llvm::function_ref< void(Expr *, RecordDecl *, FieldDecl *, CharUnits)> Action)
This function calls Action when it determines that E designates a misaligned member due to the packed...
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType)
Definition: Sema.h:1424
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
AccessResult
Definition: Sema.h:1312
@ AR_dependent
Definition: Sema.h:1315
@ AR_accessible
Definition: Sema.h:1313
@ AR_inaccessible
Definition: Sema.h:1314
@ AR_delayed
Definition: Sema.h:1316
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:2296
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
CompleteTypeKind
Definition: Sema.h:14580
@ Normal
Apply the normal rules for complete types.
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA)
Check whether the given statement can have musttail applied to it, issuing a diagnostic and returning...
Definition: SemaStmt.cpp:636
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
Definition: SemaCast.cpp:3367
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, SourceLocation EllipsisLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
Preprocessor & getPreprocessor() const
Definition: Sema.h:559
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition: Sema.h:6454
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:2165
QualType GetSignedSizelessVectorType(QualType V)
Definition: SemaExpr.cpp:12580
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:13149
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
void ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, Scope *CurContext)
Once the Lambdas capture are known, we can start to create the closure, call operator method,...
FunctionTemplateDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition: SemaCast.cpp:395
void AddTemplateParametersToLambdaCallOperator(CXXMethodDecl *CallOperator, CXXRecordDecl *Class, TemplateParameterList *TemplateParams)
Definition: SemaLambda.cpp:998
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
Annotation attributes are the only attributes allowed after an access specifier.
FunctionDecl * getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2)
Returns the more constrained function according to the rules of partial ordering by constraints (C++ ...
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
llvm::SmallPtrSet< ConstantExpr *, 4 > FailedImmediateInvocations
Definition: Sema.h:7949
void deduceOpenCLAddressSpace(ValueDecl *decl)
Definition: SemaDecl.cpp:6817
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3530
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3127
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:1709
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
DefaultedComparisonKind getDefaultedComparisonKind(const FunctionDecl *FD)
Definition: Sema.h:7861
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:14577
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:1703
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, Scope *CurScope)
Definition: SemaStmt.cpp:3737
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
Definition: SemaAttr.cpp:1162
void referenceDLLExportedClassMethods()
StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit=false)
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
void MarkCaptureUsedInEnclosingContext(ValueDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
Definition: SemaExpr.cpp:18204
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member function overrides a virtual...
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates.
void setFunctionHasBranchIntoScope()
Definition: Sema.cpp:2345
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
ExprResult BuildCXXAssumeExpr(Expr *Assumption, const IdentifierInfo *AttrName, SourceRange Range)
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
Definition: Sema.h:4483
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition: SemaStmt.cpp:465
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid,...
Definition: Sema.h:1780
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
Definition: SemaDecl.cpp:6207
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
Definition: SemaExpr.cpp:16939
bool CheckOverridingFunctionAttributes(CXXMethodDecl *New, const CXXMethodDecl *Old)
void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind, StringRef Arg)
ActOnPragmaMSComment - Called on well formed #pragma comment(kind, "arg").
Definition: SemaAttr.cpp:519
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
virtual void anchor()
This virtual key function only exists to limit the emission of debug info describing the Sema class.
Definition: Sema.cpp:305
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Definition: SemaType.cpp:2374
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
Definition: SemaDecl.cpp:4797
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition: Sema.h:1698
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions,...
bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec)
tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
SimplerImplicitMoveMode
Definition: Sema.h:10835
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
Definition: SemaExpr.cpp:6608
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
Definition: SemaAttr.cpp:53
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
Definition: SemaDecl.cpp:12242
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
Definition: SemaDecl.cpp:16481
void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver)
If VD is set but not otherwise used, diagnose, for a parameter or a variable.
Definition: SemaDecl.cpp:2098
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext)
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation, bool ReportInvalid)
type checking for vector binary operators.
Definition: SemaExpr.cpp:10063
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:2443
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3478
@ Other
C++26 [dcl.fct.def.general]p1 function-body: ctor-initializer[opt] compound-statement function-try-bl...
@ Delete
deleted-function-body
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
bool RequireStructuralType(QualType T, SourceLocation Loc)
Require the given type to be a structural type, and diagnose if it is not.
ExprResult VerifyBitField(SourceLocation FieldLoc, const IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width,...
Definition: SemaDecl.cpp:18173
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
Definition: SemaStmt.cpp:52
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
Definition: SemaDecl.cpp:18269
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition: Sema.cpp:1172
ExprResult EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, const APValue &PreNarrowingValue)
EvaluateConvertedConstantExpression - Evaluate an Expression That is a converted constant expression ...
ConceptDecl * ActOnFinishConceptDefinition(Scope *S, ConceptDecl *C, Expr *ConstraintExpr, const ParsedAttributesView &Attrs)
FPOptionsOverride CurFPFeatureOverrides()
Definition: Sema.h:1710
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
Given a set of delayed diagnostics, re-emit them as if they had been delayed in the current context i...
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any.
SemaHexagon & Hexagon()
Definition: Sema.h:1134
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
Definition: SemaExpr.cpp:7445
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef)
Add an init-capture to a lambda scope.
Definition: SemaLambda.cpp:876
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt=std::nullopt)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
Definition: SemaExpr.cpp:19919
FieldDecl * BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture)
Build a FieldDecl suitable to hold the given capture.
concepts::Requirement * ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc)
void ActOnPragmaMSSeg(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, StringLiteral *SegmentName, llvm::StringRef PragmaName)
Called on well formed #pragma bss_seg/data_seg/const_seg/code_seg.
Definition: SemaAttr.cpp:748
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
void CheckThreadLocalForLargeAlignment(VarDecl *VD)
Definition: SemaDecl.cpp:14555
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
Definition: SemaExpr.cpp:15648
bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc)
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
bool IsInsideALocalClassWithinATemplateFunction()
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str)
Check Target Version attrs.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
void ActOnTranslationUnitScope(Scope *S)
Scope actions.
Definition: Sema.cpp:152
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
Definition: SemaDecl.cpp:1430
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
bool CheckConceptUseInDefinition(ConceptDecl *Concept, SourceLocation Loc)
SemaSYCL & SYCL()
Definition: Sema.h:1199
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType, SourceLocation Loc, const PartialDiagnostic &Diag)
Is the given member accessible for the purposes of deciding whether to define a special member functi...
sema::LambdaScopeInfo * RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator)
Definition: SemaDecl.cpp:15395
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16296
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:2718
StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:982
ExpressionEvaluationContextRecord & parentEvaluationContext()
Definition: Sema.h:6466
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:1567
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action, PragmaFloatControlKind Value)
ActOnPragmaFloatControl - Call on well-formed #pragma float_control.
Definition: SemaAttr.cpp:562
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
Definition: SemaExpr.cpp:784
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:11079
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
Definition: SemaDecl.cpp:3414
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition: Sema.h:11652
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition: Sema.h:11663
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:11655
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition: Sema.h:11659
bool SubstExprs(ArrayRef< Expr * > Exprs, bool IsCall, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< Expr * > &Outputs)
Substitute the given template arguments into a list of expressions, expanding pack expansions if requ...
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, const ParsedAttributesView &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
Definition: SemaDecl.cpp:640
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
void ActOnPragmaMSPointersToMembers(LangOptions::PragmaMSPointersToMembersKind Kind, SourceLocation PragmaLoc)
ActOnPragmaMSPointersToMembers - called on well formed #pragma pointers_to_members(representation met...
Definition: SemaAttr.cpp:616
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old)
[module.interface]p6: A redeclaration of an entity X is implicitly exported if X was introduced by an...
Definition: SemaDecl.cpp:1656
ExprResult CheckUnevaluatedOperand(Expr *E)
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
Definition: Sema.h:8949
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
SemaX86 & X86()
Definition: Sema.h:1219
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
Definition: SemaExpr.cpp:1036
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Look for instances where it is likely the comma operator is confused with another operator.
Definition: SemaExpr.cpp:13710
DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, ModuleDeclKind MDK, ModuleIdPath Path, ModuleIdPath Partition, ModuleImportState &ImportState)
The parser has processed a module-declaration that begins the definition of a module interface or imp...
Definition: SemaModule.cpp:259
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
llvm::DenseMap< NamedDecl *, NamedDecl * > VisibleNamespaceCache
Map from the most recent declaration of a namespace to the most recent visible declaration of that na...
Definition: Sema.h:13166
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
Definition: SemaExpr.cpp:4979
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
Definition: SemaDecl.cpp:20125
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
Definition: SemaExpr.cpp:1993
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
Definition: SemaExpr.cpp:7555
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
Definition: SemaExpr.cpp:13990
ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType)
Convert a parsed type into a parsed template argument.
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
Definition: SemaDecl.cpp:15047
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
Definition: SemaStmt.cpp:1058
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
ASTContext & Context
Definition: Sema.h:962
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
Definition: Sema.h:7775
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
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:626
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
Definition: SemaCast.cpp:2691
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
Definition: SemaExpr.cpp:9761
bool DiagIfReachable(SourceLocation Loc, ArrayRef< const Stmt * > Stmts, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the statements's reachability analysis.
Definition: SemaExpr.cpp:19930
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Definition: SemaDecl.cpp:14575
ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E)
bool ConstraintExpressionDependsOnEnclosingTemplate(const FunctionDecl *Friend, unsigned TemplateDepth, const Expr *Constraint)
bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc, TemplateDecl *PrimaryTemplate, unsigned NumExplicitArgs, ArrayRef< TemplateArgument > Args)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc)
ActOnCXXNullPtrLiteral - Parse 'nullptr'.
void ActOnCapturedRegionError()
Definition: SemaStmt.cpp:4567
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
IdentifierSourceLocations TypoCorrectionFailures
A cache containing identifiers for which typo correction failed and their locations,...
Definition: Sema.h:8960
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:7317
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
Definition: SemaType.cpp:2613
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:11419
void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc)
ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Definition: SemaAttr.cpp:836
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
Definition: SemaDecl.cpp:5771
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
Definition: Sema.h:13173
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:557
static FormatStringType GetFormatStringType(const FormatAttr *Format)
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
Definition: SemaExpr.cpp:7820
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
Definition: SemaDecl.cpp:20146
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod)
The parser has left a submodule.
Definition: SemaModule.cpp:785
void CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC, bool *ICContext=nullptr, bool IsListInit=false)
bool diagnoseConflictingFunctionEffect(const FunctionEffectsRef &FX, const FunctionEffectWithCondition &EC, SourceLocation NewAttrLoc)
Warn and return true if adding an effect to a set would create a conflict.
Definition: SemaDecl.cpp:20314
void * SkippedDefinitionContext
Definition: Sema.h:3960
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14939
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
Definition: SemaExpr.cpp:20905
void resetFPOptions(FPOptions FPO)
Definition: Sema.h:11057
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition: Sema.h:15032
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
bool currentModuleIsImplementation() const
Is the module scope we are an implementation unit?
Definition: Sema.h:9618
DeclResult ActOnModuleImport(SourceLocation StartLoc, SourceLocation ExportLoc, SourceLocation ImportLoc, ModuleIdPath Path, bool IsPartition=false)
The parser has processed a module import declaration.
Definition: SemaModule.cpp:574
static bool getPrintable(bool B)
Definition: Sema.h:14566
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Definition: SemaLookup.cpp:917
SemaObjC & ObjC()
Definition: Sema.h:1164
std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const
ExprResult SubstConstraintExprWithoutSatisfaction(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
void DiagPlaceholderFieldDeclDefinitions(RecordDecl *Record)
Emit diagnostic warnings for placeholder members.
Definition: SemaDecl.cpp:5300
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
Definition: SemaDecl.cpp:4907
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
Definition: SemaExpr.cpp:12841
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:2673
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
bool FunctionParamTypesAreEqual(ArrayRef< QualType > Old, ArrayRef< QualType > New, unsigned *ArgPos=nullptr, bool Reversed=false)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their param...
SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags
Diagnostics that are emitted only if we discover that the given function must be codegen'ed.
Definition: Sema.h:1094
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition: SemaDecl.cpp:72
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
AllowFoldKind
Definition: Sema.h:7263
@ AllowFold
Definition: Sema.h:7265
@ NoFold
Definition: Sema.h:7264
void InstantiateMemInitializers(CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, const MultiLevelTemplateArgumentList &TemplateArgs)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
Definition: SemaDecl.cpp:1496
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
void ActOnPragmaMSAllocText(SourceLocation PragmaLocation, StringRef Section, const SmallVector< std::tuple< IdentifierInfo *, SourceLocation > > &Functions)
Called on well-formed #pragma alloc_text().
Definition: SemaAttr.cpp:800
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition: Sema.h:2696
PragmaStack< bool > StrictGuardStackCheckStack
Definition: Sema.h:1706
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
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:3105
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
void CleanupVarDeclMarking()
Definition: SemaExpr.cpp:19413
bool CheckConstraintExpression(const Expr *CE, Token NextToken=Token(), bool *PossibleNonPrimary=nullptr, bool IsTrailingRequiresClause=false)
Check whether the given expression is a valid constraint expression.
Definition: SemaConcept.cpp:92
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
Definition: SemaExpr.cpp:752
bool isImmediateFunctionContext() const
Definition: Sema.h:7800
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
Definition: SemaDecl.cpp:2330
ASTContext & getASTContext() const
Definition: Sema.h:560
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition: SemaExpr.cpp:762
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, ArrayRef< QualType > Params)
DeclareGlobalAllocationFunction - Declares a single implicit global allocation function if it doesn't...
ExprResult VerifyIntegerConstantExpression(Expr *E, AllowFoldKind CanFold=NoFold)
Definition: Sema.h:7280
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
bool DiagnoseUnexpandedParameterPackInRequiresExpr(RequiresExpr *RE)
If the given requirees-expression contains an unexpanded reference to one of its own parameter packs,...
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
void CheckCoroutineWrapper(FunctionDecl *FD)
Definition: SemaDecl.cpp:15813
bool IsFloatingPointPromotion(QualType FromType, QualType ToType)
IsFloatingPointPromotion - Determines whether the conversion from FromType to ToType is a floating po...
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>.
Definition: Sema.h:6068
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
Definition: SemaExpr.cpp:15566
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:1087
void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules)
Definition: SemaAttr.cpp:919
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
bool tryCaptureVariable(ValueDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
Definition: SemaExpr.cpp:18695
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
Definition: SemaExpr.cpp:19661
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Check the redefinition in C++20 Modules.
Definition: SemaDecl.cpp:1712
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
Definition: SemaModule.cpp:844
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
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:6146
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:15084
NameClassificationKind
Describes the result of the name lookup and resolution performed by ClassifyName().
Definition: Sema.h:3190
@ NC_Unknown
This name is not a type or template in this context, but might be something else.
Definition: Sema.h:3193
@ NC_VarTemplate
The name was classified as a variable template name.
Definition: Sema.h:3220
@ NC_NonType
The name was classified as a specific non-type, non-template declaration.
Definition: Sema.h:3203
@ NC_TypeTemplate
The name was classified as a template whose specializations are types.
Definition: Sema.h:3218
@ NC_Error
Classification failed; an error has been produced.
Definition: Sema.h:3195
@ NC_FunctionTemplate
The name was classified as a function template name.
Definition: Sema.h:3222
@ NC_DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition: Sema.h:3211
@ NC_UndeclaredNonType
The name was classified as an ADL-only function name.
Definition: Sema.h:3207
@ NC_UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition: Sema.h:3224
@ NC_Keyword
The name has been typo-corrected to a keyword.
Definition: Sema.h:3197
@ NC_Type
The name was classified as a type.
Definition: Sema.h:3199
@ NC_OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition: Sema.h:3216
@ NC_Concept
The name was classified as a concept name.
Definition: Sema.h:3226
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
void PopExpressionEvaluationContext()
Definition: SemaExpr.cpp:17602
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
Definition: SemaExpr.cpp:9504
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N)
PragmaStack< StringLiteral * > ConstSegStack
Definition: Sema.h:1702
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: SemaStmt.cpp:4310
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:702
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
Definition: SemaAttr.cpp:231
bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction, const FunctionDecl *NewFunction, unsigned *ArgPos=nullptr, bool Reversed=false)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
Definition: SemaExpr.cpp:867
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Definition: SemaExpr.cpp:3478
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg, bool IsDeduced)
Check a template argument against its corresponding template template parameter.
ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, SourceLocation TildeLoc, UnqualifiedId &SecondTypeName)
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S)
isMicrosoftMissingTypename - In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal...
Definition: SemaDecl.cpp:664
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition: Sema.h:2180
ParsingClassState PushParsingClass()
Definition: Sema.h:6091
ForRangeStatus
Definition: Sema.h:10502
@ FRS_Success
Definition: Sema.h:10503
@ FRS_DiagnosticIssued
Definition: Sema.h:10505
@ FRS_NoViableFunction
Definition: Sema.h:10504
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
Definition: SemaExpr.cpp:6131
void ActOnPragmaCXLimitedRange(SourceLocation Loc, LangOptions::ComplexRangeKind Range)
ActOnPragmaCXLimitedRange - Called on well formed #pragma STDC CX_LIMITED_RANGE.
Definition: SemaAttr.cpp:1350
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
Definition: SemaExpr.cpp:3087
TemplateParameterList * GetTemplateParameterList(TemplateDecl *TD)
Returns the template parameter list with all default template argument information.
void ActOnPragmaFPExceptions(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called on well formed '#pragma clang fp' that has option 'exceptions'.
Definition: SemaAttr.cpp:1358
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord)
Add gsl::Pointer attribute to std::container::iterator.
Definition: SemaAttr.cpp:111
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
Definition: SemaExpr.cpp:6981
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:15616
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:605
TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, std::optional< unsigned > &NumExpansions) const
Returns the pattern of the pack expansion for a template argument.
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition: Sema.h:9008
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, SourceRange PlacementRange, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose=true)
Checks access to an overloaded operator new or delete.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
unsigned TyposCorrected
The number of typos corrected by CorrectTypo.
Definition: Sema.h:8952
bool BuiltinVectorToScalarMath(CallExpr *TheCall)
bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn)
We've just determined that Old and New both appear to be definitions of the same variable.
Definition: SemaDecl.cpp:4754
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition: Sema.h:5616
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
@ None
This is not a defaultable comparison operator.
@ Equal
This is an operator== that should be implemented as a series of subobject comparisons.
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
Definition: SemaExpr.cpp:7836
ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, ParsedType LhsTy, Expr *DimExpr, SourceLocation RParen)
ActOnArrayTypeTrait - Parsed one of the binary type trait support pseudo-functions.
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized.
Definition: Sema.h:8694
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType, bool &IncompatibleObjC)
IsPointerConversion - Determines whether the conversion of the expression From, which has the (possib...
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
Definition: SemaType.cpp:9274
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
AllowedExplicit
Definition: Sema.h:9859
@ Conversions
Allow explicit conversion functions but not explicit constructors.
@ All
Allow both explicit conversion functions and explicit constructors.
void ActOnFinishRequiresExpr()
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
Definition: SemaType.cpp:9402
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
Definition: Sema.h:890
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition: Sema.h:6079
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Definition: SemaExpr.cpp:12887
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
void * SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS)
Given a C++ nested-name-specifier, produce an annotation value that the parser can use later to recon...
ValueDecl * tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl, CXXScopeSpec &SS, ParsedType TemplateTypeTy, IdentifierInfo *MemberOrBase)
void ProcessPragmaWeak(Scope *S, Decl *D)
void DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range, DeclarationName Name, OverloadCandidateSet &CandidateSet, FunctionDecl *Fn, MultiExprArg Args, bool IsMember=false)
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
Definition: SemaDecl.cpp:20292
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation, bool IsUsingIfExists)
Builds a using declaration.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition: Sema.h:868
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
bool IsComplexPromotion(QualType FromType, QualType ToType)
Determine if a conversion is a complex promotion.
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union.
Definition: SemaDecl.cpp:5453
void ActOnPragmaFPEvalMethod(SourceLocation Loc, LangOptions::FPEvalMethodKind Value)
Definition: SemaAttr.cpp:535
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
Definition: Sema.h:3128
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Definition: Sema.cpp:1572
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
Definition: SemaDecl.cpp:16832
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition: Sema.cpp:2434
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition: Sema.h:3020
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
Definition: SemaDecl.cpp:8960
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
Definition: SemaExpr.cpp:2198
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
void handleLambdaNumbering(CXXRecordDecl *Class, CXXMethodDecl *Method, std::optional< CXXRecordDecl::LambdaNumbering > NumberingOverride=std::nullopt)
Number lambda for linkage purposes if necessary.
Definition: SemaLambda.cpp:456
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer * > Initializers=std::nullopt)
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
Definition: Sema.h:11069
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *AArg, SourceLocation Loc, bool IsDeduced)
void setFunctionHasIndirectGoto()
Definition: Sema.cpp:2355
void HandleDependentAccessCheck(const DependentDiagnostic &DD, const MultiLevelTemplateArgumentList &TemplateArgs)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc)
Build a bit-precise integer type.
Definition: SemaType.cpp:1927
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition: Sema.h:11794
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:11812
@ TPL_TemplateTemplateArgumentMatch
We are matching the template parameter lists of a template template argument against the template par...
Definition: Sema.h:11823
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:11802
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition: Sema.h:11833
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:15904
NamedDecl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg, bool HasTypeConstraint)
ActOnTypeParameter - Called when a C++ template type parameter (e.g., "typename T") has been parsed.
SmallVectorImpl< Decl * > & WeakTopLevelDecls()
WeakTopLevelDeclDecls - access to #pragma weak-generated Decls.
Definition: Sema.h:4474
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
Definition: Sema.cpp:1586
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9643
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
Definition: SemaExpr.cpp:1665
ExprResult BuildCaptureInit(const sema::Capture &Capture, SourceLocation ImplicitCaptureLoc, bool IsOpenMPMapping=false)
Initialize the given capture with a suitable expression.
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
Definition: Sema.h:7987
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
Definition: SemaAttr.cpp:286
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr * > Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
AssumedTemplateKind
Definition: Sema.h:11129
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Target, bool SkipTargetFirstParameter, SourceLocation TargetLoc, const FunctionProtoType *Source, bool SkipSourceFirstParameter, SourceLocation SourceLoc)
CheckParamExceptionSpec - Check if the parameter and return types of the two functions have equivalen...
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, OverloadCandidateParamOrder PO={})
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
Definition: SemaAttr.cpp:694
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
Definition: SemaDecl.cpp:4344
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Definition: SemaExpr.cpp:1963
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
Definition: SemaType.cpp:1568
std::optional< unsigned > getNumArgumentsInExpansionFromUnexpanded(llvm::ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs)
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfMove - Emits a warning if a value is moved to itself.
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
bool isSameOrCompatibleFunctionType(QualType Param, QualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment,...
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Definition: SemaStmt.cpp:1246
AtomicArgumentOrder
Definition: Sema.h:2288
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:2184
ExprResult ActOnNameClassifiedAsNonType(Scope *S, const CXXScopeSpec &SS, NamedDecl *Found, SourceLocation NameLoc, const Token &NextToken)
Act on the result of classifying a name as a specific non-type declaration.
Definition: SemaDecl.cpp:1246
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
Definition: SemaCast.cpp:383
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
Definition: Sema.cpp:1592
SourceRange getExprRange(Expr *E) const
Definition: SemaExpr.cpp:507
bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS)
The parser has parsed a global nested-name-specifier '::'.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
NamedReturnInfo getNamedReturnInfo(Expr *&E, SimplerImplicitMoveMode Mode=SimplerImplicitMoveMode::Normal)
Determine whether the given expression might be move-eligible or copy-elidable in either a (co_)retur...
Definition: SemaStmt.cpp:3238
void setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called to set exception behavior for floating point operations.
Definition: SemaAttr.cpp:1326
bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
The parser has parsed a nested-name-specifier 'identifier::'.
void PrintPragmaAttributeInstantiationPoint()
Definition: SemaAttr.cpp:1124
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:2510
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
Definition: Sema.h:11062
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
Definition: SemaAttr.cpp:167
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Definition: Sema.h:703
bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
LazyVector< const DeclaratorDecl *, ExternalSemaSource, &ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2 > UnusedFileScopedDeclsType
Definition: Sema.h:3101
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:7833
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:14573
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition: Sema.h:4175
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
Definition: SemaDecl.cpp:16731
bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id, bool IsUDSuffix)
bool FriendConstraintsDependOnEnclosingTemplate(const FunctionDecl *FD)
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
Definition: SemaStmt.cpp:225
FPOptions & getCurFPFeatures()
Definition: Sema.h:555
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition: Sema.h:7943
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:1008
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
Definition: SemaExpr.cpp:20163
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:84
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:2202
StmtResult ActOnCoreturnStmt(Scope *S, SourceLocation KwLoc, Expr *E)
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
void PopCompoundScope()
Definition: Sema.cpp:2334
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14983
bool EnsureTemplateArgumentListConstraints(TemplateDecl *Template, const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange)
Ensure that the given template arguments satisfy the constraints associated with the given template,...
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
Definition: SemaDecl.cpp:19601
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:13895
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition: Sema.h:13915
@ UPPC_RequiresClause
Definition: Sema.h:13966
@ UPPC_UsingDeclaration
A using declaration.
Definition: Sema.h:13921
@ UPPC_IfExists
Microsoft __if_exists.
Definition: Sema.h:13948
@ UPPC_Requirement
Definition: Sema.h:13963
@ UPPC_ExceptionType
The type of an exception.
Definition: Sema.h:13939
@ UPPC_EnumeratorValue
The enumerator value.
Definition: Sema.h:13918
@ UPPC_Lambda
Lambda expression.
Definition: Sema.h:13954
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition: Sema.h:13951
@ UPPC_PartialSpecialization
Partial specialization.
Definition: Sema.h:13945
@ UPPC_Initializer
An initializer.
Definition: Sema.h:13930
@ UPPC_BaseType
The base type of a class type.
Definition: Sema.h:13900
@ UPPC_FriendDeclaration
A friend declaration.
Definition: Sema.h:13924
@ UPPC_DefaultArgument
A default argument.
Definition: Sema.h:13933
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition: Sema.h:13903
@ UPPC_Expression
An arbitrary expression.
Definition: Sema.h:13897
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition: Sema.h:13942
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition: Sema.h:13927
@ UPPC_DataMemberType
The type of a data member.
Definition: Sema.h:13906
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition: Sema.h:13912
@ UPPC_Block
Block expression.
Definition: Sema.h:13957
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition: Sema.h:13909
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition: Sema.h:13936
@ UPPC_TypeConstraint
A type constraint.
Definition: Sema.h:13960
api_notes::APINotesManager APINotes
Definition: Sema.h:966
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
bool IsLayoutCompatible(QualType T1, QualType T2) const
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl, bool IsNested)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
llvm::DenseMap< Decl *, SmallVector< PartialDiagnosticAt, 1 > > SuppressedDiagnosticsMap
For each declaration that involved template argument deduction, the set of diagnostics that were supp...
Definition: Sema.h:12161
void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool Mutable)
Endow the lambda scope info with the relevant properties.
Definition: SemaLambda.cpp:523
const LangOptions & getLangOpts() const
Definition: Sema.h:553
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl, bool SupportedForCompatibility=false)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
bool RequireCompleteExprType(Expr *E, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
Definition: SemaType.cpp:8896
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
void DiagnoseInvalidJumps(Stmt *Body)
bool CaptureHasSideEffects(const sema::Capture &From)
Does copying/destroying the captured variable have side effects?
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
StmtResult ActOnFinishFullStmt(Stmt *Stmt)
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
Definition: Sema.h:5406
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:1720
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12049
SourceLocation CurInitSegLoc
Definition: Sema.h:1742
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
Definition: SemaExpr.cpp:7219
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Definition: SemaExpr.cpp:12816
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition: SemaAttr.cpp:623
SemaCodeCompletion & CodeCompletion()
Definition: Sema.h:1119
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition: Sema.h:3122
void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, Declarator &ParamInfo, const DeclSpec &DS)
ActOnStartOfLambdaDefinition - This is called just before we start parsing the body of a lambda; it a...
SemaOpenACC & OpenACC()
Definition: Sema.h:1169
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition: Sema.h:14347
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
Definition: SemaDecl.cpp:1387
ReuseLambdaContextDecl_t
Definition: Sema.h:6551
@ ReuseLambdaContextDecl
Definition: Sema.h:6551
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, QualType &T, SourceLocation Loc, unsigned FailedFoldDiagID)
Attempt to fold a variable-sized type to a constant-sized type, returning true if we were successful.
Definition: SemaDecl.cpp:6562
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr, ExceptionSpecificationType &EST)
Check the given noexcept-specifier, convert its expression, and compute the appropriate ExceptionSpec...
void MarkExpressionAsImmediateEscalating(Expr *E)
Definition: SemaExpr.cpp:17277
void NoteTemplateLocation(const NamedDecl &Decl, std::optional< SourceRange > ParamRange={})
NamedDecl * findLocallyScopedExternCDecl(DeclarationName Name)
Look for a locally scoped extern "C" declaration by the given name.
Definition: SemaDecl.cpp:6596
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
Definition: SemaDecl.cpp:1597
void ActOnLambdaClosureParameters(Scope *LambdaScope, MutableArrayRef< DeclaratorChunk::ParamInfo > ParamInfo)
void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange)
CheckCastAlign - Implements -Wcast-align, which warns when a pointer cast increases the alignment req...
ASTConsumer & getASTConsumer() const
Definition: Sema.h:561
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
Definition: SemaExpr.cpp:2246
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
bool isUnexpandedParameterPackPermitted()
Determine whether an unexpanded parameter pack might be permitted in this location.
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules,...
void diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD, SourceLocation Loc)
Produce diagnostics if FD is an aligned allocation or deallocation function that is unavailable.
SemaBPF & BPF()
Definition: Sema.h:1114
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E)
Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
Definition: SemaExpr.cpp:19802
void * OpaqueParser
Definition: Sema.h:1006
Preprocessor & PP
Definition: Sema.h:961
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:10854
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
Definition: SemaExpr.cpp:5649
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
Definition: SemaExpr.cpp:6407
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9568
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc, const Expr *Op, const CXXMethodDecl *MD)
Definition: SemaExpr.cpp:13962
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
Definition: Sema.h:1789
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
Definition: SemaExpr.cpp:16570
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
Definition: SemaExpr.cpp:4694
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition: Sema.h:999
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:1767
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
Definition: SemaDecl.cpp:8181
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:1984
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy)
Are the two types matrix types and do they have the same dimensions i.e.
Definition: SemaExpr.cpp:7460
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
LazyVector< VarDecl *, ExternalSemaSource, &ExternalSemaSource::ReadTentativeDefinitions, 2, 2 > TentativeDefinitionsType
Definition: Sema.h:3109
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:6044
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
SemaMSP430 & MSP430()
Definition: Sema.h:1154
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< const Expr * > ConstraintExprs, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
Definition: Sema.h:14375
const LangOptions & LangOpts
Definition: Sema.h:960
void InstantiateClassMembers(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiates the definitions of all of the member of the given class, which is an instantiation of a ...
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, AllocationFunctionScope NewScope, AllocationFunctionScope DeleteScope, QualType AllocType, bool IsArray, bool &PassAlignment, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete, bool Diagnose=true)
Finds the overloads of operator new and delete that are appropriate for the allocation.
ExprResult PerformQualificationConversion(Expr *E, QualType Ty, ExprValueKind VK=VK_PRValue, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
Definition: SemaInit.cpp:7503
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From,...
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
Definition: SemaExpr.cpp:15718
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:896
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:8473
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2409
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
Definition: SemaExpr.cpp:6658
static const uint64_t MaximumAlignment
Definition: Sema.h:891
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition: Sema.h:8697
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr, bool PartialOrderingTTP=false)
Check that the given template arguments can be provided to the given template, converting the argumen...
ExprResult CheckConditionVariable(VarDecl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
Check the use of the given variable as a C++ condition in an if, while, do-while, or switch statement...
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
Definition: SemaExpr.cpp:17298
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
Definition: SemaInit.cpp:7485
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition: SemaStmt.cpp:396
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition: Sema.h:14996
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
Definition: SemaDecl.cpp:15235
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:6046
SemaHLSL & HLSL()
Definition: Sema.h:1129
VarTemplateSpecializationDecl * CompleteVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiates a variable template specialization by completing it with appropriate type information an...
llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > LateParsedTemplateMapT
Definition: Sema.h:11078
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:894
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:9007
bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange, const sema::Capture &From)
Diagnose if an explicit lambda capture is unused.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind)
Definition: Sema.cpp:1107
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Definition: SemaDecl.cpp:1829
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
Definition: SemaDecl.cpp:11822
CXXRecordDecl * getStdBadAlloc() const
ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation LParenOrBraceLoc, MultiExprArg Exprs, SourceLocation RParenOrBraceLoc, bool ListInitialization)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
Definition: SemaDecl.cpp:18364
ExpressionEvaluationContextRecord & currentEvaluationContext()
Definition: Sema.h:6460
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
Definition: SemaExpr.cpp:17262
void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst)
Update instantiation attributes after template was late parsed.
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
PragmaClangSection PragmaClangRelroSection
Definition: Sema.h:1479
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
SemaMIPS & MIPS()
Definition: Sema.h:1149
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition: Sema.cpp:118
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
SemaRISCV & RISCV()
Definition: Sema.h:1194
bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass, QualType BaseType)
Checks access to Target from the given class.
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition: Sema.h:1456
llvm::DenseMap< CXXRecordDecl *, bool > VTablesUsed
The set of classes whose vtables have been used within this translation unit, and a bit that will be ...
Definition: Sema.h:5412
bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD, SourceLocation ReturnLoc, Expr *RetExpr, const AutoType *AT)
Deduce the return type for a function from a returned expression, per C++1y [dcl.spec....
Definition: SemaStmt.cpp:3626
QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions, IdentifierInfo *Id, bool DirectInit, Expr *&Init)
Definition: SemaLambda.cpp:784
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
Definition: SemaExpr.cpp:205
void CheckCXXDefaultArguments(FunctionDecl *FD)
Helpers for dealing with blocks and functions.
bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes, bool OrNull)
Check if applying the specified attribute variant from the "counted by" family of attributes to Field...
ComparisonCategoryUsage
Definition: Sema.h:4801
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition: Sema.h:13530
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition: Sema.h:6039
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
Definition: SemaExpr.cpp:73
ConditionResult ActOnConditionVariable(Decl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
Definition: SemaExpr.cpp:19812
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, SourceRange R)
Checks that a type is suitable as the allocated type in a new-expression.
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Diagnose cases where a scalar was implicitly converted to a vector and diagnose the underlying types.
Definition: SemaExpr.cpp:9785
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
static StringRef getPrintable(StringRef S)
Definition: Sema.h:14568
SemaSwift & Swift()
Definition: Sema.h:1204
NamedDecl * BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation NameLoc, TypeSourceInfo *EnumType, EnumDecl *ED)
void AddImplicitMSFunctionNoBuiltinAttr(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based n...
Definition: SemaAttr.cpp:1206
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
Definition: SemaStmt.cpp:3619
PragmaStack< AlignPackInfo > AlignPackStack
Definition: Sema.h:1691
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used,...
Definition: SemaDecl.cpp:15699
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:6138
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:6487
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:13198
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:6072
StmtResult ActOnExprStmtError()
Definition: SemaStmt.cpp:69
AcceptableKind
Definition: Sema.h:9003
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:1701
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
const VarDecl * getCopyElisionCandidate(NamedReturnInfo &Info, QualType ReturnType)
Updates given NamedReturnInfo's move-eligible and copy-elidable statuses, considering the function re...
Definition: SemaStmt.cpp:3316
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed.
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
void completeExprArrayBound(Expr *E)
Definition: SemaType.cpp:8824
DeclContext * getCurLexicalContext() const
Definition: Sema.h:767
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition: Sema.h:1017
ExprResult BuildConvertedConstantExpression(Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest=nullptr)
llvm::StringMap< std::tuple< StringRef, SourceLocation > > FunctionToSectionMap
Sections used with #pragma alloc_text.
Definition: Sema.h:1745
bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc, SourceLocation ColonColonLoc, CXXScopeSpec &SS)
The parser has parsed a '__super' nested-name-specifier.
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
Definition: Sema.cpp:1579
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
Definition: SemaType.cpp:9370
bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L, CXXScopeSpec *SS=nullptr)
Require that the EnumDecl is completed with its enumerators defined or instantiated.
ExprResult ActOnRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation ClosingBraceLoc)
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool UseMemberUsingDeclRules)
Determine whether the given New declaration is an overload of the declarations in Old.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, Expr *ParamExpr)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
bool hasExplicitCallingConv(QualType T)
Definition: SemaType.cpp:7991
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, CorrectionCandidateCallback *CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
Definition: SemaDecl.cpp:859
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
Definition: SemaStmt.cpp:74
OpenCLOptions OpenCLFeatures
Definition: Sema.h:957
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
Definition: Sema.h:13534
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Definition: SemaExpr.cpp:936
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
Definition: SemaDecl.cpp:16807
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
Definition: Sema.h:1792
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
void ExitDeclaratorContext(Scope *S)
Definition: SemaDecl.cpp:1374
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
Definition: SemaExpr.cpp:15529
bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI)
Diagnose shadowing for variables shadowed in the lambda record LambdaRD when these variables are capt...
Definition: SemaDecl.cpp:8320
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition: Sema.cpp:785
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
Definition: SemaStmt.cpp:4410
bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D)
Determine if we're in a case where we need to (incorrectly) eagerly parse an exception specification ...
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
bool buildCoroutineParameterMoves(SourceLocation Loc)
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMemberKind CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
Definition: SemaCast.cpp:3341
DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc)
The parser has processed a global-module-fragment declaration that begins the definition of the globa...
Definition: SemaModule.cpp:163
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted)
void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams)
Definition: SemaStmt.cpp:4478
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Definition: SemaDecl.cpp:12429
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition: Sema.h:14562
void AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
ProcessingContextState ParsingClassState
Definition: Sema.h:6090
void DiagnoseMisalignedMembers()
Diagnoses the current set of gathered accesses.
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a Microsoft __uuidof expression with a type operand.
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val)
Definition: SemaDecl.cpp:19627
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:993
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
void PushCompoundScope(bool IsStmtExpr)
Definition: Sema.cpp:2329
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Definition: SemaDecl.cpp:14805
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Definition: SemaDecl.cpp:2286
FunctionTemplateDecl * getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1, QualType RawObj1Ty={}, QualType RawObj2Ty={}, bool Reversed=false)
Returns the more specialized function template according to the rules of function template partial or...
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
Definition: SemaDecl.cpp:2261
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
bool isDeclaratorFunctionLike(Declarator &D)
Determine whether.
Definition: Sema.cpp:2762
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
Definition: SemaExpr.cpp:3629
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
Definition: SemaType.cpp:1844
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it's plausible that E was intended to be a template-name.
Definition: Sema.h:3402
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:2266
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Definition: SemaDecl.cpp:20180
std::optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
Definition: SemaExpr.cpp:10322
bool CheckNontrivialField(FieldDecl *FD)
Definition: SemaDecl.cpp:18562
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
Helper for delayed processing TransparentUnion or BPFPreserveAccessIndexAttr attribute.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
Definition: SemaExpr.cpp:9556
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
Definition: SemaStmt.cpp:1664
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition: Sema.h:6484
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
Definition: SemaAttr.cpp:1216
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID, const FunctionProtoType *Superset, bool SkipSupersetFirstParameter, SourceLocation SuperLoc, const FunctionProtoType *Subset, bool SkipSubsetFirstParameter, SourceLocation SubLoc)
CheckExceptionSpecSubset - Check whether the second function type's exception specification is a subs...
CXXRecordDecl * getCurrentInstantiationOf(NestedNameSpecifier *NNS)
If the given nested name specifier refers to the current instantiation, return the declaration that c...
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
Definition: SemaDecl.cpp:18044
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
TemplateDeductionResult SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate, TemplateArgumentListInfo &ExplicitTemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< QualType > &ParamTypes, QualType *FunctionType, sema::TemplateDeductionInfo &Info)
Substitute the explicitly-provided template arguments into the given function template according to C...
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
Check the validity of a C++ base class specifier.
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:2148
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Member, Decl *ObjCImpDecl)
The main callback when the parser finds something like expression .
ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, bool IsDefiniteInstance, const Scope *S)
Builds an implicit member access expression.
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
Definition: Sema.h:12668
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
Definition: SemaInit.cpp:9726
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx=UINT_MAX, bool StrictlyUnsigned=false)
If Expr is a valid integer constant, get the value of the integer expression and return success or fa...
Definition: Sema.h:4434
bool SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams, ExtParameterInfoBuilder &ParamInfos)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, unsigned DiagID)
Emit DiagID if statement located on StmtLoc has a suspicious null statement as a Body,...
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
Definition: SemaDecl.cpp:8835
void LateTemplateParserCleanupCB(void *P)
Definition: Sema.h:1003
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
Definition: Sema.h:5402
void MarkThisReferenced(CXXThisExpr *This)
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, ArrayRef< const Expr * > AC1, NamedDecl *D2, ArrayRef< const Expr * > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
std::optional< unsigned > getFullyPackExpandedSize(TemplateArgument Arg)
Given a template argument that contains an unexpanded parameter pack, but which has already been subs...
void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody)
Warn if a for/while loop statement S, which is followed by PossibleBody, has a suspicious null statem...
ExprResult DefaultLvalueConversion(Expr *E)
Definition: SemaExpr.cpp:640
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:13206
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model)
bool CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
Definition: SemaExpr.cpp:3175
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, unsigned ByteNo) const
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
Definition: Sema.h:14990
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition: Sema.h:7804
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:1741
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Definition: SemaDecl.cpp:20210
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition: Sema.h:9613
bool CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
AddOverriddenMethods - See if a method overrides any in the base classes, and if so,...
Definition: SemaDecl.cpp:8855
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
Definition: SemaExpr.cpp:7206
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:2115
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
ControllingExprOrType is either an opaque pointer coming out of a ParsedType or an Expr *.
Definition: SemaExpr.cpp:1633
void DiagPlaceholderVariableDefinition(SourceLocation Loc)
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
Definition: SemaExpr.cpp:16090
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
Definition: SemaExpr.cpp:7596
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
Definition: SemaDecl.cpp:15341
bool hasReachableDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a reachable default argument.
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition: Sema.cpp:2365
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
Definition: Sema.h:6512
IfExistsResult CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo)
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res)
std::unique_ptr< RecordDeclSetTy > PureVirtualClassDiagSet
PureVirtualClassDiagSet - a set of class declarations which we have emitted a list of pure virtual fu...
Definition: Sema.h:6053
void CheckTCBEnforcement(const SourceLocation CallExprLoc, const NamedDecl *Callee)
Enforce the bounds of a TCB CheckTCBEnforcement - Enforces that every function in a named TCB only di...
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
Definition: SemaDecl.cpp:18035
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
Definition: SemaDecl.cpp:15265
FunctionDecl * resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:1097
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, bool Diagnose=true, bool WantSize=false, bool WantAligned=false)
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
Definition: SemaInit.cpp:7466
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount)
Checks that a call expression's argument count is at least the desired number.
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
Definition: Sema.h:9090
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
Definition: SemaExpr.cpp:20626
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc)
ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const,addrspace}_cast's.
Definition: SemaCast.cpp:274
DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc, SourceLocation PrivateLoc)
The parser has processed a private-module-fragment declaration that begins the definition of the priv...
Definition: SemaModule.cpp:512
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
Definition: SemaDecl.cpp:14845
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition: Sema.h:12162
@ VAK_Invalid
Definition: Sema.h:7559
@ VAK_Valid
Definition: Sema.h:7555
@ VAK_ValidInCXX11
Definition: Sema.h:7556
@ VAK_MSVCUndefined
Definition: Sema.h:7558
@ VAK_Undefined
Definition: Sema.h:7557
SemaOpenCL & OpenCL()
Definition: Sema.h:1174
void ActOnPragmaMSFunction(SourceLocation Loc, const llvm::SmallVectorImpl< StringRef > &NoBuiltins)
Call on well formed #pragma function.
Definition: SemaAttr.cpp:1152
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
Definition: SemaDecl.cpp:5776
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:13543
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams, SourceLocation EllipsisLoc)
Handle a friend type declaration.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9604
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
Definition: SemaAttr.cpp:515
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
Definition: SemaExpr.cpp:16452
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition: Sema.h:1867
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
Definition: SemaDecl.cpp:15102
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
Definition: SemaType.cpp:3750
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression, SourceLocation EllipsisLoc, SourceLocation LSquareLoc, Expr *IndexExpr, SourceLocation RSquareLoc)
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, StringLiteral *SegmentName)
Called on well-formed #pragma init_seg().
Definition: SemaAttr.cpp:791
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
static SourceRange getPrintable(TypeLoc TL)
Definition: Sema.h:14578
bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
Definition: SemaExpr.cpp:7842
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, ParsedType ObjectType)
TrivialABIHandling
Definition: Sema.h:5885
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:5887
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition: Sema.h:5890
FormatArgumentPassingKind
Definition: Sema.h:2190
@ FAPK_Fixed
Definition: Sema.h:2191
@ FAPK_Variadic
Definition: Sema.h:2192
@ FAPK_VAList
Definition: Sema.h:2193
void FillInlineAsmIdentifierInfo(Expr *Res, llvm::InlineAsmIdentifierInfo &Info)
CXXMethodDecl * LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the moving assignment operator for the given class.
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
Definition: SemaExpr.cpp:19865
bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
Build a new nested-name-specifier for "identifier::", as described by ActOnCXXNestedNameSpecifier.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
Definition: Sema.h:7796
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:12659
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition: Sema.cpp:1547
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, NamedReturnInfo &NRInfo, bool SupressSimplerImplicitMoves)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes.
Definition: SemaStmt.cpp:3413
Stmt * MaybeCreateStmtWithCleanups(Stmt *SubStmt)
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
llvm::SmallVector< TypoExpr *, 2 > TypoExprs
Holds TypoExprs that are created from createDelayedTypo.
Definition: Sema.h:9001
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition: Sema.h:7599
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition: Sema.h:7643
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition: Sema.h:7609
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:7667
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:7672
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition: Sema.h:7659
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:7638
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition: Sema.h:7617
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition: Sema.h:7676
@ Compatible
Compatible - the types are compatible according to the standard.
Definition: Sema.h:7601
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition: Sema.h:7628
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition: Sema.h:7680
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:7613
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition: Sema.h:7622
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:7634
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition: Sema.h:7655
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition: Sema.h:7649
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition: Sema.h:7605
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:7663
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
Parsed a C++ 'new' expression (C++ 5.3.4).
void MarkVirtualBaseDestructorsReferenced(SourceLocation Location, CXXRecordDecl *ClassDecl, llvm::SmallPtrSetImpl< const RecordType * > *DirectVirtualBases=nullptr)
Mark destructors of virtual bases of this class referenced.
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool EmptyPack=false)
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
Definition: SemaDecl.cpp:8361
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1288
StmtResult ActOnCapturedRegionEnd(Stmt *S)
Definition: SemaStmt.cpp:4582
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition: Sema.h:7418
@ ACK_Arithmetic
An arithmetic operation.
Definition: Sema.h:7420
@ ACK_CompAssign
A compound assignment expression.
Definition: Sema.h:7428
@ ACK_BitwiseOp
A bitwise operation.
Definition: Sema.h:7422
@ ACK_Conditional
A conditional (?:) operator.
Definition: Sema.h:7426
@ ACK_Comparison
A comparison.
Definition: Sema.h:7424
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
Definition: SemaDecl.cpp:4699
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
Definition: SemaExpr.cpp:19761
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
Definition: SemaDecl.cpp:15674
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen)
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind ActOnExplicitInstantiationNewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
bool isAcceptable(const NamedDecl *D, AcceptableKind Kind)
Determine whether a declaration is acceptable (visible/reachable).
Definition: Sema.h:15003
void RestoreNestedNameSpecifierAnnotation(void *Annotation, SourceRange AnnotationRange, CXXScopeSpec &SS)
Given an annotation pointer for a nested-name-specifier, restore the nested-name-specifier structure.
QualType getDecltypeForExpr(Expr *E)
getDecltypeForExpr - Given an expr, will return the decltype for that expression, according to the ru...
Definition: SemaType.cpp:9419
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, SourceLocation Loc)
DeclClonePragmaWeak - clone existing decl (maybe definition), #pragma weak needs a non-definition dec...
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
Definition: SemaExpr.cpp:2882
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
bool CheckTypeConstraint(TemplateIdAnnotation *TypeConstraint)
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:2165
bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result)
BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr TheCall is a constant expression.
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
Definition: SemaStmt.cpp:3142
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
Definition: Sema.h:7998
TemplateNameKind ActOnTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a template name from a name that is syntactically required to name a template,...
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
Definition: SemaExpr.cpp:4093
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16537
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:3119
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition: Sema.h:6299
bool MSStructPragmaOn
Definition: Sema.h:1453
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:20716
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Definition: SemaType.cpp:9029
ExprResult TransformToPotentiallyEvaluated(Expr *E)
Definition: SemaExpr.cpp:17161
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
unsigned ActOnReenterTemplateScope(Decl *Template, llvm::function_ref< Scope *()> EnterScope)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore,...
Definition: Sema.h:13182
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
Definition: SemaDecl.cpp:15723
bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, QualType NewT, QualType OldT)
Determines if we can perform a correct type check for D as a redeclaration of PrevDecl.
Definition: SemaDecl.cpp:10935
ExprResult CreateUnresolvedLookupExpr(CXXRecordDecl *NamingClass, NestedNameSpecifierLoc NNSLoc, DeclarationNameInfo DNI, const UnresolvedSetImpl &Fns, bool PerformADL=true)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
Definition: Sema.h:13497
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:3853
@ NTK_Typedef
Definition: Sema.h:3858
@ NTK_NonUnion
Definition: Sema.h:3856
@ NTK_TypeAlias
Definition: Sema.h:3859
@ NTK_NonClass
Definition: Sema.h:3855
@ NTK_NonEnum
Definition: Sema.h:3857
@ NTK_NonStruct
Definition: Sema.h:3854
@ NTK_TemplateTemplateArgument
Definition: Sema.h:3862
@ NTK_TypeAliasTemplate
Definition: Sema.h:3861
@ NTK_Template
Definition: Sema.h:3860
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition: Sema.h:14978
SourceManager & getSourceManager() const
Definition: Sema.h:558
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
Definition: SemaModule.cpp:727
TryCaptureKind
Definition: Sema.h:6613
@ TryCapture_Implicit
Definition: Sema.h:6614
@ TryCapture_ExplicitByVal
Definition: Sema.h:6615
@ TryCapture_ExplicitByRef
Definition: Sema.h:6616
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9620
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition: Sema.h:8069
AssignmentAction
Definition: Sema.h:6495
@ AA_Returning
Definition: Sema.h:6498
@ AA_Passing_CFAudited
Definition: Sema.h:6503
@ AA_Initializing
Definition: Sema.h:6500
@ AA_Converting
Definition: Sema.h:6499
@ AA_Assigning
Definition: Sema.h:6496
@ AA_Passing
Definition: Sema.h:6497
@ AA_Casting
Definition: Sema.h:6502
@ AA_Sending
Definition: Sema.h:6501
FunctionDecl * SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD, FunctionDecl *Spaceship)
Substitute the name and return type of a defaulted 'operator<=>' to form an implicit 'operator=='.
CallingConventionIgnoredReason
Describes the reason a calling convention specification was ignored, used for diagnostics.
Definition: Sema.h:4412
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
Definition: SemaExpr.cpp:6636
bool CheckVecStepExpr(Expr *E)
Definition: SemaExpr.cpp:4374
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
Definition: Sema.cpp:579
bool isModuleVisible(const Module *M, bool ModulePrivate=false)
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false, OverloadCandidateParamOrder PO={})
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
Definition: Sema.h:3072
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
bool CheckRebuiltStmtAttributes(ArrayRef< const Attr * > Attrs)
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible.
Definition: SemaDecl.cpp:4269
bool hasVisibleMergedDefinition(const NamedDecl *Def)
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
Definition: Sema.cpp:882
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
Definition: SemaDecl.cpp:19882
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl * > Equiv)
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
Definition: SemaDecl.cpp:1339
void diagnoseFunctionEffectConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn when implicitly changing function effects.
Definition: Sema.cpp:642
ClassTemplateDecl * lookupCoroutineTraits(SourceLocation KwLoc, SourceLocation FuncLoc)
Lookup 'coroutine_traits' in std namespace and std::experimental namespace.
bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Definition: Sema.h:11905
bool areMultiversionVariantFunctionsCompatible(const FunctionDecl *OldFD, const FunctionDecl *NewFD, const PartialDiagnostic &NoProtoDiagID, const PartialDiagnosticAt &NoteCausedDiagIDAt, const PartialDiagnosticAt &NoSupportDiagIDAt, const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported, bool ConstexprSupported, bool CLinkageMayDiffer)
Checks if the variant/multiversion functions are compatible.
Definition: SemaDecl.cpp:11101
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:3373
bool CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *MD, DefaultedComparisonKind DCK)
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
Definition: SemaExpr.cpp:8704
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
Definition: SemaExpr.cpp:12592
ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
bool BuiltinElementwiseTernaryMath(CallExpr *TheCall, bool CheckForFloatArgs=true)
void ActOnLambdaExplicitTemplateParameterList(LambdaIntroducer &Intro, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > TParams, SourceLocation RAngleLoc, ExprResult RequiresClause)
This is called after parsing the explicit template parameter list on a lambda (if it exists) in C++2a...
Definition: SemaLambda.cpp:545
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
Definition: SemaExpr.cpp:10497
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
Get the specialization of the given variable template corresponding to the specified argument list,...
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Definition: Sema.h:8995
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
Definition: SemaExpr.cpp:19377
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Definition: SemaType.cpp:9524
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13549
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition: SemaAttr.cpp:449
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
bool ActOnCXXNestedNameSpecifierIndexedPack(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc, QualType Type)
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
Definition: SemaDecl.cpp:18021
bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount, unsigned MaxArgCount)
Checks that a call expression's argument count is in the desired range.
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
CanThrowResult canThrow(const Stmt *E)
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
bool isThisOutsideMemberFunctionBody(QualType BaseType)
Determine whether the given type is the type of *this that is used outside of the body of a member fu...
bool AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors.
Definition: Sema.h:12094
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc)
PragmaClangSection PragmaClangTextSection
Definition: Sema.h:1480
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
CallExpr::ADLCallKind ADLCallKind
Definition: Sema.h:7005
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
NonTrivialCUnionKind
Definition: Sema.h:3663
@ NTCUK_Destruct
Definition: Sema.h:3665
@ NTCUK_Init
Definition: Sema.h:3664
@ NTCUK_Copy
Definition: Sema.h:3666
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
DelayedDiagnosticsState ProcessingContextState
Definition: Sema.h:1034
void CheckLookupAccess(const LookupResult &R)
Checks access to all the declarations in the given result set.
concepts::ExprRequirement * BuildExprRequirement(Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement)
void ActOnPragmaFPValueChangingOption(SourceLocation Loc, PragmaFPKind Kind, bool IsEnabled)
Called on well formed #pragma clang fp reassociate or #pragma clang fp reciprocal.
Definition: SemaAttr.cpp:1283
QualType BuildAtomicType(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:9807
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:1477
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Definition: SemaExpr.cpp:20000
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Definition: SemaDecl.cpp:15751
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
Definition: SemaExpr.cpp:5452
llvm::Error isValidSectionSpecifier(StringRef Str)
Used to implement to perform semantic checking on attribute((section("foo"))) specifiers.
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
ParsedType actOnLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init)
Perform initialization analysis of the init-capture and perform any implicit conversions such as an l...
Definition: Sema.h:8791
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
Definition: SemaDecl.cpp:13801
bool anyAltivecTypes(QualType srcType, QualType destType)
Definition: SemaExpr.cpp:7490
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
TypeSourceInfo * SubstAutoTypeSourceInfoDependent(TypeSourceInfo *TypeWithAuto)
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type?
Definition: SemaExpr.cpp:7527
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute.
Definition: SemaAttr.cpp:1363
ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc)
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
Definition: SemaDecl.cpp:1227
void keepInLifetimeExtendingContext()
keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext flag from previous context.
Definition: Sema.h:7851
StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
Definition: SemaStmt.cpp:2335
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition: Sema.cpp:2196
bool IsAtLeastAsConstrained(NamedDecl *D1, MutableArrayRef< const Expr * > AC1, NamedDecl *D2, MutableArrayRef< const Expr * > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
sema::FunctionScopeInfo * getCurFunctionAvailabilityContext()
Retrieve the current function, if any, that should be analyzed for potential availability violations.
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaRedefineExtname - Called on well formed #pragma redefine_extname oldname newname.
Definition: SemaDecl.cpp:20153
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
PragmaStack< MSVtorDispMode > VtorDispStack
Whether to insert vtordisps prior to virtual bases in the Microsoft C++ ABI.
Definition: Sema.h:1690
TypeSourceInfo * ReplaceAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
Definition: SemaAttr.cpp:89
QualType CXXCheckConditionalOperands(ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc)
Check the operands of ?: under C++ semantics.
ExprResult BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, SourceLocation nameLoc, IndirectFieldDecl *indirectField, DeclAccessPair FoundDecl=DeclAccessPair::make(nullptr, AS_none), Expr *baseObjectExpr=nullptr, SourceLocation opLoc=SourceLocation())
TypeResult ActOnTypeName(Declarator &D)
Definition: SemaType.cpp:6348
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
MaybeODRUseExprSet MaybeODRUseExprs
Definition: Sema.h:6297
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:563
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
unsigned FunctionScopesStart
The index of the first FunctionScope that corresponds to the current context.
Definition: Sema.h:904
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:1748
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum, unsigned ArgBits)
BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of TheCall is a constant expression re...
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition: Sema.h:8428
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope, bool IsInstantiation=false)
ActOnLambdaError - If there is an error parsing a lambda, this callback is invoked to pop the informa...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
Definition: SemaExpr.cpp:216
static SourceRange getPrintable(SourceRange R)
Definition: Sema.h:14575
void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
CheckParmsForFunctionDef - Check that the parameters of the given function are appropriate for the de...
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
TopLevelStmtDecl * ActOnStartTopLevelStmtDecl(Scope *S)
Definition: SemaDecl.cpp:20137
concepts::Requirement * ActOnTypeRequirement(SourceLocation TypenameKWLoc, CXXScopeSpec &SS, SourceLocation NameLoc, const IdentifierInfo *TypeName, TemplateIdAnnotation *TemplateId)
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
Definition: SemaDecl.cpp:8204
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name, TemplateNameKind &TNK, SourceLocation NameLoc, IdentifierInfo *&II)
Try to resolve an undeclared template name as a type template.
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, const IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations.
Definition: SemaExprCXX.cpp:58
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over....
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e....
Definition: SemaExpr.cpp:2042
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
void PushSatisfactionStackEntry(const NamedDecl *D, const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:14312
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc, ImplicitTypenameContext IsImplicitTypename=ImplicitTypenameContext::No)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
Definition: SemaStmt.cpp:3790
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition: Sema.h:14945
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition: Sema.h:773
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
Binary Operators. 'Tok' is the token for the operator.
Definition: SemaExpr.cpp:15071
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
Definition: Sema.cpp:2724
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void emitDeferredDiags()
Definition: Sema.cpp:1880
void setFunctionHasMustTail()
Definition: Sema.cpp:2360
ExprResult BuildPseudoDestructorExpr(Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration,...
bool WarnedStackExhausted
Definition: Sema.h:925
bool hasReachableMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is a member specialization declaration (as op...
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
Definition: SemaExpr.cpp:7629
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:7994
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
CorrectTypoKind
Definition: Sema.h:9407
@ CTK_NonError
Definition: Sema.h:9408
@ CTK_ErrorRecovery
Definition: Sema.h:9409
void CheckCompleteVariableDeclaration(VarDecl *VD)
Definition: SemaDecl.cpp:14211
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
Definition: SemaInit.cpp:3444
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
TUFragmentKind
Definition: Sema.h:644
@ Global
The global module fragment, between 'module;' and a module-declaration.
Definition: Sema.h:646
@ Private
The private module fragment, between 'module :private;' and the end of the translation unit.
Definition: Sema.h:653
@ Normal
A normal translation unit fragment.
Definition: Sema.h:650
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
void PopSatisfactionStackEntry()
Definition: Sema.h:14318
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
Definition: SemaType.cpp:1792
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL,...
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
Definition: SemaDecl.cpp:14730
void setFunctionHasBranchProtectedScope()
Definition: Sema.cpp:2350
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition: Sema.h:15024
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
Definition: SemaDecl.cpp:4460
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
bool isConstantEvaluatedContext() const
Definition: Sema.h:2182
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:6064
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
Definition: SemaStmt.cpp:4368
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output, SourceLocation Loc={}, const DeclarationName &Entity={})
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
Definition: SemaDecl.cpp:591
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
std::pair< const NamedDecl *, llvm::FoldingSetNodeID > SatisfactionStackEntryTy
Definition: Sema.h:14328
bool SubstDefaultArgument(SourceLocation Loc, ParmVarDecl *Param, const MultiLevelTemplateArgumentList &TemplateArgs, bool ForCallExpr=false)
Substitute the given template arguments into the default argument.
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope)
Definition: SemaStmt.cpp:3182
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9587
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
void ActOnStartOfTranslationUnit()
This is called before the very first declaration in the translation unit is parsed.
Definition: Sema.cpp:1101
CCEKind
Contexts in which a converted constant expression is required.
Definition: Sema.h:10023
@ CCEK_StaticAssertMessageSize
Call to size() in a static assert message.
Definition: Sema.h:10030
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
Definition: Sema.h:10028
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
Definition: Sema.h:10029
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:10027
@ CCEK_CaseValue
Expression in a case label.
Definition: Sema.h:10024
@ CCEK_TemplateArg
Value of a non-type template parameter.
Definition: Sema.h:10026
@ CCEK_StaticAssertMessageData
Call to data() in a static assert message.
Definition: Sema.h:10032
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
Definition: Sema.h:10025
StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
Definition: SemaStmt.cpp:2593
ExprResult ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, SourceRange Range)
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
Definition: SemaStmt.cpp:1741
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
Definition: SemaDecl.cpp:18625
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:10939
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:1122
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
Definition: SemaDecl.cpp:3078
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
Definition: SemaDecl.cpp:1892
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition: Sema.h:3093
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
Definition: SemaDecl.cpp:288
ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Definition: SemaDecl.cpp:19420
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
Definition: Sema.h:1225
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
Definition: SemaDecl.cpp:12464
ASTConsumer & Consumer
Definition: Sema.h:963
bool handlerCanCatch(QualType HandlerType, QualType ExceptionType)
RequiresExprBodyDecl * ActOnStartRequiresExpr(SourceLocation RequiresKWLoc, ArrayRef< ParmVarDecl * > LocalParameters, Scope *BodyScope)
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false, bool FirstArgumentIsBase=false)
Add all of the function declarations in the given function set to the overload candidate set.
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand)
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
Definition: Sema.h:4238
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
OverloadKind
Definition: Sema.h:9801
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
Definition: Sema.h:9812
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:9804
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:9808
PragmaAlignPackDiagnoseKind
Definition: Sema.h:1845
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType.
SmallVector< ExprWithCleanups::CleanupObject, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
Definition: Sema.h:6491
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition: SemaExpr.cpp:121
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
Definition: SemaDecl.cpp:2049
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:998
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
Definition: Sema.cpp:1690
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition: Sema.h:13526
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Definition: SemaExpr.cpp:5101
ExprResult BuiltinShuffleVector(CallExpr *TheCall)
BuiltinShuffleVector - Handle __builtin_shufflevector.
bool CheckImplicitNullabilityTypeSpecifier(QualType &Type, NullabilityKind Nullability, SourceLocation DiagLoc, bool AllowArrayTypes, bool OverrideExisting)
Check whether a nullability type specifier can be added to the given type through some means not writ...
Definition: SemaType.cpp:7279
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
ModuleImportState
An enumeration to represent the transition of states in parsing module fragments and imports.
Definition: Sema.h:9640
@ PrivateFragmentImportFinished
after 'module :private;' but a non-import decl has already been seen.
@ ImportFinished
after any non-import decl.
@ PrivateFragmentImportAllowed
after 'module :private;' but before any non-import decl.
@ FirstDecl
Parsing the first decl in a TU.
@ GlobalFragment
after 'module;' but before 'module X;'
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
@ ImportAllowed
after 'module X;' but before any non-import decl.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters are used in a given expression.
static QualType getPrintable(QualType T)
Definition: Sema.h:14574
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Definition: SemaExpr.cpp:3526
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData)
Definition: SemaExpr.cpp:16578
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
Definition: SemaExpr.cpp:12537
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition: Sema.cpp:88
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
Definition: SemaStmt.cpp:4398
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition: Sema.h:927
void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc)
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, const ParsedAttributesView &Attr)
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
void AddNonMemberOperatorCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
Add all of the non-member operator function declarations in the given function set to the overload ca...
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
Definition: SemaExpr.cpp:8330
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
Definition: SemaDecl.cpp:16412
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition: Sema.h:6241
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ DiscardedStatement
The current expression occurs within a discarded statement.
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
Definition: SemaCast.cpp:2043
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
Definition: SemaType.cpp:9492
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
Definition: Sema.h:13190
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9751
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition: Sema.h:4397
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
Definition: Sema.h:4403
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition: Sema.h:4407
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition: Sema.h:4400
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition: Sema.h:4054
@ AMK_None
Don't merge availability attributes at all.
Definition: Sema.h:4056
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition: Sema.h:4062
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:4065
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition: Sema.h:4068
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition: Sema.h:4059
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
Definition: SemaDecl.cpp:14849
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Parse a __builtin_astype expression.
Definition: SemaExpr.cpp:6629
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4348
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
Definition: SemaExpr.cpp:4600
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
Definition: SemaType.cpp:5653
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
Definition: SemaDecl.cpp:14518
ExprResult BuildOperatorCoawaitLookupExpr(Scope *S, SourceLocation Loc)
std::pair< SourceLocation, bool > DeleteExprLoc
Definition: Sema.h:604
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
Definition: SemaExpr.cpp:20006
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
Definition: SemaExpr.cpp:4211
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
Definition: SemaDecl.cpp:17016
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, const ParsedAttributesView &DeclAttrs, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e....
Definition: SemaDecl.cpp:4777
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
SemaPPC & PPC()
Definition: Sema.h:1184
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
Definition: Sema.cpp:2209
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16289
MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc)
Handle a C++ member initializer.
void ActOnAfterCompoundStatementLeadingPragmas()
Definition: SemaStmt.cpp:400
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
Definition: SemaType.cpp:5766
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition: SemaStmt.cpp:79
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition: Sema.h:4471
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:8907
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Definition: SemaDecl.cpp:15187
void actOnDelayedExceptionSpecification(Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member or friend function (or function template).
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Definition: Sema.h:923
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, ReferenceConversions *Conv=nullptr)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
Definition: SemaDecl.cpp:1335
void DiagnoseUnterminatedPragmaAttribute()
Definition: SemaAttr.cpp:1130
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
Definition: SemaAttr.cpp:1235
bool SatisfactionStackContains(const NamedDecl *D, const llvm::FoldingSetNodeID &ID) const
Definition: Sema.h:14320
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
Definition: SemaExpr.cpp:20646
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:1004
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
Definition: SemaDecl.cpp:18871
void CheckExplicitObjectLambda(Declarator &D)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
QualType getCapturedDeclRefType(ValueDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope.
Definition: SemaExpr.cpp:19011
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Definition: SemaExpr.cpp:7664
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC #pragma optimize in scope,...
Definition: SemaAttr.cpp:1185
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
Definition: SemaAttr.cpp:1372
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Delete-expressions to be analyzed at the end of translation unit.
Definition: Sema.h:8005
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
Definition: SemaDecl.cpp:10959
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:3112
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition: Sema.h:9780
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
Definition: SemaInit.cpp:7339
QualType getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType, CallingConv CC)
Get the return type to use for a lambda's conversion function(s) to function pointer type,...
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
Definition: Sema.h:7786
SemaSystemZ & SystemZ()
Definition: Sema.h:1209
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition: Sema.cpp:102
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr)
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:2746
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
Definition: SemaExpr.cpp:17680
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9632
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
Definition: SemaExpr.cpp:19003
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:7946
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
Definition: SemaDecl.cpp:1307
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
Definition: SemaExpr.cpp:7576
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
void makeModuleVisible(Module *Mod, SourceLocation ImportLoc)
Definition: Sema.h:9626
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
Definition: SemaType.cpp:8882
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
Definition: SemaStmt.cpp:624
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9658
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition: Sema.h:965
TemplateNameIsRequiredTag
Definition: Sema.h:11106
@ TemplateNameIsRequired
Definition: Sema.h:11106
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
Definition: SemaExpr.cpp:4686
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
Definition: SemaExpr.cpp:7737
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc)
Called when an expression computing the size of a parameter pack is parsed.
bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const
Determine whether FD is an aligned allocation or deallocation function that is unavailable.
bool hasReachableExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is an explicit specialization declaration for...
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure.
Definition: SemaDecl.cpp:5729
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, CXXScopeSpec &SS, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration.
TypeSourceInfo * SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, StringRef SlotLabel, Expr *Alignment)
ActOnPragmaPack - Called on well formed #pragma pack(...).
Definition: SemaAttr.cpp:335
static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD)
Definition: SemaDecl.cpp:15808
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
LazyVector< CXXConstructorDecl *, ExternalSemaSource, &ExternalSemaSource::ReadDelegatingConstructors, 2, 2 > DelegatingCtorDeclsType
Definition: Sema.h:6057
LabelDecl * GetOrCreateMSAsmLabel(StringRef ExternalLabelName, SourceLocation Location, bool AlwaysCreate)
bool DiagnoseDependentMemberLookup(const LookupResult &R)
Diagnose a lookup that found results in an enclosing class during error recovery.
Definition: SemaExpr.cpp:2387
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Definition: Sema.h:9092
DiagnosticsEngine & Diags
Definition: Sema.h:964
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
Definition: SemaLambda.cpp:973
void DiagnoseUnterminatedPragmaAlignPack()
Definition: SemaAttr.cpp:488
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope)
Definition: SemaStmt.cpp:3209
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:7321
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:554
FPOptions CurFPFeatures
Definition: Sema.h:958
void ActOnStartSEHFinallyBlock()
Definition: SemaStmt.cpp:4360
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
static bool CanBeGetReturnObject(const FunctionDecl *FD)
Definition: SemaDecl.cpp:15804
NamespaceDecl * getStdNamespace() const
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9596
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition: Sema.h:6048
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
Definition: SemaDecl.cpp:6619
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
Definition: SemaType.cpp:2035
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Definition: SemaExpr.cpp:516
PragmaStack< StringLiteral * > DataSegStack
Definition: Sema.h:1700
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
Definition: SemaLambda.cpp:691
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:1005
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector,...
Definition: SemaExpr.cpp:7513
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Definition: SemaInit.cpp:9656
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Definition: SemaDecl.cpp:7200
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
Definition: SemaDecl.cpp:14880
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< ParsedType > Args, SourceLocation RParenLoc)
Parsed one of the type trait support pseudo-functions.
TemplateParamListContext
The context in which we are checking a template parameter list.
Definition: Sema.h:11294
@ TPC_ClassTemplate
Definition: Sema.h:11295
@ TPC_FriendFunctionTemplate
Definition: Sema.h:11300
@ TPC_ClassTemplateMember
Definition: Sema.h:11298
@ TPC_FunctionTemplate
Definition: Sema.h:11297
@ TPC_FriendClassTemplate
Definition: Sema.h:11299
@ TPC_FriendFunctionTemplateDefinition
Definition: Sema.h:11301
@ TPC_TypeAliasTemplate
Definition: Sema.h:11302
@ TPC_VarTemplate
Definition: Sema.h:11296
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
Definition: SemaAttr.cpp:1249
void ActOnAbortSEHFinallyBlock()
Definition: SemaStmt.cpp:4364
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMemberKind SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name,...
Definition: SemaDecl.cpp:6703
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
Definition: SemaDecl.cpp:16267
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:1771
SemaAVR & AVR()
Definition: Sema.h:1109
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:13648
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5526
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
bool checkTargetClonesAttrString(SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal, Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault, SmallVectorImpl< SmallString< 64 > > &StringsBuffer)
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition,...
Definition: SemaExpr.cpp:20049
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:1776
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
void DiagnoseUnusedDecl(const NamedDecl *ND)
Definition: SemaDecl.cpp:2067
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
friend class ArgumentPackSubstitutionRAII
Definition: Sema.h:13227
bool hasAcceptableDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules, Sema::AcceptableKind Kind)
Determine if the template parameter D has a reachable default argument.
QualType BuildReadPipeType(QualType T, SourceLocation Loc)
Build a Read-only Pipe type.
Definition: SemaType.cpp:1919
void PopDeclContext()
Definition: SemaDecl.cpp:1314
void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init)
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param, SourceLocation Location)
Get a template argument mapping the given template parameter to itself, e.g.
bool CheckIfFunctionSpecializationIsImmediate(FunctionDecl *FD, SourceLocation Loc)
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
Definition: SemaType.cpp:2851
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12938
concepts::NestedRequirement * BuildNestedRequirement(Expr *E)
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
Definition: Sema.h:6076
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition: Sema.h:13157
void PrintStats() const
Print out statistics about the semantic analysis.
Definition: Sema.cpp:618
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
Definition: SemaExpr.cpp:15643
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
static unsigned getPrintable(unsigned I)
Definition: Sema.h:14565
void checkVariadicArgument(const Expr *E, VariadicCallType CT)
Check to see if the given expression is a valid argument to a variadic function, issuing a diagnostic...
Definition: SemaExpr.cpp:991
ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS, tok::TokenKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)
Handle a C++1z fold-expression: ( expr op ... op expr ).
void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, const Expr *ArgExpr)
CheckStaticArrayArgument - If the given argument corresponds to a static array parameter,...
Definition: SemaExpr.cpp:6006
FormatStringType
Definition: Sema.h:2219
@ FST_NSString
Definition: Sema.h:2222
@ FST_Syslog
Definition: Sema.h:2229
@ FST_Unknown
Definition: Sema.h:2230
@ FST_Strftime
Definition: Sema.h:2223
@ FST_Printf
Definition: Sema.h:2221
@ FST_FreeBSDKPrintf
Definition: Sema.h:2226
@ FST_Scanf
Definition: Sema.h:2220
@ FST_Strfmon
Definition: Sema.h:2224
@ FST_OSLog
Definition: Sema.h:2228
@ FST_Kprintf
Definition: Sema.h:2225
@ FST_OSTrace
Definition: Sema.h:2227
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:1451
QualType SubstAutoTypeDependent(QualType TypeWithAuto)
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
Definition: SemaDecl.cpp:1578
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it,...
QualType CheckSizelessVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12653
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:909
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
Definition: SemaType.cpp:1923
void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, const FunctionProtoType *Proto, Expr *Object, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddSurrogateCandidate - Adds a "surrogate" candidate function that converts the given Object to a fun...
MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
BuildForRangeKind
Definition: Sema.h:10770
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition: Sema.h:10778
@ BFRK_Build
Initial building of a for-range statement.
Definition: Sema.h:10772
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:10775
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
Definition: SemaExpr.cpp:8807
SemaNVPTX & NVPTX()
Definition: Sema.h:1159
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
void checkIncorrectVTablePointerAuthenticationAttribute(CXXRecordDecl &RD)
Check that VTable Pointer authentication is only being set on the first first instantiation of the vt...
StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl, Stmt *HandlerBlock)
ActOnCXXCatchBlock - Takes an exception declaration and a handler block and creates a proper catch ha...
Definition: SemaStmt.cpp:4077
void ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation, PragmaMsStackAction Action, bool Value)
ActOnPragmaMSStrictGuardStackCheck - Called on well formed #pragma strict_gs_check.
Definition: SemaAttr.cpp:775
void ActOnUninitializedDecl(Decl *dcl)
Definition: SemaDecl.cpp:13843
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
Definition: SemaDecl.cpp:13010
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
Definition: SemaDecl.cpp:1563
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
Definition: SemaDecl.cpp:16675
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs)
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc)
Definition: SemaType.cpp:9506
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
Definition: Sema.cpp:2392
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition: SemaStmt.cpp:548
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
Definition: SemaExpr.cpp:16100
OffsetOfKind
Definition: Sema.h:3877
@ OOK_Outside
Definition: Sema.h:3879
@ OOK_Macro
Definition: Sema.h:3884
@ OOK_Builtin
Definition: Sema.h:3881
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
Definition: SemaDecl.cpp:13283
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
Definition: SemaType.cpp:9379
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
PragmaSectionKind
Definition: Sema.h:1720
@ PSK_ConstSeg
Definition: Sema.h:1723
@ PSK_DataSeg
Definition: Sema.h:1721
@ PSK_CodeSeg
Definition: Sema.h:1724
@ PSK_BSSSeg
Definition: Sema.h:1722
TemplateDeductionResult FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, SmallVectorImpl< OriginalCallArg > const *OriginalCallArgs=nullptr, bool PartialOverloading=false, llvm::function_ref< bool()> CheckNonDependent=[] { return false;})
Finish template argument deduction for a function template, checking the deduced template arguments f...
void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope)
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
Definition: Sema.cpp:574
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Definition: SemaExpr.cpp:19783
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Definition: Sema.cpp:604
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition: SemaCast.cpp:297
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
Definition: SemaExpr.cpp:16606
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition: Sema.h:5819
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
Definition: SemaDecl.cpp:18261
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
Definition: SemaExpr.cpp:17861
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
Definition: SemaExpr.cpp:15687
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, IdentifierInfo *IIEnvironment)
void BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs, LateInstantiatedAttrVec *LateAttrs, DeclContext *Owner, LocalInstantiationScope *StartingScope, bool InstantiatingVarTemplate=false, VarTemplateSpecializationDecl *PrevVTSD=nullptr)
BuildVariableInstantiation - Used after a new variable has been created.
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
Definition: SemaExpr.cpp:4739
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
Definition: SemaDecl.cpp:4305
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void ActOnCXXForRangeDecl(Decl *D)
Definition: SemaDecl.cpp:14128
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
Definition: SemaExpr.cpp:5892
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
Definition: SemaLambda.cpp:282
void diagnoseFunctionEffectMergeConflicts(const FunctionEffectSet::Conflicts &Errs, SourceLocation NewLoc, SourceLocation OldLoc)
Definition: SemaDecl.cpp:20304
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
Definition: SemaType.cpp:2434
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
Definition: SemaExpr.cpp:20105
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
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:3087
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition: Sema.cpp:1967
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
Definition: SemaExpr.cpp:20913
bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis=false)
Check if IdxExpr is a valid parameter index for a function or instance method D.
Definition: Sema.h:4712
void CompleteLambdaCallOperator(CXXMethodDecl *Method, SourceLocation LambdaLoc, SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause, TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind, StorageClass SC, ArrayRef< ParmVarDecl * > Params, bool HasExplicitResultType)
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
Definition: SemaType.cpp:8936
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15134
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:1476
Decl * ActOnDeclarator(Scope *S, Declarator &D)
Definition: SemaDecl.cpp:6038
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3663
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:1021
AbstractDiagSelID
Definition: Sema.h:5765
@ AbstractSynthesizedIvarType
Definition: Sema.h:5772
@ AbstractVariableType
Definition: Sema.h:5769
@ AbstractReturnType
Definition: Sema.h:5767
@ AbstractNone
Definition: Sema.h:5766
@ AbstractFieldType
Definition: Sema.h:5770
@ AbstractArrayType
Definition: Sema.h:5773
@ AbstractParamType
Definition: Sema.h:5768
@ AbstractIvarType
Definition: Sema.h:5771
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:2955
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:909
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High, bool RangeIsError=true)
BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr TheCall is a constant express...
bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiate the definition of an enum from a given pattern.
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7181
PragmaOptionsAlignKind
Definition: Sema.h:1815
@ POAK_Power
Definition: Sema.h:1819
@ POAK_Reset
Definition: Sema.h:1821
@ POAK_Packed
Definition: Sema.h:1818
@ POAK_Mac68k
Definition: Sema.h:1820
@ POAK_Natural
Definition: Sema.h:1817
@ POAK_Native
Definition: Sema.h:1816
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:15942
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
void CheckAlignasUnderalignment(Decl *D)
ParsedType getConstructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext)
Definition: SemaExprCXX.cpp:92
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
Definition: SemaExpr.cpp:4812
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old)
A wrapper function for checking the semantic restrictions of a redeclaration within a module.
Definition: SemaDecl.cpp:1702
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition: Sema.h:7991
ExprResult ActOnNameClassifiedAsDependentNonType(const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, bool IsAddressOfOperand)
Act on the result of classifying a name as an undeclared member of a dependent base class.
Definition: SemaDecl.cpp:1236
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
Definition: SemaExpr.cpp:14599
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
Decl * ActOnFinishExportDecl(Scope *S, Decl *ExportDecl, SourceLocation RBraceLoc)
Complete the definition of an export declaration.
Definition: SemaModule.cpp:993
void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI)
Note that we have finished the explicit captures for the given lambda.
Definition: SemaLambda.cpp:541
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9725
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
Definition: SemaExpr.cpp:9082
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
void ActOnPragmaFPContract(SourceLocation Loc, LangOptions::FPModeKind FPC)
ActOnPragmaFPContract - Called on well formed #pragma {STDC,OPENCL} FP_CONTRACT and #pragma clang fp ...
Definition: SemaAttr.cpp:1264
void adjustMemberFunctionCC(QualType &T, bool HasThisPointer, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
Definition: SemaType.cpp:8005
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc)
Called on well formed #pragma clang optimize.
Definition: SemaAttr.cpp:1136
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
Definition: SemaExpr.cpp:6369
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
Definition: SemaExpr.cpp:4669
QualType PreferredConditionType(ConditionKind K) const
Definition: Sema.h:7516
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
Create an CUDALaunchBoundsAttr attribute.
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
void clearDelayedTypo(TypoExpr *TE)
Clears the state of the given TypoExpr.
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
Definition: Sema.h:9064
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition: Sema.h:9068
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition: Sema.h:9074
@ LOLR_Error
The lookup resulted in an error.
Definition: Sema.h:9066
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:9071
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition: Sema.h:9082
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:9078
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Definition: SemaDecl.cpp:20192
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition: Sema.cpp:2380
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition: Sema.h:6472
SemaLoongArch & LoongArch()
Definition: Sema.h:1139
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Definition: SemaExpr.cpp:15971
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:10536
CheckConstexprKind
Definition: Sema.h:5961
@ CheckValid
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
ExprResult InitializeExplicitObjectArgument(Sema &S, Expr *Obj, FunctionDecl *Fun)
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
Definition: Sema.h:13522
void CheckVariableDeclarationType(VarDecl *NewVD)
Definition: SemaDecl.cpp:8532
sema::CompoundScopeInfo & getCurCompoundScope() const
Definition: SemaStmt.cpp:412
DeclContext * FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, const MultiLevelTemplateArgumentList &TemplateArgs)
Finds the instantiation of the given declaration context within the current instantiation.
sema::CapturedRegionScopeInfo * getCurCapturedRegion()
Retrieve the current captured region, if any.
Definition: Sema.cpp:2738
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:954
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
void warnStackExhausted(SourceLocation Loc)
Warn that the stack is nearly exhausted.
Definition: Sema.cpp:566
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
Definition: SemaInit.cpp:9641
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
bool DiagnoseInvalidExplicitObjectParameterInLambda(CXXMethodDecl *Method, SourceLocation CallLoc)
Returns true if the explicit object parameter was invalid.
Definition: SemaLambda.cpp:393
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
Definition: SemaDecl.cpp:1321
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
Definition: Sema.cpp:654
bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E)
CheckCXXThrowOperand - Validate the operand of a throw.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
Definition: SemaDecl.cpp:12976
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II)
Called on #pragma clang __debug dump II.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled)
ActOnPragmaFenvAccess - Called on well formed #pragma STDC FENV_ACCESS.
Definition: SemaAttr.cpp:1334
bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New)
Definition: SemaDecl.cpp:2434
bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Perform substitution on the base class specifiers of the given class template specialization.
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
Definition: SemaType.cpp:2731
llvm::SmallPtrSet< const NamedDecl *, 4 > TypoCorrectedFunctionDefinitions
The function definitions which were renamed as part of typo-correction to match their respective decl...
Definition: Sema.h:3068
void ActOnFinishOfCompoundStmt()
Definition: SemaStmt.cpp:408
concepts::Requirement * ActOnNestedRequirement(Expr *Constraint)
QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType, bool AdjustExceptionSpec=false)
Adjust the type ArgFunctionType to match the calling convention, noreturn, and optionally the excepti...
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
void AddSectionMSAllocText(FunctionDecl *FD)
Only called on function definitions; if there is a #pragma alloc_text that decides which code section...
Definition: SemaAttr.cpp:1169
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
Definition: SemaDecl.cpp:15688
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14869
void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
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:13262
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:10977
static ConditionResult ConditionError()
Definition: Sema.h:7358
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition: SemaStmt.cpp:416
void NoteTemplateParameterLocation(const NamedDecl &Decl)
SemaWasm & Wasm()
Definition: Sema.h:1214
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
Definition: SemaExpr.cpp:6650
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, bool SuppressUserConversions, CXXRecordDecl *ActingContext=nullptr, QualType ObjectType=QualType(), Expr::Classification ObjectClassification={}, OverloadCandidateParamOrder PO={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
const NormalizedConstraint * getNormalizedAssociatedConstraints(NamedDecl *ConstrainedDecl, ArrayRef< const Expr * > AssociatedConstraints)
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
IdentifierResolver IdResolver
Definition: Sema.h:3016
bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo, bool EnteringContext)
IsInvalidUnlessNestedName - This method is used for error recovery purposes to determine whether the ...
const TypoExprState & getTypoExprState(TypoExpr *TE) const
llvm::DenseSet< QualType > InstantiatedNonDependentTypes
Non-dependent types used in templates that have already been instantiated by some template instantiat...
Definition: Sema.h:13153
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
Definition: SemaExpr.cpp:20650
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
Definition: SemaDecl.cpp:19853
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
Definition: SemaExpr.cpp:5752
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
Definition: SemaExpr.cpp:15885
SemaPseudoObject & PseudoObject()
Definition: Sema.h:1189
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:2341
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:573
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition: Sema.h:11071
StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
ActOnCXXTryBlock - Takes a try compound-statement and a number of handlers and creates a try statemen...
Definition: SemaStmt.cpp:4197
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:7314
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
Definition: SemaDecl.cpp:680
void DiagnoseSizeOfParametersAndReturnValue(ArrayRef< ParmVarDecl * > Parameters, QualType ReturnTy, NamedDecl *D)
Diagnose whether the size of parameters or return value of a function or obj-c method definition is p...
Definition: SemaDecl.cpp:15076
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
Definition: Sema.h:7954
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:953
static int getPrintable(int I)
Definition: Sema.h:14564
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply.
void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags, StringLiteral *SegmentName)
Called on well formed #pragma section().
Definition: SemaAttr.cpp:786
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
Definition: Sema.h:9334
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:12500
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition: SemaStmt.cpp:553
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
ExprResult ActOnCXXThis(SourceLocation Loc)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
Definition: Sema.h:3388
bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, QualType SrcTy)
Definition: SemaCast.cpp:2704
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
Definition: SemaExpr.cpp:17688
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
static const std::string & getPrintable(const std::string &S)
Definition: Sema.h:14569
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:1459
@ PCSK_Invalid
Definition: Sema.h:1460
@ PCSK_BSS
Definition: Sema.h:1461
@ PCSK_Data
Definition: Sema.h:1462
@ PCSK_Text
Definition: Sema.h:1464
@ PCSK_Relro
Definition: Sema.h:1465
@ PCSK_Rodata
Definition: Sema.h:1463
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7113
void warnOnReservedIdentifier(const NamedDecl *D)
Definition: SemaDecl.cpp:6025
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition: SemaStmt.cpp:517
bool isCheckingDefaultArgumentOrInitializer() const
Definition: Sema.h:7810
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
Definition: SemaDecl.cpp:16748
SemaARM & ARM()
Definition: Sema.h:1104
bool CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, SourceLocation DefaultLoc)
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined.
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
Definition: SemaAttr.cpp:219
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings=std::nullopt)
Definition: SemaDecl.cpp:7377
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
static const char * getPrintable(const char *S)
Definition: Sema.h:14567
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto)
CheckFunctionCall - Check a direct function call for various correctness and safety properties not st...
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO={})
Add overload candidates for overloaded operators that are member functions.
ExprResult ActOnDecltypeExpression(Expr *E)
Process the expression contained within a decltype.
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
Definition: SemaType.cpp:2662
AllocationFunctionScope
The scope in which to find allocation functions.
Definition: Sema.h:8188
@ AFS_Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition: Sema.h:8196
@ AFS_Class
Only look for allocation functions in the scope of the allocated class.
Definition: Sema.h:8193
@ AFS_Global
Only look for allocation functions in the global scope.
Definition: Sema.h:8190
bool isAbstractType(SourceLocation Loc, QualType T)
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
Definition: SemaExpr.cpp:5313
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:600
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Definition: SemaType.cpp:2714
PragmaMsStackAction
Definition: Sema.h:1482
@ PSK_Push_Set
Definition: Sema.h:1488
@ PSK_Reset
Definition: Sema.h:1483
@ PSK_Pop_Set
Definition: Sema.h:1489
@ PSK_Show
Definition: Sema.h:1487
@ PSK_Pop
Definition: Sema.h:1486
@ PSK_Set
Definition: Sema.h:1484
@ PSK_Push
Definition: Sema.h:1485
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3109
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D, SourceLocation Loc=SourceLocation())
Determine whether the callee of a particular function call can throw.
void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc, bool IsDelete, bool CallCanBeVirtual, bool WarnOnNonAbstractTypes, SourceLocation DtorLoc)
void DiagnoseImmediateEscalatingReason(FunctionDecl *FD)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Definition: Sema.h:8293
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, bool EvaluateConstraints=true)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
Definition: SemaExpr.cpp:4987
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Definition: SemaDecl.cpp:1263
StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, Module *Mod)
Create an implicit import of the given module at the given source location, for error recovery,...
Definition: SemaModule.cpp:825
void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, const Expr *ThisArg, ArrayRef< const Expr * > Args, bool IsMemberFunction, SourceLocation Loc, SourceRange Range, VariadicCallType CallType)
Handles the checks for format strings, non-POD arguments to vararg functions, NULL arguments passed t...
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
Definition: Overload.h:292
Stmt - This represents one statement.
Definition: Stmt.h:84
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:326
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3561
Exposes information about the current target.
Definition: TargetInfo.h:218
A convenient class for passing around template argument information.
Definition: TemplateBase.h:632
A template argument list.
Definition: DeclTemplate.h:244
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
Represents a template argument.
Definition: TemplateBase.h:61
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:394
Represents a C++ template name within the type system.
Definition: TemplateName.h:203
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:73
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
Token - This structure provides full information about a lexed token.
Definition: Token.h:36
A declaration that models statements at global scope.
Definition: Decl.h:4434
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition: ASTConcept.h:227
Represents a declaration of a type.
Definition: Decl.h:3367
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:59
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:153
A container of type source information.
Definition: Type.h:7726
The base class of the type hierarchy.
Definition: Type.h:1829
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
Definition: Type.cpp:2477
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3511
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3409
Simple class containing the result of Sema::CorrectTypo.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:6777
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:1028
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3203
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3943
A set of unresolved declarations.
Definition: UnresolvedSet.h:62
Represents a C++ using-declaration.
Definition: DeclCXX.h:3516
Represents C++ using-directive.
Definition: DeclCXX.h:3019
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3324
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:667
Represents a variable declaration or definition.
Definition: Decl.h:879
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
Represents a GCC generic vector type.
Definition: Type.h:4026
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2783
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Definition: Lookup.h:836
Captures information about a #pragma weak directive.
Definition: Weak.h:25
The API notes manager helps find API notes associated with declarations.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
Definition: ExprConcepts.h:280
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
Definition: ExprConcepts.h:429
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:168
A requires-expression requirement which queries the existence of a type name or type template special...
Definition: ExprConcepts.h:225
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:784
Retains information about a captured region.
Definition: ScopeInfo.h:810
Contains information about the compound statement currently being parsed.
Definition: ScopeInfo.h:67
A collection of diagnostics which were delayed.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:104
Provides information about an attempted template argument deduction, whose success or failure was des...
#define UINT_MAX
Definition: limits.h:64
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
void threadSafetyCleanup(BeforeSet *Cache)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:25
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:55
ImplicitTypenameContext
Definition: DeclSpec.h:1886
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
PragmaFPKind
Definition: PragmaKinds.h:38
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:42
@ CPlusPlus
Definition: LangStandard.h:56
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition: Overload.h:869
FunctionEffectMode
Used with attributes/effects with a boolean condition, e.g. nonblocking.
Definition: Sema.h:435
CUDAFunctionTarget
Definition: Cuda.h:140
CanThrowResult
Possible results from evaluation of a noexcept expression.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
PragmaMSCommentKind
Definition: PragmaKinds.h:14
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition: Specifiers.h:35
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition: Specifiers.h:39
bool isInstanceMethod(const Decl *D)
Definition: Attr.h:120
ArrayRef< std::pair< IdentifierInfo *, SourceLocation > > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
Definition: ModuleLoader.h:32
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:336
InClassInitStyle
In-class initialization styles for non-static data members.
Definition: Specifiers.h:271
CXXConstructionKind
Definition: ExprCXX.h:1538
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:149
BinaryOperatorKind
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
Definition: Overload.h:84
TypeOfKind
The kind of 'typeof' expression we're after.
Definition: Type.h:922
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
Definition: CallGraph.h:207
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:16
StorageClass
Storage classes.
Definition: Specifiers.h:248
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:51
bool isFunctionOrMethodOrBlockForAttrSubject(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
Definition: Attr.h:40
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
Definition: Overload.h:89
LambdaCaptureInitKind
Definition: DeclSpec.h:2827
@ CopyInit
[a = b], [a = {b}]
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ AANT_ArgumentIntegerConstant
Definition: ParsedAttr.h:1081
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:3568
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isFunctionOrMethodVariadic(const Decl *D)
Definition: Attr.h:112
TagUseKind
Definition: Sema.h:427
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
Definition: LangOptions.h:35
UnaryOperatorKind
ActionResult< Expr * > ExprResult
Definition: Ownership.h:248
TagTypeKind
The kind of a tag type.
Definition: Type.h:6695
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Definition: DeclTemplate.h:65
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:1065
@ TU_Complete
The translation unit is a complete translation unit.
Definition: LangOptions.h:1067
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:1071
ComparisonCategoryType
An enumeration representing the different comparison categories types.
PragmaMSStructKind
Definition: PragmaKinds.h:23
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:249
CXXSpecialMemberKind
Kinds of C++ special members.
Definition: Sema.h:403
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
Definition: TemplateKinds.h:20
@ TNK_Var_template
The name refers to a variable template whose specialization produces a variable.
Definition: TemplateKinds.h:33
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
Definition: TemplateKinds.h:30
@ TNK_Function_template
The name refers to a function template or a set of overloaded functions that includes at least one fu...
Definition: TemplateKinds.h:26
@ TNK_Concept_template
The name refers to a concept.
Definition: TemplateKinds.h:52
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
Definition: TemplateKinds.h:50
ActionResult< ParsedType > TypeResult
Definition: Ownership.h:250
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:22
PragmaFloatControlKind
Definition: PragmaKinds.h:28
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
const FunctionProtoType * T
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition: Specifiers.h:392
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
Definition: Attr.h:55
unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
Definition: Attr.h:64
TPOC
The context in which partial ordering of function templates occurs.
Definition: Template.h:298
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:216
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
TemplateDeductionResult
Describes the result of template argument deduction.
Definition: Sema.h:345
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
@ CUDATargetMismatch
CUDA Target attributes do not match.
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ Success
Template argument deduction was successful.
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:188
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:278
@ None
The alignment was not explicit in code.
SourceLocIdentKind
Definition: Expr.h:4748
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:6670
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DynamicNone
throw()
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition: Expr.h:1975
CheckedConversionKind
The kind of conversion being performed.
Definition: Sema.h:414
@ Implicit
An implicit conversion.
@ CStyleCast
A C-style cast.
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
@ OtherCast
A cast other than a C-style cast.
@ FunctionalCast
A functional-style cast.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:123
@ AS_none
Definition: Specifiers.h:127
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition: Specifiers.h:173
unsigned int uint32_t
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
#define true
Definition: stdbool.h:25
#define false
Definition: stdbool.h:26
#define bool
Definition: stdbool.h:24
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:89
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Describes whether we've seen any nullability information for the given file.
Definition: Sema.h:220
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition: Sema.h:227
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition: Sema.h:223
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition: Sema.h:233
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition: Sema.h:230
FunctionEffect::Kind EffectKind
Definition: Sema.h:445
bool shouldDiagnoseConversion(QualType SrcType, const FunctionEffectsRef &SrcFX, QualType DstType, const FunctionEffectsRef &DstFX) const
Return true if adding or removing the effect as part of a type conversion should generate a diagnosti...
Definition: Sema.cpp:2839
StringRef effectName() const
Definition: Sema.h:450
OverrideResult
Describes the result of effects differing between a base class's virtual method and an overriding met...
Definition: Sema.h:458
FunctionEffectWithCondition Old
Definition: Sema.h:447
OverrideResult shouldDiagnoseMethodOverride(const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX, const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const
Return true if adding or removing the effect in a C++ virtual method override should generate a diagn...
Definition: Sema.cpp:2903
FunctionEffectWithCondition New
Definition: Sema.h:448
bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction, const FunctionEffectsRef &OldFX, const FunctionDecl &NewFunction, const FunctionEffectsRef &NewFX) const
Return true if adding or removing the effect in a redeclaration should generate a diagnostic.
Definition: Sema.cpp:2877
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition: Type.h:4825
Holds information about the various types of exception specification.
Definition: Type.h:5064
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:5066
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:5069
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:5072
Extra information about a function prototype.
Definition: Type.h:5092
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:103
Represents a complete lambda introducer.
Definition: DeclSpec.h:2835
Contains a late templated function.
Definition: Sema.h:15075
CachedTokens Toks
Definition: Sema.h:15076
FPOptions FPO
Floating-point options in the point of definition.
Definition: Sema.h:15080
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:15078
A normalized constraint, as defined in C++ [temp.constr.normal], is either an atomic constraint,...
Definition: SemaConcept.h:106
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1695
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:12673
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:12834
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:12787
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:12803
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:12829
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:12822
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition: Sema.h:12798
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:12790
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition: Sema.h:12816
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition: Sema.h:12806
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:12813
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:12675
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition: Sema.h:12767
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition: Sema.h:12685
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition: Sema.h:12694
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:12713
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition: Sema.h:12764
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:12721
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition: Sema.h:12728
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition: Sema.h:12771
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:12739
@ Memoization
Added for Template instantiation observation.
Definition: Sema.h:12777
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition: Sema.h:12704
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition: Sema.h:12783
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition: Sema.h:12780
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:12701
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:12709
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:12717
@ TemplateInstantiation
We are instantiating a template declaration.
Definition: Sema.h:12678
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition: Sema.h:12731
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition: Sema.h:12735
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition: Sema.h:12690
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:12761
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition: Sema.h:12724
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:12793
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition: Sema.h:12819
ConstraintEvalRAII(InstTy &TI)
Definition: Sema.h:13341
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition: Sema.h:6390
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:6303
SmallVector< CXXBindTemporaryExpr *, 8 > DelayedDecltypeBinds
If we are processing a decltype type, a set of temporary binding expressions for which we have deferr...
Definition: Sema.h:6335
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition: Sema.h:6337
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:6327
SmallVector< CallExpr *, 8 > DelayedDecltypeCalls
If we are processing a decltype type, a set of call expressions for which we have deferred checking t...
Definition: Sema.h:6331
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition: Sema.h:6342
llvm::SmallPtrSet< DeclRefExpr *, 4 > ReferenceToConsteval
Set of DeclRefExprs referencing a consteval function when used in a context not already known to be i...
Definition: Sema.h:6350
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition: Sema.h:6346
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition: Sema.h:6356
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:6322
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:6360
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:6308
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:6316
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition: Sema.h:6400
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:6402
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:6305
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:6312
FormatArgumentPassingKind ArgPassingKind
Definition: Sema.h:2201
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:982
A stack object to be created when performing template instantiation.
Definition: Sema.h:12858
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:13012
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:13016
LocalInstantiationScope * Scope
Definition: Sema.h:13641
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:13644
bool isMoveEligible() const
Definition: Sema.h:10832
bool isCopyElidable() const
Definition: Sema.h:10833
const VarDecl * Candidate
Definition: Sema.h:10827
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2823
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition: Sema.h:2829
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:2838
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:2832
SourceLocation CCLoc
The location of the '::'.
Definition: Sema.h:2835
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition: Sema.h:2826
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:2844
SourceLocation LocEnd
Definition: Sema.h:7090
IdentifierInfo * IdentInfo
Definition: Sema.h:7093
brief A function argument from which we performed template argument
Definition: Sema.h:12262
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition: Sema.h:12263
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:1751
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:1754
A push'd group of PragmaAttributeEntries.
Definition: Sema.h:1759
SourceLocation Loc
The location of the push attribute.
Definition: Sema.h:1761
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition: Sema.h:1764
const IdentifierInfo * Namespace
The namespace of this push group.
Definition: Sema.h:1763
SourceLocation PragmaLocation
Definition: Sema.h:1473
PragmaMsStackAction Action
Definition: Sema.h:1493
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:1606
llvm::StringRef StackSlotLabel
Definition: Sema.h:1602
SourceLocation PragmaLocation
Definition: Sema.h:1604
SourceLocation PragmaPushLocation
Definition: Sema.h:1605
ValueType CurrentValue
Definition: Sema.h:1676
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:1662
bool hasValue() const
Definition: Sema.h:1672
SmallVector< Slot, 2 > Stack
Definition: Sema.h:1674
ValueType DefaultValue
Definition: Sema.h:1675
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1677
PragmaStack(const ValueType &Default)
Definition: Sema.h:1669
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition: Sema.h:1613
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition: Sema.h:4654
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition: Sema.h:4648
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition: Sema.h:10156
Abstract class used to diagnose incomplete types.
Definition: Sema.h:7887
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
virtual ~TypeDiagnoser()
Definition: Sema.h:7891
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:2250
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition: Sema.h:2259
std::unique_ptr< TypoCorrectionConsumer > Consumer
Definition: Sema.h:9516
TypoDiagnosticGenerator DiagHandler
Definition: Sema.h:9517
TypoRecoveryCallback RecoveryHandler
Definition: Sema.h:9518
bool CheckSameAsPrevious
Definition: Sema.h:331
NamedDecl * Previous
Definition: Sema.h:332
SkipBodyInfo()=default
NamedDecl * New
Definition: Sema.h:333
Information about a template-id annotation token.