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
19#include "clang/AST/ASTFwd.h"
20#include "clang/AST/Attr.h"
25#include "clang/AST/Expr.h"
26#include "clang/AST/ExprCXX.h"
28#include "clang/AST/ExprObjC.h"
32#include "clang/AST/NSAPI.h"
34#include "clang/AST/StmtCXX.h"
35#include "clang/AST/TypeLoc.h"
39#include "clang/Basic/Cuda.h"
43#include "clang/Basic/Module.h"
50#include "clang/Sema/Attr.h"
52#include "clang/Sema/DeclSpec.h"
58#include "clang/Sema/Scope.h"
59#include "clang/Sema/SemaBase.h"
63#include "clang/Sema/Weak.h"
64#include "llvm/ADT/ArrayRef.h"
65#include "llvm/ADT/STLForwardCompat.h"
66#include "llvm/ADT/SetVector.h"
67#include "llvm/ADT/SmallBitVector.h"
68#include "llvm/ADT/SmallPtrSet.h"
69#include "llvm/ADT/SmallSet.h"
70#include "llvm/ADT/SmallVector.h"
71#include "llvm/ADT/StringExtras.h"
72#include "llvm/ADT/TinyPtrVector.h"
73#include <deque>
74#include <memory>
75#include <optional>
76#include <string>
77#include <tuple>
78#include <vector>
79
80namespace llvm {
81class APSInt;
82template <typename ValueT, typename ValueInfoT> class DenseSet;
83class SmallBitVector;
84struct InlineAsmIdentifierInfo;
85} // namespace llvm
86
87namespace clang {
88class ADLResult;
89class ASTConsumer;
90class ASTContext;
91class ASTMutationListener;
92class ASTReader;
93class ASTWriter;
94class ArrayType;
95class ParsedAttr;
96class BindingDecl;
97class BlockDecl;
98class CapturedDecl;
99class CXXBasePath;
100class CXXBasePaths;
101class CXXBindTemporaryExpr;
103class CXXConstructorDecl;
104class CXXConversionDecl;
105class CXXDeleteExpr;
106class CXXDestructorDecl;
107class CXXFieldCollector;
108class CXXMemberCallExpr;
109class CXXMethodDecl;
110class CXXScopeSpec;
111class CXXTemporary;
112class CXXTryStmt;
113class CallExpr;
114class ClassTemplateDecl;
115class ClassTemplatePartialSpecializationDecl;
116class ClassTemplateSpecializationDecl;
117class VarTemplatePartialSpecializationDecl;
118class CodeCompleteConsumer;
119class CodeCompletionAllocator;
120class CodeCompletionTUInfo;
121class CodeCompletionResult;
122class CoroutineBodyStmt;
123class Decl;
124class DeclAccessPair;
125class DeclContext;
126class DeclRefExpr;
127class DeclaratorDecl;
128class DeducedTemplateArgument;
129class DependentDiagnostic;
130class DesignatedInitExpr;
131class Designation;
132class EnableIfAttr;
133class EnumConstantDecl;
134class Expr;
135class ExtVectorType;
136class FormatAttr;
137class FriendDecl;
138class FunctionDecl;
139class FunctionProtoType;
140class FunctionTemplateDecl;
141class ImplicitConversionSequence;
143class InitListExpr;
144class InitializationKind;
145class InitializationSequence;
146class InitializedEntity;
147class IntegerLiteral;
148class LabelStmt;
149class LambdaExpr;
150class LangOptions;
151class LocalInstantiationScope;
152class LookupResult;
153class MacroInfo;
155class ModuleLoader;
156class MultiLevelTemplateArgumentList;
157class NamedDecl;
158class ObjCImplementationDecl;
159class ObjCInterfaceDecl;
160class ObjCMethodDecl;
161class ObjCProtocolDecl;
162struct OverloadCandidate;
163enum class OverloadCandidateParamOrder : char;
165class OverloadCandidateSet;
166class OverloadExpr;
167class ParenListExpr;
168class ParmVarDecl;
169class Preprocessor;
170class PseudoDestructorTypeStorage;
171class PseudoObjectExpr;
172class QualType;
173class SemaAMDGPU;
174class SemaARM;
175class SemaAVR;
176class SemaBPF;
177class SemaCodeCompletion;
178class SemaCUDA;
179class SemaHLSL;
180class SemaHexagon;
181class SemaLoongArch;
182class SemaM68k;
183class SemaMIPS;
184class SemaMSP430;
185class SemaNVPTX;
186class SemaObjC;
187class SemaOpenACC;
188class SemaOpenCL;
189class SemaOpenMP;
190class SemaPPC;
191class SemaPseudoObject;
192class SemaRISCV;
193class SemaSYCL;
194class SemaSwift;
195class SemaSystemZ;
196class SemaWasm;
197class SemaX86;
198class StandardConversionSequence;
199class Stmt;
200class StringLiteral;
201class SwitchStmt;
202class TemplateArgument;
203class TemplateArgumentList;
204class TemplateArgumentLoc;
205class TemplateDecl;
206class TemplateInstantiationCallback;
207class TemplateParameterList;
208class TemplatePartialOrderingContext;
209class TemplateTemplateParmDecl;
210class Token;
211class TypeAliasDecl;
212class TypedefDecl;
213class TypedefNameDecl;
214class TypeLoc;
215class TypoCorrectionConsumer;
216class UnqualifiedId;
217class UnresolvedLookupExpr;
218class UnresolvedMemberExpr;
219class UnresolvedSetImpl;
220class UnresolvedSetIterator;
221class UsingDecl;
222class UsingShadowDecl;
223class ValueDecl;
224class VarDecl;
225class VarTemplateSpecializationDecl;
226class VisibilityAttr;
227class VisibleDeclConsumer;
228class IndirectFieldDecl;
229struct DeductionFailureInfo;
230class TemplateSpecCandidateSet;
231
232namespace sema {
233class AccessedEntity;
234class BlockScopeInfo;
235class Capture;
236class CapturedRegionScopeInfo;
237class CapturingScopeInfo;
238class CompoundScopeInfo;
239class DelayedDiagnostic;
240class DelayedDiagnosticPool;
241class FunctionScopeInfo;
242class LambdaScopeInfo;
243class PossiblyUnreachableDiag;
244class RISCVIntrinsicManager;
245class SemaPPCallbacks;
246class TemplateDeductionInfo;
247} // namespace sema
248
249namespace threadSafety {
250class BeforeSet;
251void threadSafetyCleanup(BeforeSet *Cache);
252} // namespace threadSafety
253
254// FIXME: No way to easily map from TemplateTypeParmTypes to
255// TemplateTypeParmDecls, so we have this horrible PointerUnion.
256typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *>,
257 SourceLocation>
259
260/// Describes whether we've seen any nullability information for the given
261/// file.
263 /// The first pointer declarator (of any pointer kind) in the file that does
264 /// not have a corresponding nullability annotation.
266
267 /// The end location for the first pointer declarator in the file. Used for
268 /// placing fix-its.
270
271 /// Which kind of pointer declarator we saw.
272 uint8_t PointerKind;
273
274 /// Whether we saw any type nullability annotations in the given file.
275 bool SawTypeNullability = false;
276};
277
278/// A mapping from file IDs to a record of whether we've seen nullability
279/// information in that file.
281 /// A mapping from file IDs to the nullability information for each file ID.
282 llvm::DenseMap<FileID, FileNullability> Map;
283
284 /// A single-element cache based on the file ID.
285 struct {
288 } Cache;
289
290public:
292 // Check the single-element cache.
293 if (file == Cache.File)
294 return Cache.Nullability;
295
296 // It's not in the single-element cache; flush the cache if we have one.
297 if (!Cache.File.isInvalid()) {
298 Map[Cache.File] = Cache.Nullability;
299 }
300
301 // Pull this entry into the cache.
302 Cache.File = file;
303 Cache.Nullability = Map[file];
304 return Cache.Nullability;
305 }
306};
307
308/// Tracks expected type during expression parsing, for use in code completion.
309/// The type is tied to a particular token, all functions that update or consume
310/// the type take a start location of the token they are looking at as a
311/// parameter. This avoids updating the type on hot paths in the parser.
313public:
314 PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {}
315
316 void enterCondition(Sema &S, SourceLocation Tok);
317 void enterReturn(Sema &S, SourceLocation Tok);
319 /// Handles e.g. BaseType{ .D = Tok...
321 const Designation &D);
322 /// Computing a type for the function argument may require running
323 /// overloading, so we postpone its computation until it is actually needed.
324 ///
325 /// Clients should be very careful when using this function, as it stores a
326 /// function_ref, clients should make sure all calls to get() with the same
327 /// location happen while function_ref is alive.
328 ///
329 /// The callback should also emit signature help as a side-effect, but only
330 /// if the completion point has been reached.
332 llvm::function_ref<QualType()> ComputeType);
333
335 void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
336 SourceLocation OpLoc);
337 void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
339 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
340 /// Handles all type casts, including C-style cast, C++ casts, etc.
342
343 /// Get the expected type associated with this location, if any.
344 ///
345 /// If the location is a function argument, determining the expected type
346 /// involves considering all function overloads and the arguments so far.
347 /// In this case, signature help for these function overloads will be reported
348 /// as a side-effect (only if the completion point has been reached).
350 if (!Enabled || Tok != ExpectedLoc)
351 return QualType();
352 if (!Type.isNull())
353 return Type;
354 if (ComputeType)
355 return ComputeType();
356 return QualType();
357 }
358
359private:
360 bool Enabled;
361 /// Start position of a token for which we store expected type.
362 SourceLocation ExpectedLoc;
363 /// Expected type for a token starting at ExpectedLoc.
365 /// A function to compute expected type at ExpectedLoc. It is only considered
366 /// if Type is null.
367 llvm::function_ref<QualType()> ComputeType;
368};
369
371 SkipBodyInfo() = default;
372 bool ShouldSkip = false;
374 NamedDecl *Previous = nullptr;
375 NamedDecl *New = nullptr;
376};
377
378/// Describes the result of template argument deduction.
379///
380/// The TemplateDeductionResult enumeration describes the result of
381/// template argument deduction, as returned from
382/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
383/// structure provides additional information about the results of
384/// template argument deduction, e.g., the deduced template argument
385/// list (if successful) or the specific template parameters or
386/// deduced arguments that were involved in the failure.
388 /// Template argument deduction was successful.
389 Success = 0,
390 /// The declaration was invalid; do nothing.
391 Invalid,
392 /// Template argument deduction exceeded the maximum template
393 /// instantiation depth (which has already been diagnosed).
395 /// Template argument deduction did not deduce a value
396 /// for every template parameter.
398 /// Template argument deduction did not deduce a value for every
399 /// expansion of an expanded template parameter pack.
401 /// Template argument deduction produced inconsistent
402 /// deduced values for the given template parameter.
404 /// Template argument deduction failed due to inconsistent
405 /// cv-qualifiers on a template parameter type that would
406 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
407 /// but were given a non-const "X".
409 /// Substitution of the deduced template argument values
410 /// resulted in an error.
412 /// After substituting deduced template arguments, a dependent
413 /// parameter type did not match the corresponding argument.
415 /// After substituting deduced template arguments, an element of
416 /// a dependent parameter type did not match the corresponding element
417 /// of the corresponding argument (when deducing from an initializer list).
419 /// A non-depnedent component of the parameter did not match the
420 /// corresponding component of the argument.
422 /// When performing template argument deduction for a function
423 /// template, there were too many call arguments.
425 /// When performing template argument deduction for a function
426 /// template, there were too few call arguments.
428 /// The explicitly-specified template arguments were not valid
429 /// template arguments for the given template.
431 /// Checking non-dependent argument conversions failed.
433 /// The deduced arguments did not satisfy the constraints associated
434 /// with the template.
436 /// Deduction failed; that's all we know.
438 /// CUDA Target attributes do not match.
440 /// Some error which was already diagnosed.
442};
443
444/// Kinds of C++ special members.
452 Invalid
453};
454
455/// The kind of conversion being performed.
457 /// An implicit conversion.
458 Implicit,
459 /// A C-style cast.
461 /// A functional-style cast.
463 /// A cast other than a C-style cast.
464 OtherCast,
465 /// A conversion for an operand of a builtin overloaded operator.
467};
468
469enum class TagUseKind {
470 Reference, // Reference to a tag: 'struct foo *X;'
471 Declaration, // Fwd decl of a tag: 'struct foo;'
472 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
473 Friend // Friend declaration: 'friend struct foo;'
474};
475
476/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
477enum class FunctionEffectMode : uint8_t {
478 None, // effect is not present.
479 False, // effect(false).
480 True, // effect(true).
481 Dependent // effect(expr) where expr is dependent.
482};
483
486
489 FunctionEffectWithCondition Old; // invalid when Added.
490 FunctionEffectWithCondition New; // invalid when Removed.
491
492 StringRef effectName() const {
494 return Old.Effect.name();
495 return New.Effect.name();
496 }
497
498 /// Describes the result of effects differing between a base class's virtual
499 /// method and an overriding method in a subclass.
500 enum class OverrideResult {
501 NoAction,
502 Warn,
503 Merge // Merge missing effect from base to derived.
504 };
505
506 /// Return true if adding or removing the effect as part of a type conversion
507 /// should generate a diagnostic.
509 const FunctionEffectsRef &SrcFX,
510 QualType DstType,
511 const FunctionEffectsRef &DstFX) const;
512
513 /// Return true if adding or removing the effect in a redeclaration should
514 /// generate a diagnostic.
515 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
516 const FunctionEffectsRef &OldFX,
517 const FunctionDecl &NewFunction,
518 const FunctionEffectsRef &NewFX) const;
519
520 /// Return true if adding or removing the effect in a C++ virtual method
521 /// override should generate a diagnostic.
523 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
524 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
525};
526
527struct FunctionEffectDifferences : public SmallVector<FunctionEffectDiff> {
528 /// Caller should short-circuit by checking for equality first.
530 const FunctionEffectsRef &New);
531};
532
533/// Sema - This implements semantic analysis and AST building for C.
534/// \nosubgrouping
535class Sema final : public SemaBase {
536 // Table of Contents
537 // -----------------
538 // 1. Semantic Analysis (Sema.cpp)
539 // 2. C++ Access Control (SemaAccess.cpp)
540 // 3. Attributes (SemaAttr.cpp)
541 // 4. Availability Attribute Handling (SemaAvailability.cpp)
542 // 5. Casts (SemaCast.cpp)
543 // 6. Extra Semantic Checking (SemaChecking.cpp)
544 // 7. C++ Coroutines (SemaCoroutine.cpp)
545 // 8. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
546 // 9. Declarations (SemaDecl.cpp)
547 // 10. Declaration Attribute Handling (SemaDeclAttr.cpp)
548 // 11. C++ Declarations (SemaDeclCXX.cpp)
549 // 12. C++ Exception Specifications (SemaExceptionSpec.cpp)
550 // 13. Expressions (SemaExpr.cpp)
551 // 14. C++ Expressions (SemaExprCXX.cpp)
552 // 15. Member Access Expressions (SemaExprMember.cpp)
553 // 16. Initializers (SemaInit.cpp)
554 // 17. C++ Lambda Expressions (SemaLambda.cpp)
555 // 18. Name Lookup (SemaLookup.cpp)
556 // 19. Modules (SemaModule.cpp)
557 // 20. C++ Overloading (SemaOverload.cpp)
558 // 21. Statements (SemaStmt.cpp)
559 // 22. `inline asm` Statement (SemaStmtAsm.cpp)
560 // 23. Statement Attribute Handling (SemaStmtAttr.cpp)
561 // 24. C++ Templates (SemaTemplate.cpp)
562 // 25. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
563 // 26. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
564 // 27. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
565 // 28. C++ Template Declaration Instantiation
566 // (SemaTemplateInstantiateDecl.cpp)
567 // 29. C++ Variadic Templates (SemaTemplateVariadic.cpp)
568 // 30. Constraints and Concepts (SemaConcept.cpp)
569 // 31. Types (SemaType.cpp)
570 // 32. FixIt Helpers (SemaFixItUtils.cpp)
571
572 /// \name Semantic Analysis
573 /// Implementations are in Sema.cpp
574 ///@{
575
576public:
577 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
579 CodeCompleteConsumer *CompletionConsumer = nullptr);
580 ~Sema();
581
582 /// Perform initialization that occurs after the parser has been
583 /// initialized but before it parses anything.
584 void Initialize();
585
586 /// This virtual key function only exists to limit the emission of debug info
587 /// describing the Sema class. GCC and Clang only emit debug info for a class
588 /// with a vtable when the vtable is emitted. Sema is final and not
589 /// polymorphic, but the debug info size savings are so significant that it is
590 /// worth adding a vtable just to take advantage of this optimization.
591 virtual void anchor();
592
593 const LangOptions &getLangOpts() const { return LangOpts; }
596
599 Preprocessor &getPreprocessor() const { return PP; }
600 ASTContext &getASTContext() const { return Context; }
604
606 StringRef Platform);
608
609 /// Registers an external source. If an external source already exists,
610 /// creates a multiplex external source and appends to it.
611 ///
612 ///\param[in] E - A non-null external sema source.
613 ///
615
616 /// Print out statistics about the semantic analysis.
617 void PrintStats() const;
618
619 /// Warn that the stack is nearly exhausted.
621
622 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
623 /// guaranteed). Produces a warning if we're low on stack space and allocates
624 /// more in that case. Use this in code that may recurse deeply (for example,
625 /// in template instantiation) to avoid stack overflow.
627 llvm::function_ref<void()> Fn);
628
629 /// Returns default addr space for method qualifiers.
631
632 /// Load weak undeclared identifiers from the external source.
634
635 /// Determine if VD, which must be a variable or function, is an external
636 /// symbol that nonetheless can't be referenced from outside this translation
637 /// unit because its type has no linkage and it's not extern "C".
638 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
639
640 /// Obtain a sorted list of functions that are undefined but ODR-used.
642 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
643
644 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
646 /// Retrieves list of suspicious delete-expressions that will be checked at
647 /// the end of translation unit.
648 const llvm::MapVector<FieldDecl *, DeleteLocs> &
650
651 /// Cause the active diagnostic on the DiagosticsEngine to be
652 /// emitted. This is closely coupled to the SemaDiagnosticBuilder class and
653 /// should not be used elsewhere.
654 void EmitCurrentDiagnostic(unsigned DiagID);
655
656 void addImplicitTypedef(StringRef Name, QualType T);
657
658 /// Whether uncompilable error has occurred. This includes error happens
659 /// in deferred diagnostics.
660 bool hasUncompilableErrorOccurred() const;
661
662 /// Looks through the macro-expansion chain for the given
663 /// location, looking for a macro expansion with the given name.
664 /// If one is found, returns true and sets the location to that
665 /// expansion loc.
666 bool findMacroSpelling(SourceLocation &loc, StringRef name);
667
668 /// Calls \c Lexer::getLocForEndOfToken()
670
671 /// Retrieve the module loader associated with the preprocessor.
673
674 /// Invent a new identifier for parameters of abbreviated templates.
677 unsigned Index);
678
680
681 // Emit all deferred diagnostics.
682 void emitDeferredDiags();
683
685 /// The global module fragment, between 'module;' and a module-declaration.
687 /// A normal translation unit fragment. For a non-module unit, this is the
688 /// entire translation unit. Otherwise, it runs from the module-declaration
689 /// to the private-module-fragment (if any) or the end of the TU (if not).
691 /// The private module fragment, between 'module :private;' and the end of
692 /// the translation unit.
693 Private
694 };
695
696 /// This is called before the very first declaration in the translation unit
697 /// is parsed. Note that the ASTContext may have already injected some
698 /// declarations.
700 /// ActOnEndOfTranslationUnit - This is called at the very end of the
701 /// translation unit when EOF is reached and all but the top-level scope is
702 /// popped.
705
706 /// Determines the active Scope associated with the given declaration
707 /// context.
708 ///
709 /// This routine maps a declaration context to the active Scope object that
710 /// represents that declaration context in the parser. It is typically used
711 /// from "scope-less" code (e.g., template instantiation, lazy creation of
712 /// declarations) that injects a name for name-lookup purposes and, therefore,
713 /// must update the Scope.
714 ///
715 /// \returns The scope corresponding to the given declaraion context, or NULL
716 /// if no such scope is open.
718
719 void PushFunctionScope();
720 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
722
723 /// This is used to inform Sema what the current TemplateParameterDepth
724 /// is during Parsing. Currently it is used to pass on the depth
725 /// when parsing generic lambda 'auto' parameters.
726 void RecordParsingTemplateParameterDepth(unsigned Depth);
727
728 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
730 unsigned OpenMPCaptureLevel = 0);
731
732 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
733 /// time after they've been popped.
735 Sema *Self;
736
737 public:
738 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
740 };
741
743 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
744
745 /// Pop a function (or block or lambda or captured region) scope from the
746 /// stack.
747 ///
748 /// \param WP The warning policy to use for CFG-based warnings, or null if
749 /// such warnings should not be produced.
750 /// \param D The declaration corresponding to this function scope, if
751 /// producing CFG-based warnings.
752 /// \param BlockType The type of the block expression, if D is a BlockDecl.
755 const Decl *D = nullptr,
756 QualType BlockType = QualType());
757
759
764
765 void PushCompoundScope(bool IsStmtExpr);
766 void PopCompoundScope();
767
768 /// Determine whether any errors occurred within this function/method/
769 /// block.
771
772 /// Retrieve the current block, if any.
774
775 /// Get the innermost lambda enclosing the current location, if any. This
776 /// looks through intervening non-lambda scopes such as local functions and
777 /// blocks.
779
780 /// Retrieve the current lambda scope info, if any.
781 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
782 /// lambda scope info ignoring all inner capturing scopes that are not
783 /// lambda scopes.
785 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
786
787 /// Retrieve the current generic lambda info, if any.
789
790 /// Retrieve the current captured region, if any.
792
793 void ActOnComment(SourceRange Comment);
794
795 /// Retrieve the parser's current scope.
796 ///
797 /// This routine must only be used when it is certain that semantic analysis
798 /// and the parser are in precisely the same context, which is not the case
799 /// when, e.g., we are performing any kind of template instantiation.
800 /// Therefore, the only safe places to use this scope are in the parser
801 /// itself and in routines directly invoked from the parser and *never* from
802 /// template substitution or instantiation.
803 Scope *getCurScope() const { return CurScope; }
804
806
809 }
810
811 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
812 const FunctionDecl *FD = nullptr);
814 const PartialDiagnostic &PD,
815 const FunctionDecl *FD = nullptr) {
816 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
817 }
818
819 /// Check if the type is allowed to be used for the current target.
821 ValueDecl *D = nullptr);
822
823 // /// The kind of conversion being performed.
824 // enum CheckedConversionKind {
825 // /// An implicit conversion.
826 // CCK_ImplicitConversion,
827 // /// A C-style cast.
828 // CCK_CStyleCast,
829 // /// A functional-style cast.
830 // CCK_FunctionalCast,
831 // /// A cast other than a C-style cast.
832 // CCK_OtherCast,
833 // /// A conversion for an operand of a builtin overloaded operator.
834 // CCK_ForBuiltinOverloadedOp
835 // };
836
837 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
838 /// cast. If there is already an implicit cast, merge into the existing one.
839 /// If isLvalue, the result of the cast is an lvalue.
842 const CXXCastPath *BasePath = nullptr,
844
845 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
846 /// to the conversion from scalar type ScalarTy to the Boolean type.
848
849 /// If \p AllowLambda is true, treat lambda as function.
850 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
851
852 /// Returns a pointer to the innermost enclosing function, or nullptr if the
853 /// current context is not inside a function. If \p AllowLambda is true,
854 /// this can return the call operator of an enclosing lambda, otherwise
855 /// lambdas are skipped when looking for an enclosing function.
856 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
857
858 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
859 /// the method decl for the method being parsed. If we're currently
860 /// in a 'block', this returns the containing context.
862
863 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
864 /// or C function we're in, otherwise return null. If we're currently
865 /// in a 'block', this returns the containing context.
867
868 /// Warn if we're implicitly casting from a _Nullable pointer type to a
869 /// _Nonnull one.
872
873 /// Warn when implicitly casting 0 to nullptr.
875
876 // ----- function effects ---
877
878 /// Warn when implicitly changing function effects.
881
882 /// Warn and return true if adding an effect to a set would create a conflict.
885 SourceLocation NewAttrLoc);
886
887 // Report a failure to merge function effects between declarations due to a
888 // conflict.
889 void
891 SourceLocation NewLoc,
892 SourceLocation OldLoc);
893
894 /// Try to parse the conditional expression attached to an effect attribute
895 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
896 /// optional on error.
897 std::optional<FunctionEffectMode>
898 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
899
900 /// makeUnavailableInSystemHeader - There is an error in the current
901 /// context. If we're still in a system header, and we can plausibly
902 /// make the relevant declaration unavailable instead of erroring, do
903 /// so and return true.
905 UnavailableAttr::ImplicitReason reason);
906
907 /// Retrieve a suitable printing policy for diagnostics.
910 }
911
912 /// Retrieve a suitable printing policy for diagnostics.
914 const Preprocessor &PP);
915
916 /// Scope actions.
918
919 /// Determine whether \param D is function like (function or function
920 /// template) for parsing.
922
923 /// The maximum alignment, same as in llvm::Value. We duplicate them here
924 /// because that allows us not to duplicate the constants in clang code,
925 /// which we must to since we can't directly use the llvm constants.
926 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
927 ///
928 /// This is the greatest alignment value supported by load, store, and alloca
929 /// instructions, and global values.
930 static const unsigned MaxAlignmentExponent = 32;
931 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
932
933 /// Flag indicating whether or not to collect detailed statistics.
935
936 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
937
938 /// Stack containing information about each of the nested
939 /// function, block, and method scopes that are currently active.
941
942 /// The index of the first FunctionScope that corresponds to the current
943 /// context.
945
946 /// Track the number of currently active capturing scopes.
948
949 llvm::BumpPtrAllocator BumpAlloc;
950
951 /// The kind of translation unit we are processing.
952 ///
953 /// When we're processing a complete translation unit, Sema will perform
954 /// end-of-translation-unit semantic tasks (such as creating
955 /// initializers for tentative definitions in C) once parsing has
956 /// completed. Modules and precompiled headers perform different kinds of
957 /// checks.
959
960 /// Translation Unit Scope - useful to Objective-C actions that need
961 /// to lookup file scope declarations in the "ordinary" C decl namespace.
962 /// For example, user-defined classes, built-in "id" type, etc.
964
966
968 return CurScope->incrementMSManglingNumber();
969 }
970
971 /// Try to recover by turning the given expression into a
972 /// call. Returns true if recovery was attempted or an error was
973 /// emitted; this may also leave the ExprResult invalid.
975 bool ForceComplain = false,
976 bool (*IsPlausibleResult)(QualType) = nullptr);
977
978 /// Figure out if an expression could be turned into a call.
979 ///
980 /// Use this when trying to recover from an error where the programmer may
981 /// have written just the name of a function instead of actually calling it.
982 ///
983 /// \param E - The expression to examine.
984 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
985 /// with no arguments, this parameter is set to the type returned by such a
986 /// call; otherwise, it is set to an empty QualType.
987 /// \param OverloadSet - If the expression is an overloaded function
988 /// name, this parameter is populated with the decls of the various
989 /// overloads.
990 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
991 UnresolvedSetImpl &NonTemplateOverloads);
992
996
999
1007
1008 /// A RAII object to enter scope of a compound statement.
1010 public:
1011 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
1012 S.ActOnStartOfCompoundStmt(IsStmtExpr);
1013 }
1014
1016
1017 private:
1018 Sema &S;
1019 };
1020
1021 /// An RAII helper that pops function a function scope on exit.
1027 if (Active)
1029 }
1030 void disable() { Active = false; }
1031 };
1032
1034 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
1035 }
1036
1037 /// Worker object for performing CFG-based warnings.
1040
1041 /// Callback to the parser to parse templated functions when needed.
1042 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
1043 typedef void LateTemplateParserCleanupCB(void *P);
1047
1049 LateTemplateParserCleanupCB *LTPCleanup, void *P) {
1050 LateTemplateParser = LTP;
1051 LateTemplateParserCleanup = LTPCleanup;
1052 OpaqueParser = P;
1053 }
1054
1055 /// Callback to the parser to parse a type expressed as a string.
1056 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
1058
1059 /// VAListTagName - The declaration name corresponding to __va_list_tag.
1060 /// This is used as part of a hack to omit that class from ADL results.
1062
1063 /// Is the last error level diagnostic immediate. This is used to determined
1064 /// whether the next info diagnostic should be immediate.
1066
1067 class DelayedDiagnostics;
1068
1070 sema::DelayedDiagnosticPool *SavedPool = nullptr;
1072 };
1075
1076 /// A class which encapsulates the logic for delaying diagnostics
1077 /// during parsing and other processing.
1079 /// The current pool of diagnostics into which delayed
1080 /// diagnostics should go.
1081 sema::DelayedDiagnosticPool *CurPool = nullptr;
1082
1083 public:
1085
1086 /// Adds a delayed diagnostic.
1087 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
1088
1089 /// Determines whether diagnostics should be delayed.
1090 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
1091
1092 /// Returns the current delayed-diagnostics pool.
1093 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1094
1095 /// Enter a new scope. Access and deprecation diagnostics will be
1096 /// collected in this pool.
1099 state.SavedPool = CurPool;
1100 CurPool = &pool;
1101 return state;
1102 }
1103
1104 /// Leave a delayed-diagnostic state that was previously pushed.
1105 /// Do not emit any of the diagnostics. This is performed as part
1106 /// of the bookkeeping of popping a pool "properly".
1108 CurPool = state.SavedPool;
1109 }
1110
1111 /// Enter a new scope where access and deprecation diagnostics are
1112 /// not delayed.
1115 state.SavedPool = CurPool;
1116 CurPool = nullptr;
1117 return state;
1118 }
1119
1120 /// Undo a previous pushUndelayed().
1122 assert(CurPool == nullptr);
1123 CurPool = state.SavedPool;
1124 }
1125 } DelayedDiagnostics;
1126
1128 return DelayedDiagnostics.push(pool);
1129 }
1130
1131 /// Diagnostics that are emitted only if we discover that the given function
1132 /// must be codegen'ed. Because handling these correctly adds overhead to
1133 /// compilation, this is currently only enabled for CUDA compilations.
1134 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1135
1136 /// CurContext - This is the current declaration context of parsing.
1138
1140 assert(AMDGPUPtr);
1141 return *AMDGPUPtr;
1142 }
1143
1145 assert(ARMPtr);
1146 return *ARMPtr;
1147 }
1148
1150 assert(AVRPtr);
1151 return *AVRPtr;
1152 }
1153
1155 assert(BPFPtr);
1156 return *BPFPtr;
1157 }
1158
1160 assert(CodeCompletionPtr);
1161 return *CodeCompletionPtr;
1162 }
1163
1165 assert(CUDAPtr);
1166 return *CUDAPtr;
1167 }
1168
1170 assert(HLSLPtr);
1171 return *HLSLPtr;
1172 }
1173
1175 assert(HexagonPtr);
1176 return *HexagonPtr;
1177 }
1178
1180 assert(LoongArchPtr);
1181 return *LoongArchPtr;
1182 }
1183
1185 assert(M68kPtr);
1186 return *M68kPtr;
1187 }
1188
1190 assert(MIPSPtr);
1191 return *MIPSPtr;
1192 }
1193
1195 assert(MSP430Ptr);
1196 return *MSP430Ptr;
1197 }
1198
1200 assert(NVPTXPtr);
1201 return *NVPTXPtr;
1202 }
1203
1205 assert(ObjCPtr);
1206 return *ObjCPtr;
1207 }
1208
1210 assert(OpenACCPtr);
1211 return *OpenACCPtr;
1212 }
1213
1215 assert(OpenCLPtr);
1216 return *OpenCLPtr;
1217 }
1218
1220 assert(OpenMPPtr && "SemaOpenMP is dead");
1221 return *OpenMPPtr;
1222 }
1223
1225 assert(PPCPtr);
1226 return *PPCPtr;
1227 }
1228
1230 assert(PseudoObjectPtr);
1231 return *PseudoObjectPtr;
1232 }
1233
1235 assert(RISCVPtr);
1236 return *RISCVPtr;
1237 }
1238
1240 assert(SYCLPtr);
1241 return *SYCLPtr;
1242 }
1243
1245 assert(SwiftPtr);
1246 return *SwiftPtr;
1247 }
1248
1250 assert(SystemZPtr);
1251 return *SystemZPtr;
1252 }
1253
1255 assert(WasmPtr);
1256 return *WasmPtr;
1257 }
1258
1260 assert(X86Ptr);
1261 return *X86Ptr;
1262 }
1263
1264 /// Source of additional semantic information.
1266
1267protected:
1268 friend class Parser;
1270 friend class ASTReader;
1271 friend class ASTDeclReader;
1272 friend class ASTWriter;
1273
1274private:
1275 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1276 bool WarnedDarwinSDKInfoMissing = false;
1277
1278 Sema(const Sema &) = delete;
1279 void operator=(const Sema &) = delete;
1280
1281 /// The handler for the FileChanged preprocessor events.
1282 ///
1283 /// Used for diagnostics that implement custom semantic analysis for #include
1284 /// directives, like -Wpragma-pack.
1285 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1286
1287 /// The parser's current scope.
1288 ///
1289 /// The parser maintains this state here.
1290 Scope *CurScope;
1291
1292 mutable IdentifierInfo *Ident_super;
1293
1294 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1295 std::unique_ptr<SemaARM> ARMPtr;
1296 std::unique_ptr<SemaAVR> AVRPtr;
1297 std::unique_ptr<SemaBPF> BPFPtr;
1298 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1299 std::unique_ptr<SemaCUDA> CUDAPtr;
1300 std::unique_ptr<SemaHLSL> HLSLPtr;
1301 std::unique_ptr<SemaHexagon> HexagonPtr;
1302 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1303 std::unique_ptr<SemaM68k> M68kPtr;
1304 std::unique_ptr<SemaMIPS> MIPSPtr;
1305 std::unique_ptr<SemaMSP430> MSP430Ptr;
1306 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1307 std::unique_ptr<SemaObjC> ObjCPtr;
1308 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1309 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1310 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1311 std::unique_ptr<SemaPPC> PPCPtr;
1312 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1313 std::unique_ptr<SemaRISCV> RISCVPtr;
1314 std::unique_ptr<SemaSYCL> SYCLPtr;
1315 std::unique_ptr<SemaSwift> SwiftPtr;
1316 std::unique_ptr<SemaSystemZ> SystemZPtr;
1317 std::unique_ptr<SemaWasm> WasmPtr;
1318 std::unique_ptr<SemaX86> X86Ptr;
1319
1320 ///@}
1321
1322 //
1323 //
1324 // -------------------------------------------------------------------------
1325 //
1326 //
1327
1328 /// \name C++ Access Control
1329 /// Implementations are in SemaAccess.cpp
1330 ///@{
1331
1332public:
1339
1340 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1341 /// Returns true on error (when the previous member decl access specifier
1342 /// is different from the new member decl access specifier).
1343 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1344 NamedDecl *PrevMemberDecl,
1345 AccessSpecifier LexicalAS);
1346
1347 /// Perform access-control checking on a previously-unresolved member
1348 /// access which has now been resolved to a member.
1350 DeclAccessPair FoundDecl);
1352 DeclAccessPair FoundDecl);
1353
1354 /// Checks access to an overloaded operator new or delete.
1356 SourceRange PlacementRange,
1357 CXXRecordDecl *NamingClass,
1358 DeclAccessPair FoundDecl,
1359 bool Diagnose = true);
1360
1361 /// Checks access to a constructor.
1363 DeclAccessPair FoundDecl,
1364 const InitializedEntity &Entity,
1365 bool IsCopyBindingRefToTemp = false);
1366
1367 /// Checks access to a constructor.
1369 DeclAccessPair FoundDecl,
1370 const InitializedEntity &Entity,
1371 const PartialDiagnostic &PDiag);
1373 CXXDestructorDecl *Dtor,
1374 const PartialDiagnostic &PDiag,
1375 QualType objectType = QualType());
1376
1377 /// Checks access to the target of a friend declaration.
1379
1380 /// Checks access to a member.
1382 CXXRecordDecl *NamingClass,
1384
1385 /// Checks implicit access to a member in a structured binding.
1388 CXXRecordDecl *DecomposedClass,
1389 DeclAccessPair Field);
1391 const SourceRange &,
1392 DeclAccessPair FoundDecl);
1393
1394 /// Checks access to an overloaded member operator, including
1395 /// conversion operators.
1397 Expr *ArgExpr,
1398 DeclAccessPair FoundDecl);
1400 ArrayRef<Expr *> ArgExprs,
1401 DeclAccessPair FoundDecl);
1403 DeclAccessPair FoundDecl);
1404
1405 /// Checks access for a hierarchy conversion.
1406 ///
1407 /// \param ForceCheck true if this check should be performed even if access
1408 /// control is disabled; some things rely on this for semantics
1409 /// \param ForceUnprivileged true if this check should proceed as if the
1410 /// context had no special privileges
1412 QualType Derived, const CXXBasePath &Path,
1413 unsigned DiagID, bool ForceCheck = false,
1414 bool ForceUnprivileged = false);
1415
1416 /// Checks access to all the declarations in the given result set.
1417 void CheckLookupAccess(const LookupResult &R);
1418
1419 /// Checks access to Target from the given class. The check will take access
1420 /// specifiers into account, but no member access expressions and such.
1421 ///
1422 /// \param Target the declaration to check if it can be accessed
1423 /// \param NamingClass the class in which the lookup was started.
1424 /// \param BaseType type of the left side of member access expression.
1425 /// \p BaseType and \p NamingClass are used for C++ access control.
1426 /// Depending on the lookup case, they should be set to the following:
1427 /// - lhs.target (member access without a qualifier):
1428 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1429 /// - lhs.X::target (member access with a qualifier):
1430 /// BaseType is the type of 'lhs', NamingClass is 'X'
1431 /// - X::target (qualified lookup without member access):
1432 /// BaseType is null, NamingClass is 'X'.
1433 /// - target (unqualified lookup).
1434 /// BaseType is null, NamingClass is the parent class of 'target'.
1435 /// \return true if the Target is accessible from the Class, false otherwise.
1436 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1437 QualType BaseType);
1438
1439 /// Is the given member accessible for the purposes of deciding whether to
1440 /// define a special member function as deleted?
1442 DeclAccessPair Found, QualType ObjectType,
1444 const PartialDiagnostic &Diag);
1447 QualType ObjectType) {
1448 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1449 SourceLocation(), PDiag());
1450 }
1451
1453 const DependentDiagnostic &DD,
1454 const MultiLevelTemplateArgumentList &TemplateArgs);
1456
1457 ///@}
1458
1459 //
1460 //
1461 // -------------------------------------------------------------------------
1462 //
1463 //
1464
1465 /// \name Attributes
1466 /// Implementations are in SemaAttr.cpp
1467 ///@{
1468
1469public:
1470 /// Controls member pointer representation format under the MS ABI.
1473
1474 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1475
1476 /// Source location for newly created implicit MSInheritanceAttrs
1478
1479 /// pragma clang section kind
1486 PCSK_Relro = 5
1488
1490
1492 std::string SectionName;
1493 bool Valid = false;
1495 };
1496
1502
1504 PSK_Reset = 0x0, // #pragma ()
1505 PSK_Set = 0x1, // #pragma (value)
1506 PSK_Push = 0x2, // #pragma (push[, id])
1507 PSK_Pop = 0x4, // #pragma (pop[, id])
1508 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1509 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1510 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1511 };
1512
1515 StringRef SlotLabel;
1517 };
1518
1519 // #pragma pack and align.
1521 public:
1522 // `Native` represents default align mode, which may vary based on the
1523 // platform.
1524 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1525
1526 // #pragma pack info constructor
1527 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1528 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1529 assert(Num == PackNumber && "The pack number has been truncated.");
1530 }
1531
1532 // #pragma align info constructor
1534 : PackAttr(false), AlignMode(M),
1535 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1536
1537 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1538
1540
1541 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1542 // integer encoding for it. This should only be passed to
1543 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1544 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1545 std::uint32_t Encoding{};
1546 if (Info.IsXLStack())
1547 Encoding |= IsXLMask;
1548
1549 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1550
1551 if (Info.IsPackAttr())
1552 Encoding |= PackAttrMask;
1553
1554 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1555
1556 return Encoding;
1557 }
1558
1559 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1560 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1562 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1563 int PackNumber = (Encoding & PackNumMask) >> 4;
1564
1565 if (Encoding & PackAttrMask)
1566 return AlignPackInfo(M, PackNumber, IsXL);
1567
1568 return AlignPackInfo(M, IsXL);
1569 }
1570
1571 bool IsPackAttr() const { return PackAttr; }
1572
1573 bool IsAlignAttr() const { return !PackAttr; }
1574
1575 Mode getAlignMode() const { return AlignMode; }
1576
1577 unsigned getPackNumber() const { return PackNumber; }
1578
1579 bool IsPackSet() const {
1580 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1581 // attriute on a decl.
1582 return PackNumber != UninitPackVal && PackNumber != 0;
1583 }
1584
1585 bool IsXLStack() const { return XLStack; }
1586
1587 bool operator==(const AlignPackInfo &Info) const {
1588 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1589 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1590 Info.XLStack);
1591 }
1592
1593 bool operator!=(const AlignPackInfo &Info) const {
1594 return !(*this == Info);
1595 }
1596
1597 private:
1598 /// \brief True if this is a pragma pack attribute,
1599 /// not a pragma align attribute.
1600 bool PackAttr;
1601
1602 /// \brief The alignment mode that is in effect.
1603 Mode AlignMode;
1604
1605 /// \brief The pack number of the stack.
1606 unsigned char PackNumber;
1607
1608 /// \brief True if it is a XL #pragma align/pack stack.
1609 bool XLStack;
1610
1611 /// \brief Uninitialized pack value.
1612 static constexpr unsigned char UninitPackVal = -1;
1613
1614 // Masks to encode and decode an AlignPackInfo.
1615 static constexpr uint32_t IsXLMask{0x0000'0001};
1616 static constexpr uint32_t AlignModeMask{0x0000'0006};
1617 static constexpr uint32_t PackAttrMask{0x00000'0008};
1618 static constexpr uint32_t PackNumMask{0x0000'01F0};
1619 };
1620
1621 template <typename ValueType> struct PragmaStack {
1622 struct Slot {
1623 llvm::StringRef StackSlotLabel;
1624 ValueType Value;
1627 Slot(llvm::StringRef StackSlotLabel, ValueType Value,
1632 };
1633
1634 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1635 llvm::StringRef StackSlotLabel, ValueType Value) {
1636 if (Action == PSK_Reset) {
1638 CurrentPragmaLocation = PragmaLocation;
1639 return;
1640 }
1641 if (Action & PSK_Push)
1642 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1643 PragmaLocation);
1644 else if (Action & PSK_Pop) {
1645 if (!StackSlotLabel.empty()) {
1646 // If we've got a label, try to find it and jump there.
1647 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1648 return x.StackSlotLabel == StackSlotLabel;
1649 });
1650 // If we found the label so pop from there.
1651 if (I != Stack.rend()) {
1652 CurrentValue = I->Value;
1653 CurrentPragmaLocation = I->PragmaLocation;
1654 Stack.erase(std::prev(I.base()), Stack.end());
1655 }
1656 } else if (!Stack.empty()) {
1657 // We do not have a label, just pop the last entry.
1658 CurrentValue = Stack.back().Value;
1659 CurrentPragmaLocation = Stack.back().PragmaLocation;
1660 Stack.pop_back();
1661 }
1662 }
1663 if (Action & PSK_Set) {
1665 CurrentPragmaLocation = PragmaLocation;
1666 }
1667 }
1668
1669 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1670 // method body to restore the stacks on exit, so it works like this:
1671 //
1672 // struct S {
1673 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1674 // void Method {}
1675 // #pragma <name>(pop, InternalPragmaSlot)
1676 // };
1677 //
1678 // It works even with #pragma vtordisp, although MSVC doesn't support
1679 // #pragma vtordisp(push [, id], n)
1680 // syntax.
1681 //
1682 // Push / pop a named sentinel slot.
1683 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
1684 assert((Action == PSK_Push || Action == PSK_Pop) &&
1685 "Can only push / pop #pragma stack sentinels!");
1687 }
1688
1689 // Constructors.
1690 explicit PragmaStack(const ValueType &Default)
1692
1693 bool hasValue() const { return CurrentValue != DefaultValue; }
1694
1696 ValueType DefaultValue; // Value used for PSK_Reset action.
1697 ValueType CurrentValue;
1699 };
1700 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
1701 // we shouldn't do so if they're in a module).
1702
1703 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
1704 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
1705 ///
1706 /// 0: Suppress all vtordisps
1707 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
1708 /// structors
1709 /// 2: Always insert vtordisps to support RTTI on partially constructed
1710 /// objects
1713 // The current #pragma align/pack values and locations at each #include.
1718 };
1720 // Segment #pragmas.
1725
1726 // #pragma strict_gs_check.
1728
1729 // This stack tracks the current state of Sema.CurFPFeatures.
1732 FPOptionsOverride result;
1733 if (!FpPragmaStack.hasValue()) {
1734 result = FPOptionsOverride();
1735 } else {
1736 result = FpPragmaStack.CurrentValue;
1737 }
1738 return result;
1739 }
1740
1746 };
1747
1748 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
1749 // Actions should be performed only if we enter / exit a C++ method body.
1751 public:
1752 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
1754
1755 private:
1756 Sema &S;
1757 StringRef SlotLabel;
1758 bool ShouldAct;
1759 };
1760
1761 /// Last section used with #pragma init_seg.
1764
1765 /// Sections used with #pragma alloc_text.
1766 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
1767
1768 /// VisContext - Manages the stack for \#pragma GCC visibility.
1769 void *VisContext; // Really a "PragmaVisStack*"
1770
1771 /// This an attribute introduced by \#pragma clang attribute.
1777 };
1778
1779 /// A push'd group of PragmaAttributeEntries.
1781 /// The location of the push attribute.
1783 /// The namespace of this push group.
1786 };
1787
1789
1790 /// The declaration that is currently receiving an attribute from the
1791 /// #pragma attribute stack.
1793
1794 /// This represents the last location of a "#pragma clang optimize off"
1795 /// directive if such a directive has not been closed by an "on" yet. If
1796 /// optimizations are currently "on", this is set to an invalid location.
1798
1799 /// Get the location for the currently active "\#pragma clang optimize
1800 /// off". If this location is invalid, then the state of the pragma is "on".
1803 }
1804
1805 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
1806 /// whether the optimizations in the list passed to the pragma should be
1807 /// turned off or on. This boolean is true by default because command line
1808 /// options are honored when `#pragma optimize("", on)`.
1809 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
1811
1812 /// Set of no-builtin functions listed by \#pragma function.
1814
1815 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
1816 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
1818
1819 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
1821
1822 /// Add gsl::Pointer attribute to std::container::iterator
1823 /// \param ND The declaration that introduces the name
1824 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
1825 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
1826
1827 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
1829
1830 /// Add [[gsl::Pointer]] attributes for std:: types.
1832
1833 /// Add _Nullable attributes for std:: types.
1835
1837 POAK_Native, // #pragma options align=native
1838 POAK_Natural, // #pragma options align=natural
1839 POAK_Packed, // #pragma options align=packed
1840 POAK_Power, // #pragma options align=power
1841 POAK_Mac68k, // #pragma options align=mac68k
1842 POAK_Reset // #pragma options align=reset
1844
1845 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
1848 PragmaClangSectionKind SecKind,
1849 StringRef SecName);
1850
1851 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
1853 SourceLocation PragmaLoc);
1854
1855 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
1856 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
1857 StringRef SlotLabel, Expr *Alignment);
1858
1859 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
1860 /// (unless they are value dependent or type dependent). Returns false
1861 /// and emits a diagnostic if one or more of the arguments could not be
1862 /// folded into a constant.
1865
1869 };
1870
1872 SourceLocation IncludeLoc);
1874
1875 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
1877
1878 /// ActOnPragmaMSComment - Called on well formed
1879 /// \#pragma comment(kind, "arg").
1881 StringRef Arg);
1882
1883 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
1884 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
1885 StringRef Value);
1886
1887 /// Are precise floating point semantics currently enabled?
1889 return !CurFPFeatures.getAllowFPReassociate() &&
1890 !CurFPFeatures.getNoSignedZero() &&
1891 !CurFPFeatures.getAllowReciprocal() &&
1892 !CurFPFeatures.getAllowApproxFunc();
1893 }
1894
1897
1898 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
1901
1902 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
1903 /// pointers_to_members(representation method[, general purpose
1904 /// representation]).
1907 SourceLocation PragmaLoc);
1908
1909 /// Called on well formed \#pragma vtordisp().
1912
1913 bool UnifySection(StringRef SectionName, int SectionFlags,
1914 NamedDecl *TheDecl);
1915 bool UnifySection(StringRef SectionName, int SectionFlags,
1916 SourceLocation PragmaSectionLocation);
1917
1918 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
1919 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
1920 PragmaMsStackAction Action,
1921 llvm::StringRef StackSlotLabel,
1922 StringLiteral *SegmentName, llvm::StringRef PragmaName);
1923
1924 /// Called on well formed \#pragma section().
1925 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
1926 StringLiteral *SegmentName);
1927
1928 /// Called on well-formed \#pragma init_seg().
1929 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
1930 StringLiteral *SegmentName);
1931
1932 /// Called on well-formed \#pragma alloc_text().
1934 SourceLocation PragmaLocation, StringRef Section,
1935 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
1936 &Functions);
1937
1938 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
1939 /// strict_gs_check.
1941 PragmaMsStackAction Action,
1942 bool Value);
1943
1944 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
1945 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
1946 SourceLocation PragmaLoc);
1947
1949 SourceLocation PragmaLoc,
1952 const IdentifierInfo *Namespace);
1953
1954 /// Called on well-formed '\#pragma clang attribute pop'.
1956 const IdentifierInfo *Namespace);
1957
1958 /// Adds the attributes that have been specified using the
1959 /// '\#pragma clang attribute push' directives to the given declaration.
1960 void AddPragmaAttributes(Scope *S, Decl *D);
1961
1963
1965
1966 /// Called on well formed \#pragma clang optimize.
1967 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
1968
1969 /// #pragma optimize("[optimization-list]", on | off).
1970 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
1971
1972 /// Call on well formed \#pragma function.
1973 void
1975 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
1976
1977 /// Only called on function definitions; if there is a pragma in scope
1978 /// with the effect of a range-based optnone, consider marking the function
1979 /// with attribute optnone.
1981
1982 /// Only called on function definitions; if there is a `#pragma alloc_text`
1983 /// that decides which code section the function should be in, add
1984 /// attribute section to the function.
1986
1987 /// Adds the 'optnone' attribute to the function declaration if there
1988 /// are no conflicts; Loc represents the location causing the 'optnone'
1989 /// attribute to be added (usually because of a pragma).
1991
1992 /// Only called on function definitions; if there is a MSVC #pragma optimize
1993 /// in scope, consider changing the function's attributes based on the
1994 /// optimization list passed to the pragma.
1996
1997 /// Only called on function definitions; if there is a pragma in scope
1998 /// with the effect of a range-based no_builtin, consider marking the function
1999 /// with attribute no_builtin.
2001
2002 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
2003 /// add an appropriate visibility attribute.
2005
2006 /// FreeVisContext - Deallocate and null out VisContext.
2007 void FreeVisContext();
2008
2009 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
2010 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
2011 SourceLocation PragmaLoc);
2012
2013 /// ActOnPragmaFPContract - Called on well formed
2014 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
2015 /// \#pragma clang fp contract
2017
2018 /// Called on well formed
2019 /// \#pragma clang fp reassociate
2020 /// or
2021 /// \#pragma clang fp reciprocal
2023 bool IsEnabled);
2024
2025 /// ActOnPragmaFenvAccess - Called on well formed
2026 /// \#pragma STDC FENV_ACCESS
2027 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
2028
2029 /// ActOnPragmaCXLimitedRange - Called on well formed
2030 /// \#pragma STDC CX_LIMITED_RANGE
2033
2034 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
2037
2038 /// Called to set constant rounding mode for floating point operations.
2039 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
2040
2041 /// Called to set exception behavior for floating point operations.
2043
2044 /// PushNamespaceVisibilityAttr - Note that we've entered a
2045 /// namespace with a visibility attribute.
2046 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
2048
2049 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
2050 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2051 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2052
2053 /// Handles semantic checking for features that are common to all attributes,
2054 /// such as checking whether a parameter was properly specified, or the
2055 /// correct number of arguments were passed, etc. Returns true if the
2056 /// attribute has been diagnosed.
2057 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2058 bool SkipArgCountCheck = false);
2059 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2060 bool SkipArgCountCheck = false);
2061
2062 ///@}
2063
2064 //
2065 //
2066 // -------------------------------------------------------------------------
2067 //
2068 //
2069
2070 /// \name Availability Attribute Handling
2071 /// Implementations are in SemaAvailability.cpp
2072 ///@{
2073
2074public:
2075 /// Issue any -Wunguarded-availability warnings in \c FD
2077
2079
2080 /// Retrieve the current function, if any, that should be analyzed for
2081 /// potential availability violations.
2083
2085 const ObjCInterfaceDecl *UnknownObjCClass,
2086 bool ObjCPropertyAccess,
2087 bool AvoidPartialAvailabilityChecks = false,
2088 ObjCInterfaceDecl *ClassReceiver = nullptr);
2089
2090 ///@}
2091
2092 //
2093 //
2094 // -------------------------------------------------------------------------
2095 //
2096 //
2097
2098 /// \name Casts
2099 /// Implementations are in SemaCast.cpp
2100 ///@{
2101
2102public:
2104 return CCK == CheckedConversionKind::CStyleCast ||
2107 }
2108
2109 /// ActOnCXXNamedCast - Parse
2110 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2112 SourceLocation LAngleBracketLoc, Declarator &D,
2113 SourceLocation RAngleBracketLoc,
2114 SourceLocation LParenLoc, Expr *E,
2115 SourceLocation RParenLoc);
2116
2118 TypeSourceInfo *Ty, Expr *E,
2119 SourceRange AngleBrackets, SourceRange Parens);
2120
2122 ExprResult Operand,
2123 SourceLocation RParenLoc);
2124
2126 Expr *Operand, SourceLocation RParenLoc);
2127
2128 // Checks that reinterpret casts don't have undefined behavior.
2129 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2130 bool IsDereference, SourceRange Range);
2131
2132 // Checks that the vector type should be initialized from a scalar
2133 // by splatting the value rather than populating a single element.
2134 // This is the case for AltiVecVector types as well as with
2135 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2136 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2137
2138 // Checks if the -faltivec-src-compat=gcc option is specified.
2139 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2140 // treated the same way as they are when trying to initialize
2141 // these vectors on gcc (an error is emitted).
2143 QualType SrcTy);
2144
2146 SourceLocation RParenLoc, Expr *Op);
2147
2149 SourceLocation LParenLoc,
2150 Expr *CastExpr,
2151 SourceLocation RParenLoc);
2152
2153 ///@}
2154
2155 //
2156 //
2157 // -------------------------------------------------------------------------
2158 //
2159 //
2160
2161 /// \name Extra Semantic Checking
2162 /// Implementations are in SemaChecking.cpp
2163 ///@{
2164
2165public:
2166 /// Used to change context to isConstantEvaluated without pushing a heavy
2167 /// ExpressionEvaluationContextRecord object.
2169
2173 }
2174
2176 unsigned ByteNo) const;
2177
2179 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2180 FAPK_Variadic, // values to format are passed as variadic arguments
2181 FAPK_VAList, // values to format are passed in a va_list
2182 };
2183
2184 // Used to grab the relevant information from a FormatAttr and a
2185 // FunctionDeclaration.
2187 unsigned FormatIdx;
2190 };
2191
2192 /// Given a FunctionDecl's FormatAttr, attempts to populate the
2193 /// FomatStringInfo parameter with the FormatAttr's correct format_idx and
2194 /// firstDataArg. Returns true when the format fits the function and the
2195 /// FormatStringInfo has been populated.
2196 static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
2197 bool IsVariadic, FormatStringInfo *FSI);
2198
2199 // Used by C++ template instantiation.
2201
2202 /// ConvertVectorExpr - Handle __builtin_convertvector
2204 SourceLocation BuiltinLoc,
2205 SourceLocation RParenLoc);
2206
2219 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2220
2221 bool FormatStringHasSArg(const StringLiteral *FExpr);
2222
2223 /// Check for comparisons of floating-point values using == and !=. Issue a
2224 /// warning if the comparison is not likely to do what the programmer
2225 /// intended.
2227 BinaryOperatorKind Opcode);
2228
2229 /// Register a magic integral constant to be used as a type tag.
2230 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2231 uint64_t MagicValue, QualType Type,
2232 bool LayoutCompatible, bool MustBeNull);
2233
2236
2240
2242
2243 /// If true, \c Type should be compared with other expression's types for
2244 /// layout-compatibility.
2245 LLVM_PREFERRED_TYPE(bool)
2247 LLVM_PREFERRED_TYPE(bool)
2248 unsigned MustBeNull : 1;
2249 };
2250
2251 /// A pair of ArgumentKind identifier and magic value. This uniquely
2252 /// identifies the magic value.
2253 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2254
2255 /// Diagnoses the current set of gathered accesses. This typically
2256 /// happens at full expression level. The set is cleared after emitting the
2257 /// diagnostics.
2259
2260 /// This function checks if the expression is in the sef of potentially
2261 /// misaligned members and it is converted to some pointer type T with lower
2262 /// or equal alignment requirements. If so it removes it. This is used when
2263 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2264 /// void*).
2266
2267 /// This function calls Action when it determines that E designates a
2268 /// misaligned member due to the packed attribute. This is used to emit
2269 /// local diagnostics like in reference binding.
2271 Expr *E,
2272 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2273 Action);
2274
2275 enum class AtomicArgumentOrder { API, AST };
2277 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2278 SourceLocation RParenLoc, MultiExprArg Args,
2281
2282 /// Check to see if a given expression could have '.c_str()' called on it.
2283 bool hasCStrMethod(const Expr *E);
2284
2285 /// Diagnose pointers that are always non-null.
2286 /// \param E the expression containing the pointer
2287 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2288 /// compared to a null pointer
2289 /// \param IsEqual True when the comparison is equal to a null pointer
2290 /// \param Range Extra SourceRange to highlight in the diagnostic
2293 bool IsEqual, SourceRange Range);
2294
2295 /// CheckParmsForFunctionDef - Check that the parameters of the given
2296 /// function are appropriate for the definition of a function. This
2297 /// takes care of any checks that cannot be performed on the
2298 /// declaration itself, e.g., that the types of each of the function
2299 /// parameters are complete.
2301 bool CheckParameterNames);
2302
2303 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2304 /// pointer cast increases the alignment requirements.
2305 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2306
2307 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2308 /// to weak/__unsafe_unretained type.
2310
2311 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2312 /// to weak/__unsafe_unretained expression.
2314
2315 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2316 /// statement as a \p Body, and it is located on the same line.
2317 ///
2318 /// This helps prevent bugs due to typos, such as:
2319 /// if (condition);
2320 /// do_stuff();
2321 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2322 unsigned DiagID);
2323
2324 /// Warn if a for/while loop statement \p S, which is followed by
2325 /// \p PossibleBody, has a suspicious null statement as a body.
2326 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2327
2328 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2329 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2330 SourceLocation OpLoc);
2331
2332 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
2340
2341 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2343 const TypeSourceInfo *Derived);
2344
2345 /// CheckFunctionCall - Check a direct function call for various correctness
2346 /// and safety properties not strictly enforced by the C type system.
2347 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2348 const FunctionProtoType *Proto);
2349
2350 bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res);
2351 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2352
2353 /// Handles the checks for format strings, non-POD arguments to vararg
2354 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2355 /// attributes and AArch64 SME attributes.
2356 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2357 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2358 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2359 VariadicCallType CallType);
2360
2361 /// \brief Enforce the bounds of a TCB
2362 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2363 /// directly calls other functions in the same TCB as marked by the
2364 /// enforce_tcb and enforce_tcb_leaf attributes.
2365 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2366 const NamedDecl *Callee);
2367
2368 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2369
2370 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2371 /// TheCall is a constant expression.
2372 bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result);
2373
2374 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2375 /// TheCall is a constant expression in the range [Low, High].
2376 bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High,
2377 bool RangeIsError = true);
2378
2379 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2380 /// TheCall is a constant expression is a multiple of Num..
2381 bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
2382 unsigned Multiple);
2383
2384 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2385 /// constant expression representing a power of 2.
2386 bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum);
2387
2388 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2389 /// a constant expression representing an arbitrary byte value shifted left by
2390 /// a multiple of 8 bits.
2391 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
2392 unsigned ArgBits);
2393
2394 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2395 /// TheCall is a constant expression representing either a shifted byte value,
2396 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2397 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2398 /// Arm MVE intrinsics.
2399 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
2400 unsigned ArgBits);
2401
2402 /// Checks that a call expression's argument count is at least the desired
2403 /// number. This is useful when doing custom type-checking on a variadic
2404 /// function. Returns true on error.
2405 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2406
2407 /// Checks that a call expression's argument count is at most the desired
2408 /// number. This is useful when doing custom type-checking on a variadic
2409 /// function. Returns true on error.
2410 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2411
2412 /// Checks that a call expression's argument count is in the desired range.
2413 /// This is useful when doing custom type-checking on a variadic function.
2414 /// Returns true on error.
2415 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2416 unsigned MaxArgCount);
2417
2418 /// Checks that a call expression's argument count is the desired number.
2419 /// This is useful when doing custom type-checking. Returns true on error.
2420 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2421
2422 /// Returns true if the argument consists of one contiguous run of 1s with any
2423 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2424 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2425 /// since all 1s are not contiguous.
2426 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2427
2429 bool *ICContext = nullptr,
2430 bool IsListInit = false);
2431
2433 bool CheckForFloatArgs = true);
2435
2436private:
2437 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2438 const ArraySubscriptExpr *ASE = nullptr,
2439 bool AllowOnePastEnd = true, bool IndexNegated = false);
2440 void CheckArrayAccess(const Expr *E);
2441
2442 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2443 const FunctionProtoType *Proto);
2444
2445 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
2446 /// such as function pointers returned from functions.
2447 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2448
2449 /// CheckConstructorCall - Check a constructor call for correctness and safety
2450 /// properties not enforced by the C type system.
2451 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2453 const FunctionProtoType *Proto, SourceLocation Loc);
2454
2455 /// Warn if a pointer or reference argument passed to a function points to an
2456 /// object that is less aligned than the parameter. This can happen when
2457 /// creating a typedef with a lower alignment than the original type and then
2458 /// calling functions defined in terms of the original type.
2459 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2460 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2461
2462 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2463
2464 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2465 CallExpr *TheCall);
2466
2467 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2468 CallExpr *TheCall);
2469
2470 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2471
2472 /// Check the arguments to '__builtin_va_start' or '__builtin_ms_va_start'
2473 /// for validity. Emit an error and return true on failure; return false
2474 /// on success.
2475 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2476 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2477
2478 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
2479 /// friends. This is declared to take (...), so we have to check everything.
2480 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2481
2482 /// BuiltinSemaBuiltinFPClassification - Handle functions like
2483 /// __builtin_isnan and friends. This is declared to take (...), so we have
2484 /// to check everything.
2485 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2486 unsigned BuiltinID);
2487
2488 /// Perform semantic analysis for a call to __builtin_complex.
2489 bool BuiltinComplex(CallExpr *TheCall);
2490 bool BuiltinOSLogFormat(CallExpr *TheCall);
2491
2492 /// BuiltinPrefetch - Handle __builtin_prefetch.
2493 /// This is declared to take (const void*, ...) and can take two
2494 /// optional constant int args.
2495 bool BuiltinPrefetch(CallExpr *TheCall);
2496
2497 /// Handle __builtin_alloca_with_align. This is declared
2498 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
2499 /// than 8.
2500 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2501
2502 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
2503 bool BuiltinArithmeticFence(CallExpr *TheCall);
2504
2505 /// BuiltinAssume - Handle __assume (MS Extension).
2506 /// __assume does not evaluate its arguments, and should warn if its argument
2507 /// has side effects.
2508 bool BuiltinAssume(CallExpr *TheCall);
2509
2510 /// Handle __builtin_assume_aligned. This is declared
2511 /// as (const void*, size_t, ...) and can take one optional constant int arg.
2512 bool BuiltinAssumeAligned(CallExpr *TheCall);
2513
2514 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
2515 /// This checks that the target supports __builtin_longjmp and
2516 /// that val is a constant 1.
2517 bool BuiltinLongjmp(CallExpr *TheCall);
2518
2519 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
2520 /// This checks that the target supports __builtin_setjmp.
2521 bool BuiltinSetjmp(CallExpr *TheCall);
2522
2523 /// We have a call to a function like __sync_fetch_and_add, which is an
2524 /// overloaded function based on the pointer type of its first argument.
2525 /// The main BuildCallExpr routines have already promoted the types of
2526 /// arguments because all of these calls are prototyped as void(...).
2527 ///
2528 /// This function goes through and does final semantic checking for these
2529 /// builtins, as well as generating any warnings.
2530 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2531
2532 /// BuiltinNontemporalOverloaded - We have a call to
2533 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
2534 /// overloaded function based on the pointer type of its last argument.
2535 ///
2536 /// This function goes through and does final semantic checking for these
2537 /// builtins.
2538 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2539 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2541
2542 bool BuiltinElementwiseMath(CallExpr *TheCall);
2543 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
2544
2545 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
2546
2547 // Matrix builtin handling.
2548 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
2549 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
2550 ExprResult CallResult);
2551 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
2552 ExprResult CallResult);
2553
2554 /// CheckFormatArguments - Check calls to printf and scanf (and similar
2555 /// functions) for correct use of format strings.
2556 /// Returns true if a format string has been fully checked.
2557 bool CheckFormatArguments(const FormatAttr *Format,
2558 ArrayRef<const Expr *> Args, bool IsCXXMember,
2561 llvm::SmallBitVector &CheckedVarArgs);
2562 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
2563 FormatArgumentPassingKind FAPK, unsigned format_idx,
2564 unsigned firstDataArg, FormatStringType Type,
2566 SourceRange range,
2567 llvm::SmallBitVector &CheckedVarArgs);
2568
2569 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
2570
2571 /// Warn when using the wrong abs() function.
2572 void CheckAbsoluteValueFunction(const CallExpr *Call,
2573 const FunctionDecl *FDecl);
2574
2575 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
2576
2577 /// Check for dangerous or invalid arguments to memset().
2578 ///
2579 /// This issues warnings on known problematic, dangerous or unspecified
2580 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
2581 /// function calls.
2582 ///
2583 /// \param Call The call expression to diagnose.
2584 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
2585 IdentifierInfo *FnName);
2586
2587 // Warn if the user has made the 'size' argument to strlcpy or strlcat
2588 // be the size of the source, instead of the destination.
2589 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2590
2591 // Warn on anti-patterns as the 'size' argument to strncat.
2592 // The correct size argument should look like following:
2593 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
2594 void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2595
2596 /// Alerts the user that they are attempting to free a non-malloc'd object.
2597 void CheckFreeArguments(const CallExpr *E);
2598
2599 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
2600 SourceLocation ReturnLoc, bool isObjCMethod = false,
2601 const AttrVec *Attrs = nullptr,
2602 const FunctionDecl *FD = nullptr);
2603
2604 /// Diagnoses "dangerous" implicit conversions within the given
2605 /// expression (which is a full expression). Implements -Wconversion
2606 /// and -Wsign-compare.
2607 ///
2608 /// \param CC the "context" location of the implicit conversion, i.e.
2609 /// the most location of the syntactic entity requiring the implicit
2610 /// conversion
2611 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
2612
2613 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
2614 /// Input argument E is a logical expression.
2615 void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
2616
2617 /// Diagnose when expression is an integer constant expression and its
2618 /// evaluation results in integer overflow
2619 void CheckForIntOverflow(const Expr *E);
2620 void CheckUnsequencedOperations(const Expr *E);
2621
2622 /// Perform semantic checks on a completed expression. This will either
2623 /// be a full-expression or a default argument expression.
2624 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
2625 bool IsConstexpr = false);
2626
2627 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
2628 Expr *Init);
2629
2630 /// A map from magic value to type information.
2631 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
2632 TypeTagForDatatypeMagicValues;
2633
2634 /// Peform checks on a call of a function with argument_with_type_tag
2635 /// or pointer_with_type_tag attributes.
2636 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
2637 const ArrayRef<const Expr *> ExprArgs,
2638 SourceLocation CallSiteLoc);
2639
2640 /// Check if we are taking the address of a packed field
2641 /// as this may be a problem if the pointer value is dereferenced.
2642 void CheckAddressOfPackedMember(Expr *rhs);
2643
2644 /// Helper class that collects misaligned member designations and
2645 /// their location info for delayed diagnostics.
2646 struct MisalignedMember {
2647 Expr *E;
2648 RecordDecl *RD;
2649 ValueDecl *MD;
2650 CharUnits Alignment;
2651
2652 MisalignedMember() : E(), RD(), MD() {}
2653 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
2654 CharUnits Alignment)
2655 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
2656 explicit MisalignedMember(Expr *E)
2657 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
2658
2659 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
2660 };
2661 /// Small set of gathered accesses to potentially misaligned members
2662 /// due to the packed attribute.
2663 SmallVector<MisalignedMember, 4> MisalignedMembers;
2664
2665 /// Adds an expression to the set of gathered misaligned members.
2666 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
2667 CharUnits Alignment);
2668 ///@}
2669
2670 //
2671 //
2672 // -------------------------------------------------------------------------
2673 //
2674 //
2675
2676 /// \name C++ Coroutines
2677 /// Implementations are in SemaCoroutine.cpp
2678 ///@{
2679
2680public:
2681 /// The C++ "std::coroutine_traits" template, which is defined in
2682 /// <coroutine_traits>
2684
2686 StringRef Keyword);
2690
2693 UnresolvedLookupExpr *Lookup);
2695 Expr *Awaiter, bool IsImplicit = false);
2697 UnresolvedLookupExpr *Lookup);
2700 bool IsImplicit = false);
2705
2706 // As a clang extension, enforces that a non-coroutine function must be marked
2707 // with [[clang::coro_wrapper]] if it returns a type marked with
2708 // [[clang::coro_return_type]].
2709 // Expects that FD is not a coroutine.
2711 /// Lookup 'coroutine_traits' in std namespace and std::experimental
2712 /// namespace. The namespace found is recorded in Namespace.
2714 SourceLocation FuncLoc);
2715 /// Check that the expression co_await promise.final_suspend() shall not be
2716 /// potentially-throwing.
2717 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
2718
2719 ///@}
2720
2721 //
2722 //
2723 // -------------------------------------------------------------------------
2724 //
2725 //
2726
2727 /// \name C++ Scope Specifiers
2728 /// Implementations are in SemaCXXScopeSpec.cpp
2729 ///@{
2730
2731public:
2732 // Marks SS invalid if it represents an incomplete type.
2734 // Complete an enum decl, maybe without a scope spec.
2736 CXXScopeSpec *SS = nullptr);
2737
2738 /// Compute the DeclContext that is associated with the given type.
2739 ///
2740 /// \param T the type for which we are attempting to find a DeclContext.
2741 ///
2742 /// \returns the declaration context represented by the type T,
2743 /// or NULL if the declaration context cannot be computed (e.g., because it is
2744 /// dependent and not the current instantiation).
2746
2747 /// Compute the DeclContext that is associated with the given
2748 /// scope specifier.
2749 ///
2750 /// \param SS the C++ scope specifier as it appears in the source
2751 ///
2752 /// \param EnteringContext when true, we will be entering the context of
2753 /// this scope specifier, so we can retrieve the declaration context of a
2754 /// class template or class template partial specialization even if it is
2755 /// not the current instantiation.
2756 ///
2757 /// \returns the declaration context represented by the scope specifier @p SS,
2758 /// or NULL if the declaration context cannot be computed (e.g., because it is
2759 /// dependent and not the current instantiation).
2761 bool EnteringContext = false);
2763
2764 /// If the given nested name specifier refers to the current
2765 /// instantiation, return the declaration that corresponds to that
2766 /// current instantiation (C++0x [temp.dep.type]p1).
2767 ///
2768 /// \param NNS a dependent nested name specifier.
2770
2771 /// The parser has parsed a global nested-name-specifier '::'.
2772 ///
2773 /// \param CCLoc The location of the '::'.
2774 ///
2775 /// \param SS The nested-name-specifier, which will be updated in-place
2776 /// to reflect the parsed nested-name-specifier.
2777 ///
2778 /// \returns true if an error occurred, false otherwise.
2780
2781 /// The parser has parsed a '__super' nested-name-specifier.
2782 ///
2783 /// \param SuperLoc The location of the '__super' keyword.
2784 ///
2785 /// \param ColonColonLoc The location of the '::'.
2786 ///
2787 /// \param SS The nested-name-specifier, which will be updated in-place
2788 /// to reflect the parsed nested-name-specifier.
2789 ///
2790 /// \returns true if an error occurred, false otherwise.
2792 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
2793
2794 /// Determines whether the given declaration is an valid acceptable
2795 /// result for name lookup of a nested-name-specifier.
2796 /// \param SD Declaration checked for nested-name-specifier.
2797 /// \param IsExtension If not null and the declaration is accepted as an
2798 /// extension, the pointed variable is assigned true.
2800 bool *CanCorrect = nullptr);
2801
2802 /// If the given nested-name-specifier begins with a bare identifier
2803 /// (e.g., Base::), perform name lookup for that identifier as a
2804 /// nested-name-specifier within the given scope, and return the result of
2805 /// that name lookup.
2807
2808 /// Keeps information about an identifier in a nested-name-spec.
2809 ///
2811 /// The type of the object, if we're parsing nested-name-specifier in
2812 /// a member access expression.
2814
2815 /// The identifier preceding the '::'.
2817
2818 /// The location of the identifier.
2820
2821 /// The location of the '::'.
2823
2824 /// Creates info object for the most typical case.
2826 SourceLocation ColonColonLoc,
2827 ParsedType ObjectType = ParsedType())
2828 : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
2829 CCLoc(ColonColonLoc) {}
2830
2832 SourceLocation ColonColonLoc, QualType ObjectType)
2833 : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
2834 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
2835 };
2836
2837 /// Build a new nested-name-specifier for "identifier::", as described
2838 /// by ActOnCXXNestedNameSpecifier.
2839 ///
2840 /// \param S Scope in which the nested-name-specifier occurs.
2841 /// \param IdInfo Parser information about an identifier in the
2842 /// nested-name-spec.
2843 /// \param EnteringContext If true, enter the context specified by the
2844 /// nested-name-specifier.
2845 /// \param SS Optional nested name specifier preceding the identifier.
2846 /// \param ScopeLookupResult Provides the result of name lookup within the
2847 /// scope of the nested-name-specifier that was computed at template
2848 /// definition time.
2849 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
2850 /// error recovery and what kind of recovery is performed.
2851 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
2852 /// are allowed. The bool value pointed by this parameter is set to
2853 /// 'true' if the identifier is treated as if it was followed by ':',
2854 /// not '::'.
2855 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2856 ///
2857 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
2858 /// that it contains an extra parameter \p ScopeLookupResult, which provides
2859 /// the result of name lookup within the scope of the nested-name-specifier
2860 /// that was computed at template definition time.
2861 ///
2862 /// If ErrorRecoveryLookup is true, then this call is used to improve error
2863 /// recovery. This means that it should not emit diagnostics, it should
2864 /// just return true on failure. It also means it should only return a valid
2865 /// scope if it *knows* that the result is correct. It should not return in a
2866 /// dependent context, for example. Nor will it extend \p SS with the scope
2867 /// specifier.
2868 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2869 bool EnteringContext, CXXScopeSpec &SS,
2870 NamedDecl *ScopeLookupResult,
2871 bool ErrorRecoveryLookup,
2872 bool *IsCorrectedToColon = nullptr,
2873 bool OnlyNamespace = false);
2874
2875 /// The parser has parsed a nested-name-specifier 'identifier::'.
2876 ///
2877 /// \param S The scope in which this nested-name-specifier occurs.
2878 ///
2879 /// \param IdInfo Parser information about an identifier in the
2880 /// nested-name-spec.
2881 ///
2882 /// \param EnteringContext Whether we're entering the context nominated by
2883 /// this nested-name-specifier.
2884 ///
2885 /// \param SS The nested-name-specifier, which is both an input
2886 /// parameter (the nested-name-specifier before this type) and an
2887 /// output parameter (containing the full nested-name-specifier,
2888 /// including this new type).
2889 ///
2890 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
2891 /// are allowed. The bool value pointed by this parameter is set to 'true'
2892 /// if the identifier is treated as if it was followed by ':', not '::'.
2893 ///
2894 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2895 ///
2896 /// \returns true if an error occurred, false otherwise.
2897 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2898 bool EnteringContext, CXXScopeSpec &SS,
2899 bool *IsCorrectedToColon = nullptr,
2900 bool OnlyNamespace = false);
2901
2902 /// The parser has parsed a nested-name-specifier
2903 /// 'template[opt] template-name < template-args >::'.
2904 ///
2905 /// \param S The scope in which this nested-name-specifier occurs.
2906 ///
2907 /// \param SS The nested-name-specifier, which is both an input
2908 /// parameter (the nested-name-specifier before this type) and an
2909 /// output parameter (containing the full nested-name-specifier,
2910 /// including this new type).
2911 ///
2912 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
2913 /// \param TemplateName the template name.
2914 /// \param TemplateNameLoc The location of the template name.
2915 /// \param LAngleLoc The location of the opening angle bracket ('<').
2916 /// \param TemplateArgs The template arguments.
2917 /// \param RAngleLoc The location of the closing angle bracket ('>').
2918 /// \param CCLoc The location of the '::'.
2919 ///
2920 /// \param EnteringContext Whether we're entering the context of the
2921 /// nested-name-specifier.
2922 ///
2923 ///
2924 /// \returns true if an error occurred, false otherwise.
2926 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
2927 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
2928 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
2929 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
2930
2932 SourceLocation ColonColonLoc);
2933
2935 const DeclSpec &DS,
2936 SourceLocation ColonColonLoc,
2937 QualType Type);
2938
2939 /// IsInvalidUnlessNestedName - This method is used for error recovery
2940 /// purposes to determine whether the specified identifier is only valid as
2941 /// a nested name specifier, for example a namespace name. It is
2942 /// conservatively correct to always return false from this method.
2943 ///
2944 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
2946 NestedNameSpecInfo &IdInfo,
2947 bool EnteringContext);
2948
2949 /// Given a C++ nested-name-specifier, produce an annotation value
2950 /// that the parser can use later to reconstruct the given
2951 /// nested-name-specifier.
2952 ///
2953 /// \param SS A nested-name-specifier.
2954 ///
2955 /// \returns A pointer containing all of the information in the
2956 /// nested-name-specifier \p SS.
2958
2959 /// Given an annotation pointer for a nested-name-specifier, restore
2960 /// the nested-name-specifier structure.
2961 ///
2962 /// \param Annotation The annotation pointer, produced by
2963 /// \c SaveNestedNameSpecifierAnnotation().
2964 ///
2965 /// \param AnnotationRange The source range corresponding to the annotation.
2966 ///
2967 /// \param SS The nested-name-specifier that will be updated with the contents
2968 /// of the annotation pointer.
2969 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
2970 SourceRange AnnotationRange,
2971 CXXScopeSpec &SS);
2972
2973 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2974
2975 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2976 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2977 /// After this method is called, according to [C++ 3.4.3p3], names should be
2978 /// looked up in the declarator-id's scope, until the declarator is parsed and
2979 /// ActOnCXXExitDeclaratorScope is called.
2980 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2982
2983 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2984 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2985 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2986 /// Used to indicate that names should revert to being looked up in the
2987 /// defining scope.
2989
2990 ///@}
2991
2992 //
2993 //
2994 // -------------------------------------------------------------------------
2995 //
2996 //
2997
2998 /// \name Declarations
2999 /// Implementations are in SemaDecl.cpp
3000 ///@{
3001
3002public:
3004
3005 /// The index of the first InventedParameterInfo that refers to the current
3006 /// context.
3008
3009 /// A RAII object to temporarily push a declaration context.
3011 private:
3012 Sema &S;
3013 DeclContext *SavedContext;
3014 ProcessingContextState SavedContextState;
3015 QualType SavedCXXThisTypeOverride;
3016 unsigned SavedFunctionScopesStart;
3017 unsigned SavedInventedParameterInfosStart;
3018
3019 public:
3020 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3021 : S(S), SavedContext(S.CurContext),
3022 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3023 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3024 SavedFunctionScopesStart(S.FunctionScopesStart),
3025 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3026 assert(ContextToPush && "pushing null context");
3027 S.CurContext = ContextToPush;
3028 if (NewThisContext)
3029 S.CXXThisTypeOverride = QualType();
3030 // Any saved FunctionScopes do not refer to this context.
3031 S.FunctionScopesStart = S.FunctionScopes.size();
3032 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3033 }
3034
3035 void pop() {
3036 if (!SavedContext)
3037 return;
3038 S.CurContext = SavedContext;
3039 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3040 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3041 S.FunctionScopesStart = SavedFunctionScopesStart;
3042 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3043 SavedContext = nullptr;
3044 }
3045
3046 ~ContextRAII() { pop(); }
3047 };
3048
3049 void DiagnoseInvalidJumps(Stmt *Body);
3050
3051 /// The function definitions which were renamed as part of typo-correction
3052 /// to match their respective declarations. We want to keep track of them
3053 /// to ensure that we don't emit a "redefinition" error if we encounter a
3054 /// correctly named definition after the renamed definition.
3056
3057 /// A cache of the flags available in enumerations with the flag_bits
3058 /// attribute.
3059 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3060
3061 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3062 /// declared. Rare. May alias another identifier, declared or undeclared.
3063 ///
3064 /// For aliases, the target identifier is used as a key for eventual
3065 /// processing when the target is declared. For the single-identifier form,
3066 /// the sole identifier is used as the key. Each entry is a `SetVector`
3067 /// (ordered by parse order) of aliases (identified by the alias name) in case
3068 /// of multiple aliases to the same undeclared identifier.
3069 llvm::MapVector<
3071 llvm::SetVector<
3073 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3075
3076 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3077 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3078 /// to define functions that occur in multiple standards to call the version
3079 /// in the currently selected standard.
3080 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
3081
3082 /// Set containing all typedefs that are likely unused.
3085
3089
3090 /// The set of file scoped decls seen so far that have not been used
3091 /// and must warn if not used. Only contains the first declaration.
3093
3097
3098 /// All the tentative definitions encountered in the TU.
3100
3101 /// All the external declarations encoutered and used in the TU.
3103
3104 /// Generally null except when we temporarily switch decl contexts,
3105 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3107
3108 /// Is the module scope we are in a C++ Header Unit?
3110 return ModuleScopes.empty() ? false
3111 : ModuleScopes.back().Module->isHeaderUnit();
3112 }
3113
3114 /// Get the module owning an entity.
3115 Module *getOwningModule(const Decl *Entity) {
3116 return Entity->getOwningModule();
3117 }
3118
3119 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3120
3121 /// If the identifier refers to a type name within this scope,
3122 /// return the declaration of that type.
3123 ///
3124 /// This routine performs ordinary name lookup of the identifier II
3125 /// within the given scope, with optional C++ scope specifier SS, to
3126 /// determine whether the name refers to a type. If so, returns an
3127 /// opaque pointer (actually a QualType) corresponding to that
3128 /// type. Otherwise, returns NULL.
3130 Scope *S, CXXScopeSpec *SS = nullptr,
3131 bool isClassName = false, bool HasTrailingDot = false,
3132 ParsedType ObjectType = nullptr,
3133 bool IsCtorOrDtorName = false,
3134 bool WantNontrivialTypeSourceInfo = false,
3135 bool IsClassTemplateDeductionContext = true,
3136 ImplicitTypenameContext AllowImplicitTypename =
3138 IdentifierInfo **CorrectedII = nullptr);
3139
3140 /// isTagName() - This method is called *for error recovery purposes only*
3141 /// to determine if the specified name is a valid tag name ("struct foo"). If
3142 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3143 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3144 /// diagnose cases in C where the user forgot to specify the tag.
3146
3147 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3148 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3149 /// then downgrade the missing typename error to a warning.
3150 /// This is needed for MSVC compatibility; Example:
3151 /// @code
3152 /// template<class T> class A {
3153 /// public:
3154 /// typedef int TYPE;
3155 /// };
3156 /// template<class T> class B : public A<T> {
3157 /// public:
3158 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3159 /// };
3160 /// @endcode
3161 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3163 Scope *S, CXXScopeSpec *SS,
3164 ParsedType &SuggestedType,
3165 bool IsTemplateName = false);
3166
3167 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3168 /// type name has failed in a dependent context. In these situations, we
3169 /// automatically form a DependentTypeName that will retry lookup in a related
3170 /// scope during instantiation.
3172 SourceLocation NameLoc,
3173 bool IsTemplateTypeArg);
3174
3175 /// Describes the result of the name lookup and resolution performed
3176 /// by \c ClassifyName().
3178 /// This name is not a type or template in this context, but might be
3179 /// something else.
3181 /// Classification failed; an error has been produced.
3183 /// The name has been typo-corrected to a keyword.
3185 /// The name was classified as a type.
3187 /// The name was classified as a specific non-type, non-template
3188 /// declaration. ActOnNameClassifiedAsNonType should be called to
3189 /// convert the declaration to an expression.
3191 /// The name was classified as an ADL-only function name.
3192 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
3193 /// result to an expression.
3195 /// The name denotes a member of a dependent type that could not be
3196 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
3197 /// convert the result to an expression.
3199 /// The name was classified as an overload set, and an expression
3200 /// representing that overload set has been formed.
3201 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
3202 /// expression referencing the overload set.
3204 /// The name was classified as a template whose specializations are types.
3206 /// The name was classified as a variable template name.
3208 /// The name was classified as a function template name.
3210 /// The name was classified as an ADL-only function template name.
3212 /// The name was classified as a concept name.
3214 };
3215
3218 union {
3223 };
3224
3226
3227 public:
3229
3230 NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
3231
3232 static NameClassification Error() { return NameClassification(NC_Error); }
3233
3235 return NameClassification(NC_Unknown);
3236 }
3237
3239 NameClassification Result(NC_OverloadSet);
3240 Result.Expr = E;
3241 return Result;
3242 }
3243
3245 NameClassification Result(NC_NonType);
3246 Result.NonTypeDecl = D;
3247 return Result;
3248 }
3249
3251 return NameClassification(NC_UndeclaredNonType);
3252 }
3253
3255 return NameClassification(NC_DependentNonType);
3256 }
3257
3259 NameClassification Result(NC_TypeTemplate);
3260 Result.Template = Name;
3261 return Result;
3262 }
3263
3265 NameClassification Result(NC_VarTemplate);
3266 Result.Template = Name;
3267 return Result;
3268 }
3269
3271 NameClassification Result(NC_FunctionTemplate);
3272 Result.Template = Name;
3273 return Result;
3274 }
3275
3277 NameClassification Result(NC_Concept);
3278 Result.Template = Name;
3279 return Result;
3280 }
3281
3283 NameClassification Result(NC_UndeclaredTemplate);
3284 Result.Template = Name;
3285 return Result;
3286 }
3287
3289
3291 assert(Kind == NC_OverloadSet);
3292 return Expr;
3293 }
3294
3296 assert(Kind == NC_Type);
3297 return Type;
3298 }
3299
3301 assert(Kind == NC_NonType);
3302 return NonTypeDecl;
3303 }
3304
3306 assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
3307 Kind == NC_VarTemplate || Kind == NC_Concept ||
3308 Kind == NC_UndeclaredTemplate);
3309 return Template;
3310 }
3311
3313 switch (Kind) {
3314 case NC_TypeTemplate:
3315 return TNK_Type_template;
3316 case NC_FunctionTemplate:
3317 return TNK_Function_template;
3318 case NC_VarTemplate:
3319 return TNK_Var_template;
3320 case NC_Concept:
3321 return TNK_Concept_template;
3322 case NC_UndeclaredTemplate:
3324 default:
3325 llvm_unreachable("unsupported name classification.");
3326 }
3327 }
3328 };
3329
3330 /// Perform name lookup on the given name, classifying it based on
3331 /// the results of name lookup and the following token.
3332 ///
3333 /// This routine is used by the parser to resolve identifiers and help direct
3334 /// parsing. When the identifier cannot be found, this routine will attempt
3335 /// to correct the typo and classify based on the resulting name.
3336 ///
3337 /// \param S The scope in which we're performing name lookup.
3338 ///
3339 /// \param SS The nested-name-specifier that precedes the name.
3340 ///
3341 /// \param Name The identifier. If typo correction finds an alternative name,
3342 /// this pointer parameter will be updated accordingly.
3343 ///
3344 /// \param NameLoc The location of the identifier.
3345 ///
3346 /// \param NextToken The token following the identifier. Used to help
3347 /// disambiguate the name.
3348 ///
3349 /// \param CCC The correction callback, if typo correction is desired.
3350 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3351 IdentifierInfo *&Name, SourceLocation NameLoc,
3352 const Token &NextToken,
3353 CorrectionCandidateCallback *CCC = nullptr);
3354
3355 /// Act on the result of classifying a name as an undeclared (ADL-only)
3356 /// non-type declaration.
3358 SourceLocation NameLoc);
3359 /// Act on the result of classifying a name as an undeclared member of a
3360 /// dependent base class.
3362 IdentifierInfo *Name,
3363 SourceLocation NameLoc,
3364 bool IsAddressOfOperand);
3365 /// Act on the result of classifying a name as a specific non-type
3366 /// declaration.
3369 SourceLocation NameLoc,
3370 const Token &NextToken);
3371 /// Act on the result of classifying a name as an overload set.
3373
3374 /// Describes the detailed kind of a template name. Used in diagnostics.
3381 Concept,
3383 };
3386
3387 /// Determine whether it's plausible that E was intended to be a
3388 /// template-name.
3390 if (!getLangOpts().CPlusPlus || E.isInvalid())
3391 return false;
3392 Dependent = false;
3393 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3394 return !DRE->hasExplicitTemplateArgs();
3395 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3396 return !ME->hasExplicitTemplateArgs();
3397 Dependent = true;
3398 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3399 return !DSDRE->hasExplicitTemplateArgs();
3400 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3401 return !DSME->hasExplicitTemplateArgs();
3402 // Any additional cases recognized here should also be handled by
3403 // diagnoseExprIntendedAsTemplateName.
3404 return false;
3405 }
3406
3408
3410
3412 MultiTemplateParamsArg TemplateParameterLists);
3413
3414 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3415 /// true if we were successful.
3418 unsigned FailedFoldDiagID);
3419
3420 /// Register the given locally-scoped extern "C" declaration so
3421 /// that it can be found later for redeclarations. We include any extern "C"
3422 /// declaration that is not visible in the translation unit here, not just
3423 /// function-scope declarations.
3425
3426 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3427 /// If T is the name of a class, then each of the following shall have a
3428 /// name different from T:
3429 /// - every static data member of class T;
3430 /// - every member function of class T
3431 /// - every member of class T that is itself a type;
3432 /// \returns true if the declaration name violates these rules.
3434
3435 /// Diagnose a declaration whose declarator-id has the given
3436 /// nested-name-specifier.
3437 ///
3438 /// \param SS The nested-name-specifier of the declarator-id.
3439 ///
3440 /// \param DC The declaration context to which the nested-name-specifier
3441 /// resolves.
3442 ///
3443 /// \param Name The name of the entity being declared.
3444 ///
3445 /// \param Loc The location of the name of the entity being declared.
3446 ///
3447 /// \param IsMemberSpecialization Whether we are declaring a member
3448 /// specialization.
3449 ///
3450 /// \param TemplateId The template-id, if any.
3451 ///
3452 /// \returns true if we cannot safely recover from this error, false
3453 /// otherwise.
3456 TemplateIdAnnotation *TemplateId,
3457 bool IsMemberSpecialization);
3458
3460
3461 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
3462
3463 /// Diagnose function specifiers on a declaration of an identifier that
3464 /// does not identify a function.
3465 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
3466
3467 /// Return the declaration shadowed by the given typedef \p D, or null
3468 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3470 const LookupResult &R);
3471
3472 /// Return the declaration shadowed by the given variable \p D, or null
3473 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3475
3476 /// Return the declaration shadowed by the given variable \p D, or null
3477 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3479 const LookupResult &R);
3480 /// Diagnose variable or built-in function shadowing. Implements
3481 /// -Wshadow.
3482 ///
3483 /// This method is called whenever a VarDecl is added to a "useful"
3484 /// scope.
3485 ///
3486 /// \param ShadowedDecl the declaration that is shadowed by the given variable
3487 /// \param R the lookup of the name
3488 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
3489 const LookupResult &R);
3490
3491 /// Check -Wshadow without the advantage of a previous lookup.
3492 void CheckShadow(Scope *S, VarDecl *D);
3493
3494 /// Warn if 'E', which is an expression that is about to be modified, refers
3495 /// to a shadowing declaration.
3497
3498 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
3499 /// when these variables are captured by the lambda.
3501
3502 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
3503 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
3504 TypedefNameDecl *NewTD);
3507 TypeSourceInfo *TInfo,
3509
3510 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
3511 /// declares a typedef-name, either using the 'typedef' type specifier or via
3512 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
3514 LookupResult &Previous, bool &Redeclaration);
3516 Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo,
3517 LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists,
3518 bool &AddToScope, ArrayRef<BindingDecl *> Bindings = std::nullopt);
3519
3520 /// Perform semantic checking on a newly-created variable
3521 /// declaration.
3522 ///
3523 /// This routine performs all of the type-checking required for a
3524 /// variable declaration once it has been built. It is used both to
3525 /// check variables after they have been parsed and their declarators
3526 /// have been translated into a declaration, and to check variables
3527 /// that have been instantiated from a template.
3528 ///
3529 /// Sets NewVD->isInvalidDecl() if an error was encountered.
3530 ///
3531 /// Returns true if the variable declaration is a redeclaration.
3535
3537 TypeSourceInfo *TInfo,
3539 MultiTemplateParamsArg TemplateParamLists,
3540 bool &AddToScope);
3541
3542 /// AddOverriddenMethods - See if a method overrides any in the base classes,
3543 /// and if so, check that it's a valid override and remember it.
3545
3546 /// Perform semantic checking of a new function declaration.
3547 ///
3548 /// Performs semantic analysis of the new function declaration
3549 /// NewFD. This routine performs all semantic checking that does not
3550 /// require the actual declarator involved in the declaration, and is
3551 /// used both for the declaration of functions as they are parsed
3552 /// (called via ActOnDeclarator) and for the declaration of functions
3553 /// that have been instantiated via C++ template instantiation (called
3554 /// via InstantiateDecl).
3555 ///
3556 /// \param IsMemberSpecialization whether this new function declaration is
3557 /// a member specialization (that replaces any definition provided by the
3558 /// previous declaration).
3559 ///
3560 /// This sets NewFD->isInvalidDecl() to true if there was an error.
3561 ///
3562 /// \returns true if the function declaration is a redeclaration.
3565 bool IsMemberSpecialization, bool DeclIsDefn);
3566
3567 /// Checks if the new declaration declared in dependent context must be
3568 /// put in the same redeclaration chain as the specified declaration.
3569 ///
3570 /// \param D Declaration that is checked.
3571 /// \param PrevDecl Previous declaration found with proper lookup method for
3572 /// the same declaration name.
3573 /// \returns True if D must be added to the redeclaration chain which PrevDecl
3574 /// belongs to.
3576
3577 /// Determines if we can perform a correct type check for \p D as a
3578 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
3579 /// best-effort check.
3580 ///
3581 /// \param NewD The new declaration.
3582 /// \param OldD The old declaration.
3583 /// \param NewT The portion of the type of the new declaration to check.
3584 /// \param OldT The portion of the type of the old declaration to check.
3586 QualType NewT, QualType OldT);
3587 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
3589
3590 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
3591 /// containing class. Otherwise it will return implicit SectionAttr if the
3592 /// function is a definition and there is an active value on CodeSegStack
3593 /// (from the current #pragma code-seg value).
3594 ///
3595 /// \param FD Function being declared.
3596 /// \param IsDefinition Whether it is a definition or just a declaration.
3597 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
3598 /// nullptr if no attribute should be added.
3600 bool IsDefinition);
3601
3602 /// Common checks for a parameter-declaration that should apply to both
3603 /// function parameters and non-type template parameters.
3605
3606 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
3607 /// to introduce parameters into function prototype scope.
3609 SourceLocation ExplicitThisLoc = {});
3610
3611 /// Synthesizes a variable for a parameter arising from a
3612 /// typedef.
3613 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
3614 QualType T);
3615 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
3616 SourceLocation NameLoc,
3617 const IdentifierInfo *Name, QualType T,
3618 TypeSourceInfo *TSInfo, StorageClass SC);
3619
3620 // Contexts where using non-trivial C union types can be disallowed. This is
3621 // passed to err_non_trivial_c_union_in_invalid_context.
3623 // Function parameter.
3625 // Function return.
3627 // Default-initialized object.
3629 // Variable with automatic storage duration.
3631 // Initializer expression that might copy from another object.
3633 // Assignment.
3635 // Compound literal.
3637 // Block capture.
3639 // lvalue-to-rvalue conversion of volatile type.
3641 };
3642
3643 /// Emit diagnostics if the initializer or any of its explicit or
3644 /// implicitly-generated subexpressions require copying or
3645 /// default-initializing a type that is or contains a C union type that is
3646 /// non-trivial to copy or default-initialize.
3648
3649 // These flags are passed to checkNonTrivialCUnion.
3654 };
3655
3656 /// Emit diagnostics if a non-trivial C union type or a struct that contains
3657 /// a non-trivial C union is used in an invalid context.
3659 NonTrivialCUnionContext UseContext,
3660 unsigned NonTrivialKind);
3661
3662 /// AddInitializerToDecl - Adds the initializer Init to the
3663 /// declaration dcl. If DirectInit is true, this is C++ direct
3664 /// initialization rather than copy initialization.
3665 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
3666 void ActOnUninitializedDecl(Decl *dcl);
3667
3668 /// ActOnInitializerError - Given that there was an error parsing an
3669 /// initializer for the given declaration, try to at least re-establish
3670 /// invariants such as whether a variable's type is either dependent or
3671 /// complete.
3672 void ActOnInitializerError(Decl *Dcl);
3673
3676 IdentifierInfo *Ident,
3677 ParsedAttributes &Attrs);
3678
3679 /// Check if VD needs to be dllexport/dllimport due to being in a
3680 /// dllexport/import function.
3683
3684 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
3685 /// any semantic actions necessary after any initializer has been attached.
3686 void FinalizeDeclaration(Decl *D);
3688 ArrayRef<Decl *> Group);
3689
3690 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
3691 /// group, performing any necessary semantic checking.
3693
3694 /// Should be called on all declarations that might have attached
3695 /// documentation comments.
3698
3699 enum class FnBodyKind {
3700 /// C++26 [dcl.fct.def.general]p1
3701 /// function-body:
3702 /// ctor-initializer[opt] compound-statement
3703 /// function-try-block
3704 Other,
3705 /// = default ;
3706 Default,
3707 /// deleted-function-body
3708 ///
3709 /// deleted-function-body:
3710 /// = delete ;
3711 /// = delete ( unevaluated-string ) ;
3712 Delete
3713 };
3714
3716 SourceLocation LocAfterDecls);
3718 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
3719 SkipBodyInfo *SkipBody = nullptr);
3721 MultiTemplateParamsArg TemplateParamLists,
3722 SkipBodyInfo *SkipBody = nullptr,
3723 FnBodyKind BodyKind = FnBodyKind::Other);
3725 SkipBodyInfo *SkipBody = nullptr,
3726 FnBodyKind BodyKind = FnBodyKind::Other);
3728
3729 /// Determine whether we can delay parsing the body of a function or
3730 /// function template until it is used, assuming we don't care about emitting
3731 /// code for that function.
3732 ///
3733 /// This will be \c false if we may need the body of the function in the
3734 /// middle of parsing an expression (where it's impractical to switch to
3735 /// parsing a different function), for instance, if it's constexpr in C++11
3736 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
3737 bool canDelayFunctionBody(const Declarator &D);
3738
3739 /// Determine whether we can skip parsing the body of a function
3740 /// definition, assuming we don't care about analyzing its body or emitting
3741 /// code for that function.
3742 ///
3743 /// This will be \c false only if we may need the body of the function in
3744 /// order to parse the rest of the program (for instance, if it is
3745 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
3746 bool canSkipFunctionBody(Decl *D);
3747
3748 /// Given the set of return statements within a function body,
3749 /// compute the variables that are subject to the named return value
3750 /// optimization.
3751 ///
3752 /// Each of the variables that is subject to the named return value
3753 /// optimization will be marked as NRVO variables in the AST, and any
3754 /// return statement that has a marked NRVO variable as its NRVO candidate can
3755 /// use the named return value optimization.
3756 ///
3757 /// This function applies a very simplistic algorithm for NRVO: if every
3758 /// return statement in the scope of a variable has the same NRVO candidate,
3759 /// that candidate is an NRVO variable.
3762 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
3765
3766 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
3767 /// attribute for which parsing is delayed.
3769
3770 /// Diagnose any unused parameters in the given sequence of
3771 /// ParmVarDecl pointers.
3773
3774 /// Diagnose whether the size of parameters or return value of a
3775 /// function or obj-c method definition is pass-by-value and larger than a
3776 /// specified threshold.
3777 void
3779 QualType ReturnTy, NamedDecl *D);
3780
3782 SourceLocation RParenLoc);
3783
3786
3788
3789 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3790 /// no declarator (e.g. "struct foo;") is parsed.
3792 const ParsedAttributesView &DeclAttrs,
3793 RecordDecl *&AnonRecord);
3794
3795 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3796 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
3797 /// parameters to cope with template friend declarations.
3799 const ParsedAttributesView &DeclAttrs,
3800 MultiTemplateParamsArg TemplateParams,
3801 bool IsExplicitInstantiation,
3802 RecordDecl *&AnonRecord);
3803
3804 /// BuildAnonymousStructOrUnion - Handle the declaration of an
3805 /// anonymous structure or union. Anonymous unions are a C++ feature
3806 /// (C++ [class.union]) and a C11 feature; anonymous structures
3807 /// are a C11 feature and GNU C++ extension.
3810 const PrintingPolicy &Policy);
3811
3812 /// Called once it is known whether
3813 /// a tag declaration is an anonymous union or struct.
3815
3816 /// Emit diagnostic warnings for placeholder members.
3817 /// We can only do that after the class is fully constructed,
3818 /// as anonymous union/structs can insert placeholders
3819 /// in their parent scope (which might be a Record).
3821
3822 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
3823 /// Microsoft C anonymous structure.
3824 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
3825 /// Example:
3826 ///
3827 /// struct A { int a; };
3828 /// struct B { struct A; int b; };
3829 ///
3830 /// void foo() {
3831 /// B var;
3832 /// var.a = 3;
3833 /// }
3836
3837 /// Common ways to introduce type names without a tag for use in diagnostics.
3838 /// Keep in sync with err_tag_reference_non_tag.
3849 };
3850
3851 /// Given a non-tag type declaration, returns an enum useful for indicating
3852 /// what kind of non-tag type this is.
3854
3855 /// Determine whether a tag with a given kind is acceptable
3856 /// as a redeclaration of the given tag declaration.
3857 ///
3858 /// \returns true if the new tag kind is acceptable, false otherwise.
3860 bool isDefinition, SourceLocation NewTagLoc,
3861 const IdentifierInfo *Name);
3862
3864 // Not parsing a type within __builtin_offsetof.
3866 // Parsing a type within __builtin_offsetof.
3868 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
3869 // To improve our diagnostic message.
3871 };
3872
3873 /// This is invoked when we see 'struct foo' or 'struct {'. In the
3874 /// former case, Name will be non-null. In the later case, Name will be null.
3875 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
3876 /// a reference/declaration/definition of a tag.
3877 ///
3878 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
3879 /// trailing-type-specifier) other than one in an alias-declaration.
3880 ///
3881 /// \param SkipBody If non-null, will be set to indicate if the caller should
3882 /// skip the definition of this tag and treat it as if it were a declaration.
3883 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
3884 SourceLocation KWLoc, CXXScopeSpec &SS,
3885 IdentifierInfo *Name, SourceLocation NameLoc,
3887 SourceLocation ModulePrivateLoc,
3888 MultiTemplateParamsArg TemplateParameterLists,
3889 bool &OwnedDecl, bool &IsDependent,
3890 SourceLocation ScopedEnumKWLoc,
3891 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
3892 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
3893 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
3894
3895 /// ActOnField - Each field of a C struct/union is passed into this in order
3896 /// to create a FieldDecl object for it.
3897 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
3898 Declarator &D, Expr *BitfieldWidth);
3899
3900 /// HandleField - Analyze a field of a C struct or a C++ data member.
3901 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
3902 Declarator &D, Expr *BitfieldWidth,
3903 InClassInitStyle InitStyle, AccessSpecifier AS);
3904
3905 /// Build a new FieldDecl and check its well-formedness.
3906 ///
3907 /// This routine builds a new FieldDecl given the fields name, type,
3908 /// record, etc. \p PrevDecl should refer to any previous declaration
3909 /// with the same name and in the same scope as the field to be
3910 /// created.
3911 ///
3912 /// \returns a new FieldDecl.
3913 ///
3914 /// \todo The Declarator argument is a hack. It will be removed once
3917 SourceLocation Loc, bool Mutable,
3918 Expr *BitfieldWidth, InClassInitStyle InitStyle,
3920 NamedDecl *PrevDecl, Declarator *D = nullptr);
3921
3923
3924 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
3925 /// class and class extensions. For every class \@interface and class
3926 /// extension \@interface, if the last ivar is a bitfield of any type,
3927 /// then add an implicit `char :0` ivar to the end of that interface.
3928 void ActOnLastBitfield(SourceLocation DeclStart,
3929 SmallVectorImpl<Decl *> &AllIvarDecls);
3930
3931 // This is used for both record definitions and ObjC interface declarations.
3932 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
3933 ArrayRef<Decl *> Fields, SourceLocation LBrac,
3934 SourceLocation RBrac, const ParsedAttributesView &AttrList);
3935
3936 /// ActOnTagStartDefinition - Invoked when we have entered the
3937 /// scope of a tag's definition (e.g., for an enumeration, class,
3938 /// struct, or union).
3940
3941 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
3942 /// Differently from C++, actually parse the body and reject / error out
3943 /// in case of a structural mismatch.
3944 bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody);
3945
3947
3948 /// Invoked when we enter a tag definition that we're skipping.
3950
3951 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
3952 /// C++ record definition's base-specifiers clause and are starting its
3953 /// member declarations.
3955 SourceLocation FinalLoc,
3956 bool IsFinalSpelledSealed,
3957 bool IsAbstract,
3958 SourceLocation LBraceLoc);
3959
3960 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
3961 /// the definition of a tag (enumeration, class, struct, or union).
3963 SourceRange BraceRange);
3964
3966
3967 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
3968 /// error parsing the definition of a tag.
3970
3972 EnumConstantDecl *LastEnumConst,
3974 Expr *val);
3975
3976 /// Check that this is a valid underlying type for an enum declaration.
3978
3979 /// Check whether this is a valid redeclaration of a previous enumeration.
3980 /// \return true if the redeclaration was invalid.
3981 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
3982 QualType EnumUnderlyingTy, bool IsFixed,
3983 const EnumDecl *Prev);
3984
3985 /// Determine whether the body of an anonymous enumeration should be skipped.
3986 /// \param II The name of the first enumerator.
3988 SourceLocation IILoc);
3989
3990 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
3992 const ParsedAttributesView &Attrs,
3993 SourceLocation EqualLoc, Expr *Val);
3994 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
3995 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
3996 const ParsedAttributesView &Attr);
3997
3998 /// Set the current declaration context until it gets popped.
3999 void PushDeclContext(Scope *S, DeclContext *DC);
4000 void PopDeclContext();
4001
4002 /// EnterDeclaratorContext - Used when we must lookup names in the context
4003 /// of a declarator's nested name specifier.
4006
4007 /// Enter a template parameter scope, after it's been associated with a
4008 /// particular DeclContext. Causes lookup within the scope to chain through
4009 /// enclosing contexts in the correct order.
4011
4012 /// Push the parameters of D, which must be a function, into scope.
4015
4016 /// Add this decl to the scope shadowed decl chains.
4017 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4018
4019 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4020 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4021 /// true if 'D' belongs to the given declaration context.
4022 ///
4023 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4024 /// enclosing namespace set of the context, rather than contained
4025 /// directly within it.
4026 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4027 bool AllowInlineNamespace = false) const;
4028
4029 /// Finds the scope corresponding to the given decl context, if it
4030 /// happens to be an enclosing scope. Otherwise return NULL.
4032
4033 /// Subroutines of ActOnDeclarator().
4035 TypeSourceInfo *TInfo);
4036 bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New);
4037
4038 /// Describes the kind of merge to perform for availability
4039 /// attributes (including "deprecated", "unavailable", and "availability").
4041 /// Don't merge availability attributes at all.
4043 /// Merge availability attributes for a redeclaration, which requires
4044 /// an exact match.
4046 /// Merge availability attributes for an override, which requires
4047 /// an exact match or a weakening of constraints.
4049 /// Merge availability attributes for an implementation of
4050 /// a protocol requirement.
4052 /// Merge availability attributes for an implementation of
4053 /// an optional protocol requirement.
4056
4057 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4058 void mergeDeclAttributes(NamedDecl *New, Decl *Old,
4060
4061 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4062 /// same name and scope as a previous declaration 'Old'. Figure out
4063 /// how to resolve this situation, merging decls or emitting
4064 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4066 LookupResult &OldDecls);
4067
4068 /// MergeFunctionDecl - We just parsed a function 'New' from
4069 /// declarator D which has the same name and scope as a previous
4070 /// declaration 'Old'. Figure out how to resolve this situation,
4071 /// merging decls or emitting diagnostics as appropriate.
4072 ///
4073 /// In C++, New and Old must be declarations that are not
4074 /// overloaded. Use IsOverload to determine whether New and Old are
4075 /// overloaded, and to select the Old declaration that New should be
4076 /// merged with.
4077 ///
4078 /// Returns true if there was an error, false otherwise.
4079 bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
4080 bool MergeTypeWithOld, bool NewDeclIsDefn);
4081
4082 /// Completes the merge of two function declarations that are
4083 /// known to be compatible.
4084 ///
4085 /// This routine handles the merging of attributes and other
4086 /// properties of function declarations from the old declaration to
4087 /// the new declaration, once we know that New is in fact a
4088 /// redeclaration of Old.
4089 ///
4090 /// \returns false
4092 Scope *S, bool MergeTypeWithOld);
4094
4095 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4096 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4097 /// situation, merging decls or emitting diagnostics as appropriate.
4098 ///
4099 /// Tentative definition rules (C99 6.9.2p2) are checked by
4100 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4101 /// definitions here, since the initializer hasn't been attached.
4103
4104 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4105 /// scope as a previous declaration 'Old'. Figure out how to merge their
4106 /// types, emitting diagnostics as appropriate.
4107 ///
4108 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4109 /// back to here in AddInitializerToDecl. We can't check them before the
4110 /// initializer is attached.
4111 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4112
4113 /// We've just determined that \p Old and \p New both appear to be definitions
4114 /// of the same variable. Either diagnose or fix the problem.
4115 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4116 void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
4117
4118 /// Filters out lookup results that don't fall within the given scope
4119 /// as determined by isDeclInScope.
4121 bool ConsiderLinkage, bool AllowInlineNamespace);
4122
4123 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4124 /// have compatible owning modules.
4126
4127 /// [module.interface]p6:
4128 /// A redeclaration of an entity X is implicitly exported if X was introduced
4129 /// by an exported declaration; otherwise it shall not be exported.
4131
4132 /// A wrapper function for checking the semantic restrictions of
4133 /// a redeclaration within a module.
4135
4136 /// Check the redefinition in C++20 Modules.
4137 ///
4138 /// [basic.def.odr]p14:
4139 /// For any definable item D with definitions in multiple translation units,
4140 /// - if D is a non-inline non-templated function or variable, or
4141 /// - if the definitions in different translation units do not satisfy the
4142 /// following requirements,
4143 /// the program is ill-formed; a diagnostic is required only if the
4144 /// definable item is attached to a named module and a prior definition is
4145 /// reachable at the point where a later definition occurs.
4146 /// - Each such definition shall not be attached to a named module
4147 /// ([module.unit]).
4148 /// - Each such definition shall consist of the same sequence of tokens, ...
4149 /// ...
4150 ///
4151 /// Return true if the redefinition is not allowed. Return false otherwise.
4152 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4153
4155
4156 /// If it's a file scoped decl that must warn if not used, keep track
4157 /// of it.
4159
4160 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4162
4165 DiagReceiverTy DiagReceiver);
4166 void DiagnoseUnusedDecl(const NamedDecl *ND);
4167
4168 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4169 /// unless they are marked attr(unused).
4170 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4171
4172 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4173 /// variable.
4174 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4175
4176 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4177 /// from S, where a non-field would be declared. This routine copes
4178 /// with the difference between C and C++ scoping rules in structs and
4179 /// unions. For example, the following code is well-formed in C but
4180 /// ill-formed in C++:
4181 /// @code
4182 /// struct S6 {
4183 /// enum { BAR } e;
4184 /// };
4185 ///
4186 /// void test_S6() {
4187 /// struct S6 a;
4188 /// a.e = BAR;
4189 /// }
4190 /// @endcode
4191 /// For the declaration of BAR, this routine will return a different
4192 /// scope. The scope S will be the scope of the unnamed enumeration
4193 /// within S6. In C++, this routine will return the scope associated
4194 /// with S6, because the enumeration's scope is a transparent
4195 /// context but structures can contain non-field names. In C, this
4196 /// routine will return the translation unit scope, since the
4197 /// enumeration's scope is a transparent context and structures cannot
4198 /// contain non-field names.
4200
4203
4204 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4205 /// file scope. lazily create a decl for it. ForRedeclaration is true
4206 /// if we're creating this built-in in anticipation of redeclaring the
4207 /// built-in.
4209 bool ForRedeclaration, SourceLocation Loc);
4210
4211 /// Get the outermost AttributedType node that sets a calling convention.
4212 /// Valid types should not have multiple attributes with different CCs.
4214
4215 /// GetNameForDeclarator - Determine the full declaration name for the
4216 /// given Declarator.
4218
4219 /// Retrieves the declaration name from a parsed unqualified-id.
4221
4222 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4223 /// we are currently parsing the initializer.
4225
4226 /// Look for a locally scoped extern "C" declaration by the given name.
4228
4230
4231 /// Adjust the \c DeclContext for a function or variable that might be a
4232 /// function-local external declaration.
4234
4236
4237 /// Checks if the variant/multiversion functions are compatible.
4239 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4240 const PartialDiagnostic &NoProtoDiagID,
4241 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4242 const PartialDiagnosticAt &NoSupportDiagIDAt,
4243 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4244 bool ConstexprSupported, bool CLinkageMayDiffer);
4245
4246 /// type checking declaration initializers (C99 6.7.8)
4248 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4249
4253 Expr *Init);
4254
4256 Expr *Init);
4257
4259
4260 // Heuristically tells if the function is `get_return_object` member of a
4261 // coroutine promise_type by matching the function name.
4262 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4263 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4264
4265 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4266 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4268 Scope *S);
4269
4270 /// If this function is a C++ replaceable global allocation function
4271 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4272 /// adds any function attributes that we know a priori based on the standard.
4273 ///
4274 /// We need to check for duplicate attributes both here and where user-written
4275 /// attributes are applied to declarations.
4277 FunctionDecl *FD);
4278
4279 /// Adds any function attributes that we know a priori based on
4280 /// the declaration of this function.
4281 ///
4282 /// These attributes can apply both to implicitly-declared builtins
4283 /// (like __builtin___printf_chk) or to library-declared functions
4284 /// like NSLog or printf.
4285 ///
4286 /// We need to check for duplicate attributes both here and where user-written
4287 /// attributes are applied to declarations.
4289
4290 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4291 /// the correct width, and that the field type is valid.
4292 /// Returns false on success.
4294 const IdentifierInfo *FieldName, QualType FieldTy,
4295 bool IsMsStruct, Expr *BitWidth);
4296
4297 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4298 /// enum. If AllowMask is true, then we also allow the complement of a valid
4299 /// value, to be used as a mask.
4300 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4301 bool AllowMask) const;
4302
4303 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4304 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4305 SourceLocation WeakNameLoc);
4306
4307 /// ActOnPragmaRedefineExtname - Called on well formed
4308 /// \#pragma redefine_extname oldname newname.
4310 IdentifierInfo *AliasName,
4311 SourceLocation PragmaLoc,
4312 SourceLocation WeakNameLoc,
4313 SourceLocation AliasNameLoc);
4314
4315 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4316 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4317 SourceLocation PragmaLoc,
4318 SourceLocation WeakNameLoc,
4319 SourceLocation AliasNameLoc);
4320
4321 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4323 Emitted,
4324 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4325 OMPDiscarded, // Discarded due to OpenMP hostness
4326 TemplateDiscarded, // Discarded due to uninstantiated templates
4327 Unknown,
4328 };
4329 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4330 bool Final = false);
4331
4332 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4334
4335private:
4336 /// Function or variable declarations to be checked for whether the deferred
4337 /// diagnostics should be emitted.
4338 llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
4339
4340 /// Map of current shadowing declarations to shadowed declarations. Warn if
4341 /// it looks like the user is trying to modify the shadowing declaration.
4342 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4343
4344 // We need this to handle
4345 //
4346 // typedef struct {
4347 // void *foo() { return 0; }
4348 // } A;
4349 //
4350 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4351 // for example. If 'A', foo will have external linkage. If we have '*A',
4352 // foo will have no linkage. Since we can't know until we get to the end
4353 // of the typedef, this function finds out if D might have non-external
4354 // linkage. Callers should verify at the end of the TU if it D has external
4355 // linkage or not.
4356 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4357
4358 ///@}
4359
4360 //
4361 //
4362 // -------------------------------------------------------------------------
4363 //
4364 //
4365
4366 /// \name Declaration Attribute Handling
4367 /// Implementations are in SemaDeclAttr.cpp
4368 ///@{
4369
4370public:
4371 /// Describes the kind of priority given to an availability attribute.
4372 ///
4373 /// The sum of priorities deteremines the final priority of the attribute.
4374 /// The final priority determines how the attribute will be merged.
4375 /// An attribute with a lower priority will always remove higher priority
4376 /// attributes for the specified platform when it is being applied. An
4377 /// attribute with a higher priority will not be applied if the declaration
4378 /// already has an availability attribute with a lower priority for the
4379 /// specified platform. The final prirority values are not expected to match
4380 /// the values in this enumeration, but instead should be treated as a plain
4381 /// integer value. This enumeration just names the priority weights that are
4382 /// used to calculate that final vaue.
4384 /// The availability attribute was specified explicitly next to the
4385 /// declaration.
4387
4388 /// The availability attribute was applied using '#pragma clang attribute'.
4390
4391 /// The availability attribute for a specific platform was inferred from
4392 /// an availability attribute for another platform.
4395
4396 /// Describes the reason a calling convention specification was ignored, used
4397 /// for diagnostics.
4399 ForThisTarget = 0,
4403 };
4404
4405 /// A helper function to provide Attribute Location for the Attr types
4406 /// AND the ParsedAttr.
4407 template <typename AttrInfo>
4408 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4409 getAttrLoc(const AttrInfo &AL) {
4410 return AL.getLocation();
4411 }
4413
4414 /// If Expr is a valid integer constant, get the value of the integer
4415 /// expression and return success or failure. May output an error.
4416 ///
4417 /// Negative argument is implicitly converted to unsigned, unless
4418 /// \p StrictlyUnsigned is true.
4419 template <typename AttrInfo>
4420 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4421 unsigned Idx = UINT_MAX,
4422 bool StrictlyUnsigned = false) {
4423 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4424 if (Expr->isTypeDependent() ||
4426 if (Idx != UINT_MAX)
4427 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4428 << &AI << Idx << AANT_ArgumentIntegerConstant
4429 << Expr->getSourceRange();
4430 else
4431 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4433 return false;
4434 }
4435
4436 if (!I->isIntN(32)) {
4437 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4438 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4439 return false;
4440 }
4441
4442 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
4443 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
4444 << &AI << /*non-negative*/ 1;
4445 return false;
4446 }
4447
4448 Val = (uint32_t)I->getZExtValue();
4449 return true;
4450 }
4451
4452 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
4453 /// \#pragma weak during processing of other Decls.
4454 /// I couldn't figure out a clean way to generate these in-line, so
4455 /// we store them here and handle separately -- which is a hack.
4456 /// It would be best to refactor this.
4458
4459 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
4461
4465
4466 /// ExtVectorDecls - This is a list all the extended vector types. This allows
4467 /// us to associate a raw vector type with one of the ext_vector type names.
4468 /// This is only necessary for issuing pretty diagnostics.
4470
4471 /// Check if the argument \p E is a ASCII string literal. If not emit an error
4472 /// and return false, otherwise set \p Str to the value of the string literal
4473 /// and return true.
4475 const Expr *E, StringRef &Str,
4476 SourceLocation *ArgLocation = nullptr);
4477
4478 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
4479 /// If not emit an error and return false. If the argument is an identifier it
4480 /// will emit an error with a fixit hint and treat it as if it was a string
4481 /// literal.
4482 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
4483 StringRef &Str,
4484 SourceLocation *ArgLocation = nullptr);
4485
4486 /// Determine if type T is a valid subject for a nonnull and similar
4487 /// attributes. By default, we look through references (the behavior used by
4488 /// nonnull), but if the second parameter is true, then we treat a reference
4489 /// type as valid.
4490 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
4491
4492 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
4493 /// declaration.
4495 Expr *OE);
4496
4497 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
4498 /// declaration.
4500 Expr *ParamExpr);
4501
4502 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
4503 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
4504
4505 AvailabilityAttr *mergeAvailabilityAttr(
4506 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform,
4507 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
4508 VersionTuple Obsoleted, bool IsUnavailable, StringRef Message,
4509 bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK,
4510 int Priority, IdentifierInfo *IIEnvironment);
4511
4512 TypeVisibilityAttr *
4514 TypeVisibilityAttr::VisibilityType Vis);
4515 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
4516 VisibilityAttr::VisibilityType Vis);
4517 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
4518 StringRef Name);
4519
4520 /// Used to implement to perform semantic checking on
4521 /// attribute((section("foo"))) specifiers.
4522 ///
4523 /// In this case, "foo" is passed in to be checked. If the section
4524 /// specifier is invalid, return an Error that indicates the problem.
4525 ///
4526 /// This is a simple quality of implementation feature to catch errors
4527 /// and give good diagnostics in cases when the assembler or code generator
4528 /// would otherwise reject the section specifier.
4529 llvm::Error isValidSectionSpecifier(StringRef Str);
4530 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
4531 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
4532 StringRef Name);
4533
4534 // Check for things we'd like to warn about. Multiversioning issues are
4535 // handled later in the process, once we know how many exist.
4536 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
4537
4538 /// Check Target Version attrs
4539 bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
4541 SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
4542 Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
4543 SmallVectorImpl<SmallString<64>> &StringsBuffer);
4544
4545 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
4546 StringRef NewUserDiagnostic);
4547 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
4548 IdentifierInfo *Format, int FormatIdx,
4549 int FirstArg);
4550
4551 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4552 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4553 bool IsPackExpansion);
4555 bool IsPackExpansion);
4556
4557 /// AddAlignValueAttr - Adds an align_value attribute to a particular
4558 /// declaration.
4559 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
4560
4561 /// AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
4563 StringRef Annot, MutableArrayRef<Expr *> Args);
4564
4566 bool BestCase,
4567 MSInheritanceModel SemanticSpelling);
4568
4570
4571 /// AddModeAttr - Adds a mode attribute to a particular declaration.
4572 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
4573 bool InInstantiation = false);
4574 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
4575 const AttributeCommonInfo &CI,
4576 const IdentifierInfo *Ident);
4577 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
4578 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
4579 const AttributeCommonInfo &CI);
4580 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
4581 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
4582 const InternalLinkageAttr &AL);
4583
4584 /// Check validaty of calling convention attribute \p attr. If \p FD
4585 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
4586 /// target. Otherwise, it is specified by \p CFT.
4588 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
4590
4591 /// Checks a regparm attribute, returning true if it is ill-formed and
4592 /// otherwise setting numParams to the appropriate value.
4593 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
4594
4595 /// Create an CUDALaunchBoundsAttr attribute.
4596 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
4597 Expr *MaxThreads,
4598 Expr *MinBlocks,
4599 Expr *MaxBlocks);
4600
4601 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
4602 /// declaration.
4604 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
4605
4606 enum class RetainOwnershipKind { NS, CF, OS };
4607
4608 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
4609 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
4610
4611 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
4612
4613 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
4614 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
4615 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
4616 const AttributeCommonInfo &CI,
4617 bool BestCase,
4618 MSInheritanceModel Model);
4619
4620 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
4621 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
4622 const EnforceTCBLeafAttr &AL);
4623
4624 /// Helper for delayed processing TransparentUnion or
4625 /// BPFPreserveAccessIndexAttr attribute.
4627 const ParsedAttributesView &AttrList);
4628
4629 // Options for ProcessDeclAttributeList().
4632 : IncludeCXX11Attributes(true), IgnoreTypeAttributes(false) {}
4633
4635 ProcessDeclAttributeOptions Result = *this;
4636 Result.IncludeCXX11Attributes = Val;
4637 return Result;
4638 }
4639
4641 ProcessDeclAttributeOptions Result = *this;
4642 Result.IgnoreTypeAttributes = Val;
4643 return Result;
4644 }
4645
4646 // Should C++11 attributes be processed?
4648
4649 // Should any type attributes encountered be ignored?
4650 // If this option is false, a diagnostic will be emitted for any type
4651 // attributes of a kind that does not "slide" from the declaration to
4652 // the decl-specifier-seq.
4654 };
4655
4656 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
4657 /// attribute list to the specified decl, ignoring any type attributes.
4659 const ParsedAttributesView &AttrList,
4660 const ProcessDeclAttributeOptions &Options =
4662
4663 /// Annotation attributes are the only attributes allowed after an access
4664 /// specifier.
4666 const ParsedAttributesView &AttrList);
4667
4668 /// checkUnusedDeclAttributes - Given a declarator which is not being
4669 /// used to build a declaration, complain about any decl attributes
4670 /// which might be lying around on it.
4672
4673 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
4674 /// \#pragma weak needs a non-definition decl and source may not have one.
4677
4678 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
4679 /// applied to it, possibly with an alias.
4680 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
4681
4682 void ProcessPragmaWeak(Scope *S, Decl *D);
4683 // Decl attributes - this routine is the top level dispatcher.
4684 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
4685
4687
4688 /// Given a set of delayed diagnostics, re-emit them as if they had
4689 /// been delayed in the current context instead of in the given pool.
4690 /// Essentially, this just moves them to the current pool.
4692
4693 /// Check if IdxExpr is a valid parameter index for a function or
4694 /// instance method D. May output an error.
4695 ///
4696 /// \returns true if IdxExpr is a valid index.
4697 template <typename AttrInfo>
4698 bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI,
4699 unsigned AttrArgNum,
4700 const Expr *IdxExpr, ParamIdx &Idx,
4701 bool CanIndexImplicitThis = false) {
4703
4704 // In C++ the implicit 'this' function parameter also counts.
4705 // Parameters are counted from one.
4706 bool HP = hasFunctionProto(D);
4707 bool HasImplicitThisParam = isInstanceMethod(D);
4708 bool IV = HP && isFunctionOrMethodVariadic(D);
4709 unsigned NumParams =
4710 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
4711
4712 std::optional<llvm::APSInt> IdxInt;
4713 if (IdxExpr->isTypeDependent() ||
4714 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
4715 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4716 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
4717 << IdxExpr->getSourceRange();
4718 return false;
4719 }
4720
4721 unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX);
4722 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
4723 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
4724 << &AI << AttrArgNum << IdxExpr->getSourceRange();
4725 return false;
4726 }
4727 if (HasImplicitThisParam && !CanIndexImplicitThis) {
4728 if (IdxSource == 1) {
4729 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
4730 << &AI << IdxExpr->getSourceRange();
4731 return false;
4732 }
4733 }
4734
4735 Idx = ParamIdx(IdxSource, D);
4736 return true;
4737 }
4738
4739 ///@}
4740
4741 //
4742 //
4743 // -------------------------------------------------------------------------
4744 //
4745 //
4746
4747 /// \name C++ Declarations
4748 /// Implementations are in SemaDeclCXX.cpp
4749 ///@{
4750
4751public:
4753
4754 /// Called before parsing a function declarator belonging to a function
4755 /// declaration.
4757 unsigned TemplateParameterDepth);
4758
4759 /// Called after parsing a function declarator belonging to a function
4760 /// declaration.
4762
4763 // Act on C++ namespaces
4765 SourceLocation NamespaceLoc,
4766 SourceLocation IdentLoc, IdentifierInfo *Ident,
4767 SourceLocation LBrace,
4768 const ParsedAttributesView &AttrList,
4769 UsingDirectiveDecl *&UsingDecl, bool IsNested);
4770
4771 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
4772 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
4773 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
4774
4776
4777 /// Retrieve the special "std" namespace, which may require us to
4778 /// implicitly define the namespace.
4780
4782 EnumDecl *getStdAlignValT() const;
4783
4785 const IdentifierInfo *MemberOrBase);
4786
4788 /// The '<=>' operator was used in an expression and a builtin operator
4789 /// was selected.
4791 /// A defaulted 'operator<=>' needed the comparison category. This
4792 /// typically only applies to 'std::strong_ordering', due to the implicit
4793 /// fallback return value.
4795 };
4796
4797 /// Lookup the specified comparison category types in the standard
4798 /// library, an check the VarDecls possibly returned by the operator<=>
4799 /// builtins for that type.
4800 ///
4801 /// \return The type of the comparison category type corresponding to the
4802 /// specified Kind, or a null type if an error occurs
4806
4807 /// Tests whether Ty is an instance of std::initializer_list and, if
4808 /// it is and Element is not NULL, assigns the element type to Element.
4809 bool isStdInitializerList(QualType Ty, QualType *Element);
4810
4811 /// Looks for the std::initializer_list template and instantiates it
4812 /// with Element, or emits an error if it's not found.
4813 ///
4814 /// \returns The instantiated template, or null on error.
4816
4817 /// Determine whether Ctor is an initializer-list constructor, as
4818 /// defined in [dcl.init.list]p2.
4819 bool isInitListConstructor(const FunctionDecl *Ctor);
4820
4821 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
4822 SourceLocation NamespcLoc, CXXScopeSpec &SS,
4823 SourceLocation IdentLoc,
4824 IdentifierInfo *NamespcName,
4825 const ParsedAttributesView &AttrList);
4826
4828
4829 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
4830 SourceLocation AliasLoc, IdentifierInfo *Alias,
4831 CXXScopeSpec &SS, SourceLocation IdentLoc,
4832 IdentifierInfo *Ident);
4833
4834 /// Remove decls we can't actually see from a lookup being used to declare
4835 /// shadow using decls.
4836 ///
4837 /// \param S - The scope of the potential shadow decl
4838 /// \param Previous - The lookup of a potential shadow decl's name.
4839 void FilterUsingLookup(Scope *S, LookupResult &lookup);
4840
4841 /// Hides a using shadow declaration. This is required by the current
4842 /// using-decl implementation when a resolvable using declaration in a
4843 /// class is followed by a declaration which would hide or override
4844 /// one or more of the using decl's targets; for example:
4845 ///
4846 /// struct Base { void foo(int); };
4847 /// struct Derived : Base {
4848 /// using Base::foo;
4849 /// void foo(int);
4850 /// };
4851 ///
4852 /// The governing language is C++03 [namespace.udecl]p12:
4853 ///
4854 /// When a using-declaration brings names from a base class into a
4855 /// derived class scope, member functions in the derived class
4856 /// override and/or hide member functions with the same name and
4857 /// parameter types in a base class (rather than conflicting).
4858 ///
4859 /// There are two ways to implement this:
4860 /// (1) optimistically create shadow decls when they're not hidden
4861 /// by existing declarations, or
4862 /// (2) don't create any shadow decls (or at least don't make them
4863 /// visible) until we've fully parsed/instantiated the class.
4864 /// The problem with (1) is that we might have to retroactively remove
4865 /// a shadow decl, which requires several O(n) operations because the
4866 /// decl structures are (very reasonably) not designed for removal.
4867 /// (2) avoids this but is very fiddly and phase-dependent.
4868 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
4869
4870 /// Determines whether to create a using shadow decl for a particular
4871 /// decl, given the set of decls existing prior to this using lookup.
4873 const LookupResult &PreviousDecls,
4874 UsingShadowDecl *&PrevShadow);
4875
4876 /// Builds a shadow declaration corresponding to a 'using' declaration.
4879 UsingShadowDecl *PrevDecl);
4880
4881 /// Checks that the given using declaration is not an invalid
4882 /// redeclaration. Note that this is checking only for the using decl
4883 /// itself, not for any ill-formedness among the UsingShadowDecls.
4885 bool HasTypenameKeyword,
4886 const CXXScopeSpec &SS,
4887 SourceLocation NameLoc,
4888 const LookupResult &Previous);
4889
4890 /// Checks that the given nested-name qualifier used in a using decl
4891 /// in the current context is appropriately related to the current
4892 /// scope. If an error is found, diagnoses it and returns true.
4893 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
4894 /// the result of that lookup. UD is likewise nullptr, except when we have an
4895 /// already-populated UsingDecl whose shadow decls contain the same
4896 /// information (i.e. we're instantiating a UsingDecl with non-dependent
4897 /// scope).
4898 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
4899 const CXXScopeSpec &SS,
4900 const DeclarationNameInfo &NameInfo,
4901 SourceLocation NameLoc,
4902 const LookupResult *R = nullptr,
4903 const UsingDecl *UD = nullptr);
4904
4905 /// Builds a using declaration.
4906 ///
4907 /// \param IsInstantiation - Whether this call arises from an
4908 /// instantiation of an unresolved using declaration. We treat
4909 /// the lookup differently for these declarations.
4911 SourceLocation UsingLoc,
4912 bool HasTypenameKeyword,
4913 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4914 DeclarationNameInfo NameInfo,
4915 SourceLocation EllipsisLoc,
4916 const ParsedAttributesView &AttrList,
4917 bool IsInstantiation, bool IsUsingIfExists);
4919 SourceLocation UsingLoc,
4920 SourceLocation EnumLoc,
4921 SourceLocation NameLoc,
4923 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
4924 ArrayRef<NamedDecl *> Expansions);
4925
4926 /// Additional checks for a using declaration referring to a constructor name.
4928
4929 /// Given a derived-class using shadow declaration for a constructor and the
4930 /// correspnding base class constructor, find or create the implicit
4931 /// synthesized derived class constructor to use for this initialization.
4934 ConstructorUsingShadowDecl *DerivedShadow);
4935
4937 SourceLocation UsingLoc,
4938 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4939 UnqualifiedId &Name, SourceLocation EllipsisLoc,
4940 const ParsedAttributesView &AttrList);
4942 SourceLocation UsingLoc,
4943 SourceLocation EnumLoc, SourceRange TyLoc,
4944 const IdentifierInfo &II, ParsedType Ty,
4945 CXXScopeSpec *SS = nullptr);
4947 MultiTemplateParamsArg TemplateParams,
4948 SourceLocation UsingLoc, UnqualifiedId &Name,
4949 const ParsedAttributesView &AttrList,
4950 TypeResult Type, Decl *DeclFromDeclSpec);
4951
4952 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
4953 /// including handling of its default argument expressions.
4954 ///
4955 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
4957 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4958 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
4959 bool HadMultipleCandidates, bool IsListInitialization,
4960 bool IsStdInitListInitialization, bool RequiresZeroInit,
4961 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4962
4963 /// Build a CXXConstructExpr whose constructor has already been resolved if
4964 /// it denotes an inherited constructor.
4966 SourceLocation ConstructLoc, QualType DeclInitType,
4967 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4968 bool HadMultipleCandidates, bool IsListInitialization,
4969 bool IsStdInitListInitialization, bool RequiresZeroInit,
4970 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4971
4972 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4973 // the constructor can be elidable?
4975 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4976 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4977 bool HadMultipleCandidates, bool IsListInitialization,
4978 bool IsStdInitListInitialization, bool RequiresZeroInit,
4979 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4980
4982 SourceLocation InitLoc);
4983
4984 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4985 /// constructed variable.
4986 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
4987
4988 /// Helper class that collects exception specifications for
4989 /// implicitly-declared special member functions.
4991 // Pointer to allow copying
4992 Sema *Self;
4993 // We order exception specifications thus:
4994 // noexcept is the most restrictive, but is only used in C++11.
4995 // throw() comes next.
4996 // Then a throw(collected exceptions)
4997 // Finally no specification, which is expressed as noexcept(false).
4998 // throw(...) is used instead if any called function uses it.
4999 ExceptionSpecificationType ComputedEST;
5000 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5001 SmallVector<QualType, 4> Exceptions;
5002
5003 void ClearExceptions() {
5004 ExceptionsSeen.clear();
5005 Exceptions.clear();
5006 }
5007
5008 public:
5010 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5011 if (!Self.getLangOpts().CPlusPlus11)
5012 ComputedEST = EST_DynamicNone;
5013 }
5014
5015 /// Get the computed exception specification type.
5017 assert(!isComputedNoexcept(ComputedEST) &&
5018 "noexcept(expr) should not be a possible result");
5019 return ComputedEST;
5020 }
5021
5022 /// The number of exceptions in the exception specification.
5023 unsigned size() const { return Exceptions.size(); }
5024
5025 /// The set of exceptions in the exception specification.
5026 const QualType *data() const { return Exceptions.data(); }
5027
5028 /// Integrate another called method into the collected data.
5029 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5030
5031 /// Integrate an invoked expression into the collected data.
5032 void CalledExpr(Expr *E) { CalledStmt(E); }
5033
5034 /// Integrate an invoked statement into the collected data.
5035 void CalledStmt(Stmt *S);
5036
5037 /// Overwrite an EPI's exception specification with this
5038 /// computed exception specification.
5041 ESI.Type = getExceptionSpecType();
5042 if (ESI.Type == EST_Dynamic) {
5043 ESI.Exceptions = Exceptions;
5044 } else if (ESI.Type == EST_None) {
5045 /// C++11 [except.spec]p14:
5046 /// The exception-specification is noexcept(false) if the set of
5047 /// potential exceptions of the special member function contains "any"
5048 ESI.Type = EST_NoexceptFalse;
5049 ESI.NoexceptExpr =
5050 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5051 }
5052 return ESI;
5053 }
5054 };
5055
5056 /// Evaluate the implicit exception specification for a defaulted
5057 /// special member function.
5059
5060 /// Check the given exception-specification and update the
5061 /// exception specification information with the results.
5062 void checkExceptionSpecification(bool IsTopLevel,
5064 ArrayRef<ParsedType> DynamicExceptions,
5065 ArrayRef<SourceRange> DynamicExceptionRanges,
5066 Expr *NoexceptExpr,
5067 SmallVectorImpl<QualType> &Exceptions,
5069
5070 /// Add an exception-specification to the given member or friend function
5071 /// (or function template). The exception-specification was parsed
5072 /// after the function itself was declared.
5074 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5075 ArrayRef<ParsedType> DynamicExceptions,
5076 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5077
5078 class InheritedConstructorInfo;
5079
5080 /// Determine if a special member function should have a deleted
5081 /// definition when it is defaulted.
5083 InheritedConstructorInfo *ICI = nullptr,
5084 bool Diagnose = false);
5085
5086 /// Produce notes explaining why a defaulted function was defined as deleted.
5088
5089 /// Declare the implicit default constructor for the given class.
5090 ///
5091 /// \param ClassDecl The class declaration into which the implicit
5092 /// default constructor will be added.
5093 ///
5094 /// \returns The implicitly-declared default constructor.
5097
5098 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5099 /// defining this constructor as the default constructor.
5101 CXXConstructorDecl *Constructor);
5102
5103 /// Declare the implicit destructor for the given class.
5104 ///
5105 /// \param ClassDecl The class declaration into which the implicit
5106 /// destructor will be added.
5107 ///
5108 /// \returns The implicitly-declared destructor.
5110
5111 /// DefineImplicitDestructor - Checks for feasibility of
5112 /// defining this destructor as the default destructor.
5113 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5115
5116 /// Build an exception spec for destructors that don't have one.
5117 ///
5118 /// C++11 says that user-defined destructors with no exception spec get one
5119 /// that looks as if the destructor was implicitly declared.
5121
5122 /// Define the specified inheriting constructor.
5124 CXXConstructorDecl *Constructor);
5125
5126 /// Declare the implicit copy constructor for the given class.
5127 ///
5128 /// \param ClassDecl The class declaration into which the implicit
5129 /// copy constructor will be added.
5130 ///
5131 /// \returns The implicitly-declared copy constructor.
5133
5134 /// DefineImplicitCopyConstructor - Checks for feasibility of
5135 /// defining this constructor as the copy constructor.
5136 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5137 CXXConstructorDecl *Constructor);
5138
5139 /// Declare the implicit move constructor for the given class.
5140 ///
5141 /// \param ClassDecl The Class declaration into which the implicit
5142 /// move constructor will be added.
5143 ///
5144 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5145 /// declared.
5147
5148 /// DefineImplicitMoveConstructor - Checks for feasibility of
5149 /// defining this constructor as the move constructor.
5150 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5151 CXXConstructorDecl *Constructor);
5152
5153 /// Declare the implicit copy assignment operator for the given class.
5154 ///
5155 /// \param ClassDecl The class declaration into which the implicit
5156 /// copy assignment operator will be added.
5157 ///
5158 /// \returns The implicitly-declared copy assignment operator.
5160
5161 /// Defines an implicitly-declared copy assignment operator.
5162 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5163 CXXMethodDecl *MethodDecl);
5164
5165 /// Declare the implicit move assignment operator for the given class.
5166 ///
5167 /// \param ClassDecl The Class declaration into which the implicit
5168 /// move assignment operator will be added.
5169 ///
5170 /// \returns The implicitly-declared move assignment operator, or NULL if it
5171 /// wasn't declared.
5173
5174 /// Defines an implicitly-declared move assignment operator.
5175 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5176 CXXMethodDecl *MethodDecl);
5177
5178 /// Check a completed declaration of an implicit special member.
5180
5181 /// Determine whether the given function is an implicitly-deleted
5182 /// special member function.
5184
5185 /// Check whether 'this' shows up in the type of a static member
5186 /// function after the (naturally empty) cv-qualifier-seq would be.
5187 ///
5188 /// \returns true if an error occurred.
5190
5191 /// Whether this' shows up in the exception specification of a static
5192 /// member function.
5194
5195 /// Check whether 'this' shows up in the attributes of the given
5196 /// static member function.
5197 ///
5198 /// \returns true if an error occurred.
5200
5202 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5203
5205
5206 /// Given a constructor and the set of arguments provided for the
5207 /// constructor, convert the arguments and add any required default arguments
5208 /// to form a proper call to this constructor.
5209 ///
5210 /// \returns true if an error occurred, false otherwise.
5212 QualType DeclInitType, MultiExprArg ArgsPtr,
5214 SmallVectorImpl<Expr *> &ConvertedArgs,
5215 bool AllowExplicit = false,
5216 bool IsListInitialization = false);
5217
5218 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5219 /// initializer for the declaration 'Dcl'.
5220 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5221 /// static data member of class X, names should be looked up in the scope of
5222 /// class X.
5224
5225 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5226 /// initializer for the declaration 'Dcl'.
5227 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5228
5229 /// Define the "body" of the conversion from a lambda object to a
5230 /// function pointer.
5231 ///
5232 /// This routine doesn't actually define a sensible body; rather, it fills
5233 /// in the initialization expression needed to copy the lambda object into
5234 /// the block, and IR generation actually generates the real body of the
5235 /// block pointer conversion.
5236 void
5238 CXXConversionDecl *Conv);
5239
5240 /// Define the "body" of the conversion from a lambda object to a
5241 /// block pointer.
5242 ///
5243 /// This routine doesn't actually define a sensible body; rather, it fills
5244 /// in the initialization expression needed to copy the lambda object into
5245 /// the block, and IR generation actually generates the real body of the
5246 /// block pointer conversion.
5248 CXXConversionDecl *Conv);
5249
5250 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5251 /// linkage specification, including the language and (if present)
5252 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5253 /// language string literal. LBraceLoc, if valid, provides the location of
5254 /// the '{' brace. Otherwise, this linkage specification does not
5255 /// have any braces.
5257 Expr *LangStr, SourceLocation LBraceLoc);
5258
5259 /// ActOnFinishLinkageSpecification - Complete the definition of
5260 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5261 /// valid, it's the position of the closing '}' brace in a linkage
5262 /// specification that uses braces.
5264 SourceLocation RBraceLoc);
5265
5266 //===--------------------------------------------------------------------===//
5267 // C++ Classes
5268 //
5269
5270 /// Get the class that is directly named by the current context. This is the
5271 /// class for which an unqualified-id in this scope could name a constructor
5272 /// or destructor.
5273 ///
5274 /// If the scope specifier denotes a class, this will be that class.
5275 /// If the scope specifier is empty, this will be the class whose
5276 /// member-specification we are currently within. Otherwise, there
5277 /// is no such class.
5279
5280 /// isCurrentClassName - Determine whether the identifier II is the
5281 /// name of the class type currently being defined. In the case of
5282 /// nested classes, this will only return true if II is the name of
5283 /// the innermost class.
5284 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5285 const CXXScopeSpec *SS = nullptr);
5286
5287 /// Determine whether the identifier II is a typo for the name of
5288 /// the class type currently being defined. If so, update it to the identifier
5289 /// that should have been used.
5291
5292 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5294 SourceLocation ColonLoc,
5295 const ParsedAttributesView &Attrs);
5296
5297 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5298 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5299 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5300 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5301 /// present (but parsing it has been deferred).
5302 NamedDecl *
5304 MultiTemplateParamsArg TemplateParameterLists,
5305 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5306 InClassInitStyle InitStyle);
5307
5308 /// Enter a new C++ default initializer scope. After calling this, the
5309 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5310 /// parsing or instantiating the initializer failed.
5312
5313 /// This is invoked after parsing an in-class initializer for a
5314 /// non-static C++ class member, and after instantiating an in-class
5315 /// initializer in a class template. Such actions are deferred until the class
5316 /// is complete.
5318 SourceLocation EqualLoc,
5319 Expr *Init);
5320
5321 /// Handle a C++ member initializer using parentheses syntax.
5323 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5324 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5325 const DeclSpec &DS, SourceLocation IdLoc,
5326 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5327 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5328
5329 /// Handle a C++ member initializer using braced-init-list syntax.
5330 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5331 CXXScopeSpec &SS,
5332 IdentifierInfo *MemberOrBase,
5333 ParsedType TemplateTypeTy,
5334 const DeclSpec &DS, SourceLocation IdLoc,
5335 Expr *InitList, SourceLocation EllipsisLoc);
5336
5337 /// Handle a C++ member initializer.
5338 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5339 CXXScopeSpec &SS,
5340 IdentifierInfo *MemberOrBase,
5341 ParsedType TemplateTypeTy,
5342 const DeclSpec &DS, SourceLocation IdLoc,
5343 Expr *Init, SourceLocation EllipsisLoc);
5344
5346 SourceLocation IdLoc);
5347
5349 TypeSourceInfo *BaseTInfo, Expr *Init,
5350 CXXRecordDecl *ClassDecl,
5351 SourceLocation EllipsisLoc);
5352
5354 CXXRecordDecl *ClassDecl);
5355
5358
5360 CXXConstructorDecl *Constructor, bool AnyErrors,
5361 ArrayRef<CXXCtorInitializer *> Initializers = std::nullopt);
5362
5363 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5364 /// mark all the non-trivial destructors of its members and bases as
5365 /// referenced.
5368
5369 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5370 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5371 /// class. In the Microsoft C++ ABI, this is done any time a class's
5372 /// destructor is referenced.
5374 SourceLocation Location, CXXRecordDecl *ClassDecl,
5375 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases = nullptr);
5376
5377 /// Do semantic checks to allow the complete destructor variant to be emitted
5378 /// when the destructor is defined in another translation unit. In the Itanium
5379 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
5380 /// can be emitted in separate TUs. To emit the complete variant, run a subset
5381 /// of the checks performed when emitting a regular destructor.
5383 CXXDestructorDecl *Dtor);
5384
5385 /// The list of classes whose vtables have been used within
5386 /// this translation unit, and the source locations at which the
5387 /// first use occurred.
5388 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
5389
5390 /// The list of vtables that are required but have not yet been
5391 /// materialized.
5393
5394 /// The set of classes whose vtables have been used within
5395 /// this translation unit, and a bit that will be true if the vtable is
5396 /// required to be emitted (otherwise, it should be emitted only if needed
5397 /// by code generation).
5398 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5399
5400 /// Load any externally-stored vtable uses.
5402
5403 /// Note that the vtable for the given class was used at the
5404 /// given location.
5406 bool DefinitionRequired = false);
5407
5408 /// Mark the exception specifications of all virtual member functions
5409 /// in the given class as needed.
5411 const CXXRecordDecl *RD);
5412
5413 /// MarkVirtualMembersReferenced - Will mark all members of the given
5414 /// CXXRecordDecl referenced.
5416 bool ConstexprOnly = false);
5417
5418 /// Define all of the vtables that have been used in this
5419 /// translation unit and reference any virtual members used by those
5420 /// vtables.
5421 ///
5422 /// \returns true if any work was done, false otherwise.
5423 bool DefineUsedVTables();
5424
5425 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
5426 /// special functions, such as the default constructor, copy
5427 /// constructor, or destructor, to the given C++ class (C++
5428 /// [special]p1). This routine can only be executed just before the
5429 /// definition of the class is complete.
5431
5432 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5433 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
5435 bool AnyErrors);
5436
5437 /// Check class-level dllimport/dllexport attribute. The caller must
5438 /// ensure that referenceDLLExportedClassMethods is called some point later
5439 /// when all outer classes of Class are complete.
5442
5444
5445 /// Perform propagation of DLL attributes from a derived class to a
5446 /// templated base class for MS compatibility.
5448 CXXRecordDecl *Class, Attr *ClassAttr,
5449 ClassTemplateSpecializationDecl *BaseTemplateSpec,
5450 SourceLocation BaseLoc);
5451
5452 /// Perform semantic checks on a class definition that has been
5453 /// completing, introducing implicitly-declared members, checking for
5454 /// abstract types, etc.
5455 ///
5456 /// \param S The scope in which the class was parsed. Null if we didn't just
5457 /// parse a class definition.
5458 /// \param Record The completed class.
5460
5461 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
5462 /// conditions that are needed for the attribute to have an effect.
5464
5465 /// Check that VTable Pointer authentication is only being set on the first
5466 /// first instantiation of the vtable
5468
5470 Decl *TagDecl, SourceLocation LBrac,
5471 SourceLocation RBrac,
5472 const ParsedAttributesView &AttrList);
5473
5474 /// Perform any semantic analysis which needs to be delayed until all
5475 /// pending class member declarations have been parsed.
5478
5479 /// This is used to implement the constant expression evaluation part of the
5480 /// attribute enable_if extension. There is nothing in standard C++ which
5481 /// would require reentering parameters.
5483 unsigned ActOnReenterTemplateScope(Decl *Template,
5484 llvm::function_ref<Scope *()> EnterScope);
5486
5487 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
5488 /// parsing a top-level (non-nested) C++ class, and we are now
5489 /// parsing those parts of the given Method declaration that could
5490 /// not be parsed earlier (C++ [class.mem]p2), such as default
5491 /// arguments. This action should enter the scope of the given
5492 /// Method declaration as if we had just parsed the qualified method
5493 /// name. However, it should not bring the parameters into scope;
5494 /// that will be performed by ActOnDelayedCXXMethodParameter.
5496 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
5498
5499 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
5500 /// processing the delayed method declaration for Method. The method
5501 /// declaration is now considered finished. There may be a separate
5502 /// ActOnStartOfFunctionDef action later (not necessarily
5503 /// immediately!) for this method, if it was also defined inside the
5504 /// class body.
5507
5508 bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result,
5509 ASTContext &Ctx,
5510 bool ErrorOnInvalidMessage);
5512 Expr *AssertExpr, Expr *AssertMessageExpr,
5513 SourceLocation RParenLoc);
5515 Expr *AssertExpr, Expr *AssertMessageExpr,
5516 SourceLocation RParenLoc, bool Failed);
5517
5518 /// Try to print more useful information about a failed static_assert
5519 /// with expression \E
5520 void DiagnoseStaticAssertDetails(const Expr *E);
5521
5522 /// Handle a friend type declaration. This works in tandem with
5523 /// ActOnTag.
5524 ///
5525 /// Notes on friend class templates:
5526 ///
5527 /// We generally treat friend class declarations as if they were
5528 /// declaring a class. So, for example, the elaborated type specifier
5529 /// in a friend declaration is required to obey the restrictions of a
5530 /// class-head (i.e. no typedefs in the scope chain), template
5531 /// parameters are required to match up with simple template-ids, &c.
5532 /// However, unlike when declaring a template specialization, it's
5533 /// okay to refer to a template specialization without an empty
5534 /// template parameter declaration, e.g.
5535 /// friend class A<T>::B<unsigned>;
5536 /// We permit this as a special case; if there are any template
5537 /// parameters present at all, require proper matching, i.e.
5538 /// template <> template <class T> friend class A<int>::B;
5539 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
5540 MultiTemplateParamsArg TemplateParams);
5542 MultiTemplateParamsArg TemplateParams);
5543
5544 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
5545 /// the well-formedness of the constructor declarator @p D with type @p
5546 /// R. If there are any errors in the declarator, this routine will
5547 /// emit diagnostics and set the invalid bit to true. In any case, the type
5548 /// will be updated to reflect a well-formed type for the constructor and
5549 /// returned.
5551 StorageClass &SC);
5552
5553 /// CheckConstructor - Checks a fully-formed constructor for
5554 /// well-formedness, issuing any diagnostics required. Returns true if
5555 /// the constructor declarator is invalid.
5556 void CheckConstructor(CXXConstructorDecl *Constructor);
5557
5558 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
5559 /// the well-formednes of the destructor declarator @p D with type @p
5560 /// R. If there are any errors in the declarator, this routine will
5561 /// emit diagnostics and set the declarator to invalid. Even if this happens,
5562 /// will be updated to reflect a well-formed type for the destructor and
5563 /// returned.
5565 StorageClass &SC);
5566
5567 /// CheckDestructor - Checks a fully-formed destructor definition for
5568 /// well-formedness, issuing any diagnostics required. Returns true
5569 /// on error.
5571
5572 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
5573 /// well-formednes of the conversion function declarator @p D with
5574 /// type @p R. If there are any errors in the declarator, this routine
5575 /// will emit diagnostics and return true. Otherwise, it will return
5576 /// false. Either way, the type @p R will be updated to reflect a
5577 /// well-formed type for the conversion operator.
5579
5580 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
5581 /// the declaration of the given C++ conversion function. This routine
5582 /// is responsible for recording the conversion function in the C++
5583 /// class, if possible.
5585
5586 /// Check the validity of a declarator that we parsed for a deduction-guide.
5587 /// These aren't actually declarators in the grammar, so we need to check that
5588 /// the user didn't specify any pieces that are not part of the
5589 /// deduction-guide grammar. Return true on invalid deduction-guide.
5591 StorageClass &SC);
5592
5594
5597 SourceLocation DefaultLoc);
5599
5600 /// Kinds of defaulted comparison operator functions.
5601 enum class DefaultedComparisonKind : unsigned char {
5602 /// This is not a defaultable comparison operator.
5603 None,
5604 /// This is an operator== that should be implemented as a series of
5605 /// subobject comparisons.
5606 Equal,
5607 /// This is an operator<=> that should be implemented as a series of
5608 /// subobject comparisons.
5609 ThreeWay,
5610 /// This is an operator!= that should be implemented as a rewrite in terms
5611 /// of a == comparison.
5612 NotEqual,
5613 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
5614 /// terms of a <=> comparison.
5615 Relational,
5616 };
5617
5621 FunctionDecl *Spaceship);
5624
5626 QualType R, bool IsLambda,
5627 DeclContext *DC = nullptr);
5629 DeclarationName Name, QualType R);
5631
5632 //===--------------------------------------------------------------------===//
5633 // C++ Derived Classes
5634 //
5635
5636 /// Check the validity of a C++ base class specifier.
5637 ///
5638 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
5639 /// and returns NULL otherwise.
5641 SourceRange SpecifierRange, bool Virtual,
5642 AccessSpecifier Access,
5643 TypeSourceInfo *TInfo,
5644 SourceLocation EllipsisLoc);
5645
5646 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
5647 /// one entry in the base class list of a class specifier, for
5648 /// example:
5649 /// class foo : public bar, virtual private baz {
5650 /// 'public bar' and 'virtual private baz' are each base-specifiers.
5651 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
5652 const ParsedAttributesView &Attrs, bool Virtual,
5653 AccessSpecifier Access, ParsedType basetype,
5654 SourceLocation BaseLoc,
5655 SourceLocation EllipsisLoc);
5656
5657 /// Performs the actual work of attaching the given base class
5658 /// specifiers to a C++ class.
5661
5662 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
5663 /// class, after checking whether there are any duplicate base
5664 /// classes.
5665 void ActOnBaseSpecifiers(Decl *ClassDecl,
5667
5668 /// Determine whether the type \p Derived is a C++ class that is
5669 /// derived from the type \p Base.
5671
5672 /// Determine whether the type \p Derived is a C++ class that is
5673 /// derived from the type \p Base.
5675 CXXBasePaths &Paths);
5676
5677 // FIXME: I don't like this name.
5678 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
5679
5682 CXXCastPath *BasePath = nullptr,
5683 bool IgnoreAccess = false);
5684
5685 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
5686 /// conversion (where Derived and Base are class types) is
5687 /// well-formed, meaning that the conversion is unambiguous (and
5688 /// that all of the base classes are accessible). Returns true
5689 /// and emits a diagnostic if the code is ill-formed, returns false
5690 /// otherwise. Loc is the location where this routine should point to
5691 /// if there is an error, and Range is the source range to highlight
5692 /// if there is an error.
5693 ///
5694 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
5695 /// diagnostic for the respective type of error will be suppressed, but the
5696 /// check for ill-formed code will still be performed.
5698 unsigned InaccessibleBaseID,
5699 unsigned AmbiguousBaseConvID,
5701 DeclarationName Name, CXXCastPath *BasePath,
5702 bool IgnoreAccess = false);
5703
5704 /// Builds a string representing ambiguous paths from a
5705 /// specific derived class to different subobjects of the same base
5706 /// class.
5707 ///
5708 /// This function builds a string that can be used in error messages
5709 /// to show the different paths that one can take through the
5710 /// inheritance hierarchy to go from the derived class to different
5711 /// subobjects of a base class. The result looks something like this:
5712 /// @code
5713 /// struct D -> struct B -> struct A
5714 /// struct D -> struct C -> struct A
5715 /// @endcode
5716 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
5717
5719 const CXXMethodDecl *Old);
5720
5721 /// CheckOverridingFunctionReturnType - Checks whether the return types are
5722 /// covariant, according to C++ [class.virtual]p5.
5724 const CXXMethodDecl *Old);
5725
5726 // Check that the overriding method has no explicit object parameter.
5728 const CXXMethodDecl *Old);
5729
5730 /// Mark the given method pure.
5731 ///
5732 /// \param Method the method to be marked pure.
5733 ///
5734 /// \param InitRange the source range that covers the "0" initializer.
5735 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
5736
5737 /// CheckOverrideControl - Check C++11 override control semantics.
5739
5740 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
5741 /// not used in the declaration of an overriding method.
5743
5744 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
5745 /// function overrides a virtual member function marked 'final', according to
5746 /// C++11 [class.virtual]p4.
5748 const CXXMethodDecl *Old);
5749
5760
5761 struct TypeDiagnoser;
5762
5765 TypeDiagnoser &Diagnoser);
5766 template <typename... Ts>
5768 const Ts &...Args) {
5769 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
5770 return RequireNonAbstractType(Loc, T, Diagnoser);
5771 }
5772
5773 void DiagnoseAbstractType(const CXXRecordDecl *RD);
5774
5775 //===--------------------------------------------------------------------===//
5776 // C++ Overloaded Operators [C++ 13.5]
5777 //
5778
5779 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
5780 /// of this overloaded operator is well-formed. If so, returns false;
5781 /// otherwise, emits appropriate diagnostics and returns true.
5783
5784 /// CheckLiteralOperatorDeclaration - Check whether the declaration
5785 /// of this literal operator function is well-formed. If so, returns
5786 /// false; otherwise, emits appropriate diagnostics and returns true.
5788
5789 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
5790 /// found in an explicit(bool) specifier.
5792
5793 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
5794 /// Returns true if the explicit specifier is now resolved.
5796
5797 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
5798 /// C++ if/switch/while/for statement.
5799 /// e.g: "if (int x = f()) {...}"
5801
5802 // Emitting members of dllexported classes is delayed until the class
5803 // (including field initializers) is fully parsed.
5806
5807 /// Merge the exception specifications of two variable declarations.
5808 ///
5809 /// This is called when there's a redeclaration of a VarDecl. The function
5810 /// checks if the redeclaration might have an exception specification and
5811 /// validates compatibility and merges the specs if necessary.
5813
5814 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
5815 /// function, once we already know that they have the same
5816 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
5817 /// error, false otherwise.
5819
5820 /// Helpers for dealing with blocks and functions.
5822
5823 /// CheckExtraCXXDefaultArguments - Check for any extra default
5824 /// arguments in the declarator, which is not a function declaration
5825 /// or definition and therefore is not permitted to have default
5826 /// arguments. This routine should be invoked for every declarator
5827 /// that is not a function declaration or definition.
5829
5832 }
5833
5834 /// Perform semantic analysis for the variable declaration that
5835 /// occurs within a C++ catch clause, returning the newly-created
5836 /// variable.
5838 SourceLocation StartLoc,
5839 SourceLocation IdLoc,
5840 const IdentifierInfo *Id);
5841
5842 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
5843 /// handler.
5845
5847
5848 /// Handle a friend tag declaration where the scope specifier was
5849 /// templated.
5851 unsigned TagSpec, SourceLocation TagLoc,
5852 CXXScopeSpec &SS, IdentifierInfo *Name,
5853 SourceLocation NameLoc,
5855 MultiTemplateParamsArg TempParamLists);
5856
5858 SourceLocation DeclStart, Declarator &D,
5859 Expr *BitfieldWidth,
5860 InClassInitStyle InitStyle,
5861 AccessSpecifier AS,
5862 const ParsedAttr &MSPropertyAttr);
5863
5864 /// Diagnose why the specified class does not have a trivial special member of
5865 /// the given kind.
5868
5870 /// The triviality of a method unaffected by "trivial_abi".
5872
5873 /// The triviality of a method affected by "trivial_abi".
5876
5877 /// Determine whether a defaulted or deleted special member function is
5878 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
5879 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
5882 bool Diagnose = false);
5883
5884 /// For a defaulted function, the kind of defaulted function that it is.
5886 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
5887 unsigned SpecialMember : 8;
5888 unsigned Comparison : 8;
5889
5890 public:
5892 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5893 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5895 : SpecialMember(llvm::to_underlying(CSM)),
5896 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5898 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5899 Comparison(llvm::to_underlying(Comp)) {}
5900
5901 bool isSpecialMember() const {
5902 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
5903 CXXSpecialMemberKind::Invalid;
5904 }
5905 bool isComparison() const {
5906 return static_cast<DefaultedComparisonKind>(Comparison) !=
5907 DefaultedComparisonKind::None;
5908 }
5909
5910 explicit operator bool() const {
5911 return isSpecialMember() || isComparison();
5912 }
5913
5915 return static_cast<CXXSpecialMemberKind>(SpecialMember);
5916 }
5918 return static_cast<DefaultedComparisonKind>(Comparison);
5919 }
5920
5921 /// Get the index of this function kind for use in diagnostics.
5922 unsigned getDiagnosticIndex() const {
5923 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
5924 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
5925 "invalid should have highest index");
5926 static_assert((unsigned)DefaultedComparisonKind::None == 0,
5927 "none should be equal to zero");
5928 return SpecialMember + Comparison;
5929 }
5930 };
5931
5932 /// Determine the kind of defaulting that would be done for a given function.
5933 ///
5934 /// If the function is both a default constructor and a copy / move
5935 /// constructor (due to having a default argument for the first parameter),
5936 /// this picks CXXSpecialMemberKind::DefaultConstructor.
5937 ///
5938 /// FIXME: Check that case is properly handled by all callers.
5939 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
5940
5941 /// Handle a C++11 empty-declaration and attribute-declaration.
5943 SourceLocation SemiLoc);
5944
5946 /// Diagnose issues that are non-constant or that are extensions.
5947 Diagnose,
5948 /// Identify whether this function satisfies the formal rules for constexpr
5949 /// functions in the current lanugage mode (with no extensions).
5951 };
5952
5953 // Check whether a function declaration satisfies the requirements of a
5954 // constexpr function definition or a constexpr constructor definition. If so,
5955 // return true. If not, produce appropriate diagnostics (unless asked not to
5956 // by Kind) and return false.
5957 //
5958 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
5961
5962 /// Diagnose methods which overload virtual methods in a base class
5963 /// without overriding any.
5965
5966 /// Check if a method overloads virtual methods in a base class without
5967 /// overriding any.
5968 void
5970 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5971 void
5973 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5974
5975 /// ActOnParamDefaultArgument - Check whether the default argument
5976 /// provided for a function parameter is well-formed. If so, attach it
5977 /// to the parameter declaration.
5978 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
5979 Expr *defarg);
5980
5981 /// ActOnParamUnparsedDefaultArgument - We've seen a default
5982 /// argument for a function parameter, but we can't parse it yet
5983 /// because we're inside a class definition. Note that this default
5984 /// argument will be parsed later.
5986 SourceLocation ArgLoc);
5987
5988 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
5989 /// the default argument for the parameter param failed.
5991 Expr *DefaultArg);
5993 SourceLocation EqualLoc);
5994 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
5995 SourceLocation EqualLoc);
5996
5997 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
5998 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
5999 StringLiteral *Message = nullptr);
6000 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6001
6003 StringLiteral *DeletedMessage = nullptr);
6007
6008 NamedDecl *
6010 MultiTemplateParamsArg TemplateParamLists);
6013 RecordDecl *ClassDecl,
6014 const IdentifierInfo *Name);
6015
6017
6018 /// Stack containing information needed when in C++2a an 'auto' is encountered
6019 /// in a function declaration parameter type specifier in order to invent a
6020 /// corresponding template parameter in the enclosing abbreviated function
6021 /// template. This information is also present in LambdaScopeInfo, stored in
6022 /// the FunctionScopes stack.
6024
6025 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6026 std::unique_ptr<CXXFieldCollector> FieldCollector;
6027
6029 /// Set containing all declared private fields that are not used.
6031
6033
6034 /// PureVirtualClassDiagSet - a set of class declarations which we have
6035 /// emitted a list of pure virtual functions. Used to prevent emitting the
6036 /// same list more than once.
6037 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6038
6042
6043 /// All the delegating constructors seen so far in the file, used for
6044 /// cycle detection at the end of the TU.
6046
6047 /// The C++ "std" namespace, where the standard library resides.
6049
6050 /// The C++ "std::initializer_list" template, which is defined in
6051 /// <initializer_list>.
6053
6054 // Contains the locations of the beginning of unparsed default
6055 // argument locations.
6056 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6057
6058 /// UndefinedInternals - all the used, undefined objects which require a
6059 /// definition in this translation unit.
6060 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6061
6062 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6064
6065 /// The C++ special members which we are currently in the process of
6066 /// declaring. If this process recursively triggers the declaration of the
6067 /// same special member, we should act as if it is not yet declared.
6069
6071
6072 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6073
6076 ParsingClassDepth++;
6078 }
6080 ParsingClassDepth--;
6082 }
6083
6085 CXXScopeSpec &SS,
6086 ParsedType TemplateTypeTy,
6087 IdentifierInfo *MemberOrBase);
6088
6089private:
6090 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6091 QualType ResultTy,
6092 ArrayRef<QualType> Args);
6093
6094 // A cache representing if we've fully checked the various comparison category
6095 // types stored in ASTContext. The bit-index corresponds to the integer value
6096 // of a ComparisonCategoryType enumerator.
6097 llvm::SmallBitVector FullyCheckedComparisonCategories;
6098
6099 /// Check if there is a field shadowing.
6100 void CheckShadowInheritedFields(const SourceLocation &Loc,
6101 DeclarationName FieldName,
6102 const CXXRecordDecl *RD,
6103 bool DeclIsField = true);
6104
6105 ///@}
6106
6107 //
6108 //
6109 // -------------------------------------------------------------------------
6110 //
6111 //
6112
6113 /// \name C++ Exception Specifications
6114 /// Implementations are in SemaExceptionSpec.cpp
6115 ///@{
6116
6117public:
6118 /// All the overriding functions seen during a class definition
6119 /// that had their exception spec checks delayed, plus the overridden
6120 /// function.
6123
6124 /// All the function redeclarations seen during a class definition that had
6125 /// their exception spec checks delayed, plus the prior declaration they
6126 /// should be checked against. Except during error recovery, the new decl
6127 /// should always be a friend declaration, as that's the only valid way to
6128 /// redeclare a special member before its class is complete.
6131
6132 /// Determine if we're in a case where we need to (incorrectly) eagerly
6133 /// parse an exception specification to work around a libstdc++ bug.
6135
6136 /// Check the given noexcept-specifier, convert its expression, and compute
6137 /// the appropriate ExceptionSpecificationType.
6138 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6140
6141 CanThrowResult canThrow(const Stmt *E);
6142 /// Determine whether the callee of a particular function call can throw.
6143 /// E, D and Loc are all optional.
6144 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6147 const FunctionProtoType *FPT);
6150
6151 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6152 /// exception specification. Incomplete types, or pointers to incomplete types
6153 /// other than void are not allowed.
6154 ///
6155 /// \param[in,out] T The exception type. This will be decayed to a pointer
6156 /// type
6157 /// when the input is an array or a function type.
6159
6160 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6161 /// pointer to member to a function with an exception specification. This
6162 /// means that it is invalid to add another level of indirection.
6165
6166 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6167 /// exception specifications. Exception specifications are equivalent if
6168 /// they allow exactly the same set of exception types. It does not matter how
6169 /// that is achieved. See C++ [except.spec]p2.
6171 SourceLocation OldLoc,
6172 const FunctionProtoType *New,
6173 SourceLocation NewLoc);
6175 const PartialDiagnostic &NoteID,
6176 const FunctionProtoType *Old,
6177 SourceLocation OldLoc,
6178 const FunctionProtoType *New,
6179 SourceLocation NewLoc);
6180 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6181
6182 /// CheckExceptionSpecSubset - Check whether the second function type's
6183 /// exception specification is a subset (or equivalent) of the first function
6184 /// type. This is used by override and pointer assignment checks.
6186 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6187 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6188 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6189 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6190 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6191
6192 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6193 /// two functions have equivalent exception specs. This is part of the
6194 /// assignment and override compatibility check. We do not check the
6195 /// parameters of parameter function pointers recursively, as no sane
6196 /// programmer would even be able to write such a function type.
6198 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6199 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6200 SourceLocation TargetLoc, const FunctionProtoType *Source,
6201 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6202
6203 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6204
6205 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6206 /// spec is a subset of base spec.
6208 const CXXMethodDecl *Old);
6209
6210 ///@}
6211
6212 //
6213 //
6214 // -------------------------------------------------------------------------
6215 //
6216 //
6217
6218 /// \name Expressions
6219 /// Implementations are in SemaExpr.cpp
6220 ///@{
6221
6222public:
6223 /// Describes how the expressions currently being parsed are
6224 /// evaluated at run-time, if at all.
6226 /// The current expression and its subexpressions occur within an
6227 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6228 /// \c sizeof, where the type of the expression may be significant but
6229 /// no code will be generated to evaluate the value of the expression at
6230 /// run time.
6232
6233 /// The current expression occurs within a braced-init-list within
6234 /// an unevaluated operand. This is mostly like a regular unevaluated
6235 /// context, except that we still instantiate constexpr functions that are
6236 /// referenced here so that we can perform narrowing checks correctly.
6238
6239 /// The current expression occurs within a discarded statement.
6240 /// This behaves largely similarly to an unevaluated operand in preventing
6241 /// definitions from being required, but not in other ways.
6243
6244 /// The current expression occurs within an unevaluated
6245 /// operand that unconditionally permits abstract references to
6246 /// fields, such as a SIZE operator in MS-style inline assembly.
6248
6249 /// The current context is "potentially evaluated" in C++11 terms,
6250 /// but the expression is evaluated at compile-time (like the values of
6251 /// cases in a switch statement).
6253
6254 /// In addition of being constant evaluated, the current expression
6255 /// occurs in an immediate function context - either a consteval function
6256 /// or a consteval if statement.
6258
6259 /// The current expression is potentially evaluated at run time,
6260 /// which means that code may be generated to evaluate the value of the
6261 /// expression at run time.
6263
6264 /// The current expression is potentially evaluated, but any
6265 /// declarations referenced inside that expression are only used if
6266 /// in fact the current expression is used.
6267 ///
6268 /// This value is used when parsing default function arguments, for which
6269 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6270 /// through varargs) but do not want to mark declarations as "referenced"
6271 /// until the default argument is used.
6273 };
6274
6275 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6276 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6277 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6278 /// have been applied to all subexpressions of the enclosing full expression.
6279 /// This is cleared at the end of each full expression.
6282
6283 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6284
6285 /// Data structure used to record current or nested
6286 /// expression evaluation contexts.
6288 /// The expression evaluation context.
6290
6291 /// Whether the enclosing context needed a cleanup.
6293
6294 /// The number of active cleanup objects when we entered
6295 /// this expression evaluation context.
6297
6298 /// The number of typos encountered during this expression evaluation
6299 /// context (i.e. the number of TypoExprs created).
6300 unsigned NumTypos;
6301
6303
6304 /// The lambdas that are present within this context, if it
6305 /// is indeed an unevaluated context.
6307
6308 /// The declaration that provides context for lambda expressions
6309 /// and block literals if the normal declaration context does not
6310 /// suffice, e.g., in a default function argument.
6312
6313 /// If we are processing a decltype type, a set of call expressions
6314 /// for which we have deferred checking the completeness of the return type.
6316
6317 /// If we are processing a decltype type, a set of temporary binding
6318 /// expressions for which we have deferred checking the destructor.
6320
6322
6323 /// Expressions appearing as the LHS of a volatile assignment in this
6324 /// context. We produce a warning for these when popping the context if
6325 /// they are not discarded-value expressions nor unevaluated operands.
6327
6328 /// Set of candidates for starting an immediate invocation.
6331
6332 /// Set of DeclRefExprs referencing a consteval function when used in a
6333 /// context not already known to be immediately invoked.
6335
6336 /// P2718R0 - Lifetime extension in range-based for loops.
6337 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6338 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6339 /// InLifetimeExtendingContext is true.
6341
6342 /// \brief Describes whether we are in an expression constext which we have
6343 /// to handle differently.
6348 EK_Other
6349 } ExprContext;
6350
6351 // A context can be nested in both a discarded statement context and
6352 // an immediate function context, so they need to be tracked independently.
6356
6357 bool IsCurrentlyCheckingDefaultArgumentOrInitializer = false;
6358
6359 // We are in a constant context, but we also allow
6360 // non constant expressions, for example for array bounds (which may be
6361 // VLAs).
6362 bool InConditionallyConstantEvaluateContext = false;
6363
6364 /// Whether we are currently in a context in which all temporaries must be
6365 /// lifetime-extended, even if they're not bound to a reference (for
6366 /// example, in a for-range initializer).
6367 bool InLifetimeExtendingContext = false;
6368
6369 // When evaluating immediate functions in the initializer of a default
6370 // argument or default member initializer, this is the declaration whose
6371 // default initializer is being evaluated and the location of the call
6372 // or constructor definition.
6375 DeclContext *Context)
6376 : Loc(Loc), Decl(Decl), Context(Context) {
6377 assert(Decl && Context && "invalid initialization context");
6378 }
6379
6381 ValueDecl *Decl = nullptr;
6382 DeclContext *Context = nullptr;
6383 };
6384 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6385
6387 unsigned NumCleanupObjects,
6388 CleanupInfo ParentCleanup,
6389 Decl *ManglingContextDecl,
6390 ExpressionKind ExprContext)
6391 : Context(Context), ParentCleanup(ParentCleanup),
6392 NumCleanupObjects(NumCleanupObjects), NumTypos(0),
6393 ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext),
6394 InDiscardedStatement(false), InImmediateFunctionContext(false),
6395 InImmediateEscalatingFunctionContext(false) {}
6396
6397 bool isUnevaluated() const {
6398 return Context == ExpressionEvaluationContext::Unevaluated ||
6399 Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
6400 Context == ExpressionEvaluationContext::UnevaluatedList;
6401 }
6402
6404 return Context == ExpressionEvaluationContext::PotentiallyEvaluated ||
6405 Context ==
6406 ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed ||
6407 Context == ExpressionEvaluationContext::ConstantEvaluated;
6408 }
6409
6410 bool isConstantEvaluated() const {
6411 return Context == ExpressionEvaluationContext::ConstantEvaluated ||
6412 Context == ExpressionEvaluationContext::ImmediateFunctionContext;
6413 }
6414
6416 return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
6417 (Context == ExpressionEvaluationContext::DiscardedStatement &&
6418 InImmediateFunctionContext) ||
6419 // C++23 [expr.const]p14:
6420 // An expression or conversion is in an immediate function
6421 // context if it is potentially evaluated and either:
6422 // * its innermost enclosing non-block scope is a function
6423 // parameter scope of an immediate function, or
6424 // * its enclosing statement is enclosed by the compound-
6425 // statement of a consteval if statement.
6426 (Context == ExpressionEvaluationContext::PotentiallyEvaluated &&
6427 InImmediateFunctionContext);
6428 }
6429
6431 return Context == ExpressionEvaluationContext::DiscardedStatement ||
6432 (Context ==
6433 ExpressionEvaluationContext::ImmediateFunctionContext &&
6434 InDiscardedStatement);
6435 }
6436 };
6437
6439 assert(!ExprEvalContexts.empty() &&
6440 "Must be in an expression evaluation context");
6441 return ExprEvalContexts.back();
6442 };
6443
6445 assert(!ExprEvalContexts.empty() &&
6446 "Must be in an expression evaluation context");
6447 return ExprEvalContexts.back();
6448 };
6449
6451 assert(ExprEvalContexts.size() >= 2 &&
6452 "Must be in an expression evaluation context");
6453 return ExprEvalContexts[ExprEvalContexts.size() - 2];
6454 };
6455
6457 return const_cast<Sema *>(this)->parentEvaluationContext();
6458 };
6459
6460 bool isAttrContext() const {
6461 return ExprEvalContexts.back().ExprContext ==
6463 }
6464
6465 /// Increment when we find a reference; decrement when we find an ignored
6466 /// assignment. Ultimately the value is 0 if every reference is an ignored
6467 /// assignment.
6468 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
6469
6470 /// Used to control the generation of ExprWithCleanups.
6472
6473 /// ExprCleanupObjects - This is the stack of objects requiring
6474 /// cleanup that are created by the current full expression.
6476
6477 // AssignmentAction - This is used by all the assignment diagnostic functions
6478 // to represent what is actually causing the operation
6489
6490 /// Determine whether the use of this declaration is valid, without
6491 /// emitting diagnostics.
6492 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
6493 // A version of DiagnoseUseOfDecl that should be used if overload resolution
6494 // has been used to find this declaration, which means we don't have to bother
6495 // checking the trailing requires clause.
6497 return DiagnoseUseOfDecl(
6498 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
6499 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
6500 /*SkipTrailingRequiresClause=*/true);
6501 }
6502
6503 /// Determine whether the use of this declaration is valid, and
6504 /// emit any corresponding diagnostics.
6505 ///
6506 /// This routine diagnoses various problems with referencing
6507 /// declarations that can occur when using a declaration. For example,
6508 /// it might warn if a deprecated or unavailable declaration is being
6509 /// used, or produce an error (and return true) if a C++0x deleted
6510 /// function is being used.
6511 ///
6512 /// \returns true if there was an error (this declaration cannot be
6513 /// referenced), false otherwise.
6515 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
6516 bool ObjCPropertyAccess = false,
6517 bool AvoidPartialAvailabilityChecks = false,
6518 ObjCInterfaceDecl *ClassReciever = nullptr,
6519 bool SkipTrailingRequiresClause = false);
6520
6521 /// Emit a note explaining that this function is deleted.
6523
6524 /// DiagnoseSentinelCalls - This routine checks whether a call or
6525 /// message-send is to a declaration with the sentinel attribute, and
6526 /// if so, it checks that the requirements of the sentinel are
6527 /// satisfied.
6529 ArrayRef<Expr *> Args);
6530
6532 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
6541
6543
6547
6548 /// Check whether E, which is either a discarded-value expression or an
6549 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
6550 /// lvalue, and if so, remove it from the list of volatile-qualified
6551 /// assignments that we are going to warn are deprecated.
6553
6555
6556 // Functions for marking a declaration referenced. These functions also
6557 // contain the relevant logic for marking if a reference to a function or
6558 // variable is an odr-use (in the C++11 sense). There are separate variants
6559 // for expressions referring to a decl; these exist because odr-use marking
6560 // needs to be delayed for some constant variables when we build one of the
6561 // named expressions.
6562 //
6563 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
6564 // should usually be true. This only needs to be set to false if the lack of
6565 // odr-use cannot be determined from the current context (for instance,
6566 // because the name denotes a virtual function and was written without an
6567 // explicit nested-name-specifier).
6568 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
6569
6570 /// Mark a function referenced, and check whether it is odr-used
6571 /// (C++ [basic.def.odr]p2, C99 6.9p3)
6573 bool MightBeOdrUse = true);
6574
6575 /// Mark a variable referenced, and check whether it is odr-used
6576 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
6577 /// used directly for normal expressions referring to VarDecl.
6579
6580 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
6581 ///
6582 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
6583 /// be handled with care if the DeclRefExpr is not newly-created.
6584 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
6585
6586 /// Perform reference-marking and odr-use handling for a MemberExpr.
6588
6589 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
6592 unsigned CapturingScopeIndex);
6593
6595 void CleanupVarDeclMarking();
6596
6602
6603 /// Try to capture the given variable.
6604 ///
6605 /// \param Var The variable to capture.
6606 ///
6607 /// \param Loc The location at which the capture occurs.
6608 ///
6609 /// \param Kind The kind of capture, which may be implicit (for either a
6610 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
6611 ///
6612 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
6613 /// an explicit lambda capture.
6614 ///
6615 /// \param BuildAndDiagnose Whether we are actually supposed to add the
6616 /// captures or diagnose errors. If false, this routine merely check whether
6617 /// the capture can occur without performing the capture itself or complaining
6618 /// if the variable cannot be captured.
6619 ///
6620 /// \param CaptureType Will be set to the type of the field used to capture
6621 /// this variable in the innermost block or lambda. Only valid when the
6622 /// variable can be captured.
6623 ///
6624 /// \param DeclRefType Will be set to the type of a reference to the capture
6625 /// from within the current scope. Only valid when the variable can be
6626 /// captured.
6627 ///
6628 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
6629 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
6630 /// This is useful when enclosing lambdas must speculatively capture
6631 /// variables that may or may not be used in certain specializations of
6632 /// a nested generic lambda.
6633 ///
6634 /// \returns true if an error occurred (i.e., the variable cannot be
6635 /// captured) and false if the capture succeeded.
6637 TryCaptureKind Kind, SourceLocation EllipsisLoc,
6638 bool BuildAndDiagnose, QualType &CaptureType,
6639 QualType &DeclRefType,
6640 const unsigned *const FunctionScopeIndexToStopAt);
6641
6642 /// Try to capture the given variable.
6645 SourceLocation EllipsisLoc = SourceLocation());
6646
6647 /// Checks if the variable must be captured.
6649
6650 /// Given a variable, determine the type that a reference to that
6651 /// variable will have in the given scope.
6653
6654 /// Mark all of the declarations referenced within a particular AST node as
6655 /// referenced. Used when template instantiation instantiates a non-dependent
6656 /// type -- entities referenced by the type are now referenced.
6658
6659 /// Mark any declarations that appear within this expression or any
6660 /// potentially-evaluated subexpressions as "referenced".
6661 ///
6662 /// \param SkipLocalVariables If true, don't mark local variables as
6663 /// 'referenced'.
6664 /// \param StopAt Subexpressions that we shouldn't recurse into.
6666 Expr *E, bool SkipLocalVariables = false,
6667 ArrayRef<const Expr *> StopAt = std::nullopt);
6668
6669 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
6670 /// conversion.
6672
6673 /// Conditionally issue a diagnostic based on the statements's reachability
6674 /// analysis.
6675 ///
6676 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
6677 /// the function body is parsed, and then do a basic reachability analysis to
6678 /// determine if the statement is reachable. If it is unreachable, the
6679 /// diagnostic will not be emitted.
6681 const PartialDiagnostic &PD);
6682
6683 /// Conditionally issue a diagnostic based on the current
6684 /// evaluation context.
6685 ///
6686 /// \param Statement If Statement is non-null, delay reporting the
6687 /// diagnostic until the function body is parsed, and then do a basic
6688 /// reachability analysis to determine if the statement is reachable.
6689 /// If it is unreachable, the diagnostic will not be emitted.
6690 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
6691 const PartialDiagnostic &PD);
6692 /// Similar, but diagnostic is only produced if all the specified statements
6693 /// are reachable.
6695 const PartialDiagnostic &PD);
6696
6697 // Primary Expressions.
6699
6701 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
6702 bool HasTrailingLParen, bool IsAddressOfOperand,
6703 CorrectionCandidateCallback *CCC = nullptr,
6704 bool IsInlineAsmIdentifier = false,
6705 Token *KeywordReplacement = nullptr);
6706
6707 /// Decomposes the given name into a DeclarationNameInfo, its location, and
6708 /// possibly a list of template arguments.
6709 ///
6710 /// If this produces template arguments, it is permitted to call
6711 /// DecomposeTemplateName.
6712 ///
6713 /// This actually loses a lot of source location information for
6714 /// non-standard name kinds; we should consider preserving that in
6715 /// some way.
6718 DeclarationNameInfo &NameInfo,
6719 const TemplateArgumentListInfo *&TemplateArgs);
6720
6721 /// Diagnose a lookup that found results in an enclosing class during error
6722 /// recovery. This usually indicates that the results were found in a
6723 /// dependent base class that could not be searched as part of a template
6724 /// definition. Always issues a diagnostic (though this may be only a warning
6725 /// in MS compatibility mode).
6726 ///
6727 /// Return \c true if the error is unrecoverable, or \c false if the caller
6728 /// should attempt to recover using these lookup results.
6730
6731 /// Diagnose an empty lookup.
6732 ///
6733 /// \return false if new lookup candidates were found
6734 bool
6737 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
6738 ArrayRef<Expr *> Args = std::nullopt,
6739 DeclContext *LookupCtx = nullptr,
6740 TypoExpr **Out = nullptr);
6741
6742 /// If \p D cannot be odr-used in the current expression evaluation context,
6743 /// return a reason explaining why. Otherwise, return NOUR_None.
6745
6748 const CXXScopeSpec *SS = nullptr);
6749 DeclRefExpr *
6751 const DeclarationNameInfo &NameInfo,
6752 const CXXScopeSpec *SS = nullptr,
6753 NamedDecl *FoundD = nullptr,
6754 SourceLocation TemplateKWLoc = SourceLocation(),
6755 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6756
6757 /// BuildDeclRefExpr - Build an expression that references a
6758 /// declaration that does not require a closure capture.
6759 DeclRefExpr *
6761 const DeclarationNameInfo &NameInfo,
6762 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
6763 SourceLocation TemplateKWLoc = SourceLocation(),
6764 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6765
6766 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
6767 bool HasTrailingLParen);
6768
6769 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
6770 /// declaration name, generally during template instantiation.
6771 /// There's a large number of things which don't need to be done along
6772 /// this path.
6774 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
6775 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
6776
6778 bool NeedsADL,
6779 bool AcceptInvalidDecl = false);
6780
6781 /// Complete semantic analysis for a reference to the given declaration.
6783 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
6784 NamedDecl *FoundD = nullptr,
6785 const TemplateArgumentListInfo *TemplateArgs = nullptr,
6786 bool AcceptInvalidDecl = false);
6787
6788 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
6789 // where Tokens representing function local predefined macros (such as
6790 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
6792
6796
6797 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
6798
6799 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
6801 Scope *UDLScope = nullptr);
6804 MultiExprArg Val);
6805
6806 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
6807 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
6808 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
6809 /// from multiple tokens. However, the common case is that StringToks points
6810 /// to one string.
6812 Scope *UDLScope = nullptr);
6813
6815
6816 /// ControllingExprOrType is either an opaque pointer coming out of a
6817 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
6818 /// into two so we don't take a void *, but that's awkward because one of
6819 /// the operands is either a ParsedType or an Expr *, which doesn't lend
6820 /// itself to generic code very well.
6822 SourceLocation DefaultLoc,
6823 SourceLocation RParenLoc,
6824 bool PredicateIsExpr,
6825 void *ControllingExprOrType,
6826 ArrayRef<ParsedType> ArgTypes,
6827 ArrayRef<Expr *> ArgExprs);
6828 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
6829 /// it'd be better to split this interface into two so we don't take a
6830 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
6831 /// isn't a trivial change.
6833 SourceLocation DefaultLoc,
6834 SourceLocation RParenLoc,
6835 bool PredicateIsExpr,
6836 void *ControllingExprOrType,
6838 ArrayRef<Expr *> Exprs);
6839
6840 // Binary/Unary Operators. 'Tok' is the token for the operator.
6842 Expr *InputExpr, bool IsAfterAmp = false);
6844 Expr *Input, bool IsAfterAmp = false);
6845
6846 /// Unary Operators. 'Tok' is the token for the operator.
6848 Expr *Input, bool IsAfterAmp = false);
6849
6850 /// Determine whether the given expression is a qualified member
6851 /// access expression, of a form that could be turned into a pointer to member
6852 /// with the address-of operator.
6855 const Expr *Op,
6856 const CXXMethodDecl *MD);
6857
6858 /// CheckAddressOfOperand - The operand of & must be either a function
6859 /// designator or an lvalue designating an object. If it is an lvalue, the
6860 /// object cannot be declared with storage class register or be a bit field.
6861 /// Note: The usual conversions are *not* applied to the operand of the &
6862 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
6863 /// In C++, the operand might be an overloaded function name, in which case
6864 /// we allow the '&' but retain the overloaded-function type.
6866
6867 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
6868 /// _Alignas(type-name) .
6869 /// [dcl.align] An alignment-specifier of the form
6870 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
6871 ///
6872 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
6873 /// _Alignas(_Alignof(type-name)).
6874 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
6875 SourceLocation OpLoc, SourceRange R);
6876 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
6877 SourceLocation OpLoc, SourceRange R);
6878
6879 /// Build a sizeof or alignof expression given a type operand.
6881 SourceLocation OpLoc,
6882 UnaryExprOrTypeTrait ExprKind,
6883 SourceRange R);
6884
6885 /// Build a sizeof or alignof expression given an expression
6886 /// operand.
6888 UnaryExprOrTypeTrait ExprKind);
6889
6890 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
6891 /// expr and the same for @c alignof and @c __alignof
6892 /// Note that the ArgRange is invalid if isType is false.
6894 UnaryExprOrTypeTrait ExprKind,
6895 bool IsType, void *TyOrEx,
6896 SourceRange ArgRange);
6897
6898 /// Check for operands with placeholder types and complain if found.
6899 /// Returns ExprError() if there was an error and no recovery was possible.
6901 bool CheckVecStepExpr(Expr *E);
6902
6903 /// Check the constraints on expression operands to unary type expression
6904 /// and type traits.
6905 ///
6906 /// Completes any types necessary and validates the constraints on the operand
6907 /// expression. The logic mostly mirrors the type-based overload, but may
6908 /// modify the expression as it completes the type for that expression through
6909 /// template instantiation, etc.
6911
6912 /// Check the constraints on operands to unary expression and type
6913 /// traits.
6914 ///
6915 /// This will complete any types necessary, and validate the various
6916 /// constraints on those operands.
6917 ///
6918 /// The UsualUnaryConversions() function is *not* called by this routine.
6919 /// C99 6.3.2.1p[2-4] all state:
6920 /// Except when it is the operand of the sizeof operator ...
6921 ///
6922 /// C++ [expr.sizeof]p4
6923 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
6924 /// standard conversions are not applied to the operand of sizeof.
6925 ///
6926 /// This policy is followed for all of the unary trait expressions.
6928 SourceRange ExprRange,
6929 UnaryExprOrTypeTrait ExprKind,
6930 StringRef KWName);
6931
6933 tok::TokenKind Kind, Expr *Input);
6934
6936 MultiExprArg ArgExprs,
6937 SourceLocation RLoc);
6939 Expr *Idx, SourceLocation RLoc);
6940
6942 Expr *ColumnIdx,
6943 SourceLocation RBLoc);
6944
6945 /// ConvertArgumentsForCall - Converts the arguments specified in
6946 /// Args/NumArgs to the parameter types of the function FDecl with
6947 /// function prototype Proto. Call is the call expression itself, and
6948 /// Fn is the function expression. For a C++ member function, this
6949 /// routine does not attempt to convert the object argument. Returns
6950 /// true if the call is ill-formed.
6952 const FunctionProtoType *Proto,
6953 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
6954 bool ExecConfig = false);
6955
6956 /// CheckStaticArrayArgument - If the given argument corresponds to a static
6957 /// array parameter, check that it is non-null, and that if it is formed by
6958 /// array-to-pointer decay, the underlying array is sufficiently large.
6959 ///
6960 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
6961 /// the array type derivation, then for each call to the function, the value
6962 /// of the corresponding actual argument shall provide access to the first
6963 /// element of an array with at least as many elements as specified by the
6964 /// size expression.
6966 const Expr *ArgExpr);
6967
6968 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
6969 /// This provides the location of the left/right parens and a list of comma
6970 /// locations.
6972 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6973 Expr *ExecConfig = nullptr);
6974
6975 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
6976 /// This provides the location of the left/right parens and a list of comma
6977 /// locations.
6979 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6980 Expr *ExecConfig = nullptr,
6981 bool IsExecConfig = false,
6982 bool AllowRecovery = false);
6983
6984 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
6985 // with the specified CallArgs
6987 MultiExprArg CallArgs);
6988
6990
6991 /// BuildResolvedCallExpr - Build a call to a resolved expression,
6992 /// i.e. an expression not of \p OverloadTy. The expression should
6993 /// unary-convert to an expression of function-pointer or
6994 /// block-pointer type.
6995 ///
6996 /// \param NDecl the declaration being called, if available
6998 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
6999 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
7000 Expr *Config = nullptr, bool IsExecConfig = false,
7001 ADLCallKind UsesADL = ADLCallKind::NotADL);
7002
7004 ParsedType &Ty, SourceLocation RParenLoc,
7005 Expr *CastExpr);
7006
7007 /// Prepares for a scalar cast, performing all the necessary stages
7008 /// except the final cast and returning the kind required.
7010
7011 /// Build an altivec or OpenCL literal.
7013 SourceLocation RParenLoc, Expr *E,
7014 TypeSourceInfo *TInfo);
7015
7016 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7017 /// the ParenListExpr into a sequence of comma binary operators.
7019
7021 SourceLocation RParenLoc, Expr *InitExpr);
7022
7024 TypeSourceInfo *TInfo,
7025 SourceLocation RParenLoc,
7026 Expr *LiteralExpr);
7027
7028 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7029 SourceLocation RBraceLoc);
7030
7031 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7032 SourceLocation RBraceLoc);
7033
7034 /// Binary Operators. 'Tok' is the token for the operator.
7036 Expr *LHSExpr, Expr *RHSExpr);
7038 Expr *LHSExpr, Expr *RHSExpr);
7039
7040 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7041 /// operator @p Opc at location @c TokLoc. This routine only supports
7042 /// built-in operations; ActOnBinOp handles overloaded operators.
7044 Expr *LHSExpr, Expr *RHSExpr);
7046 UnresolvedSetImpl &Functions);
7047
7048 /// Look for instances where it is likely the comma operator is confused with
7049 /// another operator. There is an explicit list of acceptable expressions for
7050 /// the left hand side of the comma operator, otherwise emit a warning.
7051 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7052
7053 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7054 /// in the case of a the GNU conditional expr extension.
7056 SourceLocation ColonLoc, Expr *CondExpr,
7057 Expr *LHSExpr, Expr *RHSExpr);
7058
7059 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7061 LabelDecl *TheDecl);
7062
7063 void ActOnStartStmtExpr();
7064 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7065 SourceLocation RPLoc);
7067 SourceLocation RPLoc, unsigned TemplateDepth);
7068 // Handle the final expression in a statement expression.
7070 void ActOnStmtExprError();
7071
7072 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
7075 bool isBrackets; // true if [expr], false if .ident
7076 union {
7079 } U;
7080 };
7081
7082 /// __builtin_offsetof(type, a.b[123][456].c)
7084 TypeSourceInfo *TInfo,
7085 ArrayRef<OffsetOfComponent> Components,
7086 SourceLocation RParenLoc);
7089 ParsedType ParsedArgTy,
7090 ArrayRef<OffsetOfComponent> Components,
7091 SourceLocation RParenLoc);
7092
7093 // __builtin_choose_expr(constExpr, expr1, expr2)
7094 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7095 Expr *LHSExpr, Expr *RHSExpr,
7096 SourceLocation RPLoc);
7097
7098 // __builtin_va_arg(expr, type)
7100 SourceLocation RPLoc);
7102 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7103
7104 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7105 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7107 SourceLocation BuiltinLoc,
7108 SourceLocation RPLoc);
7109
7110 // #embed
7112 StringLiteral *BinaryData);
7113
7114 // Build a potentially resolved SourceLocExpr.
7116 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7117 DeclContext *ParentContext);
7118
7119 // __null
7121
7122 bool CheckCaseExpression(Expr *E);
7123
7124 //===------------------------- "Block" Extension ------------------------===//
7125
7126 /// ActOnBlockStart - This callback is invoked when a block literal is
7127 /// started.
7128 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7129
7130 /// ActOnBlockArguments - This callback allows processing of block arguments.
7131 /// If there are no arguments, this is still invoked.
7132 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7133 Scope *CurScope);
7134
7135 /// ActOnBlockError - If there is an error parsing a block, this callback
7136 /// is invoked to pop the information about the block from the action impl.
7137 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7138
7139 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7140 /// literal was successfully completed. ^(int x){...}
7142 Scope *CurScope);
7143
7144 //===---------------------------- Clang Extensions ----------------------===//
7145
7146 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7147 /// provided arguments.
7148 ///
7149 /// __builtin_convertvector( value, dst type )
7150 ///
7152 SourceLocation BuiltinLoc,
7153 SourceLocation RParenLoc);
7154
7155 //===---------------------------- OpenCL Features -----------------------===//
7156
7157 /// Parse a __builtin_astype expression.
7158 ///
7159 /// __builtin_astype( value, dst type )
7160 ///
7162 SourceLocation BuiltinLoc,
7163 SourceLocation RParenLoc);
7164
7165 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7167 SourceLocation BuiltinLoc,
7168 SourceLocation RParenLoc);
7169
7170 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7172 ArrayRef<Expr *> SubExprs,
7173 QualType T = QualType());
7174
7175 /// Cast a base object to a member's actual type.
7176 ///
7177 /// There are two relevant checks:
7178 ///
7179 /// C++ [class.access.base]p7:
7180 ///
7181 /// If a class member access operator [...] is used to access a non-static
7182 /// data member or non-static member function, the reference is ill-formed
7183 /// if the left operand [...] cannot be implicitly converted to a pointer to
7184 /// the naming class of the right operand.
7185 ///
7186 /// C++ [expr.ref]p7:
7187 ///
7188 /// If E2 is a non-static data member or a non-static member function, the
7189 /// program is ill-formed if the class of which E2 is directly a member is
7190 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7191 ///
7192 /// Note that the latter check does not consider access; the access of the
7193 /// "real" base class is checked as appropriate when checking the access of
7194 /// the member name.
7196 NestedNameSpecifier *Qualifier,
7197 NamedDecl *FoundDecl,
7198 NamedDecl *Member);
7199
7200 /// CheckCallReturnType - Checks that a call expression's return type is
7201 /// complete. Returns true on failure. The location passed in is the location
7202 /// that best represents the call.
7204 CallExpr *CE, FunctionDecl *FD);
7205
7206 /// Emit a warning for all pending noderef expressions that we recorded.
7207 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
7208
7210
7211 /// Instantiate or parse a C++ default argument expression as necessary.
7212 /// Return true on error.
7214 ParmVarDecl *Param, Expr *Init = nullptr,
7215 bool SkipImmediateInvocations = true);
7216
7217 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7218 /// the default expr if needed.
7220 ParmVarDecl *Param, Expr *Init = nullptr);
7221
7222 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7223 /// invocation.
7225
7227
7228 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7229 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7230
7231 /// Abstract base class used for diagnosing integer constant
7232 /// expression violations.
7234 public:
7236
7237 VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {}
7238
7239 virtual SemaDiagnosticBuilder
7240 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7242 SourceLocation Loc) = 0;
7243 virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc);
7245 };
7246
7250 };
7251
7252 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7253 /// and reports the appropriate diagnostics. Returns false on success.
7254 /// Can optionally return the value of the expression.
7256 VerifyICEDiagnoser &Diagnoser,
7257 AllowFoldKind CanFold = NoFold);
7259 unsigned DiagID,
7260 AllowFoldKind CanFold = NoFold);
7262 llvm::APSInt *Result = nullptr,
7263 AllowFoldKind CanFold = NoFold);
7265 AllowFoldKind CanFold = NoFold) {
7266 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7267 }
7268
7269 /// DiagnoseAssignmentAsCondition - Given that an expression is
7270 /// being used as a boolean condition, warn if it's an assignment.
7272
7273 /// Redundant parentheses over an equality comparison can indicate
7274 /// that the user intended an assignment used as condition.
7276
7278 public:
7279 FullExprArg() : E(nullptr) {}
7280 FullExprArg(Sema &actions) : E(nullptr) {}
7281
7282 ExprResult release() { return E; }
7283
7284 Expr *get() const { return E; }
7285
7286 Expr *operator->() { return E; }
7287
7288 private:
7289 // FIXME: No need to make the entire Sema class a friend when it's just
7290 // Sema::MakeFullExpr that needs access to the constructor below.
7291 friend class Sema;
7292
7293 explicit FullExprArg(Expr *expr) : E(expr) {}
7294
7295 Expr *E;
7296 };
7297
7299 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7300 }
7302 return FullExprArg(
7303 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7304 }
7306 ExprResult FE =
7307 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7308 /*DiscardedValue*/ true);
7309 return FullExprArg(FE.get());
7310 }
7311
7313 Decl *ConditionVar;
7315 bool Invalid;
7316 std::optional<bool> KnownValue;
7317
7318 friend class Sema;
7319 ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
7320 bool IsConstexpr)
7321 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7322 if (IsConstexpr && Condition.get()) {
7323 if (std::optional<llvm::APSInt> Val =
7324 Condition.get()->getIntegerConstantExpr(S.Context)) {
7325 KnownValue = !!(*Val);
7326 }
7327 }
7328 }
7329 explicit ConditionResult(bool Invalid)
7330 : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
7331 KnownValue(std::nullopt) {}
7332
7333 public:
7335 bool isInvalid() const { return Invalid; }
7336 std::pair<VarDecl *, Expr *> get() const {
7337 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7338 Condition.get());
7339 }
7340 std::optional<bool> getKnownValue() const { return KnownValue; }
7341 };
7343
7344 /// CheckBooleanCondition - Diagnose problems involving the use of
7345 /// the given expression as a boolean condition (e.g. in an if
7346 /// statement). Also performs the standard function and array
7347 /// decays, possibly changing the input variable.
7348 ///
7349 /// \param Loc - A location associated with the condition, e.g. the
7350 /// 'if' keyword.
7351 /// \return true iff there were any errors
7353 bool IsConstexpr = false);
7354
7355 enum class ConditionKind {
7356 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7357 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7358 Switch ///< An integral condition for a 'switch' statement.
7359 };
7360
7361 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7362 ConditionKind CK, bool MissingOK = false);
7363
7364 QualType CheckConditionalOperands( // C99 6.5.15
7365 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
7366 ExprObjectKind &OK, SourceLocation QuestionLoc);
7367
7368 /// Emit a specialized diagnostic when one expression is a null pointer
7369 /// constant and the other is not a pointer. Returns true if a diagnostic is
7370 /// emitted.
7371 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7372 SourceLocation QuestionLoc);
7373
7374 /// type checking for vector binary operators.
7376 SourceLocation Loc, bool IsCompAssign,
7377 bool AllowBothBool, bool AllowBoolConversion,
7378 bool AllowBoolOperation, bool ReportInvalid);
7379
7380 /// Return a signed ext_vector_type that is of identical size and number of
7381 /// elements. For floating point vectors, return an integer type of identical
7382 /// size and number of elements. In the non ext_vector_type case, search from
7383 /// the largest type to the smallest type to avoid cases where long long ==
7384 /// long, where long gets picked over long long.
7387
7388 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7389 /// operates on extended vector types. Instead of producing an IntTy result,
7390 /// like a scalar comparison, a vector comparison produces a vector of integer
7391 /// types.
7394 BinaryOperatorKind Opc);
7397 BinaryOperatorKind Opc);
7400
7401 /// Context in which we're performing a usual arithmetic conversion.
7403 /// An arithmetic operation.
7405 /// A bitwise operation.
7407 /// A comparison.
7409 /// A conditional (?:) operator.
7411 /// A compound assignment expression.
7413 };
7414
7415 // type checking for sizeless vector binary operators.
7417 SourceLocation Loc, bool IsCompAssign,
7418 ArithConvKind OperationKind);
7419
7420 /// Type checking for matrix binary operators.
7423 bool IsCompAssign);
7425 SourceLocation Loc, bool IsCompAssign);
7426
7427 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
7428 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
7429 /// VLST) allowed?
7430 ///
7431 /// This will also return false if the two given types do not make sense from
7432 /// the perspective of SVE bitcasts.
7433 bool isValidSveBitcast(QualType srcType, QualType destType);
7434
7435 /// Are the two types matrix types and do they have the same dimensions i.e.
7436 /// do they have the same number of rows and the same number of columns?
7438
7439 bool areVectorTypesSameSize(QualType srcType, QualType destType);
7440
7441 /// Are the two types lax-compatible vector types? That is, given
7442 /// that one of them is a vector, do they have equal storage sizes,
7443 /// where the storage size is the number of elements times the element
7444 /// size?
7445 ///
7446 /// This will also return false if either of the types is neither a
7447 /// vector nor a real type.
7448 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
7449
7450 /// Is this a legal conversion between two types, one of which is
7451 /// known to be a vector type?
7452 bool isLaxVectorConversion(QualType srcType, QualType destType);
7453
7454 // This returns true if at least one of the types is an altivec vector.
7455 bool anyAltivecTypes(QualType srcType, QualType destType);
7456
7457 // type checking C++ declaration initializers (C++ [dcl.init]).
7458
7459 /// Check a cast of an unknown-any type. We intentionally only
7460 /// trigger this for C-style casts.
7464
7465 /// Force an expression with unknown-type to an expression of the
7466 /// given type.
7468
7469 /// Type-check an expression that's being passed to an
7470 /// __unknown_anytype parameter.
7472 QualType &paramType);
7473
7474 // CheckMatrixCast - Check type constraints for matrix casts.
7475 // We allow casting between matrixes of the same dimensions i.e. when they
7476 // have the same number of rows and column. Returns true if the cast is
7477 // invalid.
7478 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
7479 CastKind &Kind);
7480
7481 // CheckVectorCast - check type constraints for vectors.
7482 // Since vectors are an extension, there are no C standard reference for this.
7483 // We allow casting between vectors and integer datatypes of the same size.
7484 // returns true if the cast is invalid
7485 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
7486 CastKind &Kind);
7487
7488 /// Prepare `SplattedExpr` for a vector splat operation, adding
7489 /// implicit casts if necessary.
7490 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
7491
7492 // CheckExtVectorCast - check type constraints for extended vectors.
7493 // Since vectors are an extension, there are no C standard reference for this.
7494 // We allow casting between vectors and integer datatypes of the same size,
7495 // or vectors and the element type of that vector.
7496 // returns the cast expr
7498 CastKind &Kind);
7499
7502 }
7503
7504 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
7505 // functions and arrays to their respective pointers (C99 6.3.2.1).
7507
7508 /// CallExprUnaryConversions - a special case of an unary conversion
7509 /// performed on a function designator of a call expression.
7511
7512 // DefaultFunctionArrayConversion - converts functions and arrays
7513 // to their respective pointers (C99 6.3.2.1).
7515
7516 // DefaultFunctionArrayLvalueConversion - converts functions and
7517 // arrays to their respective pointers and performs the
7518 // lvalue-to-rvalue conversion.
7520 bool Diagnose = true);
7521
7522 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
7523 // the operand. This function is a no-op if the operand has a function type
7524 // or an array type.
7526
7527 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
7528 // do not have a prototype. Integer promotions are performed on each
7529 // argument, and arguments that have type float are promoted to double.
7531
7533 const FunctionProtoType *Proto,
7534 Expr *Fn);
7535
7536 // Used for determining in which context a type is allowed to be passed to a
7537 // vararg function.
7545
7546 /// Determine the degree of POD-ness for an expression.
7547 /// Incomplete types are considered POD, since this check can be performed
7548 /// when we're in an unevaluated context.
7550
7551 /// Check to see if the given expression is a valid argument to a variadic
7552 /// function, issuing a diagnostic if not.
7554
7555 /// GatherArgumentsForCall - Collector argument expressions for various
7556 /// form of call prototypes.
7558 const FunctionProtoType *Proto,
7559 unsigned FirstParam, ArrayRef<Expr *> Args,
7560 SmallVectorImpl<Expr *> &AllArgs,
7562 bool AllowExplicit = false,
7563 bool IsListInitialization = false);
7564
7565 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
7566 // will create a runtime trap if the resulting type is not a POD type.
7568 FunctionDecl *FDecl);
7569
7570 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
7571 // operands and then handles various conversions that are common to binary
7572 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
7573 // routine returns the first non-arithmetic type found. The client is
7574 // responsible for emitting appropriate error diagnostics.
7577
7578 /// AssignConvertType - All of the 'assignment' semantic checks return this
7579 /// enum to indicate whether the assignment was allowed. These checks are
7580 /// done for simple assignments, as well as initialization, return from
7581 /// function, argument passing, etc. The query is phrased in terms of a
7582 /// source and destination type.
7584 /// Compatible - the types are compatible according to the standard.
7586
7587 /// PointerToInt - The assignment converts a pointer to an int, which we
7588 /// accept as an extension.
7590
7591 /// IntToPointer - The assignment converts an int to a pointer, which we
7592 /// accept as an extension.
7594
7595 /// FunctionVoidPointer - The assignment is between a function pointer and
7596 /// void*, which the standard doesn't allow, but we accept as an extension.
7598
7599 /// IncompatiblePointer - The assignment is between two pointers types that
7600 /// are not compatible, but we accept them as an extension.
7602
7603 /// IncompatibleFunctionPointer - The assignment is between two function
7604 /// pointers types that are not compatible, but we accept them as an
7605 /// extension.
7607
7608 /// IncompatibleFunctionPointerStrict - The assignment is between two
7609 /// function pointer types that are not identical, but are compatible,
7610 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
7611 /// may trip an indirect call runtime check.
7613
7614 /// IncompatiblePointerSign - The assignment is between two pointers types
7615 /// which point to integers which have a different sign, but are otherwise
7616 /// identical. This is a subset of the above, but broken out because it's by
7617 /// far the most common case of incompatible pointers.
7619
7620 /// CompatiblePointerDiscardsQualifiers - The assignment discards
7621 /// c/v/r qualifiers, which we accept as an extension.
7623
7624 /// IncompatiblePointerDiscardsQualifiers - The assignment
7625 /// discards qualifiers that we don't permit to be discarded,
7626 /// like address spaces.
7628
7629 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
7630 /// changes address spaces in nested pointer types which is not allowed.
7631 /// For instance, converting __private int ** to __generic int ** is
7632 /// illegal even though __private could be converted to __generic.
7634
7635 /// IncompatibleNestedPointerQualifiers - The assignment is between two
7636 /// nested pointer types, and the qualifiers other than the first two
7637 /// levels differ e.g. char ** -> const char **, but we accept them as an
7638 /// extension.
7640
7641 /// IncompatibleVectors - The assignment is between two vector types that
7642 /// have the same size, which we accept as an extension.
7644
7645 /// IntToBlockPointer - The assignment converts an int to a block
7646 /// pointer. We disallow this.
7648
7649 /// IncompatibleBlockPointer - The assignment is between two block
7650 /// pointers types that are not compatible.
7652
7653 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
7654 /// id type and something else (that is incompatible with it). For example,
7655 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
7657
7658 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
7659 /// object with __weak qualifier.
7661
7662 /// Incompatible - We reject this conversion outright, it is invalid to
7663 /// represent it in the AST.
7666
7667 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
7668 /// assignment conversion type specified by ConvTy. This returns true if the
7669 /// conversion was invalid or false if the conversion was accepted.
7671 QualType DstType, QualType SrcType,
7672 Expr *SrcExpr, AssignmentAction Action,
7673 bool *Complained = nullptr);
7674
7675 /// CheckAssignmentConstraints - Perform type checking for assignment,
7676 /// argument passing, variable initialization, and function return values.
7677 /// C99 6.5.16.
7679 QualType LHSType,
7680 QualType RHSType);
7681
7682 /// Check assignment constraints and optionally prepare for a conversion of
7683 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
7684 /// is true.
7686 ExprResult &RHS, CastKind &Kind,
7687 bool ConvertRHS = true);
7688
7689 /// Check assignment constraints for an assignment of RHS to LHSType.
7690 ///
7691 /// \param LHSType The destination type for the assignment.
7692 /// \param RHS The source expression for the assignment.
7693 /// \param Diagnose If \c true, diagnostics may be produced when checking
7694 /// for assignability. If a diagnostic is produced, \p RHS will be
7695 /// set to ExprError(). Note that this function may still return
7696 /// without producing a diagnostic, even for an invalid assignment.
7697 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
7698 /// in an audited Core Foundation API and does not need to be checked
7699 /// for ARC retain issues.
7700 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
7701 /// conversions necessary to perform the assignment. If \c false,
7702 /// \p Diagnose must also be \c false.
7704 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
7705 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
7706
7707 // If the lhs type is a transparent union, check whether we
7708 // can initialize the transparent union with the given expression.
7710 ExprResult &RHS);
7711
7712 /// the following "Check" methods will return a valid/converted QualType
7713 /// or a null QualType (indicating an error diagnostic was issued).
7714
7715 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
7717 ExprResult &RHS);
7718
7719 /// Diagnose cases where a scalar was implicitly converted to a vector and
7720 /// diagnose the underlying types. Otherwise, diagnose the error
7721 /// as invalid vector logical operands for non-C++ cases.
7723 ExprResult &RHS);
7724
7726 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
7727 bool IsDivide);
7728 QualType CheckRemainderOperands( // C99 6.5.5
7730 bool IsCompAssign = false);
7731 QualType CheckAdditionOperands( // C99 6.5.6
7733 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
7736 QualType *CompLHSTy = nullptr);
7737 QualType CheckShiftOperands( // C99 6.5.7
7739 BinaryOperatorKind Opc, bool IsCompAssign = false);
7741 QualType CheckCompareOperands( // C99 6.5.8/9
7743 BinaryOperatorKind Opc);
7744 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
7746 BinaryOperatorKind Opc);
7747 QualType CheckLogicalOperands( // C99 6.5.[13,14]
7749 BinaryOperatorKind Opc);
7750 // CheckAssignmentOperands is used for both simple and compound assignment.
7751 // For simple assignment, pass both expressions and a null converted type.
7752 // For compound assignment, pass both expressions and the converted type.
7753 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
7754 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
7755 BinaryOperatorKind Opc);
7756
7757 /// To be used for checking whether the arguments being passed to
7758 /// function exceeds the number of parameters expected for it.
7759 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
7760 bool PartialOverloading = false) {
7761 // We check whether we're just after a comma in code-completion.
7762 if (NumArgs > 0 && PartialOverloading)
7763 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
7764 return NumArgs > NumParams;
7765 }
7766
7767 /// Whether the AST is currently being rebuilt to correct immediate
7768 /// invocations. Immediate invocation candidates and references to consteval
7769 /// functions aren't tracked when this is set.
7771
7776 }
7777
7778 /// Determines whether we are currently in a context that
7779 /// is not evaluated as per C++ [expr] p5.
7782 }
7783
7786 }
7787
7789 assert(!ExprEvalContexts.empty() &&
7790 "Must be in an expression evaluation context");
7791 return ExprEvalContexts.back().InLifetimeExtendingContext;
7792 }
7793
7796 return (Ctx.Context ==
7799 }
7800
7801 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7803 assert(!ExprEvalContexts.empty() &&
7804 "Must be in an expression evaluation context");
7805 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7807 Ctx.DelayedDefaultInitializationContext)
7808 return Ctx.DelayedDefaultInitializationContext;
7809 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7810 Ctx.isUnevaluated())
7811 break;
7812 }
7813 return std::nullopt;
7814 }
7815
7816 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7818 assert(!ExprEvalContexts.empty() &&
7819 "Must be in an expression evaluation context");
7820 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
7821 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7823 !Ctx.DelayedDefaultInitializationContext && Res)
7824 break;
7825 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7826 Ctx.isUnevaluated())
7827 break;
7828 Res = Ctx.DelayedDefaultInitializationContext;
7829 }
7830 return Res;
7831 }
7832
7833 /// keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext
7834 /// flag from previous context.
7836 if (ExprEvalContexts.size() > 2 &&
7837 parentEvaluationContext().InLifetimeExtendingContext) {
7838 auto &LastRecord = ExprEvalContexts.back();
7839 auto &PrevRecord = parentEvaluationContext();
7840 LastRecord.InLifetimeExtendingContext =
7841 PrevRecord.InLifetimeExtendingContext;
7842 }
7843 }
7844
7847 }
7848
7849 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
7850 /// SelfAssigned when inside a CXXMethodDecl.
7851 const FieldDecl *
7853
7855
7856 template <typename... Ts>
7858 const Ts &...Args) {
7859 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7861 }
7862
7863 template <typename... Ts>
7864 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
7865 const Ts &...Args) {
7866 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7868 }
7869
7870 /// Abstract class used to diagnose incomplete types.
7873
7874 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
7875 virtual ~TypeDiagnoser() {}
7876 };
7877
7878 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
7879 protected:
7880 unsigned DiagID;
7881 std::tuple<const Ts &...> Args;
7882
7883 template <std::size_t... Is>
7885 std::index_sequence<Is...>) const {
7886 // Apply all tuple elements to the builder in order.
7887 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
7888 (void)Dummy;
7889 }
7890
7891 public:
7892 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7893 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
7894 assert(DiagID != 0 && "no diagnostic for type diagnoser");
7895 }
7896
7897 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7898 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
7899 emit(DB, std::index_sequence_for<Ts...>());
7900 DB << T;
7901 }
7902 };
7903
7904 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
7905 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
7906 /// For example, a diagnostic with no other parameters would generally have
7907 /// the form "...%select{incomplete|sizeless}0 type %1...".
7908 template <typename... Ts>
7910 public:
7911 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7912 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
7913
7914 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7915 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
7916 this->emit(DB, std::index_sequence_for<Ts...>());
7917 DB << T->isSizelessType() << T;
7918 }
7919 };
7920
7921 /// Check an argument list for placeholders that we won't try to
7922 /// handle later.
7924
7925 /// The C++ "std::source_location::__impl" struct, defined in
7926 /// <source_location>.
7928
7929 /// A stack of expression evaluation contexts.
7931
7932 // Set of failed immediate invocations to avoid double diagnosing.
7934
7935 /// List of SourceLocations where 'self' is implicitly retained inside a
7936 /// block.
7939
7940 /// Do an explicit extend of the given block pointer if we're in ARC.
7942
7943private:
7944 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
7945
7946 /// Methods for marking which expressions involve dereferencing a pointer
7947 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
7948 /// they are parsed, meaning that a noderef pointer may not be accessed. For
7949 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
7950 /// `*p`, but need to check that `address of` is called on it. This requires
7951 /// keeping a container of all pending expressions and checking if the address
7952 /// of them are eventually taken.
7953 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
7954 void CheckAddressOfNoDeref(const Expr *E);
7955
7956 ///@}
7957
7958 //
7959 //
7960 // -------------------------------------------------------------------------
7961 //
7962 //
7963
7964 /// \name C++ Expressions
7965 /// Implementations are in SemaExprCXX.cpp
7966 ///@{
7967
7968public:
7969 /// The C++ "std::bad_alloc" class, which is defined by the C++
7970 /// standard library.
7972
7973 /// The C++ "std::align_val_t" enum class, which is defined by the C++
7974 /// standard library.
7976
7977 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
7979
7980 /// A flag to remember whether the implicit forms of operator new and delete
7981 /// have been declared.
7983
7984 /// Delete-expressions to be analyzed at the end of translation unit
7985 ///
7986 /// This list contains class members, and locations of delete-expressions
7987 /// that could not be proven as to whether they mismatch with new-expression
7988 /// used in initializer of the field.
7989 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
7990
7991 /// Handle the result of the special case name lookup for inheriting
7992 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
7993 /// constructor names in member using declarations, even if 'X' is not the
7994 /// name of the corresponding type.
7996 SourceLocation NameLoc,
7997 const IdentifierInfo &Name);
7998
8000 SourceLocation NameLoc, Scope *S,
8001 CXXScopeSpec &SS, bool EnteringContext);
8003 Scope *S, CXXScopeSpec &SS,
8004 ParsedType ObjectType, bool EnteringContext);
8005
8007 ParsedType ObjectType);
8008
8009 /// Build a C++ typeid expression with a type operand.
8010 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8011 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8012
8013 /// Build a C++ typeid expression with an expression operand.
8014 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8015 Expr *Operand, SourceLocation RParenLoc);
8016
8017 /// ActOnCXXTypeid - Parse typeid( something ).
8019 bool isType, void *TyOrExpr,
8020 SourceLocation RParenLoc);
8021
8022 /// Build a Microsoft __uuidof expression with a type operand.
8023 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8024 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8025
8026 /// Build a Microsoft __uuidof expression with an expression operand.
8027 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8028 Expr *Operand, SourceLocation RParenLoc);
8029
8030 /// ActOnCXXUuidof - Parse __uuidof( something ).
8032 bool isType, void *TyOrExpr,
8033 SourceLocation RParenLoc);
8034
8035 //// ActOnCXXThis - Parse 'this' pointer.
8037
8038 /// Check whether the type of 'this' is valid in the current context.
8040
8041 /// Build a CXXThisExpr and mark it referenced in the current context.
8043 void MarkThisReferenced(CXXThisExpr *This);
8044
8045 /// Try to retrieve the type of the 'this' pointer.
8046 ///
8047 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8049
8050 /// When non-NULL, the C++ 'this' expression is allowed despite the
8051 /// current context not being a non-static member function. In such cases,
8052 /// this provides the type used for 'this'.
8054
8055 /// RAII object used to temporarily allow the C++ 'this' expression
8056 /// to be used, with the given qualifiers on the current class type.
8058 Sema &S;
8059 QualType OldCXXThisTypeOverride;
8060 bool Enabled;
8061
8062 public:
8063 /// Introduce a new scope where 'this' may be allowed (when enabled),
8064 /// using the given declaration (which is either a class template or a
8065 /// class) along with the given qualifiers.
8066 /// along with the qualifiers placed on '*this'.
8067 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8068 bool Enabled = true);
8069
8071 };
8072
8073 /// Make sure the value of 'this' is actually available in the current
8074 /// context, if it is a potentially evaluated context.
8075 ///
8076 /// \param Loc The location at which the capture of 'this' occurs.
8077 ///
8078 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8079 /// capture list.
8080 ///
8081 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8082 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8083 /// This is useful when enclosing lambdas must speculatively capture
8084 /// 'this' that may or may not be used in certain specializations of
8085 /// a nested generic lambda (depending on whether the name resolves to
8086 /// a non-static member function or a static function).
8087 /// \return returns 'true' if failed, 'false' if success.
8089 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8090 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8091 bool ByCopy = false);
8092
8093 /// Determine whether the given type is the type of *this that is used
8094 /// outside of the body of a member function for a type that is currently
8095 /// being defined.
8097
8098 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8100
8101 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8103
8104 //// ActOnCXXThrow - Parse throw expressions.
8107 bool IsThrownVarInScope);
8108
8109 /// CheckCXXThrowOperand - Validate the operand of a throw.
8110 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8111
8112 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8113 /// Can be interpreted either as function-style casting ("int(x)")
8114 /// or class type construction ("ClassType(x,y,z)")
8115 /// or creation of a value-initialized type ("int()").
8117 SourceLocation LParenOrBraceLoc,
8118 MultiExprArg Exprs,
8119 SourceLocation RParenOrBraceLoc,
8120 bool ListInitialization);
8121
8123 SourceLocation LParenLoc,
8124 MultiExprArg Exprs,
8125 SourceLocation RParenLoc,
8126 bool ListInitialization);
8127
8128 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8129 ///
8130 /// E.g.:
8131 /// @code new (memory) int[size][4] @endcode
8132 /// or
8133 /// @code ::new Foo(23, "hello") @endcode
8134 ///
8135 /// \param StartLoc The first location of the expression.
8136 /// \param UseGlobal True if 'new' was prefixed with '::'.
8137 /// \param PlacementLParen Opening paren of the placement arguments.
8138 /// \param PlacementArgs Placement new arguments.
8139 /// \param PlacementRParen Closing paren of the placement arguments.
8140 /// \param TypeIdParens If the type is in parens, the source range.
8141 /// \param D The type to be allocated, as well as array dimensions.
8142 /// \param Initializer The initializing expression or initializer-list, or
8143 /// null if there is none.
8144 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8145 SourceLocation PlacementLParen,
8146 MultiExprArg PlacementArgs,
8147 SourceLocation PlacementRParen,
8148 SourceRange TypeIdParens, Declarator &D,
8149 Expr *Initializer);
8151 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8152 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8153 SourceRange TypeIdParens, QualType AllocType,
8154 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8155 SourceRange DirectInitRange, Expr *Initializer);
8156
8157 /// Determine whether \p FD is an aligned allocation or deallocation
8158 /// function that is unavailable.
8160
8161 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8162 /// function that is unavailable.
8165
8166 /// Checks that a type is suitable as the allocated type
8167 /// in a new-expression.
8169 SourceRange R);
8170
8171 /// The scope in which to find allocation functions.
8173 /// Only look for allocation functions in the global scope.
8175 /// Only look for allocation functions in the scope of the
8176 /// allocated class.
8178 /// Look for allocation functions in both the global scope
8179 /// and in the scope of the allocated class.
8180 AFS_Both
8182
8183 /// Finds the overloads of operator new and delete that are appropriate
8184 /// for the allocation.
8186 AllocationFunctionScope NewScope,
8187 AllocationFunctionScope DeleteScope,
8188 QualType AllocType, bool IsArray,
8189 bool &PassAlignment, MultiExprArg PlaceArgs,
8190 FunctionDecl *&OperatorNew,
8191 FunctionDecl *&OperatorDelete,
8192 bool Diagnose = true);
8193
8194 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8195 /// delete. These are:
8196 /// @code
8197 /// // C++03:
8198 /// void* operator new(std::size_t) throw(std::bad_alloc);
8199 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8200 /// void operator delete(void *) throw();
8201 /// void operator delete[](void *) throw();
8202 /// // C++11:
8203 /// void* operator new(std::size_t);
8204 /// void* operator new[](std::size_t);
8205 /// void operator delete(void *) noexcept;
8206 /// void operator delete[](void *) noexcept;
8207 /// // C++1y:
8208 /// void* operator new(std::size_t);
8209 /// void* operator new[](std::size_t);
8210 /// void operator delete(void *) noexcept;
8211 /// void operator delete[](void *) noexcept;
8212 /// void operator delete(void *, std::size_t) noexcept;
8213 /// void operator delete[](void *, std::size_t) noexcept;
8214 /// @endcode
8215 /// Note that the placement and nothrow forms of new are *not* implicitly
8216 /// declared. Their use requires including <new>.
8219 ArrayRef<QualType> Params);
8220
8222 DeclarationName Name, FunctionDecl *&Operator,
8223 bool Diagnose = true, bool WantSize = false,
8224 bool WantAligned = false);
8226 bool CanProvideSize,
8227 bool Overaligned,
8228 DeclarationName Name);
8230 CXXRecordDecl *RD);
8231
8232 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8233 /// @code ::delete ptr; @endcode
8234 /// or
8235 /// @code delete [] ptr; @endcode
8236 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8237 bool ArrayForm, Expr *Operand);
8239 bool IsDelete, bool CallCanBeVirtual,
8240 bool WarnOnNonAbstractTypes,
8241 SourceLocation DtorLoc);
8242
8244 Expr *Operand, SourceLocation RParen);
8246 SourceLocation RParen);
8247
8249 SourceLocation OpLoc,
8250 tok::TokenKind OpKind,
8251 ParsedType &ObjectType,
8252 bool &MayBePseudoDestructor);
8253
8255 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8256 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8257 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8258
8260 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8261 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8262 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8263
8265 SourceLocation OpLoc,
8266 tok::TokenKind OpKind,
8267 SourceLocation TildeLoc,
8268 const DeclSpec &DS);
8269
8270 /// MaybeCreateExprWithCleanups - If the current full-expression
8271 /// requires any cleanups, surround it with a ExprWithCleanups node.
8272 /// Otherwise, just returns the passed-in expression.
8276
8277 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8278 return ActOnFinishFullExpr(
8279 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8280 }
8282 bool DiscardedValue, bool IsConstexpr = false,
8283 bool IsTemplateArgument = false);
8285
8286 /// Process the expression contained within a decltype. For such expressions,
8287 /// certain semantic checks on temporaries are delayed until this point, and
8288 /// are omitted for the 'topmost' call in the decltype expression. If the
8289 /// topmost call bound a temporary, strip that temporary off the expression.
8291
8292 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8293 bool IsUDSuffix);
8294
8296
8297 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8298 SourceLocation StmtLoc,
8299 ConditionKind CK);
8300
8301 /// Check the use of the given variable as a C++ condition in an if,
8302 /// while, do-while, or switch statement.
8304 SourceLocation StmtLoc, ConditionKind CK);
8305
8306 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8307 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8308
8309 /// Helper function to determine whether this is the (deprecated) C++
8310 /// conversion from a string literal to a pointer to non-const char or
8311 /// non-const wchar_t (for narrow and wide string literals,
8312 /// respectively).
8314
8315 /// PerformImplicitConversion - Perform an implicit conversion of the
8316 /// expression From to the type ToType using the pre-computed implicit
8317 /// conversion sequence ICS. Returns the converted
8318 /// expression. Action is the kind of conversion we're performing,
8319 /// used in the error message.
8321 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8322 AssignmentAction Action,
8324
8325 /// PerformImplicitConversion - Perform an implicit conversion of the
8326 /// expression From to the type ToType by following the standard
8327 /// conversion sequence SCS. Returns the converted
8328 /// expression. Flavor is the context in which we're performing this
8329 /// conversion, for use in error messages.
8331 const StandardConversionSequence &SCS,
8332 AssignmentAction Action,
8334
8335 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8336
8337 /// Parsed one of the type trait support pseudo-functions.
8340 SourceLocation RParenLoc);
8343 SourceLocation RParenLoc);
8344
8345 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8346 /// pseudo-functions.
8348 ParsedType LhsTy, Expr *DimExpr,
8349 SourceLocation RParen);
8350
8352 TypeSourceInfo *TSInfo, Expr *DimExpr,
8353 SourceLocation RParen);
8354
8355 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8356 /// pseudo-functions.
8358 Expr *Queried, SourceLocation RParen);
8359
8361 Expr *Queried, SourceLocation RParen);
8362
8364 ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc,
8365 bool isIndirect);
8367 ExprResult &RHS,
8368 SourceLocation QuestionLoc);
8369
8371 ExprResult &LHS, ExprResult &RHS,
8372 SourceLocation QuestionLoc);
8373
8374 /// Check the operands of ?: under C++ semantics.
8375 ///
8376 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8377 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8378 ///
8379 /// This function also implements GCC's vector extension and the
8380 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8381 /// permit the use of a?b:c where the type of a is that of a integer vector
8382 /// with the same number of elements and size as the vectors of b and c. If
8383 /// one of either b or c is a scalar it is implicitly converted to match the
8384 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8385 /// c are scalars, then b and c are checked and converted to the type of a if
8386 /// possible.
8387 ///
8388 /// The expressions are evaluated differently for GCC's and OpenCL's
8389 /// extensions. For the GCC extension, the ?: operator is evaluated as
8390 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8391 /// For the OpenCL extensions, the ?: operator is evaluated as
8392 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8393 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8395 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8396 ExprObjectKind &OK, SourceLocation questionLoc);
8397
8398 /// Find a merged pointer type and convert the two expressions to it.
8399 ///
8400 /// This finds the composite pointer type for \p E1 and \p E2 according to
8401 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8402 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8403 /// ConvertArgs is \c true).
8404 ///
8405 /// \param Loc The location of the operator requiring these two expressions to
8406 /// be converted to the composite pointer type.
8407 ///
8408 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8409 /// type.
8411 bool ConvertArgs = true);
8413 ExprResult &E2, bool ConvertArgs = true) {
8414 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8415 QualType Composite =
8416 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8417 E1 = E1Tmp;
8418 E2 = E2Tmp;
8419 return Composite;
8420 }
8421
8422 /// MaybeBindToTemporary - If the passed in expression has a record type with
8423 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8424 /// it simply returns the passed in expression.
8426
8427 /// IgnoredValueConversions - Given that an expression's result is
8428 /// syntactically ignored, perform any conversions that are
8429 /// required.
8431
8433
8434 /// Process any TypoExprs in the given Expr and its children,
8435 /// generating diagnostics as appropriate and returning a new Expr if there
8436 /// were typos that were all successfully corrected and ExprError if one or
8437 /// more typos could not be corrected.
8438 ///
8439 /// \param E The Expr to check for TypoExprs.
8440 ///
8441 /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
8442 /// initializer.
8443 ///
8444 /// \param RecoverUncorrectedTypos If true, when typo correction fails, it
8445 /// will rebuild the given Expr with all TypoExprs degraded to RecoveryExprs.
8446 ///
8447 /// \param Filter A function applied to a newly rebuilt Expr to determine if
8448 /// it is an acceptable/usable result from a single combination of typo
8449 /// corrections. As long as the filter returns ExprError, different
8450 /// combinations of corrections will be tried until all are exhausted.
8452 Expr *E, VarDecl *InitDecl = nullptr,
8453 bool RecoverUncorrectedTypos = false,
8454 llvm::function_ref<ExprResult(Expr *)> Filter =
8455 [](Expr *E) -> ExprResult { return E; });
8456
8458 ExprResult ER, VarDecl *InitDecl = nullptr,
8459 bool RecoverUncorrectedTypos = false,
8460 llvm::function_ref<ExprResult(Expr *)> Filter =
8461 [](Expr *E) -> ExprResult { return E; }) {
8462 return ER.isInvalid()
8463 ? ER
8464 : CorrectDelayedTyposInExpr(ER.get(), InitDecl,
8465 RecoverUncorrectedTypos, Filter);
8466 }
8467
8468 /// Describes the result of an "if-exists" condition check.
8470 /// The symbol exists.
8472
8473 /// The symbol does not exist.
8475
8476 /// The name is a dependent name, so the results will differ
8477 /// from one instantiation to the next.
8479
8480 /// An error occurred.
8481 IER_Error
8483
8486 const DeclarationNameInfo &TargetNameInfo);
8487
8489 SourceLocation KeywordLoc,
8490 bool IsIfExists, CXXScopeSpec &SS,
8491 UnqualifiedId &Name);
8492
8495 ArrayRef<ParmVarDecl *> LocalParameters,
8496 Scope *BodyScope);
8500 CXXScopeSpec &SS,
8501 SourceLocation NameLoc,
8502 const IdentifierInfo *TypeName,
8503 TemplateIdAnnotation *TemplateId);
8505 SourceLocation NoexceptLoc);
8507 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8508 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8511 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8515 bool IsSatisfied, SourceLocation NoexceptLoc,
8522 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8523 const ASTConstraintSatisfaction &Satisfaction);
8526 SourceLocation LParenLoc,
8527 ArrayRef<ParmVarDecl *> LocalParameters,
8528 SourceLocation RParenLoc,
8530 SourceLocation ClosingBraceLoc);
8531
8532private:
8533 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8534 bool IsDelete);
8535
8536 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8537 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8538 bool DeleteWasArrayForm);
8539
8540 ///@}
8541
8542 //
8543 //
8544 // -------------------------------------------------------------------------
8545 //
8546 //
8547
8548 /// \name Member Access Expressions
8549 /// Implementations are in SemaExprMember.cpp
8550 ///@{
8551
8552public:
8553 /// Check whether an expression might be an implicit class member access.
8555 bool IsAddressOfOperand);
8556
8557 /// Builds an expression which might be an implicit member expression.
8559 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
8560 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
8561
8562 /// Builds an implicit member access expression. The current context
8563 /// is known to be an instance method, and the given unqualified lookup
8564 /// set is known to contain only instance members, at least one of which
8565 /// is from an appropriate type.
8567 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8568 LookupResult &R,
8569 const TemplateArgumentListInfo *TemplateArgs,
8570 bool IsDefiniteInstance, const Scope *S);
8571
8573 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
8574 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8575 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8576 const TemplateArgumentListInfo *TemplateArgs);
8577
8578 /// The main callback when the parser finds something like
8579 /// expression . [nested-name-specifier] identifier
8580 /// expression -> [nested-name-specifier] identifier
8581 /// where 'identifier' encompasses a fairly broad spectrum of
8582 /// possibilities, including destructor and operator references.
8583 ///
8584 /// \param OpKind either tok::arrow or tok::period
8585 /// \param ObjCImpDecl the current Objective-C \@implementation
8586 /// decl; this is an ugly hack around the fact that Objective-C
8587 /// \@implementations aren't properly put in the context chain
8589 tok::TokenKind OpKind, CXXScopeSpec &SS,
8590 SourceLocation TemplateKWLoc,
8591 UnqualifiedId &Member, Decl *ObjCImpDecl);
8592
8593 MemberExpr *
8594 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
8595 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
8596 ValueDecl *Member, DeclAccessPair FoundDecl,
8597 bool HadMultipleCandidates,
8598 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
8600 const TemplateArgumentListInfo *TemplateArgs = nullptr);
8601
8602 // Check whether the declarations we found through a nested-name
8603 // specifier in a member expression are actually members of the base
8604 // type. The restriction here is:
8605 //
8606 // C++ [expr.ref]p2:
8607 // ... In these cases, the id-expression shall name a
8608 // member of the class or of one of its base classes.
8609 //
8610 // So it's perfectly legitimate for the nested-name specifier to name
8611 // an unrelated class, and for us to find an overload set including
8612 // decls from classes which are not superclasses, as long as the decl
8613 // we actually pick through overload resolution is from a superclass.
8614 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
8615 const CXXScopeSpec &SS,
8616 const LookupResult &R);
8617
8618 // This struct is for use by ActOnMemberAccess to allow
8619 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
8620 // changing the access operator from a '.' to a '->' (to see if that is the
8621 // change needed to fix an error about an unknown member, e.g. when the class
8622 // defines a custom operator->).
8627 };
8628
8630 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
8631 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8632 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8633 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
8634 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8635
8638 bool IsArrow, const CXXScopeSpec &SS,
8639 SourceLocation TemplateKWLoc,
8640 NamedDecl *FirstQualifierInScope, LookupResult &R,
8641 const TemplateArgumentListInfo *TemplateArgs,
8642 const Scope *S, bool SuppressQualifierCheck = false,
8643 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8644
8645 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
8646 SourceLocation OpLoc,
8647 const CXXScopeSpec &SS, FieldDecl *Field,
8648 DeclAccessPair FoundDecl,
8649 const DeclarationNameInfo &MemberNameInfo);
8650
8651 /// Perform conversions on the LHS of a member access expression.
8653
8655 const CXXScopeSpec &SS, SourceLocation nameLoc,
8656 IndirectFieldDecl *indirectField,
8657 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
8658 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
8659
8660private:
8661 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
8662
8663 ///@}
8664
8665 //
8666 //
8667 // -------------------------------------------------------------------------
8668 //
8669 //
8670
8671 /// \name Initializers
8672 /// Implementations are in SemaInit.cpp
8673 ///@{
8674
8675public:
8676 /// Stack of types that correspond to the parameter entities that are
8677 /// currently being copy-initialized. Can be empty.
8679
8680 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
8682
8683 bool IsStringInit(Expr *Init, const ArrayType *AT);
8684
8685 /// Determine whether we can perform aggregate initialization for the purposes
8686 /// of overload resolution.
8688 const InitializedEntity &Entity, InitListExpr *From);
8689
8691 SourceLocation EqualOrColonLoc,
8692 bool GNUSyntax, ExprResult Init);
8693
8694 /// Check that the lifetime of the initializer (and its subobjects) is
8695 /// sufficient for initializing the entity, and perform lifetime extension
8696 /// (when permitted) if not.
8698
8701 bool BoundToLvalueReference);
8702
8703 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
8704 /// it as an xvalue. In C++98, the result will still be a prvalue, because
8705 /// we don't have xvalues there.
8707
8711
8715 SourceLocation EqualLoc, ExprResult Init,
8716 bool TopLevelOfInitList = false,
8717 bool AllowExplicit = false);
8718
8720 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
8722
8723 ///@}
8724
8725 //
8726 //
8727 // -------------------------------------------------------------------------
8728 //
8729 //
8730
8731 /// \name C++ Lambda Expressions
8732 /// Implementations are in SemaLambda.cpp
8733 ///@{
8734
8735public:
8736 /// Create a new lambda closure type.
8738 TypeSourceInfo *Info,
8739 unsigned LambdaDependencyKind,
8740 LambdaCaptureDefault CaptureDefault);
8741
8742 /// Number lambda for linkage purposes if necessary.
8744 std::optional<CXXRecordDecl::LambdaNumbering>
8745 NumberingOverride = std::nullopt);
8746
8747 /// Endow the lambda scope info with the relevant properties.
8748 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
8749 SourceRange IntroducerRange,
8750 LambdaCaptureDefault CaptureDefault,
8751 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
8752 bool Mutable);
8753
8756
8758 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
8759 TemplateParameterList *TemplateParams);
8760
8762 CXXMethodDecl *Method, SourceLocation LambdaLoc,
8763 SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause,
8764 TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind,
8766 bool HasExplicitResultType);
8767
8768 /// Returns true if the explicit object parameter was invalid.
8770 SourceLocation CallLoc);
8771
8772 /// Perform initialization analysis of the init-capture and perform
8773 /// any implicit conversions such as an lvalue-to-rvalue conversion if
8774 /// not being used to initialize a reference.
8776 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8779 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
8781 }
8783 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8784 std::optional<unsigned> NumExpansions, IdentifierInfo *Id,
8785 bool DirectInit, Expr *&Init);
8786
8787 /// Create a dummy variable within the declcontext of the lambda's
8788 /// call operator, for name lookup purposes for a lambda init capture.
8789 ///
8790 /// CodeGen handles emission of lambda captures, ignoring these dummy
8791 /// variables appropriately.
8793 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
8794 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
8795
8796 /// Add an init-capture to a lambda scope.
8797 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
8798
8799 /// Note that we have finished the explicit captures for the
8800 /// given lambda.
8802
8803 /// Deduce a block or lambda's return type based on the return
8804 /// statements present in the body.
8806
8807 /// Once the Lambdas capture are known, we can start to create the closure,
8808 /// call operator method, and keep track of the captures.
8809 /// We do the capture lookup here, but they are not actually captured until
8810 /// after we know what the qualifiers of the call operator are.
8812 Scope *CurContext);
8813
8814 /// This is called after parsing the explicit template parameter list
8815 /// on a lambda (if it exists) in C++2a.
8817 SourceLocation LAngleLoc,
8818 ArrayRef<NamedDecl *> TParams,
8819 SourceLocation RAngleLoc,
8820 ExprResult RequiresClause);
8821
8823 SourceLocation MutableLoc);
8824
8826 Scope *LambdaScope,
8828
8829 /// ActOnStartOfLambdaDefinition - This is called just before we start
8830 /// parsing the body of a lambda; it analyzes the explicit captures and
8831 /// arguments, and sets up various data-structures for the body of the
8832 /// lambda.
8834 Declarator &ParamInfo, const DeclSpec &DS);
8835
8836 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
8837 /// is invoked to pop the information about the lambda.
8838 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
8839 bool IsInstantiation = false);
8840
8841 /// ActOnLambdaExpr - This is called when the body of a lambda expression
8842 /// was successfully completed.
8844
8845 /// Does copying/destroying the captured variable have side effects?
8846 bool CaptureHasSideEffects(const sema::Capture &From);
8847
8848 /// Diagnose if an explicit lambda capture is unused. Returns true if a
8849 /// diagnostic is emitted.
8850 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
8851 const sema::Capture &From);
8852
8853 /// Build a FieldDecl suitable to hold the given capture.
8855
8856 /// Initialize the given capture with a suitable expression.
8858 SourceLocation ImplicitCaptureLoc,
8859 bool IsOpenMPMapping = false);
8860
8861 /// Complete a lambda-expression having processed and attached the
8862 /// lambda body.
8865
8866 /// Get the return type to use for a lambda's conversion function(s) to
8867 /// function pointer type, given the type of the call operator.
8868 QualType
8870 CallingConv CC);
8871
8873 SourceLocation ConvLocation,
8874 CXXConversionDecl *Conv, Expr *Src);
8875
8877 : private FunctionScopeRAII {
8878 public:
8880 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
8882 bool ShouldAddDeclsFromParentScope = true);
8883 };
8884
8885 /// Compute the mangling number context for a lambda expression or
8886 /// block literal. Also return the extra mangling decl if any.
8887 ///
8888 /// \param DC - The DeclContext containing the lambda expression or
8889 /// block literal.
8890 std::tuple<MangleNumberingContext *, Decl *>
8892
8893 ///@}
8894
8895 //
8896 //
8897 // -------------------------------------------------------------------------
8898 //
8899 //
8900
8901 /// \name Name Lookup
8902 ///
8903 /// These routines provide name lookup that is used during semantic
8904 /// analysis to resolve the various kinds of names (identifiers,
8905 /// overloaded operator names, constructor names, etc.) into zero or
8906 /// more declarations within a particular scope. The major entry
8907 /// points are LookupName, which performs unqualified name lookup,
8908 /// and LookupQualifiedName, which performs qualified name lookup.
8909 ///
8910 /// All name lookup is performed based on some specific criteria,
8911 /// which specify what names will be visible to name lookup and how
8912 /// far name lookup should work. These criteria are important both
8913 /// for capturing language semantics (certain lookups will ignore
8914 /// certain names, for example) and for performance, since name
8915 /// lookup is often a bottleneck in the compilation of C++. Name
8916 /// lookup criteria is specified via the LookupCriteria enumeration.
8917 ///
8918 /// The results of name lookup can vary based on the kind of name
8919 /// lookup performed, the current language, and the translation
8920 /// unit. In C, for example, name lookup will either return nothing
8921 /// (no entity found) or a single declaration. In C++, name lookup
8922 /// can additionally refer to a set of overloaded functions or
8923 /// result in an ambiguity. All of the possible results of name
8924 /// lookup are captured by the LookupResult class, which provides
8925 /// the ability to distinguish among them.
8926 ///
8927 /// Implementations are in SemaLookup.cpp
8928 ///@{
8929
8930public:
8931 /// Tracks whether we are in a context where typo correction is
8932 /// disabled.
8934
8935 /// The number of typos corrected by CorrectTypo.
8937
8938 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
8939 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
8940
8941 /// A cache containing identifiers for which typo correction failed and
8942 /// their locations, so that repeated attempts to correct an identifier in a
8943 /// given location are ignored if typo correction already failed for it.
8945
8946 /// SpecialMemberOverloadResult - The overloading result for a special member
8947 /// function.
8948 ///
8949 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
8950 /// integer are used to determine whether overload resolution succeeded.
8952 public:
8953 enum Kind { NoMemberOrDeleted, Ambiguous, Success };
8954
8955 private:
8956 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
8957
8958 public:
8961 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
8962
8963 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
8964 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
8965
8966 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
8967 void setKind(Kind K) { Pair.setInt(K); }
8968 };
8969
8970 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
8972 public:
8973 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
8974 : FastFoldingSetNode(ID) {}
8975 };
8976
8977 /// A cache of special member function overload resolution results
8978 /// for C++ records.
8979 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
8980
8981 /// Holds TypoExprs that are created from `createDelayedTypo`. This is used by
8982 /// `TransformTypos` in order to keep track of any TypoExprs that are created
8983 /// recursively during typo correction and wipe them away if the correction
8984 /// fails.
8986
8988
8989 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
8990 // TODO: make this is a typesafe union.
8993
8994 /// Describes the kind of name lookup to perform.
8996 /// Ordinary name lookup, which finds ordinary names (functions,
8997 /// variables, typedefs, etc.) in C and most kinds of names
8998 /// (functions, variables, members, types, etc.) in C++.
9000 /// Tag name lookup, which finds the names of enums, classes,
9001 /// structs, and unions.
9003 /// Label name lookup.
9005 /// Member name lookup, which finds the names of
9006 /// class/struct/union members.
9008 /// Look up of an operator name (e.g., operator+) for use with
9009 /// operator overloading. This lookup is similar to ordinary name
9010 /// lookup, but will ignore any declarations that are class members.
9012 /// Look up a name following ~ in a destructor name. This is an ordinary
9013 /// lookup, but prefers tags to typedefs.
9015 /// Look up of a name that precedes the '::' scope resolution
9016 /// operator in C++. This lookup completely ignores operator, object,
9017 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9019 /// Look up a namespace name within a C++ using directive or
9020 /// namespace alias definition, ignoring non-namespace names (C++
9021 /// [basic.lookup.udir]p1).
9023 /// Look up all declarations in a scope with the given name,
9024 /// including resolved using declarations. This is appropriate
9025 /// for checking redeclarations for a using declaration.
9027 /// Look up an ordinary name that is going to be redeclared as a
9028 /// name with linkage. This lookup ignores any declarations that
9029 /// are outside of the current scope unless they have linkage. See
9030 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9032 /// Look up a friend of a local class. This lookup does not look
9033 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9035 /// Look up the name of an Objective-C protocol.
9037 /// Look up implicit 'self' parameter of an objective-c method.
9039 /// Look up the name of an OpenMP user-defined reduction operation.
9041 /// Look up the name of an OpenMP user-defined mapper.
9043 /// Look up any declaration with any name.
9046
9047 /// The possible outcomes of name lookup for a literal operator.
9049 /// The lookup resulted in an error.
9051 /// The lookup found no match but no diagnostic was issued.
9053 /// The lookup found a single 'cooked' literal operator, which
9054 /// expects a normal literal to be built and passed to it.
9056 /// The lookup found a single 'raw' literal operator, which expects
9057 /// a string literal containing the spelling of the literal token.
9059 /// The lookup found an overload set of literal operator templates,
9060 /// which expect the characters of the spelling of the literal token to be
9061 /// passed as a non-type template argument pack.
9063 /// The lookup found an overload set of literal operator templates,
9064 /// which expect the character type and characters of the spelling of the
9065 /// string literal token to be passed as template arguments.
9067 };
9068
9069 SpecialMemberOverloadResult
9071 bool VolatileArg, bool RValueThis, bool ConstThis,
9072 bool VolatileThis);
9073
9074 typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
9075 typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
9077
9079
9080 /// Look up a name, looking for a single declaration. Return
9081 /// null if the results were absent, ambiguous, or overloaded.
9082 ///
9083 /// It is preferable to use the elaborated form and explicitly handle
9084 /// ambiguity and overloaded.
9087 LookupNameKind NameKind,
9088 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
9089
9090 /// Lookup a builtin function, when name lookup would otherwise
9091 /// fail.
9092 bool LookupBuiltin(LookupResult &R);
9093 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9094
9095 /// Perform unqualified name lookup starting from a given
9096 /// scope.
9097 ///
9098 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9099 /// used to find names within the current scope. For example, 'x' in
9100 /// @code
9101 /// int x;
9102 /// int f() {
9103 /// return x; // unqualified name look finds 'x' in the global scope
9104 /// }
9105 /// @endcode
9106 ///
9107 /// Different lookup criteria can find different names. For example, a
9108 /// particular scope can have both a struct and a function of the same
9109 /// name, and each can be found by certain lookup criteria. For more
9110 /// information about lookup criteria, see the documentation for the
9111 /// class LookupCriteria.
9112 ///
9113 /// @param S The scope from which unqualified name lookup will
9114 /// begin. If the lookup criteria permits, name lookup may also search
9115 /// in the parent scopes.
9116 ///
9117 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9118 /// look up and the lookup kind), and is updated with the results of lookup
9119 /// including zero or more declarations and possibly additional information
9120 /// used to diagnose ambiguities.
9121 ///
9122 /// @returns \c true if lookup succeeded and false otherwise.
9123 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9124 bool ForceNoCPlusPlus = false);
9125
9126 /// Perform qualified name lookup into a given context.
9127 ///
9128 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9129 /// names when the context of those names is explicit specified, e.g.,
9130 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9131 ///
9132 /// Different lookup criteria can find different names. For example, a
9133 /// particular scope can have both a struct and a function of the same
9134 /// name, and each can be found by certain lookup criteria. For more
9135 /// information about lookup criteria, see the documentation for the
9136 /// class LookupCriteria.
9137 ///
9138 /// \param R captures both the lookup criteria and any lookup results found.
9139 ///
9140 /// \param LookupCtx The context in which qualified name lookup will
9141 /// search. If the lookup criteria permits, name lookup may also search
9142 /// in the parent contexts or (for C++ classes) base classes.
9143 ///
9144 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9145 /// occurs as part of unqualified name lookup.
9146 ///
9147 /// \returns true if lookup succeeded, false if it failed.
9148 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9149 bool InUnqualifiedLookup = false);
9150
9151 /// Performs qualified name lookup or special type of lookup for
9152 /// "__super::" scope specifier.
9153 ///
9154 /// This routine is a convenience overload meant to be called from contexts
9155 /// that need to perform a qualified name lookup with an optional C++ scope
9156 /// specifier that might require special kind of lookup.
9157 ///
9158 /// \param R captures both the lookup criteria and any lookup results found.
9159 ///
9160 /// \param LookupCtx The context in which qualified name lookup will
9161 /// search.
9162 ///
9163 /// \param SS An optional C++ scope-specifier.
9164 ///
9165 /// \returns true if lookup succeeded, false if it failed.
9166 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9167 CXXScopeSpec &SS);
9168
9169 /// Performs name lookup for a name that was parsed in the
9170 /// source code, and may contain a C++ scope specifier.
9171 ///
9172 /// This routine is a convenience routine meant to be called from
9173 /// contexts that receive a name and an optional C++ scope specifier
9174 /// (e.g., "N::M::x"). It will then perform either qualified or
9175 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9176 /// respectively) on the given name and return those results. It will
9177 /// perform a special type of lookup for "__super::" scope specifier.
9178 ///
9179 /// @param S The scope from which unqualified name lookup will
9180 /// begin.
9181 ///
9182 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9183 ///
9184 /// @param EnteringContext Indicates whether we are going to enter the
9185 /// context of the scope-specifier SS (if present).
9186 ///
9187 /// @returns True if any decls were found (but possibly ambiguous)
9189 QualType ObjectType, bool AllowBuiltinCreation = false,
9190 bool EnteringContext = false);
9191
9192 /// Perform qualified name lookup into all base classes of the given
9193 /// class.
9194 ///
9195 /// \param R captures both the lookup criteria and any lookup results found.
9196 ///
9197 /// \param Class The context in which qualified name lookup will
9198 /// search. Name lookup will search in all base classes merging the results.
9199 ///
9200 /// @returns True if any decls were found (but possibly ambiguous)
9202
9204 UnresolvedSetImpl &Functions);
9205
9206 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9207 /// If GnuLabelLoc is a valid source location, then this is a definition
9208 /// of an __label__ label name, otherwise it is a normal label definition
9209 /// or use.
9211 SourceLocation GnuLabelLoc = SourceLocation());
9212
9213 /// Look up the constructors for the given class.
9215
9216 /// Look up the default constructor for the given class.
9218
9219 /// Look up the copying constructor for the given class.
9221 unsigned Quals);
9222
9223 /// Look up the copying assignment operator for the given class.
9225 bool RValueThis, unsigned ThisQuals);
9226
9227 /// Look up the moving constructor for the given class.
9229 unsigned Quals);
9230
9231 /// Look up the moving assignment operator for the given class.
9233 bool RValueThis, unsigned ThisQuals);
9234
9235 /// Look for the destructor of the given class.
9236 ///
9237 /// During semantic analysis, this routine should be used in lieu of
9238 /// CXXRecordDecl::getDestructor().
9239 ///
9240 /// \returns The destructor for this class.
9242
9243 /// Force the declaration of any implicitly-declared members of this
9244 /// class.
9246
9247 /// Make a merged definition of an existing hidden definition \p ND
9248 /// visible at the specified location.
9250
9251 /// Check ODR hashes for C/ObjC when merging types from modules.
9252 /// Differently from C++, actually parse the body and reject in case
9253 /// of a mismatch.
9254 template <typename T,
9255 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9257 if (Duplicate->getODRHash() != Previous->getODRHash())
9258 return false;
9259
9260 // Make the previous decl visible.
9262 return true;
9263 }
9264
9265 /// Get the set of additional modules that should be checked during
9266 /// name lookup. A module and its imports become visible when instanting a
9267 /// template defined within it.
9269
9270 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9272
9273 /// Determine if the template parameter \p D has a visible default argument.
9274 bool
9276 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9277 /// Determine if the template parameter \p D has a reachable default argument.
9279 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9280 /// Determine if the template parameter \p D has a reachable default argument.
9284
9285 /// Determine if there is a visible declaration of \p D that is an explicit
9286 /// specialization declaration for a specialization of a template. (For a
9287 /// member specialization, use hasVisibleMemberSpecialization.)
9289 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9290 /// Determine if there is a reachable declaration of \p D that is an explicit
9291 /// specialization declaration for a specialization of a template. (For a
9292 /// member specialization, use hasReachableMemberSpecialization.)
9294 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9295
9296 /// Determine if there is a visible declaration of \p D that is a member
9297 /// specialization declaration (as opposed to an instantiated declaration).
9299 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9300 /// Determine if there is a reachable declaration of \p D that is a member
9301 /// specialization declaration (as opposed to an instantiated declaration).
9303 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9304
9305 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9306
9307 /// Determine whether any declaration of an entity is visible.
9308 bool
9310 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9311 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9312 }
9313
9316 /// Determine whether any declaration of an entity is reachable.
9317 bool
9319 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9320 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9321 }
9323 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9324
9325 void diagnoseTypo(const TypoCorrection &Correction,
9326 const PartialDiagnostic &TypoDiag,
9327 bool ErrorRecovery = true);
9328
9329 /// Diagnose a successfully-corrected typo. Separated from the correction
9330 /// itself to allow external validation of the result, etc.
9331 ///
9332 /// \param Correction The result of performing typo correction.
9333 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9334 /// string added to it (and usually also a fixit).
9335 /// \param PrevNote A note to use when indicating the location of the entity
9336 /// to which we are correcting. Will have the correction string added
9337 /// to it.
9338 /// \param ErrorRecovery If \c true (the default), the caller is going to
9339 /// recover from the typo as if the corrected string had been typed.
9340 /// In this case, \c PDiag must be an error, and we will attach a fixit
9341 /// to it.
9342 void diagnoseTypo(const TypoCorrection &Correction,
9343 const PartialDiagnostic &TypoDiag,
9344 const PartialDiagnostic &PrevNote,
9345 bool ErrorRecovery = true);
9346
9347 /// Find the associated classes and namespaces for
9348 /// argument-dependent lookup for a call with the given set of
9349 /// arguments.
9350 ///
9351 /// This routine computes the sets of associated classes and associated
9352 /// namespaces searched by argument-dependent lookup
9353 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9355 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9356 AssociatedNamespaceSet &AssociatedNamespaces,
9357 AssociatedClassSet &AssociatedClasses);
9358
9359 /// Produce a diagnostic describing the ambiguity that resulted
9360 /// from name lookup.
9361 ///
9362 /// \param Result The result of the ambiguous lookup to be diagnosed.
9364
9365 /// LookupLiteralOperator - Determine which literal operator should be used
9366 /// for a user-defined literal, per C++11 [lex.ext].
9367 ///
9368 /// Normal overload resolution is not used to select which literal operator to
9369 /// call for a user-defined literal. Look up the provided literal operator
9370 /// name, and filter the results to the appropriate set for the given argument
9371 /// types.
9374 bool AllowRaw, bool AllowTemplate,
9375 bool AllowStringTemplate, bool DiagnoseMissing,
9376 StringLiteral *StringLit = nullptr);
9377
9379 ArrayRef<Expr *> Args, ADLResult &Functions);
9380
9383 bool IncludeGlobalScope = true,
9384 bool LoadExternal = true);
9387 bool IncludeGlobalScope = true,
9388 bool IncludeDependentBases = false,
9389 bool LoadExternal = true);
9390
9392 CTK_NonError, // CorrectTypo used in a non error recovery situation.
9393 CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
9395
9396 /// Try to "correct" a typo in the source code by finding
9397 /// visible declarations whose names are similar to the name that was
9398 /// present in the source code.
9399 ///
9400 /// \param TypoName the \c DeclarationNameInfo structure that contains
9401 /// the name that was present in the source code along with its location.
9402 ///
9403 /// \param LookupKind the name-lookup criteria used to search for the name.
9404 ///
9405 /// \param S the scope in which name lookup occurs.
9406 ///
9407 /// \param SS the nested-name-specifier that precedes the name we're
9408 /// looking for, if present.
9409 ///
9410 /// \param CCC A CorrectionCandidateCallback object that provides further
9411 /// validation of typo correction candidates. It also provides flags for
9412 /// determining the set of keywords permitted.
9413 ///
9414 /// \param MemberContext if non-NULL, the context in which to look for
9415 /// a member access expression.
9416 ///
9417 /// \param EnteringContext whether we're entering the context described by
9418 /// the nested-name-specifier SS.
9419 ///
9420 /// \param OPT when non-NULL, the search for visible declarations will
9421 /// also walk the protocols in the qualified interfaces of \p OPT.
9422 ///
9423 /// \returns a \c TypoCorrection containing the corrected name if the typo
9424 /// along with information such as the \c NamedDecl where the corrected name
9425 /// was declared, and any additional \c NestedNameSpecifier needed to access
9426 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9428 Sema::LookupNameKind LookupKind, Scope *S,
9430 CorrectTypoKind Mode,
9431 DeclContext *MemberContext = nullptr,
9432 bool EnteringContext = false,
9433 const ObjCObjectPointerType *OPT = nullptr,
9434 bool RecordFailure = true);
9435
9436 /// Try to "correct" a typo in the source code by finding
9437 /// visible declarations whose names are similar to the name that was
9438 /// present in the source code.
9439 ///
9440 /// \param TypoName the \c DeclarationNameInfo structure that contains
9441 /// the name that was present in the source code along with its location.
9442 ///
9443 /// \param LookupKind the name-lookup criteria used to search for the name.
9444 ///
9445 /// \param S the scope in which name lookup occurs.
9446 ///
9447 /// \param SS the nested-name-specifier that precedes the name we're
9448 /// looking for, if present.
9449 ///
9450 /// \param CCC A CorrectionCandidateCallback object that provides further
9451 /// validation of typo correction candidates. It also provides flags for
9452 /// determining the set of keywords permitted.
9453 ///
9454 /// \param TDG A TypoDiagnosticGenerator functor that will be used to print
9455 /// diagnostics when the actual typo correction is attempted.
9456 ///
9457 /// \param TRC A TypoRecoveryCallback functor that will be used to build an
9458 /// Expr from a typo correction candidate.
9459 ///
9460 /// \param MemberContext if non-NULL, the context in which to look for
9461 /// a member access expression.
9462 ///
9463 /// \param EnteringContext whether we're entering the context described by
9464 /// the nested-name-specifier SS.
9465 ///
9466 /// \param OPT when non-NULL, the search for visible declarations will
9467 /// also walk the protocols in the qualified interfaces of \p OPT.
9468 ///
9469 /// \returns a new \c TypoExpr that will later be replaced in the AST with an
9470 /// Expr representing the result of performing typo correction, or nullptr if
9471 /// typo correction is not possible. If nullptr is returned, no diagnostics
9472 /// will be emitted and it is the responsibility of the caller to emit any
9473 /// that are needed.
9475 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9478 CorrectTypoKind Mode, DeclContext *MemberContext = nullptr,
9479 bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr);
9480
9481 /// Kinds of missing import. Note, the values of these enumerators correspond
9482 /// to %select values in diagnostics.
9485 Definition,
9489 };
9490
9491 /// Diagnose that the specified declaration needs to be visible but
9492 /// isn't, and suggest a module import that would resolve the problem.
9494 MissingImportKind MIK, bool Recover = true);
9496 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9497 MissingImportKind MIK, bool Recover);
9498
9500 std::unique_ptr<TypoCorrectionConsumer> Consumer;
9503 TypoExprState();
9504 TypoExprState(TypoExprState &&other) noexcept;
9505 TypoExprState &operator=(TypoExprState &&other) noexcept;
9506 };
9507
9508 const TypoExprState &getTypoExprState(TypoExpr *TE) const;
9509
9510 /// Clears the state of the given TypoExpr.
9511 void clearDelayedTypo(TypoExpr *TE);
9512
9513 /// Called on #pragma clang __debug dump II
9515
9516 /// Called on #pragma clang __debug dump E
9517 void ActOnPragmaDump(Expr *E);
9518
9519private:
9520 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9521 //
9522 // The boolean value will be true to indicate that the namespace was loaded
9523 // from an AST/PCH file, or false otherwise.
9524 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9525
9526 /// Whether we have already loaded known namespaces from an extenal
9527 /// source.
9528 bool LoadedExternalKnownNamespaces;
9529
9530 bool CppLookupName(LookupResult &R, Scope *S);
9531
9532 /// Determine if we could use all the declarations in the module.
9533 bool isUsableModule(const Module *M);
9534
9535 /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
9536 /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
9537 /// should be skipped entirely.
9538 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9539 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9541 DeclContext *MemberContext, bool EnteringContext,
9542 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9543
9544 /// The set of unhandled TypoExprs and their associated state.
9545 llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
9546
9547 /// Creates a new TypoExpr AST node.
9548 TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
9551
9552 /// Cache for module units which is usable for current module.
9553 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9554
9555 /// Record the typo correction failure and return an empty correction.
9556 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9557 bool RecordFailure = true) {
9558 if (RecordFailure)
9559 TypoCorrectionFailures[Typo].insert(TypoLoc);
9560 return TypoCorrection();
9561 }
9562
9563 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9564
9565 /// Determine whether two declarations should be linked together, given that
9566 /// the old declaration might not be visible and the new declaration might
9567 /// not have external linkage.
9568 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9569 const NamedDecl *New) {
9570 if (isVisible(Old))
9571 return true;
9572 // See comment in below overload for why it's safe to compute the linkage
9573 // of the new declaration here.
9574 if (New->isExternallyDeclarable()) {
9575 assert(Old->isExternallyDeclarable() &&
9576 "should not have found a non-externally-declarable previous decl");
9577 return true;
9578 }
9579 return false;
9580 }
9581 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9582
9583 ///@}
9584
9585 //
9586 //
9587 // -------------------------------------------------------------------------
9588 //
9589 //
9590
9591 /// \name Modules
9592 /// Implementations are in SemaModule.cpp
9593 ///@{
9594
9595public:
9596 /// Get the module unit whose scope we are currently within.
9598 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9599 }
9600
9601 /// Is the module scope we are an implementation unit?
9603 return ModuleScopes.empty()
9604 ? false
9605 : ModuleScopes.back().Module->isModuleImplementation();
9606 }
9607
9608 // When loading a non-modular PCH files, this is used to restore module
9609 // visibility.
9611 VisibleModules.setVisible(Mod, ImportLoc);
9612 }
9613
9614 enum class ModuleDeclKind {
9615 Interface, ///< 'export module X;'
9616 Implementation, ///< 'module X;'
9617 PartitionInterface, ///< 'export module X:Y;'
9618 PartitionImplementation, ///< 'module X:Y;'
9619 };
9620
9621 /// An enumeration to represent the transition of states in parsing module
9622 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9623 /// an error in state transition, the state is set to NotACXX20Module.
9625 FirstDecl, ///< Parsing the first decl in a TU.
9626 GlobalFragment, ///< after 'module;' but before 'module X;'
9627 ImportAllowed, ///< after 'module X;' but before any non-import decl.
9628 ImportFinished, ///< after any non-import decl.
9629 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
9630 ///< non-import decl.
9631 PrivateFragmentImportFinished, ///< after 'module :private;' but a
9632 ///< non-import decl has already been seen.
9633 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
9634 };
9635
9636 /// The parser has processed a module-declaration that begins the definition
9637 /// of a module interface or implementation.
9639 SourceLocation ModuleLoc, ModuleDeclKind MDK,
9640 ModuleIdPath Path, ModuleIdPath Partition,
9641 ModuleImportState &ImportState);
9642
9643 /// The parser has processed a global-module-fragment declaration that begins
9644 /// the definition of the global module fragment of the current module unit.
9645 /// \param ModuleLoc The location of the 'module' keyword.
9647
9648 /// The parser has processed a private-module-fragment declaration that begins
9649 /// the definition of the private module fragment of the current module unit.
9650 /// \param ModuleLoc The location of the 'module' keyword.
9651 /// \param PrivateLoc The location of the 'private' keyword.
9653 SourceLocation PrivateLoc);
9654
9655 /// The parser has processed a module import declaration.
9656 ///
9657 /// \param StartLoc The location of the first token in the declaration. This
9658 /// could be the location of an '@', 'export', or 'import'.
9659 /// \param ExportLoc The location of the 'export' keyword, if any.
9660 /// \param ImportLoc The location of the 'import' keyword.
9661 /// \param Path The module toplevel name as an access path.
9662 /// \param IsPartition If the name is for a partition.
9664 SourceLocation ExportLoc,
9665 SourceLocation ImportLoc, ModuleIdPath Path,
9666 bool IsPartition = false);
9668 SourceLocation ExportLoc,
9669 SourceLocation ImportLoc, Module *M,
9670 ModuleIdPath Path = {});
9671
9672 /// The parser has processed a module import translated from a
9673 /// #include or similar preprocessing directive.
9674 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9675 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9676
9677 /// The parsed has entered a submodule.
9678 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
9679 /// The parser has left a submodule.
9680 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
9681
9682 /// Create an implicit import of the given module at the given
9683 /// source location, for error recovery, if possible.
9684 ///
9685 /// This routine is typically used when an entity found by name lookup
9686 /// is actually hidden within a module that we know about but the user
9687 /// has forgotten to import.
9689 Module *Mod);
9690
9691 /// We have parsed the start of an export declaration, including the '{'
9692 /// (if present).
9693 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
9694 SourceLocation LBraceLoc);
9695
9696 /// Complete the definition of an export declaration.
9697 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
9698 SourceLocation RBraceLoc);
9699
9700private:
9701 /// The parser has begun a translation unit to be compiled as a C++20
9702 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
9703 void HandleStartOfHeaderUnit();
9704
9705 struct ModuleScope {
9706 SourceLocation BeginLoc;
9707 clang::Module *Module = nullptr;
9708 VisibleModuleSet OuterVisibleModules;
9709 };
9710 /// The modules we're currently parsing.
9712
9713 /// For an interface unit, this is the implicitly imported interface unit.
9714 clang::Module *ThePrimaryInterface = nullptr;
9715
9716 /// The explicit global module fragment of the current translation unit.
9717 /// The explicit Global Module Fragment, as specified in C++
9718 /// [module.global.frag].
9719 clang::Module *TheGlobalModuleFragment = nullptr;
9720
9721 /// The implicit global module fragments of the current translation unit.
9722 ///
9723 /// The contents in the implicit global module fragment can't be discarded.
9724 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
9725
9726 /// Namespace definitions that we will export when they finish.
9727 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
9728
9729 /// In a C++ standard module, inline declarations require a definition to be
9730 /// present at the end of a definition domain. This set holds the decls to
9731 /// be checked at the end of the TU.
9732 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
9733
9734 /// Helper function to judge if we are in module purview.
9735 /// Return false if we are not in a module.
9736 bool isCurrentModulePurview() const;
9737
9738 /// Enter the scope of the explicit global module fragment.
9739 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
9740 /// Leave the scope of the explicit global module fragment.
9741 void PopGlobalModuleFragment();
9742
9743 /// Enter the scope of an implicit global module fragment.
9744 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
9745 /// Leave the scope of an implicit global module fragment.
9746 void PopImplicitGlobalModuleFragment();
9747
9748 VisibleModuleSet VisibleModules;
9749
9750 ///@}
9751
9752 //
9753 //
9754 // -------------------------------------------------------------------------
9755 //
9756 //
9757
9758 /// \name C++ Overloading
9759 /// Implementations are in SemaOverload.cpp
9760 ///@{
9761
9762public:
9763 /// Whether deferrable diagnostics should be deferred.
9764 bool DeferDiags = false;
9765
9766 /// RAII class to control scope of DeferDiags.
9768 Sema &S;
9769 bool SavedDeferDiags = false;
9770
9771 public:
9772 DeferDiagsRAII(Sema &S, bool DeferDiags)
9773 : S(S), SavedDeferDiags(S.DeferDiags) {
9774 S.DeferDiags = DeferDiags;
9775 }
9776 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
9777 };
9778
9779 /// Flag indicating if Sema is building a recovery call expression.
9780 ///
9781 /// This flag is used to avoid building recovery call expressions
9782 /// if Sema is already doing so, which would cause infinite recursions.
9784
9786 /// This is a legitimate overload: the existing declarations are
9787 /// functions or function templates with different signatures.
9789
9790 /// This is not an overload because the signature exactly matches
9791 /// an existing declaration.
9793
9794 /// This is not an overload because the lookup results contain a
9795 /// non-function.
9798
9799 /// Determine whether the given New declaration is an overload of the
9800 /// declarations in Old. This routine returns Ovl_Match or Ovl_NonFunction if
9801 /// New and Old cannot be overloaded, e.g., if New has the same signature as
9802 /// some function in Old (C++ 1.3.10) or if the Old declarations aren't
9803 /// functions (or function templates) at all. When it does return Ovl_Match or
9804 /// Ovl_NonFunction, MatchedDecl will point to the decl that New cannot be
9805 /// overloaded with. This decl may be a UsingShadowDecl on top of the
9806 /// underlying declaration.
9807 ///
9808 /// Example: Given the following input:
9809 ///
9810 /// void f(int, float); // #1
9811 /// void f(int, int); // #2
9812 /// int f(int, int); // #3
9813 ///
9814 /// When we process #1, there is no previous declaration of "f", so IsOverload
9815 /// will not be used.
9816 ///
9817 /// When we process #2, Old contains only the FunctionDecl for #1. By
9818 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
9819 /// they have different signatures), so this routine returns Ovl_Overload;
9820 /// MatchedDecl is unchanged.
9821 ///
9822 /// When we process #3, Old is an overload set containing #1 and #2. We
9823 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
9824 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
9825 /// types of functions are not part of the signature), IsOverload returns
9826 /// Ovl_Match and MatchedDecl will be set to point to the FunctionDecl for #2.
9827 ///
9828 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
9829 /// class by a using declaration. The rules for whether to hide shadow
9830 /// declarations ignore some properties which otherwise figure into a function
9831 /// template's signature.
9833 const LookupResult &OldDecls, NamedDecl *&OldDecl,
9834 bool UseMemberUsingDeclRules);
9835 bool IsOverload(FunctionDecl *New, FunctionDecl *Old,
9836 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9837
9838 // Checks whether MD constitutes an override the base class method BaseMD.
9839 // When checking for overrides, the object object members are ignored.
9840 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
9841 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9842
9843 enum class AllowedExplicit {
9844 /// Allow no explicit functions to be used.
9845 None,
9846 /// Allow explicit conversion functions but not explicit constructors.
9848 /// Allow both explicit conversion functions and explicit constructors.
9849 All
9850 };
9851
9853 Expr *From, QualType ToType, bool SuppressUserConversions,
9854 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
9855 bool AllowObjCWritebackConversion);
9856
9857 /// PerformImplicitConversion - Perform an implicit conversion of the
9858 /// expression From to the type ToType. Returns the
9859 /// converted expression. Flavor is the kind of conversion we're
9860 /// performing, used in the error message. If @p AllowExplicit,
9861 /// explicit user-defined conversions are permitted.
9863 AssignmentAction Action,
9864 bool AllowExplicit = false);
9865
9866 /// IsIntegralPromotion - Determines whether the conversion from the
9867 /// expression From (whose potentially-adjusted type is FromType) to
9868 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
9869 /// sets PromotedType to the promoted type.
9870 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
9871
9872 /// IsFloatingPointPromotion - Determines whether the conversion from
9873 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
9874 /// returns true and sets PromotedType to the promoted type.
9875 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
9876
9877 /// Determine if a conversion is a complex promotion.
9878 ///
9879 /// A complex promotion is defined as a complex -> complex conversion
9880 /// where the conversion between the underlying real types is a
9881 /// floating-point or integral promotion.
9882 bool IsComplexPromotion(QualType FromType, QualType ToType);
9883
9884 /// IsPointerConversion - Determines whether the conversion of the
9885 /// expression From, which has the (possibly adjusted) type FromType,
9886 /// can be converted to the type ToType via a pointer conversion (C++
9887 /// 4.10). If so, returns true and places the converted type (that
9888 /// might differ from ToType in its cv-qualifiers at some level) into
9889 /// ConvertedType.
9890 ///
9891 /// This routine also supports conversions to and from block pointers
9892 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
9893 /// pointers to interfaces. FIXME: Once we've determined the
9894 /// appropriate overloading rules for Objective-C, we may want to
9895 /// split the Objective-C checks into a different routine; however,
9896 /// GCC seems to consider all of these conversions to be pointer
9897 /// conversions, so for now they live here. IncompatibleObjC will be
9898 /// set if the conversion is an allowed Objective-C conversion that
9899 /// should result in a warning.
9900 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
9901 bool InOverloadResolution, QualType &ConvertedType,
9902 bool &IncompatibleObjC);
9903
9904 /// isObjCPointerConversion - Determines whether this is an
9905 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
9906 /// with the same arguments and return values.
9907 bool isObjCPointerConversion(QualType FromType, QualType ToType,
9908 QualType &ConvertedType, bool &IncompatibleObjC);
9909 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
9910 QualType &ConvertedType);
9911
9912 /// FunctionParamTypesAreEqual - This routine checks two function proto types
9913 /// for equality of their parameter types. Caller has already checked that
9914 /// they have same number of parameters. If the parameters are different,
9915 /// ArgPos will have the parameter index of the first different parameter.
9916 /// If `Reversed` is true, the parameters of `NewType` will be compared in
9917 /// reverse order. That's useful if one of the functions is being used as a
9918 /// C++20 synthesized operator overload with a reversed parameter order.
9921 unsigned *ArgPos = nullptr,
9922 bool Reversed = false);
9923
9925 const FunctionProtoType *NewType,
9926 unsigned *ArgPos = nullptr,
9927 bool Reversed = false);
9928
9929 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
9930 const FunctionDecl *NewFunction,
9931 unsigned *ArgPos = nullptr,
9932 bool Reversed = false);
9933
9934 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
9935 /// function types. Catches different number of parameter, mismatch in
9936 /// parameter types, and different return types.
9938 QualType ToType);
9939
9940 /// CheckPointerConversion - Check the pointer conversion from the
9941 /// expression From to the type ToType. This routine checks for
9942 /// ambiguous or inaccessible derived-to-base pointer
9943 /// conversions for which IsPointerConversion has already returned
9944 /// true. It returns true and produces a diagnostic if there was an
9945 /// error, or returns false otherwise.
9946 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
9947 CXXCastPath &BasePath, bool IgnoreBaseAccess,
9948 bool Diagnose = true);
9949
9950 /// IsMemberPointerConversion - Determines whether the conversion of the
9951 /// expression From, which has the (possibly adjusted) type FromType, can be
9952 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
9953 /// If so, returns true and places the converted type (that might differ from
9954 /// ToType in its cv-qualifiers at some level) into ConvertedType.
9955 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
9956 bool InOverloadResolution,
9957 QualType &ConvertedType);
9958
9959 /// CheckMemberPointerConversion - Check the member pointer conversion from
9960 /// the expression From to the type ToType. This routine checks for ambiguous
9961 /// or virtual or inaccessible base-to-derived member pointer conversions for
9962 /// which IsMemberPointerConversion has already returned true. It returns true
9963 /// and produces a diagnostic if there was an error, or returns false
9964 /// otherwise.
9966 CXXCastPath &BasePath,
9967 bool IgnoreBaseAccess);
9968
9969 /// IsQualificationConversion - Determines whether the conversion from
9970 /// an rvalue of type FromType to ToType is a qualification conversion
9971 /// (C++ 4.4).
9972 ///
9973 /// \param ObjCLifetimeConversion Output parameter that will be set to
9974 /// indicate when the qualification conversion involves a change in the
9975 /// Objective-C object lifetime.
9976 bool IsQualificationConversion(QualType FromType, QualType ToType,
9977 bool CStyle, bool &ObjCLifetimeConversion);
9978
9979 /// Determine whether the conversion from FromType to ToType is a valid
9980 /// conversion that strips "noexcept" or "noreturn" off the nested function
9981 /// type.
9982 bool IsFunctionConversion(QualType FromType, QualType ToType,
9983 QualType &ResultTy);
9986 DeclarationName Name,
9987 OverloadCandidateSet &CandidateSet,
9988 FunctionDecl *Fn, MultiExprArg Args,
9989 bool IsMember = false);
9990
9992 FunctionDecl *Fun);
9994 Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl,
9995 CXXMethodDecl *Method);
9996
9997 /// PerformContextuallyConvertToBool - Perform a contextual conversion
9998 /// of the expression From to bool (C++0x [conv]p3).
10000
10001 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
10002 /// conversion of the expression From to an Objective-C pointer type.
10003 /// Returns a valid but null ExprResult if no conversion sequence exists.
10005
10006 /// Contexts in which a converted constant expression is required.
10007 enum CCEKind {
10008 CCEK_CaseValue, ///< Expression in a case label.
10009 CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
10010 CCEK_TemplateArg, ///< Value of a non-type template parameter.
10011 CCEK_ArrayBound, ///< Array bound in array declarator or new-expression.
10012 CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier.
10013 CCEK_Noexcept, ///< Condition in a noexcept(bool) specifier.
10014 CCEK_StaticAssertMessageSize, ///< Call to size() in a static assert
10015 ///< message.
10016 CCEK_StaticAssertMessageData, ///< Call to data() in a static assert
10017 ///< message.
10018 };
10019
10021 CCEKind CCE,
10022 NamedDecl *Dest = nullptr);
10023
10025 llvm::APSInt &Value, CCEKind CCE);
10027 APValue &Value, CCEKind CCE,
10028 NamedDecl *Dest = nullptr);
10029
10030 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10031 /// That is a converted constant expression
10032 /// (which was built with BuildConvertedConstantExpression)
10035 CCEKind CCE, bool RequireInt,
10036 const APValue &PreNarrowingValue);
10037
10038 /// Abstract base class used to perform a contextual implicit
10039 /// conversion from an expression to any type passing a filter.
10041 public:
10044
10045 ContextualImplicitConverter(bool Suppress = false,
10046 bool SuppressConversion = false)
10047 : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
10048
10049 /// Determine whether the specified type is a valid destination type
10050 /// for this conversion.
10051 virtual bool match(QualType T) = 0;
10052
10053 /// Emits a diagnostic complaining that the expression does not have
10054 /// integral or enumeration type.
10056 QualType T) = 0;
10057
10058 /// Emits a diagnostic when the expression has incomplete class type.
10059 virtual SemaDiagnosticBuilder
10061
10062 /// Emits a diagnostic when the only matching conversion function
10063 /// is explicit.
10066 QualType T,
10067 QualType ConvTy) = 0;
10068
10069 /// Emits a note for the explicit conversion function.
10070 virtual SemaDiagnosticBuilder
10072
10073 /// Emits a diagnostic when there are multiple possible conversion
10074 /// functions.
10076 QualType T) = 0;
10077
10078 /// Emits a note for one of the candidate conversions.
10079 virtual SemaDiagnosticBuilder
10081
10082 /// Emits a diagnostic when we picked a conversion function
10083 /// (for cases when we are not allowed to pick a conversion function).
10086 QualType T,
10087 QualType ConvTy) = 0;
10088
10090 };
10091
10093 bool AllowScopedEnumerations;
10094
10095 public:
10096 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10097 bool SuppressConversion)
10098 : ContextualImplicitConverter(Suppress, SuppressConversion),
10099 AllowScopedEnumerations(AllowScopedEnumerations) {}
10100
10101 /// Match an integral or (possibly scoped) enumeration type.
10102 bool match(QualType T) override;
10103
10105 QualType T) override {
10106 return diagnoseNotInt(S, Loc, T);
10107 }
10108
10109 /// Emits a diagnostic complaining that the expression does not have
10110 /// integral or enumeration type.
10112 QualType T) = 0;
10113 };
10114
10115 /// Perform a contextual implicit conversion.
10118 ContextualImplicitConverter &Converter);
10119
10120 /// ReferenceCompareResult - Expresses the result of comparing two
10121 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10122 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10124 /// Ref_Incompatible - The two types are incompatible, so direct
10125 /// reference binding is not possible.
10127 /// Ref_Related - The two types are reference-related, which means
10128 /// that their unqualified forms (T1 and T2) are either the same
10129 /// or T1 is a base class of T2.
10131 /// Ref_Compatible - The two types are reference-compatible.
10134
10135 // Fake up a scoped enumeration that still contextually converts to bool.
10137 /// The conversions that would be performed on an lvalue of type T2 when
10138 /// binding a reference of type T1 to it, as determined when evaluating
10139 /// whether T1 is reference-compatible with T2.
10141 Qualification = 0x1,
10142 NestedQualification = 0x2,
10144 DerivedToBase = 0x8,
10145 ObjC = 0x10,
10146 ObjCLifetime = 0x20,
10147
10148 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
10149 };
10150 };
10152
10153 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10154 /// determine whether they are reference-compatible,
10155 /// reference-related, or incompatible, for use in C++ initialization by
10156 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10157 /// type, and the first type (T1) is the pointee type of the reference
10158 /// type being initialized.
10161 ReferenceConversions *Conv = nullptr);
10162
10163 /// AddOverloadCandidate - Adds the given function to the set of
10164 /// candidate functions, using the given function call arguments. If
10165 /// @p SuppressUserConversions, then don't allow user-defined
10166 /// conversions via constructors or conversion operators.
10167 ///
10168 /// \param PartialOverloading true if we are performing "partial" overloading
10169 /// based on an incomplete set of function arguments. This feature is used by
10170 /// code completion.
10173 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10174 bool PartialOverloading = false, bool AllowExplicit = true,
10175 bool AllowExplicitConversion = false,
10176 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10177 ConversionSequenceList EarlyConversions = std::nullopt,
10179 bool AggregateCandidateDeduction = false);
10180
10181 /// Add all of the function declarations in the given function set to
10182 /// the overload candidate set.
10184 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10185 OverloadCandidateSet &CandidateSet,
10186 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10187 bool SuppressUserConversions = false, bool PartialOverloading = false,
10188 bool FirstArgumentIsBase = false);
10189
10190 /// AddMethodCandidate - Adds a named decl (which is some kind of
10191 /// method) as a method candidate to the given overload set.
10192 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10193 Expr::Classification ObjectClassification,
10194 ArrayRef<Expr *> Args,
10195 OverloadCandidateSet &CandidateSet,
10196 bool SuppressUserConversion = false,
10198
10199 /// AddMethodCandidate - Adds the given C++ member function to the set
10200 /// of candidate functions, using the given function call arguments
10201 /// and the object argument (@c Object). For example, in a call
10202 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10203 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10204 /// allow user-defined conversions via constructors or conversion
10205 /// operators.
10206 void
10207 AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10208 CXXRecordDecl *ActingContext, QualType ObjectType,
10209 Expr::Classification ObjectClassification,
10210 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10211 bool SuppressUserConversions = false,
10212 bool PartialOverloading = false,
10213 ConversionSequenceList EarlyConversions = std::nullopt,
10215
10216 /// Add a C++ member function template as a candidate to the candidate
10217 /// set, using template argument deduction to produce an appropriate member
10218 /// function template specialization.
10220 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10221 CXXRecordDecl *ActingContext,
10222 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10223 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10224 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10225 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10226
10227 /// Add a C++ function template specialization as a candidate
10228 /// in the candidate set, using template argument deduction to produce
10229 /// an appropriate function template specialization.
10231 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10232 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10233 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10234 bool PartialOverloading = false, bool AllowExplicit = true,
10235 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10237 bool AggregateCandidateDeduction = false);
10238
10239 /// Check that implicit conversion sequences can be formed for each argument
10240 /// whose corresponding parameter has a non-dependent type, per DR1391's
10241 /// [temp.deduct.call]p10.
10243 FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes,
10244 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10245 ConversionSequenceList &Conversions, bool SuppressUserConversions,
10246 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10247 Expr::Classification ObjectClassification = {},
10249
10250 /// AddConversionCandidate - Add a C++ conversion function as a
10251 /// candidate in the candidate set (C++ [over.match.conv],
10252 /// C++ [over.match.copy]). From is the expression we're converting from,
10253 /// and ToType is the type that we're eventually trying to convert to
10254 /// (which may or may not be the same type as the type that the
10255 /// conversion function produces).
10257 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10258 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10259 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10260 bool AllowExplicit, bool AllowResultConversion = true);
10261
10262 /// Adds a conversion function template specialization
10263 /// candidate to the overload set, using template argument deduction
10264 /// to deduce the template arguments of the conversion function
10265 /// template from the type that we are converting to (C++
10266 /// [temp.deduct.conv]).
10268 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10269 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10270 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10271 bool AllowExplicit, bool AllowResultConversion = true);
10272
10273 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10274 /// converts the given @c Object to a function pointer via the
10275 /// conversion function @c Conversion, and then attempts to call it
10276 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10277 /// the type of function that we'll eventually be calling.
10278 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10279 DeclAccessPair FoundDecl,
10280 CXXRecordDecl *ActingContext,
10281 const FunctionProtoType *Proto, Expr *Object,
10282 ArrayRef<Expr *> Args,
10283 OverloadCandidateSet &CandidateSet);
10284
10285 /// Add all of the non-member operator function declarations in the given
10286 /// function set to the overload candidate set.
10288 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10289 OverloadCandidateSet &CandidateSet,
10290 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10291
10292 /// Add overload candidates for overloaded operators that are
10293 /// member functions.
10294 ///
10295 /// Add the overloaded operator candidates that are member functions
10296 /// for the operator Op that was used in an operator expression such
10297 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10298 /// CandidateSet will store the added overload candidates. (C++
10299 /// [over.match.oper]).
10301 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10302 OverloadCandidateSet &CandidateSet,
10304
10305 /// AddBuiltinCandidate - Add a candidate for a built-in
10306 /// operator. ResultTy and ParamTys are the result and parameter types
10307 /// of the built-in candidate, respectively. Args and NumArgs are the
10308 /// arguments being passed to the candidate. IsAssignmentOperator
10309 /// should be true when this built-in candidate is an assignment
10310 /// operator. NumContextualBoolArguments is the number of arguments
10311 /// (at the beginning of the argument list) that will be contextually
10312 /// converted to bool.
10313 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10314 OverloadCandidateSet &CandidateSet,
10315 bool IsAssignmentOperator = false,
10316 unsigned NumContextualBoolArguments = 0);
10317
10318 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10319 /// operator overloads to the candidate set (C++ [over.built]), based
10320 /// on the operator @p Op and the arguments given. For example, if the
10321 /// operator is a binary '+', this routine might add "int
10322 /// operator+(int, int)" to cover integer addition.
10324 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10325 OverloadCandidateSet &CandidateSet);
10326
10327 /// Add function candidates found via argument-dependent lookup
10328 /// to the set of overloading candidates.
10329 ///
10330 /// This routine performs argument-dependent name lookup based on the
10331 /// given function name (which may also be an operator name) and adds
10332 /// all of the overload candidates found by ADL to the overload
10333 /// candidate set (C++ [basic.lookup.argdep]).
10335 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10336 TemplateArgumentListInfo *ExplicitTemplateArgs,
10337 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10338
10339 /// Check the enable_if expressions on the given function. Returns the first
10340 /// failing attribute, or NULL if they were all successful.
10341 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10342 ArrayRef<Expr *> Args,
10343 bool MissingImplicitThis = false);
10344
10345 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10346 /// non-ArgDependent DiagnoseIfAttrs.
10347 ///
10348 /// Argument-dependent diagnose_if attributes should be checked each time a
10349 /// function is used as a direct callee of a function call.
10350 ///
10351 /// Returns true if any errors were emitted.
10352 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10353 const Expr *ThisArg,
10354 ArrayRef<const Expr *> Args,
10355 SourceLocation Loc);
10356
10357 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10358 /// ArgDependent DiagnoseIfAttrs.
10359 ///
10360 /// Argument-independent diagnose_if attributes should be checked on every use
10361 /// of a function.
10362 ///
10363 /// Returns true if any errors were emitted.
10364 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10365 SourceLocation Loc);
10366
10367 /// Determine if \p A and \p B are equivalent internal linkage declarations
10368 /// from different modules, and thus an ambiguity error can be downgraded to
10369 /// an extension warning.
10370 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10371 const NamedDecl *B);
10373 SourceLocation Loc, const NamedDecl *D,
10374 ArrayRef<const NamedDecl *> Equiv);
10375
10376 // Emit as a 'note' the specific overload candidate
10378 const NamedDecl *Found, const FunctionDecl *Fn,
10380 QualType DestType = QualType(), bool TakingAddress = false);
10381
10382 // Emit as a series of 'note's all template and non-templates identified by
10383 // the expression Expr
10384 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10385 bool TakingAddress = false);
10386
10387 /// Returns whether the given function's address can be taken or not,
10388 /// optionally emitting a diagnostic if the address can't be taken.
10389 ///
10390 /// Returns false if taking the address of the function is illegal.
10391 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10392 bool Complain = false,
10393 SourceLocation Loc = SourceLocation());
10394
10395 // [PossiblyAFunctionType] --> [Return]
10396 // NonFunctionType --> NonFunctionType
10397 // R (A) --> R(A)
10398 // R (*)(A) --> R (A)
10399 // R (&)(A) --> R (A)
10400 // R (S::*)(A) --> R (A)
10401 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10402
10403 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10404 /// an overloaded function (C++ [over.over]), where @p From is an
10405 /// expression with overloaded function type and @p ToType is the type
10406 /// we're trying to resolve to. For example:
10407 ///
10408 /// @code
10409 /// int f(double);
10410 /// int f(int);
10411 ///
10412 /// int (*pfd)(double) = f; // selects f(double)
10413 /// @endcode
10414 ///
10415 /// This routine returns the resulting FunctionDecl if it could be
10416 /// resolved, and NULL otherwise. When @p Complain is true, this
10417 /// routine will emit diagnostics if there is an error.
10418 FunctionDecl *
10419 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10420 bool Complain, DeclAccessPair &Found,
10421 bool *pHadMultipleCandidates = nullptr);
10422
10423 /// Given an expression that refers to an overloaded function, try to
10424 /// resolve that function to a single function that can have its address
10425 /// taken. This will modify `Pair` iff it returns non-null.
10426 ///
10427 /// This routine can only succeed if from all of the candidates in the
10428 /// overload set for SrcExpr that can have their addresses taken, there is one
10429 /// candidate that is more constrained than the rest.
10430 FunctionDecl *
10431 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10432
10433 /// Given an overloaded function, tries to turn it into a non-overloaded
10434 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10435 /// will perform access checks, diagnose the use of the resultant decl, and,
10436 /// if requested, potentially perform a function-to-pointer decay.
10437 ///
10438 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10439 /// Otherwise, returns true. This may emit diagnostics and return true.
10441 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10442
10443 /// Given an expression that refers to an overloaded function, try to
10444 /// resolve that overloaded function expression down to a single function.
10445 ///
10446 /// This routine can only resolve template-ids that refer to a single function
10447 /// template, where that template-id refers to a single template whose
10448 /// template arguments are either provided by the template-id or have
10449 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10450 ///
10451 /// If no template-ids are found, no diagnostics are emitted and NULL is
10452 /// returned.
10454 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10455 TemplateSpecCandidateSet *FailedTSC = nullptr);
10456
10457 // Resolve and fix an overloaded expression that can be resolved
10458 // because it identifies a single function template specialization.
10459 //
10460 // Last three arguments should only be supplied if Complain = true
10461 //
10462 // Return true if it was logically possible to so resolve the
10463 // expression, regardless of whether or not it succeeded. Always
10464 // returns true if 'complain' is set.
10466 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10467 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10468 QualType DestTypeForComplaining = QualType(),
10469 unsigned DiagIDForComplaining = 0);
10470
10471 /// Add the overload candidates named by callee and/or found by argument
10472 /// dependent lookup to the given overload set.
10473 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10474 ArrayRef<Expr *> Args,
10475 OverloadCandidateSet &CandidateSet,
10476 bool PartialOverloading = false);
10477
10478 /// Add the call candidates from the given set of lookup results to the given
10479 /// overload set. Non-function lookup results are ignored.
10481 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10482 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10483
10484 // An enum used to represent the different possible results of building a
10485 // range-based for loop.
10491
10492 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10493 /// given LookupResult is non-empty, it is assumed to describe a member which
10494 /// will be invoked. Otherwise, the function will be found via argument
10495 /// dependent lookup.
10496 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10497 /// otherwise CallExpr is set to ExprError() and some non-success value
10498 /// is returned.
10500 SourceLocation RangeLoc,
10501 const DeclarationNameInfo &NameInfo,
10502 LookupResult &MemberLookup,
10503 OverloadCandidateSet *CandidateSet,
10505
10506 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10507 /// (which eventually refers to the declaration Func) and the call
10508 /// arguments Args/NumArgs, attempt to resolve the function call down
10509 /// to a specific function. If overload resolution succeeds, returns
10510 /// the call expression produced by overload resolution.
10511 /// Otherwise, emits diagnostics and returns ExprError.
10513 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10514 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10515 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10516
10517 /// Constructs and populates an OverloadedCandidateSet from
10518 /// the given function.
10519 /// \returns true when an the ExprResult output parameter has been set.
10521 MultiExprArg Args, SourceLocation RParenLoc,
10522 OverloadCandidateSet *CandidateSet,
10524
10528 const UnresolvedSetImpl &Fns,
10529 bool PerformADL = true);
10530
10531 /// Create a unary operation that may resolve to an overloaded
10532 /// operator.
10533 ///
10534 /// \param OpLoc The location of the operator itself (e.g., '*').
10535 ///
10536 /// \param Opc The UnaryOperatorKind that describes this operator.
10537 ///
10538 /// \param Fns The set of non-member functions that will be
10539 /// considered by overload resolution. The caller needs to build this
10540 /// set based on the context using, e.g.,
10541 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10542 /// set should not contain any member functions; those will be added
10543 /// by CreateOverloadedUnaryOp().
10544 ///
10545 /// \param Input The input argument.
10548 const UnresolvedSetImpl &Fns, Expr *input,
10549 bool RequiresADL = true);
10550
10551 /// Perform lookup for an overloaded binary operator.
10554 const UnresolvedSetImpl &Fns,
10555 ArrayRef<Expr *> Args, bool RequiresADL = true);
10556
10557 /// Create a binary operation that may resolve to an overloaded
10558 /// operator.
10559 ///
10560 /// \param OpLoc The location of the operator itself (e.g., '+').
10561 ///
10562 /// \param Opc The BinaryOperatorKind that describes this operator.
10563 ///
10564 /// \param Fns The set of non-member functions that will be
10565 /// considered by overload resolution. The caller needs to build this
10566 /// set based on the context using, e.g.,
10567 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10568 /// set should not contain any member functions; those will be added
10569 /// by CreateOverloadedBinOp().
10570 ///
10571 /// \param LHS Left-hand argument.
10572 /// \param RHS Right-hand argument.
10573 /// \param PerformADL Whether to consider operator candidates found by ADL.
10574 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10575 /// C++20 operator rewrites.
10576 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
10577 /// the function in question. Such a function is never a candidate in
10578 /// our overload resolution. This also enables synthesizing a three-way
10579 /// comparison from < and == as described in C++20 [class.spaceship]p1.
10581 const UnresolvedSetImpl &Fns, Expr *LHS,
10582 Expr *RHS, bool RequiresADL = true,
10583 bool AllowRewrittenCandidates = true,
10584 FunctionDecl *DefaultedFn = nullptr);
10586 const UnresolvedSetImpl &Fns,
10587 Expr *LHS, Expr *RHS,
10588 FunctionDecl *DefaultedFn);
10589
10591 SourceLocation RLoc, Expr *Base,
10592 MultiExprArg Args);
10593
10594 /// BuildCallToMemberFunction - Build a call to a member
10595 /// function. MemExpr is the expression that refers to the member
10596 /// function (and includes the object parameter), Args/NumArgs are the
10597 /// arguments to the function call (not including the object
10598 /// parameter). The caller needs to validate that the member
10599 /// expression refers to a non-static member function or an overloaded
10600 /// member function.
10602 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
10603 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
10604 bool IsExecConfig = false, bool AllowRecovery = false);
10605
10606 /// BuildCallToObjectOfClassType - Build a call to an object of class
10607 /// type (C++ [over.call.object]), which can end up invoking an
10608 /// overloaded function call operator (@c operator()) or performing a
10609 /// user-defined conversion on the object argument.
10611 SourceLocation LParenLoc,
10612 MultiExprArg Args,
10613 SourceLocation RParenLoc);
10614
10615 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
10616 /// (if one exists), where @c Base is an expression of class type and
10617 /// @c Member is the name of the member we're trying to find.
10619 SourceLocation OpLoc,
10620 bool *NoArrowOperatorFound = nullptr);
10621
10623 CXXConversionDecl *Method,
10624 bool HadMultipleCandidates);
10625
10626 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
10627 /// to a literal operator described by the provided lookup results.
10630 SourceLocation LitEndLoc,
10631 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10632
10633 /// FixOverloadedFunctionReference - E is an expression that refers to
10634 /// a C++ overloaded function (possibly with some parentheses and
10635 /// perhaps a '&' around it). We have resolved the overloaded function
10636 /// to the function declaration Fn, so patch up the expression E to
10637 /// refer (possibly indirectly) to Fn. Returns the new expr.
10639 FunctionDecl *Fn);
10641 DeclAccessPair FoundDecl,
10642 FunctionDecl *Fn);
10643
10644 /// - Returns a selector which best matches given argument list or
10645 /// nullptr if none could be found
10647 bool IsInstance,
10649
10650 ///@}
10651
10652 //
10653 //
10654 // -------------------------------------------------------------------------
10655 //
10656 //
10657
10658 /// \name Statements
10659 /// Implementations are in SemaStmt.cpp
10660 ///@{
10661
10662public:
10663 /// Stack of active SEH __finally scopes. Can be empty.
10665
10666 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
10668
10670 bool HasLeadingEmptyMacro = false);
10671
10673 SourceLocation EndLoc);
10675
10676 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
10677 /// whose result is unused, warn.
10678 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
10679
10680 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
10684 ArrayRef<Stmt *> Elts, bool isStmtExpr);
10685
10687
10690 SourceLocation DotDotDotLoc, ExprResult RHS,
10691 SourceLocation ColonLoc);
10692
10693 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
10694 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
10695
10697 SourceLocation ColonLoc, Stmt *SubStmt,
10698 Scope *CurScope);
10700 SourceLocation ColonLoc, Stmt *SubStmt);
10701
10703 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
10705 Stmt *SubStmt);
10706
10707 /// Check whether the given statement can have musttail applied to it,
10708 /// issuing a diagnostic and returning false if not. In the success case,
10709 /// the statement is rewritten to remove implicit nodes from the return
10710 /// value.
10711 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
10712
10714 SourceLocation LParenLoc, Stmt *InitStmt,
10715 ConditionResult Cond, SourceLocation RParenLoc,
10716 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10718 SourceLocation LParenLoc, Stmt *InitStmt,
10719 ConditionResult Cond, SourceLocation RParenLoc,
10720 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10721
10723
10725 SourceLocation LParenLoc, Stmt *InitStmt,
10726 ConditionResult Cond,
10727 SourceLocation RParenLoc);
10729 Stmt *Body);
10730
10731 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
10732 /// integer not in the range of enum values.
10733 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
10734 Expr *SrcExpr);
10735
10737 ConditionResult Cond, SourceLocation RParenLoc,
10738 Stmt *Body);
10740 SourceLocation WhileLoc, SourceLocation CondLParen,
10741 Expr *Cond, SourceLocation CondRParen);
10742
10744 Stmt *First, ConditionResult Second,
10745 FullExprArg Third, SourceLocation RParenLoc,
10746 Stmt *Body);
10747
10748 /// In an Objective C collection iteration statement:
10749 /// for (x in y)
10750 /// x can be an arbitrary l-value expression. Bind it up as a
10751 /// full-expression.
10753
10755 /// Initial building of a for-range statement.
10757 /// Instantiation or recovery rebuild of a for-range statement. Don't
10758 /// attempt any typo-correction.
10760 /// Determining whether a for-range statement could be built. Avoid any
10761 /// unnecessary or irreversible actions.
10764
10765 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
10766 ///
10767 /// C++11 [stmt.ranged]:
10768 /// A range-based for statement is equivalent to
10769 ///
10770 /// {
10771 /// auto && __range = range-init;
10772 /// for ( auto __begin = begin-expr,
10773 /// __end = end-expr;
10774 /// __begin != __end;
10775 /// ++__begin ) {
10776 /// for-range-declaration = *__begin;
10777 /// statement
10778 /// }
10779 /// }
10780 ///
10781 /// The body of the loop is not available yet, since it cannot be analysed
10782 /// until we have determined the type of the for-range-declaration.
10784 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
10785 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
10787 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10788
10789 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
10791 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
10792 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
10793 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
10795 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10796
10797 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
10798 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
10799 /// body cannot be performed until after the type of the range variable is
10800 /// determined.
10801 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
10802
10803 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
10804 LabelDecl *TheDecl);
10805 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
10806 SourceLocation StarLoc, Expr *DestExp);
10807 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
10808 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
10809
10812
10813 enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
10815
10816 bool isMoveEligible() const { return S != None; };
10817 bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
10818 };
10820
10821 /// Determine whether the given expression might be move-eligible or
10822 /// copy-elidable in either a (co_)return statement or throw expression,
10823 /// without considering function return type, if applicable.
10824 ///
10825 /// \param E The expression being returned from the function or block,
10826 /// being thrown, or being co_returned from a coroutine. This expression
10827 /// might be modified by the implementation.
10828 ///
10829 /// \param Mode Overrides detection of current language mode
10830 /// and uses the rules for C++23.
10831 ///
10832 /// \returns An aggregate which contains the Candidate and isMoveEligible
10833 /// and isCopyElidable methods. If Candidate is non-null, it means
10834 /// isMoveEligible() would be true under the most permissive language
10835 /// standard.
10836 NamedReturnInfo getNamedReturnInfo(
10838
10839 /// Determine whether the given NRVO candidate variable is move-eligible or
10840 /// copy-elidable, without considering function return type.
10841 ///
10842 /// \param VD The NRVO candidate variable.
10843 ///
10844 /// \returns An aggregate which contains the Candidate and isMoveEligible
10845 /// and isCopyElidable methods. If Candidate is non-null, it means
10846 /// isMoveEligible() would be true under the most permissive language
10847 /// standard.
10848 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
10849
10850 /// Updates given NamedReturnInfo's move-eligible and
10851 /// copy-elidable statuses, considering the function
10852 /// return type criteria as applicable to return statements.
10853 ///
10854 /// \param Info The NamedReturnInfo object to update.
10855 ///
10856 /// \param ReturnType This is the return type of the function.
10857 /// \returns The copy elision candidate, in case the initial return expression
10858 /// was copy elidable, or nullptr otherwise.
10859 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
10860 QualType ReturnType);
10861
10862 /// Perform the initialization of a potentially-movable value, which
10863 /// is the result of return value.
10864 ///
10865 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
10866 /// treat returned lvalues as rvalues in certain cases (to prefer move
10867 /// construction), then falls back to treating them as lvalues if that failed.
10870 const NamedReturnInfo &NRInfo, Expr *Value,
10871 bool SupressSimplerImplicitMoves = false);
10872
10874
10875 /// Deduce the return type for a function from a returned expression, per
10876 /// C++1y [dcl.spec.auto]p6.
10878 SourceLocation ReturnLoc, Expr *RetExpr,
10879 const AutoType *AT);
10880
10881 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10882 Scope *CurScope);
10883 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10884 bool AllowRecovery = false);
10885
10886 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
10887 /// for capturing scopes.
10889 NamedReturnInfo &NRInfo,
10890 bool SupressSimplerImplicitMoves);
10891
10892 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
10893 /// and creates a proper catch handler from them.
10895 Stmt *HandlerBlock);
10896
10897 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
10898 /// handlers and creates a try statement from them.
10900 ArrayRef<Stmt *> Handlers);
10901
10902 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
10903 SourceLocation TryLoc, Stmt *TryBlock,
10904 Stmt *Handler);
10906 Stmt *Block);
10911
10913 bool IsIfExists,
10914 NestedNameSpecifierLoc QualifierLoc,
10915 DeclarationNameInfo NameInfo,
10916 Stmt *Nested);
10918 bool IsIfExists, CXXScopeSpec &SS,
10919 UnqualifiedId &Name, Stmt *Nested);
10920
10922 CapturedRegionKind Kind, unsigned NumParams);
10923 typedef std::pair<StringRef, QualType> CapturedParamNameType;
10927 unsigned OpenMPCaptureLevel = 0);
10932 unsigned NumParams);
10933
10934private:
10935 /// Check whether the given statement can have musttail applied to it,
10936 /// issuing a diagnostic and returning false if not.
10937 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
10938
10939 /// Check if the given expression contains 'break' or 'continue'
10940 /// statement that produces control flow different from GCC.
10941 void CheckBreakContinueBinding(Expr *E);
10942
10943 ///@}
10944
10945 //
10946 //
10947 // -------------------------------------------------------------------------
10948 //
10949 //
10950
10951 /// \name `inline asm` Statement
10952 /// Implementations are in SemaStmtAsm.cpp
10953 ///@{
10954
10955public:
10956 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
10957 bool IsVolatile, unsigned NumOutputs,
10958 unsigned NumInputs, IdentifierInfo **Names,
10959 MultiExprArg Constraints, MultiExprArg Exprs,
10960 Expr *AsmString, MultiExprArg Clobbers,
10961 unsigned NumLabels, SourceLocation RParenLoc);
10962
10964 llvm::InlineAsmIdentifierInfo &Info);
10966 SourceLocation TemplateKWLoc,
10968 bool IsUnevaluatedContext);
10969 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
10970 SourceLocation AsmLoc);
10972 SourceLocation AsmLoc);
10974 ArrayRef<Token> AsmToks, StringRef AsmString,
10975 unsigned NumOutputs, unsigned NumInputs,
10976 ArrayRef<StringRef> Constraints,
10977 ArrayRef<StringRef> Clobbers,
10978 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
10979 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
10980 SourceLocation Location, bool AlwaysCreate);
10981
10982 ///@}
10983
10984 //
10985 //
10986 // -------------------------------------------------------------------------
10987 //
10988 //
10989
10990 /// \name Statement Attribute Handling
10991 /// Implementations are in SemaStmtAttr.cpp
10992 ///@{
10993
10994public:
10995 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
10996 const AttributeCommonInfo &A);
10997 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
10998 const AttributeCommonInfo &A);
10999
11000 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11002
11003 /// Process the attributes before creating an attributed statement. Returns
11004 /// the semantic attributes that have been processed.
11005 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11007
11011 const IdentifierInfo *AttrName,
11013
11014 ///@}
11015
11016 //
11017 //
11018 // -------------------------------------------------------------------------
11019 //
11020 //
11021
11022 /// \name C++ Templates
11023 /// Implementations are in SemaTemplate.cpp
11024 ///@{
11025
11026public:
11027 // Saves the current floating-point pragma stack and clear it in this Sema.
11029 public:
11031 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11032 S.FpPragmaStack.Stack.clear();
11033 }
11034 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11035
11036 private:
11037 Sema &S;
11039 };
11040
11042 CurFPFeatures = FPO;
11043 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11044 }
11045
11047 return llvm::ArrayRef(InventedParameterInfos.begin() +
11050 }
11051
11052 /// The number of SFINAE diagnostics that have been trapped.
11054
11057 FunctionScopes.end());
11058 }
11059
11060 typedef llvm::MapVector<const FunctionDecl *,
11061 std::unique_ptr<LateParsedTemplate>>
11064
11065 /// Determine the number of levels of enclosing template parameters. This is
11066 /// only usable while parsing. Note that this does not include dependent
11067 /// contexts in which no template parameters have yet been declared, such as
11068 /// in a terse function template or generic lambda before the first 'auto' is
11069 /// encountered.
11070 unsigned getTemplateDepth(Scope *S) const;
11071
11073 bool AllowFunctionTemplates = true,
11074 bool AllowDependent = true);
11076 bool AllowFunctionTemplates = true,
11077 bool AllowDependent = true,
11078 bool AllowNonTemplateFunctions = false);
11079 /// Try to interpret the lookup result D as a template-name.
11080 ///
11081 /// \param D A declaration found by name lookup.
11082 /// \param AllowFunctionTemplates Whether function templates should be
11083 /// considered valid results.
11084 /// \param AllowDependent Whether unresolved using declarations (that might
11085 /// name templates) should be considered valid results.
11087 bool AllowFunctionTemplates = true,
11088 bool AllowDependent = true);
11089
11091 /// Whether and why a template name is required in this lookup.
11093 public:
11094 /// Template name is required if TemplateKWLoc is valid.
11096 : TemplateKW(TemplateKWLoc) {}
11097 /// Template name is unconditionally required.
11099
11101 return TemplateKW.value_or(SourceLocation());
11102 }
11103 bool hasTemplateKeyword() const {
11104 return getTemplateKeywordLoc().isValid();
11105 }
11106 bool isRequired() const { return TemplateKW != SourceLocation(); }
11107 explicit operator bool() const { return isRequired(); }
11108
11109 private:
11110 std::optional<SourceLocation> TemplateKW;
11111 };
11112
11114 /// This is not assumed to be a template name.
11115 None,
11116 /// This is assumed to be a template name because lookup found nothing.
11118 /// This is assumed to be a template name because lookup found one or more
11119 /// functions (but no function templates).
11121 };
11122
11123 bool
11125 QualType ObjectType, bool EnteringContext,
11126 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11127 AssumedTemplateKind *ATK = nullptr,
11128 bool AllowTypoCorrection = true);
11129
11131 bool hasTemplateKeyword,
11132 const UnqualifiedId &Name,
11133 ParsedType ObjectType, bool EnteringContext,
11134 TemplateTy &Template,
11135 bool &MemberOfUnknownSpecialization,
11136 bool Disambiguation = false);
11137
11138 /// Try to resolve an undeclared template name as a type template.
11139 ///
11140 /// Sets II to the identifier corresponding to the template name, and updates
11141 /// Name to a corresponding (typo-corrected) type template name and TNK to
11142 /// the corresponding kind, if possible.
11144 TemplateNameKind &TNK,
11145 SourceLocation NameLoc,
11146 IdentifierInfo *&II);
11147
11149 SourceLocation NameLoc,
11150 bool Diagnose = true);
11151
11152 /// Determine whether a particular identifier might be the name in a C++1z
11153 /// deduction-guide declaration.
11154 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11155 SourceLocation NameLoc, CXXScopeSpec &SS,
11156 ParsedTemplateTy *Template = nullptr);
11157
11159 SourceLocation IILoc, Scope *S,
11160 const CXXScopeSpec *SS,
11161 TemplateTy &SuggestedTemplate,
11162 TemplateNameKind &SuggestedKind);
11163
11164 /// Determine whether we would be unable to instantiate this template (because
11165 /// it either has no definition, or is in the process of being instantiated).
11166 bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
11167 NamedDecl *Instantiation,
11168 bool InstantiatedFromMember,
11169 const NamedDecl *Pattern,
11170 const NamedDecl *PatternDef,
11172 bool Complain = true);
11173
11174 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11175 /// that the template parameter 'PrevDecl' is being shadowed by a new
11176 /// declaration at location Loc. Returns true to indicate that this is
11177 /// an error, and false otherwise.
11178 ///
11179 /// \param Loc The location of the declaration that shadows a template
11180 /// parameter.
11181 ///
11182 /// \param PrevDecl The template parameter that the declaration shadows.
11183 ///
11184 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11185 /// a warning for compatibility with older versions of clang.
11186 /// Ignored when MSVC compatibility is enabled.
11188 bool SupportedForCompatibility = false);
11189
11190 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11191 /// the parameter D to reference the templated declaration and return a
11192 /// pointer to the template declaration. Otherwise, do nothing to D and return
11193 /// null.
11195
11196 /// ActOnTypeParameter - Called when a C++ template type parameter
11197 /// (e.g., "typename T") has been parsed. Typename specifies whether
11198 /// the keyword "typename" was used to declare the type parameter
11199 /// (otherwise, "class" was used), and KeyLoc is the location of the
11200 /// "class" or "typename" keyword. ParamName is the name of the
11201 /// parameter (NULL indicates an unnamed template parameter) and
11202 /// ParamNameLoc is the location of the parameter name (if any).
11203 /// If the type parameter has a default argument, it will be added
11204 /// later via ActOnTypeParameterDefault.
11206 SourceLocation EllipsisLoc,
11207 SourceLocation KeyLoc,
11208 IdentifierInfo *ParamName,
11209 SourceLocation ParamNameLoc, unsigned Depth,
11210 unsigned Position, SourceLocation EqualLoc,
11211 ParsedType DefaultArg, bool HasTypeConstraint);
11212
11214
11215 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11217 TemplateTypeParmDecl *ConstrainedParameter,
11218 SourceLocation EllipsisLoc);
11219 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11221 TemplateTypeParmDecl *ConstrainedParameter,
11222 SourceLocation EllipsisLoc,
11223 bool AllowUnexpandedPack);
11224
11225 /// Attach a type-constraint to a template parameter.
11226 /// \returns true if an error occurred. This can happen if the
11227 /// immediately-declared constraint could not be formed (e.g. incorrect number
11228 /// of arguments for the named concept).
11230 DeclarationNameInfo NameInfo,
11231 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
11232 const TemplateArgumentListInfo *TemplateArgs,
11233 TemplateTypeParmDecl *ConstrainedParameter,
11234 SourceLocation EllipsisLoc);
11235
11237 NonTypeTemplateParmDecl *NewConstrainedParm,
11238 NonTypeTemplateParmDecl *OrigConstrainedParm,
11239 SourceLocation EllipsisLoc);
11240
11241 /// Require the given type to be a structural type, and diagnose if it is not.
11242 ///
11243 /// \return \c true if an error was produced.
11245
11246 /// Check that the type of a non-type template parameter is
11247 /// well-formed.
11248 ///
11249 /// \returns the (possibly-promoted) parameter type if valid;
11250 /// otherwise, produces a diagnostic and returns a NULL type.
11254
11256 unsigned Depth, unsigned Position,
11257 SourceLocation EqualLoc,
11258 Expr *DefaultArg);
11259
11260 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11261 /// parameter (e.g. T in template <template <typename> class T> class array)
11262 /// has been parsed. S is the current scope.
11264 Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params,
11265 bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11266 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11267 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11268
11269 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11270 /// constrained by RequiresClause, that contains the template parameters in
11271 /// Params.
11273 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11274 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11275 SourceLocation RAngleLoc, Expr *RequiresClause);
11276
11277 /// The context in which we are checking a template parameter list.
11288
11289 /// Checks the validity of a template parameter list, possibly
11290 /// considering the template parameter list from a previous
11291 /// declaration.
11292 ///
11293 /// If an "old" template parameter list is provided, it must be
11294 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11295 /// template parameter list.
11296 ///
11297 /// \param NewParams Template parameter list for a new template
11298 /// declaration. This template parameter list will be updated with any
11299 /// default arguments that are carried through from the previous
11300 /// template parameter list.
11301 ///
11302 /// \param OldParams If provided, template parameter list from a
11303 /// previous declaration of the same template. Default template
11304 /// arguments will be merged from the old template parameter list to
11305 /// the new template parameter list.
11306 ///
11307 /// \param TPC Describes the context in which we are checking the given
11308 /// template parameter list.
11309 ///
11310 /// \param SkipBody If we might have already made a prior merged definition
11311 /// of this template visible, the corresponding body-skipping information.
11312 /// Default argument redefinition is not an error when skipping such a body,
11313 /// because (under the ODR) we can assume the default arguments are the same
11314 /// as the prior merged definition.
11315 ///
11316 /// \returns true if an error occurred, false otherwise.
11318 TemplateParameterList *OldParams,
11320 SkipBodyInfo *SkipBody = nullptr);
11321
11322 /// Match the given template parameter lists to the given scope
11323 /// specifier, returning the template parameter list that applies to the
11324 /// name.
11325 ///
11326 /// \param DeclStartLoc the start of the declaration that has a scope
11327 /// specifier or a template parameter list.
11328 ///
11329 /// \param DeclLoc The location of the declaration itself.
11330 ///
11331 /// \param SS the scope specifier that will be matched to the given template
11332 /// parameter lists. This scope specifier precedes a qualified name that is
11333 /// being declared.
11334 ///
11335 /// \param TemplateId The template-id following the scope specifier, if there
11336 /// is one. Used to check for a missing 'template<>'.
11337 ///
11338 /// \param ParamLists the template parameter lists, from the outermost to the
11339 /// innermost template parameter lists.
11340 ///
11341 /// \param IsFriend Whether to apply the slightly different rules for
11342 /// matching template parameters to scope specifiers in friend
11343 /// declarations.
11344 ///
11345 /// \param IsMemberSpecialization will be set true if the scope specifier
11346 /// denotes a fully-specialized type, and therefore this is a declaration of
11347 /// a member specialization.
11348 ///
11349 /// \returns the template parameter list, if any, that corresponds to the
11350 /// name that is preceded by the scope specifier @p SS. This template
11351 /// parameter list may have template parameters (if we're declaring a
11352 /// template) or may have no template parameters (if we're declaring a
11353 /// template specialization), or may be NULL (if what we're declaring isn't
11354 /// itself a template).
11356 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11357 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11358 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11359 bool &IsMemberSpecialization, bool &Invalid,
11360 bool SuppressDiagnostic = false);
11361
11362 /// Returns the template parameter list with all default template argument
11363 /// information.
11365
11367 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11368 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11369 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11370 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11371 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11372 TemplateParameterList **OuterTemplateParamLists,
11373 SkipBodyInfo *SkipBody = nullptr);
11374
11375 /// Translates template arguments as provided by the parser
11376 /// into template arguments used by semantic analysis.
11379
11380 /// Convert a parsed type into a parsed template argument. This is mostly
11381 /// trivial, except that we may have parsed a C++17 deduced class template
11382 /// specialization type, in which case we should form a template template
11383 /// argument instead of a type template argument.
11385
11387
11389 SourceLocation TemplateLoc,
11390 TemplateArgumentListInfo &TemplateArgs);
11391
11394 TemplateTy Template, const IdentifierInfo *TemplateII,
11395 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11396 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11397 bool IsCtorOrDtorName = false, bool IsClassName = false,
11398 ImplicitTypenameContext AllowImplicitTypename =
11400
11401 /// Parsed an elaborated-type-specifier that refers to a template-id,
11402 /// such as \c class T::template apply<U>.
11404 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11405 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11406 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11407 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11408
11411 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11413
11414 /// Get the specialization of the given variable template corresponding to
11415 /// the specified argument list, or a null-but-valid result if the arguments
11416 /// are dependent.
11418 SourceLocation TemplateLoc,
11419 SourceLocation TemplateNameLoc,
11420 const TemplateArgumentListInfo &TemplateArgs);
11421
11422 /// Form a reference to the specialization of the given variable template
11423 /// corresponding to the specified argument list, or a null-but-valid result
11424 /// if the arguments are dependent.
11426 const DeclarationNameInfo &NameInfo,
11427 VarTemplateDecl *Template, NamedDecl *FoundD,
11428 SourceLocation TemplateLoc,
11429 const TemplateArgumentListInfo *TemplateArgs);
11430
11432 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11433 const DeclarationNameInfo &ConceptNameInfo,
11434 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
11435 const TemplateArgumentListInfo *TemplateArgs);
11436
11439 bool TemplateKeyword, TemplateDecl *TD,
11441
11443 SourceLocation TemplateKWLoc, LookupResult &R,
11444 bool RequiresADL,
11445 const TemplateArgumentListInfo *TemplateArgs);
11446
11447 // We actually only call this from template instantiation.
11450 const DeclarationNameInfo &NameInfo,
11451 const TemplateArgumentListInfo *TemplateArgs,
11452 bool IsAddressOfOperand);
11453
11454 /// Form a template name from a name that is syntactically required to name a
11455 /// template, either due to use of the 'template' keyword or because a name in
11456 /// this syntactic context is assumed to name a template (C++
11457 /// [temp.names]p2-4).
11458 ///
11459 /// This action forms a template name given the name of the template and its
11460 /// optional scope specifier. This is used when the 'template' keyword is used
11461 /// or when the parsing context unambiguously treats a following '<' as
11462 /// introducing a template argument list. Note that this may produce a
11463 /// non-dependent template name if we can perform the lookup now and identify
11464 /// the named template.
11465 ///
11466 /// For example, given "x.MetaFun::template apply", the scope specifier
11467 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11468 /// of the "template" keyword, and "apply" is the \p Name.
11470 SourceLocation TemplateKWLoc,
11471 const UnqualifiedId &Name,
11472 ParsedType ObjectType,
11473 bool EnteringContext, TemplateTy &Template,
11474 bool AllowInjectedClassName = false);
11475
11477 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11478 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11480 MultiTemplateParamsArg TemplateParameterLists,
11481 SkipBodyInfo *SkipBody = nullptr);
11482
11483 /// Check the non-type template arguments of a class template
11484 /// partial specialization according to C++ [temp.class.spec]p9.
11485 ///
11486 /// \param TemplateNameLoc the location of the template name.
11487 /// \param PrimaryTemplate the template parameters of the primary class
11488 /// template.
11489 /// \param NumExplicit the number of explicitly-specified template arguments.
11490 /// \param TemplateArgs the template arguments of the class template
11491 /// partial specialization.
11492 ///
11493 /// \returns \c true if there was an error, \c false otherwise.
11495 TemplateDecl *PrimaryTemplate,
11496 unsigned NumExplicitArgs,
11502
11504 MultiTemplateParamsArg TemplateParameterLists,
11505 Declarator &D);
11506
11507 /// Diagnose cases where we have an explicit template specialization
11508 /// before/after an explicit template instantiation, producing diagnostics
11509 /// for those cases where they are required and determining whether the
11510 /// new specialization/instantiation will have any effect.
11511 ///
11512 /// \param NewLoc the location of the new explicit specialization or
11513 /// instantiation.
11514 ///
11515 /// \param NewTSK the kind of the new explicit specialization or
11516 /// instantiation.
11517 ///
11518 /// \param PrevDecl the previous declaration of the entity.
11519 ///
11520 /// \param PrevTSK the kind of the old explicit specialization or
11521 /// instantiatin.
11522 ///
11523 /// \param PrevPointOfInstantiation if valid, indicates where the previous
11524 /// declaration was instantiated (either implicitly or explicitly).
11525 ///
11526 /// \param HasNoEffect will be set to true to indicate that the new
11527 /// specialization or instantiation has no effect and should be ignored.
11528 ///
11529 /// \returns true if there was an error that should prevent the introduction
11530 /// of the new declaration into the AST, false otherwise.
11532 SourceLocation NewLoc,
11533 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
11534 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
11535 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
11536
11537 /// Perform semantic analysis for the given dependent function
11538 /// template specialization.
11539 ///
11540 /// The only possible way to get a dependent function template specialization
11541 /// is with a friend declaration, like so:
11542 ///
11543 /// \code
11544 /// template <class T> void foo(T);
11545 /// template <class T> class A {
11546 /// friend void foo<>(T);
11547 /// };
11548 /// \endcode
11549 ///
11550 /// There really isn't any useful analysis we can do here, so we
11551 /// just store the information.
11553 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
11555
11556 /// Perform semantic analysis for the given function template
11557 /// specialization.
11558 ///
11559 /// This routine performs all of the semantic analysis required for an
11560 /// explicit function template specialization. On successful completion,
11561 /// the function declaration \p FD will become a function template
11562 /// specialization.
11563 ///
11564 /// \param FD the function declaration, which will be updated to become a
11565 /// function template specialization.
11566 ///
11567 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
11568 /// if any. Note that this may be valid info even when 0 arguments are
11569 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
11570 /// as it anyway contains info on the angle brackets locations.
11571 ///
11572 /// \param Previous the set of declarations that may be specialized by
11573 /// this function specialization.
11574 ///
11575 /// \param QualifiedFriend whether this is a lookup for a qualified friend
11576 /// declaration with no explicit template argument list that might be
11577 /// befriending a function template specialization.
11579 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
11580 LookupResult &Previous, bool QualifiedFriend = false);
11581
11582 /// Perform semantic analysis for the given non-template member
11583 /// specialization.
11584 ///
11585 /// This routine performs all of the semantic analysis required for an
11586 /// explicit member function specialization. On successful completion,
11587 /// the function declaration \p FD will become a member function
11588 /// specialization.
11589 ///
11590 /// \param Member the member declaration, which will be updated to become a
11591 /// specialization.
11592 ///
11593 /// \param Previous the set of declarations, one of which may be specialized
11594 /// by this function specialization; the set will be modified to contain the
11595 /// redeclared member.
11598
11599 // Explicit instantiation of a class template specialization
11601 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
11602 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
11603 TemplateTy Template, SourceLocation TemplateNameLoc,
11604 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
11605 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
11606
11607 // Explicit instantiation of a member class of a class template.
11609 SourceLocation TemplateLoc,
11610 unsigned TagSpec, SourceLocation KWLoc,
11611 CXXScopeSpec &SS, IdentifierInfo *Name,
11612 SourceLocation NameLoc,
11613 const ParsedAttributesView &Attr);
11614
11616 SourceLocation TemplateLoc,
11617 Declarator &D);
11618
11619 /// If the given template parameter has a default template
11620 /// argument, substitute into that default template argument and
11621 /// return the corresponding template argument.
11623 TemplateDecl *Template, SourceLocation TemplateLoc,
11624 SourceLocation RAngleLoc, Decl *Param,
11625 ArrayRef<TemplateArgument> SugaredConverted,
11626 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
11627
11628 /// Returns the top most location responsible for the definition of \p N.
11629 /// If \p N is a a template specialization, this is the location
11630 /// of the top of the instantiation stack.
11631 /// Otherwise, the location of \p N is returned.
11633
11634 /// Specifies the context in which a particular template
11635 /// argument is being checked.
11637 /// The template argument was specified in the code or was
11638 /// instantiated with some deduced template arguments.
11640
11641 /// The template argument was deduced via template argument
11642 /// deduction.
11644
11645 /// The template argument was deduced from an array bound
11646 /// via template argument deduction.
11649
11650 /// Check that the given template argument corresponds to the given
11651 /// template parameter.
11652 ///
11653 /// \param Param The template parameter against which the argument will be
11654 /// checked.
11655 ///
11656 /// \param Arg The template argument, which may be updated due to conversions.
11657 ///
11658 /// \param Template The template in which the template argument resides.
11659 ///
11660 /// \param TemplateLoc The location of the template name for the template
11661 /// whose argument list we're matching.
11662 ///
11663 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
11664 /// the template argument list.
11665 ///
11666 /// \param ArgumentPackIndex The index into the argument pack where this
11667 /// argument will be placed. Only valid if the parameter is a parameter pack.
11668 ///
11669 /// \param Converted The checked, converted argument will be added to the
11670 /// end of this small vector.
11671 ///
11672 /// \param CTAK Describes how we arrived at this particular template argument:
11673 /// explicitly written, deduced, etc.
11674 ///
11675 /// \returns true on error, false otherwise.
11676 bool
11678 NamedDecl *Template, SourceLocation TemplateLoc,
11679 SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
11680 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11681 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11683
11684 /// Check that the given template arguments can be provided to
11685 /// the given template, converting the arguments along the way.
11686 ///
11687 /// \param Template The template to which the template arguments are being
11688 /// provided.
11689 ///
11690 /// \param TemplateLoc The location of the template name in the source.
11691 ///
11692 /// \param TemplateArgs The list of template arguments. If the template is
11693 /// a template template parameter, this function may extend the set of
11694 /// template arguments to also include substituted, defaulted template
11695 /// arguments.
11696 ///
11697 /// \param PartialTemplateArgs True if the list of template arguments is
11698 /// intentionally partial, e.g., because we're checking just the initial
11699 /// set of template arguments.
11700 ///
11701 /// \param Converted Will receive the converted, canonicalized template
11702 /// arguments.
11703 ///
11704 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
11705 /// contain the converted forms of the template arguments as written.
11706 /// Otherwise, \p TemplateArgs will not be modified.
11707 ///
11708 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
11709 /// receive true if the cause for the error is the associated constraints of
11710 /// the template not being satisfied by the template arguments.
11711 ///
11712 /// \param PartialOrderingTTP If true, assume these template arguments are
11713 /// the injected template arguments for a template template parameter.
11714 /// This will relax the requirement that all its possible uses are valid:
11715 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11716 /// during instantiation.
11717 ///
11718 /// \returns true if an error occurred, false otherwise.
11720 TemplateDecl *Template, SourceLocation TemplateLoc,
11721 TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs,
11722 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11723 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11724 bool UpdateArgsWithConversions = true,
11725 bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false);
11726
11729 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11730 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
11731
11732 /// Check a template argument against its corresponding
11733 /// template type parameter.
11734 ///
11735 /// This routine implements the semantics of C++ [temp.arg.type]. It
11736 /// returns true if an error occurred, and false otherwise.
11738
11739 /// Check a template argument against its corresponding
11740 /// non-type template parameter.
11741 ///
11742 /// This routine implements the semantics of C++ [temp.arg.nontype].
11743 /// If an error occurred, it returns ExprError(); otherwise, it
11744 /// returns the converted template argument. \p ParamType is the
11745 /// type of the non-type template parameter after it has been instantiated.
11747 QualType InstantiatedParamType, Expr *Arg,
11748 TemplateArgument &SugaredConverted,
11749 TemplateArgument &CanonicalConverted,
11751
11752 /// Check a template argument against its corresponding
11753 /// template template parameter.
11754 ///
11755 /// This routine implements the semantics of C++ [temp.arg.template].
11756 /// It returns true if an error occurred, and false otherwise.
11758 TemplateParameterList *Params,
11759 TemplateArgumentLoc &Arg, bool IsDeduced);
11760
11762 std::optional<SourceRange> ParamRange = {});
11763 void NoteTemplateParameterLocation(const NamedDecl &Decl);
11764
11765 /// Given a non-type template argument that refers to a
11766 /// declaration and the type of its corresponding non-type template
11767 /// parameter, produce an expression that properly refers to that
11768 /// declaration.
11770 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
11771 NamedDecl *TemplateParam = nullptr);
11773 BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg,
11774 SourceLocation Loc);
11775
11776 /// Enumeration describing how template parameter lists are compared
11777 /// for equality.
11779 /// We are matching the template parameter lists of two templates
11780 /// that might be redeclarations.
11781 ///
11782 /// \code
11783 /// template<typename T> struct X;
11784 /// template<typename T> struct X;
11785 /// \endcode
11787
11788 /// We are matching the template parameter lists of two template
11789 /// template parameters as part of matching the template parameter lists
11790 /// of two templates that might be redeclarations.
11791 ///
11792 /// \code
11793 /// template<template<int I> class TT> struct X;
11794 /// template<template<int Value> class Other> struct X;
11795 /// \endcode
11797
11798 /// We are matching the template parameter lists of a template
11799 /// template argument against the template parameter lists of a template
11800 /// template parameter.
11801 ///
11802 /// \code
11803 /// template<template<int Value> class Metafun> struct X;
11804 /// template<int Value> struct integer_c;
11805 /// X<integer_c> xic;
11806 /// \endcode
11808
11809 /// We are determining whether the template-parameters are equivalent
11810 /// according to C++ [temp.over.link]/6. This comparison does not consider
11811 /// constraints.
11812 ///
11813 /// \code
11814 /// template<C1 T> void f(T);
11815 /// template<C2 T> void f(T);
11816 /// \endcode
11818 };
11819
11820 // A struct to represent the 'new' declaration, which is either itself just
11821 // the named decl, or the important information we need about it in order to
11822 // do constraint comparisons.
11824 const NamedDecl *ND = nullptr;
11825 const DeclContext *DC = nullptr;
11826 const DeclContext *LexicalDC = nullptr;
11828
11829 public:
11832 const DeclContext *LexicalDeclCtx,
11834
11835 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
11836 assert(DC && LexicalDC &&
11837 "Constructor only for cases where we have the information to put "
11838 "in here");
11839 }
11840
11841 // If this was constructed with no information, we cannot do substitution
11842 // for constraint comparison, so make sure we can check that.
11843 bool isInvalid() const { return !ND && !DC; }
11844
11845 const NamedDecl *getDecl() const { return ND; }
11846
11847 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
11848
11850 return ND ? ND->getLexicalDeclContext() : LexicalDC;
11851 }
11852
11854 return ND ? ND->getDeclContext() : DC;
11855 }
11856
11857 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
11858 };
11859
11860 /// Determine whether the given template parameter lists are
11861 /// equivalent.
11862 ///
11863 /// \param New The new template parameter list, typically written in the
11864 /// source code as part of a new template declaration.
11865 ///
11866 /// \param Old The old template parameter list, typically found via
11867 /// name lookup of the template declared with this template parameter
11868 /// list.
11869 ///
11870 /// \param Complain If true, this routine will produce a diagnostic if
11871 /// the template parameter lists are not equivalent.
11872 ///
11873 /// \param Kind describes how we are to match the template parameter lists.
11874 ///
11875 /// \param TemplateArgLoc If this source location is valid, then we
11876 /// are actually checking the template parameter list of a template
11877 /// argument (New) against the template parameter list of its
11878 /// corresponding template template parameter (Old). We produce
11879 /// slightly different diagnostics in this scenario.
11880 ///
11881 /// \returns True if the template parameter lists are equal, false
11882 /// otherwise.
11884 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
11885 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
11887 SourceLocation TemplateArgLoc = SourceLocation());
11888
11890 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
11892 SourceLocation TemplateArgLoc = SourceLocation()) {
11893 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
11894 Kind, TemplateArgLoc);
11895 }
11896
11897 /// Check whether a template can be declared within this scope.
11898 ///
11899 /// If the template declaration is valid in this scope, returns
11900 /// false. Otherwise, issues a diagnostic and returns true.
11901 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
11902
11903 /// Called when the parser has parsed a C++ typename
11904 /// specifier, e.g., "typename T::type".
11905 ///
11906 /// \param S The scope in which this typename type occurs.
11907 /// \param TypenameLoc the location of the 'typename' keyword
11908 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11909 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
11910 /// \param IdLoc the location of the identifier.
11911 /// \param IsImplicitTypename context where T::type refers to a type.
11913 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
11914 const IdentifierInfo &II, SourceLocation IdLoc,
11916
11917 /// Called when the parser has parsed a C++ typename
11918 /// specifier that ends in a template-id, e.g.,
11919 /// "typename MetaFun::template apply<T1, T2>".
11920 ///
11921 /// \param S The scope in which this typename type occurs.
11922 /// \param TypenameLoc the location of the 'typename' keyword
11923 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11924 /// \param TemplateLoc the location of the 'template' keyword, if any.
11925 /// \param TemplateName The template name.
11926 /// \param TemplateII The identifier used to name the template.
11927 /// \param TemplateIILoc The location of the template name.
11928 /// \param LAngleLoc The location of the opening angle bracket ('<').
11929 /// \param TemplateArgs The template arguments.
11930 /// \param RAngleLoc The location of the closing angle bracket ('>').
11932 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
11933 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
11934 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
11935 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11936 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
11937
11939 SourceLocation KeywordLoc,
11940 NestedNameSpecifierLoc QualifierLoc,
11941 const IdentifierInfo &II, SourceLocation IILoc,
11942 TypeSourceInfo **TSI, bool DeducedTSTContext);
11943
11945 SourceLocation KeywordLoc,
11946 NestedNameSpecifierLoc QualifierLoc,
11947 const IdentifierInfo &II, SourceLocation IILoc,
11948 bool DeducedTSTContext = true);
11949
11950 /// Rebuilds a type within the context of the current instantiation.
11951 ///
11952 /// The type \p T is part of the type of an out-of-line member definition of
11953 /// a class template (or class template partial specialization) that was
11954 /// parsed and constructed before we entered the scope of the class template
11955 /// (or partial specialization thereof). This routine will rebuild that type
11956 /// now that we have entered the declarator's scope, which may produce
11957 /// different canonical types, e.g.,
11958 ///
11959 /// \code
11960 /// template<typename T>
11961 /// struct X {
11962 /// typedef T* pointer;
11963 /// pointer data();
11964 /// };
11965 ///
11966 /// template<typename T>
11967 /// typename X<T>::pointer X<T>::data() { ... }
11968 /// \endcode
11969 ///
11970 /// Here, the type "typename X<T>::pointer" will be created as a
11971 /// DependentNameType, since we do not know that we can look into X<T> when we
11972 /// parsed the type. This function will rebuild the type, performing the
11973 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
11974 /// canonical type is the same as the canonical type of T*, allowing the
11975 /// return types of the out-of-line definition and the declaration to match.
11978 DeclarationName Name);
11980
11982
11983 /// Rebuild the template parameters now that we know we're in a current
11984 /// instantiation.
11985 bool
11987
11988 /// Produces a formatted string that describes the binding of
11989 /// template parameters to template arguments.
11990 std::string
11992 const TemplateArgumentList &Args);
11993
11994 std::string
11996 const TemplateArgument *Args,
11997 unsigned NumArgs);
11998
12002
12003 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12004 /// was just parsed. This is only possible with an explicit scope
12005 /// specifier naming a dependent type.
12007 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12008 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12009 const TemplateArgumentListInfo *TemplateArgs);
12010
12013 SourceLocation TemplateKWLoc,
12014 const DeclarationNameInfo &NameInfo,
12015 const TemplateArgumentListInfo *TemplateArgs);
12016
12017 // Calculates whether the expression Constraint depends on an enclosing
12018 // template, for the purposes of [temp.friend] p9.
12019 // TemplateDepth is the 'depth' of the friend function, which is used to
12020 // compare whether a declaration reference is referring to a containing
12021 // template, or just the current friend function. A 'lower' TemplateDepth in
12022 // the AST refers to a 'containing' template. As the constraint is
12023 // uninstantiated, this is relative to the 'top' of the TU.
12024 bool
12026 unsigned TemplateDepth,
12027 const Expr *Constraint);
12028
12029 /// Find the failed Boolean condition within a given Boolean
12030 /// constant expression, and describe it with a string.
12031 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12032
12034
12036 MultiTemplateParamsArg TemplateParameterLists,
12037 const IdentifierInfo *Name,
12038 SourceLocation NameLoc, Expr *ConstraintExpr,
12039 const ParsedAttributesView &Attrs);
12040
12042 bool &AddToScope);
12043
12044 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12045 const CXXScopeSpec &SS,
12046 const IdentifierInfo *Name,
12047 SourceLocation TagLoc, SourceLocation NameLoc);
12048
12050 CachedTokens &Toks);
12053
12054 /// We've found a use of a templated declaration that would trigger an
12055 /// implicit instantiation. Check that any relevant explicit specializations
12056 /// and partial specializations are visible/reachable, and diagnose if not.
12059
12060 ///@}
12061
12062 //
12063 //
12064 // -------------------------------------------------------------------------
12065 //
12066 //
12067
12068 /// \name C++ Template Argument Deduction
12069 /// Implementations are in SemaTemplateDeduction.cpp
12070 ///@{
12071
12072public:
12073 /// When true, access checking violations are treated as SFINAE
12074 /// failures rather than hard errors.
12076
12077 /// RAII class used to determine whether SFINAE has
12078 /// trapped any errors that occur during template argument
12079 /// deduction.
12081 Sema &SemaRef;
12082 unsigned PrevSFINAEErrors;
12083 bool PrevInNonInstantiationSFINAEContext;
12084 bool PrevAccessCheckingSFINAE;
12085 bool PrevLastDiagnosticIgnored;
12086
12087 public:
12088 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
12089 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
12090 PrevInNonInstantiationSFINAEContext(
12091 SemaRef.InNonInstantiationSFINAEContext),
12092 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
12093 PrevLastDiagnosticIgnored(
12094 SemaRef.getDiagnostics().isLastDiagnosticIgnored()) {
12095 if (!SemaRef.isSFINAEContext())
12096 SemaRef.InNonInstantiationSFINAEContext = true;
12097 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
12098 }
12099
12101 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
12103 PrevInNonInstantiationSFINAEContext;
12104 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
12106 PrevLastDiagnosticIgnored);
12107 }
12108
12109 /// Determine whether any SFINAE errors have been trapped.
12110 bool hasErrorOccurred() const {
12111 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
12112 }
12113 };
12114
12115 /// RAII class used to indicate that we are performing provisional
12116 /// semantic analysis to determine the validity of a construct, so
12117 /// typo-correction and diagnostics in the immediate context (not within
12118 /// implicitly-instantiated templates) should be suppressed.
12120 Sema &SemaRef;
12121 // FIXME: Using a SFINAETrap for this is a hack.
12122 SFINAETrap Trap;
12123 bool PrevDisableTypoCorrection;
12124
12125 public:
12126 explicit TentativeAnalysisScope(Sema &SemaRef)
12127 : SemaRef(SemaRef), Trap(SemaRef, true),
12128 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12129 SemaRef.DisableTypoCorrection = true;
12130 }
12132 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12133 }
12134 };
12135
12136 /// For each declaration that involved template argument deduction, the
12137 /// set of diagnostics that were suppressed during that template argument
12138 /// deduction.
12139 ///
12140 /// FIXME: Serialize this structure to the AST file.
12141 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12144
12145 /// Compare types for equality with respect to possibly compatible
12146 /// function types (noreturn adjustment, implicit calling conventions). If any
12147 /// of parameter and argument is not a function, just perform type comparison.
12148 ///
12149 /// \param P the template parameter type.
12150 ///
12151 /// \param A the argument type.
12153
12154 /// Allocate a TemplateArgumentLoc where all locations have
12155 /// been initialized to the given location.
12156 ///
12157 /// \param Arg The template argument we are producing template argument
12158 /// location information for.
12159 ///
12160 /// \param NTTPType For a declaration template argument, the type of
12161 /// the non-type template parameter that corresponds to this template
12162 /// argument. Can be null if no type sugar is available to add to the
12163 /// type from the template argument.
12164 ///
12165 /// \param Loc The source location to use for the resulting template
12166 /// argument.
12170 NamedDecl *TemplateParam = nullptr);
12171
12172 /// Get a template argument mapping the given template parameter to itself,
12173 /// e.g. for X in \c template<int X>, this would return an expression template
12174 /// argument referencing X.
12176 SourceLocation Location);
12177
12178 /// Adjust the type \p ArgFunctionType to match the calling convention,
12179 /// noreturn, and optionally the exception specification of \p FunctionType.
12180 /// Deduction often wants to ignore these properties when matching function
12181 /// types.
12183 bool AdjustExceptionSpec = false);
12184
12187 ArrayRef<TemplateArgument> TemplateArgs,
12189
12192 ArrayRef<TemplateArgument> TemplateArgs,
12194
12195 /// Deduce the template arguments of the given template from \p FromType.
12196 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12197 /// [over.match.class.deduct]p4.
12198 ///
12199 /// It only supports class or type alias templates.
12203
12208 bool NumberOfArgumentsMustMatch);
12209
12210 /// Substitute the explicitly-provided template arguments into the
12211 /// given function template according to C++ [temp.arg.explicit].
12212 ///
12213 /// \param FunctionTemplate the function template into which the explicit
12214 /// template arguments will be substituted.
12215 ///
12216 /// \param ExplicitTemplateArgs the explicitly-specified template
12217 /// arguments.
12218 ///
12219 /// \param Deduced the deduced template arguments, which will be populated
12220 /// with the converted and checked explicit template arguments.
12221 ///
12222 /// \param ParamTypes will be populated with the instantiated function
12223 /// parameters.
12224 ///
12225 /// \param FunctionType if non-NULL, the result type of the function template
12226 /// will also be instantiated and the pointed-to value will be updated with
12227 /// the instantiated function type.
12228 ///
12229 /// \param Info if substitution fails for any reason, this object will be
12230 /// populated with more information about the failure.
12231 ///
12232 /// \returns TemplateDeductionResult::Success if substitution was successful,
12233 /// or some failure condition.
12236 TemplateArgumentListInfo &ExplicitTemplateArgs,
12240
12241 /// brief A function argument from which we performed template argument
12242 // deduction for a call.
12244 OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
12245 unsigned ArgIdx, QualType OriginalArgType)
12246 : OriginalParamType(OriginalParamType),
12247 DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
12248 OriginalArgType(OriginalArgType) {}
12249
12252 unsigned ArgIdx;
12254 };
12255
12256 /// Finish template argument deduction for a function template,
12257 /// checking the deduced template arguments for completeness and forming
12258 /// the function template specialization.
12259 ///
12260 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12261 /// which the deduced argument types should be compared.
12265 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12267 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
12268 bool PartialOverloading = false,
12269 llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
12270
12271 /// Perform template argument deduction from a function call
12272 /// (C++ [temp.deduct.call]).
12273 ///
12274 /// \param FunctionTemplate the function template for which we are performing
12275 /// template argument deduction.
12276 ///
12277 /// \param ExplicitTemplateArgs the explicit template arguments provided
12278 /// for this call.
12279 ///
12280 /// \param Args the function call arguments
12281 ///
12282 /// \param Specialization if template argument deduction was successful,
12283 /// this will be set to the function template specialization produced by
12284 /// template argument deduction.
12285 ///
12286 /// \param Info the argument will be updated to provide additional information
12287 /// about template argument deduction.
12288 ///
12289 /// \param CheckNonDependent A callback to invoke to check conversions for
12290 /// non-dependent parameters, between deduction and substitution, per DR1391.
12291 /// If this returns true, substitution will be skipped and we return
12292 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12293 /// passed the parameter types (after substituting explicit template
12294 /// arguments).
12295 ///
12296 /// \returns the result of template argument deduction.
12299 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12301 bool PartialOverloading, bool AggregateDeductionCandidate,
12302 QualType ObjectType, Expr::Classification ObjectClassification,
12303 llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
12304
12305 /// Deduce template arguments when taking the address of a function
12306 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12307 /// a template.
12308 ///
12309 /// \param FunctionTemplate the function template for which we are performing
12310 /// template argument deduction.
12311 ///
12312 /// \param ExplicitTemplateArgs the explicitly-specified template
12313 /// arguments.
12314 ///
12315 /// \param ArgFunctionType the function type that will be used as the
12316 /// "argument" type (A) when performing template argument deduction from the
12317 /// function template's function type. This type may be NULL, if there is no
12318 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12319 ///
12320 /// \param Specialization if template argument deduction was successful,
12321 /// this will be set to the function template specialization produced by
12322 /// template argument deduction.
12323 ///
12324 /// \param Info the argument will be updated to provide additional information
12325 /// about template argument deduction.
12326 ///
12327 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12328 /// the address of a function template per [temp.deduct.funcaddr] and
12329 /// [over.over]. If \c false, we are looking up a function template
12330 /// specialization based on its signature, per [temp.deduct.decl].
12331 ///
12332 /// \returns the result of template argument deduction.
12335 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12337 bool IsAddressOfFunction = false);
12338
12339 /// Deduce template arguments for a templated conversion
12340 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12341 /// conversion function template specialization.
12344 Expr::Classification ObjectClassification, QualType ToType,
12346
12347 /// Deduce template arguments for a function template when there is
12348 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12349 ///
12350 /// \param FunctionTemplate the function template for which we are performing
12351 /// template argument deduction.
12352 ///
12353 /// \param ExplicitTemplateArgs the explicitly-specified template
12354 /// arguments.
12355 ///
12356 /// \param Specialization if template argument deduction was successful,
12357 /// this will be set to the function template specialization produced by
12358 /// template argument deduction.
12359 ///
12360 /// \param Info the argument will be updated to provide additional information
12361 /// about template argument deduction.
12362 ///
12363 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12364 /// the address of a function template in a context where we do not have a
12365 /// target type, per [over.over]. If \c false, we are looking up a function
12366 /// template specialization based on its signature, which only happens when
12367 /// deducing a function parameter type from an argument that is a template-id
12368 /// naming a function template specialization.
12369 ///
12370 /// \returns the result of template argument deduction.
12373 TemplateArgumentListInfo *ExplicitTemplateArgs,
12376 bool IsAddressOfFunction = false);
12377
12378 /// Substitute Replacement for \p auto in \p TypeWithAuto
12379 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12380 /// Substitute Replacement for auto in TypeWithAuto
12382 QualType Replacement);
12383
12384 // Substitute auto in TypeWithAuto for a Dependent auto type
12386
12387 // Substitute auto in TypeWithAuto for a Dependent auto type
12390
12391 /// Completely replace the \c auto in \p TypeWithAuto by
12392 /// \p Replacement. This does not retain any \c auto type sugar.
12393 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12395 QualType Replacement);
12396
12397 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12398 ///
12399 /// Note that this is done even if the initializer is dependent. (This is
12400 /// necessary to support partial ordering of templates using 'auto'.)
12401 /// A dependent type will be produced when deducing from a dependent type.
12402 ///
12403 /// \param Type the type pattern using the auto type-specifier.
12404 /// \param Init the initializer for the variable whose type is to be deduced.
12405 /// \param Result if type deduction was successful, this will be set to the
12406 /// deduced type.
12407 /// \param Info the argument will be updated to provide additional information
12408 /// about template argument deduction.
12409 /// \param DependentDeduction Set if we should permit deduction in
12410 /// dependent cases. This is necessary for template partial ordering
12411 /// with 'auto' template parameters. The template parameter depth to be
12412 /// used should be specified in the 'Info' parameter.
12413 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12414 /// does not satisfy the type-constraint in the auto
12415 /// type.
12419 bool DependentDeduction = false,
12420 bool IgnoreConstraints = false,
12421 TemplateSpecCandidateSet *FailedTSC = nullptr);
12422 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12424 bool Diagnose = true);
12425
12428
12429 /// Returns the more specialized class template partial specialization
12430 /// according to the rules of partial ordering of class template partial
12431 /// specializations (C++ [temp.class.order]).
12432 ///
12433 /// \param PS1 the first class template partial specialization
12434 ///
12435 /// \param PS2 the second class template partial specialization
12436 ///
12437 /// \returns the more specialized class template partial specialization. If
12438 /// neither partial specialization is more specialized, returns NULL.
12443
12446
12450
12453
12456 bool IsDeduced);
12457
12458 /// Mark which template parameters are used in a given expression.
12459 ///
12460 /// \param E the expression from which template parameters will be deduced.
12461 ///
12462 /// \param Used a bit vector whose elements will be set to \c true
12463 /// to indicate when the corresponding template parameter will be
12464 /// deduced.
12465 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12466 unsigned Depth, llvm::SmallBitVector &Used);
12467
12468 /// Mark which template parameters can be deduced from a given
12469 /// template argument list.
12470 ///
12471 /// \param TemplateArgs the template argument list from which template
12472 /// parameters will be deduced.
12473 ///
12474 /// \param Used a bit vector whose elements will be set to \c true
12475 /// to indicate when the corresponding template parameter will be
12476 /// deduced.
12477 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
12478 bool OnlyDeduced, unsigned Depth,
12479 llvm::SmallBitVector &Used);
12480 void
12482 llvm::SmallBitVector &Deduced) {
12484 }
12485
12486 /// Marks all of the template parameters that will be deduced by a
12487 /// call to the given function template.
12488 static void
12491 llvm::SmallBitVector &Deduced);
12492
12493 /// Returns the more specialized function template according
12494 /// to the rules of function template partial ordering (C++
12495 /// [temp.func.order]).
12496 ///
12497 /// \param FT1 the first function template
12498 ///
12499 /// \param FT2 the second function template
12500 ///
12501 /// \param TPOC the context in which we are performing partial ordering of
12502 /// function templates.
12503 ///
12504 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
12505 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
12506 /// when calling a member function.
12507 ///
12508 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
12509 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
12510 /// template from a member function
12511 ///
12512 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
12513 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
12514 /// template from a member function
12515 ///
12516 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
12517 /// candidate with a reversed parameter order. In this case, the corresponding
12518 /// P/A pairs between FT1 and FT2 are reversed.
12519 ///
12520 /// \returns the more specialized function template. If neither
12521 /// template is more specialized, returns NULL.
12524 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
12525 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false);
12526
12527 /// Retrieve the most specialized of the given function template
12528 /// specializations.
12529 ///
12530 /// \param SpecBegin the start iterator of the function template
12531 /// specializations that we will be comparing.
12532 ///
12533 /// \param SpecEnd the end iterator of the function template
12534 /// specializations, paired with \p SpecBegin.
12535 ///
12536 /// \param Loc the location where the ambiguity or no-specializations
12537 /// diagnostic should occur.
12538 ///
12539 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
12540 /// no matching candidates.
12541 ///
12542 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
12543 /// occurs.
12544 ///
12545 /// \param CandidateDiag partial diagnostic used for each function template
12546 /// specialization that is a candidate in the ambiguous ordering. One
12547 /// parameter in this diagnostic should be unbound, which will correspond to
12548 /// the string describing the template arguments for the function template
12549 /// specialization.
12550 ///
12551 /// \returns the most specialized function template specialization, if
12552 /// found. Otherwise, returns SpecEnd.
12553 UnresolvedSetIterator
12554 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
12555 TemplateSpecCandidateSet &FailedCandidates,
12556 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
12557 const PartialDiagnostic &AmbigDiag,
12558 const PartialDiagnostic &CandidateDiag,
12559 bool Complain = true, QualType TargetType = QualType());
12560
12561 /// Returns the more constrained function according to the rules of
12562 /// partial ordering by constraints (C++ [temp.constr.order]).
12563 ///
12564 /// \param FD1 the first function
12565 ///
12566 /// \param FD2 the second function
12567 ///
12568 /// \returns the more constrained function. If neither function is
12569 /// more constrained, returns NULL.
12570 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
12571 FunctionDecl *FD2);
12572
12573 ///@}
12574
12575 //
12576 //
12577 // -------------------------------------------------------------------------
12578 //
12579 //
12580
12581 /// \name C++ Template Deduction Guide
12582 /// Implementations are in SemaTemplateDeductionGuide.cpp
12583 ///@{
12584
12585 /// Declare implicit deduction guides for a class template if we've
12586 /// not already done so.
12587 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12588 SourceLocation Loc);
12589
12590 FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12591 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12592 SourceLocation Loc);
12593
12594 ///@}
12595
12596 //
12597 //
12598 // -------------------------------------------------------------------------
12599 //
12600 //
12601
12602 /// \name C++ Template Instantiation
12603 /// Implementations are in SemaTemplateInstantiate.cpp
12604 ///@{
12605
12606public:
12607 /// A helper class for building up ExtParameterInfos.
12610 bool HasInteresting = false;
12611
12612 public:
12613 /// Set the ExtParameterInfo for the parameter at the given index,
12614 ///
12615 void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
12616 assert(Infos.size() <= index);
12617 Infos.resize(index);
12618 Infos.push_back(info);
12619
12620 if (!HasInteresting)
12621 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
12622 }
12623
12624 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
12625 /// ExtParameterInfo array we've built up.
12627 getPointerOrNull(unsigned numParams) {
12628 if (!HasInteresting)
12629 return nullptr;
12630 Infos.resize(numParams);
12631 return Infos.data();
12632 }
12633 };
12634
12635 /// The current instantiation scope used to store local
12636 /// variables.
12638
12639 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
12641
12642 /// A mapping from parameters with unparsed default arguments to the
12643 /// set of instantiations of each parameter.
12644 ///
12645 /// This mapping is a temporary data structure used when parsing
12646 /// nested class templates or nested classes of class templates,
12647 /// where we might end up instantiating an inner class before the
12648 /// default arguments of its methods have been parsed.
12650
12651 /// A context in which code is being synthesized (where a source location
12652 /// alone is not sufficient to identify the context). This covers template
12653 /// instantiation and various forms of implicitly-generated functions.
12655 /// The kind of template instantiation we are performing
12657 /// We are instantiating a template declaration. The entity is
12658 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
12660
12661 /// We are instantiating a default argument for a template
12662 /// parameter. The Entity is the template parameter whose argument is
12663 /// being instantiated, the Template is the template, and the
12664 /// TemplateArgs/NumTemplateArguments provide the template arguments as
12665 /// specified.
12667
12668 /// We are instantiating a default argument for a function.
12669 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
12670 /// provides the template arguments as specified.
12672
12673 /// We are substituting explicit template arguments provided for
12674 /// a function template. The entity is a FunctionTemplateDecl.
12676
12677 /// We are substituting template argument determined as part of
12678 /// template argument deduction for either a class template
12679 /// partial specialization or a function template. The
12680 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
12681 /// a TemplateDecl.
12683
12684 /// We are substituting into a lambda expression.
12686
12687 /// We are substituting prior template arguments into a new
12688 /// template parameter. The template parameter itself is either a
12689 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
12691
12692 /// We are checking the validity of a default template argument that
12693 /// has been used when naming a template-id.
12695
12696 /// We are computing the exception specification for a defaulted special
12697 /// member function.
12699
12700 /// We are instantiating the exception specification for a function
12701 /// template which was deferred until it was needed.
12703
12704 /// We are instantiating a requirement of a requires expression.
12706
12707 /// We are checking the satisfaction of a nested requirement of a requires
12708 /// expression.
12710
12711 /// We are declaring an implicit special member function.
12713
12714 /// We are declaring an implicit 'operator==' for a defaulted
12715 /// 'operator<=>'.
12717
12718 /// We are defining a synthesized function (such as a defaulted special
12719 /// member).
12721
12722 // We are checking the constraints associated with a constrained entity or
12723 // the constraint expression of a concept. This includes the checks that
12724 // atomic constraints have the type 'bool' and that they can be constant
12725 // evaluated.
12727
12728 // We are substituting template arguments into a constraint expression.
12730
12731 // We are normalizing a constraint expression.
12733
12734 // Instantiating a Requires Expression parameter clause.
12736
12737 // We are substituting into the parameter mapping of an atomic constraint
12738 // during normalization.
12740
12741 /// We are rewriting a comparison operator in terms of an operator<=>.
12743
12744 /// We are initializing a structured binding.
12746
12747 /// We are marking a class as __dllexport.
12749
12750 /// We are building an implied call from __builtin_dump_struct. The
12751 /// arguments are in CallArgs.
12753
12754 /// Added for Template instantiation observation.
12755 /// Memoization means we are _not_ instantiating a template because
12756 /// it is already instantiated (but we entered a context where we
12757 /// would have had to if it was not already instantiated).
12759
12760 /// We are building deduction guides for a class.
12762
12763 /// We are instantiating a type alias template declaration.
12766
12767 /// Was the enclosing context a non-instantiation SFINAE context?
12769
12770 /// The point of instantiation or synthesis within the source code.
12772
12773 /// The entity that is being synthesized.
12775
12776 /// The template (or partial specialization) in which we are
12777 /// performing the instantiation, for substitutions of prior template
12778 /// arguments.
12780
12781 union {
12782 /// The list of template arguments we are substituting, if they
12783 /// are not part of the entity.
12785
12786 /// The list of argument expressions in a synthesized call.
12787 const Expr *const *CallArgs;
12788 };
12789
12790 // FIXME: Wrap this union around more members, or perhaps store the
12791 // kind-specific members in the RAII object owning the context.
12792 union {
12793 /// The number of template arguments in TemplateArgs.
12795
12796 /// The number of expressions in CallArgs.
12797 unsigned NumCallArgs;
12798
12799 /// The special member being declared or defined.
12801 };
12802
12804 assert(Kind != DeclaringSpecialMember);
12805 return {TemplateArgs, NumTemplateArgs};
12806 }
12807
12808 /// The template deduction info object associated with the
12809 /// substitution or checking of explicit or deduced template arguments.
12811
12812 /// The source range that covers the construct that cause
12813 /// the instantiation, e.g., the template-id that causes a class
12814 /// template instantiation.
12816
12818 : Kind(TemplateInstantiation),
12819 SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
12820 Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
12821 DeductionInfo(nullptr) {}
12822
12823 /// Determines whether this template is an actual instantiation
12824 /// that should be counted toward the maximum instantiation depth.
12825 bool isInstantiationRecord() const;
12826 };
12827
12828 /// A stack object to be created when performing template
12829 /// instantiation.
12830 ///
12831 /// Construction of an object of type \c InstantiatingTemplate
12832 /// pushes the current instantiation onto the stack of active
12833 /// instantiations. If the size of this stack exceeds the maximum
12834 /// number of recursive template instantiations, construction
12835 /// produces an error and evaluates true.
12836 ///
12837 /// Destruction of this object will pop the named instantiation off
12838 /// the stack.
12840 /// Note that we are instantiating a class template,
12841 /// function template, variable template, alias template,
12842 /// or a member thereof.
12843 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12844 Decl *Entity,
12845 SourceRange InstantiationRange = SourceRange());
12846
12848 /// Note that we are instantiating an exception specification
12849 /// of a function template.
12850 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12852 SourceRange InstantiationRange = SourceRange());
12853
12854 /// Note that we are instantiating a type alias template declaration.
12855 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12856 TypeAliasTemplateDecl *Entity,
12857 ArrayRef<TemplateArgument> TemplateArgs,
12858 SourceRange InstantiationRange = SourceRange());
12859
12860 /// Note that we are instantiating a default argument in a
12861 /// template-id.
12862 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12863 TemplateParameter Param, TemplateDecl *Template,
12864 ArrayRef<TemplateArgument> TemplateArgs,
12865 SourceRange InstantiationRange = SourceRange());
12866
12867 /// Note that we are substituting either explicitly-specified or
12868 /// deduced template arguments during function template argument deduction.
12869 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12870 FunctionTemplateDecl *FunctionTemplate,
12871 ArrayRef<TemplateArgument> TemplateArgs,
12873 sema::TemplateDeductionInfo &DeductionInfo,
12874 SourceRange InstantiationRange = SourceRange());
12875
12876 /// Note that we are instantiating as part of template
12877 /// argument deduction for a class template declaration.
12878 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12879 TemplateDecl *Template,
12880 ArrayRef<TemplateArgument> TemplateArgs,
12881 sema::TemplateDeductionInfo &DeductionInfo,
12882 SourceRange InstantiationRange = SourceRange());
12883
12884 /// Note that we are instantiating as part of template
12885 /// argument deduction for a class template partial
12886 /// specialization.
12887 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12889 ArrayRef<TemplateArgument> TemplateArgs,
12890 sema::TemplateDeductionInfo &DeductionInfo,
12891 SourceRange InstantiationRange = SourceRange());
12892
12893 /// Note that we are instantiating as part of template
12894 /// argument deduction for a variable template partial
12895 /// specialization.
12896 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12898 ArrayRef<TemplateArgument> TemplateArgs,
12899 sema::TemplateDeductionInfo &DeductionInfo,
12900 SourceRange InstantiationRange = SourceRange());
12901
12902 /// Note that we are instantiating a default argument for a function
12903 /// parameter.
12904 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12905 ParmVarDecl *Param,
12906 ArrayRef<TemplateArgument> TemplateArgs,
12907 SourceRange InstantiationRange = SourceRange());
12908
12909 /// Note that we are substituting prior template arguments into a
12910 /// non-type parameter.
12911 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12912 NamedDecl *Template, NonTypeTemplateParmDecl *Param,
12913 ArrayRef<TemplateArgument> TemplateArgs,
12914 SourceRange InstantiationRange);
12915
12916 /// Note that we are substituting prior template arguments into a
12917 /// template template parameter.
12918 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12919 NamedDecl *Template, TemplateTemplateParmDecl *Param,
12920 ArrayRef<TemplateArgument> TemplateArgs,
12921 SourceRange InstantiationRange);
12922
12923 /// Note that we are checking the default template argument
12924 /// against the template parameter for a given template-id.
12925 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12926 TemplateDecl *Template, NamedDecl *Param,
12927 ArrayRef<TemplateArgument> TemplateArgs,
12928 SourceRange InstantiationRange);
12929
12931 /// \brief Note that we are checking the constraints associated with some
12932 /// constrained entity (a concept declaration or a template with associated
12933 /// constraints).
12934 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12935 ConstraintsCheck, NamedDecl *Template,
12936 ArrayRef<TemplateArgument> TemplateArgs,
12937 SourceRange InstantiationRange);
12938
12940 /// \brief Note that we are checking a constraint expression associated
12941 /// with a template declaration or as part of the satisfaction check of a
12942 /// concept.
12943 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12945 sema::TemplateDeductionInfo &DeductionInfo,
12946 SourceRange InstantiationRange);
12947
12949 /// \brief Note that we are normalizing a constraint expression.
12950 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12952 SourceRange InstantiationRange);
12953
12955 /// \brief Note that we are subtituting into the parameter mapping of an
12956 /// atomic constraint during constraint normalization.
12957 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12959 SourceRange InstantiationRange);
12960
12961 /// \brief Note that we are substituting template arguments into a part of
12962 /// a requirement of a requires expression.
12963 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12965 sema::TemplateDeductionInfo &DeductionInfo,
12966 SourceRange InstantiationRange = SourceRange());
12967
12968 /// \brief Note that we are checking the satisfaction of the constraint
12969 /// expression inside of a nested requirement.
12970 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12972 SourceRange InstantiationRange = SourceRange());
12973
12974 /// \brief Note that we are checking a requires clause.
12975 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12976 const RequiresExpr *E,
12977 sema::TemplateDeductionInfo &DeductionInfo,
12978 SourceRange InstantiationRange);
12979
12981 /// \brief Note that we are building deduction guides.
12982 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12984 SourceRange InstantiationRange = SourceRange());
12985
12986 /// Note that we have finished instantiating this template.
12987 void Clear();
12988
12990
12991 /// Determines whether we have exceeded the maximum
12992 /// recursive template instantiations.
12993 bool isInvalid() const { return Invalid; }
12994
12995 /// Determine whether we are already instantiating this
12996 /// specialization in some surrounding active instantiation.
12997 bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
12998
12999 private:
13000 Sema &SemaRef;
13001 bool Invalid;
13002 bool AlreadyInstantiating;
13003 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
13004 SourceRange InstantiationRange);
13005
13008 SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
13009 Decl *Entity, NamedDecl *Template = nullptr,
13010 ArrayRef<TemplateArgument> TemplateArgs = std::nullopt,
13011 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
13012
13014
13015 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13016 };
13017
13019 const MultiLevelTemplateArgumentList &TemplateArgs,
13020 TemplateArgumentLoc &Output,
13021 SourceLocation Loc = {},
13022 const DeclarationName &Entity = {});
13023 bool
13024 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13025 const MultiLevelTemplateArgumentList &TemplateArgs,
13026 TemplateArgumentListInfo &Outputs);
13027
13028 /// Retrieve the template argument list(s) that should be used to
13029 /// instantiate the definition of the given declaration.
13030 ///
13031 /// \param ND the declaration for which we are computing template
13032 /// instantiation arguments.
13033 ///
13034 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13035 /// the decl context where it will be created. In this case, the `Innermost`
13036 /// should likely be provided. If ND is non-null, this is ignored.
13037 ///
13038 /// \param Innermost if non-NULL, specifies a template argument list for the
13039 /// template declaration passed as ND.
13040 ///
13041 /// \param RelativeToPrimary true if we should get the template
13042 /// arguments relative to the primary template, even when we're
13043 /// dealing with a specialization. This is only relevant for function
13044 /// template specializations.
13045 ///
13046 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13047 /// instantiating the definition of the given declaration, \p ND. This is
13048 /// used to determine the proper set of template instantiation arguments for
13049 /// friend function template specializations.
13050 ///
13051 /// \param ForConstraintInstantiation when collecting arguments,
13052 /// ForConstraintInstantiation indicates we should continue looking when
13053 /// encountering a lambda generic call operator, and continue looking for
13054 /// arguments on an enclosing class template.
13055 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13056 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13057 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13058 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13059 bool ForConstraintInstantiation = false,
13060 bool SkipForSpecialization = false);
13061
13062 /// RAII object to handle the state changes required to synthesize
13063 /// a function body.
13065 Sema &S;
13066 Sema::ContextRAII SavedContext;
13067 bool PushedCodeSynthesisContext = false;
13068
13069 public:
13071 : S(S), SavedContext(S, DC) {
13072 auto *FD = dyn_cast<FunctionDecl>(DC);
13073 S.PushFunctionScope();
13074 S.PushExpressionEvaluationContext(
13075 (FD && FD->isConsteval())
13076 ? ExpressionEvaluationContext::ImmediateFunctionContext
13077 : ExpressionEvaluationContext::PotentiallyEvaluated);
13078 if (FD) {
13079 FD->setWillHaveBody(true);
13080 S.ExprEvalContexts.back().InImmediateFunctionContext =
13081 FD->isImmediateFunction() ||
13082 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
13083 .isConstantEvaluated() ||
13084 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
13085 .isImmediateFunctionContext();
13086 S.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
13087 S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating();
13088 } else
13089 assert(isa<ObjCMethodDecl>(DC));
13090 }
13091
13093 assert(!PushedCodeSynthesisContext);
13094
13096 Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
13097 Ctx.PointOfInstantiation = UseLoc;
13098 Ctx.Entity = cast<Decl>(S.CurContext);
13099 S.pushCodeSynthesisContext(Ctx);
13100
13101 PushedCodeSynthesisContext = true;
13102 }
13103
13105 if (PushedCodeSynthesisContext)
13106 S.popCodeSynthesisContext();
13107 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13108 FD->setWillHaveBody(false);
13109 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13110 }
13111 S.PopExpressionEvaluationContext();
13112 S.PopFunctionScopeInfo();
13113 }
13114 };
13115
13116 /// List of active code synthesis contexts.
13117 ///
13118 /// This vector is treated as a stack. As synthesis of one entity requires
13119 /// synthesis of another, additional contexts are pushed onto the stack.
13121
13122 /// Specializations whose definitions are currently being instantiated.
13124
13125 /// Non-dependent types used in templates that have already been instantiated
13126 /// by some template instantiation.
13128
13129 /// Extra modules inspected when performing a lookup during a template
13130 /// instantiation. Computed lazily.
13132
13133 /// Cache of additional modules that should be used for name lookup
13134 /// within the current template instantiation. Computed lazily; use
13135 /// getLookupModules() to get a complete set.
13137
13138 /// Map from the most recent declaration of a namespace to the most
13139 /// recent visible declaration of that namespace.
13140 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13141
13142 /// Whether we are in a SFINAE context that is not associated with
13143 /// template instantiation.
13144 ///
13145 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
13146 /// of a template instantiation or template argument deduction.
13148
13149 /// The number of \p CodeSynthesisContexts that are not template
13150 /// instantiations and, therefore, should not be counted as part of the
13151 /// instantiation depth.
13152 ///
13153 /// When the instantiation depth reaches the user-configurable limit
13154 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13155 // FIXME: Should we have a similar limit for other forms of synthesis?
13157
13158 /// The depth of the context stack at the point when the most recent
13159 /// error or warning was produced.
13160 ///
13161 /// This value is used to suppress printing of redundant context stacks
13162 /// when there are multiple errors or warnings in the same instantiation.
13163 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13165
13166 /// The template instantiation callbacks to trace or track
13167 /// instantiations (objects can be chained).
13168 ///
13169 /// This callbacks is used to print, trace or track template
13170 /// instantiations as they are being constructed.
13171 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
13173
13174 /// The current index into pack expansion arguments that will be
13175 /// used for substitution of parameter packs.
13176 ///
13177 /// The pack expansion index will be -1 to indicate that parameter packs
13178 /// should be instantiated as themselves. Otherwise, the index specifies
13179 /// which argument within the parameter pack will be used for substitution.
13181
13182 /// RAII object used to change the argument pack substitution index
13183 /// within a \c Sema object.
13184 ///
13185 /// See \c ArgumentPackSubstitutionIndex for more information.
13187 Sema &Self;
13188 int OldSubstitutionIndex;
13189
13190 public:
13191 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
13192 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
13193 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
13194 }
13195
13197 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
13198 }
13199 };
13200
13202
13205
13207 if (!CodeSynthesisContexts.empty() &&
13211 }
13214 }
13215 /// Prints the current instantiation stack through a series of
13216 /// notes.
13218
13219 /// Determines whether we are currently in a context where
13220 /// template argument substitution failures are not considered
13221 /// errors.
13222 ///
13223 /// \returns An empty \c Optional if we're not in a SFINAE context.
13224 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
13225 /// template-deduction context object, which can be used to capture
13226 /// diagnostics that will be suppressed.
13227 std::optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
13228
13229 /// Perform substitution on the type T with a given set of template
13230 /// arguments.
13231 ///
13232 /// This routine substitutes the given template arguments into the
13233 /// type T and produces the instantiated type.
13234 ///
13235 /// \param T the type into which the template arguments will be
13236 /// substituted. If this type is not dependent, it will be returned
13237 /// immediately.
13238 ///
13239 /// \param Args the template arguments that will be
13240 /// substituted for the top-level template parameters within T.
13241 ///
13242 /// \param Loc the location in the source code where this substitution
13243 /// is being performed. It will typically be the location of the
13244 /// declarator (if we're instantiating the type of some declaration)
13245 /// or the location of the type in the source code (if, e.g., we're
13246 /// instantiating the type of a cast expression).
13247 ///
13248 /// \param Entity the name of the entity associated with a declaration
13249 /// being instantiated (if any). May be empty to indicate that there
13250 /// is no such entity (if, e.g., this is a type that occurs as part of
13251 /// a cast expression) or that the entity has no name (e.g., an
13252 /// unnamed function parameter).
13253 ///
13254 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13255 /// acceptable as the top level type of the result.
13256 ///
13257 /// \returns If the instantiation succeeds, the instantiated
13258 /// type. Otherwise, produces diagnostics and returns a NULL type.
13260 const MultiLevelTemplateArgumentList &TemplateArgs,
13262 bool AllowDeducedTST = false);
13263
13265 const MultiLevelTemplateArgumentList &TemplateArgs,
13267
13269 const MultiLevelTemplateArgumentList &TemplateArgs,
13271
13272 /// A form of SubstType intended specifically for instantiating the
13273 /// type of a FunctionDecl. Its purpose is solely to force the
13274 /// instantiation of default-argument expressions and to avoid
13275 /// instantiating an exception-specification.
13277 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13278 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13279 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13280 void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
13281 const MultiLevelTemplateArgumentList &Args);
13284 SmallVectorImpl<QualType> &ExceptionStorage,
13285 const MultiLevelTemplateArgumentList &Args);
13286 ParmVarDecl *
13288 const MultiLevelTemplateArgumentList &TemplateArgs,
13289 int indexAdjustment, std::optional<unsigned> NumExpansions,
13290 bool ExpectParameterPack, bool EvaluateConstraints = true);
13291
13292 /// Substitute the given template arguments into the given set of
13293 /// parameters, producing the set of parameter types that would be generated
13294 /// from such a substitution.
13296 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13297 const MultiLevelTemplateArgumentList &TemplateArgs,
13298 SmallVectorImpl<QualType> &ParamTypes,
13300 ExtParameterInfoBuilder &ParamInfos);
13301
13302 /// Substitute the given template arguments into the default argument.
13304 const MultiLevelTemplateArgumentList &TemplateArgs,
13305 bool ForCallExpr = false);
13307 const MultiLevelTemplateArgumentList &TemplateArgs);
13308
13309 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
13310 // to disable constraint evaluation, then restore the state.
13311 template <typename InstTy> struct ConstraintEvalRAII {
13312 InstTy &TI;
13314
13316 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
13317 TI.setEvaluateConstraints(false);
13318 }
13319 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
13320 };
13321
13322 // Must be used instead of SubstExpr at 'constraint checking' time.
13325 const MultiLevelTemplateArgumentList &TemplateArgs);
13326 // Unlike the above, this does not evaluates constraints.
13328 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13329
13330 /// Substitute the given template arguments into a list of
13331 /// expressions, expanding pack expansions if required.
13332 ///
13333 /// \param Exprs The list of expressions to substitute into.
13334 ///
13335 /// \param IsCall Whether this is some form of call, in which case
13336 /// default arguments will be dropped.
13337 ///
13338 /// \param TemplateArgs The set of template arguments to substitute.
13339 ///
13340 /// \param Outputs Will receive all of the substituted arguments.
13341 ///
13342 /// \returns true if an error occurred, false otherwise.
13343 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13344 const MultiLevelTemplateArgumentList &TemplateArgs,
13345 SmallVectorImpl<Expr *> &Outputs);
13346
13348 const MultiLevelTemplateArgumentList &TemplateArgs);
13349
13352 bool CXXDirectInit);
13353
13354 /// Perform substitution on the base class specifiers of the
13355 /// given class template specialization.
13356 ///
13357 /// Produces a diagnostic and returns true on error, returns false and
13358 /// attaches the instantiated base classes to the class template
13359 /// specialization if successful.
13360 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13361 const MultiLevelTemplateArgumentList &TemplateArgs);
13362
13363 /// Instantiate the definition of a class from a given pattern.
13364 ///
13365 /// \param PointOfInstantiation The point of instantiation within the
13366 /// source code.
13367 ///
13368 /// \param Instantiation is the declaration whose definition is being
13369 /// instantiated. This will be either a class template specialization
13370 /// or a member class of a class template specialization.
13371 ///
13372 /// \param Pattern is the pattern from which the instantiation
13373 /// occurs. This will be either the declaration of a class template or
13374 /// the declaration of a member class of a class template.
13375 ///
13376 /// \param TemplateArgs The template arguments to be substituted into
13377 /// the pattern.
13378 ///
13379 /// \param TSK the kind of implicit or explicit instantiation to perform.
13380 ///
13381 /// \param Complain whether to complain if the class cannot be instantiated
13382 /// due to the lack of a definition.
13383 ///
13384 /// \returns true if an error occurred, false otherwise.
13385 bool InstantiateClass(SourceLocation PointOfInstantiation,
13386 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13387 const MultiLevelTemplateArgumentList &TemplateArgs,
13388 TemplateSpecializationKind TSK, bool Complain = true);
13389
13390 /// Instantiate the definition of an enum from a given pattern.
13391 ///
13392 /// \param PointOfInstantiation The point of instantiation within the
13393 /// source code.
13394 /// \param Instantiation is the declaration whose definition is being
13395 /// instantiated. This will be a member enumeration of a class
13396 /// temploid specialization, or a local enumeration within a
13397 /// function temploid specialization.
13398 /// \param Pattern The templated declaration from which the instantiation
13399 /// occurs.
13400 /// \param TemplateArgs The template arguments to be substituted into
13401 /// the pattern.
13402 /// \param TSK The kind of implicit or explicit instantiation to perform.
13403 ///
13404 /// \return \c true if an error occurred, \c false otherwise.
13405 bool InstantiateEnum(SourceLocation PointOfInstantiation,
13406 EnumDecl *Instantiation, EnumDecl *Pattern,
13407 const MultiLevelTemplateArgumentList &TemplateArgs,
13409
13410 /// Instantiate the definition of a field from the given pattern.
13411 ///
13412 /// \param PointOfInstantiation The point of instantiation within the
13413 /// source code.
13414 /// \param Instantiation is the declaration whose definition is being
13415 /// instantiated. This will be a class of a class temploid
13416 /// specialization, or a local enumeration within a function temploid
13417 /// specialization.
13418 /// \param Pattern The templated declaration from which the instantiation
13419 /// occurs.
13420 /// \param TemplateArgs The template arguments to be substituted into
13421 /// the pattern.
13422 ///
13423 /// \return \c true if an error occurred, \c false otherwise.
13425 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
13426 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
13427
13430
13432 SourceLocation PointOfInstantiation,
13433 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13434 TemplateSpecializationKind TSK, bool Complain = true);
13435
13436 /// Instantiates the definitions of all of the member
13437 /// of the given class, which is an instantiation of a class template
13438 /// or a member class of a template.
13439 void
13440 InstantiateClassMembers(SourceLocation PointOfInstantiation,
13441 CXXRecordDecl *Instantiation,
13442 const MultiLevelTemplateArgumentList &TemplateArgs,
13444
13445 /// Instantiate the definitions of all of the members of the
13446 /// given class template specialization, which was named as part of an
13447 /// explicit instantiation.
13449 SourceLocation PointOfInstantiation,
13450 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13452
13455 const MultiLevelTemplateArgumentList &TemplateArgs);
13456
13457 /// Do template substitution on declaration name info.
13460 const MultiLevelTemplateArgumentList &TemplateArgs);
13464 const MultiLevelTemplateArgumentList &TemplateArgs);
13465
13467 const MultiLevelTemplateArgumentList &TemplateArgs,
13468 bool EvaluateConstraint);
13469
13470 /// Determine whether we are currently performing template instantiation.
13473 }
13474
13475 ///@}
13476
13477 //
13478 //
13479 // -------------------------------------------------------------------------
13480 //
13481 //
13482
13483 /// \name C++ Template Declaration Instantiation
13484 /// Implementations are in SemaTemplateInstantiateDecl.cpp
13485 ///@{
13486
13487public:
13488 /// An entity for which implicit template instantiation is required.
13489 ///
13490 /// The source location associated with the declaration is the first place in
13491 /// the source code where the declaration was "used". It is not necessarily
13492 /// the point of instantiation (which will be either before or after the
13493 /// namespace-scope declaration that triggered this implicit instantiation),
13494 /// However, it is the location that diagnostics should generally refer to,
13495 /// because users will need to know what code triggered the instantiation.
13496 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
13497
13498 /// The queue of implicit template instantiations that are required
13499 /// but have not yet been performed.
13500 std::deque<PendingImplicitInstantiation> PendingInstantiations;
13501
13502 /// Queue of implicit template instantiations that cannot be performed
13503 /// eagerly.
13505
13509
13510 /// The queue of implicit template instantiations that are required
13511 /// and must be performed within the current local scope.
13512 ///
13513 /// This queue is only used for member functions of local classes in
13514 /// templates, which must be instantiated in the same scope as their
13515 /// enclosing function, so that they can reference function-local
13516 /// types, static variables, enumerators, etc.
13517 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
13518
13520 public:
13522 SavedPendingLocalImplicitInstantiations.swap(
13523 S.PendingLocalImplicitInstantiations);
13524 }
13525
13526 void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
13527
13529 assert(S.PendingLocalImplicitInstantiations.empty() &&
13530 "there shouldn't be any pending local implicit instantiations");
13531 SavedPendingLocalImplicitInstantiations.swap(
13532 S.PendingLocalImplicitInstantiations);
13533 }
13534
13535 private:
13536 Sema &S;
13537 std::deque<PendingImplicitInstantiation>
13538 SavedPendingLocalImplicitInstantiations;
13539 };
13540
13541 /// Records and restores the CurFPFeatures state on entry/exit of compound
13542 /// statements.
13544 public:
13547 FPOptionsOverride getOverrides() { return OldOverrides; }
13548
13549 private:
13550 Sema &S;
13551 FPOptions OldFPFeaturesState;
13552 FPOptionsOverride OldOverrides;
13553 LangOptions::FPEvalMethodKind OldEvalMethod;
13554 SourceLocation OldFPPragmaLocation;
13555 };
13556
13558 public:
13560 : S(S), Enabled(Enabled) {
13561 if (!Enabled)
13562 return;
13563
13564 S.SavedPendingInstantiations.emplace_back();
13565 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
13566
13567 S.SavedVTableUses.emplace_back();
13568 S.SavedVTableUses.back().swap(S.VTableUses);
13569 }
13570
13571 void perform() {
13572 if (Enabled) {
13573 S.DefineUsedVTables();
13574 S.PerformPendingInstantiations();
13575 }
13576 }
13577
13579 if (!Enabled)
13580 return;
13581
13582 // Restore the set of pending vtables.
13583 assert(S.VTableUses.empty() &&
13584 "VTableUses should be empty before it is discarded.");
13585 S.VTableUses.swap(S.SavedVTableUses.back());
13586 S.SavedVTableUses.pop_back();
13587
13588 // Restore the set of pending implicit instantiations.
13589 if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
13590 assert(S.PendingInstantiations.empty() &&
13591 "PendingInstantiations should be empty before it is discarded.");
13592 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13593 S.SavedPendingInstantiations.pop_back();
13594 } else {
13595 // Template instantiations in the PCH may be delayed until the TU.
13596 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13597 S.PendingInstantiations.insert(
13598 S.PendingInstantiations.end(),
13599 S.SavedPendingInstantiations.back().begin(),
13600 S.SavedPendingInstantiations.back().end());
13601 S.SavedPendingInstantiations.pop_back();
13602 }
13603 }
13604
13605 private:
13606 Sema &S;
13607 bool Enabled;
13608 };
13609
13611 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
13612
13617
13619 Decl *D)
13620 : TmplAttr(A), Scope(S), NewDecl(D) {}
13621 };
13623
13624 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
13625 const Decl *Pattern, Decl *Inst,
13626 LateInstantiatedAttrVec *LateAttrs = nullptr,
13627 LocalInstantiationScope *OuterMostScope = nullptr);
13628
13629 /// Update instantiation attributes after template was late parsed.
13630 ///
13631 /// Some attributes are evaluated based on the body of template. If it is
13632 /// late parsed, such attributes cannot be evaluated when declaration is
13633 /// instantiated. This function is used to update instantiation attributes
13634 /// when template definition is ready.
13635 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
13636
13637 void
13639 const Decl *Pattern, Decl *Inst,
13640 LateInstantiatedAttrVec *LateAttrs = nullptr,
13641 LocalInstantiationScope *OuterMostScope = nullptr);
13642
13643 /// In the MS ABI, we need to instantiate default arguments of dllexported
13644 /// default constructors along with the constructor definition. This allows IR
13645 /// gen to emit a constructor closure which calls the default constructor with
13646 /// its default arguments.
13648
13650 ParmVarDecl *Param);
13651 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
13653
13654 /// Instantiate (or find existing instantiation of) a function template with a
13655 /// given set of template arguments.
13656 ///
13657 /// Usually this should not be used, and template argument deduction should be
13658 /// used in its place.
13664
13665 /// Instantiate the definition of the given function from its
13666 /// template.
13667 ///
13668 /// \param PointOfInstantiation the point at which the instantiation was
13669 /// required. Note that this is not precisely a "point of instantiation"
13670 /// for the function, but it's close.
13671 ///
13672 /// \param Function the already-instantiated declaration of a
13673 /// function template specialization or member function of a class template
13674 /// specialization.
13675 ///
13676 /// \param Recursive if true, recursively instantiates any functions that
13677 /// are required by this instantiation.
13678 ///
13679 /// \param DefinitionRequired if true, then we are performing an explicit
13680 /// instantiation where the body of the function is required. Complain if
13681 /// there is no such body.
13682 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
13684 bool Recursive = false,
13685 bool DefinitionRequired = false,
13686 bool AtEndOfTU = false);
13689 const TemplateArgumentList *PartialSpecArgs,
13690 const TemplateArgumentListInfo &TemplateArgsInfo,
13692 SourceLocation PointOfInstantiation,
13693 LateInstantiatedAttrVec *LateAttrs = nullptr,
13694 LocalInstantiationScope *StartingScope = nullptr);
13695
13696 /// Instantiates a variable template specialization by completing it
13697 /// with appropriate type information and initializer.
13699 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
13700 const MultiLevelTemplateArgumentList &TemplateArgs);
13701
13702 /// BuildVariableInstantiation - Used after a new variable has been created.
13703 /// Sets basic variable data and decides whether to postpone the
13704 /// variable instantiation.
13705 void
13707 const MultiLevelTemplateArgumentList &TemplateArgs,
13708 LateInstantiatedAttrVec *LateAttrs,
13709 DeclContext *Owner,
13710 LocalInstantiationScope *StartingScope,
13711 bool InstantiatingVarTemplate = false,
13712 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
13713
13714 /// Instantiate the initializer of a variable.
13716 VarDecl *Var, VarDecl *OldVar,
13717 const MultiLevelTemplateArgumentList &TemplateArgs);
13718
13719 /// Instantiate the definition of the given variable from its
13720 /// template.
13721 ///
13722 /// \param PointOfInstantiation the point at which the instantiation was
13723 /// required. Note that this is not precisely a "point of instantiation"
13724 /// for the variable, but it's close.
13725 ///
13726 /// \param Var the already-instantiated declaration of a templated variable.
13727 ///
13728 /// \param Recursive if true, recursively instantiates any functions that
13729 /// are required by this instantiation.
13730 ///
13731 /// \param DefinitionRequired if true, then we are performing an explicit
13732 /// instantiation where a definition of the variable is required. Complain
13733 /// if there is no such definition.
13734 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
13735 VarDecl *Var, bool Recursive = false,
13736 bool DefinitionRequired = false,
13737 bool AtEndOfTU = false);
13738
13740 CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl,
13741 const MultiLevelTemplateArgumentList &TemplateArgs);
13742
13743 /// Find the instantiation of the given declaration within the
13744 /// current instantiation.
13745 ///
13746 /// This routine is intended to be used when \p D is a declaration
13747 /// referenced from within a template, that needs to mapped into the
13748 /// corresponding declaration within an instantiation. For example,
13749 /// given:
13750 ///
13751 /// \code
13752 /// template<typename T>
13753 /// struct X {
13754 /// enum Kind {
13755 /// KnownValue = sizeof(T)
13756 /// };
13757 ///
13758 /// bool getKind() const { return KnownValue; }
13759 /// };
13760 ///
13761 /// template struct X<int>;
13762 /// \endcode
13763 ///
13764 /// In the instantiation of X<int>::getKind(), we need to map the \p
13765 /// EnumConstantDecl for \p KnownValue (which refers to
13766 /// X<T>::<Kind>::KnownValue) to its instantiation
13767 /// (X<int>::<Kind>::KnownValue).
13768 /// \p FindInstantiatedDecl performs this mapping from within the
13769 /// instantiation of X<int>.
13770 NamedDecl *
13772 const MultiLevelTemplateArgumentList &TemplateArgs,
13773 bool FindingInstantiatedContext = false);
13774
13775 /// Finds the instantiation of the given declaration context
13776 /// within the current instantiation.
13777 ///
13778 /// \returns NULL if there was an error
13779 DeclContext *
13781 const MultiLevelTemplateArgumentList &TemplateArgs);
13782
13783 Decl *SubstDecl(Decl *D, DeclContext *Owner,
13784 const MultiLevelTemplateArgumentList &TemplateArgs);
13785
13786 /// Substitute the name and return type of a defaulted 'operator<=>' to form
13787 /// an implicit 'operator=='.
13789 FunctionDecl *Spaceship);
13790
13791 /// Performs template instantiation for all implicit template
13792 /// instantiations we have seen until this point.
13793 void PerformPendingInstantiations(bool LocalOnly = false);
13794
13797 const MultiLevelTemplateArgumentList &TemplateArgs,
13798 bool EvaluateConstraints = true);
13799
13801 const DeclContext *Pattern,
13802 const MultiLevelTemplateArgumentList &TemplateArgs);
13803
13804private:
13805 /// Introduce the instantiated local variables into the local
13806 /// instantiation scope.
13807 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
13808 const FunctionDecl *PatternDecl,
13810 /// Introduce the instantiated function parameters into the local
13811 /// instantiation scope, and set the parameter names to those used
13812 /// in the template.
13813 bool addInstantiatedParametersToScope(
13814 FunctionDecl *Function, const FunctionDecl *PatternDecl,
13816 const MultiLevelTemplateArgumentList &TemplateArgs);
13817
13818 int ParsingClassDepth = 0;
13819
13820 class SavePendingParsedClassStateRAII {
13821 public:
13822 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
13823
13824 ~SavePendingParsedClassStateRAII() {
13825 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
13826 "there shouldn't be any pending delayed exception spec checks");
13827 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
13828 "there shouldn't be any pending delayed exception spec checks");
13829 swapSavedState();
13830 }
13831
13832 private:
13833 Sema &S;
13834 decltype(DelayedOverridingExceptionSpecChecks)
13835 SavedOverridingExceptionSpecChecks;
13836 decltype(DelayedEquivalentExceptionSpecChecks)
13837 SavedEquivalentExceptionSpecChecks;
13838
13839 void swapSavedState() {
13840 SavedOverridingExceptionSpecChecks.swap(
13841 S.DelayedOverridingExceptionSpecChecks);
13842 SavedEquivalentExceptionSpecChecks.swap(
13843 S.DelayedEquivalentExceptionSpecChecks);
13844 }
13845 };
13846
13847 ///@}
13848
13849 //
13850 //
13851 // -------------------------------------------------------------------------
13852 //
13853 //
13854
13855 /// \name C++ Variadic Templates
13856 /// Implementations are in SemaTemplateVariadic.cpp
13857 ///@{
13858
13859public:
13860 /// Determine whether an unexpanded parameter pack might be permitted in this
13861 /// location. Useful for error recovery.
13863
13864 /// The context in which an unexpanded parameter pack is
13865 /// being diagnosed.
13866 ///
13867 /// Note that the values of this enumeration line up with the first
13868 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
13870 /// An arbitrary expression.
13872
13873 /// The base type of a class type.
13875
13876 /// The type of an arbitrary declaration.
13878
13879 /// The type of a data member.
13881
13882 /// The size of a bit-field.
13884
13885 /// The expression in a static assertion.
13887
13888 /// The fixed underlying type of an enumeration.
13890
13891 /// The enumerator value.
13893
13894 /// A using declaration.
13896
13897 /// A friend declaration.
13899
13900 /// A declaration qualifier.
13902
13903 /// An initializer.
13905
13906 /// A default argument.
13908
13909 /// The type of a non-type template parameter.
13911
13912 /// The type of an exception.
13914
13915 /// Explicit specialization.
13917
13918 /// Partial specialization.
13920
13921 /// Microsoft __if_exists.
13923
13924 /// Microsoft __if_not_exists.
13926
13927 /// Lambda expression.
13929
13930 /// Block expression.
13932
13933 /// A type constraint.
13935
13936 // A requirement in a requires-expression.
13938
13939 // A requires-clause.
13941 };
13942
13943 /// Diagnose unexpanded parameter packs.
13944 ///
13945 /// \param Loc The location at which we should emit the diagnostic.
13946 ///
13947 /// \param UPPC The context in which we are diagnosing unexpanded
13948 /// parameter packs.
13949 ///
13950 /// \param Unexpanded the set of unexpanded parameter packs.
13951 ///
13952 /// \returns true if an error occurred, false otherwise.
13956
13957 /// If the given type contains an unexpanded parameter pack,
13958 /// diagnose the error.
13959 ///
13960 /// \param Loc The source location where a diagnostc should be emitted.
13961 ///
13962 /// \param T The type that is being checked for unexpanded parameter
13963 /// packs.
13964 ///
13965 /// \returns true if an error occurred, false otherwise.
13968
13969 /// If the given expression contains an unexpanded parameter
13970 /// pack, diagnose the error.
13971 ///
13972 /// \param E The expression that is being checked for unexpanded
13973 /// parameter packs.
13974 ///
13975 /// \returns true if an error occurred, false otherwise.
13978
13979 /// If the given requirees-expression contains an unexpanded reference to one
13980 /// of its own parameter packs, diagnose the error.
13981 ///
13982 /// \param RE The requiress-expression that is being checked for unexpanded
13983 /// parameter packs.
13984 ///
13985 /// \returns true if an error occurred, false otherwise.
13987
13988 /// If the given nested-name-specifier contains an unexpanded
13989 /// parameter pack, diagnose the error.
13990 ///
13991 /// \param SS The nested-name-specifier that is being checked for
13992 /// unexpanded parameter packs.
13993 ///
13994 /// \returns true if an error occurred, false otherwise.
13997
13998 /// If the given name contains an unexpanded parameter pack,
13999 /// diagnose the error.
14000 ///
14001 /// \param NameInfo The name (with source location information) that
14002 /// is being checked for unexpanded parameter packs.
14003 ///
14004 /// \returns true if an error occurred, false otherwise.
14007
14008 /// If the given template name contains an unexpanded parameter pack,
14009 /// diagnose the error.
14010 ///
14011 /// \param Loc The location of the template name.
14012 ///
14013 /// \param Template The template name that is being checked for unexpanded
14014 /// parameter packs.
14015 ///
14016 /// \returns true if an error occurred, false otherwise.
14018 TemplateName Template,
14020
14021 /// If the given template argument contains an unexpanded parameter
14022 /// pack, diagnose the error.
14023 ///
14024 /// \param Arg The template argument that is being checked for unexpanded
14025 /// parameter packs.
14026 ///
14027 /// \returns true if an error occurred, false otherwise.
14030
14031 /// Collect the set of unexpanded parameter packs within the given
14032 /// template argument.
14033 ///
14034 /// \param Arg The template argument that will be traversed to find
14035 /// unexpanded parameter packs.
14037 TemplateArgument Arg,
14039
14040 /// Collect the set of unexpanded parameter packs within the given
14041 /// template argument.
14042 ///
14043 /// \param Arg The template argument that will be traversed to find
14044 /// unexpanded parameter packs.
14048
14049 /// Collect the set of unexpanded parameter packs within the given
14050 /// type.
14051 ///
14052 /// \param T The type that will be traversed to find
14053 /// unexpanded parameter packs.
14056
14057 /// Collect the set of unexpanded parameter packs within the given
14058 /// type.
14059 ///
14060 /// \param TL The type that will be traversed to find
14061 /// unexpanded parameter packs.
14064
14065 /// Collect the set of unexpanded parameter packs within the given
14066 /// nested-name-specifier.
14067 ///
14068 /// \param NNS The nested-name-specifier that will be traversed to find
14069 /// unexpanded parameter packs.
14073
14074 /// Collect the set of unexpanded parameter packs within the given
14075 /// name.
14076 ///
14077 /// \param NameInfo The name that will be traversed to find
14078 /// unexpanded parameter packs.
14080 const DeclarationNameInfo &NameInfo,
14082
14083 /// Collect the set of unexpanded parameter packs within the given
14084 /// expression.
14087
14088 /// Invoked when parsing a template argument followed by an
14089 /// ellipsis, which creates a pack expansion.
14090 ///
14091 /// \param Arg The template argument preceding the ellipsis, which
14092 /// may already be invalid.
14093 ///
14094 /// \param EllipsisLoc The location of the ellipsis.
14096 SourceLocation EllipsisLoc);
14097
14098 /// Invoked when parsing a type followed by an ellipsis, which
14099 /// creates a pack expansion.
14100 ///
14101 /// \param Type The type preceding the ellipsis, which will become
14102 /// the pattern of the pack expansion.
14103 ///
14104 /// \param EllipsisLoc The location of the ellipsis.
14106
14107 /// Construct a pack expansion type from the pattern of the pack
14108 /// expansion.
14110 SourceLocation EllipsisLoc,
14111 std::optional<unsigned> NumExpansions);
14112
14113 /// Construct a pack expansion type from the pattern of the pack
14114 /// expansion.
14115 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14116 SourceLocation EllipsisLoc,
14117 std::optional<unsigned> NumExpansions);
14118
14119 /// Invoked when parsing an expression followed by an ellipsis, which
14120 /// creates a pack expansion.
14121 ///
14122 /// \param Pattern The expression preceding the ellipsis, which will become
14123 /// the pattern of the pack expansion.
14124 ///
14125 /// \param EllipsisLoc The location of the ellipsis.
14126 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14127
14128 /// Invoked when parsing an expression followed by an ellipsis, which
14129 /// creates a pack expansion.
14130 ///
14131 /// \param Pattern The expression preceding the ellipsis, which will become
14132 /// the pattern of the pack expansion.
14133 ///
14134 /// \param EllipsisLoc The location of the ellipsis.
14135 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14136 std::optional<unsigned> NumExpansions);
14137
14138 /// Determine whether we could expand a pack expansion with the
14139 /// given set of parameter packs into separate arguments by repeatedly
14140 /// transforming the pattern.
14141 ///
14142 /// \param EllipsisLoc The location of the ellipsis that identifies the
14143 /// pack expansion.
14144 ///
14145 /// \param PatternRange The source range that covers the entire pattern of
14146 /// the pack expansion.
14147 ///
14148 /// \param Unexpanded The set of unexpanded parameter packs within the
14149 /// pattern.
14150 ///
14151 /// \param ShouldExpand Will be set to \c true if the transformer should
14152 /// expand the corresponding pack expansions into separate arguments. When
14153 /// set, \c NumExpansions must also be set.
14154 ///
14155 /// \param RetainExpansion Whether the caller should add an unexpanded
14156 /// pack expansion after all of the expanded arguments. This is used
14157 /// when extending explicitly-specified template argument packs per
14158 /// C++0x [temp.arg.explicit]p9.
14159 ///
14160 /// \param NumExpansions The number of separate arguments that will be in
14161 /// the expanded form of the corresponding pack expansion. This is both an
14162 /// input and an output parameter, which can be set by the caller if the
14163 /// number of expansions is known a priori (e.g., due to a prior substitution)
14164 /// and will be set by the callee when the number of expansions is known.
14165 /// The callee must set this value when \c ShouldExpand is \c true; it may
14166 /// set this value in other cases.
14167 ///
14168 /// \returns true if an error occurred (e.g., because the parameter packs
14169 /// are to be instantiated with arguments of different lengths), false
14170 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14171 /// must be set.
14173 SourceLocation EllipsisLoc, SourceRange PatternRange,
14175 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
14176 bool &RetainExpansion, std::optional<unsigned> &NumExpansions);
14177
14178 /// Determine the number of arguments in the given pack expansion
14179 /// type.
14180 ///
14181 /// This routine assumes that the number of arguments in the expansion is
14182 /// consistent across all of the unexpanded parameter packs in its pattern.
14183 ///
14184 /// Returns an empty Optional if the type can't be expanded.
14185 std::optional<unsigned> getNumArgumentsInExpansion(
14186 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14187
14188 /// Determine whether the given declarator contains any unexpanded
14189 /// parameter packs.
14190 ///
14191 /// This routine is used by the parser to disambiguate function declarators
14192 /// with an ellipsis prior to the ')', e.g.,
14193 ///
14194 /// \code
14195 /// void f(T...);
14196 /// \endcode
14197 ///
14198 /// To determine whether we have an (unnamed) function parameter pack or
14199 /// a variadic function.
14200 ///
14201 /// \returns true if the declarator contains any unexpanded parameter packs,
14202 /// false otherwise.
14204
14205 /// Returns the pattern of the pack expansion for a template argument.
14206 ///
14207 /// \param OrigLoc The template argument to expand.
14208 ///
14209 /// \param Ellipsis Will be set to the location of the ellipsis.
14210 ///
14211 /// \param NumExpansions Will be set to the number of expansions that will
14212 /// be generated from this pack expansion, if known a priori.
14214 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
14215 std::optional<unsigned> &NumExpansions) const;
14216
14217 /// Given a template argument that contains an unexpanded parameter pack, but
14218 /// which has already been substituted, attempt to determine the number of
14219 /// elements that will be produced once this argument is fully-expanded.
14220 ///
14221 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14222 /// avoid actually expanding the pack where possible.
14223 std::optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
14224
14225 /// Called when an expression computing the size of a parameter pack
14226 /// is parsed.
14227 ///
14228 /// \code
14229 /// template<typename ...Types> struct count {
14230 /// static const unsigned value = sizeof...(Types);
14231 /// };
14232 /// \endcode
14233 ///
14234 //
14235 /// \param OpLoc The location of the "sizeof" keyword.
14236 /// \param Name The name of the parameter pack whose size will be determined.
14237 /// \param NameLoc The source location of the name of the parameter pack.
14238 /// \param RParenLoc The location of the closing parentheses.
14240 IdentifierInfo &Name,
14241 SourceLocation NameLoc,
14242 SourceLocation RParenLoc);
14243
14244 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14245 SourceLocation EllipsisLoc,
14246 SourceLocation LSquareLoc, Expr *IndexExpr,
14247 SourceLocation RSquareLoc);
14248
14249 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14250 SourceLocation EllipsisLoc, Expr *IndexExpr,
14251 SourceLocation RSquareLoc,
14252 ArrayRef<Expr *> ExpandedExprs = {},
14253 bool EmptyPack = false);
14254
14255 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
14256 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14257 tok::TokenKind Operator,
14258 SourceLocation EllipsisLoc, Expr *RHS,
14259 SourceLocation RParenLoc);
14260 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
14261 SourceLocation LParenLoc, Expr *LHS,
14262 BinaryOperatorKind Operator,
14263 SourceLocation EllipsisLoc, Expr *RHS,
14264 SourceLocation RParenLoc,
14265 std::optional<unsigned> NumExpansions);
14266 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
14267 BinaryOperatorKind Operator);
14268
14269 ///@}
14270
14271 //
14272 //
14273 // -------------------------------------------------------------------------
14274 //
14275 //
14276
14277 /// \name Constraints and Concepts
14278 /// Implementations are in SemaConcept.cpp
14279 ///@{
14280
14281public:
14283 const llvm::FoldingSetNodeID &ID) {
14284 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14285 SatisfactionStack.emplace_back(Can, ID);
14286 }
14287
14288 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
14289
14291 const llvm::FoldingSetNodeID &ID) const {
14292 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14293 return llvm::find(SatisfactionStack, SatisfactionStackEntryTy{Can, ID}) !=
14294 SatisfactionStack.end();
14295 }
14296
14298 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
14299
14300 // Resets the current SatisfactionStack for cases where we are instantiating
14301 // constraints as a 'side effect' of normal instantiation in a way that is not
14302 // indicative of recursive definition.
14305 Sema &SemaRef;
14306
14307 public:
14309 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14310 }
14311
14313 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14314 }
14315 };
14316
14319 SatisfactionStack.swap(NewSS);
14320 }
14321
14322 /// Check whether the given expression is a valid constraint expression.
14323 /// A diagnostic is emitted if it is not, false is returned, and
14324 /// PossibleNonPrimary will be set to true if the failure might be due to a
14325 /// non-primary expression being used as an atomic constraint.
14326 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
14327 bool *PossibleNonPrimary = nullptr,
14328 bool IsTrailingRequiresClause = false);
14329
14330 /// \brief Check whether the given list of constraint expressions are
14331 /// satisfied (as if in a 'conjunction') given template arguments.
14332 /// \param Template the template-like entity that triggered the constraints
14333 /// check (either a concept or a constrained entity).
14334 /// \param ConstraintExprs a list of constraint expressions, treated as if
14335 /// they were 'AND'ed together.
14336 /// \param TemplateArgLists the list of template arguments to substitute into
14337 /// the constraint expression.
14338 /// \param TemplateIDRange The source range of the template id that
14339 /// caused the constraints check.
14340 /// \param Satisfaction if true is returned, will contain details of the
14341 /// satisfaction, with enough information to diagnose an unsatisfied
14342 /// expression.
14343 /// \returns true if an error occurred and satisfaction could not be checked,
14344 /// false otherwise.
14346 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14347 const MultiLevelTemplateArgumentList &TemplateArgLists,
14348 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
14350 return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted,
14351 TemplateArgLists, TemplateIDRange,
14352 Satisfaction);
14353 }
14354
14355 /// \brief Check whether the given list of constraint expressions are
14356 /// satisfied (as if in a 'conjunction') given template arguments.
14357 /// Additionally, takes an empty list of Expressions which is populated with
14358 /// the instantiated versions of the ConstraintExprs.
14359 /// \param Template the template-like entity that triggered the constraints
14360 /// check (either a concept or a constrained entity).
14361 /// \param ConstraintExprs a list of constraint expressions, treated as if
14362 /// they were 'AND'ed together.
14363 /// \param ConvertedConstraints a out parameter that will get populated with
14364 /// the instantiated version of the ConstraintExprs if we successfully checked
14365 /// satisfaction.
14366 /// \param TemplateArgList the multi-level list of template arguments to
14367 /// substitute into the constraint expression. This should be relative to the
14368 /// top-level (hence multi-level), since we need to instantiate fully at the
14369 /// time of checking.
14370 /// \param TemplateIDRange The source range of the template id that
14371 /// caused the constraints check.
14372 /// \param Satisfaction if true is returned, will contain details of the
14373 /// satisfaction, with enough information to diagnose an unsatisfied
14374 /// expression.
14375 /// \returns true if an error occurred and satisfaction could not be checked,
14376 /// false otherwise.
14378 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14379 llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
14380 const MultiLevelTemplateArgumentList &TemplateArgList,
14381 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
14382
14383 /// \brief Check whether the given non-dependent constraint expression is
14384 /// satisfied. Returns false and updates Satisfaction with the satisfaction
14385 /// verdict if successful, emits a diagnostic and returns true if an error
14386 /// occurred and satisfaction could not be determined.
14387 ///
14388 /// \returns true if an error occurred, false otherwise.
14389 bool CheckConstraintSatisfaction(const Expr *ConstraintExpr,
14390 ConstraintSatisfaction &Satisfaction);
14391
14392 /// Check whether the given function decl's trailing requires clause is
14393 /// satisfied, if any. Returns false and updates Satisfaction with the
14394 /// satisfaction verdict if successful, emits a diagnostic and returns true if
14395 /// an error occurred and satisfaction could not be determined.
14396 ///
14397 /// \returns true if an error occurred, false otherwise.
14399 ConstraintSatisfaction &Satisfaction,
14400 SourceLocation UsageLoc = SourceLocation(),
14401 bool ForOverloadResolution = false);
14402
14403 // Calculates whether two constraint expressions are equal irrespective of a
14404 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
14405 // 'New', which are the "source" of the constraint, since this is necessary
14406 // for figuring out the relative 'depth' of the constraint. The depth of the
14407 // 'primary template' and the 'instantiated from' templates aren't necessarily
14408 // the same, such as a case when one is a 'friend' defined in a class.
14410 const Expr *OldConstr,
14411 const TemplateCompareNewDeclInfo &New,
14412 const Expr *NewConstr);
14413
14414 // Calculates whether the friend function depends on an enclosing template for
14415 // the purposes of [temp.friend] p9.
14417
14418 /// \brief Ensure that the given template arguments satisfy the constraints
14419 /// associated with the given template, emitting a diagnostic if they do not.
14420 ///
14421 /// \param Template The template to which the template arguments are being
14422 /// provided.
14423 ///
14424 /// \param TemplateArgs The converted, canonicalized template arguments.
14425 ///
14426 /// \param TemplateIDRange The source range of the template id that
14427 /// caused the constraints check.
14428 ///
14429 /// \returns true if the constrains are not satisfied or could not be checked
14430 /// for satisfaction, false if the constraints are satisfied.
14432 TemplateDecl *Template,
14433 const MultiLevelTemplateArgumentList &TemplateArgs,
14434 SourceRange TemplateIDRange);
14435
14437 SourceLocation PointOfInstantiation, FunctionDecl *Decl,
14438 ArrayRef<TemplateArgument> TemplateArgs,
14439 ConstraintSatisfaction &Satisfaction);
14440
14441 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14442 /// unsatisfied.
14443 /// \param First whether this is the first time an unsatisfied constraint is
14444 /// diagnosed for this error.
14446 bool First = true);
14447
14448 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14449 /// unsatisfied.
14450 void
14452 bool First = true);
14453
14455 NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints);
14456
14457 /// \brief Check whether the given declaration's associated constraints are
14458 /// at least as constrained than another declaration's according to the
14459 /// partial ordering of constraints.
14460 ///
14461 /// \param Result If no error occurred, receives the result of true if D1 is
14462 /// at least constrained than D2, and false otherwise.
14463 ///
14464 /// \returns true if an error occurred, false otherwise.
14467 bool &Result);
14468
14469 /// If D1 was not at least as constrained as D2, but would've been if a pair
14470 /// of atomic constraints involved had been declared in a concept and not
14471 /// repeated in two separate places in code.
14472 /// \returns true if such a diagnostic was emitted, false otherwise.
14476
14477private:
14478 /// Caches pairs of template-like decls whose associated constraints were
14479 /// checked for subsumption and whether or not the first's constraints did in
14480 /// fact subsume the second's.
14481 llvm::DenseMap<std::pair<NamedDecl *, NamedDecl *>, bool> SubsumptionCache;
14482 /// Caches the normalized associated constraints of declarations (concepts or
14483 /// constrained declarations). If an error occurred while normalizing the
14484 /// associated constraints of the template or concept, nullptr will be cached
14485 /// here.
14486 llvm::DenseMap<NamedDecl *, NormalizedConstraint *> NormalizationCache;
14487
14488 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
14489 SatisfactionCache;
14490
14491 // The current stack of constraint satisfactions, so we can exit-early.
14493
14494 /// Introduce the instantiated captures of the lambda into the local
14495 /// instantiation scope.
14496 bool addInstantiatedCapturesToScope(
14497 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14499 const MultiLevelTemplateArgumentList &TemplateArgs);
14500
14501 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in
14502 /// the case of lambdas) set up the LocalInstantiationScope of the current
14503 /// function.
14504 bool
14505 SetupConstraintScope(FunctionDecl *FD,
14506 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14507 const MultiLevelTemplateArgumentList &MLTAL,
14509
14510 /// Used during constraint checking, sets up the constraint template argument
14511 /// lists, and calls SetupConstraintScope to set up the
14512 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
14513 std::optional<MultiLevelTemplateArgumentList>
14514 SetupConstraintCheckingTemplateArgumentsAndScope(
14515 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14517
14518 ///@}
14519
14520 //
14521 //
14522 // -------------------------------------------------------------------------
14523 //
14524 //
14525
14526 /// \name Types
14527 /// Implementations are in SemaType.cpp
14528 ///@{
14529
14530public:
14531 /// A mapping that describes the nullability we've seen in each header file.
14533
14534 static int getPrintable(int I) { return I; }
14535 static unsigned getPrintable(unsigned I) { return I; }
14536 static bool getPrintable(bool B) { return B; }
14537 static const char *getPrintable(const char *S) { return S; }
14538 static StringRef getPrintable(StringRef S) { return S; }
14539 static const std::string &getPrintable(const std::string &S) { return S; }
14540 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
14541 return II;
14542 }
14544 static QualType getPrintable(QualType T) { return T; }
14545 static SourceRange getPrintable(SourceRange R) { return R; }
14547 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
14549
14550 enum class CompleteTypeKind {
14551 /// Apply the normal rules for complete types. In particular,
14552 /// treat all sizeless types as incomplete.
14553 Normal,
14554
14555 /// Relax the normal rules for complete types so that they include
14556 /// sizeless built-in types.
14558
14559 // FIXME: Eventually we should flip the default to Normal and opt in
14560 // to AcceptSizeless rather than opt out of it.
14562 };
14563
14565 const DeclSpec *DS = nullptr);
14567 const DeclSpec *DS = nullptr);
14568
14569 /// Build a pointer type.
14570 ///
14571 /// \param T The type to which we'll be building a pointer.
14572 ///
14573 /// \param Loc The location of the entity whose type involves this
14574 /// pointer type or, if there is no such entity, the location of the
14575 /// type that will have pointer type.
14576 ///
14577 /// \param Entity The name of the entity that involves the pointer
14578 /// type, if known.
14579 ///
14580 /// \returns A suitable pointer type, if there are no
14581 /// errors. Otherwise, returns a NULL type.
14583 DeclarationName Entity);
14584
14585 /// Build a reference type.
14586 ///
14587 /// \param T The type to which we'll be building a reference.
14588 ///
14589 /// \param Loc The location of the entity whose type involves this
14590 /// reference type or, if there is no such entity, the location of the
14591 /// type that will have reference type.
14592 ///
14593 /// \param Entity The name of the entity that involves the reference
14594 /// type, if known.
14595 ///
14596 /// \returns A suitable reference type, if there are no
14597 /// errors. Otherwise, returns a NULL type.
14599 DeclarationName Entity);
14600
14601 /// Build an array type.
14602 ///
14603 /// \param T The type of each element in the array.
14604 ///
14605 /// \param ASM C99 array size modifier (e.g., '*', 'static').
14606 ///
14607 /// \param ArraySize Expression describing the size of the array.
14608 ///
14609 /// \param Brackets The range from the opening '[' to the closing ']'.
14610 ///
14611 /// \param Entity The name of the entity that involves the array
14612 /// type, if known.
14613 ///
14614 /// \returns A suitable array type, if there are no errors. Otherwise,
14615 /// returns a NULL type.
14617 unsigned Quals, SourceRange Brackets,
14618 DeclarationName Entity);
14620
14621 /// Build an ext-vector type.
14622 ///
14623 /// Run the required checks for the extended vector type.
14625 SourceLocation AttrLoc);
14626 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
14627 SourceLocation AttrLoc);
14628
14630 Expr *CountExpr,
14631 bool CountInBytes,
14632 bool OrNull);
14633
14634 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
14635 /// expression is uninstantiated. If instantiated it will apply the
14636 /// appropriate address space to the type. This function allows dependent
14637 /// template variables to be used in conjunction with the address_space
14638 /// attribute
14639 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
14640 SourceLocation AttrLoc);
14641
14642 /// Same as above, but constructs the AddressSpace index if not provided.
14644 SourceLocation AttrLoc);
14645
14647
14649
14650 /// Build a function type.
14651 ///
14652 /// This routine checks the function type according to C++ rules and
14653 /// under the assumption that the result type and parameter types have
14654 /// just been instantiated from a template. It therefore duplicates
14655 /// some of the behavior of GetTypeForDeclarator, but in a much
14656 /// simpler form that is only suitable for this narrow use case.
14657 ///
14658 /// \param T The return type of the function.
14659 ///
14660 /// \param ParamTypes The parameter types of the function. This array
14661 /// will be modified to account for adjustments to the types of the
14662 /// function parameters.
14663 ///
14664 /// \param Loc The location of the entity whose type involves this
14665 /// function type or, if there is no such entity, the location of the
14666 /// type that will have function type.
14667 ///
14668 /// \param Entity The name of the entity that involves the function
14669 /// type, if known.
14670 ///
14671 /// \param EPI Extra information about the function type. Usually this will
14672 /// be taken from an existing function with the same prototype.
14673 ///
14674 /// \returns A suitable function type, if there are no errors. The
14675 /// unqualified type will always be a FunctionProtoType.
14676 /// Otherwise, returns a NULL type.
14680
14681 /// Build a member pointer type \c T Class::*.
14682 ///
14683 /// \param T the type to which the member pointer refers.
14684 /// \param Class the class type into which the member pointer points.
14685 /// \param Loc the location where this type begins
14686 /// \param Entity the name of the entity that will have this member pointer
14687 /// type
14688 ///
14689 /// \returns a member pointer type, if successful, or a NULL type if there was
14690 /// an error.
14693
14694 /// Build a block pointer type.
14695 ///
14696 /// \param T The type to which we'll be building a block pointer.
14697 ///
14698 /// \param Loc The source location, used for diagnostics.
14699 ///
14700 /// \param Entity The name of the entity that involves the block pointer
14701 /// type, if known.
14702 ///
14703 /// \returns A suitable block pointer type, if there are no
14704 /// errors. Otherwise, returns a NULL type.
14706 DeclarationName Entity);
14707
14708 /// Build a paren type including \p T.
14711
14712 /// Build a Read-only Pipe type.
14713 ///
14714 /// \param T The type to which we'll be building a Pipe.
14715 ///
14716 /// \param Loc We do not use it for now.
14717 ///
14718 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14719 /// a NULL type.
14721
14722 /// Build a Write-only Pipe type.
14723 ///
14724 /// \param T The type to which we'll be building a Pipe.
14725 ///
14726 /// \param Loc We do not use it for now.
14727 ///
14728 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14729 /// a NULL type.
14731
14732 /// Build a bit-precise integer type.
14733 ///
14734 /// \param IsUnsigned Boolean representing the signedness of the type.
14735 ///
14736 /// \param BitWidth Size of this int type in bits, or an expression
14737 /// representing that.
14738 ///
14739 /// \param Loc Location of the keyword.
14740 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
14741
14742 /// GetTypeForDeclarator - Convert the type for the specified
14743 /// declarator to Type instances.
14744 ///
14745 /// The result of this call will never be null, but the associated
14746 /// type may be a null type if there's an unrecoverable error.
14749
14750 /// Package the given type and TSI into a ParsedType.
14753 TypeSourceInfo **TInfo = nullptr);
14754
14756
14757 // Check whether the size of array element of type \p EltTy is a multiple of
14758 // its alignment and return false if it isn't.
14760
14761 void
14762 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
14763 SourceLocation FallbackLoc,
14764 SourceLocation ConstQualLoc = SourceLocation(),
14765 SourceLocation VolatileQualLoc = SourceLocation(),
14766 SourceLocation RestrictQualLoc = SourceLocation(),
14767 SourceLocation AtomicQualLoc = SourceLocation(),
14768 SourceLocation UnalignedQualLoc = SourceLocation());
14769
14770 /// Retrieve the keyword associated
14772
14773 /// Adjust the calling convention of a method to be the ABI default if it
14774 /// wasn't specified explicitly. This handles method types formed from
14775 /// function type typedefs and typename template arguments.
14776 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
14777 bool IsCtorOrDtor, SourceLocation Loc);
14778
14779 // Check if there is an explicit attribute, but only look through parens.
14780 // The intent is to look for an attribute on the current declarator, but not
14781 // one that came from a typedef.
14783
14784 /// Check whether a nullability type specifier can be added to the given
14785 /// type through some means not written in source (e.g. API notes).
14786 ///
14787 /// \param Type The type to which the nullability specifier will be
14788 /// added. On success, this type will be updated appropriately.
14789 ///
14790 /// \param Nullability The nullability specifier to add.
14791 ///
14792 /// \param DiagLoc The location to use for diagnostics.
14793 ///
14794 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
14795 /// array type (e.g., because it will decay to a pointer).
14796 ///
14797 /// \param OverrideExisting Whether to override an existing, locally-specified
14798 /// nullability specifier rather than complaining about the conflict.
14799 ///
14800 /// \returns true if nullability cannot be applied, false otherwise.
14802 NullabilityKind Nullability,
14803 SourceLocation DiagLoc,
14804 bool AllowArrayTypes,
14805 bool OverrideExisting);
14806
14807 /// Get the type of expression E, triggering instantiation to complete the
14808 /// type if necessary -- that is, if the expression refers to a templated
14809 /// static data member of incomplete array type.
14810 ///
14811 /// May still return an incomplete type if instantiation was not possible or
14812 /// if the type is incomplete for a different reason. Use
14813 /// RequireCompleteExprType instead if a diagnostic is expected for an
14814 /// incomplete expression type.
14816
14818
14819 /// Ensure that the type of the given expression is complete.
14820 ///
14821 /// This routine checks whether the expression \p E has a complete type. If
14822 /// the expression refers to an instantiable construct, that instantiation is
14823 /// performed as needed to complete its type. Furthermore
14824 /// Sema::RequireCompleteType is called for the expression's type (or in the
14825 /// case of a reference type, the referred-to type).
14826 ///
14827 /// \param E The expression whose type is required to be complete.
14828 /// \param Kind Selects which completeness rules should be applied.
14829 /// \param Diagnoser The object that will emit a diagnostic if the type is
14830 /// incomplete.
14831 ///
14832 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
14833 /// otherwise.
14835 TypeDiagnoser &Diagnoser);
14836 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
14837
14838 template <typename... Ts>
14839 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
14840 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14842 }
14843
14844 /// Retrieve a version of the type 'T' that is elaborated by Keyword,
14845 /// qualified by the nested-name-specifier contained in SS, and that is
14846 /// (re)declared by OwnedTagDecl, which is nullptr if this is not a
14847 /// (re)declaration.
14849 const CXXScopeSpec &SS, QualType T,
14850 TagDecl *OwnedTagDecl = nullptr);
14851
14852 // Returns the underlying type of a decltype with the given expression.
14854
14856 /// If AsUnevaluated is false, E is treated as though it were an evaluated
14857 /// context, such as when building a type for decltype(auto).
14858 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
14859
14860 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
14862 SourceLocation EllipsisLoc);
14863 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
14864 SourceLocation Loc, SourceLocation EllipsisLoc,
14865 bool FullySubstituted = false,
14866 ArrayRef<QualType> Expansions = {});
14867
14885
14886 /// Ensure that the type T is a literal type.
14887 ///
14888 /// This routine checks whether the type @p T is a literal type. If @p T is an
14889 /// incomplete type, an attempt is made to complete it. If @p T is a literal
14890 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
14891 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
14892 /// it the type @p T), along with notes explaining why the type is not a
14893 /// literal type, and returns true.
14894 ///
14895 /// @param Loc The location in the source that the non-literal type
14896 /// diagnostic should refer to.
14897 ///
14898 /// @param T The type that this routine is examining for literalness.
14899 ///
14900 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
14901 ///
14902 /// @returns @c true if @p T is not a literal type and a diagnostic was
14903 /// emitted, @c false otherwise.
14905 TypeDiagnoser &Diagnoser);
14906 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
14907
14908 template <typename... Ts>
14910 const Ts &...Args) {
14911 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14912 return RequireLiteralType(Loc, T, Diagnoser);
14913 }
14914
14917 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
14918 }
14919
14920 /// Ensure that the type T is a complete type.
14921 ///
14922 /// This routine checks whether the type @p T is complete in any
14923 /// context where a complete type is required. If @p T is a complete
14924 /// type, returns false. If @p T is a class template specialization,
14925 /// this routine then attempts to perform class template
14926 /// instantiation. If instantiation fails, or if @p T is incomplete
14927 /// and cannot be completed, issues the diagnostic @p diag (giving it
14928 /// the type @p T) and returns true.
14929 ///
14930 /// @param Loc The location in the source that the incomplete type
14931 /// diagnostic should refer to.
14932 ///
14933 /// @param T The type that this routine is examining for completeness.
14934 ///
14935 /// @param Kind Selects which completeness rules should be applied.
14936 ///
14937 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
14938 /// @c false otherwise.
14940 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
14942 CompleteTypeKind Kind, unsigned DiagID);
14943
14945 TypeDiagnoser &Diagnoser) {
14947 }
14950 }
14951
14952 template <typename... Ts>
14954 const Ts &...Args) {
14955 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14956 return RequireCompleteType(Loc, T, Diagnoser);
14957 }
14958
14959 /// Determine whether a declaration is visible to name lookup.
14960 bool isVisible(const NamedDecl *D) {
14961 return D->isUnconditionallyVisible() ||
14962 isAcceptableSlow(D, AcceptableKind::Visible);
14963 }
14964
14965 /// Determine whether a declaration is reachable.
14966 bool isReachable(const NamedDecl *D) {
14967 // All visible declarations are reachable.
14968 return D->isUnconditionallyVisible() ||
14969 isAcceptableSlow(D, AcceptableKind::Reachable);
14970 }
14971
14972 /// Determine whether a declaration is acceptable (visible/reachable).
14975 }
14976
14977 /// Determine if \p D and \p Suggested have a structurally compatible
14978 /// layout as described in C11 6.2.7/1.
14979 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
14980
14981 /// Determine if \p D has a visible definition. If not, suggest a declaration
14982 /// that should be made visible to expose the definition.
14983 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
14984 bool OnlyNeedComplete = false);
14986 NamedDecl *Hidden;
14987 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
14988 }
14989
14990 /// Determine if \p D has a reachable definition. If not, suggest a
14991 /// declaration that should be made reachable to expose the definition.
14992 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
14993 bool OnlyNeedComplete = false);
14995 NamedDecl *Hidden;
14996 return hasReachableDefinition(D, &Hidden);
14997 }
14998
14999 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15001 bool OnlyNeedComplete = false);
15003 NamedDecl *Hidden;
15004 return hasAcceptableDefinition(D, &Hidden, Kind);
15005 }
15006
15007private:
15008 /// The implementation of RequireCompleteType
15009 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15010 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15011
15012 /// Nullability type specifiers.
15013 IdentifierInfo *Ident__Nonnull = nullptr;
15014 IdentifierInfo *Ident__Nullable = nullptr;
15015 IdentifierInfo *Ident__Nullable_result = nullptr;
15016 IdentifierInfo *Ident__Null_unspecified = nullptr;
15017
15018 ///@}
15019
15020 //
15021 //
15022 // -------------------------------------------------------------------------
15023 //
15024 //
15025
15026 /// \name FixIt Helpers
15027 /// Implementations are in SemaFixItUtils.cpp
15028 ///@{
15029
15030public:
15031 /// Get a string to suggest for zero-initialization of a type.
15033 SourceLocation Loc) const;
15035
15036 ///@}
15037
15038 //
15039 //
15040 // -------------------------------------------------------------------------
15041 //
15042 //
15043
15044 /// \name API Notes
15045 /// Implementations are in SemaAPINotes.cpp
15046 ///@{
15047
15048public:
15049 /// Map any API notes provided for this declaration to attributes on the
15050 /// declaration.
15051 ///
15052 /// Triggered by declaration-attribute processing.
15053 void ProcessAPINotes(Decl *D);
15054
15055 ///@}
15056
15057 //
15058 //
15059 // -------------------------------------------------------------------------
15060 //
15061 //
15062
15063 /// \name Bounds Safety
15064 /// Implementations are in SemaBoundsSafety.cpp
15065 ///@{
15066public:
15067 /// Check if applying the specified attribute variant from the "counted by"
15068 /// family of attributes to FieldDecl \p FD is semantically valid. If
15069 /// semantically invalid diagnostics will be emitted explaining the problems.
15070 ///
15071 /// \param FD The FieldDecl to apply the attribute to
15072 /// \param E The count expression on the attribute
15073 /// \param[out] Decls If the attribute is semantically valid \p Decls
15074 /// is populated with TypeCoupledDeclRefInfo objects, each
15075 /// describing Decls referred to in \p E.
15076 /// \param CountInBytes If true the attribute is from the "sized_by" family of
15077 /// attributes. If the false the attribute is from
15078 /// "counted_by" family of attributes.
15079 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
15080 /// of attributes. If false the attribute does not have the
15081 /// suffix.
15082 ///
15083 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
15084 /// \p CountInBytes and \p OrNull both being true indicates the
15085 /// `counted_by_or_null` attribute.
15086 ///
15087 /// \returns false iff semantically valid.
15089 FieldDecl *FD, Expr *E,
15090 llvm::SmallVectorImpl<TypeCoupledDeclRefInfo> &Decls, bool CountInBytes,
15091 bool OrNull);
15092
15093 ///@}
15094};
15095
15096DeductionFailureInfo
15098 sema::TemplateDeductionInfo &Info);
15099
15100/// Contains a late templated function.
15101/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15104 /// The template function declaration to be late parsed.
15106 /// Floating-point options in the point of definition.
15108};
15109
15110template <>
15112 PragmaMsStackAction Action,
15113 llvm::StringRef StackSlotLabel,
15115} // end namespace clang
15116
15117#endif
This file provides AST data structures related to concepts.
#define V(N, I)
Definition: ASTContext.h:3338
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
Provides LLVM's BitmaskEnum facility to enumeration types declared in namespace clang.
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
const LambdaCapture * Capture
Expr * E
enum clang::sema::@1651::IndirectLocalPathEntry::EntryKind Kind
llvm::APSInt APSInt
Definition: Compiler.cpp:22
Defines the C++ template declaration subclasses.
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:2993
StringRef Identifier
Definition: Format.cpp:2997
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
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.
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:1143
AccessResult
A copy of Sema's enum without AR_delayed.
Definition: SemaAccess.cpp:31
CastType
Definition: SemaCast.cpp:49
SourceRange Range
Definition: SemaObjC.cpp:757
SourceLocation Loc
Definition: SemaObjC.cpp:758
Sema::AllowedExplicit AllowedExplicit
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TemplateNameKind enum.
Defines the clang::TypeLoc interface and its subclasses.
Allows QualTypes to be sorted and hence used in maps and sets.
Defines enumerations for the type traits support.
TypePropertyCache< Private > Cache
Definition: Type.cpp:4476
SourceLocation Begin
StateNode * Previous
std::string Label
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:186
CanQualType BoolTy
Definition: ASTContext.h:1119
CanQualType IntTy
Definition: ASTContext.h:1127
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:366
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:3540
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:5991
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:6368
Represents a C++ declaration that introduces decls from somewhere else.
Definition: DeclCXX.h:3417
A binding in a decomposition declaration.
Definition: DeclCXX.h:4107
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4467
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:2535
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2862
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2300
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2497
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2799
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2060
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:4666
CaseStmt - Represent a case statement.
Definition: Stmt.h:1806
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:3598
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4523
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:1358
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1425
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:825
SourceLocation getLocation() const
Definition: DeclBase.h:445
DeclContext * getDeclContext()
Definition: DeclBase.h:454
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:897
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:1900
A decomposition declaration.
Definition: DeclCXX.h:4166
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:3270
Represents an enum.
Definition: Decl.h:3840
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:5962
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1897
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:919
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
Definition: LangOptions.h:1026
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:280
FileNullability & operator[](FileID file)
Definition: Sema.h:291
FileNullability Nullability
Definition: Sema.h:287
Represents a function declaration or definition.
Definition: Decl.h:1932
Kind kind() const
The kind of the effect.
Definition: Type.h:4714
Kind
Identifies the particular effect.
Definition: Type.h:4676
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition: Type.cpp:5115
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition: Type.h:4853
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4646
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4973
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:4304
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4278
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:3314
Describes an C or C++ initializer list.
Definition: Expr.h:5029
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:413
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:461
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:4289
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4235
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4726
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:7392
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:312
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:314
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
Definition: Sema.h:349
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:2565
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:4141
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:5936
Represents the body of a requires-expression.
Definition: DeclCXX.h:2029
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:1527
bool operator==(const AlignPackInfo &Info) const
Definition: Sema.h:1587
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:1559
unsigned getPackNumber() const
Definition: Sema.h:1577
bool IsXLStack() const
Definition: Sema.h:1585
bool IsPackSet() const
Definition: Sema.h:1579
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition: Sema.h:1533
bool IsAlignAttr() const
Definition: Sema.h:1573
bool IsPackAttr() const
Definition: Sema.h:1571
bool operator!=(const AlignPackInfo &Info) const
Definition: Sema.h:1593
AlignPackInfo(bool IsXL)
Definition: Sema.h:1537
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition: Sema.h:1544
Mode getAlignMode() const
Definition: Sema.h:1575
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:13186
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:13191
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7892
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7897
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition: Sema.h:7884
std::tuple< const Ts &... > Args
Definition: Sema.h:7881
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:8057
A RAII object to enter scope of a compound statement.
Definition: Sema.h:1009
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:1011
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:7336
bool isInvalid() const
Definition: Sema.h:7335
std::optional< bool > getKnownValue() const
Definition: Sema.h:7340
A RAII object to temporarily push a declaration context.
Definition: Sema.h:3010
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition: Sema.h:3020
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:10040
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:10045
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:5885
DefaultedComparisonKind asComparison() const
Definition: Sema.h:5917
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition: Sema.h:5894
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition: Sema.h:5922
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition: Sema.h:5897
CXXSpecialMemberKind asSpecialMember() const
Definition: Sema.h:5914
RAII class to control scope of DeferDiags.
Definition: Sema.h:9767
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition: Sema.h:9772
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition: Sema.h:1078
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:1097
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:1121
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:1090
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:1093
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:1107
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:1113
A helper class for building up ExtParameterInfos.
Definition: Sema.h:12608
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:12627
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:12615
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:13543
FPOptionsOverride getOverrides()
Definition: Sema.h:13547
FullExprArg(Sema &actions)
Definition: Sema.h:7280
ExprResult release()
Definition: Sema.h:7282
Expr * get() const
Definition: Sema.h:7284
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:13559
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:10104
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:10096
Helper class that collects exception specifications for implicitly-declared special member functions.
Definition: Sema.h:4990
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:5023
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:5016
const QualType * data() const
The set of exceptions in the exception specification.
Definition: Sema.h:5026
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
Definition: Sema.h:5032
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition: Sema.h:5039
static NameClassification DependentNonType()
Definition: Sema.h:3254
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:3264
ExprResult getExpression() const
Definition: Sema.h:3290
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:3230
static NameClassification Unknown()
Definition: Sema.h:3234
static NameClassification OverloadSet(ExprResult E)
Definition: Sema.h:3238
NameClassificationKind getKind() const
Definition: Sema.h:3288
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition: Sema.h:3282
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:3270
NamedDecl * getNonTypeDecl() const
Definition: Sema.h:3300
NameClassification(ParsedType Type)
Definition: Sema.h:3228
TemplateName getTemplateName() const
Definition: Sema.h:3305
ParsedType getType() const
Definition: Sema.h:3295
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:3312
static NameClassification NonType(NamedDecl *D)
Definition: Sema.h:3244
static NameClassification Concept(TemplateName Name)
Definition: Sema.h:3276
static NameClassification UndeclaredNonType()
Definition: Sema.h:3250
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:3258
static NameClassification Error()
Definition: Sema.h:3232
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
Definition: Sema.h:734
void operator()(sema::FunctionScopeInfo *Scope) const
Definition: Sema.cpp:2299
Whether and why a template name is required in this lookup.
Definition: Sema.h:11092
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition: Sema.h:11098
SourceLocation getTemplateKeywordLoc() const
Definition: Sema.h:11100
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition: Sema.h:11095
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:12080
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:12110
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:12088
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition: Sema.h:7909
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7914
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7911
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:8973
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:8951
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:8960
CXXMethodDecl * getMethod() const
Definition: Sema.h:8963
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:8964
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:13064
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:13092
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:13070
SourceLocation getLocation() const
Definition: Sema.h:11857
bool ContainsDecl(const NamedDecl *ND) const
Definition: Sema.h:11847
const DeclContext * getDeclContext() const
Definition: Sema.h:11853
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition: Sema.h:11831
const NamedDecl * getDecl() const
Definition: Sema.h:11845
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition: Sema.h:11830
const DeclContext * getLexicalDeclContext() const
Definition: Sema.h:11849
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:12119
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:12126
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:7233
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition: Sema.h:7237
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:535
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:14364
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:14123
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:9024
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:10888
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:1654
SemaAMDGPU & AMDGPU()
Definition: Sema.h:1139
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:6321
SmallVector< DeclaratorDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
Definition: Sema.h:3102
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
Definition: SemaDecl.cpp:6661
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:13136
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.
std::optional< ExpressionEvaluationContextRecord::InitializationContext > InnermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:7802
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:13120
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:10664
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:12637
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:803
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:2467
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:8899
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:6581
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
SmallVector< SmallVector< VTableUse, 16 >, 8 > SavedVTableUses
Definition: Sema.h:13506
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Definition: SemaDecl.cpp:9660
void PopParsingClass(ParsingClassState state)
Definition: Sema.h:6079
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:2434
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:9783
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition: Sema.cpp:989
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:6068
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:2010
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:15588
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7864
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:1557
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
Definition: SemaExpr.cpp:3578
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
Definition: SemaExpr.cpp:15265
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:7772
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:863
bool isAttrContext() const
Definition: Sema.h:6460
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
Definition: SemaDecl.cpp:15001
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Definition: SemaStmt.cpp:4375
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:7857
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:2471
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition: Sema.h:5830
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:8995
@ LookupLabel
Label name lookup.
Definition: Sema.h:9004
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:8999
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition: Sema.h:9026
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition: Sema.h:9018
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:9040
@ LookupLocalFriendName
Look up a friend of a local class.
Definition: Sema.h:9034
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition: Sema.h:9036
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:9031
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:9011
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition: Sema.h:9038
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition: Sema.h:9022
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:9007
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition: Sema.h:9014
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:9002
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition: Sema.h:9042
@ LookupAnyName
Look up any declaration with any name.
Definition: Sema.h:9044
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:407
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition: Sema.h:8939
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:4464
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:6597
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
Definition: SemaType.cpp:6424
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:2178
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
Definition: SemaDecl.cpp:5290
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
Definition: SemaExpr.cpp:19378
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:12980
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
Definition: SemaDecl.cpp:15682
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:5767
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS=nullptr)
VariadicCallType
Definition: Sema.h:2333
@ VariadicDoesNotApply
Definition: Sema.h:2338
@ VariadicFunction
Definition: Sema.h:2334
@ VariadicMethod
Definition: Sema.h:2336
@ VariadicConstructor
Definition: Sema.h:2337
@ VariadicBlock
Definition: Sema.h:2335
SemaM68k & M68k()
Definition: Sema.h:1184
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
Definition: SemaDecl.cpp:12769
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:6954
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:849
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:1073
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:3622
@ NTCUC_CopyInit
Definition: Sema.h:3632
@ NTCUC_AutoVar
Definition: Sema.h:3630
@ NTCUC_CompoundLiteral
Definition: Sema.h:3636
@ NTCUC_DefaultInitializedObject
Definition: Sema.h:3628
@ NTCUC_Assignment
Definition: Sema.h:3634
@ NTCUC_BlockCapture
Definition: Sema.h:3638
@ NTCUC_FunctionReturn
Definition: Sema.h:3626
@ NTCUC_LValueToRValueVolatile
Definition: Sema.h:3640
@ NTCUC_FunctionParam
Definition: Sema.h:3624
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:1792
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:3535
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:9483
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:7458
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:6074
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:4409
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:4606
OpaquePtr< QualType > TypeTy
Definition: Sema.h:995
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
Definition: SemaDecl.cpp:18086
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:306
void PrintContextStack()
Definition: Sema.h:13206
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:2320
bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc, StringRef Keyword)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
Definition: SemaType.cpp:2295
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:606
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:1219
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:8469
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:8474
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:8478
@ IER_Error
An error occurred.
Definition: Sema.h:8481
@ IER_Exists
The symbol exists.
Definition: Sema.h:8471
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:8938
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:15607
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:5805
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:9309
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
Definition: SemaExpr.cpp:17224
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
Definition: SemaExpr.cpp:15613
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition: Sema.h:1065
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
Definition: SemaStmt.cpp:4364
void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
Definition: SemaAttr.cpp:1320
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:6059
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:1539
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition: Sema.h:14540
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:2222
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:958
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Definition: SemaDecl.cpp:18027
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
Definition: Sema.h:4322
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:3084
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:1499
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:7488
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
Definition: SemaExpr.cpp:12000
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:248
bool hasVisibleDefinition(const NamedDecl *D)
Definition: Sema.h:14985
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:6045
void emitAndClearUnusedLocalTypedefWarnings()
Definition: Sema.cpp:1080
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:16221
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:6026
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:14880
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:947
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:1164
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:17159
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:1454
PragmaClangSectionAction
Definition: Sema.h:1489
@ PCSA_Set
Definition: Sema.h:1489
@ PCSA_Clear
Definition: Sema.h:1489
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:20110
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:312
ConditionKind
Definition: Sema.h:7355
@ 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:1042
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:14944
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:14546
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:2650
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:9614
@ 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:940
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:1453
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
Definition: Sema.h:9256
Decl * ActOnConceptDefinition(Scope *S, MultiTemplateParamsArg TemplateParameterLists, const IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr, const ParsedAttributesView &Attrs)
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition: Sema.h:10123
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition: Sema.h:10126
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition: Sema.h:10132
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition: Sema.h:10130
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:1445
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:1333
@ AR_dependent
Definition: Sema.h:1336
@ AR_accessible
Definition: Sema.h:1334
@ AR_inaccessible
Definition: Sema.h:1335
@ AR_delayed
Definition: Sema.h:1337
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:2276
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:14550
@ 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:635
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
Definition: SemaCast.cpp:3367
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:599
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition: Sema.h:6438
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:2145
QualType GetSignedSizelessVectorType(QualType V)
Definition: SemaExpr.cpp:12558
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:13123
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:997
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:7933
void deduceOpenCLAddressSpace(ValueDecl *decl)
Definition: SemaDecl.cpp:6812
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3518
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3126
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:1730
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:7845
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:14547
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:1724
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:3736
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:18182
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:2325
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:4469
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition: SemaStmt.cpp:464
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid,...
Definition: Sema.h:1801
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
Definition: SemaDecl.cpp:6202
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:16917
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:304
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Definition: SemaType.cpp:2366
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
Definition: SemaDecl.cpp:4796
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition: Sema.h:1719
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:10819
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
Definition: SemaExpr.cpp:6595
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:12191
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
Definition: SemaDecl.cpp:16422
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:2097
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext)
bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, llvm::SmallVectorImpl< TypeCoupledDeclRefInfo > &Decls, bool CountInBytes, bool OrNull)
Check if applying the specified attribute variant from the "counted by" family of attributes to Field...
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:10050
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:2423
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3475
@ 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:18105
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:18201
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition: Sema.cpp:1164
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 ...
FPOptionsOverride CurFPFeatureOverrides()
Definition: Sema.h:1731
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:1174
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
Definition: SemaExpr.cpp:7432
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:875
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:19897
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:14496
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
Definition: SemaExpr.cpp:15626
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:151
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:1429
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition: Sema.h:1239
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:15336
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16274
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:2698
StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:981
ExpressionEvaluationContextRecord & parentEvaluationContext()
Definition: Sema.h:6450
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:1547
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:779
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:11063
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
Definition: SemaDecl.cpp:3413
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition: Sema.h:11636
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition: Sema.h:11647
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:11639
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition: Sema.h:11643
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:639
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:1655
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:8933
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:1259
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
Definition: SemaExpr.cpp:1024
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:13688
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:13140
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
Definition: SemaExpr.cpp:4967
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
Definition: SemaDecl.cpp:20046
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
Definition: SemaExpr.cpp:1981
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
Definition: SemaExpr.cpp:7542
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
Definition: SemaExpr.cpp:13968
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:14988
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
Definition: SemaStmt.cpp:1057
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
ASTContext & Context
Definition: Sema.h:1002
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:7759
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:618
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:9748
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:19908
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Definition: SemaDecl.cpp:14516
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:4556
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:8944
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:7301
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
Definition: SemaType.cpp:2605
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:11397
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:5766
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:13147
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:597
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:7807
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
Definition: SemaDecl.cpp:20067
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:20233
void * SkippedDefinitionContext
Definition: Sema.h:3946
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14909
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
Definition: SemaExpr.cpp:20881
void resetFPOptions(FPOptions FPO)
Definition: Sema.h:11041
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition: Sema.h:15002
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:9602
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:14536
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Definition: SemaLookup.cpp:917
SemaObjC & ObjC()
Definition: Sema.h:1204
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:5295
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
Definition: SemaDecl.cpp:4906
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
Definition: SemaExpr.cpp:12819
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:2653
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:1134
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition: SemaDecl.cpp:71
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:7247
@ AllowFold
Definition: Sema.h:7249
@ NoFold
Definition: Sema.h:7248
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:1495
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:2683
PragmaStack< bool > StrictGuardStackCheckStack
Definition: Sema.h:1727
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:3092
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:19391
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:747
bool isImmediateFunctionContext() const
Definition: Sema.h:7784
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:2329
ASTContext & getASTContext() const
Definition: Sema.h:600
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition: SemaExpr.cpp:757
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:7264
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:15754
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:6052
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:15544
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:1127
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:18673
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:19639
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Check the redefinition in C++20 Modules.
Definition: SemaDecl.cpp:1711
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:6130
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:15062
NameClassificationKind
Describes the result of the name lookup and resolution performed by ClassifyName().
Definition: Sema.h:3177
@ NC_Unknown
This name is not a type or template in this context, but might be something else.
Definition: Sema.h:3180
@ NC_VarTemplate
The name was classified as a variable template name.
Definition: Sema.h:3207
@ NC_NonType
The name was classified as a specific non-type, non-template declaration.
Definition: Sema.h:3190
@ NC_TypeTemplate
The name was classified as a template whose specializations are types.
Definition: Sema.h:3205
@ NC_Error
Classification failed; an error has been produced.
Definition: Sema.h:3182
@ NC_FunctionTemplate
The name was classified as a function template name.
Definition: Sema.h:3209
@ NC_DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition: Sema.h:3198
@ NC_UndeclaredNonType
The name was classified as an ADL-only function name.
Definition: Sema.h:3194
@ NC_UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition: Sema.h:3211
@ NC_Keyword
The name has been typo-corrected to a keyword.
Definition: Sema.h:3184
@ NC_Type
The name was classified as a type.
Definition: Sema.h:3186
@ NC_OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition: Sema.h:3203
@ NC_Concept
The name was classified as a concept name.
Definition: Sema.h:3213
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:17580
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
Definition: SemaExpr.cpp:9491
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:1723
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: SemaStmt.cpp:4299
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:694
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:862
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:3466
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:663
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition: Sema.h:2168
ParsingClassState PushParsingClass()
Definition: Sema.h:6075
ForRangeStatus
Definition: Sema.h:10486
@ FRS_Success
Definition: Sema.h:10487
@ FRS_DiagnosticIssued
Definition: Sema.h:10489
@ FRS_NoViableFunction
Definition: Sema.h:10488
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
Definition: SemaExpr.cpp:6118
void ActOnPragmaCXLimitedRange(SourceLocation Loc, LangOptions::ComplexRangeKind Range)
ActOnPragmaCXLimitedRange - Called on well formed #pragma STDC CX_LIMITED_RANGE.
Definition: SemaAttr.cpp:1351
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
Definition: SemaExpr.cpp:3075
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:1359
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:6968
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:15594
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:645
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:8992
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:8936
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:4753
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition: Sema.h:5601
@ 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:7823
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:8678
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:9252
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:9843
@ 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:9380
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
Definition: Sema.h:930
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition: Sema.h:6063
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Definition: SemaExpr.cpp:12865
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:20211
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:908
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:5448
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:3115
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:1552
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:16773
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition: Sema.cpp:2414
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition: Sema.h:3007
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
Definition: SemaDecl.cpp:8925
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
Definition: SemaExpr.cpp:2186
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:455
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:11053
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *AArg, SourceLocation Loc, bool IsDeduced)
void setFunctionHasIndirectGoto()
Definition: Sema.cpp:2335
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:1919
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition: Sema.h:11778
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:11796
@ TPL_TemplateTemplateArgumentMatch
We are matching the template parameter lists of a template template argument against the template par...
Definition: Sema.h:11807
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:11786
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition: Sema.h:11817
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:15882
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:4460
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
Definition: Sema.cpp:1566
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9621
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:1653
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:7971
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:11113
@ 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:4343
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Definition: SemaExpr.cpp:1951
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
Definition: SemaType.cpp:1560
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:1245
AtomicArgumentOrder
Definition: Sema.h:2275
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:2164
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:1245
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:1572
SourceRange getExprRange(Expr *E) const
Definition: SemaExpr.cpp:502
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:3237
void setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called to set exception behavior for floating point operations.
Definition: SemaAttr.cpp:1327
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:2502
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
Definition: Sema.h:11046
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:743
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:3088
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:7817
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:14543
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition: Sema.h:4161
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
Definition: SemaDecl.cpp:16672
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:595
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition: Sema.h:7927
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:1048
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
Definition: SemaExpr.cpp:20141
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:83
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:2182
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:2314
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14953
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:19522
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:13869
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition: Sema.h:13889
@ UPPC_RequiresClause
Definition: Sema.h:13940
@ UPPC_UsingDeclaration
A using declaration.
Definition: Sema.h:13895
@ UPPC_IfExists
Microsoft __if_exists.
Definition: Sema.h:13922
@ UPPC_Requirement
Definition: Sema.h:13937
@ UPPC_ExceptionType
The type of an exception.
Definition: Sema.h:13913
@ UPPC_EnumeratorValue
The enumerator value.
Definition: Sema.h:13892
@ UPPC_Lambda
Lambda expression.
Definition: Sema.h:13928
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition: Sema.h:13925
@ UPPC_PartialSpecialization
Partial specialization.
Definition: Sema.h:13919
@ UPPC_Initializer
An initializer.
Definition: Sema.h:13904
@ UPPC_BaseType
The base type of a class type.
Definition: Sema.h:13874
@ UPPC_FriendDeclaration
A friend declaration.
Definition: Sema.h:13898
@ UPPC_DefaultArgument
A default argument.
Definition: Sema.h:13907
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition: Sema.h:13877
@ UPPC_Expression
An arbitrary expression.
Definition: Sema.h:13871
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition: Sema.h:13916
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition: Sema.h:13901
@ UPPC_DataMemberType
The type of a data member.
Definition: Sema.h:13880
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition: Sema.h:13886
@ UPPC_Block
Block expression.
Definition: Sema.h:13931
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition: Sema.h:13883
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition: Sema.h:13910
@ UPPC_TypeConstraint
A type constraint.
Definition: Sema.h:13934
api_notes::APINotesManager APINotes
Definition: Sema.h:1006
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:12142
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:522
const LangOptions & getLangOpts() const
Definition: Sema.h:593
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:8874
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:5392
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:1719
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12027
SourceLocation CurInitSegLoc
Definition: Sema.h:1763
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:7206
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Definition: SemaExpr.cpp:12794
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition: SemaAttr.cpp:623
SemaCodeCompletion & CodeCompletion()
Definition: Sema.h:1159
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition: Sema.h:3109
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:1209
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition: Sema.h:14317
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
Definition: SemaDecl.cpp:1386
ReuseLambdaContextDecl_t
Definition: Sema.h:6535
@ ReuseLambdaContextDecl
Definition: Sema.h:6535
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:6557
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:17255
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:6591
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
Definition: SemaDecl.cpp:1596
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:601
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
Definition: SemaExpr.cpp:2234
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:1154
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:19780
void * OpaqueParser
Definition: Sema.h:1046
Preprocessor & PP
Definition: Sema.h:1001
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:10832
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
Definition: SemaExpr.cpp:5638
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:6394
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9546
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:13940
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
Definition: Sema.h:1810
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:16548
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
Definition: SemaExpr.cpp:4682
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:1039
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:1788
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:8147
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:1964
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:7447
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:3096
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:6028
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:1194
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:14345
const LangOptions & LangOpts
Definition: Sema.h:1000
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:7463
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:15696
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:936
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:8457
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2389
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:6645
static const uint64_t MaximumAlignment
Definition: Sema.h:931
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition: Sema.h:8681
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:17276
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
Definition: SemaInit.cpp:7445
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition: SemaStmt.cpp:395
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition: Sema.h:14966
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:15176
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:6030
SemaHLSL & HLSL()
Definition: Sema.h:1169
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:11062
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:934
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:8991
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:1099
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Definition: SemaDecl.cpp:1828
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
Definition: SemaDecl.cpp:11771
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:18296
ExpressionEvaluationContextRecord & currentEvaluationContext()
Definition: Sema.h:6444
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
Definition: SemaExpr.cpp:17240
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:1500
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
SemaMIPS & MIPS()
Definition: Sema.h:1189
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition: Sema.cpp:117
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:1234
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:1477
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:5398
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:3625
QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions, IdentifierInfo *Id, bool DirectInit, Expr *&Init)
Definition: SemaLambda.cpp:783
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
Definition: SemaExpr.cpp:204
void CheckCXXDefaultArguments(FunctionDecl *FD)
Helpers for dealing with blocks and functions.
ComparisonCategoryUsage
Definition: Sema.h:4787
@ 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:13504
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition: Sema.h:6023
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:72
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:19790
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:9772
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:14538
SemaSwift & Swift()
Definition: Sema.h:1244
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:3618
PragmaStack< AlignPackInfo > AlignPackStack
Definition: Sema.h:1712
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:15640
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:6122
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:6471
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:13172
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:6056
StmtResult ActOnExprStmtError()
Definition: SemaStmt.cpp:69
AcceptableKind
Definition: Sema.h:8987
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:1722
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:3315
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:8802
DeclContext * getCurLexicalContext() const
Definition: Sema.h:807
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition: Sema.h:1057
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:1766
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:1559
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:9348
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:7983
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:858
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:997
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:13508
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Definition: SemaExpr.cpp:924
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:16748
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
Definition: Sema.h:1813
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
void ExitDeclaratorContext(Scope *S)
Definition: SemaDecl.cpp:1373
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
Definition: SemaExpr.cpp:15507
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:8286
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition: Sema.cpp:777
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
Definition: SemaStmt.cpp:4399
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:4467
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Definition: SemaDecl.cpp:12370
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition: Sema.h:14532
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:6074
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:19548
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:1033
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:2309
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:14746
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Definition: SemaDecl.cpp:2285
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:2260
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:2742
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
Definition: SemaExpr.cpp:3617
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
Definition: SemaType.cpp:1836
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it's plausible that E was intended to be a template-name.
Definition: Sema.h:3389
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:2253
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Definition: SemaDecl.cpp:20101
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:10300
bool CheckNontrivialField(FieldDecl *FD)
Definition: SemaDecl.cpp:18486
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:9543
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:1663
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition: Sema.h:6468
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:17985
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:2128
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:12649
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
Definition: SemaInit.cpp:9686
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:4420
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:8800
void LateTemplateParserCleanupCB(void *P)
Definition: Sema.h:1043
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:5388
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:635
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:13180
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:3163
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:14960
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition: Sema.h:7788
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:1762
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Definition: SemaDecl.cpp:20131
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition: Sema.h:9597
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:8820
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:7193
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:2103
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:1621
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:16068
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
Definition: SemaExpr.cpp:7583
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:15282
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:2345
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
Definition: Sema.h:6496
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:6037
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:17976
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
Definition: SemaDecl.cpp:15206
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:1137
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:7426
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:9074
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:20604
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:14786
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition: Sema.h:12143
@ VAK_Invalid
Definition: Sema.h:7543
@ VAK_Valid
Definition: Sema.h:7539
@ VAK_ValidInCXX11
Definition: Sema.h:7540
@ VAK_MSVCUndefined
Definition: Sema.h:7542
@ VAK_Undefined
Definition: Sema.h:7541
SemaOpenCL & OpenCL()
Definition: Sema.h:1214
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:5771
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:13517
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9582
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:16430
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition: Sema.h:1888
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
Definition: SemaDecl.cpp:15043
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
Definition: SemaType.cpp:3742
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:14548
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:7829
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:5869
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:5871
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition: Sema.h:5874
FormatArgumentPassingKind
Definition: Sema.h:2178
@ FAPK_Fixed
Definition: Sema.h:2179
@ FAPK_Variadic
Definition: Sema.h:2180
@ FAPK_VAList
Definition: Sema.h:2181
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:19843
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:7780
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:12640
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition: Sema.cpp:1527
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, NamedReturnInfo &NRInfo, bool SupressSimplerImplicitMoves)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes.
Definition: SemaStmt.cpp:3412
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:8985
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition: Sema.h:7583
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition: Sema.h:7627
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition: Sema.h:7593
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:7651
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:7656
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition: Sema.h:7643
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:7622
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition: Sema.h:7601
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition: Sema.h:7660
@ Compatible
Compatible - the types are compatible according to the standard.
Definition: Sema.h:7585
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition: Sema.h:7612
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition: Sema.h:7664
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:7597
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition: Sema.h:7606
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:7618
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition: Sema.h:7639
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition: Sema.h:7633
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition: Sema.h:7589
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:7647
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:8327
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1287
StmtResult ActOnCapturedRegionEnd(Stmt *S)
Definition: SemaStmt.cpp:4571
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition: Sema.h:7402
@ ACK_Arithmetic
An arithmetic operation.
Definition: Sema.h:7404
@ ACK_CompAssign
A compound assignment expression.
Definition: Sema.h:7412
@ ACK_BitwiseOp
A bitwise operation.
Definition: Sema.h:7406
@ ACK_Conditional
A conditional (?:) operator.
Definition: Sema.h:7410
@ ACK_Comparison
A comparison.
Definition: Sema.h:7408
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
Definition: SemaDecl.cpp:4698
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
Definition: SemaExpr.cpp:19739
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
Definition: SemaDecl.cpp:15615
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:14973
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:9397
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:2870
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:2164
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:3141
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
Definition: Sema.h:7982
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:4081
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16515
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:3106
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition: Sema.h:6283
bool MSStructPragmaOn
Definition: Sema.h:1474
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:20694
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Definition: SemaType.cpp:9007
ExprResult TransformToPotentiallyEvaluated(Expr *E)
Definition: SemaExpr.cpp:17139
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:13156
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:15664
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:10900
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:13471
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:3839
@ NTK_Typedef
Definition: Sema.h:3844
@ NTK_NonUnion
Definition: Sema.h:3842
@ NTK_TypeAlias
Definition: Sema.h:3845
@ NTK_NonClass
Definition: Sema.h:3841
@ NTK_NonEnum
Definition: Sema.h:3843
@ NTK_NonStruct
Definition: Sema.h:3840
@ NTK_TemplateTemplateArgument
Definition: Sema.h:3848
@ NTK_TypeAliasTemplate
Definition: Sema.h:3847
@ NTK_Template
Definition: Sema.h:3846
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition: Sema.h:14948
SourceManager & getSourceManager() const
Definition: Sema.h:598
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
Definition: SemaModule.cpp:727
TryCaptureKind
Definition: Sema.h:6597
@ TryCapture_Implicit
Definition: Sema.h:6598
@ TryCapture_ExplicitByVal
Definition: Sema.h:6599
@ TryCapture_ExplicitByRef
Definition: Sema.h:6600
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9598
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition: Sema.h:8053
AssignmentAction
Definition: Sema.h:6479
@ AA_Returning
Definition: Sema.h:6482
@ AA_Passing_CFAudited
Definition: Sema.h:6487
@ AA_Initializing
Definition: Sema.h:6484
@ AA_Converting
Definition: Sema.h:6483
@ AA_Assigning
Definition: Sema.h:6480
@ AA_Passing
Definition: Sema.h:6481
@ AA_Casting
Definition: Sema.h:6486
@ AA_Sending
Definition: Sema.h:6485
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:4398
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:6623
bool CheckVecStepExpr(Expr *E)
Definition: SemaExpr.cpp:4362
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
Definition: Sema.cpp:571
bool isModuleVisible(const Module *M, bool ModulePrivate=false)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
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:3059
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:4268
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:874
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
Definition: SemaDecl.cpp:19803
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:1338
void diagnoseFunctionEffectConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn when implicitly changing function effects.
Definition: Sema.cpp:634
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:11889
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:11063
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:3372
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:8691
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:12570
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:544
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
Definition: SemaExpr.cpp:10475
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:8979
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
Definition: SemaExpr.cpp:19355
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Definition: SemaType.cpp:9502
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13527
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:17962
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:12075
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:1501
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:6989
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:3650
@ NTCUK_Destruct
Definition: Sema.h:3652
@ NTCUK_Init
Definition: Sema.h:3651
@ NTCUK_Copy
Definition: Sema.h:3653
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:1074
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:1284
QualType BuildAtomicType(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:9785
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:1498
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Definition: SemaExpr.cpp:19978
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Definition: SemaDecl.cpp:15692
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
Definition: SemaExpr.cpp:5441
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:8775
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:13742
bool anyAltivecTypes(QualType srcType, QualType destType)
Definition: SemaExpr.cpp:7477
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:7514
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute.
Definition: SemaAttr.cpp:1364
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:1226
void keepInLifetimeExtendingContext()
keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext flag from previous context.
Definition: Sema.h:7835
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:2334
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition: Sema.cpp:2176
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:20074
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:1711
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:6340
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
MaybeODRUseExprSet MaybeODRUseExprs
Definition: Sema.h:6281
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:603
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:944
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:1769
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:8412
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:215
static SourceRange getPrintable(SourceRange R)
Definition: Sema.h:14545
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:20058
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:8170
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:2030
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:14282
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:3779
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition: Sema.h:14915
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition: Sema.h:813
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:15049
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
Definition: Sema.cpp:2704
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:1860
void setFunctionHasMustTail()
Definition: Sema.cpp:2340
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:965
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:7616
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:7978
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
CorrectTypoKind
Definition: Sema.h:9391
@ CTK_NonError
Definition: Sema.h:9392
@ CTK_ErrorRecovery
Definition: Sema.h:9393
void CheckCompleteVariableDeclaration(VarDecl *VD)
Definition: SemaDecl.cpp:14152
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
Definition: SemaInit.cpp:3441
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
TUFragmentKind
Definition: Sema.h:684
@ Global
The global module fragment, between 'module;' and a module-declaration.
Definition: Sema.h:686
@ Private
The private module fragment, between 'module :private;' and the end of the translation unit.
Definition: Sema.h:693
@ Normal
A normal translation unit fragment.
Definition: Sema.h:690
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
void PopSatisfactionStackEntry()
Definition: Sema.h:14288
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
Definition: SemaType.cpp:1784
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:14671
void setFunctionHasBranchProtectedScope()
Definition: Sema.cpp:2330
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition: Sema.h:14994
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:4459
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:2170
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:6048
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
Definition: SemaStmt.cpp:4357
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:590
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:14298
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:3181
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9565
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:1093
CCEKind
Contexts in which a converted constant expression is required.
Definition: Sema.h:10007
@ CCEK_StaticAssertMessageSize
Call to size() in a static assert message.
Definition: Sema.h:10014
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
Definition: Sema.h:10012
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
Definition: Sema.h:10013
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:10011
@ CCEK_CaseValue
Expression in a case label.
Definition: Sema.h:10008
@ CCEK_TemplateArg
Value of a non-type template parameter.
Definition: Sema.h:10010
@ CCEK_StaticAssertMessageData
Call to data() in a static assert message.
Definition: Sema.h:10016
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
Definition: Sema.h:10009
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:2592
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:1740
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:18549
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:10923
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:1121
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
Definition: SemaDecl.cpp:3077
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:1891
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition: Sema.h:3080
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:287
ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Definition: SemaDecl.cpp:19341
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
Definition: Sema.h:1265
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
Definition: SemaDecl.cpp:12405
ASTConsumer & Consumer
Definition: Sema.h:1003
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:4224
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
OverloadKind
Definition: Sema.h:9785
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
Definition: Sema.h:9796
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:9788
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:9792
PragmaAlignPackDiagnoseKind
Definition: Sema.h:1866
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:6475
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition: SemaExpr.cpp:120
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
Definition: SemaDecl.cpp:2048
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:1038
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
Definition: Sema.cpp:1670
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition: Sema.h:13500
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Definition: SemaExpr.cpp:5090
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:7271
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:9624
@ 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:14544
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Definition: SemaExpr.cpp:3514
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData)
Definition: SemaExpr.cpp:16556
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
Definition: SemaExpr.cpp:12515
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition: Sema.cpp:87
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
Definition: SemaStmt.cpp:4387
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition: Sema.h:967
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:8317
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
Definition: SemaDecl.cpp:16353
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition: Sema.h:6225
@ 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:9470
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
Definition: Sema.h:13164
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:9729
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition: Sema.h:4383
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
Definition: Sema.h:4389
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition: Sema.h:4393
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition: Sema.h:4386
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition: Sema.h:4040
@ AMK_None
Don't merge availability attributes at all.
Definition: Sema.h:4042
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition: Sema.h:4048
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:4051
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition: Sema.h:4054
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition: Sema.h:4045
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
Definition: SemaDecl.cpp:14790
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Parse a __builtin_astype expression.
Definition: SemaExpr.cpp:6616
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4337
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
Definition: SemaExpr.cpp:4588
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
Definition: SemaType.cpp:5645
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
Definition: SemaDecl.cpp:14459
ExprResult BuildOperatorCoawaitLookupExpr(Scope *S, SourceLocation Loc)
std::pair< SourceLocation, bool > DeleteExprLoc
Definition: Sema.h:644
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:19984
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
Definition: SemaExpr.cpp:4199
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:16957
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:4776
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:1224
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:2189
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16267
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:399
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
Definition: SemaType.cpp:5758
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:4457
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:8885
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Definition: SemaDecl.cpp:15128
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:963
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:1334
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:14290
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
Definition: SemaExpr.cpp:20624
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:1044
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:18795
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:18989
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Definition: SemaExpr.cpp:7651
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:1373
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Delete-expressions to be analyzed at the end of translation unit.
Definition: Sema.h:7989
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:10924
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:3099
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition: Sema.h:9764
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:7299
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:7770
SemaSystemZ & SystemZ()
Definition: Sema.h:1249
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition: Sema.cpp:101
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:2726
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:17658
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9610
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
Definition: SemaExpr.cpp:18981
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:7930
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
Definition: SemaDecl.cpp:1306
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
Definition: SemaExpr.cpp:7563
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:9610
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
Definition: SemaType.cpp:8860
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
Definition: SemaStmt.cpp:623
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9636
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition: Sema.h:1005
TemplateNameIsRequiredTag
Definition: Sema.h:11090
@ TemplateNameIsRequired
Definition: Sema.h:11090
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:4674
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
Definition: SemaExpr.cpp:7724
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:5724
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:15749
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:6041
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:2375
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Definition: Sema.h:9076
DiagnosticsEngine & Diags
Definition: Sema.h:1004
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
Definition: SemaLambda.cpp:972
void DiagnoseUnterminatedPragmaAlignPack()
Definition: SemaAttr.cpp:488
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope)
Definition: SemaStmt.cpp:3208
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:7305
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:594
FPOptions CurFPFeatures
Definition: Sema.h:998
void ActOnStartSEHFinallyBlock()
Definition: SemaStmt.cpp:4349
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
static bool CanBeGetReturnObject(const FunctionDecl *FD)
Definition: SemaDecl.cpp:15745
NamespaceDecl * getStdNamespace() const
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9574
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition: Sema.h:6032
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:6614
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
Definition: SemaType.cpp:2027
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Definition: SemaExpr.cpp:511
PragmaStack< StringLiteral * > DataSegStack
Definition: Sema.h:1721
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:690
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:1045
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:7500
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:9616
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Definition: SemaDecl.cpp:7183
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:14821
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:11278
@ TPC_ClassTemplate
Definition: Sema.h:11279
@ TPC_FriendFunctionTemplate
Definition: Sema.h:11284
@ TPC_ClassTemplateMember
Definition: Sema.h:11282
@ TPC_FunctionTemplate
Definition: Sema.h:11281
@ TPC_FriendClassTemplate
Definition: Sema.h:11283
@ TPC_FriendFunctionTemplateDefinition
Definition: Sema.h:11285
@ TPC_TypeAliasTemplate
Definition: Sema.h:11286
@ TPC_VarTemplate
Definition: Sema.h:11280
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
Definition: SemaAttr.cpp:1249
void ActOnAbortSEHFinallyBlock()
Definition: SemaStmt.cpp:4353
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:6698
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
Definition: SemaDecl.cpp:16208
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:1763
SemaAVR & AVR()
Definition: Sema.h:1149
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:13622
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5515
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:20027
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:1797
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:2066
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
friend class ArgumentPackSubstitutionRAII
Definition: Sema.h:13201
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:1911
void PopDeclContext()
Definition: SemaDecl.cpp:1313
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:2843
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:12916
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:6060
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition: Sema.h:13131
void PrintStats() const
Print out statistics about the semantic analysis.
Definition: Sema.cpp:610
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
Definition: SemaExpr.cpp:15621
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:14535
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:979
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:5995
FormatStringType
Definition: Sema.h:2207
@ FST_NSString
Definition: Sema.h:2210
@ FST_Unknown
Definition: Sema.h:2217
@ FST_Strftime
Definition: Sema.h:2211
@ FST_Printf
Definition: Sema.h:2209
@ FST_FreeBSDKPrintf
Definition: Sema.h:2214
@ FST_Scanf
Definition: Sema.h:2208
@ FST_Strfmon
Definition: Sema.h:2212
@ FST_OSLog
Definition: Sema.h:2216
@ FST_Kprintf
Definition: Sema.h:2213
@ FST_OSTrace
Definition: Sema.h:2215
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:1472
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:1577
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:12631
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:949
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:1915
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:10754
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition: Sema.h:10762
@ BFRK_Build
Initial building of a for-range statement.
Definition: Sema.h:10756
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:10759
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
Definition: SemaExpr.cpp:8794
SemaNVPTX & NVPTX()
Definition: Sema.h:1199
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:4066
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:13784
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:12951
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:1562
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
Definition: SemaDecl.cpp:16616
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:9484
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
Definition: Sema.cpp:2372
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition: SemaStmt.cpp:547
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:16078
OffsetOfKind
Definition: Sema.h:3863
@ OOK_Outside
Definition: Sema.h:3865
@ OOK_Macro
Definition: Sema.h:3870
@ OOK_Builtin
Definition: Sema.h:3867
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
Definition: SemaDecl.cpp:13224
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
Definition: SemaType.cpp:9357
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
PragmaSectionKind
Definition: Sema.h:1741
@ PSK_ConstSeg
Definition: Sema.h:1744
@ PSK_DataSeg
Definition: Sema.h:1742
@ PSK_CodeSeg
Definition: Sema.h:1745
@ PSK_BSSSeg
Definition: Sema.h:1743
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:566
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Definition: SemaExpr.cpp:19761
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Definition: Sema.cpp:596
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:16584
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:5804
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:18193
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:17839
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
Definition: SemaExpr.cpp:15665
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:4727
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
Definition: SemaDecl.cpp:4304
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:14069
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:5881
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
Definition: SemaLambda.cpp:281
void diagnoseFunctionEffectMergeConflicts(const FunctionEffectSet::Conflicts &Errs, SourceLocation NewLoc, SourceLocation OldLoc)
Definition: SemaDecl.cpp:20223
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
Definition: SemaType.cpp:2426
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
Definition: SemaExpr.cpp:20083
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:3074
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition: Sema.cpp:1947
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:20889
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:4698
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:8914
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15112
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:1497
Decl * ActOnDeclarator(Scope *S, Declarator &D)
Definition: SemaDecl.cpp:6033
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3651
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:1061
AbstractDiagSelID
Definition: Sema.h:5750
@ AbstractSynthesizedIvarType
Definition: Sema.h:5757
@ AbstractVariableType
Definition: Sema.h:5754
@ AbstractReturnType
Definition: Sema.h:5752
@ AbstractNone
Definition: Sema.h:5751
@ AbstractFieldType
Definition: Sema.h:5755
@ AbstractArrayType
Definition: Sema.h:5758
@ AbstractParamType
Definition: Sema.h:5753
@ AbstractIvarType
Definition: Sema.h:5756
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:2943
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:908
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:7168
PragmaOptionsAlignKind
Definition: Sema.h:1836
@ POAK_Power
Definition: Sema.h:1840
@ POAK_Reset
Definition: Sema.h:1842
@ POAK_Packed
Definition: Sema.h:1839
@ POAK_Mac68k
Definition: Sema.h:1841
@ POAK_Natural
Definition: Sema.h:1838
@ POAK_Native
Definition: Sema.h:1837
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:15920
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:4800
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:1701
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition: Sema.h:7975
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:1235
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:14577
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:540
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9703
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
Definition: SemaExpr.cpp:9069
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:7997
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:6356
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:4657
QualType PreferredConditionType(ConditionKind K) const
Definition: Sema.h:7500
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:9048
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition: Sema.h:9052
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition: Sema.h:9058
@ LOLR_Error
The lookup resulted in an error.
Definition: Sema.h:9050
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:9055
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition: Sema.h:9066
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:9062
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Definition: SemaDecl.cpp:20113
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition: Sema.cpp:2360
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition: Sema.h:6456
SemaLoongArch & LoongArch()
Definition: Sema.h:1179
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Definition: SemaExpr.cpp:15949
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:10514
CheckConstexprKind
Definition: Sema.h:5945
@ 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:13496
void CheckVariableDeclarationType(VarDecl *NewVD)
Definition: SemaDecl.cpp:8498
sema::CompoundScopeInfo & getCurCompoundScope() const
Definition: SemaStmt.cpp:411
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:2718
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:994
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:558
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
Definition: SemaInit.cpp:9601
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:392
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
Definition: SemaDecl.cpp:1320
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
Definition: Sema.cpp:646
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:12917
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:1335
bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New)
Definition: SemaDecl.cpp:2433
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:2723
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:3055
void ActOnFinishOfCompoundStmt()
Definition: SemaStmt.cpp:407
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:15629
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14839
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:13203
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:10955
static ConditionResult ConditionError()
Definition: Sema.h:7342
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition: SemaStmt.cpp:415
void NoteTemplateParameterLocation(const NamedDecl &Decl)
SemaWasm & Wasm()
Definition: Sema.h:1254
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
Definition: SemaExpr.cpp:6637
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:3003
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
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:13127
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
Definition: SemaExpr.cpp:20628
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:19774
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:5741
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
Definition: SemaExpr.cpp:15863
SemaPseudoObject & PseudoObject()
Definition: Sema.h:1229
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:2321
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:572
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition: Sema.h:11055
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:4186
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:7298
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:679
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:15017
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:7938
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:993
static int getPrintable(int I)
Definition: Sema.h:14534
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.
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)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
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:9318
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:12481
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition: SemaStmt.cpp:552
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:3375
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:17666
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:14539
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:1480
@ PCSK_Invalid
Definition: Sema.h:1481
@ PCSK_BSS
Definition: Sema.h:1482
@ PCSK_Data
Definition: Sema.h:1483
@ PCSK_Text
Definition: Sema.h:1485
@ PCSK_Relro
Definition: Sema.h:1486
@ PCSK_Rodata
Definition: Sema.h:1484
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7100
void warnOnReservedIdentifier(const NamedDecl *D)
Definition: SemaDecl.cpp:6020
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition: SemaStmt.cpp:516
bool isCheckingDefaultArgumentOrInitializer() const
Definition: Sema.h:7794
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:16689
SemaARM & ARM()
Definition: Sema.h:1144
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:7351
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:14537
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:2654
AllocationFunctionScope
The scope in which to find allocation functions.
Definition: Sema.h:8172
@ AFS_Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition: Sema.h:8180
@ AFS_Class
Only look for allocation functions in the scope of the allocated class.
Definition: Sema.h:8177
@ AFS_Global
Only look for allocation functions in the global scope.
Definition: Sema.h:8174
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:5302
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:592
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Definition: SemaType.cpp:2706
PragmaMsStackAction
Definition: Sema.h:1503
@ PSK_Push_Set
Definition: Sema.h:1509
@ PSK_Reset
Definition: Sema.h:1504
@ PSK_Pop_Set
Definition: Sema.h:1510
@ PSK_Show
Definition: Sema.h:1508
@ PSK_Pop
Definition: Sema.h:1507
@ PSK_Set
Definition: Sema.h:1505
@ PSK_Push
Definition: Sema.h:1506
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3108
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:8277
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:4975
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Definition: SemaDecl.cpp:1262
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:3557
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:4430
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition: ASTConcept.h:228
Represents a declaration of a type.
Definition: Decl.h:3363
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:7714
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:2474
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3507
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3405
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:6767
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:1025
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3202
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3941
A set of unresolved declarations.
Definition: UnresolvedSet.h:62
Represents a C++ using-declaration.
Definition: DeclCXX.h:3512
Represents C++ using-directive.
Definition: DeclCXX.h:3015
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3320
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:3991
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2780
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:1883
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:477
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:333
InClassInitStyle
In-class initialization styles for non-static data members.
Definition: Specifiers.h:268
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:146
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:245
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:2824
@ 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:3537
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isFunctionOrMethodVariadic(const Decl *D)
Definition: Attr.h:112
TagUseKind
Definition: Sema.h:469
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:6683
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:1037
@ TU_Complete
The translation unit is a complete translation unit.
Definition: LangOptions.h:1039
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:1043
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:445
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:129
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:132
const FunctionProtoType * T
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition: ASTContext.h:115
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition: Specifiers.h:389
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:258
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:387
@ 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:185
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:275
@ None
The alignment was not explicit in code.
SourceLocIdentKind
Definition: Expr.h:4738
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:6658
@ 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:456
@ 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:120
@ AS_none
Definition: Specifiers.h:124
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition: Specifiers.h:170
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:90
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:262
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition: Sema.h:269
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition: Sema.h:265
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition: Sema.h:275
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition: Sema.h:272
FunctionEffect::Kind EffectKind
Definition: Sema.h:487
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:2819
StringRef effectName() const
Definition: Sema.h:492
OverrideResult
Describes the result of effects differing between a base class's virtual method and an overriding met...
Definition: Sema.h:500
FunctionEffectWithCondition Old
Definition: Sema.h:489
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:2883
FunctionEffectWithCondition New
Definition: Sema.h:490
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:2857
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition: Type.h:4791
Holds information about the various types of exception specification.
Definition: Type.h:5030
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:5032
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:5035
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:5038
Extra information about a function prototype.
Definition: Type.h:5058
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:103
Represents a complete lambda introducer.
Definition: DeclSpec.h:2832
Contains a late templated function.
Definition: Sema.h:15102
CachedTokens Toks
Definition: Sema.h:15103
FPOptions FPO
Floating-point options in the point of definition.
Definition: Sema.h:15107
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:15105
A normalized constraint, as defined in C++ [temp.constr.normal], is either an atomic constraint,...
Definition: SemaConcept.h:105
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1716
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:12654
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:12815
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:12768
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:12784
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:12810
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:12803
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition: Sema.h:12779
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:12771
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition: Sema.h:12797
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition: Sema.h:12787
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:12794
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:12656
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition: Sema.h:12748
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition: Sema.h:12666
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition: Sema.h:12675
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:12694
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition: Sema.h:12745
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:12702
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition: Sema.h:12709
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition: Sema.h:12752
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:12720
@ Memoization
Added for Template instantiation observation.
Definition: Sema.h:12758
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition: Sema.h:12685
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition: Sema.h:12764
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition: Sema.h:12761
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:12682
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:12690
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:12698
@ TemplateInstantiation
We are instantiating a template declaration.
Definition: Sema.h:12659
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition: Sema.h:12712
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition: Sema.h:12716
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition: Sema.h:12671
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:12742
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition: Sema.h:12705
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:12774
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition: Sema.h:12800
ConstraintEvalRAII(InstTy &TI)
Definition: Sema.h:13315
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition: Sema.h:6374
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:6287
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:6319
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition: Sema.h:6321
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:6311
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:6315
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition: Sema.h:6326
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:6334
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition: Sema.h:6330
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition: Sema.h:6340
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:6306
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:6344
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:6292
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:6300
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition: Sema.h:6384
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:6386
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:6289
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:6296
FormatArgumentPassingKind ArgPassingKind
Definition: Sema.h:2189
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:1022
A stack object to be created when performing template instantiation.
Definition: Sema.h:12839
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:12993
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:12997
LocalInstantiationScope * Scope
Definition: Sema.h:13615
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:13618
bool isMoveEligible() const
Definition: Sema.h:10816
bool isCopyElidable() const
Definition: Sema.h:10817
const VarDecl * Candidate
Definition: Sema.h:10811
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2810
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition: Sema.h:2816
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:2825
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:2819
SourceLocation CCLoc
The location of the '::'.
Definition: Sema.h:2822
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition: Sema.h:2813
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:2831
SourceLocation LocEnd
Definition: Sema.h:7074
IdentifierInfo * IdentInfo
Definition: Sema.h:7077
brief A function argument from which we performed template argument
Definition: Sema.h:12243
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition: Sema.h:12244
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:1772
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:1775
A push'd group of PragmaAttributeEntries.
Definition: Sema.h:1780
SourceLocation Loc
The location of the push attribute.
Definition: Sema.h:1782
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition: Sema.h:1785
const IdentifierInfo * Namespace
The namespace of this push group.
Definition: Sema.h:1784
SourceLocation PragmaLocation
Definition: Sema.h:1494
PragmaMsStackAction Action
Definition: Sema.h:1514
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:1627
llvm::StringRef StackSlotLabel
Definition: Sema.h:1623
SourceLocation PragmaLocation
Definition: Sema.h:1625
SourceLocation PragmaPushLocation
Definition: Sema.h:1626
ValueType CurrentValue
Definition: Sema.h:1697
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:1683
bool hasValue() const
Definition: Sema.h:1693
SmallVector< Slot, 2 > Stack
Definition: Sema.h:1695
ValueType DefaultValue
Definition: Sema.h:1696
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1698
PragmaStack(const ValueType &Default)
Definition: Sema.h:1690
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition: Sema.h:1634
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition: Sema.h:4640
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition: Sema.h:4634
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition: Sema.h:10140
Abstract class used to diagnose incomplete types.
Definition: Sema.h:7871
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
virtual ~TypeDiagnoser()
Definition: Sema.h:7875
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:2237
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition: Sema.h:2246
std::unique_ptr< TypoCorrectionConsumer > Consumer
Definition: Sema.h:9500
TypoDiagnosticGenerator DiagHandler
Definition: Sema.h:9501
TypoRecoveryCallback RecoveryHandler
Definition: Sema.h:9502
bool CheckSameAsPrevious
Definition: Sema.h:373
NamedDecl * Previous
Definition: Sema.h:374
SkipBodyInfo()=default
NamedDecl * New
Definition: Sema.h:375
Information about a template-id annotation token.