clang 19.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"
42#include "clang/Basic/Module.h"
50#include "clang/Sema/DeclSpec.h"
56#include "clang/Sema/Scope.h"
57#include "clang/Sema/SemaBase.h"
61#include "clang/Sema/Weak.h"
62#include "llvm/ADT/ArrayRef.h"
63#include "llvm/ADT/STLForwardCompat.h"
64#include "llvm/ADT/SetVector.h"
65#include "llvm/ADT/SmallBitVector.h"
66#include "llvm/ADT/SmallPtrSet.h"
67#include "llvm/ADT/SmallSet.h"
68#include "llvm/ADT/SmallVector.h"
69#include "llvm/ADT/TinyPtrVector.h"
70#include <deque>
71#include <memory>
72#include <optional>
73#include <string>
74#include <tuple>
75#include <vector>
76
77namespace llvm {
78class APSInt;
79template <typename ValueT, typename ValueInfoT> class DenseSet;
80class SmallBitVector;
81struct InlineAsmIdentifierInfo;
82} // namespace llvm
83
84namespace clang {
85class ADLResult;
86class ASTConsumer;
87class ASTContext;
88class ASTMutationListener;
89class ASTReader;
90class ASTWriter;
91class ArrayType;
92class ParsedAttr;
93class BindingDecl;
94class BlockDecl;
95class CapturedDecl;
96class CXXBasePath;
97class CXXBasePaths;
98class CXXBindTemporaryExpr;
100class CXXConstructorDecl;
101class CXXConversionDecl;
102class CXXDeleteExpr;
103class CXXDestructorDecl;
104class CXXFieldCollector;
105class CXXMemberCallExpr;
106class CXXMethodDecl;
107class CXXScopeSpec;
108class CXXTemporary;
109class CXXTryStmt;
110class CallExpr;
111class ClassTemplateDecl;
112class ClassTemplatePartialSpecializationDecl;
113class ClassTemplateSpecializationDecl;
114class VarTemplatePartialSpecializationDecl;
115class CodeCompleteConsumer;
116class CodeCompletionAllocator;
117class CodeCompletionTUInfo;
118class CodeCompletionResult;
119class CoroutineBodyStmt;
120class Decl;
121class DeclAccessPair;
122class DeclContext;
123class DeclRefExpr;
124class DeclaratorDecl;
125class DeducedTemplateArgument;
126class DependentDiagnostic;
127class DesignatedInitExpr;
128class Designation;
129class EnableIfAttr;
130class EnumConstantDecl;
131class Expr;
132class ExtVectorType;
133class FormatAttr;
134class FriendDecl;
135class FunctionDecl;
136class FunctionProtoType;
137class FunctionTemplateDecl;
138class ImplicitConversionSequence;
140class InitListExpr;
141class InitializationKind;
142class InitializationSequence;
143class InitializedEntity;
144class IntegerLiteral;
145class LabelStmt;
146class LambdaExpr;
147class LangOptions;
148class LocalInstantiationScope;
149class LookupResult;
150class MacroInfo;
152class ModuleLoader;
153class MultiLevelTemplateArgumentList;
154class NamedDecl;
155class ObjCImplementationDecl;
156class ObjCInterfaceDecl;
157class ObjCMethodDecl;
158class ObjCProtocolDecl;
159struct OverloadCandidate;
160enum class OverloadCandidateParamOrder : char;
162class OverloadCandidateSet;
163class OverloadExpr;
164class ParenListExpr;
165class ParmVarDecl;
166class Preprocessor;
167class PseudoDestructorTypeStorage;
168class PseudoObjectExpr;
169class QualType;
170class SemaCodeCompletion;
171class SemaCUDA;
172class SemaHLSL;
173class SemaObjC;
174class SemaOpenACC;
175class SemaOpenMP;
176class SemaSYCL;
177class StandardConversionSequence;
178class Stmt;
179class StringLiteral;
180class SwitchStmt;
181class TemplateArgument;
182class TemplateArgumentList;
183class TemplateArgumentLoc;
184class TemplateDecl;
185class TemplateInstantiationCallback;
186class TemplateParameterList;
187class TemplatePartialOrderingContext;
188class TemplateTemplateParmDecl;
189class Token;
190class TypeAliasDecl;
191class TypedefDecl;
192class TypedefNameDecl;
193class TypeLoc;
194class TypoCorrectionConsumer;
195class UnqualifiedId;
196class UnresolvedLookupExpr;
197class UnresolvedMemberExpr;
198class UnresolvedSetImpl;
199class UnresolvedSetIterator;
200class UsingDecl;
201class UsingShadowDecl;
202class ValueDecl;
203class VarDecl;
204class VarTemplateSpecializationDecl;
205class VisibilityAttr;
206class VisibleDeclConsumer;
207class IndirectFieldDecl;
208struct DeductionFailureInfo;
209class TemplateSpecCandidateSet;
210
211namespace sema {
212class AccessedEntity;
213class BlockScopeInfo;
214class Capture;
215class CapturedRegionScopeInfo;
216class CapturingScopeInfo;
217class CompoundScopeInfo;
218class DelayedDiagnostic;
219class DelayedDiagnosticPool;
220class FunctionScopeInfo;
221class LambdaScopeInfo;
222class PossiblyUnreachableDiag;
223class RISCVIntrinsicManager;
224class SemaPPCallbacks;
225class TemplateDeductionInfo;
226} // namespace sema
227
228namespace threadSafety {
229class BeforeSet;
230void threadSafetyCleanup(BeforeSet *Cache);
231} // namespace threadSafety
232
233// FIXME: No way to easily map from TemplateTypeParmTypes to
234// TemplateTypeParmDecls, so we have this horrible PointerUnion.
235typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *>,
236 SourceLocation>
238
239/// Describes whether we've seen any nullability information for the given
240/// file.
242 /// The first pointer declarator (of any pointer kind) in the file that does
243 /// not have a corresponding nullability annotation.
245
246 /// The end location for the first pointer declarator in the file. Used for
247 /// placing fix-its.
249
250 /// Which kind of pointer declarator we saw.
251 uint8_t PointerKind;
252
253 /// Whether we saw any type nullability annotations in the given file.
254 bool SawTypeNullability = false;
255};
256
257/// A mapping from file IDs to a record of whether we've seen nullability
258/// information in that file.
260 /// A mapping from file IDs to the nullability information for each file ID.
261 llvm::DenseMap<FileID, FileNullability> Map;
262
263 /// A single-element cache based on the file ID.
264 struct {
267 } Cache;
268
269public:
271 // Check the single-element cache.
272 if (file == Cache.File)
273 return Cache.Nullability;
274
275 // It's not in the single-element cache; flush the cache if we have one.
276 if (!Cache.File.isInvalid()) {
277 Map[Cache.File] = Cache.Nullability;
278 }
279
280 // Pull this entry into the cache.
281 Cache.File = file;
282 Cache.Nullability = Map[file];
283 return Cache.Nullability;
284 }
285};
286
287/// Tracks expected type during expression parsing, for use in code completion.
288/// The type is tied to a particular token, all functions that update or consume
289/// the type take a start location of the token they are looking at as a
290/// parameter. This avoids updating the type on hot paths in the parser.
292public:
293 PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {}
294
295 void enterCondition(Sema &S, SourceLocation Tok);
296 void enterReturn(Sema &S, SourceLocation Tok);
298 /// Handles e.g. BaseType{ .D = Tok...
300 const Designation &D);
301 /// Computing a type for the function argument may require running
302 /// overloading, so we postpone its computation until it is actually needed.
303 ///
304 /// Clients should be very careful when using this function, as it stores a
305 /// function_ref, clients should make sure all calls to get() with the same
306 /// location happen while function_ref is alive.
307 ///
308 /// The callback should also emit signature help as a side-effect, but only
309 /// if the completion point has been reached.
311 llvm::function_ref<QualType()> ComputeType);
312
314 void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
315 SourceLocation OpLoc);
316 void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
318 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
319 /// Handles all type casts, including C-style cast, C++ casts, etc.
321
322 /// Get the expected type associated with this location, if any.
323 ///
324 /// If the location is a function argument, determining the expected type
325 /// involves considering all function overloads and the arguments so far.
326 /// In this case, signature help for these function overloads will be reported
327 /// as a side-effect (only if the completion point has been reached).
329 if (!Enabled || Tok != ExpectedLoc)
330 return QualType();
331 if (!Type.isNull())
332 return Type;
333 if (ComputeType)
334 return ComputeType();
335 return QualType();
336 }
337
338private:
339 bool Enabled;
340 /// Start position of a token for which we store expected type.
341 SourceLocation ExpectedLoc;
342 /// Expected type for a token starting at ExpectedLoc.
344 /// A function to compute expected type at ExpectedLoc. It is only considered
345 /// if Type is null.
346 llvm::function_ref<QualType()> ComputeType;
347};
348
350 SkipBodyInfo() = default;
351 bool ShouldSkip = false;
353 NamedDecl *Previous = nullptr;
354 NamedDecl *New = nullptr;
355};
356
357/// Describes the result of template argument deduction.
358///
359/// The TemplateDeductionResult enumeration describes the result of
360/// template argument deduction, as returned from
361/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
362/// structure provides additional information about the results of
363/// template argument deduction, e.g., the deduced template argument
364/// list (if successful) or the specific template parameters or
365/// deduced arguments that were involved in the failure.
367 /// Template argument deduction was successful.
368 Success = 0,
369 /// The declaration was invalid; do nothing.
370 Invalid,
371 /// Template argument deduction exceeded the maximum template
372 /// instantiation depth (which has already been diagnosed).
374 /// Template argument deduction did not deduce a value
375 /// for every template parameter.
377 /// Template argument deduction did not deduce a value for every
378 /// expansion of an expanded template parameter pack.
380 /// Template argument deduction produced inconsistent
381 /// deduced values for the given template parameter.
383 /// Template argument deduction failed due to inconsistent
384 /// cv-qualifiers on a template parameter type that would
385 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
386 /// but were given a non-const "X".
388 /// Substitution of the deduced template argument values
389 /// resulted in an error.
391 /// After substituting deduced template arguments, a dependent
392 /// parameter type did not match the corresponding argument.
394 /// After substituting deduced template arguments, an element of
395 /// a dependent parameter type did not match the corresponding element
396 /// of the corresponding argument (when deducing from an initializer list).
398 /// A non-depnedent component of the parameter did not match the
399 /// corresponding component of the argument.
401 /// When performing template argument deduction for a function
402 /// template, there were too many call arguments.
404 /// When performing template argument deduction for a function
405 /// template, there were too few call arguments.
407 /// The explicitly-specified template arguments were not valid
408 /// template arguments for the given template.
410 /// Checking non-dependent argument conversions failed.
412 /// The deduced arguments did not satisfy the constraints associated
413 /// with the template.
415 /// Deduction failed; that's all we know.
417 /// CUDA Target attributes do not match.
419 /// Some error which was already diagnosed.
421};
422
423/// Kinds of C++ special members.
431 Invalid
432};
433
434/// The kind of conversion being performed.
436 /// An implicit conversion.
437 Implicit,
438 /// A C-style cast.
440 /// A functional-style cast.
442 /// A cast other than a C-style cast.
443 OtherCast,
444 /// A conversion for an operand of a builtin overloaded operator.
446};
447
448/// Sema - This implements semantic analysis and AST building for C.
449/// \nosubgrouping
450class Sema final : public SemaBase {
451 // Table of Contents
452 // -----------------
453 // 1. Semantic Analysis (Sema.cpp)
454 // 2. C++ Access Control (SemaAccess.cpp)
455 // 3. Attributes (SemaAttr.cpp)
456 // 4. Availability Attribute Handling (SemaAvailability.cpp)
457 // 5. Casts (SemaCast.cpp)
458 // 6. Extra Semantic Checking (SemaChecking.cpp)
459 // 7. C++ Coroutines (SemaCoroutine.cpp)
460 // 8. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
461 // 9. Declarations (SemaDecl.cpp)
462 // 10. Declaration Attribute Handling (SemaDeclAttr.cpp)
463 // 11. C++ Declarations (SemaDeclCXX.cpp)
464 // 12. C++ Exception Specifications (SemaExceptionSpec.cpp)
465 // 13. Expressions (SemaExpr.cpp)
466 // 14. C++ Expressions (SemaExprCXX.cpp)
467 // 15. Member Access Expressions (SemaExprMember.cpp)
468 // 16. Initializers (SemaInit.cpp)
469 // 17. C++ Lambda Expressions (SemaLambda.cpp)
470 // 18. Name Lookup (SemaLookup.cpp)
471 // 19. Modules (SemaModule.cpp)
472 // 20. C++ Overloading (SemaOverload.cpp)
473 // 21. Pseudo-Object (SemaPseudoObject.cpp)
474 // 22. Statements (SemaStmt.cpp)
475 // 23. `inline asm` Statement (SemaStmtAsm.cpp)
476 // 24. Statement Attribute Handling (SemaStmtAttr.cpp)
477 // 25. C++ Templates (SemaTemplate.cpp)
478 // 26. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
479 // 27. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
480 // 28. C++ Template Declaration Instantiation
481 // (SemaTemplateInstantiateDecl.cpp)
482 // 29. C++ Variadic Templates (SemaTemplateVariadic.cpp)
483 // 30. Constraints and Concepts (SemaConcept.cpp)
484 // 31. Types (SemaType.cpp)
485 // 32. FixIt Helpers (SemaFixItUtils.cpp)
486 // 33. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp)
487
488 /// \name Semantic Analysis
489 /// Implementations are in Sema.cpp
490 ///@{
491
492public:
493 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
495 CodeCompleteConsumer *CompletionConsumer = nullptr);
496 ~Sema();
497
498 /// Perform initialization that occurs after the parser has been
499 /// initialized but before it parses anything.
500 void Initialize();
501
502 /// This virtual key function only exists to limit the emission of debug info
503 /// describing the Sema class. GCC and Clang only emit debug info for a class
504 /// with a vtable when the vtable is emitted. Sema is final and not
505 /// polymorphic, but the debug info size savings are so significant that it is
506 /// worth adding a vtable just to take advantage of this optimization.
507 virtual void anchor();
508
509 const LangOptions &getLangOpts() const { return LangOpts; }
512
515 Preprocessor &getPreprocessor() const { return PP; }
516 ASTContext &getASTContext() const { return Context; }
520
522 StringRef Platform);
524
525 /// Registers an external source. If an external source already exists,
526 /// creates a multiplex external source and appends to it.
527 ///
528 ///\param[in] E - A non-null external sema source.
529 ///
531
532 void PrintStats() const;
533
534 /// Warn that the stack is nearly exhausted.
536
537 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
538 /// guaranteed). Produces a warning if we're low on stack space and allocates
539 /// more in that case. Use this in code that may recurse deeply (for example,
540 /// in template instantiation) to avoid stack overflow.
542 llvm::function_ref<void()> Fn);
543
544 /// Returns default addr space for method qualifiers.
546
547 /// Load weak undeclared identifiers from the external source.
549
550 /// Determine if VD, which must be a variable or function, is an external
551 /// symbol that nonetheless can't be referenced from outside this translation
552 /// unit because its type has no linkage and it's not extern "C".
553 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
554
555 /// Obtain a sorted list of functions that are undefined but ODR-used.
557 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
558
559 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
561 /// Retrieves list of suspicious delete-expressions that will be checked at
562 /// the end of translation unit.
563 const llvm::MapVector<FieldDecl *, DeleteLocs> &
565
566 /// Cause the active diagnostic on the DiagosticsEngine to be
567 /// emitted. This is closely coupled to the SemaDiagnosticBuilder class and
568 /// should not be used elsewhere.
569 void EmitCurrentDiagnostic(unsigned DiagID);
570
571 void addImplicitTypedef(StringRef Name, QualType T);
572
573 /// Whether uncompilable error has occurred. This includes error happens
574 /// in deferred diagnostics.
575 bool hasUncompilableErrorOccurred() const;
576
577 bool findMacroSpelling(SourceLocation &loc, StringRef name);
578
579 /// Calls \c Lexer::getLocForEndOfToken()
581
582 /// Retrieve the module loader associated with the preprocessor.
584
585 /// Invent a new identifier for parameters of abbreviated templates.
588 unsigned Index);
589
591
592 // Emit all deferred diagnostics.
593 void emitDeferredDiags();
594
596 /// The global module fragment, between 'module;' and a module-declaration.
598 /// A normal translation unit fragment. For a non-module unit, this is the
599 /// entire translation unit. Otherwise, it runs from the module-declaration
600 /// to the private-module-fragment (if any) or the end of the TU (if not).
602 /// The private module fragment, between 'module :private;' and the end of
603 /// the translation unit.
604 Private
605 };
606
610
612
613 void PushFunctionScope();
614 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
616
617 /// This is used to inform Sema what the current TemplateParameterDepth
618 /// is during Parsing. Currently it is used to pass on the depth
619 /// when parsing generic lambda 'auto' parameters.
620 void RecordParsingTemplateParameterDepth(unsigned Depth);
621
622 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
624 unsigned OpenMPCaptureLevel = 0);
625
626 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
627 /// time after they've been popped.
629 Sema *Self;
630
631 public:
632 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
634 };
635
637 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
638
641 const Decl *D = nullptr,
642 QualType BlockType = QualType());
643
645
650
651 void PushCompoundScope(bool IsStmtExpr);
652 void PopCompoundScope();
653
655
656 /// Retrieve the current block, if any.
658
659 /// Get the innermost lambda enclosing the current location, if any. This
660 /// looks through intervening non-lambda scopes such as local functions and
661 /// blocks.
663
664 /// Retrieve the current lambda scope info, if any.
665 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
666 /// lambda scope info ignoring all inner capturing scopes that are not
667 /// lambda scopes.
669 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
670
671 /// Retrieve the current generic lambda info, if any.
673
674 /// Retrieve the current captured region, if any.
676
677 void ActOnComment(SourceRange Comment);
678
679 /// Retrieve the parser's current scope.
680 ///
681 /// This routine must only be used when it is certain that semantic analysis
682 /// and the parser are in precisely the same context, which is not the case
683 /// when, e.g., we are performing any kind of template instantiation.
684 /// Therefore, the only safe places to use this scope are in the parser
685 /// itself and in routines directly invoked from the parser and *never* from
686 /// template substitution or instantiation.
687 Scope *getCurScope() const { return CurScope; }
688
690
693 }
694
695 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
696 const FunctionDecl *FD = nullptr);
698 const PartialDiagnostic &PD,
699 const FunctionDecl *FD = nullptr) {
700 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
701 }
702
703 /// Check if the type is allowed to be used for the current target.
705 ValueDecl *D = nullptr);
706
707 // /// The kind of conversion being performed.
708 // enum CheckedConversionKind {
709 // /// An implicit conversion.
710 // CCK_ImplicitConversion,
711 // /// A C-style cast.
712 // CCK_CStyleCast,
713 // /// A functional-style cast.
714 // CCK_FunctionalCast,
715 // /// A cast other than a C-style cast.
716 // CCK_OtherCast,
717 // /// A conversion for an operand of a builtin overloaded operator.
718 // CCK_ForBuiltinOverloadedOp
719 // };
720
721 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
722 /// cast. If there is already an implicit cast, merge into the existing one.
723 /// If isLvalue, the result of the cast is an lvalue.
726 const CXXCastPath *BasePath = nullptr,
728
729 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
730 /// to the conversion from scalar type ScalarTy to the Boolean type.
732
733 /// If \p AllowLambda is true, treat lambda as function.
734 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
735
736 /// Returns a pointer to the innermost enclosing function, or nullptr if the
737 /// current context is not inside a function. If \p AllowLambda is true,
738 /// this can return the call operator of an enclosing lambda, otherwise
739 /// lambdas are skipped when looking for an enclosing function.
740 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
741
742 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
743 /// the method decl for the method being parsed. If we're currently
744 /// in a 'block', this returns the containing context.
746
747 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
748 /// or C function we're in, otherwise return null. If we're currently
749 /// in a 'block', this returns the containing context.
751
752 /// Warn if we're implicitly casting from a _Nullable pointer type to a
753 /// _Nonnull one.
756
757 /// Warn when implicitly casting 0 to nullptr.
758 void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
759
761 UnavailableAttr::ImplicitReason reason);
762
763 /// Retrieve a suitable printing policy for diagnostics.
766 }
767
768 /// Retrieve a suitable printing policy for diagnostics.
770 const Preprocessor &PP);
771
772 /// Scope actions.
774
775 /// Determine whether \param D is function like (function or function
776 /// template) for parsing.
778
779 /// The maximum alignment, same as in llvm::Value. We duplicate them here
780 /// because that allows us not to duplicate the constants in clang code,
781 /// which we must to since we can't directly use the llvm constants.
782 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
783 ///
784 /// This is the greatest alignment value supported by load, store, and alloca
785 /// instructions, and global values.
786 static const unsigned MaxAlignmentExponent = 32;
787 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
788
789 /// Flag indicating whether or not to collect detailed statistics.
791
792 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
793
794 /// Stack containing information about each of the nested
795 /// function, block, and method scopes that are currently active.
797
798 /// The index of the first FunctionScope that corresponds to the current
799 /// context.
801
802 /// Track the number of currently active capturing scopes.
804
805 llvm::BumpPtrAllocator BumpAlloc;
806
807 /// The kind of translation unit we are processing.
808 ///
809 /// When we're processing a complete translation unit, Sema will perform
810 /// end-of-translation-unit semantic tasks (such as creating
811 /// initializers for tentative definitions in C) once parsing has
812 /// completed. Modules and precompiled headers perform different kinds of
813 /// checks.
815
816 /// Translation Unit Scope - useful to Objective-C actions that need
817 /// to lookup file scope declarations in the "ordinary" C decl namespace.
818 /// For example, user-defined classes, built-in "id" type, etc.
820
822
824 return CurScope->incrementMSManglingNumber();
825 }
826
827 /// Try to recover by turning the given expression into a
828 /// call. Returns true if recovery was attempted or an error was
829 /// emitted; this may also leave the ExprResult invalid.
831 bool ForceComplain = false,
832 bool (*IsPlausibleResult)(QualType) = nullptr);
833
834 /// Figure out if an expression could be turned into a call.
835 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
836 UnresolvedSetImpl &NonTemplateOverloads);
837
841
844
852
853 /// A RAII object to enter scope of a compound statement.
855 public:
856 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
857 S.ActOnStartOfCompoundStmt(IsStmtExpr);
858 }
859
861
862 private:
863 Sema &S;
864 };
865
866 /// An RAII helper that pops function a function scope on exit.
869 bool Active;
872 if (Active)
874 }
875 void disable() { Active = false; }
876 };
877
878 /// Build a partial diagnostic.
879 PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h
880
882 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
883 }
884
885 /// Worker object for performing CFG-based warnings.
888
889 /// Callback to the parser to parse templated functions when needed.
890 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
891 typedef void LateTemplateParserCleanupCB(void *P);
895
897 LateTemplateParserCleanupCB *LTPCleanup, void *P) {
898 LateTemplateParser = LTP;
899 LateTemplateParserCleanup = LTPCleanup;
900 OpaqueParser = P;
901 }
902
903 /// Callback to the parser to parse a type expressed as a string.
904 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
906
907 /// VAListTagName - The declaration name corresponding to __va_list_tag.
908 /// This is used as part of a hack to omit that class from ADL results.
910
911 /// Is the last error level diagnostic immediate. This is used to determined
912 /// whether the next info diagnostic should be immediate.
914
915 class DelayedDiagnostics;
916
918 sema::DelayedDiagnosticPool *SavedPool = nullptr;
920 };
923
924 /// A class which encapsulates the logic for delaying diagnostics
925 /// during parsing and other processing.
927 /// The current pool of diagnostics into which delayed
928 /// diagnostics should go.
929 sema::DelayedDiagnosticPool *CurPool = nullptr;
930
931 public:
933
934 /// Adds a delayed diagnostic.
935 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
936
937 /// Determines whether diagnostics should be delayed.
938 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
939
940 /// Returns the current delayed-diagnostics pool.
941 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
942
943 /// Enter a new scope. Access and deprecation diagnostics will be
944 /// collected in this pool.
947 state.SavedPool = CurPool;
948 CurPool = &pool;
949 return state;
950 }
951
952 /// Leave a delayed-diagnostic state that was previously pushed.
953 /// Do not emit any of the diagnostics. This is performed as part
954 /// of the bookkeeping of popping a pool "properly".
956 CurPool = state.SavedPool;
957 }
958
959 /// Enter a new scope where access and deprecation diagnostics are
960 /// not delayed.
963 state.SavedPool = CurPool;
964 CurPool = nullptr;
965 return state;
966 }
967
968 /// Undo a previous pushUndelayed().
970 assert(CurPool == nullptr);
971 CurPool = state.SavedPool;
972 }
973 } DelayedDiagnostics;
974
976 return DelayedDiagnostics.push(pool);
977 }
978
979 /// Diagnostics that are emitted only if we discover that the given function
980 /// must be codegen'ed. Because handling these correctly adds overhead to
981 /// compilation, this is currently only enabled for CUDA compilations.
982 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
983
984 /// CurContext - This is the current declaration context of parsing.
986
988 assert(CodeCompletionPtr);
989 return *CodeCompletionPtr;
990 }
991
993 assert(CUDAPtr);
994 return *CUDAPtr;
995 }
996
998 assert(HLSLPtr);
999 return *HLSLPtr;
1000 }
1001
1003 assert(ObjCPtr);
1004 return *ObjCPtr;
1005 }
1006
1008 assert(OpenACCPtr);
1009 return *OpenACCPtr;
1010 }
1011
1013 assert(OpenMPPtr && "SemaOpenMP is dead");
1014 return *OpenMPPtr;
1015 }
1016
1018 assert(SYCLPtr);
1019 return *SYCLPtr;
1020 }
1021
1022 /// Source of additional semantic information.
1024
1025protected:
1026 friend class Parser;
1028 friend class ASTReader;
1029 friend class ASTDeclReader;
1030 friend class ASTWriter;
1031
1032private:
1033 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1034 bool WarnedDarwinSDKInfoMissing = false;
1035
1036 Sema(const Sema &) = delete;
1037 void operator=(const Sema &) = delete;
1038
1039 /// The handler for the FileChanged preprocessor events.
1040 ///
1041 /// Used for diagnostics that implement custom semantic analysis for #include
1042 /// directives, like -Wpragma-pack.
1043 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1044
1045 /// The parser's current scope.
1046 ///
1047 /// The parser maintains this state here.
1048 Scope *CurScope;
1049
1050 mutable IdentifierInfo *Ident_super;
1051
1052 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1053 std::unique_ptr<SemaCUDA> CUDAPtr;
1054 std::unique_ptr<SemaHLSL> HLSLPtr;
1055 std::unique_ptr<SemaObjC> ObjCPtr;
1056 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1057 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1058 std::unique_ptr<SemaSYCL> SYCLPtr;
1059
1060 ///@}
1061
1062 //
1063 //
1064 // -------------------------------------------------------------------------
1065 //
1066 //
1067
1068 /// \name C++ Access Control
1069 /// Implementations are in SemaAccess.cpp
1070 ///@{
1071
1072public:
1079
1080 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1081 NamedDecl *PrevMemberDecl,
1082 AccessSpecifier LexicalAS);
1083
1085 DeclAccessPair FoundDecl);
1087 DeclAccessPair FoundDecl);
1089 SourceRange PlacementRange,
1090 CXXRecordDecl *NamingClass,
1091 DeclAccessPair FoundDecl,
1092 bool Diagnose = true);
1094 DeclAccessPair FoundDecl,
1095 const InitializedEntity &Entity,
1096 bool IsCopyBindingRefToTemp = false);
1098 DeclAccessPair FoundDecl,
1099 const InitializedEntity &Entity,
1100 const PartialDiagnostic &PDiag);
1102 CXXDestructorDecl *Dtor,
1103 const PartialDiagnostic &PDiag,
1104 QualType objectType = QualType());
1107 CXXRecordDecl *NamingClass,
1108 DeclAccessPair Found);
1111 CXXRecordDecl *DecomposedClass,
1112 DeclAccessPair Field);
1114 const SourceRange &,
1115 DeclAccessPair FoundDecl);
1117 Expr *ArgExpr,
1118 DeclAccessPair FoundDecl);
1120 ArrayRef<Expr *> ArgExprs,
1121 DeclAccessPair FoundDecl);
1123 DeclAccessPair FoundDecl);
1125 QualType Derived, const CXXBasePath &Path,
1126 unsigned DiagID, bool ForceCheck = false,
1127 bool ForceUnprivileged = false);
1128 void CheckLookupAccess(const LookupResult &R);
1129 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1130 QualType BaseType);
1132 DeclAccessPair Found, QualType ObjectType,
1134 const PartialDiagnostic &Diag);
1136 DeclAccessPair Found,
1137 QualType ObjectType) {
1138 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1139 SourceLocation(), PDiag());
1140 }
1141
1143 const DependentDiagnostic &DD,
1144 const MultiLevelTemplateArgumentList &TemplateArgs);
1146
1147 ///@}
1148
1149 //
1150 //
1151 // -------------------------------------------------------------------------
1152 //
1153 //
1154
1155 /// \name Attributes
1156 /// Implementations are in SemaAttr.cpp
1157 ///@{
1158
1159public:
1160 /// Controls member pointer representation format under the MS ABI.
1163
1164 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1165
1166 /// Source location for newly created implicit MSInheritanceAttrs
1168
1169 /// pragma clang section kind
1176 PCSK_Relro = 5
1178
1180
1182 std::string SectionName;
1183 bool Valid = false;
1185 };
1186
1192
1194 PSK_Reset = 0x0, // #pragma ()
1195 PSK_Set = 0x1, // #pragma (value)
1196 PSK_Push = 0x2, // #pragma (push[, id])
1197 PSK_Pop = 0x4, // #pragma (pop[, id])
1198 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1199 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1200 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1201 };
1202
1205 StringRef SlotLabel;
1207 };
1208
1209 // #pragma pack and align.
1211 public:
1212 // `Native` represents default align mode, which may vary based on the
1213 // platform.
1214 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1215
1216 // #pragma pack info constructor
1217 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1218 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1219 assert(Num == PackNumber && "The pack number has been truncated.");
1220 }
1221
1222 // #pragma align info constructor
1224 : PackAttr(false), AlignMode(M),
1225 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1226
1227 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1228
1230
1231 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1232 // integer encoding for it. This should only be passed to
1233 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1234 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1235 std::uint32_t Encoding{};
1236 if (Info.IsXLStack())
1237 Encoding |= IsXLMask;
1238
1239 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1240
1241 if (Info.IsPackAttr())
1242 Encoding |= PackAttrMask;
1243
1244 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1245
1246 return Encoding;
1247 }
1248
1249 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1250 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1252 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1253 int PackNumber = (Encoding & PackNumMask) >> 4;
1254
1255 if (Encoding & PackAttrMask)
1256 return AlignPackInfo(M, PackNumber, IsXL);
1257
1258 return AlignPackInfo(M, IsXL);
1259 }
1260
1261 bool IsPackAttr() const { return PackAttr; }
1262
1263 bool IsAlignAttr() const { return !PackAttr; }
1264
1265 Mode getAlignMode() const { return AlignMode; }
1266
1267 unsigned getPackNumber() const { return PackNumber; }
1268
1269 bool IsPackSet() const {
1270 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1271 // attriute on a decl.
1272 return PackNumber != UninitPackVal && PackNumber != 0;
1273 }
1274
1275 bool IsXLStack() const { return XLStack; }
1276
1277 bool operator==(const AlignPackInfo &Info) const {
1278 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1279 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1280 Info.XLStack);
1281 }
1282
1283 bool operator!=(const AlignPackInfo &Info) const {
1284 return !(*this == Info);
1285 }
1286
1287 private:
1288 /// \brief True if this is a pragma pack attribute,
1289 /// not a pragma align attribute.
1290 bool PackAttr;
1291
1292 /// \brief The alignment mode that is in effect.
1293 Mode AlignMode;
1294
1295 /// \brief The pack number of the stack.
1296 unsigned char PackNumber;
1297
1298 /// \brief True if it is a XL #pragma align/pack stack.
1299 bool XLStack;
1300
1301 /// \brief Uninitialized pack value.
1302 static constexpr unsigned char UninitPackVal = -1;
1303
1304 // Masks to encode and decode an AlignPackInfo.
1305 static constexpr uint32_t IsXLMask{0x0000'0001};
1306 static constexpr uint32_t AlignModeMask{0x0000'0006};
1307 static constexpr uint32_t PackAttrMask{0x00000'0008};
1308 static constexpr uint32_t PackNumMask{0x0000'01F0};
1309 };
1310
1311 template <typename ValueType> struct PragmaStack {
1312 struct Slot {
1313 llvm::StringRef StackSlotLabel;
1314 ValueType Value;
1317 Slot(llvm::StringRef StackSlotLabel, ValueType Value,
1322 };
1323
1324 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1325 llvm::StringRef StackSlotLabel, ValueType Value) {
1326 if (Action == PSK_Reset) {
1328 CurrentPragmaLocation = PragmaLocation;
1329 return;
1330 }
1331 if (Action & PSK_Push)
1332 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1333 PragmaLocation);
1334 else if (Action & PSK_Pop) {
1335 if (!StackSlotLabel.empty()) {
1336 // If we've got a label, try to find it and jump there.
1337 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1338 return x.StackSlotLabel == StackSlotLabel;
1339 });
1340 // If we found the label so pop from there.
1341 if (I != Stack.rend()) {
1342 CurrentValue = I->Value;
1343 CurrentPragmaLocation = I->PragmaLocation;
1344 Stack.erase(std::prev(I.base()), Stack.end());
1345 }
1346 } else if (!Stack.empty()) {
1347 // We do not have a label, just pop the last entry.
1348 CurrentValue = Stack.back().Value;
1349 CurrentPragmaLocation = Stack.back().PragmaLocation;
1350 Stack.pop_back();
1351 }
1352 }
1353 if (Action & PSK_Set) {
1355 CurrentPragmaLocation = PragmaLocation;
1356 }
1357 }
1358
1359 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1360 // method body to restore the stacks on exit, so it works like this:
1361 //
1362 // struct S {
1363 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1364 // void Method {}
1365 // #pragma <name>(pop, InternalPragmaSlot)
1366 // };
1367 //
1368 // It works even with #pragma vtordisp, although MSVC doesn't support
1369 // #pragma vtordisp(push [, id], n)
1370 // syntax.
1371 //
1372 // Push / pop a named sentinel slot.
1373 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
1374 assert((Action == PSK_Push || Action == PSK_Pop) &&
1375 "Can only push / pop #pragma stack sentinels!");
1377 }
1378
1379 // Constructors.
1380 explicit PragmaStack(const ValueType &Default)
1382
1383 bool hasValue() const { return CurrentValue != DefaultValue; }
1384
1386 ValueType DefaultValue; // Value used for PSK_Reset action.
1387 ValueType CurrentValue;
1389 };
1390 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
1391 // we shouldn't do so if they're in a module).
1392
1393 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
1394 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
1395 ///
1396 /// 0: Suppress all vtordisps
1397 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
1398 /// structors
1399 /// 2: Always insert vtordisps to support RTTI on partially constructed
1400 /// objects
1403 // The current #pragma align/pack values and locations at each #include.
1408 };
1410 // Segment #pragmas.
1415
1416 // #pragma strict_gs_check.
1418
1419 // This stack tracks the current state of Sema.CurFPFeatures.
1422 FPOptionsOverride result;
1423 if (!FpPragmaStack.hasValue()) {
1424 result = FPOptionsOverride();
1425 } else {
1426 result = FpPragmaStack.CurrentValue;
1427 }
1428 return result;
1429 }
1430
1436 };
1437
1438 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
1439 // Actions should be performed only if we enter / exit a C++ method body.
1441 public:
1442 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
1444
1445 private:
1446 Sema &S;
1447 StringRef SlotLabel;
1448 bool ShouldAct;
1449 };
1450
1451 /// Last section used with #pragma init_seg.
1454
1455 /// Sections used with #pragma alloc_text.
1456 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
1457
1458 /// VisContext - Manages the stack for \#pragma GCC visibility.
1459 void *VisContext; // Really a "PragmaVisStack*"
1460
1461 /// This an attribute introduced by \#pragma clang attribute.
1467 };
1468
1469 /// A push'd group of PragmaAttributeEntries.
1471 /// The location of the push attribute.
1473 /// The namespace of this push group.
1476 };
1477
1479
1480 /// The declaration that is currently receiving an attribute from the
1481 /// #pragma attribute stack.
1483
1484 /// This represents the last location of a "#pragma clang optimize off"
1485 /// directive if such a directive has not been closed by an "on" yet. If
1486 /// optimizations are currently "on", this is set to an invalid location.
1488
1489 /// Get the location for the currently active "\#pragma clang optimize
1490 /// off". If this location is invalid, then the state of the pragma is "on".
1493 }
1494
1495 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
1496 /// whether the optimizations in the list passed to the pragma should be
1497 /// turned off or on. This boolean is true by default because command line
1498 /// options are honored when `#pragma optimize("", on)`.
1499 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
1501
1502 /// Set of no-builtin functions listed by \#pragma function.
1504
1505 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
1506 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
1508
1509 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
1511
1512 /// Add gsl::Pointer attribute to std::container::iterator
1513 /// \param ND The declaration that introduces the name
1514 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
1515 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
1516
1517 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
1519
1520 /// Add [[gsl::Pointer]] attributes for std:: types.
1522
1523 /// Add _Nullable attributes for std:: types.
1525
1527 POAK_Native, // #pragma options align=native
1528 POAK_Natural, // #pragma options align=natural
1529 POAK_Packed, // #pragma options align=packed
1530 POAK_Power, // #pragma options align=power
1531 POAK_Mac68k, // #pragma options align=mac68k
1532 POAK_Reset // #pragma options align=reset
1534
1535 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
1538 PragmaClangSectionKind SecKind,
1539 StringRef SecName);
1540
1541 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
1543 SourceLocation PragmaLoc);
1544
1545 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
1546 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
1547 StringRef SlotLabel, Expr *Alignment);
1548
1549 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
1550 /// (unless they are value dependent or type dependent). Returns false
1551 /// and emits a diagnostic if one or more of the arguments could not be
1552 /// folded into a constant.
1555
1559 };
1560
1562 SourceLocation IncludeLoc);
1564
1565 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
1567
1568 /// ActOnPragmaMSComment - Called on well formed
1569 /// \#pragma comment(kind, "arg").
1571 StringRef Arg);
1572
1573 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
1574 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
1575 StringRef Value);
1576
1577 /// Are precise floating point semantics currently enabled?
1579 return !CurFPFeatures.getAllowFPReassociate() &&
1580 !CurFPFeatures.getNoSignedZero() &&
1581 !CurFPFeatures.getAllowReciprocal() &&
1582 !CurFPFeatures.getAllowApproxFunc();
1583 }
1584
1587
1588 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
1591
1592 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
1593 /// pointers_to_members(representation method[, general purpose
1594 /// representation]).
1597 SourceLocation PragmaLoc);
1598
1599 /// Called on well formed \#pragma vtordisp().
1602
1603 bool UnifySection(StringRef SectionName, int SectionFlags,
1604 NamedDecl *TheDecl);
1605 bool UnifySection(StringRef SectionName, int SectionFlags,
1606 SourceLocation PragmaSectionLocation);
1607
1608 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
1609 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
1610 PragmaMsStackAction Action,
1611 llvm::StringRef StackSlotLabel,
1612 StringLiteral *SegmentName, llvm::StringRef PragmaName);
1613
1614 /// Called on well formed \#pragma section().
1615 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
1616 StringLiteral *SegmentName);
1617
1618 /// Called on well-formed \#pragma init_seg().
1619 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
1620 StringLiteral *SegmentName);
1621
1622 /// Called on well-formed \#pragma alloc_text().
1624 SourceLocation PragmaLocation, StringRef Section,
1625 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
1626 &Functions);
1627
1628 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
1629 /// strict_gs_check.
1631 PragmaMsStackAction Action,
1632 bool Value);
1633
1634 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
1635 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
1636 SourceLocation PragmaLoc);
1637
1639 SourceLocation PragmaLoc,
1642 const IdentifierInfo *Namespace);
1643
1644 /// Called on well-formed '\#pragma clang attribute pop'.
1646 const IdentifierInfo *Namespace);
1647
1648 /// Adds the attributes that have been specified using the
1649 /// '\#pragma clang attribute push' directives to the given declaration.
1650 void AddPragmaAttributes(Scope *S, Decl *D);
1651
1653
1655
1656 /// Called on well formed \#pragma clang optimize.
1657 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
1658
1659 /// #pragma optimize("[optimization-list]", on | off).
1660 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
1661
1662 /// Call on well formed \#pragma function.
1663 void
1665 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
1666
1667 /// Only called on function definitions; if there is a pragma in scope
1668 /// with the effect of a range-based optnone, consider marking the function
1669 /// with attribute optnone.
1671
1672 /// Only called on function definitions; if there is a `#pragma alloc_text`
1673 /// that decides which code section the function should be in, add
1674 /// attribute section to the function.
1676
1677 /// Adds the 'optnone' attribute to the function declaration if there
1678 /// are no conflicts; Loc represents the location causing the 'optnone'
1679 /// attribute to be added (usually because of a pragma).
1681
1682 /// Only called on function definitions; if there is a MSVC #pragma optimize
1683 /// in scope, consider changing the function's attributes based on the
1684 /// optimization list passed to the pragma.
1686
1687 /// Only called on function definitions; if there is a pragma in scope
1688 /// with the effect of a range-based no_builtin, consider marking the function
1689 /// with attribute no_builtin.
1691
1692 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
1693 /// add an appropriate visibility attribute.
1695
1696 /// FreeVisContext - Deallocate and null out VisContext.
1697 void FreeVisContext();
1698
1699 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
1700 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
1701 SourceLocation PragmaLoc);
1702
1703 /// ActOnPragmaFPContract - Called on well formed
1704 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
1705 /// \#pragma clang fp contract
1707
1708 /// Called on well formed
1709 /// \#pragma clang fp reassociate
1710 /// or
1711 /// \#pragma clang fp reciprocal
1713 bool IsEnabled);
1714
1715 /// ActOnPragmaFenvAccess - Called on well formed
1716 /// \#pragma STDC FENV_ACCESS
1717 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
1718
1719 /// ActOnPragmaCXLimitedRange - Called on well formed
1720 /// \#pragma STDC CX_LIMITED_RANGE
1723
1724 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
1727
1728 /// Called to set constant rounding mode for floating point operations.
1729 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
1730
1731 /// Called to set exception behavior for floating point operations.
1733
1734 /// PushNamespaceVisibilityAttr - Note that we've entered a
1735 /// namespace with a visibility attribute.
1736 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
1738
1739 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
1740 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
1741 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
1742
1743 /// Handles semantic checking for features that are common to all attributes,
1744 /// such as checking whether a parameter was properly specified, or the
1745 /// correct number of arguments were passed, etc. Returns true if the
1746 /// attribute has been diagnosed.
1747 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
1748 bool SkipArgCountCheck = false);
1749 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
1750 bool SkipArgCountCheck = false);
1751
1752 ///@}
1753
1754 //
1755 //
1756 // -------------------------------------------------------------------------
1757 //
1758 //
1759
1760 /// \name Availability Attribute Handling
1761 /// Implementations are in SemaAvailability.cpp
1762 ///@{
1763
1764public:
1765 /// Issue any -Wunguarded-availability warnings in \c FD
1767
1769
1770 /// Retrieve the current function, if any, that should be analyzed for
1771 /// potential availability violations.
1773
1775 const ObjCInterfaceDecl *UnknownObjCClass,
1776 bool ObjCPropertyAccess,
1777 bool AvoidPartialAvailabilityChecks = false,
1778 ObjCInterfaceDecl *ClassReceiver = nullptr);
1779
1780 ///@}
1781
1782 //
1783 //
1784 // -------------------------------------------------------------------------
1785 //
1786 //
1787
1788 /// \name Casts
1789 /// Implementations are in SemaCast.cpp
1790 ///@{
1791
1792public:
1794 return CCK == CheckedConversionKind::CStyleCast ||
1797 }
1798
1799 /// ActOnCXXNamedCast - Parse
1800 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
1802 SourceLocation LAngleBracketLoc, Declarator &D,
1803 SourceLocation RAngleBracketLoc,
1804 SourceLocation LParenLoc, Expr *E,
1805 SourceLocation RParenLoc);
1806
1808 TypeSourceInfo *Ty, Expr *E,
1809 SourceRange AngleBrackets, SourceRange Parens);
1810
1812 ExprResult Operand,
1813 SourceLocation RParenLoc);
1814
1816 Expr *Operand, SourceLocation RParenLoc);
1817
1818 // Checks that reinterpret casts don't have undefined behavior.
1819 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
1820 bool IsDereference, SourceRange Range);
1821
1822 // Checks that the vector type should be initialized from a scalar
1823 // by splatting the value rather than populating a single element.
1824 // This is the case for AltiVecVector types as well as with
1825 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
1826 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
1827
1828 // Checks if the -faltivec-src-compat=gcc option is specified.
1829 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
1830 // treated the same way as they are when trying to initialize
1831 // these vectors on gcc (an error is emitted).
1833 QualType SrcTy);
1834
1836 SourceLocation RParenLoc, Expr *Op);
1837
1839 SourceLocation LParenLoc,
1840 Expr *CastExpr,
1841 SourceLocation RParenLoc);
1842
1843 ///@}
1844
1845 //
1846 //
1847 // -------------------------------------------------------------------------
1848 //
1849 //
1850
1851 /// \name Extra Semantic Checking
1852 /// Implementations are in SemaChecking.cpp
1853 ///@{
1854
1855public:
1856 /// Used to change context to isConstantEvaluated without pushing a heavy
1857 /// ExpressionEvaluationContextRecord object.
1859
1863 }
1864
1866 unsigned ByteNo) const;
1867
1869 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
1870 FAPK_Variadic, // values to format are passed as variadic arguments
1871 FAPK_VAList, // values to format are passed in a va_list
1872 };
1873
1874 // Used to grab the relevant information from a FormatAttr and a
1875 // FunctionDeclaration.
1877 unsigned FormatIdx;
1880 };
1881
1882 static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
1883 bool IsVariadic, FormatStringInfo *FSI);
1884
1885 // Used by C++ template instantiation.
1888 SourceLocation BuiltinLoc,
1889 SourceLocation RParenLoc);
1890
1903 static FormatStringType GetFormatStringType(const FormatAttr *Format);
1904
1905 bool FormatStringHasSArg(const StringLiteral *FExpr);
1906
1907 static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);
1908
1910 BinaryOperatorKind Opcode);
1911
1912 /// Register a magic integral constant to be used as a type tag.
1913 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
1914 uint64_t MagicValue, QualType Type,
1915 bool LayoutCompatible, bool MustBeNull);
1916
1919
1923
1925
1926 /// If true, \c Type should be compared with other expression's types for
1927 /// layout-compatibility.
1928 LLVM_PREFERRED_TYPE(bool)
1930 LLVM_PREFERRED_TYPE(bool)
1931 unsigned MustBeNull : 1;
1932 };
1933
1934 /// A pair of ArgumentKind identifier and magic value. This uniquely
1935 /// identifies the magic value.
1936 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
1937
1938 /// Diagnoses the current set of gathered accesses. This typically
1939 /// happens at full expression level. The set is cleared after emitting the
1940 /// diagnostics.
1942
1943 /// This function checks if the expression is in the sef of potentially
1944 /// misaligned members and it is converted to some pointer type T with lower
1945 /// or equal alignment requirements. If so it removes it. This is used when
1946 /// we do not want to diagnose such misaligned access (e.g. in conversions to
1947 /// void*).
1948 void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
1949
1950 /// This function calls Action when it determines that E designates a
1951 /// misaligned member due to the packed attribute. This is used to emit
1952 /// local diagnostics like in reference binding.
1954 Expr *E,
1955 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
1956 Action);
1957
1958 enum class AtomicArgumentOrder { API, AST };
1960 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
1961 SourceLocation RParenLoc, MultiExprArg Args,
1964
1965 /// Check to see if a given expression could have '.c_str()' called on it.
1966 bool hasCStrMethod(const Expr *E);
1967
1970 bool IsEqual, SourceRange Range);
1971
1973 bool CheckParameterNames);
1974
1975 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
1976
1977 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
1978 /// to weak/__unsafe_unretained type.
1980
1981 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
1982 /// to weak/__unsafe_unretained expression.
1984
1985 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
1986 /// statement as a \p Body, and it is located on the same line.
1987 ///
1988 /// This helps prevent bugs due to typos, such as:
1989 /// if (condition);
1990 /// do_stuff();
1991 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
1992 unsigned DiagID);
1993
1994 /// Warn if a for/while loop statement \p S, which is followed by
1995 /// \p PossibleBody, has a suspicious null statement as a body.
1996 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
1997
1998 /// Warn if a value is moved to itself.
1999 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2000 SourceLocation OpLoc);
2001
2002 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
2010
2011 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2013 const TypeSourceInfo *Derived);
2014
2015 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2016 const FunctionProtoType *Proto);
2017
2018 bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res);
2019 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2020
2021 bool CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2022
2023 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2024 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2025 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2026 VariadicCallType CallType);
2027
2028 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2029 const NamedDecl *Callee);
2030
2031 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2032
2033private:
2034 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2035 const ArraySubscriptExpr *ASE = nullptr,
2036 bool AllowOnePastEnd = true, bool IndexNegated = false);
2037 void CheckArrayAccess(const Expr *E);
2038
2039 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2040 const FunctionProtoType *Proto);
2041 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2042 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2044 const FunctionProtoType *Proto, SourceLocation Loc);
2045
2046 void checkAIXMemberAlignment(SourceLocation Loc, const Expr *Arg);
2047
2048 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2049 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2050
2051 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2052
2053 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2054 CallExpr *TheCall);
2055
2056 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2057 CallExpr *TheCall);
2058
2059 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2060
2061 bool CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall,
2062 unsigned MaxWidth);
2063 bool CheckNeonBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2064 CallExpr *TheCall);
2065 bool CheckMVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2066 bool CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2067 bool ParseSVEImmChecks(CallExpr *TheCall,
2068 SmallVector<std::tuple<int, int, int>, 3> &ImmChecks);
2069 bool CheckSMEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2070 bool CheckCDEBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2071 CallExpr *TheCall);
2072 bool CheckARMCoprocessorImmediate(const TargetInfo &TI, const Expr *CoprocArg,
2073 bool WantCDE);
2074 bool CheckARMBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2075 CallExpr *TheCall);
2076
2077 bool CheckAArch64BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2078 CallExpr *TheCall);
2079 bool CheckBPFBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2080 bool CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2081 bool CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall);
2082 bool CheckMipsBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2083 CallExpr *TheCall);
2084 bool CheckMipsBuiltinCpu(const TargetInfo &TI, unsigned BuiltinID,
2085 CallExpr *TheCall);
2086 bool CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall);
2087 bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2088 bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);
2089 bool CheckX86BuiltinGatherScatterScale(unsigned BuiltinID, CallExpr *TheCall);
2090 bool CheckX86BuiltinTileArguments(unsigned BuiltinID, CallExpr *TheCall);
2091 bool CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall,
2092 ArrayRef<int> ArgNums);
2093 bool CheckX86BuiltinTileDuplicate(CallExpr *TheCall, ArrayRef<int> ArgNums);
2094 bool CheckX86BuiltinTileRangeAndDuplicate(CallExpr *TheCall,
2095 ArrayRef<int> ArgNums);
2096 bool CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2097 CallExpr *TheCall);
2098 bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2099 CallExpr *TheCall);
2100 bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2101 bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum);
2102 bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2103 CallExpr *TheCall);
2104 void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D,
2105 const llvm::StringMap<bool> &FeatureMap);
2106 bool CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI,
2107 unsigned BuiltinID, CallExpr *TheCall);
2108 bool CheckWebAssemblyBuiltinFunctionCall(const TargetInfo &TI,
2109 unsigned BuiltinID,
2110 CallExpr *TheCall);
2111 bool CheckNVPTXBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2112 CallExpr *TheCall);
2113
2114 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2115 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2116 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2117 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2118 unsigned BuiltinID);
2119 bool BuiltinComplex(CallExpr *TheCall);
2120 bool BuiltinVSX(CallExpr *TheCall);
2121 bool BuiltinOSLogFormat(CallExpr *TheCall);
2122 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2123
2124 bool BuiltinPrefetch(CallExpr *TheCall);
2125 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2126 bool BuiltinArithmeticFence(CallExpr *TheCall);
2127 bool BuiltinAssume(CallExpr *TheCall);
2128 bool BuiltinAssumeAligned(CallExpr *TheCall);
2129 bool BuiltinLongjmp(CallExpr *TheCall);
2130 bool BuiltinSetjmp(CallExpr *TheCall);
2131 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2132 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2133 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2135 bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result);
2136 bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High,
2137 bool RangeIsError = true);
2138 bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
2139 unsigned Multiple);
2140 bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum);
2141 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
2142 unsigned ArgBits);
2143 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
2144 unsigned ArgBits);
2145 bool BuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall, int ArgNum,
2146 unsigned ExpectedFieldNum, bool AllowName);
2147 bool BuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall);
2148 bool BuiltinPPCMMACall(CallExpr *TheCall, unsigned BuiltinID,
2149 const char *TypeDesc);
2150
2151 bool CheckPPCMMAType(QualType Type, SourceLocation TypeLoc);
2152
2153 bool BuiltinElementwiseMath(CallExpr *TheCall);
2154 bool BuiltinElementwiseTernaryMath(CallExpr *TheCall,
2155 bool CheckForFloatArgs = true);
2156 bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall);
2157 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
2158
2159 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
2160
2161 // Matrix builtin handling.
2162 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
2163 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
2164 ExprResult CallResult);
2165 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
2166 ExprResult CallResult);
2167
2168 // WebAssembly builtin handling.
2169 bool BuiltinWasmRefNullExtern(CallExpr *TheCall);
2170 bool BuiltinWasmRefNullFunc(CallExpr *TheCall);
2171 bool BuiltinWasmTableGet(CallExpr *TheCall);
2172 bool BuiltinWasmTableSet(CallExpr *TheCall);
2173 bool BuiltinWasmTableSize(CallExpr *TheCall);
2174 bool BuiltinWasmTableGrow(CallExpr *TheCall);
2175 bool BuiltinWasmTableFill(CallExpr *TheCall);
2176 bool BuiltinWasmTableCopy(CallExpr *TheCall);
2177
2178 bool CheckFormatArguments(const FormatAttr *Format,
2179 ArrayRef<const Expr *> Args, bool IsCXXMember,
2182 llvm::SmallBitVector &CheckedVarArgs);
2183 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
2184 FormatArgumentPassingKind FAPK, unsigned format_idx,
2185 unsigned firstDataArg, FormatStringType Type,
2187 SourceRange range,
2188 llvm::SmallBitVector &CheckedVarArgs);
2189
2190 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
2191
2192 void CheckAbsoluteValueFunction(const CallExpr *Call,
2193 const FunctionDecl *FDecl);
2194
2195 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
2196
2197 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
2198 IdentifierInfo *FnName);
2199
2200 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2201
2202 void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2203
2204 void CheckFreeArguments(const CallExpr *E);
2205
2206 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
2207 SourceLocation ReturnLoc, bool isObjCMethod = false,
2208 const AttrVec *Attrs = nullptr,
2209 const FunctionDecl *FD = nullptr);
2210
2211 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
2212 void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
2213 void CheckForIntOverflow(const Expr *E);
2214 void CheckUnsequencedOperations(const Expr *E);
2215
2216 /// Perform semantic checks on a completed expression. This will either
2217 /// be a full-expression or a default argument expression.
2218 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
2219 bool IsConstexpr = false);
2220
2221 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
2222 Expr *Init);
2223
2224 /// A map from magic value to type information.
2225 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
2226 TypeTagForDatatypeMagicValues;
2227
2228 /// Peform checks on a call of a function with argument_with_type_tag
2229 /// or pointer_with_type_tag attributes.
2230 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
2231 const ArrayRef<const Expr *> ExprArgs,
2232 SourceLocation CallSiteLoc);
2233
2234 /// Check if we are taking the address of a packed field
2235 /// as this may be a problem if the pointer value is dereferenced.
2236 void CheckAddressOfPackedMember(Expr *rhs);
2237
2238 /// Helper class that collects misaligned member designations and
2239 /// their location info for delayed diagnostics.
2240 struct MisalignedMember {
2241 Expr *E;
2242 RecordDecl *RD;
2243 ValueDecl *MD;
2244 CharUnits Alignment;
2245
2246 MisalignedMember() : E(), RD(), MD() {}
2247 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
2248 CharUnits Alignment)
2249 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
2250 explicit MisalignedMember(Expr *E)
2251 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
2252
2253 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
2254 };
2255 /// Small set of gathered accesses to potentially misaligned members
2256 /// due to the packed attribute.
2257 SmallVector<MisalignedMember, 4> MisalignedMembers;
2258
2259 /// Adds an expression to the set of gathered misaligned members.
2260 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
2261 CharUnits Alignment);
2262 ///@}
2263
2264 //
2265 //
2266 // -------------------------------------------------------------------------
2267 //
2268 //
2269
2270 /// \name C++ Coroutines
2271 /// Implementations are in SemaCoroutine.cpp
2272 ///@{
2273
2274public:
2275 /// The C++ "std::coroutine_traits" template, which is defined in
2276 /// <coroutine_traits>
2278
2280 StringRef Keyword);
2284
2287 UnresolvedLookupExpr *Lookup);
2289 Expr *Awaiter, bool IsImplicit = false);
2291 UnresolvedLookupExpr *Lookup);
2294 bool IsImplicit = false);
2299
2300 // As a clang extension, enforces that a non-coroutine function must be marked
2301 // with [[clang::coro_wrapper]] if it returns a type marked with
2302 // [[clang::coro_return_type]].
2303 // Expects that FD is not a coroutine.
2305 /// Lookup 'coroutine_traits' in std namespace and std::experimental
2306 /// namespace. The namespace found is recorded in Namespace.
2308 SourceLocation FuncLoc);
2309 /// Check that the expression co_await promise.final_suspend() shall not be
2310 /// potentially-throwing.
2311 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
2312
2313 ///@}
2314
2315 //
2316 //
2317 // -------------------------------------------------------------------------
2318 //
2319 //
2320
2321 /// \name C++ Scope Specifiers
2322 /// Implementations are in SemaCXXScopeSpec.cpp
2323 ///@{
2324
2325public:
2326 // Marks SS invalid if it represents an incomplete type.
2328 // Complete an enum decl, maybe without a scope spec.
2330 CXXScopeSpec *SS = nullptr);
2331
2334 bool EnteringContext = false);
2337
2338 /// The parser has parsed a global nested-name-specifier '::'.
2339 ///
2340 /// \param CCLoc The location of the '::'.
2341 ///
2342 /// \param SS The nested-name-specifier, which will be updated in-place
2343 /// to reflect the parsed nested-name-specifier.
2344 ///
2345 /// \returns true if an error occurred, false otherwise.
2347
2348 /// The parser has parsed a '__super' nested-name-specifier.
2349 ///
2350 /// \param SuperLoc The location of the '__super' keyword.
2351 ///
2352 /// \param ColonColonLoc The location of the '::'.
2353 ///
2354 /// \param SS The nested-name-specifier, which will be updated in-place
2355 /// to reflect the parsed nested-name-specifier.
2356 ///
2357 /// \returns true if an error occurred, false otherwise.
2359 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
2360
2362 bool *CanCorrect = nullptr);
2364
2365 /// Keeps information about an identifier in a nested-name-spec.
2366 ///
2368 /// The type of the object, if we're parsing nested-name-specifier in
2369 /// a member access expression.
2371
2372 /// The identifier preceding the '::'.
2374
2375 /// The location of the identifier.
2377
2378 /// The location of the '::'.
2380
2381 /// Creates info object for the most typical case.
2383 SourceLocation ColonColonLoc,
2384 ParsedType ObjectType = ParsedType())
2385 : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
2386 CCLoc(ColonColonLoc) {}
2387
2389 SourceLocation ColonColonLoc, QualType ObjectType)
2390 : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
2391 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
2392 };
2393
2394 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2395 bool EnteringContext, CXXScopeSpec &SS,
2396 NamedDecl *ScopeLookupResult,
2397 bool ErrorRecoveryLookup,
2398 bool *IsCorrectedToColon = nullptr,
2399 bool OnlyNamespace = false);
2400
2401 /// The parser has parsed a nested-name-specifier 'identifier::'.
2402 ///
2403 /// \param S The scope in which this nested-name-specifier occurs.
2404 ///
2405 /// \param IdInfo Parser information about an identifier in the
2406 /// nested-name-spec.
2407 ///
2408 /// \param EnteringContext Whether we're entering the context nominated by
2409 /// this nested-name-specifier.
2410 ///
2411 /// \param SS The nested-name-specifier, which is both an input
2412 /// parameter (the nested-name-specifier before this type) and an
2413 /// output parameter (containing the full nested-name-specifier,
2414 /// including this new type).
2415 ///
2416 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
2417 /// are allowed. The bool value pointed by this parameter is set to 'true'
2418 /// if the identifier is treated as if it was followed by ':', not '::'.
2419 ///
2420 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2421 ///
2422 /// \returns true if an error occurred, false otherwise.
2423 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2424 bool EnteringContext, CXXScopeSpec &SS,
2425 bool *IsCorrectedToColon = nullptr,
2426 bool OnlyNamespace = false);
2427
2428 /// The parser has parsed a nested-name-specifier
2429 /// 'template[opt] template-name < template-args >::'.
2430 ///
2431 /// \param S The scope in which this nested-name-specifier occurs.
2432 ///
2433 /// \param SS The nested-name-specifier, which is both an input
2434 /// parameter (the nested-name-specifier before this type) and an
2435 /// output parameter (containing the full nested-name-specifier,
2436 /// including this new type).
2437 ///
2438 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
2439 /// \param TemplateName the template name.
2440 /// \param TemplateNameLoc The location of the template name.
2441 /// \param LAngleLoc The location of the opening angle bracket ('<').
2442 /// \param TemplateArgs The template arguments.
2443 /// \param RAngleLoc The location of the closing angle bracket ('>').
2444 /// \param CCLoc The location of the '::'.
2445 ///
2446 /// \param EnteringContext Whether we're entering the context of the
2447 /// nested-name-specifier.
2448 ///
2449 ///
2450 /// \returns true if an error occurred, false otherwise.
2452 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
2453 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
2454 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
2455 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
2456
2458 SourceLocation ColonColonLoc);
2459
2461 const DeclSpec &DS,
2462 SourceLocation ColonColonLoc,
2463 QualType Type);
2464
2466 NestedNameSpecInfo &IdInfo,
2467 bool EnteringContext);
2468
2469 /// Given a C++ nested-name-specifier, produce an annotation value
2470 /// that the parser can use later to reconstruct the given
2471 /// nested-name-specifier.
2472 ///
2473 /// \param SS A nested-name-specifier.
2474 ///
2475 /// \returns A pointer containing all of the information in the
2476 /// nested-name-specifier \p SS.
2478
2479 /// Given an annotation pointer for a nested-name-specifier, restore
2480 /// the nested-name-specifier structure.
2481 ///
2482 /// \param Annotation The annotation pointer, produced by
2483 /// \c SaveNestedNameSpecifierAnnotation().
2484 ///
2485 /// \param AnnotationRange The source range corresponding to the annotation.
2486 ///
2487 /// \param SS The nested-name-specifier that will be updated with the contents
2488 /// of the annotation pointer.
2489 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
2490 SourceRange AnnotationRange,
2491 CXXScopeSpec &SS);
2492
2493 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2494
2495 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2496 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2497 /// After this method is called, according to [C++ 3.4.3p3], names should be
2498 /// looked up in the declarator-id's scope, until the declarator is parsed and
2499 /// ActOnCXXExitDeclaratorScope is called.
2500 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2502
2503 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2504 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2505 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2506 /// Used to indicate that names should revert to being looked up in the
2507 /// defining scope.
2509
2510 ///@}
2511
2512 //
2513 //
2514 // -------------------------------------------------------------------------
2515 //
2516 //
2517
2518 /// \name Declarations
2519 /// Implementations are in SemaDecl.cpp
2520 ///@{
2521
2522public:
2524
2525 /// The index of the first InventedParameterInfo that refers to the current
2526 /// context.
2528
2529 /// A RAII object to temporarily push a declaration context.
2531 private:
2532 Sema &S;
2533 DeclContext *SavedContext;
2534 ProcessingContextState SavedContextState;
2535 QualType SavedCXXThisTypeOverride;
2536 unsigned SavedFunctionScopesStart;
2537 unsigned SavedInventedParameterInfosStart;
2538
2539 public:
2540 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
2541 : S(S), SavedContext(S.CurContext),
2542 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
2543 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
2544 SavedFunctionScopesStart(S.FunctionScopesStart),
2545 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
2546 assert(ContextToPush && "pushing null context");
2547 S.CurContext = ContextToPush;
2548 if (NewThisContext)
2549 S.CXXThisTypeOverride = QualType();
2550 // Any saved FunctionScopes do not refer to this context.
2551 S.FunctionScopesStart = S.FunctionScopes.size();
2552 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
2553 }
2554
2555 void pop() {
2556 if (!SavedContext)
2557 return;
2558 S.CurContext = SavedContext;
2559 S.DelayedDiagnostics.popUndelayed(SavedContextState);
2560 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
2561 S.FunctionScopesStart = SavedFunctionScopesStart;
2562 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
2563 SavedContext = nullptr;
2564 }
2565
2566 ~ContextRAII() { pop(); }
2567 };
2568
2569 void DiagnoseInvalidJumps(Stmt *Body);
2570
2571 /// The function definitions which were renamed as part of typo-correction
2572 /// to match their respective declarations. We want to keep track of them
2573 /// to ensure that we don't emit a "redefinition" error if we encounter a
2574 /// correctly named definition after the renamed definition.
2576
2577 /// A cache of the flags available in enumerations with the flag_bits
2578 /// attribute.
2579 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
2580
2581 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
2582 /// declared. Rare. May alias another identifier, declared or undeclared.
2583 ///
2584 /// For aliases, the target identifier is used as a key for eventual
2585 /// processing when the target is declared. For the single-identifier form,
2586 /// the sole identifier is used as the key. Each entry is a `SetVector`
2587 /// (ordered by parse order) of aliases (identified by the alias name) in case
2588 /// of multiple aliases to the same undeclared identifier.
2589 llvm::MapVector<
2591 llvm::SetVector<
2593 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
2595
2596 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
2597 /// \#pragma redefine_extname before declared. Used in Solaris system headers
2598 /// to define functions that occur in multiple standards to call the version
2599 /// in the currently selected standard.
2600 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
2601
2602 /// Set containing all typedefs that are likely unused.
2605
2609
2610 /// The set of file scoped decls seen so far that have not been used
2611 /// and must warn if not used. Only contains the first declaration.
2613
2617
2618 /// All the tentative definitions encountered in the TU.
2620
2621 /// All the external declarations encoutered and used in the TU.
2623
2624 /// Generally null except when we temporarily switch decl contexts,
2625 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
2627
2628 /// Is the module scope we are in a C++ Header Unit?
2630 return ModuleScopes.empty() ? false
2631 : ModuleScopes.back().Module->isHeaderUnit();
2632 }
2633
2634 /// Get the module owning an entity.
2635 Module *getOwningModule(const Decl *Entity) {
2636 return Entity->getOwningModule();
2637 }
2638
2639 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
2640
2642 Scope *S, CXXScopeSpec *SS = nullptr,
2643 bool isClassName = false, bool HasTrailingDot = false,
2644 ParsedType ObjectType = nullptr,
2645 bool IsCtorOrDtorName = false,
2646 bool WantNontrivialTypeSourceInfo = false,
2647 bool IsClassTemplateDeductionContext = true,
2648 ImplicitTypenameContext AllowImplicitTypename =
2650 IdentifierInfo **CorrectedII = nullptr);
2652 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
2654 Scope *S, CXXScopeSpec *SS,
2655 ParsedType &SuggestedType,
2656 bool IsTemplateName = false);
2657
2658 /// Attempt to behave like MSVC in situations where lookup of an unqualified
2659 /// type name has failed in a dependent context. In these situations, we
2660 /// automatically form a DependentTypeName that will retry lookup in a related
2661 /// scope during instantiation.
2663 SourceLocation NameLoc,
2664 bool IsTemplateTypeArg);
2665
2666 /// Describes the result of the name lookup and resolution performed
2667 /// by \c ClassifyName().
2669 /// This name is not a type or template in this context, but might be
2670 /// something else.
2672 /// Classification failed; an error has been produced.
2674 /// The name has been typo-corrected to a keyword.
2676 /// The name was classified as a type.
2678 /// The name was classified as a specific non-type, non-template
2679 /// declaration. ActOnNameClassifiedAsNonType should be called to
2680 /// convert the declaration to an expression.
2682 /// The name was classified as an ADL-only function name.
2683 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
2684 /// result to an expression.
2686 /// The name denotes a member of a dependent type that could not be
2687 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
2688 /// convert the result to an expression.
2690 /// The name was classified as an overload set, and an expression
2691 /// representing that overload set has been formed.
2692 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
2693 /// expression referencing the overload set.
2695 /// The name was classified as a template whose specializations are types.
2697 /// The name was classified as a variable template name.
2699 /// The name was classified as a function template name.
2701 /// The name was classified as an ADL-only function template name.
2703 /// The name was classified as a concept name.
2705 };
2706
2709 union {
2714 };
2715
2716 explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
2717
2718 public:
2720
2721 NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
2722
2723 static NameClassification Error() { return NameClassification(NC_Error); }
2724
2726 return NameClassification(NC_Unknown);
2727 }
2728
2730 NameClassification Result(NC_OverloadSet);
2731 Result.Expr = E;
2732 return Result;
2733 }
2734
2736 NameClassification Result(NC_NonType);
2737 Result.NonTypeDecl = D;
2738 return Result;
2739 }
2740
2742 return NameClassification(NC_UndeclaredNonType);
2743 }
2744
2746 return NameClassification(NC_DependentNonType);
2747 }
2748
2750 NameClassification Result(NC_TypeTemplate);
2751 Result.Template = Name;
2752 return Result;
2753 }
2754
2756 NameClassification Result(NC_VarTemplate);
2757 Result.Template = Name;
2758 return Result;
2759 }
2760
2762 NameClassification Result(NC_FunctionTemplate);
2763 Result.Template = Name;
2764 return Result;
2765 }
2766
2768 NameClassification Result(NC_Concept);
2769 Result.Template = Name;
2770 return Result;
2771 }
2772
2774 NameClassification Result(NC_UndeclaredTemplate);
2775 Result.Template = Name;
2776 return Result;
2777 }
2778
2779 NameClassificationKind getKind() const { return Kind; }
2780
2782 assert(Kind == NC_OverloadSet);
2783 return Expr;
2784 }
2785
2787 assert(Kind == NC_Type);
2788 return Type;
2789 }
2790
2792 assert(Kind == NC_NonType);
2793 return NonTypeDecl;
2794 }
2795
2797 assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
2798 Kind == NC_VarTemplate || Kind == NC_Concept ||
2799 Kind == NC_UndeclaredTemplate);
2800 return Template;
2801 }
2802
2804 switch (Kind) {
2805 case NC_TypeTemplate:
2806 return TNK_Type_template;
2807 case NC_FunctionTemplate:
2808 return TNK_Function_template;
2809 case NC_VarTemplate:
2810 return TNK_Var_template;
2811 case NC_Concept:
2812 return TNK_Concept_template;
2813 case NC_UndeclaredTemplate:
2815 default:
2816 llvm_unreachable("unsupported name classification.");
2817 }
2818 }
2819 };
2820
2821 /// Perform name lookup on the given name, classifying it based on
2822 /// the results of name lookup and the following token.
2823 ///
2824 /// This routine is used by the parser to resolve identifiers and help direct
2825 /// parsing. When the identifier cannot be found, this routine will attempt
2826 /// to correct the typo and classify based on the resulting name.
2827 ///
2828 /// \param S The scope in which we're performing name lookup.
2829 ///
2830 /// \param SS The nested-name-specifier that precedes the name.
2831 ///
2832 /// \param Name The identifier. If typo correction finds an alternative name,
2833 /// this pointer parameter will be updated accordingly.
2834 ///
2835 /// \param NameLoc The location of the identifier.
2836 ///
2837 /// \param NextToken The token following the identifier. Used to help
2838 /// disambiguate the name.
2839 ///
2840 /// \param CCC The correction callback, if typo correction is desired.
2841 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
2842 IdentifierInfo *&Name, SourceLocation NameLoc,
2843 const Token &NextToken,
2844 CorrectionCandidateCallback *CCC = nullptr);
2845
2846 /// Act on the result of classifying a name as an undeclared (ADL-only)
2847 /// non-type declaration.
2849 SourceLocation NameLoc);
2850 /// Act on the result of classifying a name as an undeclared member of a
2851 /// dependent base class.
2853 IdentifierInfo *Name,
2854 SourceLocation NameLoc,
2855 bool IsAddressOfOperand);
2856 /// Act on the result of classifying a name as a specific non-type
2857 /// declaration.
2859 NamedDecl *Found,
2860 SourceLocation NameLoc,
2861 const Token &NextToken);
2862 /// Act on the result of classifying a name as an overload set.
2864
2865 /// Describes the detailed kind of a template name. Used in diagnostics.
2872 Concept,
2874 };
2877
2878 /// Determine whether it's plausible that E was intended to be a
2879 /// template-name.
2881 if (!getLangOpts().CPlusPlus || E.isInvalid())
2882 return false;
2883 Dependent = false;
2884 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
2885 return !DRE->hasExplicitTemplateArgs();
2886 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
2887 return !ME->hasExplicitTemplateArgs();
2888 Dependent = true;
2889 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
2890 return !DSDRE->hasExplicitTemplateArgs();
2891 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
2892 return !DSME->hasExplicitTemplateArgs();
2893 // Any additional cases recognized here should also be handled by
2894 // diagnoseExprIntendedAsTemplateName.
2895 return false;
2896 }
2897
2898 void warnOnReservedIdentifier(const NamedDecl *D);
2899
2901
2903 MultiTemplateParamsArg TemplateParameterLists);
2906 unsigned FailedFoldDiagID);
2911 TemplateIdAnnotation *TemplateId,
2912 bool IsMemberSpecialization);
2913
2914 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
2915
2916 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
2918 const LookupResult &R);
2921 const LookupResult &R);
2922 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
2923 const LookupResult &R);
2924 void CheckShadow(Scope *S, VarDecl *D);
2925
2926 /// Warn if 'E', which is an expression that is about to be modified, refers
2927 /// to a shadowing declaration.
2929
2931
2932 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
2933 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
2934 TypedefNameDecl *NewTD);
2937 TypeSourceInfo *TInfo,
2940 LookupResult &Previous, bool &Redeclaration);
2942 Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo,
2943 LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists,
2944 bool &AddToScope, ArrayRef<BindingDecl *> Bindings = std::nullopt);
2945
2946 // Returns true if the variable declaration is a redeclaration
2950
2952 TypeSourceInfo *TInfo,
2954 MultiTemplateParamsArg TemplateParamLists,
2955 bool &AddToScope);
2957
2958 // Returns true if the function declaration is a redeclaration
2961 bool IsMemberSpecialization, bool DeclIsDefn);
2964 QualType NewT, QualType OldT);
2965 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
2968 bool IsDefinition);
2971 SourceLocation ExplicitThisLoc = {});
2972 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
2973 QualType T);
2974 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
2975 SourceLocation NameLoc,
2976 const IdentifierInfo *Name, QualType T,
2977 TypeSourceInfo *TSInfo, StorageClass SC);
2978
2979 // Contexts where using non-trivial C union types can be disallowed. This is
2980 // passed to err_non_trivial_c_union_in_invalid_context.
2982 // Function parameter.
2984 // Function return.
2986 // Default-initialized object.
2988 // Variable with automatic storage duration.
2990 // Initializer expression that might copy from another object.
2992 // Assignment.
2994 // Compound literal.
2996 // Block capture.
2998 // lvalue-to-rvalue conversion of volatile type.
3000 };
3001
3002 /// Emit diagnostics if the initializer or any of its explicit or
3003 /// implicitly-generated subexpressions require copying or
3004 /// default-initializing a type that is or contains a C union type that is
3005 /// non-trivial to copy or default-initialize.
3007
3008 // These flags are passed to checkNonTrivialCUnion.
3013 };
3014
3015 /// Emit diagnostics if a non-trivial C union type or a struct that contains
3016 /// a non-trivial C union is used in an invalid context.
3018 NonTrivialCUnionContext UseContext,
3019 unsigned NonTrivialKind);
3020
3021 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
3022 void ActOnUninitializedDecl(Decl *dcl);
3023 void ActOnInitializerError(Decl *Dcl);
3024
3025 void ActOnCXXForRangeDecl(Decl *D);
3027 IdentifierInfo *Ident,
3028 ParsedAttributes &Attrs);
3029
3032 void FinalizeDeclaration(Decl *D);
3034 ArrayRef<Decl *> Group);
3036
3037 /// Should be called on all declarations that might have attached
3038 /// documentation comments.
3039 void ActOnDocumentableDecl(Decl *D);
3041
3042 enum class FnBodyKind {
3043 /// C++26 [dcl.fct.def.general]p1
3044 /// function-body:
3045 /// ctor-initializer[opt] compound-statement
3046 /// function-try-block
3047 Other,
3048 /// = default ;
3049 Default,
3050 /// deleted-function-body
3051 ///
3052 /// deleted-function-body:
3053 /// = delete ;
3054 /// = delete ( unevaluated-string ) ;
3055 Delete
3056 };
3057
3059 SourceLocation LocAfterDecls);
3061 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
3062 SkipBodyInfo *SkipBody = nullptr);
3064 MultiTemplateParamsArg TemplateParamLists,
3065 SkipBodyInfo *SkipBody = nullptr,
3066 FnBodyKind BodyKind = FnBodyKind::Other);
3068 SkipBodyInfo *SkipBody = nullptr,
3069 FnBodyKind BodyKind = FnBodyKind::Other);
3071
3072 /// Determine whether we can delay parsing the body of a function or
3073 /// function template until it is used, assuming we don't care about emitting
3074 /// code for that function.
3075 ///
3076 /// This will be \c false if we may need the body of the function in the
3077 /// middle of parsing an expression (where it's impractical to switch to
3078 /// parsing a different function), for instance, if it's constexpr in C++11
3079 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
3080 bool canDelayFunctionBody(const Declarator &D);
3081
3082 /// Determine whether we can skip parsing the body of a function
3083 /// definition, assuming we don't care about analyzing its body or emitting
3084 /// code for that function.
3085 ///
3086 /// This will be \c false only if we may need the body of the function in
3087 /// order to parse the rest of the program (for instance, if it is
3088 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
3089 bool canSkipFunctionBody(Decl *D);
3090
3093 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
3096
3097 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
3098 /// attribute for which parsing is delayed.
3100
3101 /// Diagnose any unused parameters in the given sequence of
3102 /// ParmVarDecl pointers.
3104
3105 /// Diagnose whether the size of parameters or return value of a
3106 /// function or obj-c method definition is pass-by-value and larger than a
3107 /// specified threshold.
3108 void
3110 QualType ReturnTy, NamedDecl *D);
3111
3113 SourceLocation RParenLoc);
3114
3117
3119
3121 const ParsedAttributesView &DeclAttrs,
3122 RecordDecl *&AnonRecord);
3124 const ParsedAttributesView &DeclAttrs,
3125 MultiTemplateParamsArg TemplateParams,
3126 bool IsExplicitInstantiation,
3127 RecordDecl *&AnonRecord);
3128
3131 const PrintingPolicy &Policy);
3132
3133 /// Called once it is known whether
3134 /// a tag declaration is an anonymous union or struct.
3136
3138
3141
3142 /// Common ways to introduce type names without a tag for use in diagnostics.
3143 /// Keep in sync with err_tag_reference_non_tag.
3154 };
3155
3156 /// Given a non-tag type declaration, returns an enum useful for indicating
3157 /// what kind of non-tag type this is.
3159
3161 bool isDefinition, SourceLocation NewTagLoc,
3162 const IdentifierInfo *Name);
3163
3165 TUK_Reference, // Reference to a tag: 'struct foo *X;'
3166 TUK_Declaration, // Fwd decl of a tag: 'struct foo;'
3167 TUK_Definition, // Definition of a tag: 'struct foo { int X; } Y;'
3168 TUK_Friend // Friend declaration: 'friend struct foo;'
3170
3172 // Not parsing a type within __builtin_offsetof.
3174 // Parsing a type within __builtin_offsetof.
3176 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
3177 // To improve our diagnostic message.
3179 };
3180
3181 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
3182 SourceLocation KWLoc, CXXScopeSpec &SS,
3183 IdentifierInfo *Name, SourceLocation NameLoc,
3185 SourceLocation ModulePrivateLoc,
3186 MultiTemplateParamsArg TemplateParameterLists,
3187 bool &OwnedDecl, bool &IsDependent,
3188 SourceLocation ScopedEnumKWLoc,
3189 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
3190 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
3191 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
3192
3193 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
3194 Declarator &D, Expr *BitfieldWidth);
3195
3196 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
3197 Declarator &D, Expr *BitfieldWidth,
3198 InClassInitStyle InitStyle, AccessSpecifier AS);
3199
3202 SourceLocation Loc, bool Mutable,
3203 Expr *BitfieldWidth, InClassInitStyle InitStyle,
3205 NamedDecl *PrevDecl, Declarator *D = nullptr);
3206
3208
3209 void ActOnLastBitfield(SourceLocation DeclStart,
3210 SmallVectorImpl<Decl *> &AllIvarDecls);
3211
3212 // This is used for both record definitions and ObjC interface declarations.
3213 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
3214 ArrayRef<Decl *> Fields, SourceLocation LBrac,
3215 SourceLocation RBrac, const ParsedAttributesView &AttrList);
3216
3217 /// ActOnTagStartDefinition - Invoked when we have entered the
3218 /// scope of a tag's definition (e.g., for an enumeration, class,
3219 /// struct, or union).
3221
3222 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
3223 /// Differently from C++, actually parse the body and reject / error out
3224 /// in case of a structural mismatch.
3225 bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody);
3226
3228
3229 /// Invoked when we enter a tag definition that we're skipping.
3231
3232 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
3233 /// C++ record definition's base-specifiers clause and are starting its
3234 /// member declarations.
3236 SourceLocation FinalLoc,
3237 bool IsFinalSpelledSealed,
3238 bool IsAbstract,
3239 SourceLocation LBraceLoc);
3240
3241 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
3242 /// the definition of a tag (enumeration, class, struct, or union).
3244 SourceRange BraceRange);
3245
3247
3248 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
3249 /// error parsing the definition of a tag.
3251
3253 EnumConstantDecl *LastEnumConst,
3255 Expr *val);
3257 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
3258 QualType EnumUnderlyingTy, bool IsFixed,
3259 const EnumDecl *Prev);
3260
3261 /// Determine whether the body of an anonymous enumeration should be skipped.
3262 /// \param II The name of the first enumerator.
3264 SourceLocation IILoc);
3265
3266 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
3268 const ParsedAttributesView &Attrs,
3269 SourceLocation EqualLoc, Expr *Val);
3270 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
3271 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
3272 const ParsedAttributesView &Attr);
3273
3274 /// Set the current declaration context until it gets popped.
3275 void PushDeclContext(Scope *S, DeclContext *DC);
3276 void PopDeclContext();
3277
3278 /// EnterDeclaratorContext - Used when we must lookup names in the context
3279 /// of a declarator's nested name specifier.
3282
3283 /// Enter a template parameter scope, after it's been associated with a
3284 /// particular DeclContext. Causes lookup within the scope to chain through
3285 /// enclosing contexts in the correct order.
3287
3288 /// Push the parameters of D, which must be a function, into scope.
3291
3292 /// Add this decl to the scope shadowed decl chains.
3293 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
3294
3295 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
3296 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
3297 /// true if 'D' belongs to the given declaration context.
3298 ///
3299 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
3300 /// enclosing namespace set of the context, rather than contained
3301 /// directly within it.
3302 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
3303 bool AllowInlineNamespace = false) const;
3304
3305 /// Finds the scope corresponding to the given decl context, if it
3306 /// happens to be an enclosing scope. Otherwise return NULL.
3308
3309 /// Subroutines of ActOnDeclarator().
3311 TypeSourceInfo *TInfo);
3312 bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New);
3313
3314 /// Describes the kind of merge to perform for availability
3315 /// attributes (including "deprecated", "unavailable", and "availability").
3317 /// Don't merge availability attributes at all.
3319 /// Merge availability attributes for a redeclaration, which requires
3320 /// an exact match.
3322 /// Merge availability attributes for an override, which requires
3323 /// an exact match or a weakening of constraints.
3325 /// Merge availability attributes for an implementation of
3326 /// a protocol requirement.
3328 /// Merge availability attributes for an implementation of
3329 /// an optional protocol requirement.
3332
3333 void mergeDeclAttributes(NamedDecl *New, Decl *Old,
3336 LookupResult &OldDecls);
3337 bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
3338 bool MergeTypeWithOld, bool NewDeclIsDefn);
3340 Scope *S, bool MergeTypeWithOld);
3343 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
3344 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
3345 void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
3346
3348 bool ConsiderLinkage, bool AllowInlineNamespace);
3349
3353 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
3354
3356
3357 /// If it's a file scoped decl that must warn if not used, keep track
3358 /// of it.
3360
3361 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
3363
3366 DiagReceiverTy DiagReceiver);
3367 void DiagnoseUnusedDecl(const NamedDecl *ND);
3368 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
3369
3370 /// If VD is set but not otherwise used, diagnose, for a parameter or a
3371 /// variable.
3372 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
3373
3375
3379 bool ForRedeclaration, SourceLocation Loc);
3380
3381 /// Get the outermost AttributedType node that sets a calling convention.
3382 /// Valid types should not have multiple attributes with different CCs.
3384
3387
3388 /// ParsingInitForAutoVars - a set of declarations with auto types for which
3389 /// we are currently parsing the initializer.
3391
3392 /// Look for a locally scoped extern "C" declaration by the given name.
3394
3396
3398
3400
3401 /// Checks if the variant/multiversion functions are compatible.
3403 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
3404 const PartialDiagnostic &NoProtoDiagID,
3405 const PartialDiagnosticAt &NoteCausedDiagIDAt,
3406 const PartialDiagnosticAt &NoSupportDiagIDAt,
3407 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
3408 bool ConstexprSupported, bool CLinkageMayDiffer);
3409
3410 /// type checking declaration initializers (C99 6.7.8)
3412 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
3413
3417 Expr *Init);
3418
3420 Expr *Init);
3421
3423
3424 // Heuristically tells if the function is `get_return_object` member of a
3425 // coroutine promise_type by matching the function name.
3426 static bool CanBeGetReturnObject(const FunctionDecl *FD);
3427 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
3428
3430 Scope *S);
3432 FunctionDecl *FD);
3434
3435 /// VerifyBitField - verifies that a bit field expression is an ICE and has
3436 /// the correct width, and that the field type is valid.
3437 /// Returns false on success.
3439 const IdentifierInfo *FieldName, QualType FieldTy,
3440 bool IsMsStruct, Expr *BitWidth);
3441
3442 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
3443 /// enum. If AllowMask is true, then we also allow the complement of a valid
3444 /// value, to be used as a mask.
3445 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
3446 bool AllowMask) const;
3447
3448 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
3449 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
3450 SourceLocation WeakNameLoc);
3451
3452 /// ActOnPragmaRedefineExtname - Called on well formed
3453 /// \#pragma redefine_extname oldname newname.
3455 IdentifierInfo *AliasName,
3456 SourceLocation PragmaLoc,
3457 SourceLocation WeakNameLoc,
3458 SourceLocation AliasNameLoc);
3459
3460 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
3461 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
3462 SourceLocation PragmaLoc,
3463 SourceLocation WeakNameLoc,
3464 SourceLocation AliasNameLoc);
3465
3466 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
3468 Emitted,
3469 CUDADiscarded, // Discarded due to CUDA/HIP hostness
3470 OMPDiscarded, // Discarded due to OpenMP hostness
3471 TemplateDiscarded, // Discarded due to uninstantiated templates
3472 Unknown,
3473 };
3474 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
3475 bool Final = false);
3476
3477 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
3479
3480private:
3481 /// Function or variable declarations to be checked for whether the deferred
3482 /// diagnostics should be emitted.
3483 llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
3484
3485 /// Map of current shadowing declarations to shadowed declarations. Warn if
3486 /// it looks like the user is trying to modify the shadowing declaration.
3487 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
3488
3489 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
3490
3491 ///@}
3492
3493 //
3494 //
3495 // -------------------------------------------------------------------------
3496 //
3497 //
3498
3499 /// \name Declaration Attribute Handling
3500 /// Implementations are in SemaDeclAttr.cpp
3501 ///@{
3502
3503public:
3504 /// Describes the kind of priority given to an availability attribute.
3505 ///
3506 /// The sum of priorities deteremines the final priority of the attribute.
3507 /// The final priority determines how the attribute will be merged.
3508 /// An attribute with a lower priority will always remove higher priority
3509 /// attributes for the specified platform when it is being applied. An
3510 /// attribute with a higher priority will not be applied if the declaration
3511 /// already has an availability attribute with a lower priority for the
3512 /// specified platform. The final prirority values are not expected to match
3513 /// the values in this enumeration, but instead should be treated as a plain
3514 /// integer value. This enumeration just names the priority weights that are
3515 /// used to calculate that final vaue.
3517 /// The availability attribute was specified explicitly next to the
3518 /// declaration.
3520
3521 /// The availability attribute was applied using '#pragma clang attribute'.
3523
3524 /// The availability attribute for a specific platform was inferred from
3525 /// an availability attribute for another platform.
3528
3529 /// Describes the reason a calling convention specification was ignored, used
3530 /// for diagnostics.
3532 ForThisTarget = 0,
3536 };
3537
3538 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
3539 /// \#pragma weak during processing of other Decls.
3540 /// I couldn't figure out a clean way to generate these in-line, so
3541 /// we store them here and handle separately -- which is a hack.
3542 /// It would be best to refactor this.
3544
3545 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
3547
3551
3552 /// ExtVectorDecls - This is a list all the extended vector types. This allows
3553 /// us to associate a raw vector type with one of the ext_vector type names.
3554 /// This is only necessary for issuing pretty diagnostics.
3556
3558 const Expr *E, StringRef &Str,
3559 SourceLocation *ArgLocation = nullptr);
3560 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
3561 StringRef &Str,
3562 SourceLocation *ArgLocation = nullptr);
3563
3564 /// Determine if type T is a valid subject for a nonnull and similar
3565 /// attributes. By default, we look through references (the behavior used by
3566 /// nonnull), but if the second parameter is true, then we treat a reference
3567 /// type as valid.
3568 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
3569
3570 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
3571 /// declaration.
3572 void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
3573 Expr *OE);
3574
3575 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
3576 /// declaration.
3577 void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
3578 Expr *ParamExpr);
3579
3580 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
3581 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
3582
3583 AvailabilityAttr *
3585 IdentifierInfo *Platform, bool Implicit,
3586 VersionTuple Introduced, VersionTuple Deprecated,
3587 VersionTuple Obsoleted, bool IsUnavailable,
3588 StringRef Message, bool IsStrict, StringRef Replacement,
3590 TypeVisibilityAttr *
3592 TypeVisibilityAttr::VisibilityType Vis);
3593 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
3594 VisibilityAttr::VisibilityType Vis);
3595 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
3596 StringRef Name);
3597
3598 llvm::Error isValidSectionSpecifier(StringRef Str);
3599 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
3600 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
3601 StringRef Name);
3602
3603 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
3604 bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
3605 StringRef &Str, bool &isDefault);
3607 SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
3608 Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
3609 SmallVectorImpl<SmallString<64>> &StringsBuffer);
3610
3611 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
3612 StringRef NewUserDiagnostic);
3613 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
3614 IdentifierInfo *Format, int FormatIdx,
3615 int FirstArg);
3616
3617 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
3618 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
3619 bool IsPackExpansion);
3621 bool IsPackExpansion);
3622
3623 /// AddAlignValueAttr - Adds an align_value attribute to a particular
3624 /// declaration.
3625 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
3626
3627 /// AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
3628 void AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI,
3629 StringRef Annot, MutableArrayRef<Expr *> Args);
3630
3632 bool BestCase,
3633 MSInheritanceModel SemanticSpelling);
3634
3636
3637 /// AddModeAttr - Adds a mode attribute to a particular declaration.
3638 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
3639 bool InInstantiation = false);
3640 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
3641 const AttributeCommonInfo &CI,
3642 const IdentifierInfo *Ident);
3643 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
3644 SwiftNameAttr *mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
3645 StringRef Name);
3646 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
3647 const AttributeCommonInfo &CI);
3648 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
3649 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
3650 const InternalLinkageAttr &AL);
3651
3652 /// Check validaty of calling convention attribute \p attr. If \p FD
3653 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
3654 /// target. Otherwise, it is specified by \p CFT.
3656 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
3658
3659 void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI,
3660 ParameterABI ABI);
3661 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
3662
3663 /// Create an CUDALaunchBoundsAttr attribute.
3664 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
3665 Expr *MaxThreads,
3666 Expr *MinBlocks,
3667 Expr *MaxBlocks);
3668
3669 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
3670 /// declaration.
3671 void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
3672 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
3673
3674 enum class RetainOwnershipKind { NS, CF, OS };
3675 void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI,
3676 RetainOwnershipKind K, bool IsTemplateInstantiation);
3677
3679
3680 /// Do a check to make sure \p Name looks like a legal argument for the
3681 /// swift_name attribute applied to decl \p D. Raise a diagnostic if the name
3682 /// is invalid for the given declaration.
3683 ///
3684 /// \p AL is used to provide caret diagnostics in case of a malformed name.
3685 ///
3686 /// \returns true if the name is a valid swift name for \p D, false otherwise.
3687 bool DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc,
3688 const ParsedAttr &AL, bool IsAsync);
3689
3690 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
3691 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
3692
3693 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
3694
3695 WebAssemblyImportNameAttr *
3696 mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL);
3697 WebAssemblyImportModuleAttr *
3698 mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL);
3699
3700 /// Create an AMDGPUWavesPerEUAttr attribute.
3701 AMDGPUFlatWorkGroupSizeAttr *
3703 Expr *Max);
3704
3705 /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
3706 /// attribute to a particular declaration.
3708 Expr *Min, Expr *Max);
3709
3710 /// Create an AMDGPUWavesPerEUAttr attribute.
3711 AMDGPUWavesPerEUAttr *
3713 Expr *Max);
3714
3715 /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
3716 /// particular declaration.
3718 Expr *Min, Expr *Max);
3719
3720 /// Create an AMDGPUMaxNumWorkGroupsAttr attribute.
3721 AMDGPUMaxNumWorkGroupsAttr *
3723 Expr *YExpr, Expr *ZExpr);
3724
3725 /// addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups
3726 /// attribute to a particular declaration.
3728 Expr *XExpr, Expr *YExpr, Expr *ZExpr);
3729
3730 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
3731 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
3732 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
3733 const AttributeCommonInfo &CI,
3734 bool BestCase,
3735 MSInheritanceModel Model);
3736
3737 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
3738 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
3739 const EnforceTCBLeafAttr &AL);
3740
3741 // Helper for delayed processing of attributes.
3743 const ParsedAttributesView &AttrList);
3744
3745 // Options for ProcessDeclAttributeList().
3748 : IncludeCXX11Attributes(true), IgnoreTypeAttributes(false) {}
3749
3751 ProcessDeclAttributeOptions Result = *this;
3752 Result.IncludeCXX11Attributes = Val;
3753 return Result;
3754 }
3755
3757 ProcessDeclAttributeOptions Result = *this;
3758 Result.IgnoreTypeAttributes = Val;
3759 return Result;
3760 }
3761
3762 // Should C++11 attributes be processed?
3764
3765 // Should any type attributes encountered be ignored?
3766 // If this option is false, a diagnostic will be emitted for any type
3767 // attributes of a kind that does not "slide" from the declaration to
3768 // the decl-specifier-seq.
3770 };
3771
3773 const ParsedAttributesView &AttrList,
3774 const ProcessDeclAttributeOptions &Options =
3777 const ParsedAttributesView &AttrList);
3778
3780
3783 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
3784
3785 void ProcessPragmaWeak(Scope *S, Decl *D);
3786 // Decl attributes - this routine is the top level dispatcher.
3787 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
3788
3790
3792
3793 ///@}
3794
3795 //
3796 //
3797 // -------------------------------------------------------------------------
3798 //
3799 //
3800
3801 /// \name C++ Declarations
3802 /// Implementations are in SemaDeclCXX.cpp
3803 ///@{
3804
3805public:
3807
3808 /// Called before parsing a function declarator belonging to a function
3809 /// declaration.
3811 unsigned TemplateParameterDepth);
3812
3813 /// Called after parsing a function declarator belonging to a function
3814 /// declaration.
3816
3817 // Act on C++ namespaces
3819 SourceLocation NamespaceLoc,
3820 SourceLocation IdentLoc, IdentifierInfo *Ident,
3821 SourceLocation LBrace,
3822 const ParsedAttributesView &AttrList,
3823 UsingDirectiveDecl *&UsingDecl, bool IsNested);
3824 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
3825
3828
3830 EnumDecl *getStdAlignValT() const;
3831
3833 const IdentifierInfo *MemberOrBase);
3834
3836 /// The '<=>' operator was used in an expression and a builtin operator
3837 /// was selected.
3839 /// A defaulted 'operator<=>' needed the comparison category. This
3840 /// typically only applies to 'std::strong_ordering', due to the implicit
3841 /// fallback return value.
3843 };
3844
3845 /// Lookup the specified comparison category types in the standard
3846 /// library, an check the VarDecls possibly returned by the operator<=>
3847 /// builtins for that type.
3848 ///
3849 /// \return The type of the comparison category type corresponding to the
3850 /// specified Kind, or a null type if an error occurs
3854
3855 /// Tests whether Ty is an instance of std::initializer_list and, if
3856 /// it is and Element is not NULL, assigns the element type to Element.
3857 bool isStdInitializerList(QualType Ty, QualType *Element);
3858
3859 /// Looks for the std::initializer_list template and instantiates it
3860 /// with Element, or emits an error if it's not found.
3861 ///
3862 /// \returns The instantiated template, or null on error.
3864
3865 /// Determine whether Ctor is an initializer-list constructor, as
3866 /// defined in [dcl.init.list]p2.
3867 bool isInitListConstructor(const FunctionDecl *Ctor);
3868
3869 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
3870 SourceLocation NamespcLoc, CXXScopeSpec &SS,
3871 SourceLocation IdentLoc,
3872 IdentifierInfo *NamespcName,
3873 const ParsedAttributesView &AttrList);
3874
3876
3877 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
3878 SourceLocation AliasLoc, IdentifierInfo *Alias,
3879 CXXScopeSpec &SS, SourceLocation IdentLoc,
3880 IdentifierInfo *Ident);
3881
3882 void FilterUsingLookup(Scope *S, LookupResult &lookup);
3883 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
3885 const LookupResult &PreviousDecls,
3886 UsingShadowDecl *&PrevShadow);
3889 UsingShadowDecl *PrevDecl);
3890
3892 bool HasTypenameKeyword,
3893 const CXXScopeSpec &SS,
3894 SourceLocation NameLoc,
3895 const LookupResult &Previous);
3896 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
3897 const CXXScopeSpec &SS,
3898 const DeclarationNameInfo &NameInfo,
3899 SourceLocation NameLoc,
3900 const LookupResult *R = nullptr,
3901 const UsingDecl *UD = nullptr);
3902
3904 SourceLocation UsingLoc,
3905 bool HasTypenameKeyword,
3906 SourceLocation TypenameLoc, CXXScopeSpec &SS,
3907 DeclarationNameInfo NameInfo,
3908 SourceLocation EllipsisLoc,
3909 const ParsedAttributesView &AttrList,
3910 bool IsInstantiation, bool IsUsingIfExists);
3912 SourceLocation UsingLoc,
3913 SourceLocation EnumLoc,
3914 SourceLocation NameLoc,
3916 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
3917 ArrayRef<NamedDecl *> Expansions);
3918
3920
3921 /// Given a derived-class using shadow declaration for a constructor and the
3922 /// correspnding base class constructor, find or create the implicit
3923 /// synthesized derived class constructor to use for this initialization.
3926 ConstructorUsingShadowDecl *DerivedShadow);
3927
3929 SourceLocation UsingLoc,
3930 SourceLocation TypenameLoc, CXXScopeSpec &SS,
3931 UnqualifiedId &Name, SourceLocation EllipsisLoc,
3932 const ParsedAttributesView &AttrList);
3934 SourceLocation UsingLoc,
3935 SourceLocation EnumLoc,
3936 SourceLocation IdentLoc, IdentifierInfo &II,
3937 CXXScopeSpec *SS = nullptr);
3939 MultiTemplateParamsArg TemplateParams,
3940 SourceLocation UsingLoc, UnqualifiedId &Name,
3941 const ParsedAttributesView &AttrList,
3942 TypeResult Type, Decl *DeclFromDeclSpec);
3943
3944 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
3945 /// including handling of its default argument expressions.
3946 ///
3947 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
3949 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
3950 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
3951 bool HadMultipleCandidates, bool IsListInitialization,
3952 bool IsStdInitListInitialization, bool RequiresZeroInit,
3953 CXXConstructionKind ConstructKind, SourceRange ParenRange);
3954
3955 /// Build a CXXConstructExpr whose constructor has already been resolved if
3956 /// it denotes an inherited constructor.
3958 SourceLocation ConstructLoc, QualType DeclInitType,
3959 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
3960 bool HadMultipleCandidates, bool IsListInitialization,
3961 bool IsStdInitListInitialization, bool RequiresZeroInit,
3962 CXXConstructionKind ConstructKind, SourceRange ParenRange);
3963
3964 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
3965 // the constructor can be elidable?
3967 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
3968 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
3969 bool HadMultipleCandidates, bool IsListInitialization,
3970 bool IsStdInitListInitialization, bool RequiresZeroInit,
3971 CXXConstructionKind ConstructKind, SourceRange ParenRange);
3972
3974 SourceLocation InitLoc);
3975
3976 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
3977 /// constructed variable.
3978 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
3979
3980 /// Helper class that collects exception specifications for
3981 /// implicitly-declared special member functions.
3983 // Pointer to allow copying
3984 Sema *Self;
3985 // We order exception specifications thus:
3986 // noexcept is the most restrictive, but is only used in C++11.
3987 // throw() comes next.
3988 // Then a throw(collected exceptions)
3989 // Finally no specification, which is expressed as noexcept(false).
3990 // throw(...) is used instead if any called function uses it.
3991 ExceptionSpecificationType ComputedEST;
3992 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
3993 SmallVector<QualType, 4> Exceptions;
3994
3995 void ClearExceptions() {
3996 ExceptionsSeen.clear();
3997 Exceptions.clear();
3998 }
3999
4000 public:
4002 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
4003 if (!Self.getLangOpts().CPlusPlus11)
4004 ComputedEST = EST_DynamicNone;
4005 }
4006
4007 /// Get the computed exception specification type.
4009 assert(!isComputedNoexcept(ComputedEST) &&
4010 "noexcept(expr) should not be a possible result");
4011 return ComputedEST;
4012 }
4013
4014 /// The number of exceptions in the exception specification.
4015 unsigned size() const { return Exceptions.size(); }
4016
4017 /// The set of exceptions in the exception specification.
4018 const QualType *data() const { return Exceptions.data(); }
4019
4020 /// Integrate another called method into the collected data.
4021 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
4022
4023 /// Integrate an invoked expression into the collected data.
4024 void CalledExpr(Expr *E) { CalledStmt(E); }
4025
4026 /// Integrate an invoked statement into the collected data.
4027 void CalledStmt(Stmt *S);
4028
4029 /// Overwrite an EPI's exception specification with this
4030 /// computed exception specification.
4033 ESI.Type = getExceptionSpecType();
4034 if (ESI.Type == EST_Dynamic) {
4035 ESI.Exceptions = Exceptions;
4036 } else if (ESI.Type == EST_None) {
4037 /// C++11 [except.spec]p14:
4038 /// The exception-specification is noexcept(false) if the set of
4039 /// potential exceptions of the special member function contains "any"
4040 ESI.Type = EST_NoexceptFalse;
4041 ESI.NoexceptExpr =
4042 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
4043 }
4044 return ESI;
4045 }
4046 };
4047
4048 /// Evaluate the implicit exception specification for a defaulted
4049 /// special member function.
4051
4052 /// Check the given exception-specification and update the
4053 /// exception specification information with the results.
4054 void checkExceptionSpecification(bool IsTopLevel,
4056 ArrayRef<ParsedType> DynamicExceptions,
4057 ArrayRef<SourceRange> DynamicExceptionRanges,
4058 Expr *NoexceptExpr,
4059 SmallVectorImpl<QualType> &Exceptions,
4061
4062 /// Add an exception-specification to the given member or friend function
4063 /// (or function template). The exception-specification was parsed
4064 /// after the function itself was declared.
4066 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
4067 ArrayRef<ParsedType> DynamicExceptions,
4068 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
4069
4070 class InheritedConstructorInfo;
4071
4072 /// Determine if a special member function should have a deleted
4073 /// definition when it is defaulted.
4075 InheritedConstructorInfo *ICI = nullptr,
4076 bool Diagnose = false);
4077
4078 /// Produce notes explaining why a defaulted function was defined as deleted.
4080
4081 /// Declare the implicit default constructor for the given class.
4082 ///
4083 /// \param ClassDecl The class declaration into which the implicit
4084 /// default constructor will be added.
4085 ///
4086 /// \returns The implicitly-declared default constructor.
4089
4090 /// DefineImplicitDefaultConstructor - Checks for feasibility of
4091 /// defining this constructor as the default constructor.
4093 CXXConstructorDecl *Constructor);
4094
4095 /// Declare the implicit destructor for the given class.
4096 ///
4097 /// \param ClassDecl The class declaration into which the implicit
4098 /// destructor will be added.
4099 ///
4100 /// \returns The implicitly-declared destructor.
4102
4103 /// DefineImplicitDestructor - Checks for feasibility of
4104 /// defining this destructor as the default destructor.
4105 void DefineImplicitDestructor(SourceLocation CurrentLocation,
4107
4108 /// Build an exception spec for destructors that don't have one.
4109 ///
4110 /// C++11 says that user-defined destructors with no exception spec get one
4111 /// that looks as if the destructor was implicitly declared.
4113
4114 /// Define the specified inheriting constructor.
4116 CXXConstructorDecl *Constructor);
4117
4118 /// Declare the implicit copy constructor for the given class.
4119 ///
4120 /// \param ClassDecl The class declaration into which the implicit
4121 /// copy constructor will be added.
4122 ///
4123 /// \returns The implicitly-declared copy constructor.
4125
4126 /// DefineImplicitCopyConstructor - Checks for feasibility of
4127 /// defining this constructor as the copy constructor.
4128 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
4129 CXXConstructorDecl *Constructor);
4130
4131 /// Declare the implicit move constructor for the given class.
4132 ///
4133 /// \param ClassDecl The Class declaration into which the implicit
4134 /// move constructor will be added.
4135 ///
4136 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
4137 /// declared.
4139
4140 /// DefineImplicitMoveConstructor - Checks for feasibility of
4141 /// defining this constructor as the move constructor.
4142 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
4143 CXXConstructorDecl *Constructor);
4144
4145 /// Declare the implicit copy assignment operator for the given class.
4146 ///
4147 /// \param ClassDecl The class declaration into which the implicit
4148 /// copy assignment operator will be added.
4149 ///
4150 /// \returns The implicitly-declared copy assignment operator.
4152
4153 /// Defines an implicitly-declared copy assignment operator.
4154 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
4155 CXXMethodDecl *MethodDecl);
4156
4157 /// Declare the implicit move assignment operator for the given class.
4158 ///
4159 /// \param ClassDecl The Class declaration into which the implicit
4160 /// move assignment operator will be added.
4161 ///
4162 /// \returns The implicitly-declared move assignment operator, or NULL if it
4163 /// wasn't declared.
4165
4166 /// Defines an implicitly-declared move assignment operator.
4167 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
4168 CXXMethodDecl *MethodDecl);
4169
4170 /// Check a completed declaration of an implicit special member.
4172
4173 /// Determine whether the given function is an implicitly-deleted
4174 /// special member function.
4176
4177 /// Check whether 'this' shows up in the type of a static member
4178 /// function after the (naturally empty) cv-qualifier-seq would be.
4179 ///
4180 /// \returns true if an error occurred.
4182
4183 /// Whether this' shows up in the exception specification of a static
4184 /// member function.
4186
4187 /// Check whether 'this' shows up in the attributes of the given
4188 /// static member function.
4189 ///
4190 /// \returns true if an error occurred.
4192
4194 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
4195
4197
4199 QualType DeclInitType, MultiExprArg ArgsPtr,
4201 SmallVectorImpl<Expr *> &ConvertedArgs,
4202 bool AllowExplicit = false,
4203 bool IsListInitialization = false);
4204
4205 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
4206 /// initializer for the declaration 'Dcl'.
4207 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
4208 /// static data member of class X, names should be looked up in the scope of
4209 /// class X.
4211
4212 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
4213 /// initializer for the declaration 'Dcl'.
4214 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
4215
4216 /// Define the "body" of the conversion from a lambda object to a
4217 /// function pointer.
4218 ///
4219 /// This routine doesn't actually define a sensible body; rather, it fills
4220 /// in the initialization expression needed to copy the lambda object into
4221 /// the block, and IR generation actually generates the real body of the
4222 /// block pointer conversion.
4223 void
4225 CXXConversionDecl *Conv);
4226
4227 /// Define the "body" of the conversion from a lambda object to a
4228 /// block pointer.
4229 ///
4230 /// This routine doesn't actually define a sensible body; rather, it fills
4231 /// in the initialization expression needed to copy the lambda object into
4232 /// the block, and IR generation actually generates the real body of the
4233 /// block pointer conversion.
4235 CXXConversionDecl *Conv);
4236
4238 Expr *LangStr, SourceLocation LBraceLoc);
4240 SourceLocation RBraceLoc);
4241
4242 //===--------------------------------------------------------------------===//
4243 // C++ Classes
4244 //
4246 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
4247 const CXXScopeSpec *SS = nullptr);
4249
4251 SourceLocation ColonLoc,
4252 const ParsedAttributesView &Attrs);
4253
4254 NamedDecl *
4256 MultiTemplateParamsArg TemplateParameterLists,
4257 Expr *BitfieldWidth, const VirtSpecifiers &VS,
4258 InClassInitStyle InitStyle);
4259
4262 SourceLocation EqualLoc,
4263 Expr *Init);
4264
4266 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
4267 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
4268 const DeclSpec &DS, SourceLocation IdLoc,
4269 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
4270 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
4271
4272 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
4273 CXXScopeSpec &SS,
4274 IdentifierInfo *MemberOrBase,
4275 ParsedType TemplateTypeTy,
4276 const DeclSpec &DS, SourceLocation IdLoc,
4277 Expr *InitList, SourceLocation EllipsisLoc);
4278
4279 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
4280 CXXScopeSpec &SS,
4281 IdentifierInfo *MemberOrBase,
4282 ParsedType TemplateTypeTy,
4283 const DeclSpec &DS, SourceLocation IdLoc,
4284 Expr *Init, SourceLocation EllipsisLoc);
4285
4287 SourceLocation IdLoc);
4288
4290 TypeSourceInfo *BaseTInfo, Expr *Init,
4291 CXXRecordDecl *ClassDecl,
4292 SourceLocation EllipsisLoc);
4293
4295 CXXRecordDecl *ClassDecl);
4296
4299
4301 CXXConstructorDecl *Constructor, bool AnyErrors,
4302 ArrayRef<CXXCtorInitializer *> Initializers = std::nullopt);
4303
4304 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
4305 /// mark all the non-trivial destructors of its members and bases as
4306 /// referenced.
4309
4310 /// Mark destructors of virtual bases of this class referenced. In the Itanium
4311 /// C++ ABI, this is done when emitting a destructor for any non-abstract
4312 /// class. In the Microsoft C++ ABI, this is done any time a class's
4313 /// destructor is referenced.
4315 SourceLocation Location, CXXRecordDecl *ClassDecl,
4316 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases = nullptr);
4317
4318 /// Do semantic checks to allow the complete destructor variant to be emitted
4319 /// when the destructor is defined in another translation unit. In the Itanium
4320 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
4321 /// can be emitted in separate TUs. To emit the complete variant, run a subset
4322 /// of the checks performed when emitting a regular destructor.
4324 CXXDestructorDecl *Dtor);
4325
4326 /// The list of classes whose vtables have been used within
4327 /// this translation unit, and the source locations at which the
4328 /// first use occurred.
4329 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
4330
4331 /// The list of vtables that are required but have not yet been
4332 /// materialized.
4334
4335 /// The set of classes whose vtables have been used within
4336 /// this translation unit, and a bit that will be true if the vtable is
4337 /// required to be emitted (otherwise, it should be emitted only if needed
4338 /// by code generation).
4339 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
4340
4341 /// Load any externally-stored vtable uses.
4343
4344 /// Note that the vtable for the given class was used at the
4345 /// given location.
4347 bool DefinitionRequired = false);
4348
4349 /// Mark the exception specifications of all virtual member functions
4350 /// in the given class as needed.
4352 const CXXRecordDecl *RD);
4353
4354 /// MarkVirtualMembersReferenced - Will mark all members of the given
4355 /// CXXRecordDecl referenced.
4357 bool ConstexprOnly = false);
4358
4359 /// Define all of the vtables that have been used in this
4360 /// translation unit and reference any virtual members used by those
4361 /// vtables.
4362 ///
4363 /// \returns true if any work was done, false otherwise.
4364 bool DefineUsedVTables();
4365
4367
4368 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
4370 bool AnyErrors);
4371
4372 /// Check class-level dllimport/dllexport attribute. The caller must
4373 /// ensure that referenceDLLExportedClassMethods is called some point later
4374 /// when all outer classes of Class are complete.
4377
4379
4381 CXXRecordDecl *Class, Attr *ClassAttr,
4382 ClassTemplateSpecializationDecl *BaseTemplateSpec,
4383 SourceLocation BaseLoc);
4384
4386
4387 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
4388 /// conditions that are needed for the attribute to have an effect.
4390
4392 Decl *TagDecl, SourceLocation LBrac,
4393 SourceLocation RBrac,
4394 const ParsedAttributesView &AttrList);
4397
4399 unsigned ActOnReenterTemplateScope(Decl *Template,
4400 llvm::function_ref<Scope *()> EnterScope);
4403 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
4407
4408 bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result,
4409 ASTContext &Ctx,
4410 bool ErrorOnInvalidMessage);
4412 Expr *AssertExpr, Expr *AssertMessageExpr,
4413 SourceLocation RParenLoc);
4415 Expr *AssertExpr, Expr *AssertMessageExpr,
4416 SourceLocation RParenLoc, bool Failed);
4417 void DiagnoseStaticAssertDetails(const Expr *E);
4418
4419 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
4420 MultiTemplateParamsArg TemplateParams);
4422 MultiTemplateParamsArg TemplateParams);
4423
4425 StorageClass &SC);
4426 void CheckConstructor(CXXConstructorDecl *Constructor);
4428 StorageClass &SC);
4433 StorageClass &SC);
4434
4436
4439 SourceLocation DefaultLoc);
4441
4442 /// Kinds of defaulted comparison operator functions.
4443 enum class DefaultedComparisonKind : unsigned char {
4444 /// This is not a defaultable comparison operator.
4445 None,
4446 /// This is an operator== that should be implemented as a series of
4447 /// subobject comparisons.
4448 Equal,
4449 /// This is an operator<=> that should be implemented as a series of
4450 /// subobject comparisons.
4451 ThreeWay,
4452 /// This is an operator!= that should be implemented as a rewrite in terms
4453 /// of a == comparison.
4454 NotEqual,
4455 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
4456 /// terms of a <=> comparison.
4457 Relational,
4458 };
4459
4463 FunctionDecl *Spaceship);
4466
4468 QualType R, bool IsLambda,
4469 DeclContext *DC = nullptr);
4471 DeclarationName Name, QualType R);
4473
4474 //===--------------------------------------------------------------------===//
4475 // C++ Derived Classes
4476 //
4477
4478 /// ActOnBaseSpecifier - Parsed a base specifier
4480 SourceRange SpecifierRange, bool Virtual,
4481 AccessSpecifier Access,
4482 TypeSourceInfo *TInfo,
4483 SourceLocation EllipsisLoc);
4484
4485 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
4486 const ParsedAttributesView &Attrs, bool Virtual,
4487 AccessSpecifier Access, ParsedType basetype,
4488 SourceLocation BaseLoc,
4489 SourceLocation EllipsisLoc);
4490
4493 void ActOnBaseSpecifiers(Decl *ClassDecl,
4495
4498 CXXBasePaths &Paths);
4499
4500 // FIXME: I don't like this name.
4501 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
4502
4505 CXXCastPath *BasePath = nullptr,
4506 bool IgnoreAccess = false);
4508 unsigned InaccessibleBaseID,
4509 unsigned AmbiguousBaseConvID,
4511 DeclarationName Name, CXXCastPath *BasePath,
4512 bool IgnoreAccess = false);
4513
4514 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
4515
4517 const CXXMethodDecl *Old);
4518
4519 /// CheckOverridingFunctionReturnType - Checks whether the return types are
4520 /// covariant, according to C++ [class.virtual]p5.
4522 const CXXMethodDecl *Old);
4523
4524 // Check that the overriding method has no explicit object parameter.
4526 const CXXMethodDecl *Old);
4527
4528 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
4529
4530 /// CheckOverrideControl - Check C++11 override control semantics.
4532
4533 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
4534 /// not used in the declaration of an overriding method.
4536
4537 /// CheckForFunctionMarkedFinal - Checks whether a virtual member function
4538 /// overrides a virtual member function marked 'final', according to
4539 /// C++11 [class.virtual]p4.
4541 const CXXMethodDecl *Old);
4542
4553
4554 struct TypeDiagnoser;
4555
4558 TypeDiagnoser &Diagnoser);
4559 template <typename... Ts>
4561 const Ts &...Args) {
4562 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
4563 return RequireNonAbstractType(Loc, T, Diagnoser);
4564 }
4565
4566 void DiagnoseAbstractType(const CXXRecordDecl *RD);
4567
4568 //===--------------------------------------------------------------------===//
4569 // C++ Overloaded Operators [C++ 13.5]
4570 //
4571
4573
4575
4576 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
4577 /// found in an explicit(bool) specifier.
4579
4580 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
4581 /// Returns true if the explicit specifier is now resolved.
4583
4585
4586 // Emitting members of dllexported classes is delayed until the class
4587 // (including field initializers) is fully parsed.
4590
4593
4594 /// Helpers for dealing with blocks and functions.
4597
4600 }
4601
4603 SourceLocation StartLoc,
4604 SourceLocation IdLoc,
4605 const IdentifierInfo *Id);
4606
4608
4610
4612 unsigned TagSpec, SourceLocation TagLoc,
4613 CXXScopeSpec &SS, IdentifierInfo *Name,
4614 SourceLocation NameLoc,
4616 MultiTemplateParamsArg TempParamLists);
4617
4619 SourceLocation DeclStart, Declarator &D,
4620 Expr *BitfieldWidth,
4621 InClassInitStyle InitStyle,
4622 AccessSpecifier AS,
4623 const ParsedAttr &MSPropertyAttr);
4624
4627
4629 /// The triviality of a method unaffected by "trivial_abi".
4631
4632 /// The triviality of a method affected by "trivial_abi".
4635
4638 bool Diagnose = false);
4639
4640 /// For a defaulted function, the kind of defaulted function that it is.
4642 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
4643 unsigned SpecialMember : 8;
4644 unsigned Comparison : 8;
4645
4646 public:
4648 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
4649 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
4651 : SpecialMember(llvm::to_underlying(CSM)),
4652 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
4654 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
4655 Comparison(llvm::to_underlying(Comp)) {}
4656
4657 bool isSpecialMember() const {
4658 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
4659 CXXSpecialMemberKind::Invalid;
4660 }
4661 bool isComparison() const {
4662 return static_cast<DefaultedComparisonKind>(Comparison) !=
4663 DefaultedComparisonKind::None;
4664 }
4665
4666 explicit operator bool() const {
4667 return isSpecialMember() || isComparison();
4668 }
4669
4671 return static_cast<CXXSpecialMemberKind>(SpecialMember);
4672 }
4674 return static_cast<DefaultedComparisonKind>(Comparison);
4675 }
4676
4677 /// Get the index of this function kind for use in diagnostics.
4678 unsigned getDiagnosticIndex() const {
4679 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
4680 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
4681 "invalid should have highest index");
4682 static_assert((unsigned)DefaultedComparisonKind::None == 0,
4683 "none should be equal to zero");
4684 return SpecialMember + Comparison;
4685 }
4686 };
4687
4688 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
4689
4690 /// Handle a C++11 empty-declaration and attribute-declaration.
4692 SourceLocation SemiLoc);
4693
4695 /// Diagnose issues that are non-constant or that are extensions.
4696 Diagnose,
4697 /// Identify whether this function satisfies the formal rules for constexpr
4698 /// functions in the current lanugage mode (with no extensions).
4700 };
4701
4703 CheckConstexprKind Kind);
4704
4706 void
4708 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
4709 void
4711 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
4712 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
4713 Expr *defarg);
4715 SourceLocation ArgLoc);
4717 Expr *DefaultArg);
4719 SourceLocation EqualLoc);
4720 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
4721 SourceLocation EqualLoc);
4722
4723 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
4724 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
4725 StringLiteral *Message = nullptr);
4726 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
4727
4729 StringLiteral *DeletedMessage = nullptr);
4733
4734 NamedDecl *
4736 MultiTemplateParamsArg TemplateParamLists);
4739 RecordDecl *ClassDecl,
4740 const IdentifierInfo *Name);
4741
4743
4744 /// Stack containing information needed when in C++2a an 'auto' is encountered
4745 /// in a function declaration parameter type specifier in order to invent a
4746 /// corresponding template parameter in the enclosing abbreviated function
4747 /// template. This information is also present in LambdaScopeInfo, stored in
4748 /// the FunctionScopes stack.
4750
4751 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
4752 std::unique_ptr<CXXFieldCollector> FieldCollector;
4753
4755 /// Set containing all declared private fields that are not used.
4757
4759
4760 /// PureVirtualClassDiagSet - a set of class declarations which we have
4761 /// emitted a list of pure virtual functions. Used to prevent emitting the
4762 /// same list more than once.
4763 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
4764
4768
4769 /// All the delegating constructors seen so far in the file, used for
4770 /// cycle detection at the end of the TU.
4772
4773 /// The C++ "std" namespace, where the standard library resides.
4775
4776 /// The C++ "std::initializer_list" template, which is defined in
4777 /// <initializer_list>.
4779
4780 // Contains the locations of the beginning of unparsed default
4781 // argument locations.
4782 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
4783
4784 /// UndefinedInternals - all the used, undefined objects which require a
4785 /// definition in this translation unit.
4786 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
4787
4788 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
4790
4791 /// The C++ special members which we are currently in the process of
4792 /// declaring. If this process recursively triggers the declaration of the
4793 /// same special member, we should act as if it is not yet declared.
4795
4797
4798 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
4799
4802 ParsingClassDepth++;
4804 }
4806 ParsingClassDepth--;
4808 }
4809
4811 CXXScopeSpec &SS,
4812 ParsedType TemplateTypeTy,
4813 IdentifierInfo *MemberOrBase);
4814
4815private:
4816 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
4817 QualType ResultTy,
4818 ArrayRef<QualType> Args);
4819
4820 // A cache representing if we've fully checked the various comparison category
4821 // types stored in ASTContext. The bit-index corresponds to the integer value
4822 // of a ComparisonCategoryType enumerator.
4823 llvm::SmallBitVector FullyCheckedComparisonCategories;
4824
4825 /// Check if there is a field shadowing.
4826 void CheckShadowInheritedFields(const SourceLocation &Loc,
4827 DeclarationName FieldName,
4828 const CXXRecordDecl *RD,
4829 bool DeclIsField = true);
4830
4831 ///@}
4832
4833 //
4834 //
4835 // -------------------------------------------------------------------------
4836 //
4837 //
4838
4839 /// \name C++ Exception Specifications
4840 /// Implementations are in SemaExceptionSpec.cpp
4841 ///@{
4842
4843public:
4844 /// All the overriding functions seen during a class definition
4845 /// that had their exception spec checks delayed, plus the overridden
4846 /// function.
4849
4850 /// All the function redeclarations seen during a class definition that had
4851 /// their exception spec checks delayed, plus the prior declaration they
4852 /// should be checked against. Except during error recovery, the new decl
4853 /// should always be a friend declaration, as that's the only valid way to
4854 /// redeclare a special member before its class is complete.
4857
4858 /// Determine if we're in a case where we need to (incorrectly) eagerly
4859 /// parse an exception specification to work around a libstdc++ bug.
4861
4862 /// Check the given noexcept-specifier, convert its expression, and compute
4863 /// the appropriate ExceptionSpecificationType.
4864 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
4866
4867 CanThrowResult canThrow(const Stmt *E);
4868 /// Determine whether the callee of a particular function call can throw.
4869 /// E, D and Loc are all optional.
4870 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
4873 const FunctionProtoType *FPT);
4880 SourceLocation OldLoc,
4881 const FunctionProtoType *New,
4882 SourceLocation NewLoc);
4884 const PartialDiagnostic &NoteID,
4885 const FunctionProtoType *Old,
4886 SourceLocation OldLoc,
4887 const FunctionProtoType *New,
4888 SourceLocation NewLoc);
4889 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
4891 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
4892 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
4893 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
4894 SourceLocation SuperLoc, const FunctionProtoType *Subset,
4895 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
4897 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
4898 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
4899 SourceLocation TargetLoc, const FunctionProtoType *Source,
4900 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
4901
4902 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
4903
4904 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
4905 /// spec is a subset of base spec.
4907 const CXXMethodDecl *Old);
4908
4909 ///@}
4910
4911 //
4912 //
4913 // -------------------------------------------------------------------------
4914 //
4915 //
4916
4917 /// \name Expressions
4918 /// Implementations are in SemaExpr.cpp
4919 ///@{
4920
4921public:
4922 /// Describes how the expressions currently being parsed are
4923 /// evaluated at run-time, if at all.
4925 /// The current expression and its subexpressions occur within an
4926 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
4927 /// \c sizeof, where the type of the expression may be significant but
4928 /// no code will be generated to evaluate the value of the expression at
4929 /// run time.
4931
4932 /// The current expression occurs within a braced-init-list within
4933 /// an unevaluated operand. This is mostly like a regular unevaluated
4934 /// context, except that we still instantiate constexpr functions that are
4935 /// referenced here so that we can perform narrowing checks correctly.
4937
4938 /// The current expression occurs within a discarded statement.
4939 /// This behaves largely similarly to an unevaluated operand in preventing
4940 /// definitions from being required, but not in other ways.
4942
4943 /// The current expression occurs within an unevaluated
4944 /// operand that unconditionally permits abstract references to
4945 /// fields, such as a SIZE operator in MS-style inline assembly.
4947
4948 /// The current context is "potentially evaluated" in C++11 terms,
4949 /// but the expression is evaluated at compile-time (like the values of
4950 /// cases in a switch statement).
4952
4953 /// In addition of being constant evaluated, the current expression
4954 /// occurs in an immediate function context - either a consteval function
4955 /// or a consteval if statement.
4957
4958 /// The current expression is potentially evaluated at run time,
4959 /// which means that code may be generated to evaluate the value of the
4960 /// expression at run time.
4962
4963 /// The current expression is potentially evaluated, but any
4964 /// declarations referenced inside that expression are only used if
4965 /// in fact the current expression is used.
4966 ///
4967 /// This value is used when parsing default function arguments, for which
4968 /// we would like to provide diagnostics (e.g., passing non-POD arguments
4969 /// through varargs) but do not want to mark declarations as "referenced"
4970 /// until the default argument is used.
4972 };
4973
4974 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
4975 /// to a variable (constant) that may or may not be odr-used in this Expr, and
4976 /// we won't know until all lvalue-to-rvalue and discarded value conversions
4977 /// have been applied to all subexpressions of the enclosing full expression.
4978 /// This is cleared at the end of each full expression.
4981
4982 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
4983
4984 /// Data structure used to record current or nested
4985 /// expression evaluation contexts.
4987 /// The expression evaluation context.
4989
4990 /// Whether the enclosing context needed a cleanup.
4992
4993 /// The number of active cleanup objects when we entered
4994 /// this expression evaluation context.
4996
4997 /// The number of typos encountered during this expression evaluation
4998 /// context (i.e. the number of TypoExprs created).
4999 unsigned NumTypos;
5000
5002
5003 /// The lambdas that are present within this context, if it
5004 /// is indeed an unevaluated context.
5006
5007 /// The declaration that provides context for lambda expressions
5008 /// and block literals if the normal declaration context does not
5009 /// suffice, e.g., in a default function argument.
5011
5012 /// If we are processing a decltype type, a set of call expressions
5013 /// for which we have deferred checking the completeness of the return type.
5015
5016 /// If we are processing a decltype type, a set of temporary binding
5017 /// expressions for which we have deferred checking the destructor.
5019
5021
5022 /// Expressions appearing as the LHS of a volatile assignment in this
5023 /// context. We produce a warning for these when popping the context if
5024 /// they are not discarded-value expressions nor unevaluated operands.
5026
5027 /// Set of candidates for starting an immediate invocation.
5030
5031 /// Set of DeclRefExprs referencing a consteval function when used in a
5032 /// context not already known to be immediately invoked.
5034
5035 /// P2718R0 - Lifetime extension in range-based for loops.
5036 /// MaterializeTemporaryExprs in for-range-init expressions which need to
5037 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
5038 /// InLifetimeExtendingContext is true.
5040
5041 /// \brief Describes whether we are in an expression constext which we have
5042 /// to handle differently.
5047 EK_Other
5048 } ExprContext;
5049
5050 // A context can be nested in both a discarded statement context and
5051 // an immediate function context, so they need to be tracked independently.
5055
5056 bool IsCurrentlyCheckingDefaultArgumentOrInitializer = false;
5057
5058 // We are in a constant context, but we also allow
5059 // non constant expressions, for example for array bounds (which may be
5060 // VLAs).
5061 bool InConditionallyConstantEvaluateContext = false;
5062
5063 /// Whether we are currently in a context in which all temporaries must be
5064 /// lifetime-extended, even if they're not bound to a reference (for
5065 /// example, in a for-range initializer).
5066 bool InLifetimeExtendingContext = false;
5067
5068 // When evaluating immediate functions in the initializer of a default
5069 // argument or default member initializer, this is the declaration whose
5070 // default initializer is being evaluated and the location of the call
5071 // or constructor definition.
5074 DeclContext *Context)
5075 : Loc(Loc), Decl(Decl), Context(Context) {
5076 assert(Decl && Context && "invalid initialization context");
5077 }
5078
5080 ValueDecl *Decl = nullptr;
5081 DeclContext *Context = nullptr;
5082 };
5083 std::optional<InitializationContext> DelayedDefaultInitializationContext;
5084
5086 unsigned NumCleanupObjects,
5087 CleanupInfo ParentCleanup,
5088 Decl *ManglingContextDecl,
5089 ExpressionKind ExprContext)
5090 : Context(Context), ParentCleanup(ParentCleanup),
5091 NumCleanupObjects(NumCleanupObjects), NumTypos(0),
5092 ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext),
5093 InDiscardedStatement(false), InImmediateFunctionContext(false),
5094 InImmediateEscalatingFunctionContext(false) {}
5095
5096 bool isUnevaluated() const {
5097 return Context == ExpressionEvaluationContext::Unevaluated ||
5098 Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
5099 Context == ExpressionEvaluationContext::UnevaluatedList;
5100 }
5101
5102 bool isConstantEvaluated() const {
5103 return Context == ExpressionEvaluationContext::ConstantEvaluated ||
5104 Context == ExpressionEvaluationContext::ImmediateFunctionContext;
5105 }
5106
5108 return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
5109 (Context == ExpressionEvaluationContext::DiscardedStatement &&
5110 InImmediateFunctionContext) ||
5111 // C++23 [expr.const]p14:
5112 // An expression or conversion is in an immediate function
5113 // context if it is potentially evaluated and either:
5114 // * its innermost enclosing non-block scope is a function
5115 // parameter scope of an immediate function, or
5116 // * its enclosing statement is enclosed by the compound-
5117 // statement of a consteval if statement.
5118 (Context == ExpressionEvaluationContext::PotentiallyEvaluated &&
5119 InImmediateFunctionContext);
5120 }
5121
5123 return Context == ExpressionEvaluationContext::DiscardedStatement ||
5124 (Context ==
5125 ExpressionEvaluationContext::ImmediateFunctionContext &&
5126 InDiscardedStatement);
5127 }
5128 };
5129
5131 assert(!ExprEvalContexts.empty() &&
5132 "Must be in an expression evaluation context");
5133 return ExprEvalContexts.back();
5134 };
5135
5136 bool isBoundsAttrContext() const {
5137 return ExprEvalContexts.back().ExprContext ==
5140 }
5141
5142 /// Increment when we find a reference; decrement when we find an ignored
5143 /// assignment. Ultimately the value is 0 if every reference is an ignored
5144 /// assignment.
5145 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
5146
5147 /// Used to control the generation of ExprWithCleanups.
5149
5150 /// ExprCleanupObjects - This is the stack of objects requiring
5151 /// cleanup that are created by the current full expression.
5153
5154 // AssignmentAction - This is used by all the assignment diagnostic functions
5155 // to represent what is actually causing the operation
5166
5167 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
5168 // A version of DiagnoseUseOfDecl that should be used if overload resolution
5169 // has been used to find this declaration, which means we don't have to bother
5170 // checking the trailing requires clause.
5172 return DiagnoseUseOfDecl(
5173 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
5174 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
5175 /*SkipTrailingRequiresClause=*/true);
5176 }
5177
5179 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
5180 bool ObjCPropertyAccess = false,
5181 bool AvoidPartialAvailabilityChecks = false,
5182 ObjCInterfaceDecl *ClassReciever = nullptr,
5183 bool SkipTrailingRequiresClause = false);
5185
5187 ArrayRef<Expr *> Args);
5188
5190 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
5199
5201
5205
5207
5209
5210 // Functions for marking a declaration referenced. These functions also
5211 // contain the relevant logic for marking if a reference to a function or
5212 // variable is an odr-use (in the C++11 sense). There are separate variants
5213 // for expressions referring to a decl; these exist because odr-use marking
5214 // needs to be delayed for some constant variables when we build one of the
5215 // named expressions.
5216 //
5217 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
5218 // should usually be true. This only needs to be set to false if the lack of
5219 // odr-use cannot be determined from the current context (for instance,
5220 // because the name denotes a virtual function and was written without an
5221 // explicit nested-name-specifier).
5222 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
5224 bool MightBeOdrUse = true);
5226 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
5230 unsigned CapturingScopeIndex);
5231
5233 void CleanupVarDeclMarking();
5234
5240
5241 /// Try to capture the given variable.
5242 ///
5243 /// \param Var The variable to capture.
5244 ///
5245 /// \param Loc The location at which the capture occurs.
5246 ///
5247 /// \param Kind The kind of capture, which may be implicit (for either a
5248 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
5249 ///
5250 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
5251 /// an explicit lambda capture.
5252 ///
5253 /// \param BuildAndDiagnose Whether we are actually supposed to add the
5254 /// captures or diagnose errors. If false, this routine merely check whether
5255 /// the capture can occur without performing the capture itself or complaining
5256 /// if the variable cannot be captured.
5257 ///
5258 /// \param CaptureType Will be set to the type of the field used to capture
5259 /// this variable in the innermost block or lambda. Only valid when the
5260 /// variable can be captured.
5261 ///
5262 /// \param DeclRefType Will be set to the type of a reference to the capture
5263 /// from within the current scope. Only valid when the variable can be
5264 /// captured.
5265 ///
5266 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
5267 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
5268 /// This is useful when enclosing lambdas must speculatively capture
5269 /// variables that may or may not be used in certain specializations of
5270 /// a nested generic lambda.
5271 ///
5272 /// \returns true if an error occurred (i.e., the variable cannot be
5273 /// captured) and false if the capture succeeded.
5275 TryCaptureKind Kind, SourceLocation EllipsisLoc,
5276 bool BuildAndDiagnose, QualType &CaptureType,
5277 QualType &DeclRefType,
5278 const unsigned *const FunctionScopeIndexToStopAt);
5279
5280 /// Try to capture the given variable.
5283 SourceLocation EllipsisLoc = SourceLocation());
5284
5285 /// Checks if the variable must be captured.
5287
5288 /// Given a variable, determine the type that a reference to that
5289 /// variable will have in the given scope.
5291
5292 /// Mark all of the declarations referenced within a particular AST node as
5293 /// referenced. Used when template instantiation instantiates a non-dependent
5294 /// type -- entities referenced by the type are now referenced.
5297 Expr *E, bool SkipLocalVariables = false,
5298 ArrayRef<const Expr *> StopAt = std::nullopt);
5299
5300 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
5301 /// conversion.
5303
5304 /// Conditionally issue a diagnostic based on the statements's reachability
5305 /// analysis.
5306 ///
5307 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
5308 /// the function body is parsed, and then do a basic reachability analysis to
5309 /// determine if the statement is reachable. If it is unreachable, the
5310 /// diagnostic will not be emitted.
5312 const PartialDiagnostic &PD);
5313
5314 /// Conditionally issue a diagnostic based on the current
5315 /// evaluation context.
5316 ///
5317 /// \param Statement If Statement is non-null, delay reporting the
5318 /// diagnostic until the function body is parsed, and then do a basic
5319 /// reachability analysis to determine if the statement is reachable.
5320 /// If it is unreachable, the diagnostic will not be emitted.
5321 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
5322 const PartialDiagnostic &PD);
5323 /// Similar, but diagnostic is only produced if all the specified statements
5324 /// are reachable.
5326 const PartialDiagnostic &PD);
5327
5328 // Primary Expressions.
5329 SourceRange getExprRange(Expr *E) const;
5330
5332 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
5333 bool HasTrailingLParen, bool IsAddressOfOperand,
5334 CorrectionCandidateCallback *CCC = nullptr,
5335 bool IsInlineAsmIdentifier = false,
5336 Token *KeywordReplacement = nullptr);
5337
5340 DeclarationNameInfo &NameInfo,
5341 const TemplateArgumentListInfo *&TemplateArgs);
5342
5344
5345 bool
5348 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
5349 ArrayRef<Expr *> Args = std::nullopt,
5350 DeclContext *LookupCtx = nullptr,
5351 TypoExpr **Out = nullptr);
5352
5353 /// If \p D cannot be odr-used in the current expression evaluation context,
5354 /// return a reason explaining why. Otherwise, return NOUR_None.
5356
5359 const CXXScopeSpec *SS = nullptr);
5360 DeclRefExpr *
5362 const DeclarationNameInfo &NameInfo,
5363 const CXXScopeSpec *SS = nullptr,
5364 NamedDecl *FoundD = nullptr,
5365 SourceLocation TemplateKWLoc = SourceLocation(),
5366 const TemplateArgumentListInfo *TemplateArgs = nullptr);
5367 DeclRefExpr *
5369 const DeclarationNameInfo &NameInfo,
5370 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
5371 SourceLocation TemplateKWLoc = SourceLocation(),
5372 const TemplateArgumentListInfo *TemplateArgs = nullptr);
5373
5374 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
5375 bool HasTrailingLParen);
5376
5379 const DeclarationNameInfo &NameInfo,
5380 bool IsAddressOfOperand, const Scope *S,
5381 TypeSourceInfo **RecoveryTSI = nullptr);
5382
5384 bool NeedsADL,
5385 bool AcceptInvalidDecl = false);
5387 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
5388 NamedDecl *FoundD = nullptr,
5389 const TemplateArgumentListInfo *TemplateArgs = nullptr,
5390 bool AcceptInvalidDecl = false);
5391
5392 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
5393 // where Tokens representing function local predefined macros (such as
5394 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
5396
5400
5401 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
5402
5403 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
5405 Scope *UDLScope = nullptr);
5408 MultiExprArg Val);
5409
5410 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
5411 /// fragments (e.g. "foo" "bar" L"baz").
5413 Scope *UDLScope = nullptr);
5414
5416
5417 /// ControllingExprOrType is either an opaque pointer coming out of a
5418 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
5419 /// into two so we don't take a void *, but that's awkward because one of
5420 /// the operands is either a ParsedType or an Expr *, which doesn't lend
5421 /// itself to generic code very well.
5423 SourceLocation DefaultLoc,
5424 SourceLocation RParenLoc,
5425 bool PredicateIsExpr,
5426 void *ControllingExprOrType,
5427 ArrayRef<ParsedType> ArgTypes,
5428 ArrayRef<Expr *> ArgExprs);
5429 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
5430 /// it'd be better to split this interface into two so we don't take a
5431 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
5432 /// isn't a trivial change.
5434 SourceLocation DefaultLoc,
5435 SourceLocation RParenLoc,
5436 bool PredicateIsExpr,
5437 void *ControllingExprOrType,
5439 ArrayRef<Expr *> Exprs);
5440
5441 // Binary/Unary Operators. 'Tok' is the token for the operator.
5443 Expr *InputExpr, bool IsAfterAmp = false);
5445 Expr *Input, bool IsAfterAmp = false);
5447 Expr *Input, bool IsAfterAmp = false);
5448
5451 const Expr *Op,
5452 const CXXMethodDecl *MD);
5453
5455
5456 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
5457 SourceLocation OpLoc, SourceRange R);
5458 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
5459 SourceLocation OpLoc, SourceRange R);
5460
5462 SourceLocation OpLoc,
5463 UnaryExprOrTypeTrait ExprKind,
5464 SourceRange R);
5466 UnaryExprOrTypeTrait ExprKind);
5468 UnaryExprOrTypeTrait ExprKind,
5469 bool IsType, void *TyOrEx,
5470 SourceRange ArgRange);
5471
5473 bool CheckVecStepExpr(Expr *E);
5474
5477 SourceRange ExprRange,
5478 UnaryExprOrTypeTrait ExprKind,
5479 StringRef KWName);
5480
5482 tok::TokenKind Kind, Expr *Input);
5483
5485 MultiExprArg ArgExprs,
5486 SourceLocation RLoc);
5488 Expr *Idx, SourceLocation RLoc);
5489
5491 Expr *ColumnIdx,
5492 SourceLocation RBLoc);
5493
5495 const FunctionProtoType *Proto,
5496 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
5497 bool ExecConfig = false);
5499 const Expr *ArgExpr);
5500
5501 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
5502 /// This provides the location of the left/right parens and a list of comma
5503 /// locations.
5505 MultiExprArg ArgExprs, SourceLocation RParenLoc,
5506 Expr *ExecConfig = nullptr);
5508 MultiExprArg ArgExprs, SourceLocation RParenLoc,
5509 Expr *ExecConfig = nullptr,
5510 bool IsExecConfig = false,
5511 bool AllowRecovery = false);
5513 MultiExprArg CallArgs);
5514
5516
5518 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
5519 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
5520 Expr *Config = nullptr, bool IsExecConfig = false,
5521 ADLCallKind UsesADL = ADLCallKind::NotADL);
5522
5524 ParsedType &Ty, SourceLocation RParenLoc,
5525 Expr *CastExpr);
5526
5528
5529 /// Build an altivec or OpenCL literal.
5531 SourceLocation RParenLoc, Expr *E,
5532 TypeSourceInfo *TInfo);
5533
5535
5537 SourceLocation RParenLoc, Expr *InitExpr);
5538
5540 TypeSourceInfo *TInfo,
5541 SourceLocation RParenLoc,
5542 Expr *LiteralExpr);
5543
5544 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
5545 SourceLocation RBraceLoc);
5546
5547 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
5548 SourceLocation RBraceLoc);
5549
5551 Expr *LHSExpr, Expr *RHSExpr);
5553 Expr *LHSExpr, Expr *RHSExpr);
5555 Expr *LHSExpr, Expr *RHSExpr);
5557 UnresolvedSetImpl &Functions);
5558
5559 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
5560
5561 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
5562 /// in the case of a the GNU conditional expr extension.
5564 SourceLocation ColonLoc, Expr *CondExpr,
5565 Expr *LHSExpr, Expr *RHSExpr);
5566
5567 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
5569 LabelDecl *TheDecl);
5570
5571 void ActOnStartStmtExpr();
5572 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
5573 SourceLocation RPLoc);
5575 SourceLocation RPLoc, unsigned TemplateDepth);
5576 // Handle the final expression in a statement expression.
5578 void ActOnStmtExprError();
5579
5580 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
5583 bool isBrackets; // true if [expr], false if .ident
5584 union {
5587 } U;
5588 };
5589
5590 /// __builtin_offsetof(type, a.b[123][456].c)
5592 TypeSourceInfo *TInfo,
5593 ArrayRef<OffsetOfComponent> Components,
5594 SourceLocation RParenLoc);
5597 ParsedType ParsedArgTy,
5598 ArrayRef<OffsetOfComponent> Components,
5599 SourceLocation RParenLoc);
5600
5601 // __builtin_choose_expr(constExpr, expr1, expr2)
5602 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
5603 Expr *LHSExpr, Expr *RHSExpr,
5604 SourceLocation RPLoc);
5605
5606 // __builtin_va_arg(expr, type)
5608 SourceLocation RPLoc);
5610 TypeSourceInfo *TInfo, SourceLocation RPLoc);
5611
5612 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
5613 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
5615 SourceLocation BuiltinLoc,
5616 SourceLocation RPLoc);
5617
5618 // Build a potentially resolved SourceLocExpr.
5620 SourceLocation BuiltinLoc, SourceLocation RPLoc,
5621 DeclContext *ParentContext);
5622
5623 // __null
5625
5626 bool CheckCaseExpression(Expr *E);
5627
5628 //===------------------------- "Block" Extension ------------------------===//
5629
5630 /// ActOnBlockStart - This callback is invoked when a block literal is
5631 /// started.
5632 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
5633
5634 /// ActOnBlockArguments - This callback allows processing of block arguments.
5635 /// If there are no arguments, this is still invoked.
5636 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
5637 Scope *CurScope);
5638
5639 /// ActOnBlockError - If there is an error parsing a block, this callback
5640 /// is invoked to pop the information about the block from the action impl.
5641 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
5642
5643 /// ActOnBlockStmtExpr - This is called when the body of a block statement
5644 /// literal was successfully completed. ^(int x){...}
5646 Scope *CurScope);
5647
5648 //===---------------------------- Clang Extensions ----------------------===//
5649
5650 /// __builtin_convertvector(...)
5652 SourceLocation BuiltinLoc,
5653 SourceLocation RParenLoc);
5654
5655 //===---------------------------- OpenCL Features -----------------------===//
5656
5657 /// __builtin_astype(...)
5658 ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
5659 SourceLocation BuiltinLoc,
5660 SourceLocation RParenLoc);
5662 SourceLocation BuiltinLoc,
5663 SourceLocation RParenLoc);
5664
5665 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
5667 ArrayRef<Expr *> SubExprs,
5668 QualType T = QualType());
5669
5671 NestedNameSpecifier *Qualifier,
5672 NamedDecl *FoundDecl,
5673 NamedDecl *Member);
5674
5675 /// CheckCallReturnType - Checks that a call expression's return type is
5676 /// complete. Returns true on failure. The location passed in is the location
5677 /// that best represents the call.
5679 CallExpr *CE, FunctionDecl *FD);
5680
5681 /// Emit a warning for all pending noderef expressions that we recorded.
5682 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
5683
5685
5686 /// Instantiate or parse a C++ default argument expression as necessary.
5687 /// Return true on error.
5689 ParmVarDecl *Param, Expr *Init = nullptr,
5690 bool SkipImmediateInvocations = true);
5691
5692 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
5693 /// the default expr if needed.
5695 ParmVarDecl *Param, Expr *Init = nullptr);
5696
5697 /// Wrap the expression in a ConstantExpr if it is a potential immediate
5698 /// invocation.
5700
5702
5703 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
5704
5705 /// Abstract base class used for diagnosing integer constant
5706 /// expression violations.
5708 public:
5710
5711 VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {}
5712
5713 virtual SemaDiagnosticBuilder
5714 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
5716 SourceLocation Loc) = 0;
5717 virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc);
5719 };
5720
5724 };
5725
5726 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
5727 /// and reports the appropriate diagnostics. Returns false on success.
5728 /// Can optionally return the value of the expression.
5730 VerifyICEDiagnoser &Diagnoser,
5731 AllowFoldKind CanFold = NoFold);
5733 unsigned DiagID,
5734 AllowFoldKind CanFold = NoFold);
5736 llvm::APSInt *Result = nullptr,
5737 AllowFoldKind CanFold = NoFold);
5739 AllowFoldKind CanFold = NoFold) {
5740 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
5741 }
5742
5743 /// DiagnoseAssignmentAsCondition - Given that an expression is
5744 /// being used as a boolean condition, warn if it's an assignment.
5746
5747 /// Redundant parentheses over an equality comparison can indicate
5748 /// that the user intended an assignment used as condition.
5750
5752 public:
5753 FullExprArg() : E(nullptr) {}
5754 FullExprArg(Sema &actions) : E(nullptr) {}
5755
5756 ExprResult release() { return E; }
5757
5758 Expr *get() const { return E; }
5759
5760 Expr *operator->() { return E; }
5761
5762 private:
5763 // FIXME: No need to make the entire Sema class a friend when it's just
5764 // Sema::MakeFullExpr that needs access to the constructor below.
5765 friend class Sema;
5766
5767 explicit FullExprArg(Expr *expr) : E(expr) {}
5768
5769 Expr *E;
5770 };
5771
5773 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
5774 }
5776 return FullExprArg(
5777 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
5778 }
5780 ExprResult FE =
5781 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
5782 /*DiscardedValue*/ true);
5783 return FullExprArg(FE.get());
5784 }
5785
5787 Decl *ConditionVar;
5789 bool Invalid;
5790 std::optional<bool> KnownValue;
5791
5792 friend class Sema;
5793 ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
5794 bool IsConstexpr)
5795 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
5796 if (IsConstexpr && Condition.get()) {
5797 if (std::optional<llvm::APSInt> Val =
5798 Condition.get()->getIntegerConstantExpr(S.Context)) {
5799 KnownValue = !!(*Val);
5800 }
5801 }
5802 }
5803 explicit ConditionResult(bool Invalid)
5804 : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
5805 KnownValue(std::nullopt) {}
5806
5807 public:
5809 bool isInvalid() const { return Invalid; }
5810 std::pair<VarDecl *, Expr *> get() const {
5811 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
5812 Condition.get());
5813 }
5814 std::optional<bool> getKnownValue() const { return KnownValue; }
5815 };
5817
5818 /// CheckBooleanCondition - Diagnose problems involving the use of
5819 /// the given expression as a boolean condition (e.g. in an if
5820 /// statement). Also performs the standard function and array
5821 /// decays, possibly changing the input variable.
5822 ///
5823 /// \param Loc - A location associated with the condition, e.g. the
5824 /// 'if' keyword.
5825 /// \return true iff there were any errors
5827 bool IsConstexpr = false);
5828
5829 enum class ConditionKind {
5830 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
5831 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
5832 Switch ///< An integral condition for a 'switch' statement.
5833 };
5834
5835 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
5836 ConditionKind CK, bool MissingOK = false);
5837
5838 QualType CheckConditionalOperands( // C99 6.5.15
5839 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
5840 ExprObjectKind &OK, SourceLocation QuestionLoc);
5841
5842 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
5843 SourceLocation QuestionLoc);
5844
5845 /// type checking for vector binary operators.
5847 SourceLocation Loc, bool IsCompAssign,
5848 bool AllowBothBool, bool AllowBoolConversion,
5849 bool AllowBoolOperation, bool ReportInvalid);
5854 BinaryOperatorKind Opc);
5857 BinaryOperatorKind Opc);
5860
5861 /// Context in which we're performing a usual arithmetic conversion.
5863 /// An arithmetic operation.
5865 /// A bitwise operation.
5867 /// A comparison.
5869 /// A conditional (?:) operator.
5871 /// A compound assignment expression.
5873 };
5874
5875 // type checking for sizeless vector binary operators.
5877 SourceLocation Loc, bool IsCompAssign,
5878 ArithConvKind OperationKind);
5879
5880 /// Type checking for matrix binary operators.
5883 bool IsCompAssign);
5885 SourceLocation Loc, bool IsCompAssign);
5886
5887 bool isValidSveBitcast(QualType srcType, QualType destType);
5888 bool isValidRVVBitcast(QualType srcType, QualType destType);
5889
5891
5892 bool areVectorTypesSameSize(QualType srcType, QualType destType);
5893 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
5894 bool isLaxVectorConversion(QualType srcType, QualType destType);
5895 bool anyAltivecTypes(QualType srcType, QualType destType);
5896
5897 // type checking C++ declaration initializers (C++ [dcl.init]).
5898
5901 ExprValueKind &VK, CXXCastPath &Path);
5902
5903 /// Force an expression with unknown-type to an expression of the
5904 /// given type.
5906
5907 /// Type-check an expression that's being passed to an
5908 /// __unknown_anytype parameter.
5910 QualType &paramType);
5911
5912 // CheckMatrixCast - Check type constraints for matrix casts.
5913 // We allow casting between matrixes of the same dimensions i.e. when they
5914 // have the same number of rows and column. Returns true if the cast is
5915 // invalid.
5916 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
5917 CastKind &Kind);
5918
5919 // CheckVectorCast - check type constraints for vectors.
5920 // Since vectors are an extension, there are no C standard reference for this.
5921 // We allow casting between vectors and integer datatypes of the same size.
5922 // returns true if the cast is invalid
5923 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
5924 CastKind &Kind);
5925
5926 /// Prepare `SplattedExpr` for a vector splat operation, adding
5927 /// implicit casts if necessary.
5928 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
5929
5930 // CheckExtVectorCast - check type constraints for extended vectors.
5931 // Since vectors are an extension, there are no C standard reference for this.
5932 // We allow casting between vectors and integer datatypes of the same size,
5933 // or vectors and the element type of that vector.
5934 // returns the cast expr
5936 CastKind &Kind);
5937
5940 }
5941
5942 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
5943 // functions and arrays to their respective pointers (C99 6.3.2.1).
5945
5946 /// CallExprUnaryConversions - a special case of an unary conversion
5947 /// performed on a function designator of a call expression.
5949
5950 // DefaultFunctionArrayConversion - converts functions and arrays
5951 // to their respective pointers (C99 6.3.2.1).
5953
5954 // DefaultFunctionArrayLvalueConversion - converts functions and
5955 // arrays to their respective pointers and performs the
5956 // lvalue-to-rvalue conversion.
5958 bool Diagnose = true);
5959
5960 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
5961 // the operand. This function is a no-op if the operand has a function type
5962 // or an array type.
5964
5965 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
5966 // do not have a prototype. Integer promotions are performed on each
5967 // argument, and arguments that have type float are promoted to double.
5969
5971 const FunctionProtoType *Proto,
5972 Expr *Fn);
5973
5974 // Used for determining in which context a type is allowed to be passed to a
5975 // vararg function.
5983
5984 // Determines which VarArgKind fits an expression.
5986
5987 /// Check to see if the given expression is a valid argument to a variadic
5988 /// function, issuing a diagnostic if not.
5989 void checkVariadicArgument(const Expr *E, VariadicCallType CT);
5990
5991 /// GatherArgumentsForCall - Collector argument expressions for various
5992 /// form of call prototypes.
5994 const FunctionProtoType *Proto,
5995 unsigned FirstParam, ArrayRef<Expr *> Args,
5996 SmallVectorImpl<Expr *> &AllArgs,
5998 bool AllowExplicit = false,
5999 bool IsListInitialization = false);
6000
6001 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
6002 // will create a runtime trap if the resulting type is not a POD type.
6004 FunctionDecl *FDecl);
6005
6006 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
6007 // operands and then handles various conversions that are common to binary
6008 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
6009 // routine returns the first non-arithmetic type found. The client is
6010 // responsible for emitting appropriate error diagnostics.
6013
6014 /// AssignConvertType - All of the 'assignment' semantic checks return this
6015 /// enum to indicate whether the assignment was allowed. These checks are
6016 /// done for simple assignments, as well as initialization, return from
6017 /// function, argument passing, etc. The query is phrased in terms of a
6018 /// source and destination type.
6020 /// Compatible - the types are compatible according to the standard.
6022
6023 /// PointerToInt - The assignment converts a pointer to an int, which we
6024 /// accept as an extension.
6026
6027 /// IntToPointer - The assignment converts an int to a pointer, which we
6028 /// accept as an extension.
6030
6031 /// FunctionVoidPointer - The assignment is between a function pointer and
6032 /// void*, which the standard doesn't allow, but we accept as an extension.
6034
6035 /// IncompatiblePointer - The assignment is between two pointers types that
6036 /// are not compatible, but we accept them as an extension.
6038
6039 /// IncompatibleFunctionPointer - The assignment is between two function
6040 /// pointers types that are not compatible, but we accept them as an
6041 /// extension.
6043
6044 /// IncompatibleFunctionPointerStrict - The assignment is between two
6045 /// function pointer types that are not identical, but are compatible,
6046 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
6047 /// may trip an indirect call runtime check.
6049
6050 /// IncompatiblePointerSign - The assignment is between two pointers types
6051 /// which point to integers which have a different sign, but are otherwise
6052 /// identical. This is a subset of the above, but broken out because it's by
6053 /// far the most common case of incompatible pointers.
6055
6056 /// CompatiblePointerDiscardsQualifiers - The assignment discards
6057 /// c/v/r qualifiers, which we accept as an extension.
6059
6060 /// IncompatiblePointerDiscardsQualifiers - The assignment
6061 /// discards qualifiers that we don't permit to be discarded,
6062 /// like address spaces.
6064
6065 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
6066 /// changes address spaces in nested pointer types which is not allowed.
6067 /// For instance, converting __private int ** to __generic int ** is
6068 /// illegal even though __private could be converted to __generic.
6070
6071 /// IncompatibleNestedPointerQualifiers - The assignment is between two
6072 /// nested pointer types, and the qualifiers other than the first two
6073 /// levels differ e.g. char ** -> const char **, but we accept them as an
6074 /// extension.
6076
6077 /// IncompatibleVectors - The assignment is between two vector types that
6078 /// have the same size, which we accept as an extension.
6080
6081 /// IntToBlockPointer - The assignment converts an int to a block
6082 /// pointer. We disallow this.
6084
6085 /// IncompatibleBlockPointer - The assignment is between two block
6086 /// pointers types that are not compatible.
6088
6089 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
6090 /// id type and something else (that is incompatible with it). For example,
6091 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
6093
6094 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
6095 /// object with __weak qualifier.
6097
6098 /// Incompatible - We reject this conversion outright, it is invalid to
6099 /// represent it in the AST.
6102
6103 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
6104 /// assignment conversion type specified by ConvTy. This returns true if the
6105 /// conversion was invalid or false if the conversion was accepted.
6107 QualType DstType, QualType SrcType,
6108 Expr *SrcExpr, AssignmentAction Action,
6109 bool *Complained = nullptr);
6110
6111 /// CheckAssignmentConstraints - Perform type checking for assignment,
6112 /// argument passing, variable initialization, and function return values.
6113 /// C99 6.5.16.
6115 QualType LHSType,
6116 QualType RHSType);
6117
6118 /// Check assignment constraints and optionally prepare for a conversion of
6119 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
6120 /// is true.
6122 ExprResult &RHS, CastKind &Kind,
6123 bool ConvertRHS = true);
6124
6125 /// Check assignment constraints for an assignment of RHS to LHSType.
6126 ///
6127 /// \param LHSType The destination type for the assignment.
6128 /// \param RHS The source expression for the assignment.
6129 /// \param Diagnose If \c true, diagnostics may be produced when checking
6130 /// for assignability. If a diagnostic is produced, \p RHS will be
6131 /// set to ExprError(). Note that this function may still return
6132 /// without producing a diagnostic, even for an invalid assignment.
6133 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
6134 /// in an audited Core Foundation API and does not need to be checked
6135 /// for ARC retain issues.
6136 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
6137 /// conversions necessary to perform the assignment. If \c false,
6138 /// \p Diagnose must also be \c false.
6140 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
6141 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
6142
6143 // If the lhs type is a transparent union, check whether we
6144 // can initialize the transparent union with the given expression.
6146 ExprResult &RHS);
6147
6148 /// the following "Check" methods will return a valid/converted QualType
6149 /// or a null QualType (indicating an error diagnostic was issued).
6150
6151 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
6153 ExprResult &RHS);
6155 ExprResult &RHS);
6156
6158 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
6159 bool IsDivide);
6160 QualType CheckRemainderOperands( // C99 6.5.5
6162 bool IsCompAssign = false);
6163 QualType CheckAdditionOperands( // C99 6.5.6
6165 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
6168 QualType *CompLHSTy = nullptr);
6169 QualType CheckShiftOperands( // C99 6.5.7
6171 BinaryOperatorKind Opc, bool IsCompAssign = false);
6173 QualType CheckCompareOperands( // C99 6.5.8/9
6175 BinaryOperatorKind Opc);
6176 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
6178 BinaryOperatorKind Opc);
6179 QualType CheckLogicalOperands( // C99 6.5.[13,14]
6181 BinaryOperatorKind Opc);
6182 // CheckAssignmentOperands is used for both simple and compound assignment.
6183 // For simple assignment, pass both expressions and a null converted type.
6184 // For compound assignment, pass both expressions and the converted type.
6185 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
6186 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
6187 BinaryOperatorKind Opc);
6188
6189 /// To be used for checking whether the arguments being passed to
6190 /// function exceeds the number of parameters expected for it.
6191 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
6192 bool PartialOverloading = false) {
6193 // We check whether we're just after a comma in code-completion.
6194 if (NumArgs > 0 && PartialOverloading)
6195 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
6196 return NumArgs > NumParams;
6197 }
6198
6199 /// Whether the AST is currently being rebuilt to correct immediate
6200 /// invocations. Immediate invocation candidates and references to consteval
6201 /// functions aren't tracked when this is set.
6203
6208 }
6209
6210 /// Determines whether we are currently in a context that
6211 /// is not evaluated as per C++ [expr] p5.
6214 }
6215
6218 }
6219
6221 assert(!ExprEvalContexts.empty() &&
6222 "Must be in an expression evaluation context");
6223 return ExprEvalContexts.back().InLifetimeExtendingContext;
6224 }
6225
6228 return (Ctx.Context ==
6231 }
6232
6233 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
6235 assert(!ExprEvalContexts.empty() &&
6236 "Must be in an expression evaluation context");
6237 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
6239 Ctx.DelayedDefaultInitializationContext)
6240 return Ctx.DelayedDefaultInitializationContext;
6241 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
6242 Ctx.isUnevaluated())
6243 break;
6244 }
6245 return std::nullopt;
6246 }
6247
6248 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
6250 assert(!ExprEvalContexts.empty() &&
6251 "Must be in an expression evaluation context");
6252 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
6253 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
6255 !Ctx.DelayedDefaultInitializationContext && Res)
6256 break;
6257 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
6258 Ctx.isUnevaluated())
6259 break;
6260 Res = Ctx.DelayedDefaultInitializationContext;
6261 }
6262 return Res;
6263 }
6264
6265 /// keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext
6266 /// flag from previous context.
6268 if (ExprEvalContexts.size() > 2 &&
6270 .InLifetimeExtendingContext) {
6271 auto &LastRecord = ExprEvalContexts.back();
6272 auto &PrevRecord = ExprEvalContexts[ExprEvalContexts.size() - 2];
6273 LastRecord.InLifetimeExtendingContext =
6274 PrevRecord.InLifetimeExtendingContext;
6275 }
6276 }
6277
6280 }
6281
6282 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
6283 /// SelfAssigned when inside a CXXMethodDecl.
6284 const FieldDecl *
6286
6288
6289 template <typename... Ts>
6291 const Ts &...Args) {
6292 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6294 }
6295
6296 template <typename... Ts>
6297 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
6298 const Ts &...Args) {
6299 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6301 }
6302
6303 /// Abstract class used to diagnose incomplete types.
6306
6307 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
6308 virtual ~TypeDiagnoser() {}
6309 };
6310
6311 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
6312 protected:
6313 unsigned DiagID;
6314 std::tuple<const Ts &...> Args;
6315
6316 template <std::size_t... Is>
6318 std::index_sequence<Is...>) const {
6319 // Apply all tuple elements to the builder in order.
6320 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
6321 (void)Dummy;
6322 }
6323
6324 public:
6325 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
6326 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
6327 assert(DiagID != 0 && "no diagnostic for type diagnoser");
6328 }
6329
6330 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
6331 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
6332 emit(DB, std::index_sequence_for<Ts...>());
6333 DB << T;
6334 }
6335 };
6336
6337 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
6338 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
6339 /// For example, a diagnostic with no other parameters would generally have
6340 /// the form "...%select{incomplete|sizeless}0 type %1...".
6341 template <typename... Ts>
6343 public:
6344 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
6345 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
6346
6347 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
6348 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
6349 this->emit(DB, std::index_sequence_for<Ts...>());
6350 DB << T->isSizelessType() << T;
6351 }
6352 };
6353
6354 /// Check an argument list for placeholders that we won't try to
6355 /// handle later.
6357
6358 /// The C++ "std::source_location::__impl" struct, defined in
6359 /// <source_location>.
6361
6362 /// A stack of expression evaluation contexts.
6364
6365 // Set of failed immediate invocations to avoid double diagnosing.
6367
6368 /// List of SourceLocations where 'self' is implicitly retained inside a
6369 /// block.
6372
6373private:
6374 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
6375
6376 /// Methods for marking which expressions involve dereferencing a pointer
6377 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
6378 /// they are parsed, meaning that a noderef pointer may not be accessed. For
6379 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
6380 /// `*p`, but need to check that `address of` is called on it. This requires
6381 /// keeping a container of all pending expressions and checking if the address
6382 /// of them are eventually taken.
6383 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
6384 void CheckAddressOfNoDeref(const Expr *E);
6385
6386 ///@}
6387
6388 //
6389 //
6390 // -------------------------------------------------------------------------
6391 //
6392 //
6393
6394 /// \name C++ Expressions
6395 /// Implementations are in SemaExprCXX.cpp
6396 ///@{
6397
6398public:
6399 /// The C++ "std::bad_alloc" class, which is defined by the C++
6400 /// standard library.
6402
6403 /// The C++ "std::align_val_t" enum class, which is defined by the C++
6404 /// standard library.
6406
6407 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
6409
6410 /// A flag to remember whether the implicit forms of operator new and delete
6411 /// have been declared.
6413
6414 /// Delete-expressions to be analyzed at the end of translation unit
6415 ///
6416 /// This list contains class members, and locations of delete-expressions
6417 /// that could not be proven as to whether they mismatch with new-expression
6418 /// used in initializer of the field.
6419 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
6420
6422 SourceLocation NameLoc,
6423 const IdentifierInfo &Name);
6424
6426 SourceLocation NameLoc, Scope *S,
6427 CXXScopeSpec &SS, bool EnteringContext);
6429 Scope *S, CXXScopeSpec &SS,
6430 ParsedType ObjectType, bool EnteringContext);
6431
6433 ParsedType ObjectType);
6434
6435 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
6436 TypeSourceInfo *Operand, SourceLocation RParenLoc);
6437 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
6438 Expr *Operand, SourceLocation RParenLoc);
6439
6440 /// ActOnCXXTypeid - Parse typeid( something ).
6442 bool isType, void *TyOrExpr,
6443 SourceLocation RParenLoc);
6444
6445 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
6446 TypeSourceInfo *Operand, SourceLocation RParenLoc);
6447 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
6448 Expr *Operand, SourceLocation RParenLoc);
6449
6450 /// ActOnCXXUuidof - Parse __uuidof( something ).
6452 bool isType, void *TyOrExpr,
6453 SourceLocation RParenLoc);
6454
6455 //// ActOnCXXThis - Parse 'this' pointer.
6457
6458 /// Check whether the type of 'this' is valid in the current context.
6460
6461 /// Build a CXXThisExpr and mark it referenced in the current context.
6463 void MarkThisReferenced(CXXThisExpr *This);
6464
6465 /// Try to retrieve the type of the 'this' pointer.
6466 ///
6467 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
6469
6470 /// When non-NULL, the C++ 'this' expression is allowed despite the
6471 /// current context not being a non-static member function. In such cases,
6472 /// this provides the type used for 'this'.
6474
6475 /// RAII object used to temporarily allow the C++ 'this' expression
6476 /// to be used, with the given qualifiers on the current class type.
6478 Sema &S;
6479 QualType OldCXXThisTypeOverride;
6480 bool Enabled;
6481
6482 public:
6483 /// Introduce a new scope where 'this' may be allowed (when enabled),
6484 /// using the given declaration (which is either a class template or a
6485 /// class) along with the given qualifiers.
6486 /// along with the qualifiers placed on '*this'.
6487 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
6488 bool Enabled = true);
6489
6491 };
6492
6493 /// Make sure the value of 'this' is actually available in the current
6494 /// context, if it is a potentially evaluated context.
6495 ///
6496 /// \param Loc The location at which the capture of 'this' occurs.
6497 ///
6498 /// \param Explicit Whether 'this' is explicitly captured in a lambda
6499 /// capture list.
6500 ///
6501 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
6502 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
6503 /// This is useful when enclosing lambdas must speculatively capture
6504 /// 'this' that may or may not be used in certain specializations of
6505 /// a nested generic lambda (depending on whether the name resolves to
6506 /// a non-static member function or a static function).
6507 /// \return returns 'true' if failed, 'false' if success.
6509 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
6510 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
6511 bool ByCopy = false);
6512
6513 /// Determine whether the given type is the type of *this that is used
6514 /// outside of the body of a member function for a type that is currently
6515 /// being defined.
6517
6518 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
6520
6521 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
6523
6524 //// ActOnCXXThrow - Parse throw expressions.
6527 bool IsThrownVarInScope);
6528 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
6529
6530 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
6531 /// Can be interpreted either as function-style casting ("int(x)")
6532 /// or class type construction ("ClassType(x,y,z)")
6533 /// or creation of a value-initialized type ("int()").
6535 SourceLocation LParenOrBraceLoc,
6536 MultiExprArg Exprs,
6537 SourceLocation RParenOrBraceLoc,
6538 bool ListInitialization);
6539
6541 SourceLocation LParenLoc,
6542 MultiExprArg Exprs,
6543 SourceLocation RParenLoc,
6544 bool ListInitialization);
6545
6546 /// ActOnCXXNew - Parsed a C++ 'new' expression.
6547 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
6548 SourceLocation PlacementLParen,
6549 MultiExprArg PlacementArgs,
6550 SourceLocation PlacementRParen,
6551 SourceRange TypeIdParens, Declarator &D,
6552 Expr *Initializer);
6554 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
6555 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
6556 SourceRange TypeIdParens, QualType AllocType,
6557 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
6558 SourceRange DirectInitRange, Expr *Initializer);
6559
6560 /// Determine whether \p FD is an aligned allocation or deallocation
6561 /// function that is unavailable.
6563
6564 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
6565 /// function that is unavailable.
6568
6570 SourceRange R);
6571
6572 /// The scope in which to find allocation functions.
6574 /// Only look for allocation functions in the global scope.
6576 /// Only look for allocation functions in the scope of the
6577 /// allocated class.
6579 /// Look for allocation functions in both the global scope
6580 /// and in the scope of the allocated class.
6581 AFS_Both
6583
6584 /// Finds the overloads of operator new and delete that are appropriate
6585 /// for the allocation.
6587 AllocationFunctionScope NewScope,
6588 AllocationFunctionScope DeleteScope,
6589 QualType AllocType, bool IsArray,
6590 bool &PassAlignment, MultiExprArg PlaceArgs,
6591 FunctionDecl *&OperatorNew,
6592 FunctionDecl *&OperatorDelete,
6593 bool Diagnose = true);
6596 ArrayRef<QualType> Params);
6597
6599 DeclarationName Name, FunctionDecl *&Operator,
6600 bool Diagnose = true, bool WantSize = false,
6601 bool WantAligned = false);
6603 bool CanProvideSize,
6604 bool Overaligned,
6605 DeclarationName Name);
6607 CXXRecordDecl *RD);
6608
6609 /// ActOnCXXDelete - Parsed a C++ 'delete' expression
6610 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
6611 bool ArrayForm, Expr *Operand);
6613 bool IsDelete, bool CallCanBeVirtual,
6614 bool WarnOnNonAbstractTypes,
6615 SourceLocation DtorLoc);
6616
6618 Expr *Operand, SourceLocation RParen);
6620 SourceLocation RParen);
6621
6623 SourceLocation OpLoc,
6624 tok::TokenKind OpKind,
6625 ParsedType &ObjectType,
6626 bool &MayBePseudoDestructor);
6627
6629 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
6630 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
6631 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
6632
6634 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
6635 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
6636 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
6637
6639 SourceLocation OpLoc,
6640 tok::TokenKind OpKind,
6641 SourceLocation TildeLoc,
6642 const DeclSpec &DS);
6643
6644 /// MaybeCreateExprWithCleanups - If the current full-expression
6645 /// requires any cleanups, surround it with a ExprWithCleanups node.
6646 /// Otherwise, just returns the passed-in expression.
6650
6651 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
6652 return ActOnFinishFullExpr(
6653 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
6654 }
6656 bool DiscardedValue, bool IsConstexpr = false,
6657 bool IsTemplateArgument = false);
6659
6661
6662 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
6663 bool IsUDSuffix);
6664
6666
6667 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
6668 SourceLocation StmtLoc,
6669 ConditionKind CK);
6670
6672 SourceLocation StmtLoc, ConditionKind CK);
6673
6674 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
6675 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
6676
6678
6680 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
6681 AssignmentAction Action,
6684 const StandardConversionSequence &SCS,
6685 AssignmentAction Action,
6687
6688 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
6689
6690 /// Parsed one of the type trait support pseudo-functions.
6693 SourceLocation RParenLoc);
6696 SourceLocation RParenLoc);
6697
6698 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
6699 /// pseudo-functions.
6701 ParsedType LhsTy, Expr *DimExpr,
6702 SourceLocation RParen);
6703
6705 TypeSourceInfo *TSInfo, Expr *DimExpr,
6706 SourceLocation RParen);
6707
6708 /// ActOnExpressionTrait - Parsed one of the unary type trait support
6709 /// pseudo-functions.
6711 Expr *Queried, SourceLocation RParen);
6712
6714 Expr *Queried, SourceLocation RParen);
6715
6717 ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc,
6718 bool isIndirect);
6720 ExprResult &RHS,
6721 SourceLocation QuestionLoc);
6722
6724 ExprResult &LHS, ExprResult &RHS,
6725 SourceLocation QuestionLoc);
6726
6728 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
6729 ExprObjectKind &OK, SourceLocation questionLoc);
6730
6732 bool ConvertArgs = true);
6734 ExprResult &E2, bool ConvertArgs = true) {
6735 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
6736 QualType Composite =
6737 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
6738 E1 = E1Tmp;
6739 E2 = E2Tmp;
6740 return Composite;
6741 }
6742
6743 /// MaybeBindToTemporary - If the passed in expression has a record type with
6744 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
6745 /// it simply returns the passed in expression.
6747
6748 /// IgnoredValueConversions - Given that an expression's result is
6749 /// syntactically ignored, perform any conversions that are
6750 /// required.
6752
6754
6755 /// Process any TypoExprs in the given Expr and its children,
6756 /// generating diagnostics as appropriate and returning a new Expr if there
6757 /// were typos that were all successfully corrected and ExprError if one or
6758 /// more typos could not be corrected.
6759 ///
6760 /// \param E The Expr to check for TypoExprs.
6761 ///
6762 /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
6763 /// initializer.
6764 ///
6765 /// \param RecoverUncorrectedTypos If true, when typo correction fails, it
6766 /// will rebuild the given Expr with all TypoExprs degraded to RecoveryExprs.
6767 ///
6768 /// \param Filter A function applied to a newly rebuilt Expr to determine if
6769 /// it is an acceptable/usable result from a single combination of typo
6770 /// corrections. As long as the filter returns ExprError, different
6771 /// combinations of corrections will be tried until all are exhausted.
6773 Expr *E, VarDecl *InitDecl = nullptr,
6774 bool RecoverUncorrectedTypos = false,
6775 llvm::function_ref<ExprResult(Expr *)> Filter =
6776 [](Expr *E) -> ExprResult { return E; });
6777
6779 ExprResult ER, VarDecl *InitDecl = nullptr,
6780 bool RecoverUncorrectedTypos = false,
6781 llvm::function_ref<ExprResult(Expr *)> Filter =
6782 [](Expr *E) -> ExprResult { return E; }) {
6783 return ER.isInvalid()
6784 ? ER
6785 : CorrectDelayedTyposInExpr(ER.get(), InitDecl,
6786 RecoverUncorrectedTypos, Filter);
6787 }
6788
6789 /// Describes the result of an "if-exists" condition check.
6791 /// The symbol exists.
6793
6794 /// The symbol does not exist.
6796
6797 /// The name is a dependent name, so the results will differ
6798 /// from one instantiation to the next.
6800
6801 /// An error occurred.
6802 IER_Error
6804
6807 const DeclarationNameInfo &TargetNameInfo);
6808
6810 SourceLocation KeywordLoc,
6811 bool IsIfExists, CXXScopeSpec &SS,
6812 UnqualifiedId &Name);
6813
6816 ArrayRef<ParmVarDecl *> LocalParameters,
6817 Scope *BodyScope);
6821 CXXScopeSpec &SS,
6822 SourceLocation NameLoc,
6823 const IdentifierInfo *TypeName,
6824 TemplateIdAnnotation *TemplateId);
6826 SourceLocation NoexceptLoc);
6828 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
6829 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
6832 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
6836 bool IsSatisfied, SourceLocation NoexceptLoc,
6843 BuildNestedRequirement(StringRef InvalidConstraintEntity,
6844 const ASTConstraintSatisfaction &Satisfaction);
6847 SourceLocation LParenLoc,
6848 ArrayRef<ParmVarDecl *> LocalParameters,
6849 SourceLocation RParenLoc,
6851 SourceLocation ClosingBraceLoc);
6852
6853private:
6854 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
6855 bool IsDelete);
6856
6857 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
6858 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
6859 bool DeleteWasArrayForm);
6860
6861 ///@}
6862
6863 //
6864 //
6865 // -------------------------------------------------------------------------
6866 //
6867 //
6868
6869 /// \name Member Access Expressions
6870 /// Implementations are in SemaExprMember.cpp
6871 ///@{
6872
6873public:
6874 /// Check whether an expression might be an implicit class member access.
6876 bool IsAddressOfOperand);
6877
6879 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
6880 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
6881
6883 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6884 LookupResult &R,
6885 const TemplateArgumentListInfo *TemplateArgs,
6886 bool IsDefiniteInstance, const Scope *S);
6887
6889 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
6890 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6891 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
6892 const TemplateArgumentListInfo *TemplateArgs);
6893
6895 tok::TokenKind OpKind, CXXScopeSpec &SS,
6896 SourceLocation TemplateKWLoc,
6897 UnqualifiedId &Member, Decl *ObjCImpDecl);
6898
6899 MemberExpr *
6900 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
6901 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
6902 ValueDecl *Member, DeclAccessPair FoundDecl,
6903 bool HadMultipleCandidates,
6904 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
6906 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6907
6908 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
6909 const CXXScopeSpec &SS,
6910 const LookupResult &R);
6911
6912 // This struct is for use by ActOnMemberAccess to allow
6913 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
6914 // changing the access operator from a '.' to a '->' (to see if that is the
6915 // change needed to fix an error about an unknown member, e.g. when the class
6916 // defines a custom operator->).
6921 };
6922
6924 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
6925 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6926 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
6927 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
6928 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
6929
6932 bool IsArrow, const CXXScopeSpec &SS,
6933 SourceLocation TemplateKWLoc,
6934 NamedDecl *FirstQualifierInScope, LookupResult &R,
6935 const TemplateArgumentListInfo *TemplateArgs,
6936 const Scope *S, bool SuppressQualifierCheck = false,
6937 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
6938
6939 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
6940 SourceLocation OpLoc,
6941 const CXXScopeSpec &SS, FieldDecl *Field,
6942 DeclAccessPair FoundDecl,
6943 const DeclarationNameInfo &MemberNameInfo);
6944
6946
6948 const CXXScopeSpec &SS, SourceLocation nameLoc,
6949 IndirectFieldDecl *indirectField,
6950 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
6951 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
6952
6953private:
6954 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
6955
6956 ///@}
6957
6958 //
6959 //
6960 // -------------------------------------------------------------------------
6961 //
6962 //
6963
6964 /// \name Initializers
6965 /// Implementations are in SemaInit.cpp
6966 ///@{
6967
6968public:
6969 /// Stack of types that correspond to the parameter entities that are
6970 /// currently being copy-initialized. Can be empty.
6972
6973 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
6975
6976 bool IsStringInit(Expr *Init, const ArrayType *AT);
6977
6979 const InitializedEntity &Entity, InitListExpr *From);
6980
6982 SourceLocation EqualOrColonLoc,
6983 bool GNUSyntax, ExprResult Init);
6984
6985 /// Check that the lifetime of the initializer (and its subobjects) is
6986 /// sufficient for initializing the entity, and perform lifetime extension
6987 /// (when permitted) if not.
6989
6992 bool BoundToLvalueReference);
6993
6994 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
6995 /// it as an xvalue. In C++98, the result will still be a prvalue, because
6996 /// we don't have xvalues there.
6998
7002
7006 SourceLocation EqualLoc, ExprResult Init,
7007 bool TopLevelOfInitList = false,
7008 bool AllowExplicit = false);
7009
7011 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
7012 const InitializationKind &Kind, MultiExprArg Init);
7013
7014 ///@}
7015
7016 //
7017 //
7018 // -------------------------------------------------------------------------
7019 //
7020 //
7021
7022 /// \name C++ Lambda Expressions
7023 /// Implementations are in SemaLambda.cpp
7024 ///@{
7025
7026public:
7027 /// Create a new lambda closure type.
7029 TypeSourceInfo *Info,
7030 unsigned LambdaDependencyKind,
7031 LambdaCaptureDefault CaptureDefault);
7032
7033 /// Number lambda for linkage purposes if necessary.
7035 std::optional<CXXRecordDecl::LambdaNumbering>
7036 NumberingOverride = std::nullopt);
7037
7038 /// Endow the lambda scope info with the relevant properties.
7039 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
7040 SourceRange IntroducerRange,
7041 LambdaCaptureDefault CaptureDefault,
7042 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
7043 bool Mutable);
7044
7047
7049 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
7050 TemplateParameterList *TemplateParams);
7051
7053 CXXMethodDecl *Method, SourceLocation LambdaLoc,
7054 SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause,
7055 TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind,
7057 bool HasExplicitResultType);
7058
7060
7061 /// Perform initialization analysis of the init-capture and perform
7062 /// any implicit conversions such as an lvalue-to-rvalue conversion if
7063 /// not being used to initialize a reference.
7065 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
7068 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
7070 }
7072 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
7073 std::optional<unsigned> NumExpansions, IdentifierInfo *Id,
7074 bool DirectInit, Expr *&Init);
7075
7076 /// Create a dummy variable within the declcontext of the lambda's
7077 /// call operator, for name lookup purposes for a lambda init capture.
7078 ///
7079 /// CodeGen handles emission of lambda captures, ignoring these dummy
7080 /// variables appropriately.
7082 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
7083 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
7084
7085 /// Add an init-capture to a lambda scope.
7086 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
7087
7088 /// Note that we have finished the explicit captures for the
7089 /// given lambda.
7091
7092 /// Deduce a block or lambda's return type based on the return
7093 /// statements present in the body.
7095
7096 /// Once the Lambdas capture are known, we can start to create the closure,
7097 /// call operator method, and keep track of the captures.
7098 /// We do the capture lookup here, but they are not actually captured until
7099 /// after we know what the qualifiers of the call operator are.
7101 Scope *CurContext);
7102
7103 /// This is called after parsing the explicit template parameter list
7104 /// on a lambda (if it exists) in C++2a.
7106 SourceLocation LAngleLoc,
7107 ArrayRef<NamedDecl *> TParams,
7108 SourceLocation RAngleLoc,
7109 ExprResult RequiresClause);
7110
7112 SourceLocation MutableLoc);
7113
7115 Scope *LambdaScope,
7117
7118 /// ActOnStartOfLambdaDefinition - This is called just before we start
7119 /// parsing the body of a lambda; it analyzes the explicit captures and
7120 /// arguments, and sets up various data-structures for the body of the
7121 /// lambda.
7123 Declarator &ParamInfo, const DeclSpec &DS);
7124
7125 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
7126 /// is invoked to pop the information about the lambda.
7127 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
7128 bool IsInstantiation = false);
7129
7130 /// ActOnLambdaExpr - This is called when the body of a lambda expression
7131 /// was successfully completed.
7133
7134 /// Does copying/destroying the captured variable have side effects?
7135 bool CaptureHasSideEffects(const sema::Capture &From);
7136
7137 /// Diagnose if an explicit lambda capture is unused. Returns true if a
7138 /// diagnostic is emitted.
7139 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
7140 const sema::Capture &From);
7141
7142 /// Build a FieldDecl suitable to hold the given capture.
7144
7145 /// Initialize the given capture with a suitable expression.
7147 SourceLocation ImplicitCaptureLoc,
7148 bool IsOpenMPMapping = false);
7149
7150 /// Complete a lambda-expression having processed and attached the
7151 /// lambda body.
7154
7155 /// Get the return type to use for a lambda's conversion function(s) to
7156 /// function pointer type, given the type of the call operator.
7157 QualType
7159 CallingConv CC);
7160
7162 SourceLocation ConvLocation,
7163 CXXConversionDecl *Conv, Expr *Src);
7164
7166 : private FunctionScopeRAII {
7167 public:
7169 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
7171 bool ShouldAddDeclsFromParentScope = true);
7172 };
7173
7174 /// Compute the mangling number context for a lambda expression or
7175 /// block literal. Also return the extra mangling decl if any.
7176 ///
7177 /// \param DC - The DeclContext containing the lambda expression or
7178 /// block literal.
7179 std::tuple<MangleNumberingContext *, Decl *>
7181
7182 ///@}
7183
7184 //
7185 //
7186 // -------------------------------------------------------------------------
7187 //
7188 //
7189
7190 /// \name Name Lookup
7191 ///
7192 /// These routines provide name lookup that is used during semantic
7193 /// analysis to resolve the various kinds of names (identifiers,
7194 /// overloaded operator names, constructor names, etc.) into zero or
7195 /// more declarations within a particular scope. The major entry
7196 /// points are LookupName, which performs unqualified name lookup,
7197 /// and LookupQualifiedName, which performs qualified name lookup.
7198 ///
7199 /// All name lookup is performed based on some specific criteria,
7200 /// which specify what names will be visible to name lookup and how
7201 /// far name lookup should work. These criteria are important both
7202 /// for capturing language semantics (certain lookups will ignore
7203 /// certain names, for example) and for performance, since name
7204 /// lookup is often a bottleneck in the compilation of C++. Name
7205 /// lookup criteria is specified via the LookupCriteria enumeration.
7206 ///
7207 /// The results of name lookup can vary based on the kind of name
7208 /// lookup performed, the current language, and the translation
7209 /// unit. In C, for example, name lookup will either return nothing
7210 /// (no entity found) or a single declaration. In C++, name lookup
7211 /// can additionally refer to a set of overloaded functions or
7212 /// result in an ambiguity. All of the possible results of name
7213 /// lookup are captured by the LookupResult class, which provides
7214 /// the ability to distinguish among them.
7215 ///
7216 /// Implementations are in SemaLookup.cpp
7217 ///@{
7218
7219public:
7220 /// Tracks whether we are in a context where typo correction is
7221 /// disabled.
7223
7224 /// The number of typos corrected by CorrectTypo.
7226
7227 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
7228 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
7229
7230 /// A cache containing identifiers for which typo correction failed and
7231 /// their locations, so that repeated attempts to correct an identifier in a
7232 /// given location are ignored if typo correction already failed for it.
7234
7235 /// SpecialMemberOverloadResult - The overloading result for a special member
7236 /// function.
7237 ///
7238 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
7239 /// integer are used to determine whether overload resolution succeeded.
7241 public:
7242 enum Kind { NoMemberOrDeleted, Ambiguous, Success };
7243
7244 private:
7245 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
7246
7247 public:
7250 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
7251
7252 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
7253 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
7254
7255 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
7256 void setKind(Kind K) { Pair.setInt(K); }
7257 };
7258
7259 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
7261 public:
7262 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
7263 : FastFoldingSetNode(ID) {}
7264 };
7265
7266 /// A cache of special member function overload resolution results
7267 /// for C++ records.
7268 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
7269
7270 /// Holds TypoExprs that are created from `createDelayedTypo`. This is used by
7271 /// `TransformTypos` in order to keep track of any TypoExprs that are created
7272 /// recursively during typo correction and wipe them away if the correction
7273 /// fails.
7275
7277
7278 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
7279 // TODO: make this is a typesafe union.
7282
7283 /// Describes the kind of name lookup to perform.
7285 /// Ordinary name lookup, which finds ordinary names (functions,
7286 /// variables, typedefs, etc.) in C and most kinds of names
7287 /// (functions, variables, members, types, etc.) in C++.
7289 /// Tag name lookup, which finds the names of enums, classes,
7290 /// structs, and unions.
7292 /// Label name lookup.
7294 /// Member name lookup, which finds the names of
7295 /// class/struct/union members.
7297 /// Look up of an operator name (e.g., operator+) for use with
7298 /// operator overloading. This lookup is similar to ordinary name
7299 /// lookup, but will ignore any declarations that are class members.
7301 /// Look up a name following ~ in a destructor name. This is an ordinary
7302 /// lookup, but prefers tags to typedefs.
7304 /// Look up of a name that precedes the '::' scope resolution
7305 /// operator in C++. This lookup completely ignores operator, object,
7306 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
7308 /// Look up a namespace name within a C++ using directive or
7309 /// namespace alias definition, ignoring non-namespace names (C++
7310 /// [basic.lookup.udir]p1).
7312 /// Look up all declarations in a scope with the given name,
7313 /// including resolved using declarations. This is appropriate
7314 /// for checking redeclarations for a using declaration.
7316 /// Look up an ordinary name that is going to be redeclared as a
7317 /// name with linkage. This lookup ignores any declarations that
7318 /// are outside of the current scope unless they have linkage. See
7319 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
7321 /// Look up a friend of a local class. This lookup does not look
7322 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
7324 /// Look up the name of an Objective-C protocol.
7326 /// Look up implicit 'self' parameter of an objective-c method.
7328 /// Look up the name of an OpenMP user-defined reduction operation.
7330 /// Look up the name of an OpenMP user-defined mapper.
7332 /// Look up any declaration with any name.
7335
7336 /// The possible outcomes of name lookup for a literal operator.
7338 /// The lookup resulted in an error.
7340 /// The lookup found no match but no diagnostic was issued.
7342 /// The lookup found a single 'cooked' literal operator, which
7343 /// expects a normal literal to be built and passed to it.
7345 /// The lookup found a single 'raw' literal operator, which expects
7346 /// a string literal containing the spelling of the literal token.
7348 /// The lookup found an overload set of literal operator templates,
7349 /// which expect the characters of the spelling of the literal token to be
7350 /// passed as a non-type template argument pack.
7352 /// The lookup found an overload set of literal operator templates,
7353 /// which expect the character type and characters of the spelling of the
7354 /// string literal token to be passed as template arguments.
7356 };
7357
7358 SpecialMemberOverloadResult
7360 bool VolatileArg, bool RValueThis, bool ConstThis,
7361 bool VolatileThis);
7362
7363 typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
7364 typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
7366
7368
7369 /// Look up a name, looking for a single declaration. Return
7370 /// null if the results were absent, ambiguous, or overloaded.
7371 ///
7372 /// It is preferable to use the elaborated form and explicitly handle
7373 /// ambiguity and overloaded.
7376 LookupNameKind NameKind,
7377 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
7378 bool LookupBuiltin(LookupResult &R);
7379 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
7380 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
7381 bool ForceNoCPlusPlus = false);
7382 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
7383 bool InUnqualifiedLookup = false);
7384 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
7385 CXXScopeSpec &SS);
7387 QualType ObjectType, bool AllowBuiltinCreation = false,
7388 bool EnteringContext = false);
7390
7392 UnresolvedSetImpl &Functions);
7393
7395 SourceLocation GnuLabelLoc = SourceLocation());
7396
7400 unsigned Quals);
7402 bool RValueThis, unsigned ThisQuals);
7404 unsigned Quals);
7406 bool RValueThis, unsigned ThisQuals);
7408
7409 /// Force the declaration of any implicitly-declared members of this
7410 /// class.
7412
7413 /// Make a merged definition of an existing hidden definition \p ND
7414 /// visible at the specified location.
7416
7417 /// Check ODR hashes for C/ObjC when merging types from modules.
7418 /// Differently from C++, actually parse the body and reject in case
7419 /// of a mismatch.
7420 template <typename T,
7421 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
7423 if (Duplicate->getODRHash() != Previous->getODRHash())
7424 return false;
7425
7426 // Make the previous decl visible.
7428 return true;
7429 }
7430
7431 /// Get the set of additional modules that should be checked during
7432 /// name lookup. A module and its imports become visible when instanting a
7433 /// template defined within it.
7435
7436 bool hasVisibleMergedDefinition(const NamedDecl *Def);
7438
7439 /// Determine if the template parameter \p D has a visible default argument.
7440 bool
7442 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7443 /// Determine if the template parameter \p D has a reachable default argument.
7445 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7446 /// Determine if the template parameter \p D has a reachable default argument.
7450
7451 /// Determine if there is a visible declaration of \p D that is an explicit
7452 /// specialization declaration for a specialization of a template. (For a
7453 /// member specialization, use hasVisibleMemberSpecialization.)
7455 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7456 /// Determine if there is a reachable declaration of \p D that is an explicit
7457 /// specialization declaration for a specialization of a template. (For a
7458 /// member specialization, use hasReachableMemberSpecialization.)
7460 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7461
7462 /// Determine if there is a visible declaration of \p D that is a member
7463 /// specialization declaration (as opposed to an instantiated declaration).
7465 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7466 /// Determine if there is a reachable declaration of \p D that is a member
7467 /// specialization declaration (as opposed to an instantiated declaration).
7469 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7470
7471 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
7472
7473 /// Determine whether any declaration of an entity is visible.
7474 bool
7476 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
7477 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
7478 }
7479
7482 /// Determine whether any declaration of an entity is reachable.
7483 bool
7485 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
7486 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
7487 }
7489 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7490
7491 void diagnoseTypo(const TypoCorrection &Correction,
7492 const PartialDiagnostic &TypoDiag,
7493 bool ErrorRecovery = true);
7494
7495 void diagnoseTypo(const TypoCorrection &Correction,
7496 const PartialDiagnostic &TypoDiag,
7497 const PartialDiagnostic &PrevNote,
7498 bool ErrorRecovery = true);
7499
7501 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
7502 AssociatedNamespaceSet &AssociatedNamespaces,
7503 AssociatedClassSet &AssociatedClasses);
7504
7506
7509 bool AllowRaw, bool AllowTemplate,
7510 bool AllowStringTemplate, bool DiagnoseMissing,
7511 StringLiteral *StringLit = nullptr);
7512
7514 ArrayRef<Expr *> Args, ADLResult &Functions);
7515
7518 bool IncludeGlobalScope = true,
7519 bool LoadExternal = true);
7522 bool IncludeGlobalScope = true,
7523 bool IncludeDependentBases = false,
7524 bool LoadExternal = true);
7525
7527 CTK_NonError, // CorrectTypo used in a non error recovery situation.
7528 CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
7530
7532 Sema::LookupNameKind LookupKind, Scope *S,
7534 CorrectTypoKind Mode,
7535 DeclContext *MemberContext = nullptr,
7536 bool EnteringContext = false,
7537 const ObjCObjectPointerType *OPT = nullptr,
7538 bool RecordFailure = true);
7539
7541 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
7544 CorrectTypoKind Mode, DeclContext *MemberContext = nullptr,
7545 bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr);
7546
7547 /// Kinds of missing import. Note, the values of these enumerators correspond
7548 /// to %select values in diagnostics.
7551 Definition,
7555 };
7556
7557 /// Diagnose that the specified declaration needs to be visible but
7558 /// isn't, and suggest a module import that would resolve the problem.
7560 MissingImportKind MIK, bool Recover = true);
7562 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
7563 MissingImportKind MIK, bool Recover);
7564
7566 std::unique_ptr<TypoCorrectionConsumer> Consumer;
7569 TypoExprState();
7570 TypoExprState(TypoExprState &&other) noexcept;
7571 TypoExprState &operator=(TypoExprState &&other) noexcept;
7572 };
7573
7574 const TypoExprState &getTypoExprState(TypoExpr *TE) const;
7575
7576 /// Clears the state of the given TypoExpr.
7577 void clearDelayedTypo(TypoExpr *TE);
7578
7579 /// Called on #pragma clang __debug dump II
7581
7582 /// Called on #pragma clang __debug dump E
7583 void ActOnPragmaDump(Expr *E);
7584
7585private:
7586 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
7587 //
7588 // The boolean value will be true to indicate that the namespace was loaded
7589 // from an AST/PCH file, or false otherwise.
7590 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
7591
7592 /// Whether we have already loaded known namespaces from an extenal
7593 /// source.
7594 bool LoadedExternalKnownNamespaces;
7595
7596 bool CppLookupName(LookupResult &R, Scope *S);
7597
7598 bool isUsableModule(const Module *M);
7599
7600 /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
7601 /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
7602 /// should be skipped entirely.
7603 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
7604 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
7606 DeclContext *MemberContext, bool EnteringContext,
7607 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
7608
7609 /// The set of unhandled TypoExprs and their associated state.
7610 llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
7611
7612 /// Creates a new TypoExpr AST node.
7613 TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
7616
7617 /// Cache for module units which is usable for current module.
7618 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
7619
7620 /// Record the typo correction failure and return an empty correction.
7621 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
7622 bool RecordFailure = true) {
7623 if (RecordFailure)
7624 TypoCorrectionFailures[Typo].insert(TypoLoc);
7625 return TypoCorrection();
7626 }
7627
7628 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
7629
7630 /// Determine whether two declarations should be linked together, given that
7631 /// the old declaration might not be visible and the new declaration might
7632 /// not have external linkage.
7633 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
7634 const NamedDecl *New) {
7635 if (isVisible(Old))
7636 return true;
7637 // See comment in below overload for why it's safe to compute the linkage
7638 // of the new declaration here.
7639 if (New->isExternallyDeclarable()) {
7640 assert(Old->isExternallyDeclarable() &&
7641 "should not have found a non-externally-declarable previous decl");
7642 return true;
7643 }
7644 return false;
7645 }
7646 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
7647
7648 ///@}
7649
7650 //
7651 //
7652 // -------------------------------------------------------------------------
7653 //
7654 //
7655
7656 /// \name Modules
7657 /// Implementations are in SemaModule.cpp
7658 ///@{
7659
7660public:
7661 /// Get the module unit whose scope we are currently within.
7663 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
7664 }
7665
7666 /// Is the module scope we are an implementation unit?
7668 return ModuleScopes.empty()
7669 ? false
7670 : ModuleScopes.back().Module->isModuleImplementation();
7671 }
7672
7673 // When loading a non-modular PCH files, this is used to restore module
7674 // visibility.
7676 VisibleModules.setVisible(Mod, ImportLoc);
7677 }
7678
7679 enum class ModuleDeclKind {
7680 Interface, ///< 'export module X;'
7681 Implementation, ///< 'module X;'
7682 PartitionInterface, ///< 'export module X:Y;'
7683 PartitionImplementation, ///< 'module X:Y;'
7684 };
7685
7686 /// An enumeration to represent the transition of states in parsing module
7687 /// fragments and imports. If we are not parsing a C++20 TU, or we find
7688 /// an error in state transition, the state is set to NotACXX20Module.
7690 FirstDecl, ///< Parsing the first decl in a TU.
7691 GlobalFragment, ///< after 'module;' but before 'module X;'
7692 ImportAllowed, ///< after 'module X;' but before any non-import decl.
7693 ImportFinished, ///< after any non-import decl.
7694 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
7695 ///< non-import decl.
7696 PrivateFragmentImportFinished, ///< after 'module :private;' but a
7697 ///< non-import decl has already been seen.
7698 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
7699 };
7700
7701 /// The parser has processed a module-declaration that begins the definition
7702 /// of a module interface or implementation.
7704 SourceLocation ModuleLoc, ModuleDeclKind MDK,
7705 ModuleIdPath Path, ModuleIdPath Partition,
7706 ModuleImportState &ImportState);
7707
7708 /// The parser has processed a global-module-fragment declaration that begins
7709 /// the definition of the global module fragment of the current module unit.
7710 /// \param ModuleLoc The location of the 'module' keyword.
7712
7713 /// The parser has processed a private-module-fragment declaration that begins
7714 /// the definition of the private module fragment of the current module unit.
7715 /// \param ModuleLoc The location of the 'module' keyword.
7716 /// \param PrivateLoc The location of the 'private' keyword.
7718 SourceLocation PrivateLoc);
7719
7720 /// The parser has processed a module import declaration.
7721 ///
7722 /// \param StartLoc The location of the first token in the declaration. This
7723 /// could be the location of an '@', 'export', or 'import'.
7724 /// \param ExportLoc The location of the 'export' keyword, if any.
7725 /// \param ImportLoc The location of the 'import' keyword.
7726 /// \param Path The module toplevel name as an access path.
7727 /// \param IsPartition If the name is for a partition.
7729 SourceLocation ExportLoc,
7730 SourceLocation ImportLoc, ModuleIdPath Path,
7731 bool IsPartition = false);
7733 SourceLocation ExportLoc,
7734 SourceLocation ImportLoc, Module *M,
7735 ModuleIdPath Path = {});
7736
7737 /// The parser has processed a module import translated from a
7738 /// #include or similar preprocessing directive.
7739 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
7740 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
7741
7742 /// The parsed has entered a submodule.
7743 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
7744 /// The parser has left a submodule.
7745 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
7746
7747 /// Create an implicit import of the given module at the given
7748 /// source location, for error recovery, if possible.
7749 ///
7750 /// This routine is typically used when an entity found by name lookup
7751 /// is actually hidden within a module that we know about but the user
7752 /// has forgotten to import.
7754 Module *Mod);
7755
7756 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
7757 SourceLocation LBraceLoc);
7758 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
7759 SourceLocation RBraceLoc);
7760
7761private:
7762 /// The parser has begun a translation unit to be compiled as a C++20
7763 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
7764 void HandleStartOfHeaderUnit();
7765
7766 struct ModuleScope {
7767 SourceLocation BeginLoc;
7768 clang::Module *Module = nullptr;
7769 VisibleModuleSet OuterVisibleModules;
7770 };
7771 /// The modules we're currently parsing.
7773
7774 /// For an interface unit, this is the implicitly imported interface unit.
7775 clang::Module *ThePrimaryInterface = nullptr;
7776
7777 /// The explicit global module fragment of the current translation unit.
7778 /// The explicit Global Module Fragment, as specified in C++
7779 /// [module.global.frag].
7780 clang::Module *TheGlobalModuleFragment = nullptr;
7781
7782 /// The implicit global module fragments of the current translation unit.
7783 ///
7784 /// The contents in the implicit global module fragment can't be discarded.
7785 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
7786
7787 /// Namespace definitions that we will export when they finish.
7788 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
7789
7790 /// In a C++ standard module, inline declarations require a definition to be
7791 /// present at the end of a definition domain. This set holds the decls to
7792 /// be checked at the end of the TU.
7793 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
7794
7795 /// Helper function to judge if we are in module purview.
7796 /// Return false if we are not in a module.
7797 bool isCurrentModulePurview() const;
7798
7799 /// Enter the scope of the explicit global module fragment.
7800 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
7801 /// Leave the scope of the explicit global module fragment.
7802 void PopGlobalModuleFragment();
7803
7804 /// Enter the scope of an implicit global module fragment.
7805 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
7806 /// Leave the scope of an implicit global module fragment.
7807 void PopImplicitGlobalModuleFragment();
7808
7809 VisibleModuleSet VisibleModules;
7810
7811 ///@}
7812
7813 //
7814 //
7815 // -------------------------------------------------------------------------
7816 //
7817 //
7818
7819 /// \name C++ Overloading
7820 /// Implementations are in SemaOverload.cpp
7821 ///@{
7822
7823public:
7824 /// Whether deferrable diagnostics should be deferred.
7825 bool DeferDiags = false;
7826
7827 /// RAII class to control scope of DeferDiags.
7829 Sema &S;
7830 bool SavedDeferDiags = false;
7831
7832 public:
7833 DeferDiagsRAII(Sema &S, bool DeferDiags)
7834 : S(S), SavedDeferDiags(S.DeferDiags) {
7835 S.DeferDiags = DeferDiags;
7836 }
7837 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
7838 };
7839
7840 /// Flag indicating if Sema is building a recovery call expression.
7841 ///
7842 /// This flag is used to avoid building recovery call expressions
7843 /// if Sema is already doing so, which would cause infinite recursions.
7845
7847 /// This is a legitimate overload: the existing declarations are
7848 /// functions or function templates with different signatures.
7850
7851 /// This is not an overload because the signature exactly matches
7852 /// an existing declaration.
7854
7855 /// This is not an overload because the lookup results contain a
7856 /// non-function.
7860 const LookupResult &OldDecls, NamedDecl *&OldDecl,
7861 bool UseMemberUsingDeclRules);
7862 bool IsOverload(FunctionDecl *New, FunctionDecl *Old,
7863 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
7864
7865 // Checks whether MD constitutes an override the base class method BaseMD.
7866 // When checking for overrides, the object object members are ignored.
7867 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
7868 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
7869
7870 enum class AllowedExplicit {
7871 /// Allow no explicit functions to be used.
7872 None,
7873 /// Allow explicit conversion functions but not explicit constructors.
7875 /// Allow both explicit conversion functions and explicit constructors.
7876 All
7877 };
7878
7880 Expr *From, QualType ToType, bool SuppressUserConversions,
7881 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
7882 bool AllowObjCWritebackConversion);
7883
7885 AssignmentAction Action,
7886 bool AllowExplicit = false);
7887
7888 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
7889 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
7890 bool IsComplexPromotion(QualType FromType, QualType ToType);
7891 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
7892 bool InOverloadResolution, QualType &ConvertedType,
7893 bool &IncompatibleObjC);
7894 bool isObjCPointerConversion(QualType FromType, QualType ToType,
7895 QualType &ConvertedType, bool &IncompatibleObjC);
7896 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
7897 QualType &ConvertedType);
7898
7901 unsigned *ArgPos = nullptr,
7902 bool Reversed = false);
7903
7905 const FunctionProtoType *NewType,
7906 unsigned *ArgPos = nullptr,
7907 bool Reversed = false);
7908
7909 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
7910 const FunctionDecl *NewFunction,
7911 unsigned *ArgPos = nullptr,
7912 bool Reversed = false);
7913
7915 QualType ToType);
7916
7917 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
7918 CXXCastPath &BasePath, bool IgnoreBaseAccess,
7919 bool Diagnose = true);
7920 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
7921 bool InOverloadResolution,
7922 QualType &ConvertedType);
7923 bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
7924 CXXCastPath &BasePath,
7925 bool IgnoreBaseAccess);
7926 bool IsQualificationConversion(QualType FromType, QualType ToType,
7927 bool CStyle, bool &ObjCLifetimeConversion);
7928 bool IsFunctionConversion(QualType FromType, QualType ToType,
7929 QualType &ResultTy);
7932 DeclarationName Name,
7933 OverloadCandidateSet &CandidateSet,
7934 FunctionDecl *Fn, MultiExprArg Args,
7935 bool IsMember = false);
7936
7938 FunctionDecl *Fun);
7940 Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl,
7941 CXXMethodDecl *Method);
7942
7945
7946 /// Contexts in which a converted constant expression is required.
7947 enum CCEKind {
7948 CCEK_CaseValue, ///< Expression in a case label.
7949 CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
7950 CCEK_TemplateArg, ///< Value of a non-type template parameter.
7951 CCEK_ArrayBound, ///< Array bound in array declarator or new-expression.
7952 CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier.
7953 CCEK_Noexcept, ///< Condition in a noexcept(bool) specifier.
7954 CCEK_StaticAssertMessageSize, ///< Call to size() in a static assert
7955 ///< message.
7956 CCEK_StaticAssertMessageData, ///< Call to data() in a static assert
7957 ///< message.
7958 };
7959
7961 CCEKind CCE,
7962 NamedDecl *Dest = nullptr);
7963
7965 llvm::APSInt &Value, CCEKind CCE);
7967 APValue &Value, CCEKind CCE,
7968 NamedDecl *Dest = nullptr);
7969
7972 CCEKind CCE, bool RequireInt,
7973 const APValue &PreNarrowingValue);
7974
7975 /// Abstract base class used to perform a contextual implicit
7976 /// conversion from an expression to any type passing a filter.
7978 public:
7981
7982 ContextualImplicitConverter(bool Suppress = false,
7983 bool SuppressConversion = false)
7984 : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
7985
7986 /// Determine whether the specified type is a valid destination type
7987 /// for this conversion.
7988 virtual bool match(QualType T) = 0;
7989
7990 /// Emits a diagnostic complaining that the expression does not have
7991 /// integral or enumeration type.
7993 QualType T) = 0;
7994
7995 /// Emits a diagnostic when the expression has incomplete class type.
7996 virtual SemaDiagnosticBuilder
7998
7999 /// Emits a diagnostic when the only matching conversion function
8000 /// is explicit.
8003 QualType T,
8004 QualType ConvTy) = 0;
8005
8006 /// Emits a note for the explicit conversion function.
8007 virtual SemaDiagnosticBuilder
8009
8010 /// Emits a diagnostic when there are multiple possible conversion
8011 /// functions.
8013 QualType T) = 0;
8014
8015 /// Emits a note for one of the candidate conversions.
8016 virtual SemaDiagnosticBuilder
8018
8019 /// Emits a diagnostic when we picked a conversion function
8020 /// (for cases when we are not allowed to pick a conversion function).
8023 QualType T,
8024 QualType ConvTy) = 0;
8025
8027 };
8028
8030 bool AllowScopedEnumerations;
8031
8032 public:
8033 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
8034 bool SuppressConversion)
8035 : ContextualImplicitConverter(Suppress, SuppressConversion),
8036 AllowScopedEnumerations(AllowScopedEnumerations) {}
8037
8038 /// Match an integral or (possibly scoped) enumeration type.
8039 bool match(QualType T) override;
8040
8042 QualType T) override {
8043 return diagnoseNotInt(S, Loc, T);
8044 }
8045
8046 /// Emits a diagnostic complaining that the expression does not have
8047 /// integral or enumeration type.
8049 QualType T) = 0;
8050 };
8051
8052 /// Perform a contextual implicit conversion.
8055 ContextualImplicitConverter &Converter);
8056
8057 /// ReferenceCompareResult - Expresses the result of comparing two
8058 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
8059 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
8061 /// Ref_Incompatible - The two types are incompatible, so direct
8062 /// reference binding is not possible.
8064 /// Ref_Related - The two types are reference-related, which means
8065 /// that their unqualified forms (T1 and T2) are either the same
8066 /// or T1 is a base class of T2.
8068 /// Ref_Compatible - The two types are reference-compatible.
8071
8072 // Fake up a scoped enumeration that still contextually converts to bool.
8074 /// The conversions that would be performed on an lvalue of type T2 when
8075 /// binding a reference of type T1 to it, as determined when evaluating
8076 /// whether T1 is reference-compatible with T2.
8078 Qualification = 0x1,
8079 NestedQualification = 0x2,
8081 DerivedToBase = 0x8,
8082 ObjC = 0x10,
8083 ObjCLifetime = 0x20,
8084
8085 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
8086 };
8087 };
8089
8092 ReferenceConversions *Conv = nullptr);
8093
8096 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
8097 bool PartialOverloading = false, bool AllowExplicit = true,
8098 bool AllowExplicitConversion = false,
8099 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
8100 ConversionSequenceList EarlyConversions = std::nullopt,
8102 bool AggregateCandidateDeduction = false);
8104 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
8105 OverloadCandidateSet &CandidateSet,
8106 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
8107 bool SuppressUserConversions = false, bool PartialOverloading = false,
8108 bool FirstArgumentIsBase = false);
8109 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
8110 Expr::Classification ObjectClassification,
8111 ArrayRef<Expr *> Args,
8112 OverloadCandidateSet &CandidateSet,
8113 bool SuppressUserConversion = false,
8115 void
8116 AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
8117 CXXRecordDecl *ActingContext, QualType ObjectType,
8118 Expr::Classification ObjectClassification,
8119 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
8120 bool SuppressUserConversions = false,
8121 bool PartialOverloading = false,
8122 ConversionSequenceList EarlyConversions = std::nullopt,
8125 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
8126 CXXRecordDecl *ActingContext,
8127 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
8128 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
8129 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
8130 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
8132 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
8133 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
8134 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
8135 bool PartialOverloading = false, bool AllowExplicit = true,
8136 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
8138 bool AggregateCandidateDeduction = false);
8140 FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes,
8141 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
8142 ConversionSequenceList &Conversions, bool SuppressUserConversions,
8143 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
8144 Expr::Classification ObjectClassification = {},
8147 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
8148 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
8149 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
8150 bool AllowExplicit, bool AllowResultConversion = true);
8152 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
8153 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
8154 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
8155 bool AllowExplicit, bool AllowResultConversion = true);
8156 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
8157 DeclAccessPair FoundDecl,
8158 CXXRecordDecl *ActingContext,
8159 const FunctionProtoType *Proto, Expr *Object,
8160 ArrayRef<Expr *> Args,
8161 OverloadCandidateSet &CandidateSet);
8163 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
8164 OverloadCandidateSet &CandidateSet,
8165 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
8167 SourceLocation OpLoc, ArrayRef<Expr *> Args,
8168 OverloadCandidateSet &CandidateSet,
8170 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
8171 OverloadCandidateSet &CandidateSet,
8172 bool IsAssignmentOperator = false,
8173 unsigned NumContextualBoolArguments = 0);
8175 SourceLocation OpLoc, ArrayRef<Expr *> Args,
8176 OverloadCandidateSet &CandidateSet);
8178 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
8179 TemplateArgumentListInfo *ExplicitTemplateArgs,
8180 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
8181
8182 /// Check the enable_if expressions on the given function. Returns the first
8183 /// failing attribute, or NULL if they were all successful.
8184 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
8185 ArrayRef<Expr *> Args,
8186 bool MissingImplicitThis = false);
8187
8188 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
8189 /// non-ArgDependent DiagnoseIfAttrs.
8190 ///
8191 /// Argument-dependent diagnose_if attributes should be checked each time a
8192 /// function is used as a direct callee of a function call.
8193 ///
8194 /// Returns true if any errors were emitted.
8195 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
8196 const Expr *ThisArg,
8197 ArrayRef<const Expr *> Args,
8198 SourceLocation Loc);
8199
8200 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
8201 /// ArgDependent DiagnoseIfAttrs.
8202 ///
8203 /// Argument-independent diagnose_if attributes should be checked on every use
8204 /// of a function.
8205 ///
8206 /// Returns true if any errors were emitted.
8207 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
8208 SourceLocation Loc);
8209
8210 /// Determine if \p A and \p B are equivalent internal linkage declarations
8211 /// from different modules, and thus an ambiguity error can be downgraded to
8212 /// an extension warning.
8213 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
8214 const NamedDecl *B);
8216 SourceLocation Loc, const NamedDecl *D,
8217 ArrayRef<const NamedDecl *> Equiv);
8218
8219 // Emit as a 'note' the specific overload candidate
8221 const NamedDecl *Found, const FunctionDecl *Fn,
8223 QualType DestType = QualType(), bool TakingAddress = false);
8224
8225 // Emit as a series of 'note's all template and non-templates identified by
8226 // the expression Expr
8227 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
8228 bool TakingAddress = false);
8229
8230 /// Returns whether the given function's address can be taken or not,
8231 /// optionally emitting a diagnostic if the address can't be taken.
8232 ///
8233 /// Returns false if taking the address of the function is illegal.
8234 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
8235 bool Complain = false,
8236 SourceLocation Loc = SourceLocation());
8237
8238 // [PossiblyAFunctionType] --> [Return]
8239 // NonFunctionType --> NonFunctionType
8240 // R (A) --> R(A)
8241 // R (*)(A) --> R (A)
8242 // R (&)(A) --> R (A)
8243 // R (S::*)(A) --> R (A)
8244 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
8245
8246 FunctionDecl *
8247 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
8248 bool Complain, DeclAccessPair &Found,
8249 bool *pHadMultipleCandidates = nullptr);
8250
8251 FunctionDecl *
8252 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
8253
8255 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
8256
8258 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
8259 TemplateSpecCandidateSet *FailedTSC = nullptr);
8260
8262 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
8263 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
8264 QualType DestTypeForComplaining = QualType(),
8265 unsigned DiagIDForComplaining = 0);
8266
8267 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
8268 ArrayRef<Expr *> Args,
8269 OverloadCandidateSet &CandidateSet,
8270 bool PartialOverloading = false);
8272 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
8273 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
8274
8275 // An enum used to represent the different possible results of building a
8276 // range-based for loop.
8282
8284 SourceLocation RangeLoc,
8285 const DeclarationNameInfo &NameInfo,
8286 LookupResult &MemberLookup,
8287 OverloadCandidateSet *CandidateSet,
8289
8291 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
8292 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
8293 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
8294
8296 MultiExprArg Args, SourceLocation RParenLoc,
8297 OverloadCandidateSet *CandidateSet,
8299
8303 const UnresolvedSetImpl &Fns,
8304 bool PerformADL = true);
8305
8308 const UnresolvedSetImpl &Fns, Expr *input,
8309 bool RequiresADL = true);
8310
8313 const UnresolvedSetImpl &Fns,
8314 ArrayRef<Expr *> Args, bool RequiresADL = true);
8316 const UnresolvedSetImpl &Fns, Expr *LHS,
8317 Expr *RHS, bool RequiresADL = true,
8318 bool AllowRewrittenCandidates = true,
8319 FunctionDecl *DefaultedFn = nullptr);
8321 const UnresolvedSetImpl &Fns,
8322 Expr *LHS, Expr *RHS,
8323 FunctionDecl *DefaultedFn);
8324
8326 SourceLocation RLoc, Expr *Base,
8327 MultiExprArg Args);
8328
8330 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
8331 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
8332 bool IsExecConfig = false, bool AllowRecovery = false);
8334 SourceLocation LParenLoc,
8335 MultiExprArg Args,
8336 SourceLocation RParenLoc);
8337
8339 SourceLocation OpLoc,
8340 bool *NoArrowOperatorFound = nullptr);
8341
8343 CXXConversionDecl *Method,
8344 bool HadMultipleCandidates);
8345
8348 SourceLocation LitEndLoc,
8349 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
8350
8352 FunctionDecl *Fn);
8354 DeclAccessPair FoundDecl,
8355 FunctionDecl *Fn);
8356
8357 /// - Returns a selector which best matches given argument list or
8358 /// nullptr if none could be found
8360 bool IsInstance,
8362
8363 ///@}
8364
8365 //
8366 //
8367 // -------------------------------------------------------------------------
8368 //
8369 //
8370
8371 /// \name Pseudo-Object
8372 /// Implementations are in SemaPseudoObject.cpp
8373 ///@{
8374
8375public:
8377
8379 UnaryOperatorKind Opcode, Expr *Op);
8381 BinaryOperatorKind Opcode, Expr *LHS,
8382 Expr *RHS);
8385
8386 ///@}
8387
8388 //
8389 //
8390 // -------------------------------------------------------------------------
8391 //
8392 //
8393
8394 /// \name Statements
8395 /// Implementations are in SemaStmt.cpp
8396 ///@{
8397
8398public:
8399 /// Stack of active SEH __finally scopes. Can be empty.
8401
8402 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
8404
8406 bool HasLeadingEmptyMacro = false);
8407
8409 SourceLocation EndLoc);
8411
8412 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
8413 /// whose result is unused, warn.
8414 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
8415
8416 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
8420 ArrayRef<Stmt *> Elts, bool isStmtExpr);
8421
8423
8426 SourceLocation DotDotDotLoc, ExprResult RHS,
8427 SourceLocation ColonLoc);
8428 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
8429
8431 SourceLocation ColonLoc, Stmt *SubStmt,
8432 Scope *CurScope);
8434 SourceLocation ColonLoc, Stmt *SubStmt);
8435
8437 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
8439 Stmt *SubStmt);
8440
8441 /// Check whether the given statement can have musttail applied to it,
8442 /// issuing a diagnostic and returning false if not. In the success case,
8443 /// the statement is rewritten to remove implicit nodes from the return
8444 /// value.
8445 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
8446
8448 SourceLocation LParenLoc, Stmt *InitStmt,
8449 ConditionResult Cond, SourceLocation RParenLoc,
8450 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
8452 SourceLocation LParenLoc, Stmt *InitStmt,
8453 ConditionResult Cond, SourceLocation RParenLoc,
8454 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
8455
8457
8459 SourceLocation LParenLoc, Stmt *InitStmt,
8460 ConditionResult Cond,
8461 SourceLocation RParenLoc);
8463 Stmt *Body);
8464
8465 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
8466 /// integer not in the range of enum values.
8467 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
8468 Expr *SrcExpr);
8469
8471 ConditionResult Cond, SourceLocation RParenLoc,
8472 Stmt *Body);
8474 SourceLocation WhileLoc, SourceLocation CondLParen,
8475 Expr *Cond, SourceLocation CondRParen);
8476
8478 Stmt *First, ConditionResult Second,
8479 FullExprArg Third, SourceLocation RParenLoc,
8480 Stmt *Body);
8481
8483
8485 /// Initial building of a for-range statement.
8487 /// Instantiation or recovery rebuild of a for-range statement. Don't
8488 /// attempt any typo-correction.
8490 /// Determining whether a for-range statement could be built. Avoid any
8491 /// unnecessary or irreversible actions.
8494
8496 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
8497 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
8498 SourceLocation RParenLoc, BuildForRangeKind Kind,
8499 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
8501 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
8502 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
8503 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
8504 BuildForRangeKind Kind,
8505 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
8506 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
8507
8508 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
8509 LabelDecl *TheDecl);
8510 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
8511 SourceLocation StarLoc, Expr *DestExp);
8512 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
8513 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
8514
8517
8518 enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
8520
8521 bool isMoveEligible() const { return S != None; };
8522 bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
8523 };
8525 NamedReturnInfo getNamedReturnInfo(
8527 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
8528 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
8529 QualType ReturnType);
8530
8533 const NamedReturnInfo &NRInfo, Expr *Value,
8534 bool SupressSimplerImplicitMoves = false);
8535
8537
8539 SourceLocation ReturnLoc, Expr *RetExpr,
8540 const AutoType *AT);
8541
8542 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
8543 Scope *CurScope);
8544 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
8545 bool AllowRecovery = false);
8547 NamedReturnInfo &NRInfo,
8548 bool SupressSimplerImplicitMoves);
8549
8551 Stmt *HandlerBlock);
8553 ArrayRef<Stmt *> Handlers);
8554
8555 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
8556 SourceLocation TryLoc, Stmt *TryBlock,
8557 Stmt *Handler);
8559 Stmt *Block);
8564
8566 bool IsIfExists,
8567 NestedNameSpecifierLoc QualifierLoc,
8568 DeclarationNameInfo NameInfo,
8569 Stmt *Nested);
8571 bool IsIfExists, CXXScopeSpec &SS,
8572 UnqualifiedId &Name, Stmt *Nested);
8573
8575 CapturedRegionKind Kind, unsigned NumParams);
8576 typedef std::pair<StringRef, QualType> CapturedParamNameType;
8578 CapturedRegionKind Kind,
8580 unsigned OpenMPCaptureLevel = 0);
8585 unsigned NumParams);
8586
8587private:
8588 /// Check whether the given statement can have musttail applied to it,
8589 /// issuing a diagnostic and returning false if not.
8590 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
8591
8592 /// Check if the given expression contains 'break' or 'continue'
8593 /// statement that produces control flow different from GCC.
8594 void CheckBreakContinueBinding(Expr *E);
8595
8596 ///@}
8597
8598 //
8599 //
8600 // -------------------------------------------------------------------------
8601 //
8602 //
8603
8604 /// \name `inline asm` Statement
8605 /// Implementations are in SemaStmtAsm.cpp
8606 ///@{
8607
8608public:
8609 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
8610 bool IsVolatile, unsigned NumOutputs,
8611 unsigned NumInputs, IdentifierInfo **Names,
8612 MultiExprArg Constraints, MultiExprArg Exprs,
8613 Expr *AsmString, MultiExprArg Clobbers,
8614 unsigned NumLabels, SourceLocation RParenLoc);
8615
8617 llvm::InlineAsmIdentifierInfo &Info);
8619 SourceLocation TemplateKWLoc,
8621 bool IsUnevaluatedContext);
8622 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
8623 SourceLocation AsmLoc);
8625 SourceLocation AsmLoc);
8627 ArrayRef<Token> AsmToks, StringRef AsmString,
8628 unsigned NumOutputs, unsigned NumInputs,
8629 ArrayRef<StringRef> Constraints,
8630 ArrayRef<StringRef> Clobbers,
8631 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
8632 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
8633 SourceLocation Location, bool AlwaysCreate);
8634
8635 ///@}
8636
8637 //
8638 //
8639 // -------------------------------------------------------------------------
8640 //
8641 //
8642
8643 /// \name Statement Attribute Handling
8644 /// Implementations are in SemaStmtAttr.cpp
8645 ///@{
8646
8647public:
8648 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
8649 const AttributeCommonInfo &A);
8650 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
8651 const AttributeCommonInfo &A);
8652
8653 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
8655
8656 /// Process the attributes before creating an attributed statement. Returns
8657 /// the semantic attributes that have been processed.
8658 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
8660
8664 const IdentifierInfo *AttrName,
8666
8667 ///@}
8668
8669 //
8670 //
8671 // -------------------------------------------------------------------------
8672 //
8673 //
8674
8675 /// \name C++ Templates
8676 /// Implementations are in SemaTemplate.cpp
8677 ///@{
8678
8679public:
8680 // Saves the current floating-point pragma stack and clear it in this Sema.
8682 public:
8684 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
8685 S.FpPragmaStack.Stack.clear();
8686 }
8687 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
8688
8689 private:
8690 Sema &S;
8692 };
8693
8695 CurFPFeatures = FPO;
8696 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
8697 }
8698
8700 return llvm::ArrayRef(InventedParameterInfos.begin() +
8703 }
8704
8705 /// The number of SFINAE diagnostics that have been trapped.
8707
8710 FunctionScopes.end());
8711 }
8712
8713 typedef llvm::MapVector<const FunctionDecl *,
8714 std::unique_ptr<LateParsedTemplate>>
8717
8718 /// Determine the number of levels of enclosing template parameters. This is
8719 /// only usable while parsing. Note that this does not include dependent
8720 /// contexts in which no template parameters have yet been declared, such as
8721 /// in a terse function template or generic lambda before the first 'auto' is
8722 /// encountered.
8723 unsigned getTemplateDepth(Scope *S) const;
8724
8726 bool AllowFunctionTemplates = true,
8727 bool AllowDependent = true);
8729 bool AllowFunctionTemplates = true,
8730 bool AllowDependent = true,
8731 bool AllowNonTemplateFunctions = false);
8732 /// Try to interpret the lookup result D as a template-name.
8733 ///
8734 /// \param D A declaration found by name lookup.
8735 /// \param AllowFunctionTemplates Whether function templates should be
8736 /// considered valid results.
8737 /// \param AllowDependent Whether unresolved using declarations (that might
8738 /// name templates) should be considered valid results.
8740 bool AllowFunctionTemplates = true,
8741 bool AllowDependent = true);
8742
8744 /// Whether and why a template name is required in this lookup.
8746 public:
8747 /// Template name is required if TemplateKWLoc is valid.
8749 : TemplateKW(TemplateKWLoc) {}
8750 /// Template name is unconditionally required.
8752
8754 return TemplateKW.value_or(SourceLocation());
8755 }
8756 bool hasTemplateKeyword() const {
8757 return getTemplateKeywordLoc().isValid();
8758 }
8759 bool isRequired() const { return TemplateKW != SourceLocation(); }
8760 explicit operator bool() const { return isRequired(); }
8761
8762 private:
8763 std::optional<SourceLocation> TemplateKW;
8764 };
8765
8767 /// This is not assumed to be a template name.
8768 None,
8769 /// This is assumed to be a template name because lookup found nothing.
8771 /// This is assumed to be a template name because lookup found one or more
8772 /// functions (but no function templates).
8774 };
8775
8776 bool
8778 QualType ObjectType, bool EnteringContext,
8779 RequiredTemplateKind RequiredTemplate = SourceLocation(),
8780 AssumedTemplateKind *ATK = nullptr,
8781 bool AllowTypoCorrection = true);
8782
8784 bool hasTemplateKeyword,
8785 const UnqualifiedId &Name,
8786 ParsedType ObjectType, bool EnteringContext,
8787 TemplateTy &Template,
8788 bool &MemberOfUnknownSpecialization,
8789 bool Disambiguation = false);
8790
8791 /// Try to resolve an undeclared template name as a type template.
8792 ///
8793 /// Sets II to the identifier corresponding to the template name, and updates
8794 /// Name to a corresponding (typo-corrected) type template name and TNK to
8795 /// the corresponding kind, if possible.
8797 TemplateNameKind &TNK,
8798 SourceLocation NameLoc,
8799 IdentifierInfo *&II);
8800
8802 SourceLocation NameLoc,
8803 bool Diagnose = true);
8804
8805 /// Determine whether a particular identifier might be the name in a C++1z
8806 /// deduction-guide declaration.
8807 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
8808 SourceLocation NameLoc, CXXScopeSpec &SS,
8809 ParsedTemplateTy *Template = nullptr);
8810
8812 SourceLocation IILoc, Scope *S,
8813 const CXXScopeSpec *SS,
8814 TemplateTy &SuggestedTemplate,
8815 TemplateNameKind &SuggestedKind);
8816
8817 bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
8818 NamedDecl *Instantiation,
8819 bool InstantiatedFromMember,
8820 const NamedDecl *Pattern,
8821 const NamedDecl *PatternDef,
8823 bool Complain = true);
8824
8825 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
8826 /// that the template parameter 'PrevDecl' is being shadowed by a new
8827 /// declaration at location Loc. Returns true to indicate that this is
8828 /// an error, and false otherwise.
8829 ///
8830 /// \param Loc The location of the declaration that shadows a template
8831 /// parameter.
8832 ///
8833 /// \param PrevDecl The template parameter that the declaration shadows.
8834 ///
8835 /// \param SupportedForCompatibility Whether to issue the diagnostic as
8836 /// a warning for compatibility with older versions of clang.
8837 /// Ignored when MSVC compatibility is enabled.
8839 bool SupportedForCompatibility = false);
8841
8843 SourceLocation EllipsisLoc,
8844 SourceLocation KeyLoc,
8845 IdentifierInfo *ParamName,
8846 SourceLocation ParamNameLoc, unsigned Depth,
8847 unsigned Position, SourceLocation EqualLoc,
8848 ParsedType DefaultArg, bool HasTypeConstraint);
8849
8851
8852 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
8854 TemplateTypeParmDecl *ConstrainedParameter,
8855 SourceLocation EllipsisLoc);
8856 bool BuildTypeConstraint(const CXXScopeSpec &SS,
8858 TemplateTypeParmDecl *ConstrainedParameter,
8859 SourceLocation EllipsisLoc,
8860 bool AllowUnexpandedPack);
8861
8863 DeclarationNameInfo NameInfo,
8864 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
8865 const TemplateArgumentListInfo *TemplateArgs,
8866 TemplateTypeParmDecl *ConstrainedParameter,
8867 SourceLocation EllipsisLoc);
8868
8870 NonTypeTemplateParmDecl *NewConstrainedParm,
8871 NonTypeTemplateParmDecl *OrigConstrainedParm,
8872 SourceLocation EllipsisLoc);
8873
8875
8879
8881 unsigned Depth, unsigned Position,
8882 SourceLocation EqualLoc,
8883 Expr *DefaultArg);
8885 Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params,
8886 bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
8887 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
8888 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
8889
8891 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
8892 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
8893 SourceLocation RAngleLoc, Expr *RequiresClause);
8894
8895 /// The context in which we are checking a template parameter list.
8906
8908 TemplateParameterList *OldParams,
8910 SkipBodyInfo *SkipBody = nullptr);
8912 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
8913 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
8914 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
8915 bool &IsMemberSpecialization, bool &Invalid,
8916 bool SuppressDiagnostic = false);
8917
8919 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
8920 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
8921 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
8922 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
8923 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
8924 TemplateParameterList **OuterTemplateParamLists,
8925 SkipBodyInfo *SkipBody = nullptr);
8926
8929
8931
8933
8935 SourceLocation TemplateLoc,
8936 TemplateArgumentListInfo &TemplateArgs);
8937
8940 TemplateTy Template, const IdentifierInfo *TemplateII,
8941 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
8942 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
8943 bool IsCtorOrDtorName = false, bool IsClassName = false,
8944 ImplicitTypenameContext AllowImplicitTypename =
8946
8947 /// Parsed an elaborated-type-specifier that refers to a template-id,
8948 /// such as \c class T::template apply<U>.
8950 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
8951 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
8952 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
8953 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
8954
8957 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
8959
8960 /// Get the specialization of the given variable template corresponding to
8961 /// the specified argument list, or a null-but-valid result if the arguments
8962 /// are dependent.
8964 SourceLocation TemplateLoc,
8965 SourceLocation TemplateNameLoc,
8966 const TemplateArgumentListInfo &TemplateArgs);
8967
8968 /// Form a reference to the specialization of the given variable template
8969 /// corresponding to the specified argument list, or a null-but-valid result
8970 /// if the arguments are dependent.
8972 const DeclarationNameInfo &NameInfo,
8973 VarTemplateDecl *Template, NamedDecl *FoundD,
8974 SourceLocation TemplateLoc,
8975 const TemplateArgumentListInfo *TemplateArgs);
8976
8978 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8979 const DeclarationNameInfo &ConceptNameInfo,
8980 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
8981 const TemplateArgumentListInfo *TemplateArgs);
8982
8984
8986 SourceLocation TemplateKWLoc, LookupResult &R,
8987 bool RequiresADL,
8988 const TemplateArgumentListInfo *TemplateArgs);
8989
8992 const DeclarationNameInfo &NameInfo,
8993 const TemplateArgumentListInfo *TemplateArgs);
8994
8996 SourceLocation TemplateKWLoc,
8997 const UnqualifiedId &Name,
8998 ParsedType ObjectType,
8999 bool EnteringContext, TemplateTy &Template,
9000 bool AllowInjectedClassName = false);
9001
9003 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
9004 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
9006 MultiTemplateParamsArg TemplateParameterLists,
9007 SkipBodyInfo *SkipBody = nullptr);
9008
9010 TemplateDecl *PrimaryTemplate,
9011 unsigned NumExplicitArgs,
9017
9019 MultiTemplateParamsArg TemplateParameterLists,
9020 Declarator &D);
9021
9023 SourceLocation NewLoc,
9024 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
9025 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
9026 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
9027
9029 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
9031
9033 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
9034 LookupResult &Previous, bool QualifiedFriend = false);
9037
9039 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
9040 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
9041 TemplateTy Template, SourceLocation TemplateNameLoc,
9042 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
9043 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
9044
9046 SourceLocation TemplateLoc,
9047 unsigned TagSpec, SourceLocation KWLoc,
9048 CXXScopeSpec &SS, IdentifierInfo *Name,
9049 SourceLocation NameLoc,
9050 const ParsedAttributesView &Attr);
9051
9053 SourceLocation TemplateLoc,
9054 Declarator &D);
9055
9057 TemplateDecl *Template, SourceLocation TemplateLoc,
9058 SourceLocation RAngleLoc, Decl *Param,
9059 ArrayRef<TemplateArgument> SugaredConverted,
9060 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
9061
9063
9064 /// Specifies the context in which a particular template
9065 /// argument is being checked.
9067 /// The template argument was specified in the code or was
9068 /// instantiated with some deduced template arguments.
9070
9071 /// The template argument was deduced via template argument
9072 /// deduction.
9074
9075 /// The template argument was deduced from an array bound
9076 /// via template argument deduction.
9079
9080 bool
9082 NamedDecl *Template, SourceLocation TemplateLoc,
9083 SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
9084 SmallVectorImpl<TemplateArgument> &SugaredConverted,
9085 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
9087
9088 /// Check that the given template arguments can be provided to
9089 /// the given template, converting the arguments along the way.
9090 ///
9091 /// \param Template The template to which the template arguments are being
9092 /// provided.
9093 ///
9094 /// \param TemplateLoc The location of the template name in the source.
9095 ///
9096 /// \param TemplateArgs The list of template arguments. If the template is
9097 /// a template template parameter, this function may extend the set of
9098 /// template arguments to also include substituted, defaulted template
9099 /// arguments.
9100 ///
9101 /// \param PartialTemplateArgs True if the list of template arguments is
9102 /// intentionally partial, e.g., because we're checking just the initial
9103 /// set of template arguments.
9104 ///
9105 /// \param Converted Will receive the converted, canonicalized template
9106 /// arguments.
9107 ///
9108 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
9109 /// contain the converted forms of the template arguments as written.
9110 /// Otherwise, \p TemplateArgs will not be modified.
9111 ///
9112 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
9113 /// receive true if the cause for the error is the associated constraints of
9114 /// the template not being satisfied by the template arguments.
9115 ///
9116 /// \param PartialOrderingTTP If true, assume these template arguments are
9117 /// the injected template arguments for a template template parameter.
9118 /// This will relax the requirement that all its possible uses are valid:
9119 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
9120 /// during instantiation.
9121 ///
9122 /// \returns true if an error occurred, false otherwise.
9124 TemplateDecl *Template, SourceLocation TemplateLoc,
9125 TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs,
9126 SmallVectorImpl<TemplateArgument> &SugaredConverted,
9127 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
9128 bool UpdateArgsWithConversions = true,
9129 bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false);
9130
9133 SmallVectorImpl<TemplateArgument> &SugaredConverted,
9134 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
9135
9138 QualType InstantiatedParamType, Expr *Arg,
9139 TemplateArgument &SugaredConverted,
9140 TemplateArgument &CanonicalConverted,
9143 TemplateParameterList *Params,
9144 TemplateArgumentLoc &Arg, bool IsDeduced);
9145
9147 std::optional<SourceRange> ParamRange = {});
9148 void NoteTemplateParameterLocation(const NamedDecl &Decl);
9149
9151 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
9152 NamedDecl *TemplateParam = nullptr);
9154 BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg,
9155 SourceLocation Loc);
9156
9157 /// Enumeration describing how template parameter lists are compared
9158 /// for equality.
9160 /// We are matching the template parameter lists of two templates
9161 /// that might be redeclarations.
9162 ///
9163 /// \code
9164 /// template<typename T> struct X;
9165 /// template<typename T> struct X;
9166 /// \endcode
9168
9169 /// We are matching the template parameter lists of two template
9170 /// template parameters as part of matching the template parameter lists
9171 /// of two templates that might be redeclarations.
9172 ///
9173 /// \code
9174 /// template<template<int I> class TT> struct X;
9175 /// template<template<int Value> class Other> struct X;
9176 /// \endcode
9178
9179 /// We are matching the template parameter lists of a template
9180 /// template argument against the template parameter lists of a template
9181 /// template parameter.
9182 ///
9183 /// \code
9184 /// template<template<int Value> class Metafun> struct X;
9185 /// template<int Value> struct integer_c;
9186 /// X<integer_c> xic;
9187 /// \endcode
9189
9190 /// We are determining whether the template-parameters are equivalent
9191 /// according to C++ [temp.over.link]/6. This comparison does not consider
9192 /// constraints.
9193 ///
9194 /// \code
9195 /// template<C1 T> void f(T);
9196 /// template<C2 T> void f(T);
9197 /// \endcode
9199 };
9200
9201 // A struct to represent the 'new' declaration, which is either itself just
9202 // the named decl, or the important information we need about it in order to
9203 // do constraint comparisons.
9205 const NamedDecl *ND = nullptr;
9206 const DeclContext *DC = nullptr;
9207 const DeclContext *LexicalDC = nullptr;
9209
9210 public:
9213 const DeclContext *LexicalDeclCtx,
9215
9216 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
9217 assert(DC && LexicalDC &&
9218 "Constructor only for cases where we have the information to put "
9219 "in here");
9220 }
9221
9222 // If this was constructed with no information, we cannot do substitution
9223 // for constraint comparison, so make sure we can check that.
9224 bool isInvalid() const { return !ND && !DC; }
9225
9226 const NamedDecl *getDecl() const { return ND; }
9227
9228 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
9229
9231 return ND ? ND->getLexicalDeclContext() : LexicalDC;
9232 }
9233
9235 return ND ? ND->getDeclContext() : DC;
9236 }
9237
9238 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
9239 };
9240
9242 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
9243 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
9245 SourceLocation TemplateArgLoc = SourceLocation());
9246
9248 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
9250 SourceLocation TemplateArgLoc = SourceLocation()) {
9251 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
9252 Kind, TemplateArgLoc);
9253 }
9254
9255 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
9256
9257 /// Called when the parser has parsed a C++ typename
9258 /// specifier, e.g., "typename T::type".
9259 ///
9260 /// \param S The scope in which this typename type occurs.
9261 /// \param TypenameLoc the location of the 'typename' keyword
9262 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
9263 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
9264 /// \param IdLoc the location of the identifier.
9265 /// \param IsImplicitTypename context where T::type refers to a type.
9267 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
9268 const IdentifierInfo &II, SourceLocation IdLoc,
9270
9271 /// Called when the parser has parsed a C++ typename
9272 /// specifier that ends in a template-id, e.g.,
9273 /// "typename MetaFun::template apply<T1, T2>".
9274 ///
9275 /// \param S The scope in which this typename type occurs.
9276 /// \param TypenameLoc the location of the 'typename' keyword
9277 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
9278 /// \param TemplateLoc the location of the 'template' keyword, if any.
9279 /// \param TemplateName The template name.
9280 /// \param TemplateII The identifier used to name the template.
9281 /// \param TemplateIILoc The location of the template name.
9282 /// \param LAngleLoc The location of the opening angle bracket ('<').
9283 /// \param TemplateArgs The template arguments.
9284 /// \param RAngleLoc The location of the closing angle bracket ('>').
9286 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
9287 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
9288 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
9289 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
9290 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
9291
9293 SourceLocation KeywordLoc,
9294 NestedNameSpecifierLoc QualifierLoc,
9295 const IdentifierInfo &II, SourceLocation IILoc,
9296 TypeSourceInfo **TSI, bool DeducedTSTContext);
9297
9299 SourceLocation KeywordLoc,
9300 NestedNameSpecifierLoc QualifierLoc,
9301 const IdentifierInfo &II, SourceLocation IILoc,
9302 bool DeducedTSTContext = true);
9303
9306 DeclarationName Name);
9308
9310 bool
9312
9313 std::string
9315 const TemplateArgumentList &Args);
9316
9317 std::string
9319 const TemplateArgument *Args,
9320 unsigned NumArgs);
9321
9325
9327 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9328 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
9329 const TemplateArgumentListInfo *TemplateArgs);
9330
9333 SourceLocation TemplateKWLoc,
9334 const DeclarationNameInfo &NameInfo,
9335 const TemplateArgumentListInfo *TemplateArgs);
9336
9337 // Calculates whether the expression Constraint depends on an enclosing
9338 // template, for the purposes of [temp.friend] p9.
9339 // TemplateDepth is the 'depth' of the friend function, which is used to
9340 // compare whether a declaration reference is referring to a containing
9341 // template, or just the current friend function. A 'lower' TemplateDepth in
9342 // the AST refers to a 'containing' template. As the constraint is
9343 // uninstantiated, this is relative to the 'top' of the TU.
9344 bool
9346 unsigned TemplateDepth,
9347 const Expr *Constraint);
9348
9349 /// Declare implicit deduction guides for a class template if we've
9350 /// not already done so.
9353
9355 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
9357
9358 /// Find the failed Boolean condition within a given Boolean
9359 /// constant expression, and describe it with a string.
9360 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
9361
9363
9365 MultiTemplateParamsArg TemplateParameterLists,
9366 const IdentifierInfo *Name,
9367 SourceLocation NameLoc, Expr *ConstraintExpr,
9368 const ParsedAttributesView &Attrs);
9369
9371 bool &AddToScope);
9372
9373 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
9374 const CXXScopeSpec &SS,
9375 const IdentifierInfo *Name,
9376 SourceLocation TagLoc, SourceLocation NameLoc);
9377
9379 CachedTokens &Toks);
9382
9383 /// We've found a use of a templated declaration that would trigger an
9384 /// implicit instantiation. Check that any relevant explicit specializations
9385 /// and partial specializations are visible/reachable, and diagnose if not.
9388
9389 ///@}
9390
9391 //
9392 //
9393 // -------------------------------------------------------------------------
9394 //
9395 //
9396
9397 /// \name C++ Template Argument Deduction
9398 /// Implementations are in SemaTemplateDeduction.cpp
9399 ///@{
9400
9401public:
9402 /// When true, access checking violations are treated as SFINAE
9403 /// failures rather than hard errors.
9405
9406 /// RAII class used to determine whether SFINAE has
9407 /// trapped any errors that occur during template argument
9408 /// deduction.
9410 Sema &SemaRef;
9411 unsigned PrevSFINAEErrors;
9412 bool PrevInNonInstantiationSFINAEContext;
9413 bool PrevAccessCheckingSFINAE;
9414 bool PrevLastDiagnosticIgnored;
9415
9416 public:
9417 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
9418 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
9419 PrevInNonInstantiationSFINAEContext(
9420 SemaRef.InNonInstantiationSFINAEContext),
9421 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
9422 PrevLastDiagnosticIgnored(
9423 SemaRef.getDiagnostics().isLastDiagnosticIgnored()) {
9424 if (!SemaRef.isSFINAEContext())
9425 SemaRef.InNonInstantiationSFINAEContext = true;
9426 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
9427 }
9428
9430 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
9432 PrevInNonInstantiationSFINAEContext;
9433 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
9435 PrevLastDiagnosticIgnored);
9436 }
9437
9438 /// Determine whether any SFINAE errors have been trapped.
9439 bool hasErrorOccurred() const {
9440 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
9441 }
9442 };
9443
9444 /// RAII class used to indicate that we are performing provisional
9445 /// semantic analysis to determine the validity of a construct, so
9446 /// typo-correction and diagnostics in the immediate context (not within
9447 /// implicitly-instantiated templates) should be suppressed.
9449 Sema &SemaRef;
9450 // FIXME: Using a SFINAETrap for this is a hack.
9451 SFINAETrap Trap;
9452 bool PrevDisableTypoCorrection;
9453
9454 public:
9455 explicit TentativeAnalysisScope(Sema &SemaRef)
9456 : SemaRef(SemaRef), Trap(SemaRef, true),
9457 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
9458 SemaRef.DisableTypoCorrection = true;
9459 }
9461 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
9462 }
9463 };
9464
9465 /// For each declaration that involved template argument deduction, the
9466 /// set of diagnostics that were suppressed during that template argument
9467 /// deduction.
9468 ///
9469 /// FIXME: Serialize this structure to the AST file.
9470 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
9473
9475
9479 NamedDecl *TemplateParam = nullptr);
9480
9481 /// Get a template argument mapping the given template parameter to itself,
9482 /// e.g. for X in \c template<int X>, this would return an expression template
9483 /// argument referencing X.
9485 SourceLocation Location);
9486
9487 /// Adjust the type \p ArgFunctionType to match the calling convention,
9488 /// noreturn, and optionally the exception specification of \p FunctionType.
9489 /// Deduction often wants to ignore these properties when matching function
9490 /// types.
9492 bool AdjustExceptionSpec = false);
9493
9496 ArrayRef<TemplateArgument> TemplateArgs,
9498
9501 ArrayRef<TemplateArgument> TemplateArgs,
9503
9504 /// Deduce the template arguments of the given template from \p FromType.
9505 /// Used to implement the IsDeducible constraint for alias CTAD per C++
9506 /// [over.match.class.deduct]p4.
9507 ///
9508 /// It only supports class or type alias templates.
9512
9517 bool NumberOfArgumentsMustMatch);
9518
9521 TemplateArgumentListInfo &ExplicitTemplateArgs,
9525
9526 /// brief A function argument from which we performed template argument
9527 // deduction for a call.
9529 OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
9530 unsigned ArgIdx, QualType OriginalArgType)
9531 : OriginalParamType(OriginalParamType),
9532 DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
9533 OriginalArgType(OriginalArgType) {}
9534
9537 unsigned ArgIdx;
9539 };
9540
9544 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
9546 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
9547 bool PartialOverloading = false,
9548 llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
9549
9552 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
9554 bool PartialOverloading, bool AggregateDeductionCandidate,
9555 QualType ObjectType, Expr::Classification ObjectClassification,
9556 llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
9557
9560 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
9562 bool IsAddressOfFunction = false);
9563
9566 Expr::Classification ObjectClassification, QualType ToType,
9568
9571 TemplateArgumentListInfo *ExplicitTemplateArgs,
9574 bool IsAddressOfFunction = false);
9575
9576 /// Substitute Replacement for \p auto in \p TypeWithAuto
9577 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
9578 /// Substitute Replacement for auto in TypeWithAuto
9580 QualType Replacement);
9581
9582 // Substitute auto in TypeWithAuto for a Dependent auto type
9584
9585 // Substitute auto in TypeWithAuto for a Dependent auto type
9588
9589 /// Completely replace the \c auto in \p TypeWithAuto by
9590 /// \p Replacement. This does not retain any \c auto type sugar.
9591 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
9593 QualType Replacement);
9594
9598 bool DependentDeduction = false,
9599 bool IgnoreConstraints = false,
9600 TemplateSpecCandidateSet *FailedTSC = nullptr);
9603 bool Diagnose = true);
9604
9607
9612
9615
9619
9622
9625 bool IsDeduced);
9626
9627 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
9628 unsigned Depth, llvm::SmallBitVector &Used);
9629
9630 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
9631 bool OnlyDeduced, unsigned Depth,
9632 llvm::SmallBitVector &Used);
9633 void
9635 llvm::SmallBitVector &Deduced) {
9637 }
9638 static void
9641 llvm::SmallBitVector &Deduced);
9642
9645 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
9646 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false);
9647
9648 UnresolvedSetIterator
9649 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
9650 TemplateSpecCandidateSet &FailedCandidates,
9651 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
9652 const PartialDiagnostic &AmbigDiag,
9653 const PartialDiagnostic &CandidateDiag,
9654 bool Complain = true, QualType TargetType = QualType());
9655
9656 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
9657 FunctionDecl *FD2);
9658
9659 ///@}
9660
9661 //
9662 //
9663 // -------------------------------------------------------------------------
9664 //
9665 //
9666
9667 /// \name C++ Template Instantiation
9668 /// Implementations are in SemaTemplateInstantiate.cpp
9669 ///@{
9670
9671public:
9672 /// A helper class for building up ExtParameterInfos.
9675 bool HasInteresting = false;
9676
9677 public:
9678 /// Set the ExtParameterInfo for the parameter at the given index,
9679 ///
9680 void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
9681 assert(Infos.size() <= index);
9682 Infos.resize(index);
9683 Infos.push_back(info);
9684
9685 if (!HasInteresting)
9686 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
9687 }
9688
9689 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
9690 /// ExtParameterInfo array we've built up.
9692 getPointerOrNull(unsigned numParams) {
9693 if (!HasInteresting)
9694 return nullptr;
9695 Infos.resize(numParams);
9696 return Infos.data();
9697 }
9698 };
9699
9700 /// The current instantiation scope used to store local
9701 /// variables.
9703
9704 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
9706
9707 /// A mapping from parameters with unparsed default arguments to the
9708 /// set of instantiations of each parameter.
9709 ///
9710 /// This mapping is a temporary data structure used when parsing
9711 /// nested class templates or nested classes of class templates,
9712 /// where we might end up instantiating an inner class before the
9713 /// default arguments of its methods have been parsed.
9715
9716 /// A context in which code is being synthesized (where a source location
9717 /// alone is not sufficient to identify the context). This covers template
9718 /// instantiation and various forms of implicitly-generated functions.
9720 /// The kind of template instantiation we are performing
9722 /// We are instantiating a template declaration. The entity is
9723 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
9725
9726 /// We are instantiating a default argument for a template
9727 /// parameter. The Entity is the template parameter whose argument is
9728 /// being instantiated, the Template is the template, and the
9729 /// TemplateArgs/NumTemplateArguments provide the template arguments as
9730 /// specified.
9732
9733 /// We are instantiating a default argument for a function.
9734 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
9735 /// provides the template arguments as specified.
9737
9738 /// We are substituting explicit template arguments provided for
9739 /// a function template. The entity is a FunctionTemplateDecl.
9741
9742 /// We are substituting template argument determined as part of
9743 /// template argument deduction for either a class template
9744 /// partial specialization or a function template. The
9745 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
9746 /// a TemplateDecl.
9748
9749 /// We are substituting into a lambda expression.
9751
9752 /// We are substituting prior template arguments into a new
9753 /// template parameter. The template parameter itself is either a
9754 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
9756
9757 /// We are checking the validity of a default template argument that
9758 /// has been used when naming a template-id.
9760
9761 /// We are computing the exception specification for a defaulted special
9762 /// member function.
9764
9765 /// We are instantiating the exception specification for a function
9766 /// template which was deferred until it was needed.
9768
9769 /// We are instantiating a requirement of a requires expression.
9771
9772 /// We are checking the satisfaction of a nested requirement of a requires
9773 /// expression.
9775
9776 /// We are declaring an implicit special member function.
9778
9779 /// We are declaring an implicit 'operator==' for a defaulted
9780 /// 'operator<=>'.
9782
9783 /// We are defining a synthesized function (such as a defaulted special
9784 /// member).
9786
9787 // We are checking the constraints associated with a constrained entity or
9788 // the constraint expression of a concept. This includes the checks that
9789 // atomic constraints have the type 'bool' and that they can be constant
9790 // evaluated.
9792
9793 // We are substituting template arguments into a constraint expression.
9795
9796 // We are normalizing a constraint expression.
9798
9799 // Instantiating a Requires Expression parameter clause.
9801
9802 // We are substituting into the parameter mapping of an atomic constraint
9803 // during normalization.
9805
9806 /// We are rewriting a comparison operator in terms of an operator<=>.
9808
9809 /// We are initializing a structured binding.
9811
9812 /// We are marking a class as __dllexport.
9814
9815 /// We are building an implied call from __builtin_dump_struct. The
9816 /// arguments are in CallArgs.
9818
9819 /// Added for Template instantiation observation.
9820 /// Memoization means we are _not_ instantiating a template because
9821 /// it is already instantiated (but we entered a context where we
9822 /// would have had to if it was not already instantiated).
9824
9825 /// We are building deduction guides for a class.
9827
9828 /// We are instantiating a type alias template declaration.
9830 } Kind;
9831
9832 /// Was the enclosing context a non-instantiation SFINAE context?
9834
9835 /// The point of instantiation or synthesis within the source code.
9837
9838 /// The entity that is being synthesized.
9840
9841 /// The template (or partial specialization) in which we are
9842 /// performing the instantiation, for substitutions of prior template
9843 /// arguments.
9845
9846 union {
9847 /// The list of template arguments we are substituting, if they
9848 /// are not part of the entity.
9850
9851 /// The list of argument expressions in a synthesized call.
9852 const Expr *const *CallArgs;
9853 };
9854
9855 // FIXME: Wrap this union around more members, or perhaps store the
9856 // kind-specific members in the RAII object owning the context.
9857 union {
9858 /// The number of template arguments in TemplateArgs.
9860
9861 /// The number of expressions in CallArgs.
9862 unsigned NumCallArgs;
9863
9864 /// The special member being declared or defined.
9866 };
9867
9869 assert(Kind != DeclaringSpecialMember);
9870 return {TemplateArgs, NumTemplateArgs};
9871 }
9872
9873 /// The template deduction info object associated with the
9874 /// substitution or checking of explicit or deduced template arguments.
9876
9877 /// The source range that covers the construct that cause
9878 /// the instantiation, e.g., the template-id that causes a class
9879 /// template instantiation.
9881
9883 : Kind(TemplateInstantiation),
9884 SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
9885 Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
9886 DeductionInfo(nullptr) {}
9887
9888 /// Determines whether this template is an actual instantiation
9889 /// that should be counted toward the maximum instantiation depth.
9890 bool isInstantiationRecord() const;
9891 };
9892
9893 /// A stack object to be created when performing template
9894 /// instantiation.
9895 ///
9896 /// Construction of an object of type \c InstantiatingTemplate
9897 /// pushes the current instantiation onto the stack of active
9898 /// instantiations. If the size of this stack exceeds the maximum
9899 /// number of recursive template instantiations, construction
9900 /// produces an error and evaluates true.
9901 ///
9902 /// Destruction of this object will pop the named instantiation off
9903 /// the stack.
9905 /// Note that we are instantiating a class template,
9906 /// function template, variable template, alias template,
9907 /// or a member thereof.
9908 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9909 Decl *Entity,
9910 SourceRange InstantiationRange = SourceRange());
9911
9913 /// Note that we are instantiating an exception specification
9914 /// of a function template.
9915 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9917 SourceRange InstantiationRange = SourceRange());
9918
9919 /// Note that we are instantiating a type alias template declaration.
9920 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9921 TypeAliasTemplateDecl *Entity,
9922 ArrayRef<TemplateArgument> TemplateArgs,
9923 SourceRange InstantiationRange = SourceRange());
9924
9925 /// Note that we are instantiating a default argument in a
9926 /// template-id.
9927 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9928 TemplateParameter Param, TemplateDecl *Template,
9929 ArrayRef<TemplateArgument> TemplateArgs,
9930 SourceRange InstantiationRange = SourceRange());
9931
9932 /// Note that we are substituting either explicitly-specified or
9933 /// deduced template arguments during function template argument deduction.
9934 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9935 FunctionTemplateDecl *FunctionTemplate,
9936 ArrayRef<TemplateArgument> TemplateArgs,
9938 sema::TemplateDeductionInfo &DeductionInfo,
9939 SourceRange InstantiationRange = SourceRange());
9940
9941 /// Note that we are instantiating as part of template
9942 /// argument deduction for a class template declaration.
9943 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9944 TemplateDecl *Template,
9945 ArrayRef<TemplateArgument> TemplateArgs,
9946 sema::TemplateDeductionInfo &DeductionInfo,
9947 SourceRange InstantiationRange = SourceRange());
9948
9949 /// Note that we are instantiating as part of template
9950 /// argument deduction for a class template partial
9951 /// specialization.
9952 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9954 ArrayRef<TemplateArgument> TemplateArgs,
9955 sema::TemplateDeductionInfo &DeductionInfo,
9956 SourceRange InstantiationRange = SourceRange());
9957
9958 /// Note that we are instantiating as part of template
9959 /// argument deduction for a variable template partial
9960 /// specialization.
9961 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9963 ArrayRef<TemplateArgument> TemplateArgs,
9964 sema::TemplateDeductionInfo &DeductionInfo,
9965 SourceRange InstantiationRange = SourceRange());
9966
9967 /// Note that we are instantiating a default argument for a function
9968 /// parameter.
9969 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9970 ParmVarDecl *Param,
9971 ArrayRef<TemplateArgument> TemplateArgs,
9972 SourceRange InstantiationRange = SourceRange());
9973
9974 /// Note that we are substituting prior template arguments into a
9975 /// non-type parameter.
9976 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9977 NamedDecl *Template, NonTypeTemplateParmDecl *Param,
9978 ArrayRef<TemplateArgument> TemplateArgs,
9979 SourceRange InstantiationRange);
9980
9981 /// Note that we are substituting prior template arguments into a
9982 /// template template parameter.
9983 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9984 NamedDecl *Template, TemplateTemplateParmDecl *Param,
9985 ArrayRef<TemplateArgument> TemplateArgs,
9986 SourceRange InstantiationRange);
9987
9988 /// Note that we are checking the default template argument
9989 /// against the template parameter for a given template-id.
9990 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9991 TemplateDecl *Template, NamedDecl *Param,
9992 ArrayRef<TemplateArgument> TemplateArgs,
9993 SourceRange InstantiationRange);
9994
9996 /// \brief Note that we are checking the constraints associated with some
9997 /// constrained entity (a concept declaration or a template with associated
9998 /// constraints).
9999 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10000 ConstraintsCheck, NamedDecl *Template,
10001 ArrayRef<TemplateArgument> TemplateArgs,
10002 SourceRange InstantiationRange);
10003
10005 /// \brief Note that we are checking a constraint expression associated
10006 /// with a template declaration or as part of the satisfaction check of a
10007 /// concept.
10008 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10010 sema::TemplateDeductionInfo &DeductionInfo,
10011 SourceRange InstantiationRange);
10012
10014 /// \brief Note that we are normalizing a constraint expression.
10015 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10017 SourceRange InstantiationRange);
10018
10020 /// \brief Note that we are subtituting into the parameter mapping of an
10021 /// atomic constraint during constraint normalization.
10022 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10024 SourceRange InstantiationRange);
10025
10026 /// \brief Note that we are substituting template arguments into a part of
10027 /// a requirement of a requires expression.
10028 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10030 sema::TemplateDeductionInfo &DeductionInfo,
10031 SourceRange InstantiationRange = SourceRange());
10032
10033 /// \brief Note that we are checking the satisfaction of the constraint
10034 /// expression inside of a nested requirement.
10035 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10037 SourceRange InstantiationRange = SourceRange());
10038
10039 /// \brief Note that we are checking a requires clause.
10040 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10041 const RequiresExpr *E,
10042 sema::TemplateDeductionInfo &DeductionInfo,
10043 SourceRange InstantiationRange);
10044
10046 /// \brief Note that we are building deduction guides.
10047 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10049 SourceRange InstantiationRange = SourceRange());
10050
10051 /// Note that we have finished instantiating this template.
10052 void Clear();
10053
10055
10056 /// Determines whether we have exceeded the maximum
10057 /// recursive template instantiations.
10058 bool isInvalid() const { return Invalid; }
10059
10060 /// Determine whether we are already instantiating this
10061 /// specialization in some surrounding active instantiation.
10062 bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
10063
10064 private:
10065 Sema &SemaRef;
10066 bool Invalid;
10067 bool AlreadyInstantiating;
10068 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
10069 SourceRange InstantiationRange);
10070
10073 SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
10074 Decl *Entity, NamedDecl *Template = nullptr,
10075 ArrayRef<TemplateArgument> TemplateArgs = std::nullopt,
10076 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
10077
10079
10080 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
10081 };
10082
10084 const MultiLevelTemplateArgumentList &TemplateArgs,
10085 TemplateArgumentLoc &Output);
10086 bool
10088 const MultiLevelTemplateArgumentList &TemplateArgs,
10089 TemplateArgumentListInfo &Outputs);
10090
10092 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
10093 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
10094 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
10095 bool ForConstraintInstantiation = false,
10096 bool SkipForSpecialization = false);
10097
10098 /// RAII object to handle the state changes required to synthesize
10099 /// a function body.
10101 Sema &S;
10102 Sema::ContextRAII SavedContext;
10103 bool PushedCodeSynthesisContext = false;
10104
10105 public:
10107 : S(S), SavedContext(S, DC) {
10108 auto *FD = dyn_cast<FunctionDecl>(DC);
10109 S.PushFunctionScope();
10110 S.PushExpressionEvaluationContext(
10111 (FD && FD->isConsteval())
10112 ? ExpressionEvaluationContext::ImmediateFunctionContext
10113 : ExpressionEvaluationContext::PotentiallyEvaluated);
10114 if (FD) {
10115 FD->setWillHaveBody(true);
10116 S.ExprEvalContexts.back().InImmediateFunctionContext =
10117 FD->isImmediateFunction() ||
10118 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
10119 .isConstantEvaluated() ||
10120 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
10121 .isImmediateFunctionContext();
10122 S.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
10123 S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating();
10124 } else
10125 assert(isa<ObjCMethodDecl>(DC));
10126 }
10127
10129 assert(!PushedCodeSynthesisContext);
10130
10132 Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
10133 Ctx.PointOfInstantiation = UseLoc;
10134 Ctx.Entity = cast<Decl>(S.CurContext);
10135 S.pushCodeSynthesisContext(Ctx);
10136
10137 PushedCodeSynthesisContext = true;
10138 }
10139
10141 if (PushedCodeSynthesisContext)
10142 S.popCodeSynthesisContext();
10143 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
10144 FD->setWillHaveBody(false);
10145 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
10146 }
10147 S.PopExpressionEvaluationContext();
10148 S.PopFunctionScopeInfo();
10149 }
10150 };
10151
10152 /// List of active code synthesis contexts.
10153 ///
10154 /// This vector is treated as a stack. As synthesis of one entity requires
10155 /// synthesis of another, additional contexts are pushed onto the stack.
10157
10158 /// Specializations whose definitions are currently being instantiated.
10160
10161 /// Non-dependent types used in templates that have already been instantiated
10162 /// by some template instantiation.
10164
10165 /// Extra modules inspected when performing a lookup during a template
10166 /// instantiation. Computed lazily.
10168
10169 /// Cache of additional modules that should be used for name lookup
10170 /// within the current template instantiation. Computed lazily; use
10171 /// getLookupModules() to get a complete set.
10173
10174 /// Map from the most recent declaration of a namespace to the most
10175 /// recent visible declaration of that namespace.
10176 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
10177
10178 /// Whether we are in a SFINAE context that is not associated with
10179 /// template instantiation.
10180 ///
10181 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
10182 /// of a template instantiation or template argument deduction.
10184
10185 /// The number of \p CodeSynthesisContexts that are not template
10186 /// instantiations and, therefore, should not be counted as part of the
10187 /// instantiation depth.
10188 ///
10189 /// When the instantiation depth reaches the user-configurable limit
10190 /// \p LangOptions::InstantiationDepth we will abort instantiation.
10191 // FIXME: Should we have a similar limit for other forms of synthesis?
10193
10194 /// The depth of the context stack at the point when the most recent
10195 /// error or warning was produced.
10196 ///
10197 /// This value is used to suppress printing of redundant context stacks
10198 /// when there are multiple errors or warnings in the same instantiation.
10199 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
10201
10202 /// The template instantiation callbacks to trace or track
10203 /// instantiations (objects can be chained).
10204 ///
10205 /// This callbacks is used to print, trace or track template
10206 /// instantiations as they are being constructed.
10207 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
10209
10210 /// The current index into pack expansion arguments that will be
10211 /// used for substitution of parameter packs.
10212 ///
10213 /// The pack expansion index will be -1 to indicate that parameter packs
10214 /// should be instantiated as themselves. Otherwise, the index specifies
10215 /// which argument within the parameter pack will be used for substitution.
10217
10218 /// RAII object used to change the argument pack substitution index
10219 /// within a \c Sema object.
10220 ///
10221 /// See \c ArgumentPackSubstitutionIndex for more information.
10223 Sema &Self;
10224 int OldSubstitutionIndex;
10225
10226 public:
10227 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
10228 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
10229 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
10230 }
10231
10233 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
10234 }
10235 };
10236
10238
10241
10243 if (!CodeSynthesisContexts.empty() &&
10247 }
10250 }
10252
10253 /// Determines whether we are currently in a context where
10254 /// template argument substitution failures are not considered
10255 /// errors.
10256 ///
10257 /// \returns An empty \c Optional if we're not in a SFINAE context.
10258 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
10259 /// template-deduction context object, which can be used to capture
10260 /// diagnostics that will be suppressed.
10261 std::optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
10262
10264 const MultiLevelTemplateArgumentList &TemplateArgs,
10266 bool AllowDeducedTST = false);
10267
10269 const MultiLevelTemplateArgumentList &TemplateArgs,
10271
10273 const MultiLevelTemplateArgumentList &TemplateArgs,
10275
10277 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
10278 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
10279 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
10280 void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
10281 const MultiLevelTemplateArgumentList &Args);
10284 SmallVectorImpl<QualType> &ExceptionStorage,
10285 const MultiLevelTemplateArgumentList &Args);
10286 ParmVarDecl *
10288 const MultiLevelTemplateArgumentList &TemplateArgs,
10289 int indexAdjustment, std::optional<unsigned> NumExpansions,
10290 bool ExpectParameterPack, bool EvaluateConstraints = true);
10292 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
10293 const MultiLevelTemplateArgumentList &TemplateArgs,
10294 SmallVectorImpl<QualType> &ParamTypes,
10296 ExtParameterInfoBuilder &ParamInfos);
10298 const MultiLevelTemplateArgumentList &TemplateArgs,
10299 bool ForCallExpr = false);
10301 const MultiLevelTemplateArgumentList &TemplateArgs);
10302
10303 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
10304 // to disable constraint evaluation, then restore the state.
10305 template <typename InstTy> struct ConstraintEvalRAII {
10306 InstTy &TI;
10308
10310 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
10311 TI.setEvaluateConstraints(false);
10312 }
10313 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
10314 };
10315
10316 // Must be used instead of SubstExpr at 'constraint checking' time.
10319 const MultiLevelTemplateArgumentList &TemplateArgs);
10320 // Unlike the above, this does not evaluates constraints.
10322 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
10323
10324 /// Substitute the given template arguments into a list of
10325 /// expressions, expanding pack expansions if required.
10326 ///
10327 /// \param Exprs The list of expressions to substitute into.
10328 ///
10329 /// \param IsCall Whether this is some form of call, in which case
10330 /// default arguments will be dropped.
10331 ///
10332 /// \param TemplateArgs The set of template arguments to substitute.
10333 ///
10334 /// \param Outputs Will receive all of the substituted arguments.
10335 ///
10336 /// \returns true if an error occurred, false otherwise.
10337 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
10338 const MultiLevelTemplateArgumentList &TemplateArgs,
10339 SmallVectorImpl<Expr *> &Outputs);
10340
10342 const MultiLevelTemplateArgumentList &TemplateArgs);
10343
10346 bool CXXDirectInit);
10347
10348 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
10349 const MultiLevelTemplateArgumentList &TemplateArgs);
10350
10351 bool InstantiateClass(SourceLocation PointOfInstantiation,
10352 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
10353 const MultiLevelTemplateArgumentList &TemplateArgs,
10354 TemplateSpecializationKind TSK, bool Complain = true);
10355
10356 bool InstantiateEnum(SourceLocation PointOfInstantiation,
10357 EnumDecl *Instantiation, EnumDecl *Pattern,
10358 const MultiLevelTemplateArgumentList &TemplateArgs,
10360
10362 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
10363 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
10364
10367
10369 SourceLocation PointOfInstantiation,
10370 ClassTemplateSpecializationDecl *ClassTemplateSpec,
10371 TemplateSpecializationKind TSK, bool Complain = true);
10372
10373 void
10374 InstantiateClassMembers(SourceLocation PointOfInstantiation,
10375 CXXRecordDecl *Instantiation,
10376 const MultiLevelTemplateArgumentList &TemplateArgs,
10378
10380 SourceLocation PointOfInstantiation,
10381 ClassTemplateSpecializationDecl *ClassTemplateSpec,
10383
10386 const MultiLevelTemplateArgumentList &TemplateArgs);
10387
10390 const MultiLevelTemplateArgumentList &TemplateArgs);
10394 const MultiLevelTemplateArgumentList &TemplateArgs);
10395
10397 const MultiLevelTemplateArgumentList &TemplateArgs,
10398 bool EvaluateConstraint);
10399
10400 /// Determine whether we are currently performing template instantiation.
10403 }
10404
10405 ///@}
10406
10407 //
10408 //
10409 // -------------------------------------------------------------------------
10410 //
10411 //
10412
10413 /// \name C++ Template Declaration Instantiation
10414 /// Implementations are in SemaTemplateInstantiateDecl.cpp
10415 ///@{
10416
10417public:
10418 /// An entity for which implicit template instantiation is required.
10419 ///
10420 /// The source location associated with the declaration is the first place in
10421 /// the source code where the declaration was "used". It is not necessarily
10422 /// the point of instantiation (which will be either before or after the
10423 /// namespace-scope declaration that triggered this implicit instantiation),
10424 /// However, it is the location that diagnostics should generally refer to,
10425 /// because users will need to know what code triggered the instantiation.
10426 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
10427
10428 /// The queue of implicit template instantiations that are required
10429 /// but have not yet been performed.
10430 std::deque<PendingImplicitInstantiation> PendingInstantiations;
10431
10432 /// Queue of implicit template instantiations that cannot be performed
10433 /// eagerly.
10435
10439
10440 /// The queue of implicit template instantiations that are required
10441 /// and must be performed within the current local scope.
10442 ///
10443 /// This queue is only used for member functions of local classes in
10444 /// templates, which must be instantiated in the same scope as their
10445 /// enclosing function, so that they can reference function-local
10446 /// types, static variables, enumerators, etc.
10447 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
10448
10450 public:
10452 SavedPendingLocalImplicitInstantiations.swap(
10453 S.PendingLocalImplicitInstantiations);
10454 }
10455
10456 void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
10457
10459 assert(S.PendingLocalImplicitInstantiations.empty() &&
10460 "there shouldn't be any pending local implicit instantiations");
10461 SavedPendingLocalImplicitInstantiations.swap(
10462 S.PendingLocalImplicitInstantiations);
10463 }
10464
10465 private:
10466 Sema &S;
10467 std::deque<PendingImplicitInstantiation>
10468 SavedPendingLocalImplicitInstantiations;
10469 };
10470
10471 /// Records and restores the CurFPFeatures state on entry/exit of compound
10472 /// statements.
10474 public:
10477 FPOptionsOverride getOverrides() { return OldOverrides; }
10478
10479 private:
10480 Sema &S;
10481 FPOptions OldFPFeaturesState;
10482 FPOptionsOverride OldOverrides;
10483 LangOptions::FPEvalMethodKind OldEvalMethod;
10484 SourceLocation OldFPPragmaLocation;
10485 };
10486
10488 public:
10490 : S(S), Enabled(Enabled) {
10491 if (!Enabled)
10492 return;
10493
10494 S.SavedPendingInstantiations.emplace_back();
10495 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
10496
10497 S.SavedVTableUses.emplace_back();
10498 S.SavedVTableUses.back().swap(S.VTableUses);
10499 }
10500
10501 void perform() {
10502 if (Enabled) {
10503 S.DefineUsedVTables();
10504 S.PerformPendingInstantiations();
10505 }
10506 }
10507
10509 if (!Enabled)
10510 return;
10511
10512 // Restore the set of pending vtables.
10513 assert(S.VTableUses.empty() &&
10514 "VTableUses should be empty before it is discarded.");
10515 S.VTableUses.swap(S.SavedVTableUses.back());
10516 S.SavedVTableUses.pop_back();
10517
10518 // Restore the set of pending implicit instantiations.
10519 if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
10520 assert(S.PendingInstantiations.empty() &&
10521 "PendingInstantiations should be empty before it is discarded.");
10522 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
10523 S.SavedPendingInstantiations.pop_back();
10524 } else {
10525 // Template instantiations in the PCH may be delayed until the TU.
10526 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
10527 S.PendingInstantiations.insert(
10528 S.PendingInstantiations.end(),
10529 S.SavedPendingInstantiations.back().begin(),
10530 S.SavedPendingInstantiations.back().end());
10531 S.SavedPendingInstantiations.pop_back();
10532 }
10533 }
10534
10535 private:
10536 Sema &S;
10537 bool Enabled;
10538 };
10539
10541 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
10542
10547
10549 Decl *D)
10550 : TmplAttr(A), Scope(S), NewDecl(D) {}
10551 };
10553
10554 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
10555 const Decl *Pattern, Decl *Inst,
10556 LateInstantiatedAttrVec *LateAttrs = nullptr,
10557 LocalInstantiationScope *OuterMostScope = nullptr);
10558 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
10559
10560 void
10562 const Decl *Pattern, Decl *Inst,
10563 LateInstantiatedAttrVec *LateAttrs = nullptr,
10564 LocalInstantiationScope *OuterMostScope = nullptr);
10565
10567
10569 ParmVarDecl *Param);
10570 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
10577 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
10579 bool Recursive = false,
10580 bool DefinitionRequired = false,
10581 bool AtEndOfTU = false);
10584 const TemplateArgumentList *PartialSpecArgs,
10585 const TemplateArgumentListInfo &TemplateArgsInfo,
10587 SourceLocation PointOfInstantiation,
10588 LateInstantiatedAttrVec *LateAttrs = nullptr,
10589 LocalInstantiationScope *StartingScope = nullptr);
10591 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
10592 const MultiLevelTemplateArgumentList &TemplateArgs);
10593 void
10595 const MultiLevelTemplateArgumentList &TemplateArgs,
10596 LateInstantiatedAttrVec *LateAttrs,
10597 DeclContext *Owner,
10598 LocalInstantiationScope *StartingScope,
10599 bool InstantiatingVarTemplate = false,
10600 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
10601
10603 VarDecl *Var, VarDecl *OldVar,
10604 const MultiLevelTemplateArgumentList &TemplateArgs);
10605 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
10606 VarDecl *Var, bool Recursive = false,
10607 bool DefinitionRequired = false,
10608 bool AtEndOfTU = false);
10609
10611 CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl,
10612 const MultiLevelTemplateArgumentList &TemplateArgs);
10613
10614 NamedDecl *
10616 const MultiLevelTemplateArgumentList &TemplateArgs,
10617 bool FindingInstantiatedContext = false);
10618 DeclContext *
10620 const MultiLevelTemplateArgumentList &TemplateArgs);
10621
10622 Decl *SubstDecl(Decl *D, DeclContext *Owner,
10623 const MultiLevelTemplateArgumentList &TemplateArgs);
10624
10625 /// Substitute the name and return type of a defaulted 'operator<=>' to form
10626 /// an implicit 'operator=='.
10628 FunctionDecl *Spaceship);
10629
10630 void PerformPendingInstantiations(bool LocalOnly = false);
10631
10634 const MultiLevelTemplateArgumentList &TemplateArgs,
10635 bool EvaluateConstraints = true);
10636
10638 const DeclContext *Pattern,
10639 const MultiLevelTemplateArgumentList &TemplateArgs);
10640
10641private:
10642 /// Introduce the instantiated local variables into the local
10643 /// instantiation scope.
10644 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
10645 const FunctionDecl *PatternDecl,
10647 /// Introduce the instantiated function parameters into the local
10648 /// instantiation scope, and set the parameter names to those used
10649 /// in the template.
10650 bool addInstantiatedParametersToScope(
10651 FunctionDecl *Function, const FunctionDecl *PatternDecl,
10653 const MultiLevelTemplateArgumentList &TemplateArgs);
10654
10655 int ParsingClassDepth = 0;
10656
10657 class SavePendingParsedClassStateRAII {
10658 public:
10659 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
10660
10661 ~SavePendingParsedClassStateRAII() {
10662 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
10663 "there shouldn't be any pending delayed exception spec checks");
10664 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
10665 "there shouldn't be any pending delayed exception spec checks");
10666 swapSavedState();
10667 }
10668
10669 private:
10670 Sema &S;
10671 decltype(DelayedOverridingExceptionSpecChecks)
10672 SavedOverridingExceptionSpecChecks;
10673 decltype(DelayedEquivalentExceptionSpecChecks)
10674 SavedEquivalentExceptionSpecChecks;
10675
10676 void swapSavedState() {
10677 SavedOverridingExceptionSpecChecks.swap(
10678 S.DelayedOverridingExceptionSpecChecks);
10679 SavedEquivalentExceptionSpecChecks.swap(
10680 S.DelayedEquivalentExceptionSpecChecks);
10681 }
10682 };
10683
10684 ///@}
10685
10686 //
10687 //
10688 // -------------------------------------------------------------------------
10689 //
10690 //
10691
10692 /// \name C++ Variadic Templates
10693 /// Implementations are in SemaTemplateVariadic.cpp
10694 ///@{
10695
10696public:
10697 /// Determine whether an unexpanded parameter pack might be permitted in this
10698 /// location. Useful for error recovery.
10700
10701 /// The context in which an unexpanded parameter pack is
10702 /// being diagnosed.
10703 ///
10704 /// Note that the values of this enumeration line up with the first
10705 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
10707 /// An arbitrary expression.
10709
10710 /// The base type of a class type.
10712
10713 /// The type of an arbitrary declaration.
10715
10716 /// The type of a data member.
10718
10719 /// The size of a bit-field.
10721
10722 /// The expression in a static assertion.
10724
10725 /// The fixed underlying type of an enumeration.
10727
10728 /// The enumerator value.
10730
10731 /// A using declaration.
10733
10734 /// A friend declaration.
10736
10737 /// A declaration qualifier.
10739
10740 /// An initializer.
10742
10743 /// A default argument.
10745
10746 /// The type of a non-type template parameter.
10748
10749 /// The type of an exception.
10751
10752 /// Explicit specialization.
10754
10755 /// Partial specialization.
10757
10758 /// Microsoft __if_exists.
10760
10761 /// Microsoft __if_not_exists.
10763
10764 /// Lambda expression.
10766
10767 /// Block expression.
10769
10770 /// A type constraint.
10772
10773 // A requirement in a requires-expression.
10775
10776 // A requires-clause.
10778 };
10779
10780 /// Diagnose unexpanded parameter packs.
10781 ///
10782 /// \param Loc The location at which we should emit the diagnostic.
10783 ///
10784 /// \param UPPC The context in which we are diagnosing unexpanded
10785 /// parameter packs.
10786 ///
10787 /// \param Unexpanded the set of unexpanded parameter packs.
10788 ///
10789 /// \returns true if an error occurred, false otherwise.
10793
10794 /// If the given type contains an unexpanded parameter pack,
10795 /// diagnose the error.
10796 ///
10797 /// \param Loc The source location where a diagnostc should be emitted.
10798 ///
10799 /// \param T The type that is being checked for unexpanded parameter
10800 /// packs.
10801 ///
10802 /// \returns true if an error occurred, false otherwise.
10805
10806 /// If the given expression contains an unexpanded parameter
10807 /// pack, diagnose the error.
10808 ///
10809 /// \param E The expression that is being checked for unexpanded
10810 /// parameter packs.
10811 ///
10812 /// \returns true if an error occurred, false otherwise.
10815
10816 /// If the given requirees-expression contains an unexpanded reference to one
10817 /// of its own parameter packs, diagnose the error.
10818 ///
10819 /// \param RE The requiress-expression that is being checked for unexpanded
10820 /// parameter packs.
10821 ///
10822 /// \returns true if an error occurred, false otherwise.
10824
10825 /// If the given nested-name-specifier contains an unexpanded
10826 /// parameter pack, diagnose the error.
10827 ///
10828 /// \param SS The nested-name-specifier that is being checked for
10829 /// unexpanded parameter packs.
10830 ///
10831 /// \returns true if an error occurred, false otherwise.
10834
10835 /// If the given name contains an unexpanded parameter pack,
10836 /// diagnose the error.
10837 ///
10838 /// \param NameInfo The name (with source location information) that
10839 /// is being checked for unexpanded parameter packs.
10840 ///
10841 /// \returns true if an error occurred, false otherwise.
10844
10845 /// If the given template name contains an unexpanded parameter pack,
10846 /// diagnose the error.
10847 ///
10848 /// \param Loc The location of the template name.
10849 ///
10850 /// \param Template The template name that is being checked for unexpanded
10851 /// parameter packs.
10852 ///
10853 /// \returns true if an error occurred, false otherwise.
10855 TemplateName Template,
10857
10858 /// If the given template argument contains an unexpanded parameter
10859 /// pack, diagnose the error.
10860 ///
10861 /// \param Arg The template argument that is being checked for unexpanded
10862 /// parameter packs.
10863 ///
10864 /// \returns true if an error occurred, false otherwise.
10867
10868 /// Collect the set of unexpanded parameter packs within the given
10869 /// template argument.
10870 ///
10871 /// \param Arg The template argument that will be traversed to find
10872 /// unexpanded parameter packs.
10874 TemplateArgument Arg,
10876
10877 /// Collect the set of unexpanded parameter packs within the given
10878 /// template argument.
10879 ///
10880 /// \param Arg The template argument that will be traversed to find
10881 /// unexpanded parameter packs.
10885
10886 /// Collect the set of unexpanded parameter packs within the given
10887 /// type.
10888 ///
10889 /// \param T The type that will be traversed to find
10890 /// unexpanded parameter packs.
10893
10894 /// Collect the set of unexpanded parameter packs within the given
10895 /// type.
10896 ///
10897 /// \param TL The type that will be traversed to find
10898 /// unexpanded parameter packs.
10901
10902 /// Collect the set of unexpanded parameter packs within the given
10903 /// nested-name-specifier.
10904 ///
10905 /// \param NNS The nested-name-specifier that will be traversed to find
10906 /// unexpanded parameter packs.
10910
10911 /// Collect the set of unexpanded parameter packs within the given
10912 /// name.
10913 ///
10914 /// \param NameInfo The name that will be traversed to find
10915 /// unexpanded parameter packs.
10917 const DeclarationNameInfo &NameInfo,
10919
10920 /// Invoked when parsing a template argument followed by an
10921 /// ellipsis, which creates a pack expansion.
10922 ///
10923 /// \param Arg The template argument preceding the ellipsis, which
10924 /// may already be invalid.
10925 ///
10926 /// \param EllipsisLoc The location of the ellipsis.
10928 SourceLocation EllipsisLoc);
10929
10930 /// Invoked when parsing a type followed by an ellipsis, which
10931 /// creates a pack expansion.
10932 ///
10933 /// \param Type The type preceding the ellipsis, which will become
10934 /// the pattern of the pack expansion.
10935 ///
10936 /// \param EllipsisLoc The location of the ellipsis.
10938
10939 /// Construct a pack expansion type from the pattern of the pack
10940 /// expansion.
10942 SourceLocation EllipsisLoc,
10943 std::optional<unsigned> NumExpansions);
10944
10945 /// Construct a pack expansion type from the pattern of the pack
10946 /// expansion.
10947 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
10948 SourceLocation EllipsisLoc,
10949 std::optional<unsigned> NumExpansions);
10950
10951 /// Invoked when parsing an expression followed by an ellipsis, which
10952 /// creates a pack expansion.
10953 ///
10954 /// \param Pattern The expression preceding the ellipsis, which will become
10955 /// the pattern of the pack expansion.
10956 ///
10957 /// \param EllipsisLoc The location of the ellipsis.
10958 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
10959
10960 /// Invoked when parsing an expression followed by an ellipsis, which
10961 /// creates a pack expansion.
10962 ///
10963 /// \param Pattern The expression preceding the ellipsis, which will become
10964 /// the pattern of the pack expansion.
10965 ///
10966 /// \param EllipsisLoc The location of the ellipsis.
10967 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
10968 std::optional<unsigned> NumExpansions);
10969
10970 /// Determine whether we could expand a pack expansion with the
10971 /// given set of parameter packs into separate arguments by repeatedly
10972 /// transforming the pattern.
10973 ///
10974 /// \param EllipsisLoc The location of the ellipsis that identifies the
10975 /// pack expansion.
10976 ///
10977 /// \param PatternRange The source range that covers the entire pattern of
10978 /// the pack expansion.
10979 ///
10980 /// \param Unexpanded The set of unexpanded parameter packs within the
10981 /// pattern.
10982 ///
10983 /// \param ShouldExpand Will be set to \c true if the transformer should
10984 /// expand the corresponding pack expansions into separate arguments. When
10985 /// set, \c NumExpansions must also be set.
10986 ///
10987 /// \param RetainExpansion Whether the caller should add an unexpanded
10988 /// pack expansion after all of the expanded arguments. This is used
10989 /// when extending explicitly-specified template argument packs per
10990 /// C++0x [temp.arg.explicit]p9.
10991 ///
10992 /// \param NumExpansions The number of separate arguments that will be in
10993 /// the expanded form of the corresponding pack expansion. This is both an
10994 /// input and an output parameter, which can be set by the caller if the
10995 /// number of expansions is known a priori (e.g., due to a prior substitution)
10996 /// and will be set by the callee when the number of expansions is known.
10997 /// The callee must set this value when \c ShouldExpand is \c true; it may
10998 /// set this value in other cases.
10999 ///
11000 /// \returns true if an error occurred (e.g., because the parameter packs
11001 /// are to be instantiated with arguments of different lengths), false
11002 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
11003 /// must be set.
11005 SourceLocation EllipsisLoc, SourceRange PatternRange,
11007 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
11008 bool &RetainExpansion, std::optional<unsigned> &NumExpansions);
11009
11010 /// Determine the number of arguments in the given pack expansion
11011 /// type.
11012 ///
11013 /// This routine assumes that the number of arguments in the expansion is
11014 /// consistent across all of the unexpanded parameter packs in its pattern.
11015 ///
11016 /// Returns an empty Optional if the type can't be expanded.
11017 std::optional<unsigned> getNumArgumentsInExpansion(
11018 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
11019
11020 /// Determine whether the given declarator contains any unexpanded
11021 /// parameter packs.
11022 ///
11023 /// This routine is used by the parser to disambiguate function declarators
11024 /// with an ellipsis prior to the ')', e.g.,
11025 ///
11026 /// \code
11027 /// void f(T...);
11028 /// \endcode
11029 ///
11030 /// To determine whether we have an (unnamed) function parameter pack or
11031 /// a variadic function.
11032 ///
11033 /// \returns true if the declarator contains any unexpanded parameter packs,
11034 /// false otherwise.
11036
11037 /// Returns the pattern of the pack expansion for a template argument.
11038 ///
11039 /// \param OrigLoc The template argument to expand.
11040 ///
11041 /// \param Ellipsis Will be set to the location of the ellipsis.
11042 ///
11043 /// \param NumExpansions Will be set to the number of expansions that will
11044 /// be generated from this pack expansion, if known a priori.
11046 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
11047 std::optional<unsigned> &NumExpansions) const;
11048
11049 /// Given a template argument that contains an unexpanded parameter pack, but
11050 /// which has already been substituted, attempt to determine the number of
11051 /// elements that will be produced once this argument is fully-expanded.
11052 ///
11053 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
11054 /// avoid actually expanding the pack where possible.
11055 std::optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
11056
11058 IdentifierInfo &Name,
11059 SourceLocation NameLoc,
11060 SourceLocation RParenLoc);
11061
11062 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
11063 SourceLocation EllipsisLoc,
11064 SourceLocation LSquareLoc, Expr *IndexExpr,
11065 SourceLocation RSquareLoc);
11066
11067 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
11068 SourceLocation EllipsisLoc, Expr *IndexExpr,
11069 SourceLocation RSquareLoc,
11070 ArrayRef<Expr *> ExpandedExprs = {},
11071 bool EmptyPack = false);
11072
11073 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
11074 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
11075 tok::TokenKind Operator,
11076 SourceLocation EllipsisLoc, Expr *RHS,
11077 SourceLocation RParenLoc);
11078 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
11079 SourceLocation LParenLoc, Expr *LHS,
11080 BinaryOperatorKind Operator,
11081 SourceLocation EllipsisLoc, Expr *RHS,
11082 SourceLocation RParenLoc,
11083 std::optional<unsigned> NumExpansions);
11084 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
11085 BinaryOperatorKind Operator);
11086
11087 ///@}
11088
11089 //
11090 //
11091 // -------------------------------------------------------------------------
11092 //
11093 //
11094
11095 /// \name Constraints and Concepts
11096 /// Implementations are in SemaConcept.cpp
11097 ///@{
11098
11099public:
11101 const llvm::FoldingSetNodeID &ID) {
11102 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
11103 SatisfactionStack.emplace_back(Can, ID);
11104 }
11105
11106 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
11107
11109 const llvm::FoldingSetNodeID &ID) const {
11110 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
11111 return llvm::find(SatisfactionStack, SatisfactionStackEntryTy{Can, ID}) !=
11112 SatisfactionStack.end();
11113 }
11114
11116 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
11117
11118 // Resets the current SatisfactionStack for cases where we are instantiating
11119 // constraints as a 'side effect' of normal instantiation in a way that is not
11120 // indicative of recursive definition.
11123 Sema &SemaRef;
11124
11125 public:
11127 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
11128 }
11129
11131 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
11132 }
11133 };
11134
11137 SatisfactionStack.swap(NewSS);
11138 }
11139
11140 /// Check whether the given expression is a valid constraint expression.
11141 /// A diagnostic is emitted if it is not, false is returned, and
11142 /// PossibleNonPrimary will be set to true if the failure might be due to a
11143 /// non-primary expression being used as an atomic constraint.
11144 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
11145 bool *PossibleNonPrimary = nullptr,
11146 bool IsTrailingRequiresClause = false);
11147
11148 /// \brief Check whether the given list of constraint expressions are
11149 /// satisfied (as if in a 'conjunction') given template arguments.
11150 /// \param Template the template-like entity that triggered the constraints
11151 /// check (either a concept or a constrained entity).
11152 /// \param ConstraintExprs a list of constraint expressions, treated as if
11153 /// they were 'AND'ed together.
11154 /// \param TemplateArgLists the list of template arguments to substitute into
11155 /// the constraint expression.
11156 /// \param TemplateIDRange The source range of the template id that
11157 /// caused the constraints check.
11158 /// \param Satisfaction if true is returned, will contain details of the
11159 /// satisfaction, with enough information to diagnose an unsatisfied
11160 /// expression.
11161 /// \returns true if an error occurred and satisfaction could not be checked,
11162 /// false otherwise.
11164 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
11165 const MultiLevelTemplateArgumentList &TemplateArgLists,
11166 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
11168 return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted,
11169 TemplateArgLists, TemplateIDRange,
11170 Satisfaction);
11171 }
11172
11173 /// \brief Check whether the given list of constraint expressions are
11174 /// satisfied (as if in a 'conjunction') given template arguments.
11175 /// Additionally, takes an empty list of Expressions which is populated with
11176 /// the instantiated versions of the ConstraintExprs.
11177 /// \param Template the template-like entity that triggered the constraints
11178 /// check (either a concept or a constrained entity).
11179 /// \param ConstraintExprs a list of constraint expressions, treated as if
11180 /// they were 'AND'ed together.
11181 /// \param ConvertedConstraints a out parameter that will get populated with
11182 /// the instantiated version of the ConstraintExprs if we successfully checked
11183 /// satisfaction.
11184 /// \param TemplateArgList the multi-level list of template arguments to
11185 /// substitute into the constraint expression. This should be relative to the
11186 /// top-level (hence multi-level), since we need to instantiate fully at the
11187 /// time of checking.
11188 /// \param TemplateIDRange The source range of the template id that
11189 /// caused the constraints check.
11190 /// \param Satisfaction if true is returned, will contain details of the
11191 /// satisfaction, with enough information to diagnose an unsatisfied
11192 /// expression.
11193 /// \returns true if an error occurred and satisfaction could not be checked,
11194 /// false otherwise.
11196 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
11197 llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
11198 const MultiLevelTemplateArgumentList &TemplateArgList,
11199 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
11200
11201 /// \brief Check whether the given non-dependent constraint expression is
11202 /// satisfied. Returns false and updates Satisfaction with the satisfaction
11203 /// verdict if successful, emits a diagnostic and returns true if an error
11204 /// occurred and satisfaction could not be determined.
11205 ///
11206 /// \returns true if an error occurred, false otherwise.
11207 bool CheckConstraintSatisfaction(const Expr *ConstraintExpr,
11208 ConstraintSatisfaction &Satisfaction);
11209
11210 /// Check whether the given function decl's trailing requires clause is
11211 /// satisfied, if any. Returns false and updates Satisfaction with the
11212 /// satisfaction verdict if successful, emits a diagnostic and returns true if
11213 /// an error occurred and satisfaction could not be determined.
11214 ///
11215 /// \returns true if an error occurred, false otherwise.
11217 ConstraintSatisfaction &Satisfaction,
11218 SourceLocation UsageLoc = SourceLocation(),
11219 bool ForOverloadResolution = false);
11220
11221 // Calculates whether two constraint expressions are equal irrespective of a
11222 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
11223 // 'New', which are the "source" of the constraint, since this is necessary
11224 // for figuring out the relative 'depth' of the constraint. The depth of the
11225 // 'primary template' and the 'instantiated from' templates aren't necessarily
11226 // the same, such as a case when one is a 'friend' defined in a class.
11228 const Expr *OldConstr,
11229 const TemplateCompareNewDeclInfo &New,
11230 const Expr *NewConstr);
11231
11232 // Calculates whether the friend function depends on an enclosing template for
11233 // the purposes of [temp.friend] p9.
11235
11236 /// \brief Ensure that the given template arguments satisfy the constraints
11237 /// associated with the given template, emitting a diagnostic if they do not.
11238 ///
11239 /// \param Template The template to which the template arguments are being
11240 /// provided.
11241 ///
11242 /// \param TemplateArgs The converted, canonicalized template arguments.
11243 ///
11244 /// \param TemplateIDRange The source range of the template id that
11245 /// caused the constraints check.
11246 ///
11247 /// \returns true if the constrains are not satisfied or could not be checked
11248 /// for satisfaction, false if the constraints are satisfied.
11250 TemplateDecl *Template,
11251 const MultiLevelTemplateArgumentList &TemplateArgs,
11252 SourceRange TemplateIDRange);
11253
11255 SourceLocation PointOfInstantiation, FunctionDecl *Decl,
11256 ArrayRef<TemplateArgument> TemplateArgs,
11257 ConstraintSatisfaction &Satisfaction);
11258
11259 /// \brief Emit diagnostics explaining why a constraint expression was deemed
11260 /// unsatisfied.
11261 /// \param First whether this is the first time an unsatisfied constraint is
11262 /// diagnosed for this error.
11264 bool First = true);
11265
11266 /// \brief Emit diagnostics explaining why a constraint expression was deemed
11267 /// unsatisfied.
11268 void
11270 bool First = true);
11271
11273 NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints);
11274
11275 /// \brief Check whether the given declaration's associated constraints are
11276 /// at least as constrained than another declaration's according to the
11277 /// partial ordering of constraints.
11278 ///
11279 /// \param Result If no error occurred, receives the result of true if D1 is
11280 /// at least constrained than D2, and false otherwise.
11281 ///
11282 /// \returns true if an error occurred, false otherwise.
11285 bool &Result);
11286
11287 /// If D1 was not at least as constrained as D2, but would've been if a pair
11288 /// of atomic constraints involved had been declared in a concept and not
11289 /// repeated in two separate places in code.
11290 /// \returns true if such a diagnostic was emitted, false otherwise.
11294
11295private:
11296 /// Caches pairs of template-like decls whose associated constraints were
11297 /// checked for subsumption and whether or not the first's constraints did in
11298 /// fact subsume the second's.
11299 llvm::DenseMap<std::pair<NamedDecl *, NamedDecl *>, bool> SubsumptionCache;
11300 /// Caches the normalized associated constraints of declarations (concepts or
11301 /// constrained declarations). If an error occurred while normalizing the
11302 /// associated constraints of the template or concept, nullptr will be cached
11303 /// here.
11304 llvm::DenseMap<NamedDecl *, NormalizedConstraint *> NormalizationCache;
11305
11306 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
11307 SatisfactionCache;
11308
11309 // The current stack of constraint satisfactions, so we can exit-early.
11311
11312 /// Introduce the instantiated captures of the lambda into the local
11313 /// instantiation scope.
11314 bool addInstantiatedCapturesToScope(
11315 FunctionDecl *Function, const FunctionDecl *PatternDecl,
11317 const MultiLevelTemplateArgumentList &TemplateArgs);
11318
11319 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in
11320 /// the case of lambdas) set up the LocalInstantiationScope of the current
11321 /// function.
11322 bool
11323 SetupConstraintScope(FunctionDecl *FD,
11324 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
11325 const MultiLevelTemplateArgumentList &MLTAL,
11327
11328 /// Used during constraint checking, sets up the constraint template argument
11329 /// lists, and calls SetupConstraintScope to set up the
11330 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
11331 std::optional<MultiLevelTemplateArgumentList>
11332 SetupConstraintCheckingTemplateArgumentsAndScope(
11333 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
11335
11336 ///@}
11337
11338 //
11339 //
11340 // -------------------------------------------------------------------------
11341 //
11342 //
11343
11344 /// \name Types
11345 /// Implementations are in SemaType.cpp
11346 ///@{
11347
11348public:
11349 /// A mapping that describes the nullability we've seen in each header file.
11351
11352 static int getPrintable(int I) { return I; }
11353 static unsigned getPrintable(unsigned I) { return I; }
11354 static bool getPrintable(bool B) { return B; }
11355 static const char *getPrintable(const char *S) { return S; }
11356 static StringRef getPrintable(StringRef S) { return S; }
11357 static const std::string &getPrintable(const std::string &S) { return S; }
11358 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
11359 return II;
11360 }
11362 static QualType getPrintable(QualType T) { return T; }
11363 static SourceRange getPrintable(SourceRange R) { return R; }
11365 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
11367
11368 enum class CompleteTypeKind {
11369 /// Apply the normal rules for complete types. In particular,
11370 /// treat all sizeless types as incomplete.
11371 Normal,
11372
11373 /// Relax the normal rules for complete types so that they include
11374 /// sizeless built-in types.
11376
11377 // FIXME: Eventually we should flip the default to Normal and opt in
11378 // to AcceptSizeless rather than opt out of it.
11380 };
11381
11383 const DeclSpec *DS = nullptr);
11385 const DeclSpec *DS = nullptr);
11387 DeclarationName Entity);
11389 DeclarationName Entity);
11391 unsigned Quals, SourceRange Brackets,
11392 DeclarationName Entity);
11395 SourceLocation AttrLoc);
11396 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
11397 SourceLocation AttrLoc);
11398
11400 Expr *CountExpr);
11401
11402 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
11403 SourceLocation AttrLoc);
11404
11405 /// Same as above, but constructs the AddressSpace index if not provided.
11407 SourceLocation AttrLoc);
11408
11410
11412
11413 /// Build a function type.
11414 ///
11415 /// This routine checks the function type according to C++ rules and
11416 /// under the assumption that the result type and parameter types have
11417 /// just been instantiated from a template. It therefore duplicates
11418 /// some of the behavior of GetTypeForDeclarator, but in a much
11419 /// simpler form that is only suitable for this narrow use case.
11420 ///
11421 /// \param T The return type of the function.
11422 ///
11423 /// \param ParamTypes The parameter types of the function. This array
11424 /// will be modified to account for adjustments to the types of the
11425 /// function parameters.
11426 ///
11427 /// \param Loc The location of the entity whose type involves this
11428 /// function type or, if there is no such entity, the location of the
11429 /// type that will have function type.
11430 ///
11431 /// \param Entity The name of the entity that involves the function
11432 /// type, if known.
11433 ///
11434 /// \param EPI Extra information about the function type. Usually this will
11435 /// be taken from an existing function with the same prototype.
11436 ///
11437 /// \returns A suitable function type, if there are no errors. The
11438 /// unqualified type will always be a FunctionProtoType.
11439 /// Otherwise, returns a NULL type.
11443
11447 DeclarationName Entity);
11452 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
11453
11456
11457 /// Package the given type and TSI into a ParsedType.
11460 TypeSourceInfo **TInfo = nullptr);
11461
11463
11464 // Check whether the size of array element of type \p EltTy is a multiple of
11465 // its alignment and return false if it isn't.
11467
11468 void
11469 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
11470 SourceLocation FallbackLoc,
11471 SourceLocation ConstQualLoc = SourceLocation(),
11472 SourceLocation VolatileQualLoc = SourceLocation(),
11473 SourceLocation RestrictQualLoc = SourceLocation(),
11474 SourceLocation AtomicQualLoc = SourceLocation(),
11475 SourceLocation UnalignedQualLoc = SourceLocation());
11476
11477 /// Retrieve the keyword associated
11479
11480 /// Adjust the calling convention of a method to be the ABI default if it
11481 /// wasn't specified explicitly. This handles method types formed from
11482 /// function type typedefs and typename template arguments.
11483 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
11484 bool IsCtorOrDtor, SourceLocation Loc);
11485
11486 // Check if there is an explicit attribute, but only look through parens.
11487 // The intent is to look for an attribute on the current declarator, but not
11488 // one that came from a typedef.
11490
11491 /// Check whether a nullability type specifier can be added to the given
11492 /// type through some means not written in source (e.g. API notes).
11493 ///
11494 /// \param Type The type to which the nullability specifier will be
11495 /// added. On success, this type will be updated appropriately.
11496 ///
11497 /// \param Nullability The nullability specifier to add.
11498 ///
11499 /// \param DiagLoc The location to use for diagnostics.
11500 ///
11501 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
11502 /// array type (e.g., because it will decay to a pointer).
11503 ///
11504 /// \param OverrideExisting Whether to override an existing, locally-specified
11505 /// nullability specifier rather than complaining about the conflict.
11506 ///
11507 /// \returns true if nullability cannot be applied, false otherwise.
11509 NullabilityKind Nullability,
11510 SourceLocation DiagLoc,
11511 bool AllowArrayTypes,
11512 bool OverrideExisting);
11513
11514 /// Get the type of expression E, triggering instantiation to complete the
11515 /// type if necessary -- that is, if the expression refers to a templated
11516 /// static data member of incomplete array type.
11517 ///
11518 /// May still return an incomplete type if instantiation was not possible or
11519 /// if the type is incomplete for a different reason. Use
11520 /// RequireCompleteExprType instead if a diagnostic is expected for an
11521 /// incomplete expression type.
11523
11526 TypeDiagnoser &Diagnoser);
11527 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
11528
11529 template <typename... Ts>
11530 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
11531 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
11533 }
11534
11536 const CXXScopeSpec &SS, QualType T,
11537 TagDecl *OwnedTagDecl = nullptr);
11538
11539 // Returns the underlying type of a decltype with the given expression.
11541
11543 /// If AsUnevaluated is false, E is treated as though it were an evaluated
11544 /// context, such as when building a type for decltype(auto).
11545 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
11546
11547 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
11549 SourceLocation EllipsisLoc);
11550 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
11551 SourceLocation Loc, SourceLocation EllipsisLoc,
11552 bool FullySubstituted = false,
11553 ArrayRef<QualType> Expansions = {});
11554
11572
11574 TypeDiagnoser &Diagnoser);
11575 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
11576
11577 template <typename... Ts>
11579 const Ts &...Args) {
11580 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
11581 return RequireLiteralType(Loc, T, Diagnoser);
11582 }
11583
11586 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
11587 }
11589 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
11591 CompleteTypeKind Kind, unsigned DiagID);
11592
11594 TypeDiagnoser &Diagnoser) {
11596 }
11599 }
11600
11601 template <typename... Ts>
11603 const Ts &...Args) {
11604 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
11605 return RequireCompleteType(Loc, T, Diagnoser);
11606 }
11607
11608 /// Determine whether a declaration is visible to name lookup.
11609 bool isVisible(const NamedDecl *D) {
11610 return D->isUnconditionallyVisible() ||
11611 isAcceptableSlow(D, AcceptableKind::Visible);
11612 }
11613
11614 /// Determine whether a declaration is reachable.
11615 bool isReachable(const NamedDecl *D) {
11616 // All visible declarations are reachable.
11617 return D->isUnconditionallyVisible() ||
11618 isAcceptableSlow(D, AcceptableKind::Reachable);
11619 }
11620
11621 /// Determine whether a declaration is acceptable (visible/reachable).
11623 return Kind == AcceptableKind::Visible ? isVisible(D) : isReachable(D);
11624 }
11625
11626 /// Determine if \p D and \p Suggested have a structurally compatible
11627 /// layout as described in C11 6.2.7/1.
11628 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
11629
11630 /// Determine if \p D has a visible definition. If not, suggest a declaration
11631 /// that should be made visible to expose the definition.
11632 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
11633 bool OnlyNeedComplete = false);
11635 NamedDecl *Hidden;
11636 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
11637 }
11638
11639 /// Determine if \p D has a reachable definition. If not, suggest a
11640 /// declaration that should be made reachable to expose the definition.
11641 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
11642 bool OnlyNeedComplete = false);
11644 NamedDecl *Hidden;
11645 return hasReachableDefinition(D, &Hidden);
11646 }
11647
11648 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
11649 AcceptableKind Kind,
11650 bool OnlyNeedComplete = false);
11652 NamedDecl *Hidden;
11653 return hasAcceptableDefinition(D, &Hidden, Kind);
11654 }
11655
11656private:
11657 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
11658 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
11659
11660 /// Nullability type specifiers.
11661 IdentifierInfo *Ident__Nonnull = nullptr;
11662 IdentifierInfo *Ident__Nullable = nullptr;
11663 IdentifierInfo *Ident__Nullable_result = nullptr;
11664 IdentifierInfo *Ident__Null_unspecified = nullptr;
11665
11666 ///@}
11667
11668 //
11669 //
11670 // -------------------------------------------------------------------------
11671 //
11672 //
11673
11674 /// \name FixIt Helpers
11675 /// Implementations are in SemaFixItUtils.cpp
11676 ///@{
11677
11678public:
11679 /// Get a string to suggest for zero-initialization of a type.
11681 SourceLocation Loc) const;
11683
11684 ///@}
11685
11686 //
11687 //
11688 // -------------------------------------------------------------------------
11689 //
11690 //
11691
11692 /// \name API Notes
11693 /// Implementations are in SemaAPINotes.cpp
11694 ///@{
11695
11696public:
11697 /// Map any API notes provided for this declaration to attributes on the
11698 /// declaration.
11699 ///
11700 /// Triggered by declaration-attribute processing.
11701 void ProcessAPINotes(Decl *D);
11702
11703 ///@}
11704 //
11705 //
11706 // -------------------------------------------------------------------------
11707 //
11708 //
11709
11710 /// \name Name Lookup for RISC-V Vector Intrinsic
11711 /// Implementations are in SemaRISCVVectorLookup.cpp
11712 ///@{
11713
11714public:
11715 /// Indicate RISC-V vector builtin functions enabled or not.
11717
11718 /// Indicate RISC-V SiFive vector builtin functions enabled or not.
11720
11721private:
11722 std::unique_ptr<sema::RISCVIntrinsicManager> RVIntrinsicManager;
11723
11724 ///@}
11725};
11726
11730
11731/// Contains a late templated function.
11732/// Will be parsed at the end of the translation unit, used by Sema & Parser.
11735 /// The template function declaration to be late parsed.
11737 /// Floating-point options in the point of definition.
11739};
11740
11741template <>
11743 PragmaMsStackAction Action,
11744 llvm::StringRef StackSlotLabel,
11746
11747std::unique_ptr<sema::RISCVIntrinsicManager>
11749} // end namespace clang
11750
11751#endif
This file provides AST data structures related to concepts.
#define V(N, I)
Definition: ASTContext.h:3285
int Id
Definition: ASTDiff.cpp:190
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.
llvm::APSInt APSInt
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:2979
StringRef Identifier
Definition: Format.cpp:2983
llvm::MachO::Target Target
Definition: MachO.h:50
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
AccessResult
A copy of Sema's enum without AR_delayed.
Definition: SemaAccess.cpp:31
CastType
Definition: SemaCast.cpp:48
SourceRange Range
Definition: SemaObjC.cpp:754
SourceLocation Loc
Definition: SemaObjC.cpp:755
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:4424
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:33
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
CanQualType BoolTy
Definition: ASTContext.h:1092
CanQualType IntTy
Definition: ASTContext.h:1100
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:90
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:2664
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:3519
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:5605
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5982
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:4494
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:2493
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:1148
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:2820
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4686
CaseStmt - Represent a case statement.
Definition: Stmt.h:1801
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3483
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:4499
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
The information about the darwin SDK that was used during this compilation.
Definition: DarwinSDKInfo.h:29
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1369
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1436
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1260
Captures information about "declaration specifiers".
Definition: DeclSpec.h:247
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Definition: DeclBase.h:849
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:833
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:908
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:968
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:770
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:3297
Represents an enum.
Definition: Decl.h:3867
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:5576
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
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
Definition: Expr.h:792
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
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:915
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
Definition: LangOptions.h:1022
Represents a member of a struct/union/class.
Definition: Decl.h:3057
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:259
FileNullability & operator[](FileID file)
Definition: Sema.h:270
FileNullability Nullability
Definition: Sema.h:266
Represents a function declaration or definition.
Definition: Decl.h:1971
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4630
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4657
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:4283
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4257
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:543
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3341
Describes an C or C++ initializer list.
Definition: Expr.h:4847
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:4710
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3172
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:7009
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:980
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:2130
Represents a parameter to a function.
Definition: Decl.h:1761
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:126
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:946
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:291
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:293
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
Definition: Sema.h:328
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:128
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2561
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:6305
A (possibly-)qualified type.
Definition: Type.h:940
The collection of all-type qualifiers we support.
Definition: Type.h:318
Represents a struct/union/class.
Definition: Decl.h:4168
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:5550
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:56
AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
Definition: Sema.h:1217
bool operator==(const AlignPackInfo &Info) const
Definition: Sema.h:1277
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:1249
unsigned getPackNumber() const
Definition: Sema.h:1267
bool IsXLStack() const
Definition: Sema.h:1275
bool IsPackSet() const
Definition: Sema.h:1269
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition: Sema.h:1223
bool IsAlignAttr() const
Definition: Sema.h:1263
bool IsPackAttr() const
Definition: Sema.h:1261
bool operator!=(const AlignPackInfo &Info) const
Definition: Sema.h:1283
AlignPackInfo(bool IsXL)
Definition: Sema.h:1227
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition: Sema.h:1234
Mode getAlignMode() const
Definition: Sema.h:1265
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:10222
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:10227
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:6325
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:6330
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition: Sema.h:6317
std::tuple< const Ts &... > Args
Definition: Sema.h:6314
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:6477
A RAII object to enter scope of a compound statement.
Definition: Sema.h:854
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:856
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:5810
bool isInvalid() const
Definition: Sema.h:5809
std::optional< bool > getKnownValue() const
Definition: Sema.h:5814
A RAII object to temporarily push a declaration context.
Definition: Sema.h:2530
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition: Sema.h:2540
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:7977
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:7982
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:4641
DefaultedComparisonKind asComparison() const
Definition: Sema.h:4673
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition: Sema.h:4650
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition: Sema.h:4678
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition: Sema.h:4653
CXXSpecialMemberKind asSpecialMember() const
Definition: Sema.h:4670
RAII class to control scope of DeferDiags.
Definition: Sema.h:7828
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition: Sema.h:7833
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition: Sema.h:926
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:945
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:969
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:938
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:941
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:955
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:961
A helper class for building up ExtParameterInfos.
Definition: Sema.h:9673
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:9692
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:9680
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:10473
FPOptionsOverride getOverrides()
Definition: Sema.h:10477
FullExprArg(Sema &actions)
Definition: Sema.h:5754
ExprResult release()
Definition: Sema.h:5756
Expr * get() const
Definition: Sema.h:5758
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:10489
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:8041
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:8033
Helper class that collects exception specifications for implicitly-declared special member functions.
Definition: Sema.h:3982
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:4015
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:4008
const QualType * data() const
The set of exceptions in the exception specification.
Definition: Sema.h:4018
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
Definition: Sema.h:4024
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition: Sema.h:4031
static NameClassification DependentNonType()
Definition: Sema.h:2745
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:2755
ExprResult getExpression() const
Definition: Sema.h:2781
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:2721
static NameClassification Unknown()
Definition: Sema.h:2725
static NameClassification OverloadSet(ExprResult E)
Definition: Sema.h:2729
NameClassificationKind getKind() const
Definition: Sema.h:2779
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition: Sema.h:2773
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:2761
NamedDecl * getNonTypeDecl() const
Definition: Sema.h:2791
NameClassification(ParsedType Type)
Definition: Sema.h:2719
TemplateName getTemplateName() const
Definition: Sema.h:2796
ParsedType getType() const
Definition: Sema.h:2786
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:2803
static NameClassification NonType(NamedDecl *D)
Definition: Sema.h:2735
static NameClassification Concept(TemplateName Name)
Definition: Sema.h:2767
static NameClassification UndeclaredNonType()
Definition: Sema.h:2741
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:2749
static NameClassification Error()
Definition: Sema.h:2723
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
Definition: Sema.h:628
void operator()(sema::FunctionScopeInfo *Scope) const
Definition: Sema.cpp:2274
Whether and why a template name is required in this lookup.
Definition: Sema.h:8745
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition: Sema.h:8751
SourceLocation getTemplateKeywordLoc() const
Definition: Sema.h:8753
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition: Sema.h:8748
bool hasTemplateKeyword() const
Definition: Sema.h:8756
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:9409
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:9439
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:9417
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition: Sema.h:6342
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:6347
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:6344
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:7262
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:7240
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:7249
CXXMethodDecl * getMethod() const
Definition: Sema.h:7252
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:7253
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:10100
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:10128
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:10106
SourceLocation getLocation() const
Definition: Sema.h:9238
bool ContainsDecl(const NamedDecl *ND) const
Definition: Sema.h:9228
const DeclContext * getDeclContext() const
Definition: Sema.h:9234
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition: Sema.h:9212
const NamedDecl * getDecl() const
Definition: Sema.h:9226
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition: Sema.h:9211
const DeclContext * getLexicalDeclContext() const
Definition: Sema.h:9230
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:9448
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:9455
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:5707
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition: Sema.h:5711
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:450
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)
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:14523
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:14340
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:8970
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:11037
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:1648
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:6350
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
Definition: SemaDecl.cpp:6793
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:10172
void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn)
#pragma optimize("[optimization-list]", on | off).
Definition: SemaAttr.cpp:1142
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:6234
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
Definition: SemaAttr.cpp:400
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition: Sema.h:10156
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:8400
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:9702
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:687
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:2546
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:8845
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:6711
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
SmallVector< SmallVector< VTableUse, 16 >, 8 > SavedVTableUses
Definition: Sema.h:10436
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Definition: SemaDecl.cpp:9807
void PopParsingClass(ParsingClassState state)
Definition: Sema.h:4805
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
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:2478
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:7844
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition: Sema.cpp:939
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:4794
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:2054
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)
Definition: SemaExpr.cpp:15755
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:6297
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:1585
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
Definition: SemaExpr.cpp:3689
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
Definition: SemaExpr.cpp:15428
llvm::DenseSet< Module * > & getLookupModules()
Get the set of additional modules that should be checked during name lookup.
bool isValidRVVBitcast(QualType srcType, QualType destType)
Are the two types RVV-bitcast-compatible types? I.e.
Definition: SemaExpr.cpp:7594
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
bool isAlwaysConstantEvaluatedContext() const
Definition: Sema.h:6204
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:813
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
Definition: SemaDecl.cpp:15230
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Definition: SemaStmt.cpp:4449
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:1051
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:6290
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:2459
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition: Sema.h:4598
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:7284
@ LookupLabel
Label name lookup.
Definition: Sema.h:7293
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:7288
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition: Sema.h:7315
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition: Sema.h:7307
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:7329
@ LookupLocalFriendName
Look up a friend of a local class.
Definition: Sema.h:7323
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition: Sema.h:7325
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:7320
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:7300
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition: Sema.h:7327
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition: Sema.h:7311
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:7296
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition: Sema.h:7303
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:7291
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition: Sema.h:7331
@ LookupAnyName
Look up any declaration with any name.
Definition: Sema.h:7333
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:424
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition: Sema.h:7228
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:3550
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:6729
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
Definition: SemaType.cpp:6458
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
Definition: SemaAttr.cpp:1058
void ActOnPopScope(SourceLocation Loc, Scope *S)
Definition: SemaDecl.cpp:2237
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
Definition: SemaDecl.cpp:5365
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
Definition: SemaExpr.cpp:19512
void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
ActOnPragmaDetectMismatch - Call on well-formed #pragma detect_mismatch.
Definition: SemaAttr.cpp:526
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13157
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
Definition: SemaDecl.cpp:15920
bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D, StringRef &Str, bool &isDefault)
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:4560
VariadicCallType
Definition: Sema.h:2003
@ VariadicDoesNotApply
Definition: Sema.h:2008
@ VariadicFunction
Definition: Sema.h:2004
@ VariadicMethod
Definition: Sema.h:2006
@ VariadicConstructor
Definition: Sema.h:2007
@ VariadicBlock
Definition: Sema.h:2005
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
Definition: SemaDecl.cpp:12980
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.
void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
Definition: SemaModule.cpp:759
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)...
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
Definition: SemaExpr.cpp:7086
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:809
bool DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc, RecordDecl *ClassDecl, const IdentifierInfo *Name)
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:921
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
Definition: SemaAccess.cpp:40
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:2981
@ NTCUC_CopyInit
Definition: Sema.h:2991
@ NTCUC_AutoVar
Definition: Sema.h:2989
@ NTCUC_CompoundLiteral
Definition: Sema.h:2995
@ NTCUC_DefaultInitializedObject
Definition: Sema.h:2987
@ NTCUC_Assignment
Definition: Sema.h:2993
@ NTCUC_BlockCapture
Definition: Sema.h:2997
@ NTCUC_FunctionReturn
Definition: Sema.h:2985
@ NTCUC_LValueToRValueVolatile
Definition: Sema.h:2999
@ NTCUC_FunctionParam
Definition: Sema.h:2983
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:1482
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:3626
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:7549
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:7622
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:6198
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...
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID)
Definition: SemaLookup.cpp:992
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:720
RetainOwnershipKind
Definition: Sema.h:3674
OpaquePtr< QualType > TypeTy
Definition: Sema.h:840
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
Definition: SemaDecl.cpp:18353
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:168
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:270
void PrintContextStack()
Definition: Sema.h:10242
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:2353
bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc, StringRef Keyword)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
Definition: SemaType.cpp:2354
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:607
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e....
SemaOpenMP & OpenMP()
Definition: Sema.h:1012
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:6790
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:6795
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:6799
@ IER_Error
An error occurred.
Definition: Sema.h:6802
@ IER_Exists
The symbol exists.
Definition: Sema.h:6792
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:7227
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:15775
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:4589
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:7475
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
Definition: SemaExpr.cpp:17362
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
Definition: SemaExpr.cpp:15781
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition: Sema.h:913
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
Definition: SemaStmt.cpp:4438
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:6165
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:1563
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition: Sema.h:11358
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:2227
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:814
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Definition: SemaDecl.cpp:18294
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
Definition: Sema.h:3467
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:2604
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:1189
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
Definition: SemaExpr.cpp:12168
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:247
bool hasVisibleDefinition(const NamedDecl *D)
Definition: Sema.h:11634
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:4771
void emitAndClearUnusedLocalTypedefWarnings()
Definition: Sema.cpp:1030
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:16461
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:4752
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:15107
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:803
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:1093
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:992
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:17296
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:1179
@ PCSA_Set
Definition: Sema.h:1179
@ PCSA_Clear
Definition: Sema.h:1179
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:20261
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:276
ConditionKind
Definition: Sema.h:5829
@ 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:890
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:1191
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Definition: Sema.h:11593
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:11364
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:2694
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:7679
@ PartitionImplementation
'module X:Y;'
@ Interface
'export module X;'
@ PartitionInterface
'export module X:Y;'
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
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:796
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:1480
void addAMDGPUMaxNumWorkGroupsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups attribute to a particular declarat...
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
Definition: Sema.h:7422
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:8060
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition: Sema.h:8063
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition: Sema.h:8069
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition: Sema.h:8067
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:1135
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:1073
@ AR_dependent
Definition: Sema.h:1076
@ AR_accessible
Definition: Sema.h:1074
@ AR_inaccessible
Definition: Sema.h:1075
@ AR_delayed
Definition: Sema.h:1077
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:2251
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:11368
@ Normal
Apply the normal rules for complete types.
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA)
Check whether the given statement can have musttail applied to it, issuing a diagnostic and returning...
Definition: SemaStmt.cpp:636
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
Definition: SemaCast.cpp:3367
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:515
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition: Sema.h:5130
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:2113
QualType GetSignedSizelessVectorType(QualType V)
Definition: SemaExpr.cpp:12731
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:10159
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:396
void AddTemplateParametersToLambdaCallOperator(CXXMethodDecl *CallOperator, CXXRecordDecl *Class, TemplateParameterList *TemplateParams)
Definition: SemaLambda.cpp:957
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
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:6366
void deduceOpenCLAddressSpace(ValueDecl *decl)
Definition: SemaDecl.cpp:6947
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3629
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3154
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:1420
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:6278
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:11365
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:1414
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:3806
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:1161
void referenceDLLExportedClassMethods()
AMDGPUFlatWorkGroupSizeAttr * CreateAMDGPUFlatWorkGroupSizeAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
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:18326
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
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:2302
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:3555
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:1491
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
Definition: SemaDecl.cpp:6326
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:17081
void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind, StringRef Arg)
ActOnPragmaMSComment - Called on well formed #pragma comment(kind, "arg").
Definition: SemaAttr.cpp:518
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:268
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Definition: SemaType.cpp:2428
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
Definition: SemaDecl.cpp:4869
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition: Sema.h:1409
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:8524
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
Definition: SemaExpr.cpp:6709
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:12402
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
Definition: SemaDecl.cpp:16677
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:2156
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext)
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation, bool ReportInvalid)
type checking for vector binary operators.
Definition: SemaExpr.cpp:10235
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:2400
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3369
@ 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:18372
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:18472
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition: Sema.cpp:1120
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:1421
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.
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
Definition: SemaExpr.cpp:7573
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:835
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:20046
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:747
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:14715
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
Definition: SemaExpr.cpp:15794
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.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
void ActOnTranslationUnitScope(Scope *S)
Scope actions.
Definition: Sema.cpp:133
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:1456
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition: Sema.h:1017
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:15562
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16447
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:2686
StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:982
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:1499
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:561
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
Definition: SemaExpr.cpp:798
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:8716
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
Definition: SemaDecl.cpp:3493
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition: Sema.h:9066
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition: Sema.h:9077
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:9069
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition: Sema.h:9073
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:647
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:615
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old)
Definition: SemaDecl.cpp:1691
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:7222
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.
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but will create a trap if the resul...
Definition: SemaExpr.cpp:1048
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Definition: SemaExpr.cpp:13865
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:258
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:10176
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
Definition: SemaExpr.cpp:5088
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
Definition: SemaDecl.cpp:20331
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
Definition: SemaExpr.cpp:2005
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
Definition: SemaExpr.cpp:7716
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
Definition: SemaExpr.cpp:14151
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:15217
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
Definition: SemaStmt.cpp:1058
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
ASTContext & Context
Definition: Sema.h:847
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:6191
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:582
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:9930
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:20057
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Definition: SemaDecl.cpp:14737
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:4630
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:7233
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:5775
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
Definition: SemaType.cpp:2667
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:11565
void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc)
ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Definition: SemaAttr.cpp:835
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
Definition: SemaDecl.cpp:5864
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:10183
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
AMDGPUWavesPerEUAttr * CreateAMDGPUWavesPerEUAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
Definition: SemaExpr.cpp:2947
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:513
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:7983
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
Definition: SemaDecl.cpp:20352
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:783
void * SkippedDefinitionContext
Definition: Sema.h:3227
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:11578
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
bool CheckCaseExpression(Expr *E)
Definition: SemaExpr.cpp:21034
void resetFPOptions(FPOptions FPO)
Definition: Sema.h:8694
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition: Sema.h:11651
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:7667
DeclResult ActOnModuleImport(SourceLocation StartLoc, SourceLocation ExportLoc, SourceLocation ImportLoc, ModuleIdPath Path, bool IsPartition=false)
The parser has processed a module import declaration.
Definition: SemaModule.cpp:572
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation IdentLoc, IdentifierInfo &II, CXXScopeSpec *SS=nullptr)
static bool getPrintable(bool B)
Definition: Sema.h:11354
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Definition: SemaLookup.cpp:918
SemaObjC & ObjC()
Definition: Sema.h:1002
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:5374
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
Definition: SemaDecl.cpp:4979
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
Definition: SemaExpr.cpp:12996
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:2641
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:982
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition: SemaDecl.cpp:67
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:5721
@ AllowFold
Definition: Sema.h:5723
@ NoFold
Definition: Sema.h:5722
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:1523
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:799
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition: Sema.h:2277
bool DeclareRISCVSiFiveVectorBuiltins
Indicate RISC-V SiFive vector builtin functions enabled or not.
Definition: Sema.h:11719
PragmaStack< bool > StrictGuardStackCheckStack
Definition: Sema.h:1417
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:2612
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:19525
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:91
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
Definition: SemaExpr.cpp:764
bool isImmediateFunctionContext() const
Definition: Sema.h:6216
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:2403
ASTContext & getASTContext() const
Definition: Sema.h:516
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition: SemaExpr.cpp:776
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:5738
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:15992
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:4778
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:15710
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:975
void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules)
Definition: SemaAttr.cpp:918
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:18817
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:19776
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Definition: SemaDecl.cpp:1756
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:4856
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:15225
NameClassificationKind
Describes the result of the name lookup and resolution performed by ClassifyName().
Definition: Sema.h:2668
@ NC_Unknown
This name is not a type or template in this context, but might be something else.
Definition: Sema.h:2671
@ NC_VarTemplate
The name was classified as a variable template name.
Definition: Sema.h:2698
@ NC_NonType
The name was classified as a specific non-type, non-template declaration.
Definition: Sema.h:2681
@ NC_TypeTemplate
The name was classified as a template whose specializations are types.
Definition: Sema.h:2696
@ NC_Error
Classification failed; an error has been produced.
Definition: Sema.h:2673
@ NC_FunctionTemplate
The name was classified as a function template name.
Definition: Sema.h:2700
@ NC_DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition: Sema.h:2689
@ NC_UndeclaredNonType
The name was classified as an ADL-only function name.
Definition: Sema.h:2685
@ NC_UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition: Sema.h:2702
@ NC_Keyword
The name has been typo-corrected to a keyword.
Definition: Sema.h:2675
@ NC_Type
The name was classified as a type.
Definition: Sema.h:2677
@ NC_OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition: Sema.h:2694
@ NC_Concept
The name was classified as a concept name.
Definition: Sema.h:2704
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:17722
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
Definition: SemaExpr.cpp:9673
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:1413
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: SemaStmt.cpp:4373
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:645
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
Definition: SemaAttr.cpp:230
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:881
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:3577
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:685
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition: Sema.h:1858
ParsingClassState PushParsingClass()
Definition: Sema.h:4801
SmallVector< VarDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
Definition: Sema.h:2622
ForRangeStatus
Definition: Sema.h:8277
@ FRS_Success
Definition: Sema.h:8278
@ FRS_DiagnosticIssued
Definition: Sema.h:8280
@ FRS_NoViableFunction
Definition: Sema.h:8279
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
Definition: SemaExpr.cpp:6236
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:3185
bool isBoundsAttrContext() const
Definition: Sema.h:5136
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:7100
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:15762
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:560
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:7281
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:7225
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:4824
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition: Sema.h:4443
@ 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)
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
Definition: SemaExpr.cpp:7999
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:6971
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:9217
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:7870
@ Conversions
Allow explicit conversion functions but not explicit constructors.
@ All
Allow both explicit conversion functions and explicit constructors.
void ActOnFinishRequiresExpr()
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
Definition: Sema.h:786
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition: Sema.h:4789
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Definition: SemaExpr.cpp:13042
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:20496
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.
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, RetainOwnershipKind K, bool IsTemplateInstantiation)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition: Sema.h:764
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:5531
void ActOnPragmaFPEvalMethod(SourceLocation Loc, LangOptions::FPEvalMethodKind Value)
Definition: SemaAttr.cpp:534
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
Definition: Sema.h:2635
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:1504
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:17035
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
ActOnCXXThrow - Parse throw expressions.
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition: Sema.cpp:2391
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition: Sema.h:2527
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
Definition: SemaDecl.cpp:9073
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
Definition: SemaExpr.cpp:2208
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:415
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:8706
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *AArg, SourceLocation Loc, bool IsDeduced)
void setFunctionHasIndirectGoto()
Definition: Sema.cpp:2312
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...
bool CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall)
QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc)
Build a bit-precise integer type.
Definition: SemaType.cpp:1963
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition: Sema.h:9159
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:9177
@ TPL_TemplateTemplateArgumentMatch
We are matching the template parameter lists of a template template argument against the template par...
Definition: Sema.h:9188
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:9167
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition: Sema.h:9198
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16050
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:3546
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
Definition: Sema.cpp:1518
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9587
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:1677
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:6401
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
Definition: SemaAttr.cpp:285
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:8766
@ 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:693
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:4406
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Definition: SemaExpr.cpp:1975
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
Definition: SemaType.cpp:1553
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
bool isSameOrCompatibleFunctionType(QualType Param, QualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment,...
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Definition: SemaStmt.cpp:1246
AtomicArgumentOrder
Definition: Sema.h:1958
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:2132
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:1269
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
Definition: SemaCast.cpp:384
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
Definition: Sema.cpp:1524
SourceRange getExprRange(Expr *E) const
Definition: SemaExpr.cpp:519
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:3279
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:1123
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:2564
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
Definition: Sema.h:8699
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:637
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:2608
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:6249
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:11361
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition: Sema.h:3362
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
Definition: SemaDecl.cpp:16928
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:511
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition: Sema.h:6360
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:896
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
Definition: SemaExpr.cpp:20292
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:65
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:2150
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:2289
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:11602
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:19807
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:10706
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition: Sema.h:10726
@ UPPC_RequiresClause
Definition: Sema.h:10777
@ UPPC_UsingDeclaration
A using declaration.
Definition: Sema.h:10732
@ UPPC_IfExists
Microsoft __if_exists.
Definition: Sema.h:10759
@ UPPC_Requirement
Definition: Sema.h:10774
@ UPPC_ExceptionType
The type of an exception.
Definition: Sema.h:10750
@ UPPC_EnumeratorValue
The enumerator value.
Definition: Sema.h:10729
@ UPPC_Lambda
Lambda expression.
Definition: Sema.h:10765
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition: Sema.h:10762
@ UPPC_PartialSpecialization
Partial specialization.
Definition: Sema.h:10756
@ UPPC_Initializer
An initializer.
Definition: Sema.h:10741
@ UPPC_BaseType
The base type of a class type.
Definition: Sema.h:10711
@ UPPC_FriendDeclaration
A friend declaration.
Definition: Sema.h:10735
@ UPPC_DefaultArgument
A default argument.
Definition: Sema.h:10744
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition: Sema.h:10714
@ UPPC_Expression
An arbitrary expression.
Definition: Sema.h:10708
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition: Sema.h:10753
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition: Sema.h:10738
@ UPPC_DataMemberType
The type of a data member.
Definition: Sema.h:10717
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition: Sema.h:10723
@ UPPC_Block
Block expression.
Definition: Sema.h:10768
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition: Sema.h:10720
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition: Sema.h:10747
@ UPPC_TypeConstraint
A type constraint.
Definition: Sema.h:10771
api_notes::APINotesManager APINotes
Definition: Sema.h:851
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:9471
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:482
const LangOptions & getLangOpts() const
Definition: Sema.h:509
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:8801
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:4333
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:1720
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12195
SourceLocation CurInitSegLoc
Definition: Sema.h:1453
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:7341
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Definition: SemaExpr.cpp:12971
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition: SemaAttr.cpp:622
SemaCodeCompletion & CodeCompletion()
Definition: Sema.h:987
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition: Sema.h:2629
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:1007
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition: Sema.h:11135
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
Definition: SemaDecl.cpp:1413
ReuseLambdaContextDecl_t
Definition: Sema.h:5193
@ ReuseLambdaContextDecl
Definition: Sema.h:5193
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:6683
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:17397
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:6721
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
Definition: SemaDecl.cpp:1628
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:517
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
Definition: SemaExpr.cpp:2256
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
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.
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:19923
void * OpaqueParser
Definition: Sema.h:894
Preprocessor & PP
Definition: Sema.h:846
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:11017
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
Definition: SemaExpr.cpp:5766
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:6507
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9512
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:14116
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
Definition: Sema.h:1500
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:16721
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
Definition: SemaExpr.cpp:4803
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)
ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op)
Check an increment or decrement of a pseudo-object expression.
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition: Sema.h:887
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:1478
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:8267
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:1916
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:7611
void DiagnoseInvalidExplicitObjectParameterInLambda(CXXMethodDecl *Method)
Definition: SemaLambda.cpp:391
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:2616
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:4754
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)
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:11163
const LangOptions & LangOpts
Definition: Sema.h:845
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:8582
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:15864
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:792
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:6778
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2366
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:6775
static const uint64_t MaximumAlignment
Definition: Sema.h:787
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition: Sema.h:6974
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:17418
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
Definition: SemaInit.cpp:8564
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:11615
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:15405
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:4756
SemaHLSL & HLSL()
Definition: Sema.h:997
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:8715
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:790
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:7280
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:1052
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Definition: SemaDecl.cpp:1885
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
Definition: SemaDecl.cpp:11982
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:18577
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
Definition: SemaExpr.cpp:17382
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:1190
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition: Sema.cpp:99
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.
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:1167
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:4339
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:3695
QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions, IdentifierInfo *Id, bool DirectInit, Expr *&Init)
Definition: SemaLambda.cpp:743
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr)
Definition: SemaType.cpp:9348
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
Definition: SemaExpr.cpp:205
void CheckCXXDefaultArguments(FunctionDecl *FD)
Helpers for dealing with blocks and functions.
ComparisonCategoryUsage
Definition: Sema.h:3835
@ 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:10434
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition: Sema.h:4749
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:19933
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.
WebAssemblyImportModuleAttr * mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL)
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)
Definition: SemaExpr.cpp:9957
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:11356
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:1205
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
Definition: SemaStmt.cpp:3686
PragmaStack< AlignPackInfo > AlignPackStack
Definition: Sema.h:1402
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:15878
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:4848
static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx)
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:5148
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:10208
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:4782
StmtResult ActOnExprStmtError()
Definition: SemaStmt.cpp:69
AcceptableKind
Definition: Sema.h:7276
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:1412
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:3374
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:8728
DeclContext * getCurLexicalContext() const
Definition: Sema.h:691
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition: Sema.h:905
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:1456
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:1511
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:9316
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:7905
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:880
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:842
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:10438
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Definition: SemaExpr.cpp:946
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:17006
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
Definition: Sema.h:1503
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
void ExitDeclaratorContext(Scope *S)
Definition: SemaDecl.cpp:1400
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
Definition: SemaExpr.cpp:15673
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:8419
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition: Sema.cpp:727
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
Definition: SemaStmt.cpp:4473
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:162
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:4541
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Definition: SemaDecl.cpp:12581
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition: Sema.h:11350
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:4800
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:19833
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:881
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:2284
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:14969
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Definition: SemaDecl.cpp:2362
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:2337
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:2730
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
Definition: SemaExpr.cpp:3730
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
Definition: SemaType.cpp:1856
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it's plausible that E was intended to be a template-name.
Definition: Sema.h:2880
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:1936
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Definition: SemaDecl.cpp:20386
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:10485
bool CheckNontrivialField(FieldDecl *FD)
Definition: SemaDecl.cpp:18767
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
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:9725
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
Definition: SemaStmt.cpp:1664
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition: Sema.h:5145
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
Definition: SemaAttr.cpp:1215
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:18252
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)
ActOnBaseSpecifier - Parsed a base 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:2085
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:9714
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
Definition: SemaInit.cpp:10754
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
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:8946
void LateTemplateParserCleanupCB(void *P)
Definition: Sema.h:891
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:4329
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:652
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:10216
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:3273
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:11609
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition: Sema.h:6220
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:1452
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Definition: SemaDecl.cpp:20416
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition: Sema.h:7662
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:8968
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:7326
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:1793
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:1645
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:16239
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
Definition: SemaExpr.cpp:7757
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:15508
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:2322
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
Definition: Sema.h:5171
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:4763
void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init)
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:18243
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
Definition: SemaDecl.cpp:15435
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:985
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:8545
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,...
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
Definition: Sema.h:7363
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:20757
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:275
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:510
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
Definition: SemaDecl.cpp:15009
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition: Sema.h:9472
@ VAK_Invalid
Definition: Sema.h:5981
@ VAK_Valid
Definition: Sema.h:5977
@ VAK_ValidInCXX11
Definition: Sema.h:5978
@ VAK_MSVCUndefined
Definition: Sema.h:5980
@ VAK_Undefined
Definition: Sema.h:5979
void ActOnPragmaMSFunction(SourceLocation Loc, const llvm::SmallVectorImpl< StringRef > &NoBuiltins)
Call on well formed #pragma function.
Definition: SemaAttr.cpp:1151
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
Definition: SemaDecl.cpp:5870
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:10447
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:9548
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
Definition: SemaAttr.cpp:514
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
Definition: SemaExpr.cpp:16603
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition: Sema.h:1578
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
Definition: SemaDecl.cpp:15272
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
Definition: SemaType.cpp:3825
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:790
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:11366
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:8008
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:4628
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:4630
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition: Sema.h:4633
FormatArgumentPassingKind
Definition: Sema.h:1868
@ FAPK_Fixed
Definition: Sema.h:1869
@ FAPK_Variadic
Definition: Sema.h:1870
@ FAPK_VAList
Definition: Sema.h:1871
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:19986
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:6212
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:9705
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition: Sema.cpp:1479
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, NamedReturnInfo &NRInfo, bool SupressSimplerImplicitMoves)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes.
Definition: SemaStmt.cpp:3480
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:7274
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition: Sema.h:6019
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition: Sema.h:6063
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition: Sema.h:6029
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:6087
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:6092
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition: Sema.h:6079
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:6058
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition: Sema.h:6037
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition: Sema.h:6096
@ Compatible
Compatible - the types are compatible according to the standard.
Definition: Sema.h:6021
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition: Sema.h:6048
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition: Sema.h:6100
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:6033
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition: Sema.h:6042
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:6054
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition: Sema.h:6075
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition: Sema.h:6069
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition: Sema.h:6025
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:6083
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)
ActOnCXXNew - Parsed a C++ 'new' expression.
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:8461
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1311
StmtResult ActOnCapturedRegionEnd(Stmt *S)
Definition: SemaStmt.cpp:4645
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition: Sema.h:5862
@ ACK_Arithmetic
An arithmetic operation.
Definition: Sema.h:5864
@ ACK_CompAssign
A compound assignment expression.
Definition: Sema.h:5872
@ ACK_BitwiseOp
A bitwise operation.
Definition: Sema.h:5866
@ ACK_Conditional
A conditional (?:) operator.
Definition: Sema.h:5870
@ ACK_Comparison
A comparison.
Definition: Sema.h:5868
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
Definition: SemaDecl.cpp:4767
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
Definition: SemaExpr.cpp:19880
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
Definition: SemaDecl.cpp:15841
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:11622
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:9363
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, SourceLocation Loc)
DeclClonePragmaWeak - clone existing decl (maybe definition), #pragma weak needs a non-definition dec...
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
bool CheckTypeConstraint(TemplateIdAnnotation *TypeConstraint)
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:2165
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
Definition: SemaStmt.cpp:3169
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
Definition: Sema.h:6412
AMDGPUMaxNumWorkGroupsAttr * CreateAMDGPUMaxNumWorkGroupsAttr(const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
Create an AMDGPUMaxNumWorkGroupsAttr attribute.
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:4194
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16688
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:2626
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition: Sema.h:4982
bool MSStructPragmaOn
Definition: Sema.h:1164
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:20849
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Definition: SemaType.cpp:8953
ExprResult TransformToPotentiallyEvaluated(Expr *E)
Definition: SemaExpr.cpp:17275
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:10192
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:15902
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:11057
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:10401
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:3144
@ NTK_Typedef
Definition: Sema.h:3149
@ NTK_NonUnion
Definition: Sema.h:3147
@ NTK_TypeAlias
Definition: Sema.h:3150
@ NTK_NonClass
Definition: Sema.h:3146
@ NTK_NonEnum
Definition: Sema.h:3148
@ NTK_NonStruct
Definition: Sema.h:3145
@ NTK_TemplateTemplateArgument
Definition: Sema.h:3153
@ NTK_TypeAliasTemplate
Definition: Sema.h:3152
@ NTK_Template
Definition: Sema.h:3151
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition: Sema.h:11597
SourceManager & getSourceManager() const
Definition: Sema.h:514
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
Definition: SemaModule.cpp:725
TryCaptureKind
Definition: Sema.h:5235
@ TryCapture_Implicit
Definition: Sema.h:5236
@ TryCapture_ExplicitByVal
Definition: Sema.h:5237
@ TryCapture_ExplicitByRef
Definition: Sema.h:5238
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9564
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition: Sema.h:6473
AssignmentAction
Definition: Sema.h:5156
@ AA_Returning
Definition: Sema.h:5159
@ AA_Passing_CFAudited
Definition: Sema.h:5164
@ AA_Initializing
Definition: Sema.h:5161
@ AA_Converting
Definition: Sema.h:5160
@ AA_Assigning
Definition: Sema.h:5157
@ AA_Passing
Definition: Sema.h:5158
@ AA_Casting
Definition: Sema.h:5163
@ AA_Sending
Definition: Sema.h:5162
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:3531
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:6742
ExprResult checkPseudoObjectRValue(Expr *E)
bool CheckVecStepExpr(Expr *E)
Definition: SemaExpr.cpp:4467
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
Definition: Sema.cpp:529
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:2579
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:4324
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:824
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
Definition: SemaDecl.cpp:20088
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:1365
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:9247
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:11229
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:3437
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:8872
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:12747
ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
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:504
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
Definition: SemaExpr.cpp:10660
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:7268
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
Definition: SemaExpr.cpp:19489
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Definition: SemaType.cpp:9468
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13704
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition: SemaAttr.cpp:448
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:18229
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:9404
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:1191
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:5515
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:3009
@ NTCUK_Destruct
Definition: Sema.h:3011
@ NTCUK_Init
Definition: Sema.h:3010
@ NTCUK_Copy
Definition: Sema.h:3012
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:922
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:9751
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:1188
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Definition: SemaExpr.cpp:20127
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Definition: SemaDecl.cpp:15930
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
Definition: SemaExpr.cpp:5569
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:7064
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:13959
bool anyAltivecTypes(QualType srcType, QualType destType)
Definition: SemaExpr.cpp:7642
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:7688
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:1250
void keepInLifetimeExtendingContext()
keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext flag from previous context.
Definition: Sema.h:6267
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:2357
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition: Sema.cpp:2144
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:20359
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:1401
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:6369
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
MaybeODRUseExprSet MaybeODRUseExprs
Definition: Sema.h:4980
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:519
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:800
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:1459
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition: Sema.h:6733
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:228
static SourceRange getPrintable(SourceRange R)
Definition: Sema.h:11363
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:20343
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:8301
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:61
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:2060
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:11100
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:3849
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition: Sema.h:11584
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition: Sema.h:697
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15212
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
Definition: Sema.cpp:2692
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:1812
void setFunctionHasMustTail()
Definition: Sema.cpp:2317
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:821
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:7790
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:6408
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
CorrectTypoKind
Definition: Sema.h:7526
@ CTK_NonError
Definition: Sema.h:7527
@ CTK_ErrorRecovery
Definition: Sema.h:7528
void CheckCompleteVariableDeclaration(VarDecl *VD)
Definition: SemaDecl.cpp:14369
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
Definition: SemaInit.cpp:3335
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
TUFragmentKind
Definition: Sema.h:595
@ Global
The global module fragment, between 'module;' and a module-declaration.
Definition: Sema.h:597
@ Private
The private module fragment, between 'module :private;' and the end of the translation unit.
Definition: Sema.h:604
@ Normal
A normal translation unit fragment.
Definition: Sema.h:601
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
void PopSatisfactionStackEntry()
Definition: Sema.h:11106
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
Definition: SemaType.cpp:1791
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:14892
void setFunctionHasBranchProtectedScope()
Definition: Sema.cpp:2307
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition: Sema.h:11643
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:4530
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:1860
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:4774
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
Definition: SemaStmt.cpp:4431
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:593
bool DeclareRISCVVBuiltins
Indicate RISC-V vector builtin functions enabled or not.
Definition: Sema.h:11716
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:11116
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:3209
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9531
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:1046
CCEKind
Contexts in which a converted constant expression is required.
Definition: Sema.h:7947
@ CCEK_StaticAssertMessageSize
Call to size() in a static assert message.
Definition: Sema.h:7954
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
Definition: Sema.h:7952
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
Definition: Sema.h:7953
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:7951
@ CCEK_CaseValue
Expression in a case label.
Definition: Sema.h:7948
@ CCEK_TemplateArg
Value of a non-type template parameter.
Definition: Sema.h:7950
@ CCEK_StaticAssertMessageData
Call to data() in a static assert message.
Definition: Sema.h:7956
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
Definition: Sema.h:7949
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:2616
ExprResult ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, SourceRange Range)
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
Definition: SemaStmt.cpp:1741
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
Definition: SemaDecl.cpp:18834
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:8576
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:1122
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
Definition: SemaDecl.cpp:3157
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:1948
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition: Sema.h:2600
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:291
ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Definition: SemaDecl.cpp:19626
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
Definition: Sema.h:1023
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
Definition: SemaDecl.cpp:12616
ASTConsumer & Consumer
Definition: Sema.h:848
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.
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:3390
OverloadKind
Definition: Sema.h:7846
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
Definition: Sema.h:7857
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:7849
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:7853
PragmaAlignPackDiagnoseKind
Definition: Sema.h:1556
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:5152
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition: SemaExpr.cpp:121
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
Definition: SemaDecl.cpp:2105
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:886
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
Definition: Sema.cpp:1622
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition: Sema.h:10430
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Definition: SemaExpr.cpp:5211
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:7305
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:7689
@ 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:11362
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Definition: SemaExpr.cpp:3625
QualType GetSignedVectorType(QualType V)
Definition: SemaExpr.cpp:12688
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition: Sema.cpp:69
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
Definition: SemaStmt.cpp:4461
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition: Sema.h:823
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:8496
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
Definition: SemaDecl.cpp:16599
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition: Sema.h:4924
@ 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:9436
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
Definition: Sema.h:10200
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:9695
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition: Sema.h:3516
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
Definition: Sema.h:3522
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition: Sema.h:3526
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition: Sema.h:3519
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition: Sema.h:3316
@ AMK_None
Don't merge availability attributes at all.
Definition: Sema.h:3318
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition: Sema.h:3324
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:3327
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition: Sema.h:3330
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition: Sema.h:3321
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
Definition: SemaDecl.cpp:15013
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
Definition: SemaExpr.cpp:6734
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4411
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
Definition: SemaExpr.cpp:4697
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
Definition: SemaType.cpp:5678
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
Definition: SemaDecl.cpp:14678
ExprResult BuildOperatorCoawaitLookupExpr(Scope *S, SourceLocation Loc)
std::pair< SourceLocation, bool > DeleteExprLoc
Definition: Sema.h:559
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:20133
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
Definition: SemaExpr.cpp:4304
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:17229
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:4849
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.
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:2157
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16440
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:5791
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:3543
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:8831
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Definition: SemaDecl.cpp:15357
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:819
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:1358
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaInternal.h:24
void DiagnoseUnterminatedPragmaAttribute()
Definition: SemaAttr.cpp:1129
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:11108
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
Definition: SemaExpr.cpp:20777
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:892
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:19080
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:19123
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Definition: SemaExpr.cpp:7825
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC #pragma optimize in scope,...
Definition: SemaAttr.cpp:1184
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:6419
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:11090
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:2619
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition: Sema.h:7825
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:8137
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:6202
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition: Sema.cpp:83
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:2714
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:17800
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9576
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
Definition: SemaExpr.cpp:19115
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:6363
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
Definition: SemaDecl.cpp:1330
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
Definition: SemaExpr.cpp:7737
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:7675
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
Definition: SemaType.cpp:8772
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
Definition: SemaStmt.cpp:624
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9602
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition: Sema.h:850
TemplateNameIsRequiredTag
Definition: Sema.h:8743
@ TemplateNameIsRequired
Definition: Sema.h:8743
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:4788
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
Definition: SemaExpr.cpp:7898
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:5820
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 addAMDGPUFlatWorkGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size attribute to a particular declar...
void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, StringRef SlotLabel, Expr *Alignment)
ActOnPragmaPack - Called on well formed #pragma pack(...).
Definition: SemaAttr.cpp:334
static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD)
Definition: SemaDecl.cpp:15987
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:4767
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:2416
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Definition: Sema.h:7365
DiagnosticsEngine & Diags
Definition: Sema.h:849
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
Definition: SemaLambda.cpp:932
void DiagnoseUnterminatedPragmaAlignPack()
Definition: SemaAttr.cpp:487
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope)
Definition: SemaStmt.cpp:3236
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:5779
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:510
FPOptions CurFPFeatures
Definition: Sema.h:843
void ActOnStartSEHFinallyBlock()
Definition: SemaStmt.cpp:4423
void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI ABI)
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
static bool CanBeGetReturnObject(const FunctionDecl *FD)
Definition: SemaDecl.cpp:15983
NamespaceDecl * getStdNamespace() const
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9540
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition: Sema.h:4758
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:6746
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
Definition: SemaType.cpp:2086
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Definition: SemaExpr.cpp:528
PragmaStack< StringLiteral * > DataSegStack
Definition: Sema.h:1411
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:650
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:893
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:7672
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
@ TUK_Definition
Definition: Sema.h:3167
@ TUK_Declaration
Definition: Sema.h:3166
@ TUK_Friend
Definition: Sema.h:3168
@ TUK_Reference
Definition: Sema.h:3165
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Definition: SemaInit.cpp:10684
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Definition: SemaDecl.cpp:7320
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:15046
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:8896
@ TPC_ClassTemplate
Definition: Sema.h:8897
@ TPC_FriendFunctionTemplate
Definition: Sema.h:8902
@ TPC_ClassTemplateMember
Definition: Sema.h:8900
@ TPC_FunctionTemplate
Definition: Sema.h:8899
@ TPC_FriendClassTemplate
Definition: Sema.h:8901
@ TPC_FriendFunctionTemplateDefinition
Definition: Sema.h:8903
@ TPC_TypeAliasTemplate
Definition: Sema.h:8904
@ TPC_VarTemplate
Definition: Sema.h:8898
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
Definition: SemaAttr.cpp:1249
void ActOnAbortSEHFinallyBlock()
Definition: SemaStmt.cpp:4427
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:6833
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
Definition: SemaDecl.cpp:16446
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:1757
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:10552
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5643
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:20176
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:1487
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:2123
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
friend class ArgumentPackSubstitutionRAII
Definition: Sema.h:10237
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:1939
void PopDeclContext()
Definition: SemaDecl.cpp:1337
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:2925
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:13093
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:4786
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition: Sema.h:10167
void PrintStats() const
Print out statistics about the semantic analysis.
Definition: Sema.cpp:574
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
Definition: SemaExpr.cpp:15789
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:11353
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:1001
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:6115
FormatStringType
Definition: Sema.h:1891
@ FST_NSString
Definition: Sema.h:1894
@ FST_Unknown
Definition: Sema.h:1901
@ FST_Strftime
Definition: Sema.h:1895
@ FST_Printf
Definition: Sema.h:1893
@ FST_FreeBSDKPrintf
Definition: Sema.h:1898
@ FST_Scanf
Definition: Sema.h:1892
@ FST_Strfmon
Definition: Sema.h:1896
@ FST_OSLog
Definition: Sema.h:1900
@ FST_Kprintf
Definition: Sema.h:1897
@ FST_OSTrace
Definition: Sema.h:1899
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:1162
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:1607
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:12808
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:805
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:1951
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:8484
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition: Sema.h:8492
@ BFRK_Build
Initial building of a for-range statement.
Definition: Sema.h:8486
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:8489
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
Definition: SemaExpr.cpp:8976
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
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:4138
void ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation, PragmaMsStackAction Action, bool Value)
ActOnPragmaMSStrictGuardStackCheck - Called on well formed #pragma strict_gs_check.
Definition: SemaAttr.cpp:774
void ActOnUninitializedDecl(Decl *dcl)
Definition: SemaDecl.cpp:14001
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:13162
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:1590
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
Definition: SemaDecl.cpp:16871
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:9450
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
Definition: Sema.cpp:2349
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition: SemaStmt.cpp:548
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
Definition: SemaExpr.cpp:16251
OffsetOfKind
Definition: Sema.h:3171
@ OOK_Outside
Definition: Sema.h:3173
@ OOK_Macro
Definition: Sema.h:3178
@ OOK_Builtin
Definition: Sema.h:3175
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
Definition: SemaDecl.cpp:13438
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
Definition: SemaType.cpp:9325
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
PragmaSectionKind
Definition: Sema.h:1431
@ PSK_ConstSeg
Definition: Sema.h:1434
@ PSK_DataSeg
Definition: Sema.h:1432
@ PSK_CodeSeg
Definition: Sema.h:1435
@ PSK_BSSSeg
Definition: Sema.h:1433
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:520
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Definition: SemaExpr.cpp:19903
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Definition: Sema.cpp:559
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition: SemaCast.cpp:298
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:16748
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:4588
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:18462
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:17983
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
Definition: SemaExpr.cpp:15833
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:4848
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
Definition: SemaDecl.cpp:4360
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...
bool DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc, const ParsedAttr &AL, bool IsAsync)
Do a check to make sure Name looks like a legal argument for the swift_name attribute applied to decl...
void ActOnCXXForRangeDecl(Decl *D)
Definition: SemaDecl.cpp:14286
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:5993
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
Definition: SemaLambda.cpp:280
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
Definition: SemaType.cpp:2488
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
Definition: SemaExpr.cpp:20234
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:2594
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition: Sema.cpp:1899
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:21042
void CompleteLambdaCallOperator(CXXMethodDecl *Method, SourceLocation LambdaLoc, SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause, TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind, StorageClass SC, ArrayRef< ParmVarDecl * > Params, bool HasExplicitResultType)
Definition: SemaLambda.cpp:968
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
Definition: SemaType.cpp:8860
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15275
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:1187
Decl * ActOnDeclarator(Scope *S, Declarator &D)
Definition: SemaDecl.cpp:6132
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3764
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:909
AbstractDiagSelID
Definition: Sema.h:4543
@ AbstractSynthesizedIvarType
Definition: Sema.h:4550
@ AbstractVariableType
Definition: Sema.h:4547
@ AbstractReturnType
Definition: Sema.h:4545
@ AbstractNone
Definition: Sema.h:4544
@ AbstractFieldType
Definition: Sema.h:4548
@ AbstractArrayType
Definition: Sema.h:4551
@ AbstractParamType
Definition: Sema.h:4546
@ AbstractIvarType
Definition: Sema.h:4549
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:3053
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:909
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
bool 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:7300
PragmaOptionsAlignKind
Definition: Sema.h:1526
@ POAK_Power
Definition: Sema.h:1530
@ POAK_Reset
Definition: Sema.h:1532
@ POAK_Packed
Definition: Sema.h:1529
@ POAK_Mac68k
Definition: Sema.h:1531
@ POAK_Natural
Definition: Sema.h:1528
@ POAK_Native
Definition: Sema.h:1527
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:16089
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:95
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
Definition: SemaExpr.cpp:4921
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)
Definition: SemaDecl.cpp:1730
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition: Sema.h:6405
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:1259
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output)
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:14739
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:980
void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI)
Note that we have finished the explicit captures for the given lambda.
Definition: SemaLambda.cpp:500
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9669
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
Definition: SemaExpr.cpp:9251
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:7919
SwiftNameAttr * mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name)
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:1135
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:6474
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:4771
QualType PreferredConditionType(ConditionKind K) const
Definition: Sema.h:5938
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:7337
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition: Sema.h:7341
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition: Sema.h:7347
@ LOLR_Error
The lookup resulted in an error.
Definition: Sema.h:7339
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:7344
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition: Sema.h:7355
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:7351
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Definition: SemaDecl.cpp:20398
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition: Sema.cpp:2337
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Definition: SemaExpr.cpp:16118
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:10699
CheckConstexprKind
Definition: Sema.h:4694
@ 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:10426
void CheckVariableDeclarationType(VarDecl *NewVD)
Definition: SemaDecl.cpp:8632
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:2706
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:839
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:512
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
Definition: SemaInit.cpp:10669
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...
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
Definition: SemaDecl.cpp:1344
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
Definition: Sema.cpp:597
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:13128
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:2507
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:2805
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:2575
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:1168
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:15867
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:11530
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:13414
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:11132
static ConditionResult ConditionError()
Definition: Sema.h:5816
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition: SemaStmt.cpp:415
void NoteTemplateParameterLocation(const NamedDecl &Decl)
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
Definition: SemaExpr.cpp:6761
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:2523
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:10163
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
Definition: SemaExpr.cpp:20781
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:20059
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:5855
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
Definition: SemaExpr.cpp:16031
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:2298
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:573
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition: Sema.h:8708
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:4260
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:5772
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:701
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:15246
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:6371
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:838
static int getPrintable(int I)
Definition: Sema.h:11352
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:785
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
Definition: Sema.h:7484
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:9634
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition: SemaStmt.cpp:553
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
ExprResult ActOnCXXThis(SourceLocation Loc)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
Definition: Sema.h:2866
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:17808
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:11357
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:1170
@ PCSK_Invalid
Definition: Sema.h:1171
@ PCSK_BSS
Definition: Sema.h:1172
@ PCSK_Data
Definition: Sema.h:1173
@ PCSK_Text
Definition: Sema.h:1175
@ PCSK_Relro
Definition: Sema.h:1176
@ PCSK_Rodata
Definition: Sema.h:1174
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7232
void warnOnReservedIdentifier(const NamedDecl *D)
Definition: SemaDecl.cpp:6119
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition: SemaStmt.cpp:516
bool isCheckingDefaultArgumentOrInitializer() const
Definition: Sema.h:6226
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:16947
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:218
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:7488
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:11355
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:2725
AllocationFunctionScope
The scope in which to find allocation functions.
Definition: Sema.h:6573
@ AFS_Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition: Sema.h:6581
@ AFS_Class
Only look for allocation functions in the scope of the allocated class.
Definition: Sema.h:6578
@ AFS_Global
Only look for allocation functions in the global scope.
Definition: Sema.h:6575
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:5439
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:550
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Definition: SemaType.cpp:2788
PragmaMsStackAction
Definition: Sema.h:1193
@ PSK_Push_Set
Definition: Sema.h:1199
@ PSK_Reset
Definition: Sema.h:1194
@ PSK_Pop_Set
Definition: Sema.h:1200
@ PSK_Show
Definition: Sema.h:1198
@ PSK_Pop
Definition: Sema.h:1197
@ PSK_Set
Definition: Sema.h:1195
@ PSK_Push
Definition: Sema.h:1196
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3136
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:6651
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:5096
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Definition: SemaDecl.cpp:1286
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:823
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:267
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:1773
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3584
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:202
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:4457
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition: ASTConcept.h:231
Represents a declaration of a type.
Definition: Decl.h:3390
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:7331
The base class of the type hierarchy.
Definition: Type.h:1813
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:2465
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3534
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3432
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:6585
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:3197
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3936
A set of unresolved declarations.
Definition: UnresolvedSet.h:61
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:706
Represents a variable declaration or definition.
Definition: Decl.h:918
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:3970
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...
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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:55
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition: Overload.h:845
CUDAFunctionTarget
Definition: Cuda.h:132
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
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:1534
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
std::unique_ptr< sema::RISCVIntrinsicManager > CreateRISCVIntrinsicManager(Sema &S)
TypeOfKind
The kind of 'typeof' expression we're after.
Definition: Type.h:921
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
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...
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:3516
ParameterABI
Kinds of parameter ABI.
Definition: Specifiers.h:363
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
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:6300
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:1033
@ TU_Complete
The translation unit is a complete translation unit.
Definition: LangOptions.h:1035
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:1039
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:424
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: Expr.h:62
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition: Specifiers.h:389
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:237
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:366
@ 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
SourceLocIdentKind
Definition: Expr.h:4714
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:6275
@ 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:1970
CheckedConversionKind
The kind of conversion being performed.
Definition: Sema.h:435
@ 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
Definition: Format.h:5428
#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:93
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A structure used to record information about a failed template argument deduction,...
Describes whether we've seen any nullability information for the given file.
Definition: Sema.h:241
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition: Sema.h:248
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition: Sema.h:244
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition: Sema.h:254
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition: Sema.h:251
Holds information about the various types of exception specification.
Definition: Type.h:4708
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:4710
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:4713
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:4716
Extra information about a function prototype.
Definition: Type.h:4736
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:100
Represents a complete lambda introducer.
Definition: DeclSpec.h:2832
Contains a late templated function.
Definition: Sema.h:11733
CachedTokens Toks
Definition: Sema.h:11734
FPOptions FPO
Floating-point options in the point of definition.
Definition: Sema.h:11738
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:11736
A normalized constraint, as defined in C++ [temp.constr.normal], is either an atomic constraint,...
Definition: SemaConcept.h:81
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1406
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:9719
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:9880
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:9833
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:9849
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:9875
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:9868
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition: Sema.h:9844
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:9836
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition: Sema.h:9862
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition: Sema.h:9852
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:9859
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:9721
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition: Sema.h:9813
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition: Sema.h:9731
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition: Sema.h:9740
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:9759
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition: Sema.h:9810
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:9767
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition: Sema.h:9774
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition: Sema.h:9817
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:9785
@ Memoization
Added for Template instantiation observation.
Definition: Sema.h:9823
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition: Sema.h:9750
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition: Sema.h:9829
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition: Sema.h:9826
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:9747
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:9755
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:9763
@ TemplateInstantiation
We are instantiating a template declaration.
Definition: Sema.h:9724
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition: Sema.h:9777
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition: Sema.h:9781
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition: Sema.h:9736
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:9807
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition: Sema.h:9770
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:9839
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition: Sema.h:9865
ConstraintEvalRAII(InstTy &TI)
Definition: Sema.h:10309
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition: Sema.h:5073
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:4986
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:5018
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition: Sema.h:5020
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:5010
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:5014
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition: Sema.h:5025
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:5033
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition: Sema.h:5029
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition: Sema.h:5039
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:5005
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:5043
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:4991
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:4999
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition: Sema.h:5083
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:5085
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:4988
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:4995
FormatArgumentPassingKind ArgPassingKind
Definition: Sema.h:1879
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:867
A stack object to be created when performing template instantiation.
Definition: Sema.h:9904
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:10058
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:10062
LocalInstantiationScope * Scope
Definition: Sema.h:10545
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:10548
bool isMoveEligible() const
Definition: Sema.h:8521
bool isCopyElidable() const
Definition: Sema.h:8522
const VarDecl * Candidate
Definition: Sema.h:8516
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2367
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition: Sema.h:2373
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:2382
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:2376
SourceLocation CCLoc
The location of the '::'.
Definition: Sema.h:2379
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition: Sema.h:2370
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:2388
SourceLocation LocEnd
Definition: Sema.h:5582
IdentifierInfo * IdentInfo
Definition: Sema.h:5585
brief A function argument from which we performed template argument
Definition: Sema.h:9528
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition: Sema.h:9529
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:1462
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:1465
A push'd group of PragmaAttributeEntries.
Definition: Sema.h:1470
SourceLocation Loc
The location of the push attribute.
Definition: Sema.h:1472
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition: Sema.h:1475
const IdentifierInfo * Namespace
The namespace of this push group.
Definition: Sema.h:1474
SourceLocation PragmaLocation
Definition: Sema.h:1184
PragmaMsStackAction Action
Definition: Sema.h:1204
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:1317
llvm::StringRef StackSlotLabel
Definition: Sema.h:1313
SourceLocation PragmaLocation
Definition: Sema.h:1315
SourceLocation PragmaPushLocation
Definition: Sema.h:1316
ValueType CurrentValue
Definition: Sema.h:1387
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:1373
bool hasValue() const
Definition: Sema.h:1383
SmallVector< Slot, 2 > Stack
Definition: Sema.h:1385
ValueType DefaultValue
Definition: Sema.h:1386
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1388
PragmaStack(const ValueType &Default)
Definition: Sema.h:1380
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition: Sema.h:1324
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition: Sema.h:3756
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition: Sema.h:3750
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition: Sema.h:8077
Abstract class used to diagnose incomplete types.
Definition: Sema.h:6304
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
virtual ~TypeDiagnoser()
Definition: Sema.h:6308
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:1920
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition: Sema.h:1929
std::unique_ptr< TypoCorrectionConsumer > Consumer
Definition: Sema.h:7566
TypoDiagnosticGenerator DiagHandler
Definition: Sema.h:7567
TypoRecoveryCallback RecoveryHandler
Definition: Sema.h:7568
bool CheckSameAsPrevious
Definition: Sema.h:352
NamedDecl * Previous
Definition: Sema.h:353
SkipBodyInfo()=default
NamedDecl * New
Definition: Sema.h:354
Information about a template-id annotation token.