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 ObjCCategoryDecl;
156class ObjCCategoryImplDecl;
157class ObjCCompatibleAliasDecl;
158class ObjCContainerDecl;
159class ObjCImplDecl;
160class ObjCImplementationDecl;
161class ObjCInterfaceDecl;
162class ObjCIvarDecl;
163template <class T> class ObjCList;
164class ObjCMessageExpr;
165class ObjCMethodDecl;
166class ObjCPropertyDecl;
167class ObjCProtocolDecl;
168struct OverloadCandidate;
169enum class OverloadCandidateParamOrder : char;
171class OverloadCandidateSet;
172class OverloadExpr;
173class ParenListExpr;
174class ParmVarDecl;
175class Preprocessor;
176class PseudoDestructorTypeStorage;
177class PseudoObjectExpr;
178class QualType;
179class SemaCUDA;
180class SemaHLSL;
181class SemaOpenACC;
182class SemaOpenMP;
183class SemaSYCL;
184class StandardConversionSequence;
185class Stmt;
186class StringLiteral;
187class SwitchStmt;
188class TemplateArgument;
189class TemplateArgumentList;
190class TemplateArgumentLoc;
191class TemplateDecl;
192class TemplateInstantiationCallback;
193class TemplateParameterList;
194class TemplatePartialOrderingContext;
195class TemplateTemplateParmDecl;
196class Token;
197class TypeAliasDecl;
198class TypedefDecl;
199class TypedefNameDecl;
200class TypeLoc;
201class TypoCorrectionConsumer;
202class UnqualifiedId;
203class UnresolvedLookupExpr;
204class UnresolvedMemberExpr;
205class UnresolvedSetImpl;
206class UnresolvedSetIterator;
207class UsingDecl;
208class UsingShadowDecl;
209class ValueDecl;
210class VarDecl;
211class VarTemplateSpecializationDecl;
212class VisibilityAttr;
213class VisibleDeclConsumer;
214class IndirectFieldDecl;
215struct DeductionFailureInfo;
216class TemplateSpecCandidateSet;
217
218namespace sema {
219class AccessedEntity;
220class BlockScopeInfo;
221class Capture;
222class CapturedRegionScopeInfo;
223class CapturingScopeInfo;
224class CompoundScopeInfo;
225class DelayedDiagnostic;
226class DelayedDiagnosticPool;
227class FunctionScopeInfo;
228class LambdaScopeInfo;
229class PossiblyUnreachableDiag;
230class RISCVIntrinsicManager;
231class SemaPPCallbacks;
232class TemplateDeductionInfo;
233} // namespace sema
234
235namespace threadSafety {
236class BeforeSet;
237void threadSafetyCleanup(BeforeSet *Cache);
238} // namespace threadSafety
239
240// FIXME: No way to easily map from TemplateTypeParmTypes to
241// TemplateTypeParmDecls, so we have this horrible PointerUnion.
242typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *>,
243 SourceLocation>
245
246/// Describes whether we've seen any nullability information for the given
247/// file.
249 /// The first pointer declarator (of any pointer kind) in the file that does
250 /// not have a corresponding nullability annotation.
252
253 /// The end location for the first pointer declarator in the file. Used for
254 /// placing fix-its.
256
257 /// Which kind of pointer declarator we saw.
258 uint8_t PointerKind;
259
260 /// Whether we saw any type nullability annotations in the given file.
261 bool SawTypeNullability = false;
262};
263
264/// A mapping from file IDs to a record of whether we've seen nullability
265/// information in that file.
267 /// A mapping from file IDs to the nullability information for each file ID.
268 llvm::DenseMap<FileID, FileNullability> Map;
269
270 /// A single-element cache based on the file ID.
271 struct {
274 } Cache;
275
276public:
278 // Check the single-element cache.
279 if (file == Cache.File)
280 return Cache.Nullability;
281
282 // It's not in the single-element cache; flush the cache if we have one.
283 if (!Cache.File.isInvalid()) {
284 Map[Cache.File] = Cache.Nullability;
285 }
286
287 // Pull this entry into the cache.
288 Cache.File = file;
289 Cache.Nullability = Map[file];
290 return Cache.Nullability;
291 }
292};
293
294/// Tracks expected type during expression parsing, for use in code completion.
295/// The type is tied to a particular token, all functions that update or consume
296/// the type take a start location of the token they are looking at as a
297/// parameter. This avoids updating the type on hot paths in the parser.
299public:
300 PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {}
301
302 void enterCondition(Sema &S, SourceLocation Tok);
303 void enterReturn(Sema &S, SourceLocation Tok);
305 /// Handles e.g. BaseType{ .D = Tok...
307 const Designation &D);
308 /// Computing a type for the function argument may require running
309 /// overloading, so we postpone its computation until it is actually needed.
310 ///
311 /// Clients should be very careful when using this function, as it stores a
312 /// function_ref, clients should make sure all calls to get() with the same
313 /// location happen while function_ref is alive.
314 ///
315 /// The callback should also emit signature help as a side-effect, but only
316 /// if the completion point has been reached.
318 llvm::function_ref<QualType()> ComputeType);
319
321 void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
322 SourceLocation OpLoc);
323 void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
325 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
326 /// Handles all type casts, including C-style cast, C++ casts, etc.
328
329 /// Get the expected type associated with this location, if any.
330 ///
331 /// If the location is a function argument, determining the expected type
332 /// involves considering all function overloads and the arguments so far.
333 /// In this case, signature help for these function overloads will be reported
334 /// as a side-effect (only if the completion point has been reached).
336 if (!Enabled || Tok != ExpectedLoc)
337 return QualType();
338 if (!Type.isNull())
339 return Type;
340 if (ComputeType)
341 return ComputeType();
342 return QualType();
343 }
344
345private:
346 bool Enabled;
347 /// Start position of a token for which we store expected type.
348 SourceLocation ExpectedLoc;
349 /// Expected type for a token starting at ExpectedLoc.
351 /// A function to compute expected type at ExpectedLoc. It is only considered
352 /// if Type is null.
353 llvm::function_ref<QualType()> ComputeType;
354};
355
357 SkipBodyInfo() = default;
358 bool ShouldSkip = false;
360 NamedDecl *Previous = nullptr;
361 NamedDecl *New = nullptr;
362};
363
364/// Describes the result of template argument deduction.
365///
366/// The TemplateDeductionResult enumeration describes the result of
367/// template argument deduction, as returned from
368/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
369/// structure provides additional information about the results of
370/// template argument deduction, e.g., the deduced template argument
371/// list (if successful) or the specific template parameters or
372/// deduced arguments that were involved in the failure.
374 /// Template argument deduction was successful.
375 Success = 0,
376 /// The declaration was invalid; do nothing.
377 Invalid,
378 /// Template argument deduction exceeded the maximum template
379 /// instantiation depth (which has already been diagnosed).
381 /// Template argument deduction did not deduce a value
382 /// for every template parameter.
384 /// Template argument deduction did not deduce a value for every
385 /// expansion of an expanded template parameter pack.
387 /// Template argument deduction produced inconsistent
388 /// deduced values for the given template parameter.
390 /// Template argument deduction failed due to inconsistent
391 /// cv-qualifiers on a template parameter type that would
392 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
393 /// but were given a non-const "X".
395 /// Substitution of the deduced template argument values
396 /// resulted in an error.
398 /// After substituting deduced template arguments, a dependent
399 /// parameter type did not match the corresponding argument.
401 /// After substituting deduced template arguments, an element of
402 /// a dependent parameter type did not match the corresponding element
403 /// of the corresponding argument (when deducing from an initializer list).
405 /// A non-depnedent component of the parameter did not match the
406 /// corresponding component of the argument.
408 /// When performing template argument deduction for a function
409 /// template, there were too many call arguments.
411 /// When performing template argument deduction for a function
412 /// template, there were too few call arguments.
414 /// The explicitly-specified template arguments were not valid
415 /// template arguments for the given template.
417 /// Checking non-dependent argument conversions failed.
419 /// The deduced arguments did not satisfy the constraints associated
420 /// with the template.
422 /// Deduction failed; that's all we know.
424 /// CUDA Target attributes do not match.
426 /// Some error which was already diagnosed.
428};
429
430/// Kinds of C++ special members.
438 Invalid
439};
440
441/// The kind of conversion being performed.
443 /// An implicit conversion.
444 Implicit,
445 /// A C-style cast.
447 /// A functional-style cast.
449 /// A cast other than a C-style cast.
450 OtherCast,
451 /// A conversion for an operand of a builtin overloaded operator.
453};
454
455/// Sema - This implements semantic analysis and AST building for C.
456/// \nosubgrouping
457class Sema final : public SemaBase {
458 // Table of Contents
459 // -----------------
460 // 1. Semantic Analysis (Sema.cpp)
461 // 2. C++ Access Control (SemaAccess.cpp)
462 // 3. Attributes (SemaAttr.cpp)
463 // 4. Availability Attribute Handling (SemaAvailability.cpp)
464 // 5. Casts (SemaCast.cpp)
465 // 6. Extra Semantic Checking (SemaChecking.cpp)
466 // 7. C++ Coroutines (SemaCoroutine.cpp)
467 // 8. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
468 // 9. Declarations (SemaDecl.cpp)
469 // 10. Declaration Attribute Handling (SemaDeclAttr.cpp)
470 // 11. C++ Declarations (SemaDeclCXX.cpp)
471 // 12. C++ Exception Specifications (SemaExceptionSpec.cpp)
472 // 13. Expressions (SemaExpr.cpp)
473 // 14. C++ Expressions (SemaExprCXX.cpp)
474 // 15. Member Access Expressions (SemaExprMember.cpp)
475 // 16. Initializers (SemaInit.cpp)
476 // 17. C++ Lambda Expressions (SemaLambda.cpp)
477 // 18. Name Lookup (SemaLookup.cpp)
478 // 19. Modules (SemaModule.cpp)
479 // 20. C++ Overloading (SemaOverload.cpp)
480 // 21. Pseudo-Object (SemaPseudoObject.cpp)
481 // 22. Statements (SemaStmt.cpp)
482 // 23. `inline asm` Statement (SemaStmtAsm.cpp)
483 // 24. Statement Attribute Handling (SemaStmtAttr.cpp)
484 // 25. C++ Templates (SemaTemplate.cpp)
485 // 26. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
486 // 27. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
487 // 28. C++ Template Declaration Instantiation
488 // (SemaTemplateInstantiateDecl.cpp)
489 // 29. C++ Variadic Templates (SemaTemplateVariadic.cpp)
490 // 30. Constraints and Concepts (SemaConcept.cpp)
491 // 31. Types (SemaType.cpp)
492 // 32. ObjC Declarations (SemaDeclObjC.cpp)
493 // 33. ObjC Expressions (SemaExprObjC.cpp)
494 // 34. ObjC @property and @synthesize (SemaObjCProperty.cpp)
495 // 35. Code Completion (SemaCodeComplete.cpp)
496 // 36. FixIt Helpers (SemaFixItUtils.cpp)
497 // 37. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp)
498
499 /// \name Semantic Analysis
500 /// Implementations are in Sema.cpp
501 ///@{
502
503public:
504 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
506 CodeCompleteConsumer *CompletionConsumer = nullptr);
507 ~Sema();
508
509 /// Perform initialization that occurs after the parser has been
510 /// initialized but before it parses anything.
511 void Initialize();
512
513 /// This virtual key function only exists to limit the emission of debug info
514 /// describing the Sema class. GCC and Clang only emit debug info for a class
515 /// with a vtable when the vtable is emitted. Sema is final and not
516 /// polymorphic, but the debug info size savings are so significant that it is
517 /// worth adding a vtable just to take advantage of this optimization.
518 virtual void anchor();
519
520 const LangOptions &getLangOpts() const { return LangOpts; }
523
526 Preprocessor &getPreprocessor() const { return PP; }
527 ASTContext &getASTContext() const { return Context; }
531
533 StringRef Platform);
535
536 /// Registers an external source. If an external source already exists,
537 /// creates a multiplex external source and appends to it.
538 ///
539 ///\param[in] E - A non-null external sema source.
540 ///
542
543 void PrintStats() const;
544
545 /// Warn that the stack is nearly exhausted.
547
548 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
549 /// guaranteed). Produces a warning if we're low on stack space and allocates
550 /// more in that case. Use this in code that may recurse deeply (for example,
551 /// in template instantiation) to avoid stack overflow.
553 llvm::function_ref<void()> Fn);
554
555 /// Returns default addr space for method qualifiers.
557
558 /// Load weak undeclared identifiers from the external source.
560
561 /// Determine if VD, which must be a variable or function, is an external
562 /// symbol that nonetheless can't be referenced from outside this translation
563 /// unit because its type has no linkage and it's not extern "C".
564 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
565
566 /// Obtain a sorted list of functions that are undefined but ODR-used.
568 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
569
570 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
572 /// Retrieves list of suspicious delete-expressions that will be checked at
573 /// the end of translation unit.
574 const llvm::MapVector<FieldDecl *, DeleteLocs> &
576
577 /// Cause the active diagnostic on the DiagosticsEngine to be
578 /// emitted. This is closely coupled to the SemaDiagnosticBuilder class and
579 /// should not be used elsewhere.
580 void EmitCurrentDiagnostic(unsigned DiagID);
581
582 void addImplicitTypedef(StringRef Name, QualType T);
583
584 /// Whether uncompilable error has occurred. This includes error happens
585 /// in deferred diagnostics.
586 bool hasUncompilableErrorOccurred() const;
587
588 bool findMacroSpelling(SourceLocation &loc, StringRef name);
589
590 /// Calls \c Lexer::getLocForEndOfToken()
591 SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
592
593 /// Retrieve the module loader associated with the preprocessor.
595
596 /// Invent a new identifier for parameters of abbreviated templates.
599 unsigned Index);
600
602
603 // Emit all deferred diagnostics.
604 void emitDeferredDiags();
605
607 /// The global module fragment, between 'module;' and a module-declaration.
609 /// A normal translation unit fragment. For a non-module unit, this is the
610 /// entire translation unit. Otherwise, it runs from the module-declaration
611 /// to the private-module-fragment (if any) or the end of the TU (if not).
613 /// The private module fragment, between 'module :private;' and the end of
614 /// the translation unit.
615 Private
616 };
617
621
623
624 void PushFunctionScope();
625 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
627
628 /// This is used to inform Sema what the current TemplateParameterDepth
629 /// is during Parsing. Currently it is used to pass on the depth
630 /// when parsing generic lambda 'auto' parameters.
631 void RecordParsingTemplateParameterDepth(unsigned Depth);
632
633 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
635 unsigned OpenMPCaptureLevel = 0);
636
637 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
638 /// time after they've been popped.
640 Sema *Self;
641
642 public:
643 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
645 };
646
648 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
649
652 const Decl *D = nullptr,
653 QualType BlockType = QualType());
654
656
661
662 void PushCompoundScope(bool IsStmtExpr);
663 void PopCompoundScope();
664
666
667 /// Retrieve the current block, if any.
669
670 /// Get the innermost lambda enclosing the current location, if any. This
671 /// looks through intervening non-lambda scopes such as local functions and
672 /// blocks.
674
675 /// Retrieve the current lambda scope info, if any.
676 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
677 /// lambda scope info ignoring all inner capturing scopes that are not
678 /// lambda scopes.
680 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
681
682 /// Retrieve the current generic lambda info, if any.
684
685 /// Retrieve the current captured region, if any.
687
688 void ActOnComment(SourceRange Comment);
689
690 /// Retrieve the parser's current scope.
691 ///
692 /// This routine must only be used when it is certain that semantic analysis
693 /// and the parser are in precisely the same context, which is not the case
694 /// when, e.g., we are performing any kind of template instantiation.
695 /// Therefore, the only safe places to use this scope are in the parser
696 /// itself and in routines directly invoked from the parser and *never* from
697 /// template substitution or instantiation.
698 Scope *getCurScope() const { return CurScope; }
699
701
704 }
705
706 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
707 const FunctionDecl *FD = nullptr);
709 const PartialDiagnostic &PD,
710 const FunctionDecl *FD = nullptr) {
711 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
712 }
713
714 /// Check if the type is allowed to be used for the current target.
716 ValueDecl *D = nullptr);
717
718 // /// The kind of conversion being performed.
719 // enum CheckedConversionKind {
720 // /// An implicit conversion.
721 // CCK_ImplicitConversion,
722 // /// A C-style cast.
723 // CCK_CStyleCast,
724 // /// A functional-style cast.
725 // CCK_FunctionalCast,
726 // /// A cast other than a C-style cast.
727 // CCK_OtherCast,
728 // /// A conversion for an operand of a builtin overloaded operator.
729 // CCK_ForBuiltinOverloadedOp
730 // };
731
732 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
733 /// cast. If there is already an implicit cast, merge into the existing one.
734 /// If isLvalue, the result of the cast is an lvalue.
737 const CXXCastPath *BasePath = nullptr,
739
740 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
741 /// to the conversion from scalar type ScalarTy to the Boolean type.
743
744 /// If \p AllowLambda is true, treat lambda as function.
745 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
746
747 /// Returns a pointer to the innermost enclosing function, or nullptr if the
748 /// current context is not inside a function. If \p AllowLambda is true,
749 /// this can return the call operator of an enclosing lambda, otherwise
750 /// lambdas are skipped when looking for an enclosing function.
751 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
752
753 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
754 /// the method decl for the method being parsed. If we're currently
755 /// in a 'block', this returns the containing context.
757
758 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
759 /// or C function we're in, otherwise return null. If we're currently
760 /// in a 'block', this returns the containing context.
762
763 /// Warn if we're implicitly casting from a _Nullable pointer type to a
764 /// _Nonnull one.
766 SourceLocation Loc);
767
768 /// Warn when implicitly casting 0 to nullptr.
769 void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
770
772 UnavailableAttr::ImplicitReason reason);
773
774 /// Retrieve a suitable printing policy for diagnostics.
777 }
778
779 /// Retrieve a suitable printing policy for diagnostics.
781 const Preprocessor &PP);
782
783 /// Scope actions.
785
786 /// Determine whether \param D is function like (function or function
787 /// template) for parsing.
789
790 /// The maximum alignment, same as in llvm::Value. We duplicate them here
791 /// because that allows us not to duplicate the constants in clang code,
792 /// which we must to since we can't directly use the llvm constants.
793 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
794 ///
795 /// This is the greatest alignment value supported by load, store, and alloca
796 /// instructions, and global values.
797 static const unsigned MaxAlignmentExponent = 32;
798 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
799
800 /// Flag indicating whether or not to collect detailed statistics.
802
803 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
804
805 /// Stack containing information about each of the nested
806 /// function, block, and method scopes that are currently active.
808
809 /// The index of the first FunctionScope that corresponds to the current
810 /// context.
812
813 /// Track the number of currently active capturing scopes.
815
816 llvm::BumpPtrAllocator BumpAlloc;
817
818 /// The kind of translation unit we are processing.
819 ///
820 /// When we're processing a complete translation unit, Sema will perform
821 /// end-of-translation-unit semantic tasks (such as creating
822 /// initializers for tentative definitions in C) once parsing has
823 /// completed. Modules and precompiled headers perform different kinds of
824 /// checks.
826
827 /// Translation Unit Scope - useful to Objective-C actions that need
828 /// to lookup file scope declarations in the "ordinary" C decl namespace.
829 /// For example, user-defined classes, built-in "id" type, etc.
831
833
835 return CurScope->incrementMSManglingNumber();
836 }
837
838 /// Try to recover by turning the given expression into a
839 /// call. Returns true if recovery was attempted or an error was
840 /// emitted; this may also leave the ExprResult invalid.
842 bool ForceComplain = false,
843 bool (*IsPlausibleResult)(QualType) = nullptr);
844
845 /// Figure out if an expression could be turned into a call.
846 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
847 UnresolvedSetImpl &NonTemplateOverloads);
848
852
855
863
864 /// A RAII object to enter scope of a compound statement.
866 public:
867 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
868 S.ActOnStartOfCompoundStmt(IsStmtExpr);
869 }
870
872
873 private:
874 Sema &S;
875 };
876
877 /// An RAII helper that pops function a function scope on exit.
880 bool Active;
883 if (Active)
885 }
886 void disable() { Active = false; }
887 };
888
889 /// Build a partial diagnostic.
890 PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h
891
893 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
894 }
895
896 /// Worker object for performing CFG-based warnings.
899
900 /// Callback to the parser to parse templated functions when needed.
901 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
902 typedef void LateTemplateParserCleanupCB(void *P);
906
908 LateTemplateParserCleanupCB *LTPCleanup, void *P) {
909 LateTemplateParser = LTP;
910 LateTemplateParserCleanup = LTPCleanup;
911 OpaqueParser = P;
912 }
913
914 /// Callback to the parser to parse a type expressed as a string.
915 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
917
918 /// VAListTagName - The declaration name corresponding to __va_list_tag.
919 /// This is used as part of a hack to omit that class from ADL results.
921
922 /// Is the last error level diagnostic immediate. This is used to determined
923 /// whether the next info diagnostic should be immediate.
925
926 class DelayedDiagnostics;
927
929 sema::DelayedDiagnosticPool *SavedPool = nullptr;
931 };
934
935 /// A class which encapsulates the logic for delaying diagnostics
936 /// during parsing and other processing.
938 /// The current pool of diagnostics into which delayed
939 /// diagnostics should go.
940 sema::DelayedDiagnosticPool *CurPool = nullptr;
941
942 public:
944
945 /// Adds a delayed diagnostic.
946 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
947
948 /// Determines whether diagnostics should be delayed.
949 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
950
951 /// Returns the current delayed-diagnostics pool.
952 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
953
954 /// Enter a new scope. Access and deprecation diagnostics will be
955 /// collected in this pool.
958 state.SavedPool = CurPool;
959 CurPool = &pool;
960 return state;
961 }
962
963 /// Leave a delayed-diagnostic state that was previously pushed.
964 /// Do not emit any of the diagnostics. This is performed as part
965 /// of the bookkeeping of popping a pool "properly".
967 CurPool = state.SavedPool;
968 }
969
970 /// Enter a new scope where access and deprecation diagnostics are
971 /// not delayed.
974 state.SavedPool = CurPool;
975 CurPool = nullptr;
976 return state;
977 }
978
979 /// Undo a previous pushUndelayed().
981 assert(CurPool == nullptr);
982 CurPool = state.SavedPool;
983 }
984 } DelayedDiagnostics;
985
987 return DelayedDiagnostics.push(pool);
988 }
989
990 /// Diagnostics that are emitted only if we discover that the given function
991 /// must be codegen'ed. Because handling these correctly adds overhead to
992 /// compilation, this is currently only enabled for CUDA compilations.
993 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
994
995 /// CurContext - This is the current declaration context of parsing.
997
999 assert(CUDAPtr);
1000 return *CUDAPtr;
1001 }
1002
1004 assert(HLSLPtr);
1005 return *HLSLPtr;
1006 }
1007
1009 assert(OpenACCPtr);
1010 return *OpenACCPtr;
1011 }
1012
1014 assert(OpenMPPtr && "SemaOpenMP is dead");
1015 return *OpenMPPtr;
1016 }
1017
1019 assert(SYCLPtr);
1020 return *SYCLPtr;
1021 }
1022
1023protected:
1024 friend class Parser;
1026 friend class ASTReader;
1027 friend class ASTDeclReader;
1028 friend class ASTWriter;
1029
1030private:
1031 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1032 bool WarnedDarwinSDKInfoMissing = false;
1033
1034 Sema(const Sema &) = delete;
1035 void operator=(const Sema &) = delete;
1036
1037 /// Source of additional semantic information.
1039
1040 /// The handler for the FileChanged preprocessor events.
1041 ///
1042 /// Used for diagnostics that implement custom semantic analysis for #include
1043 /// directives, like -Wpragma-pack.
1044 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1045
1046 /// The parser's current scope.
1047 ///
1048 /// The parser maintains this state here.
1049 Scope *CurScope;
1050
1051 mutable IdentifierInfo *Ident_super;
1052
1053 std::unique_ptr<SemaCUDA> CUDAPtr;
1054 std::unique_ptr<SemaHLSL> HLSLPtr;
1055 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1056 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1057 std::unique_ptr<SemaSYCL> SYCLPtr;
1058
1059 ///@}
1060
1061 //
1062 //
1063 // -------------------------------------------------------------------------
1064 //
1065 //
1066
1067 /// \name C++ Access Control
1068 /// Implementations are in SemaAccess.cpp
1069 ///@{
1070
1071public:
1078
1079 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1080 NamedDecl *PrevMemberDecl,
1081 AccessSpecifier LexicalAS);
1082
1084 DeclAccessPair FoundDecl);
1086 DeclAccessPair FoundDecl);
1088 SourceRange PlacementRange,
1089 CXXRecordDecl *NamingClass,
1090 DeclAccessPair FoundDecl,
1091 bool Diagnose = true);
1093 DeclAccessPair FoundDecl,
1094 const InitializedEntity &Entity,
1095 bool IsCopyBindingRefToTemp = false);
1097 DeclAccessPair FoundDecl,
1098 const InitializedEntity &Entity,
1099 const PartialDiagnostic &PDiag);
1101 CXXDestructorDecl *Dtor,
1102 const PartialDiagnostic &PDiag,
1103 QualType objectType = QualType());
1106 CXXRecordDecl *NamingClass,
1107 DeclAccessPair Found);
1110 CXXRecordDecl *DecomposedClass,
1111 DeclAccessPair Field);
1113 const SourceRange &,
1114 DeclAccessPair FoundDecl);
1116 Expr *ArgExpr,
1117 DeclAccessPair FoundDecl);
1119 ArrayRef<Expr *> ArgExprs,
1120 DeclAccessPair FoundDecl);
1122 DeclAccessPair FoundDecl);
1124 QualType Derived, const CXXBasePath &Path,
1125 unsigned DiagID, bool ForceCheck = false,
1126 bool ForceUnprivileged = false);
1127 void CheckLookupAccess(const LookupResult &R);
1128 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1129 QualType BaseType);
1131 DeclAccessPair Found, QualType ObjectType,
1132 SourceLocation Loc,
1133 const PartialDiagnostic &Diag);
1135 DeclAccessPair Found,
1136 QualType ObjectType) {
1137 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1138 SourceLocation(), PDiag());
1139 }
1140
1142 const DependentDiagnostic &DD,
1143 const MultiLevelTemplateArgumentList &TemplateArgs);
1145
1146 ///@}
1147
1148 //
1149 //
1150 // -------------------------------------------------------------------------
1151 //
1152 //
1153
1154 /// \name Attributes
1155 /// Implementations are in SemaAttr.cpp
1156 ///@{
1157
1158public:
1159 /// Controls member pointer representation format under the MS ABI.
1162
1163 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1164
1165 /// Source location for newly created implicit MSInheritanceAttrs
1167
1168 /// pragma clang section kind
1175 PCSK_Relro = 5
1177
1179
1181 std::string SectionName;
1182 bool Valid = false;
1184 };
1185
1191
1193 PSK_Reset = 0x0, // #pragma ()
1194 PSK_Set = 0x1, // #pragma (value)
1195 PSK_Push = 0x2, // #pragma (push[, id])
1196 PSK_Pop = 0x4, // #pragma (pop[, id])
1197 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1198 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1199 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1200 };
1201
1204 StringRef SlotLabel;
1206 };
1207
1208 // #pragma pack and align.
1210 public:
1211 // `Native` represents default align mode, which may vary based on the
1212 // platform.
1213 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1214
1215 // #pragma pack info constructor
1216 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1217 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1218 assert(Num == PackNumber && "The pack number has been truncated.");
1219 }
1220
1221 // #pragma align info constructor
1223 : PackAttr(false), AlignMode(M),
1224 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1225
1226 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1227
1229
1230 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1231 // integer encoding for it. This should only be passed to
1232 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1233 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1234 std::uint32_t Encoding{};
1235 if (Info.IsXLStack())
1236 Encoding |= IsXLMask;
1237
1238 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1239
1240 if (Info.IsPackAttr())
1241 Encoding |= PackAttrMask;
1242
1243 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1244
1245 return Encoding;
1246 }
1247
1248 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1249 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1251 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1252 int PackNumber = (Encoding & PackNumMask) >> 4;
1253
1254 if (Encoding & PackAttrMask)
1255 return AlignPackInfo(M, PackNumber, IsXL);
1256
1257 return AlignPackInfo(M, IsXL);
1258 }
1259
1260 bool IsPackAttr() const { return PackAttr; }
1261
1262 bool IsAlignAttr() const { return !PackAttr; }
1263
1264 Mode getAlignMode() const { return AlignMode; }
1265
1266 unsigned getPackNumber() const { return PackNumber; }
1267
1268 bool IsPackSet() const {
1269 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1270 // attriute on a decl.
1271 return PackNumber != UninitPackVal && PackNumber != 0;
1272 }
1273
1274 bool IsXLStack() const { return XLStack; }
1275
1276 bool operator==(const AlignPackInfo &Info) const {
1277 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1278 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1279 Info.XLStack);
1280 }
1281
1282 bool operator!=(const AlignPackInfo &Info) const {
1283 return !(*this == Info);
1284 }
1285
1286 private:
1287 /// \brief True if this is a pragma pack attribute,
1288 /// not a pragma align attribute.
1289 bool PackAttr;
1290
1291 /// \brief The alignment mode that is in effect.
1292 Mode AlignMode;
1293
1294 /// \brief The pack number of the stack.
1295 unsigned char PackNumber;
1296
1297 /// \brief True if it is a XL #pragma align/pack stack.
1298 bool XLStack;
1299
1300 /// \brief Uninitialized pack value.
1301 static constexpr unsigned char UninitPackVal = -1;
1302
1303 // Masks to encode and decode an AlignPackInfo.
1304 static constexpr uint32_t IsXLMask{0x0000'0001};
1305 static constexpr uint32_t AlignModeMask{0x0000'0006};
1306 static constexpr uint32_t PackAttrMask{0x00000'0008};
1307 static constexpr uint32_t PackNumMask{0x0000'01F0};
1308 };
1309
1310 template <typename ValueType> struct PragmaStack {
1311 struct Slot {
1312 llvm::StringRef StackSlotLabel;
1313 ValueType Value;
1316 Slot(llvm::StringRef StackSlotLabel, ValueType Value,
1321 };
1322
1323 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1324 llvm::StringRef StackSlotLabel, ValueType Value) {
1325 if (Action == PSK_Reset) {
1327 CurrentPragmaLocation = PragmaLocation;
1328 return;
1329 }
1330 if (Action & PSK_Push)
1331 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1332 PragmaLocation);
1333 else if (Action & PSK_Pop) {
1334 if (!StackSlotLabel.empty()) {
1335 // If we've got a label, try to find it and jump there.
1336 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1337 return x.StackSlotLabel == StackSlotLabel;
1338 });
1339 // If we found the label so pop from there.
1340 if (I != Stack.rend()) {
1341 CurrentValue = I->Value;
1342 CurrentPragmaLocation = I->PragmaLocation;
1343 Stack.erase(std::prev(I.base()), Stack.end());
1344 }
1345 } else if (!Stack.empty()) {
1346 // We do not have a label, just pop the last entry.
1347 CurrentValue = Stack.back().Value;
1348 CurrentPragmaLocation = Stack.back().PragmaLocation;
1349 Stack.pop_back();
1350 }
1351 }
1352 if (Action & PSK_Set) {
1354 CurrentPragmaLocation = PragmaLocation;
1355 }
1356 }
1357
1358 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1359 // method body to restore the stacks on exit, so it works like this:
1360 //
1361 // struct S {
1362 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1363 // void Method {}
1364 // #pragma <name>(pop, InternalPragmaSlot)
1365 // };
1366 //
1367 // It works even with #pragma vtordisp, although MSVC doesn't support
1368 // #pragma vtordisp(push [, id], n)
1369 // syntax.
1370 //
1371 // Push / pop a named sentinel slot.
1372 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
1373 assert((Action == PSK_Push || Action == PSK_Pop) &&
1374 "Can only push / pop #pragma stack sentinels!");
1376 }
1377
1378 // Constructors.
1379 explicit PragmaStack(const ValueType &Default)
1381
1382 bool hasValue() const { return CurrentValue != DefaultValue; }
1383
1385 ValueType DefaultValue; // Value used for PSK_Reset action.
1386 ValueType CurrentValue;
1388 };
1389 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
1390 // we shouldn't do so if they're in a module).
1391
1392 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
1393 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
1394 ///
1395 /// 0: Suppress all vtordisps
1396 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
1397 /// structors
1398 /// 2: Always insert vtordisps to support RTTI on partially constructed
1399 /// objects
1402 // The current #pragma align/pack values and locations at each #include.
1407 };
1409 // Segment #pragmas.
1414
1415 // #pragma strict_gs_check.
1417
1418 // This stack tracks the current state of Sema.CurFPFeatures.
1421 FPOptionsOverride result;
1422 if (!FpPragmaStack.hasValue()) {
1423 result = FPOptionsOverride();
1424 } else {
1425 result = FpPragmaStack.CurrentValue;
1426 }
1427 return result;
1428 }
1429
1435 };
1436
1437 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
1438 // Actions should be performed only if we enter / exit a C++ method body.
1440 public:
1441 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
1443
1444 private:
1445 Sema &S;
1446 StringRef SlotLabel;
1447 bool ShouldAct;
1448 };
1449
1450 /// Last section used with #pragma init_seg.
1453
1454 /// Sections used with #pragma alloc_text.
1455 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
1456
1457 /// VisContext - Manages the stack for \#pragma GCC visibility.
1458 void *VisContext; // Really a "PragmaVisStack*"
1459
1460 /// This an attribute introduced by \#pragma clang attribute.
1466 };
1467
1468 /// A push'd group of PragmaAttributeEntries.
1470 /// The location of the push attribute.
1472 /// The namespace of this push group.
1475 };
1476
1478
1479 /// The declaration that is currently receiving an attribute from the
1480 /// #pragma attribute stack.
1482
1483 /// This represents the last location of a "#pragma clang optimize off"
1484 /// directive if such a directive has not been closed by an "on" yet. If
1485 /// optimizations are currently "on", this is set to an invalid location.
1487
1488 /// Get the location for the currently active "\#pragma clang optimize
1489 /// off". If this location is invalid, then the state of the pragma is "on".
1492 }
1493
1494 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
1495 /// whether the optimizations in the list passed to the pragma should be
1496 /// turned off or on. This boolean is true by default because command line
1497 /// options are honored when `#pragma optimize("", on)`.
1498 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
1500
1501 /// Set of no-builtin functions listed by \#pragma function.
1503
1504 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
1505 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
1507
1508 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
1510
1511 /// Add gsl::Pointer attribute to std::container::iterator
1512 /// \param ND The declaration that introduces the name
1513 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
1514 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
1515
1516 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
1518
1519 /// Add [[gsl::Pointer]] attributes for std:: types.
1521
1522 /// Add _Nullable attributes for std:: types.
1524
1526 POAK_Native, // #pragma options align=native
1527 POAK_Natural, // #pragma options align=natural
1528 POAK_Packed, // #pragma options align=packed
1529 POAK_Power, // #pragma options align=power
1530 POAK_Mac68k, // #pragma options align=mac68k
1531 POAK_Reset // #pragma options align=reset
1533
1534 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
1537 PragmaClangSectionKind SecKind,
1538 StringRef SecName);
1539
1540 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
1542 SourceLocation PragmaLoc);
1543
1544 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
1545 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
1546 StringRef SlotLabel, Expr *Alignment);
1547
1548 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
1549 /// (unless they are value dependent or type dependent). Returns false
1550 /// and emits a diagnostic if one or more of the arguments could not be
1551 /// folded into a constant.
1554
1558 };
1559
1561 SourceLocation IncludeLoc);
1563
1564 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
1566
1567 /// ActOnPragmaMSComment - Called on well formed
1568 /// \#pragma comment(kind, "arg").
1570 StringRef Arg);
1571
1572 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
1573 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
1574 StringRef Value);
1575
1576 /// Are precise floating point semantics currently enabled?
1578 return !CurFPFeatures.getAllowFPReassociate() &&
1579 !CurFPFeatures.getNoSignedZero() &&
1580 !CurFPFeatures.getAllowReciprocal() &&
1581 !CurFPFeatures.getAllowApproxFunc();
1582 }
1583
1586
1587 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
1590
1591 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
1592 /// pointers_to_members(representation method[, general purpose
1593 /// representation]).
1596 SourceLocation PragmaLoc);
1597
1598 /// Called on well formed \#pragma vtordisp().
1601
1602 bool UnifySection(StringRef SectionName, int SectionFlags,
1603 NamedDecl *TheDecl);
1604 bool UnifySection(StringRef SectionName, int SectionFlags,
1605 SourceLocation PragmaSectionLocation);
1606
1607 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
1608 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
1609 PragmaMsStackAction Action,
1610 llvm::StringRef StackSlotLabel,
1611 StringLiteral *SegmentName, llvm::StringRef PragmaName);
1612
1613 /// Called on well formed \#pragma section().
1614 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
1615 StringLiteral *SegmentName);
1616
1617 /// Called on well-formed \#pragma init_seg().
1618 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
1619 StringLiteral *SegmentName);
1620
1621 /// Called on well-formed \#pragma alloc_text().
1623 SourceLocation PragmaLocation, StringRef Section,
1624 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
1625 &Functions);
1626
1627 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
1628 /// strict_gs_check.
1630 PragmaMsStackAction Action,
1631 bool Value);
1632
1633 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
1634 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
1635 SourceLocation PragmaLoc);
1636
1637 /// AddCFAuditedAttribute - Check whether we're currently within
1638 /// '\#pragma clang arc_cf_code_audited' and, if so, consider adding
1639 /// the appropriate attribute.
1640 void AddCFAuditedAttribute(Decl *D);
1641
1643 SourceLocation PragmaLoc,
1646 const IdentifierInfo *Namespace);
1647
1648 /// Called on well-formed '\#pragma clang attribute pop'.
1650 const IdentifierInfo *Namespace);
1651
1652 /// Adds the attributes that have been specified using the
1653 /// '\#pragma clang attribute push' directives to the given declaration.
1654 void AddPragmaAttributes(Scope *S, Decl *D);
1655
1657
1659
1660 /// Called on well formed \#pragma clang optimize.
1661 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
1662
1663 /// #pragma optimize("[optimization-list]", on | off).
1664 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
1665
1666 /// Call on well formed \#pragma function.
1667 void
1669 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
1670
1671 /// Only called on function definitions; if there is a pragma in scope
1672 /// with the effect of a range-based optnone, consider marking the function
1673 /// with attribute optnone.
1675
1676 /// Only called on function definitions; if there is a `#pragma alloc_text`
1677 /// that decides which code section the function should be in, add
1678 /// attribute section to the function.
1680
1681 /// Adds the 'optnone' attribute to the function declaration if there
1682 /// are no conflicts; Loc represents the location causing the 'optnone'
1683 /// attribute to be added (usually because of a pragma).
1685
1686 /// Only called on function definitions; if there is a MSVC #pragma optimize
1687 /// in scope, consider changing the function's attributes based on the
1688 /// optimization list passed to the pragma.
1690
1691 /// Only called on function definitions; if there is a pragma in scope
1692 /// with the effect of a range-based no_builtin, consider marking the function
1693 /// with attribute no_builtin.
1695
1696 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
1697 /// add an appropriate visibility attribute.
1699
1700 /// FreeVisContext - Deallocate and null out VisContext.
1701 void FreeVisContext();
1702
1703 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
1704 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
1705 SourceLocation PragmaLoc);
1706
1707 /// ActOnPragmaFPContract - Called on well formed
1708 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
1709 /// \#pragma clang fp contract
1711
1712 /// Called on well formed
1713 /// \#pragma clang fp reassociate
1714 /// or
1715 /// \#pragma clang fp reciprocal
1717 bool IsEnabled);
1718
1719 /// ActOnPragmaFenvAccess - Called on well formed
1720 /// \#pragma STDC FENV_ACCESS
1721 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
1722
1723 /// ActOnPragmaCXLimitedRange - Called on well formed
1724 /// \#pragma STDC CX_LIMITED_RANGE
1727
1728 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
1731
1732 /// Called to set constant rounding mode for floating point operations.
1733 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
1734
1735 /// Called to set exception behavior for floating point operations.
1737
1738 /// PushNamespaceVisibilityAttr - Note that we've entered a
1739 /// namespace with a visibility attribute.
1740 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
1741 SourceLocation Loc);
1742
1743 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
1744 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
1745 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
1746
1747 /// Handles semantic checking for features that are common to all attributes,
1748 /// such as checking whether a parameter was properly specified, or the
1749 /// correct number of arguments were passed, etc. Returns true if the
1750 /// attribute has been diagnosed.
1751 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
1752 bool SkipArgCountCheck = false);
1753 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
1754 bool SkipArgCountCheck = false);
1755
1756 ///@}
1757
1758 //
1759 //
1760 // -------------------------------------------------------------------------
1761 //
1762 //
1763
1764 /// \name Availability Attribute Handling
1765 /// Implementations are in SemaAvailability.cpp
1766 ///@{
1767
1768public:
1769 /// Issue any -Wunguarded-availability warnings in \c FD
1771
1773
1774 /// Retrieve the current function, if any, that should be analyzed for
1775 /// potential availability violations.
1777
1779 const ObjCInterfaceDecl *UnknownObjCClass,
1780 bool ObjCPropertyAccess,
1781 bool AvoidPartialAvailabilityChecks = false,
1782 ObjCInterfaceDecl *ClassReceiver = nullptr);
1783
1784 ///@}
1785
1786 //
1787 //
1788 // -------------------------------------------------------------------------
1789 //
1790 //
1791
1792 /// \name Casts
1793 /// Implementations are in SemaCast.cpp
1794 ///@{
1795
1796public:
1798 return CCK == CheckedConversionKind::CStyleCast ||
1801 }
1802
1803 /// ActOnCXXNamedCast - Parse
1804 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
1806 SourceLocation LAngleBracketLoc, Declarator &D,
1807 SourceLocation RAngleBracketLoc,
1808 SourceLocation LParenLoc, Expr *E,
1809 SourceLocation RParenLoc);
1810
1812 TypeSourceInfo *Ty, Expr *E,
1813 SourceRange AngleBrackets, SourceRange Parens);
1814
1816 ExprResult Operand,
1817 SourceLocation RParenLoc);
1818
1820 Expr *Operand, SourceLocation RParenLoc);
1821
1822 // Checks that reinterpret casts don't have undefined behavior.
1823 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
1824 bool IsDereference, SourceRange Range);
1825
1826 // Checks that the vector type should be initialized from a scalar
1827 // by splatting the value rather than populating a single element.
1828 // This is the case for AltiVecVector types as well as with
1829 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
1830 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
1831
1832 // Checks if the -faltivec-src-compat=gcc option is specified.
1833 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
1834 // treated the same way as they are when trying to initialize
1835 // these vectors on gcc (an error is emitted).
1837 QualType SrcTy);
1838
1840 SourceLocation RParenLoc, Expr *Op);
1841
1843 SourceLocation LParenLoc,
1844 Expr *CastExpr,
1845 SourceLocation RParenLoc);
1846
1847 ///@}
1848
1849 //
1850 //
1851 // -------------------------------------------------------------------------
1852 //
1853 //
1854
1855 /// \name Extra Semantic Checking
1856 /// Implementations are in SemaChecking.cpp
1857 ///@{
1858
1859public:
1860 /// Used to change context to isConstantEvaluated without pushing a heavy
1861 /// ExpressionEvaluationContextRecord object.
1863
1867 }
1868
1870 unsigned ByteNo) const;
1871
1873 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
1874 FAPK_Variadic, // values to format are passed as variadic arguments
1875 FAPK_VAList, // values to format are passed in a va_list
1876 };
1877
1878 // Used to grab the relevant information from a FormatAttr and a
1879 // FunctionDeclaration.
1881 unsigned FormatIdx;
1884 };
1885
1886 static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
1887 bool IsVariadic, FormatStringInfo *FSI);
1888
1889 // Used by C++ template instantiation.
1892 SourceLocation BuiltinLoc,
1893 SourceLocation RParenLoc);
1894
1907 static FormatStringType GetFormatStringType(const FormatAttr *Format);
1908
1909 bool FormatStringHasSArg(const StringLiteral *FExpr);
1910
1911 static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);
1912
1913 void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
1914 BinaryOperatorKind Opcode);
1915
1916 /// Register a magic integral constant to be used as a type tag.
1917 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
1918 uint64_t MagicValue, QualType Type,
1919 bool LayoutCompatible, bool MustBeNull);
1920
1923
1927
1929
1930 /// If true, \c Type should be compared with other expression's types for
1931 /// layout-compatibility.
1932 LLVM_PREFERRED_TYPE(bool)
1934 LLVM_PREFERRED_TYPE(bool)
1935 unsigned MustBeNull : 1;
1936 };
1937
1938 /// A pair of ArgumentKind identifier and magic value. This uniquely
1939 /// identifies the magic value.
1940 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
1941
1942 /// Diagnoses the current set of gathered accesses. This typically
1943 /// happens at full expression level. The set is cleared after emitting the
1944 /// diagnostics.
1946
1947 /// This function checks if the expression is in the sef of potentially
1948 /// misaligned members and it is converted to some pointer type T with lower
1949 /// or equal alignment requirements. If so it removes it. This is used when
1950 /// we do not want to diagnose such misaligned access (e.g. in conversions to
1951 /// void*).
1952 void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
1953
1954 /// This function calls Action when it determines that E designates a
1955 /// misaligned member due to the packed attribute. This is used to emit
1956 /// local diagnostics like in reference binding.
1958 Expr *E,
1959 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
1960 Action);
1961
1962 enum class AtomicArgumentOrder { API, AST };
1964 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
1965 SourceLocation RParenLoc, MultiExprArg Args,
1968
1969 /// Check to see if a given expression could have '.c_str()' called on it.
1970 bool hasCStrMethod(const Expr *E);
1971
1974 bool IsEqual, SourceRange Range);
1975
1977 bool CheckParameterNames);
1978
1979 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
1980
1981 /// checkRetainCycles - Check whether an Objective-C message send
1982 /// might create an obvious retain cycle.
1984 void checkRetainCycles(Expr *receiver, Expr *argument);
1985 void checkRetainCycles(VarDecl *Var, Expr *Init);
1986
1987 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
1988 /// to weak/__unsafe_unretained type.
1989 bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
1990
1991 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
1992 /// to weak/__unsafe_unretained expression.
1993 void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
1994
1995 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
1996 /// statement as a \p Body, and it is located on the same line.
1997 ///
1998 /// This helps prevent bugs due to typos, such as:
1999 /// if (condition);
2000 /// do_stuff();
2001 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2002 unsigned DiagID);
2003
2004 /// Warn if a for/while loop statement \p S, which is followed by
2005 /// \p PossibleBody, has a suspicious null statement as a body.
2006 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2007
2008 /// Warn if a value is moved to itself.
2009 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2010 SourceLocation OpLoc);
2011
2012 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
2020
2021 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2023 const TypeSourceInfo *Derived);
2024
2025 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2026 const FunctionProtoType *Proto);
2027
2028 bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res);
2029 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2030
2031 bool CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
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 CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation loc,
2041 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2042 const FunctionProtoType *Proto);
2043 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2044 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2046 const FunctionProtoType *Proto, SourceLocation Loc);
2047
2048 void checkAIXMemberAlignment(SourceLocation Loc, const Expr *Arg);
2049
2050 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2051 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2052
2053 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2054 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2055 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2056 VariadicCallType CallType);
2057
2058 bool CheckObjCString(Expr *Arg);
2059 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2060
2061 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2062 CallExpr *TheCall);
2063
2064 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2065 CallExpr *TheCall);
2066
2067 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2068
2069 bool CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall,
2070 unsigned MaxWidth);
2071 bool CheckNeonBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2072 CallExpr *TheCall);
2073 bool CheckMVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2074 bool CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2075 bool ParseSVEImmChecks(CallExpr *TheCall,
2076 SmallVector<std::tuple<int, int, int>, 3> &ImmChecks);
2077 bool CheckSMEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2078 bool CheckCDEBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2079 CallExpr *TheCall);
2080 bool CheckARMCoprocessorImmediate(const TargetInfo &TI, const Expr *CoprocArg,
2081 bool WantCDE);
2082 bool CheckARMBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2083 CallExpr *TheCall);
2084
2085 bool CheckAArch64BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2086 CallExpr *TheCall);
2087 bool CheckBPFBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2088 bool CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2089 bool CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall);
2090 bool CheckMipsBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2091 CallExpr *TheCall);
2092 bool CheckMipsBuiltinCpu(const TargetInfo &TI, unsigned BuiltinID,
2093 CallExpr *TheCall);
2094 bool CheckMipsBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall);
2095 bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2096 bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);
2097 bool CheckX86BuiltinGatherScatterScale(unsigned BuiltinID, CallExpr *TheCall);
2098 bool CheckX86BuiltinTileArguments(unsigned BuiltinID, CallExpr *TheCall);
2099 bool CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall,
2100 ArrayRef<int> ArgNums);
2101 bool CheckX86BuiltinTileDuplicate(CallExpr *TheCall, ArrayRef<int> ArgNums);
2102 bool CheckX86BuiltinTileRangeAndDuplicate(CallExpr *TheCall,
2103 ArrayRef<int> ArgNums);
2104 bool CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2105 CallExpr *TheCall);
2106 bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2107 CallExpr *TheCall);
2108 bool CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
2109 bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum);
2110 bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2111 CallExpr *TheCall);
2112 void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D,
2113 const llvm::StringMap<bool> &FeatureMap);
2114 bool CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI,
2115 unsigned BuiltinID, CallExpr *TheCall);
2116 bool CheckWebAssemblyBuiltinFunctionCall(const TargetInfo &TI,
2117 unsigned BuiltinID,
2118 CallExpr *TheCall);
2119 bool CheckNVPTXBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2120 CallExpr *TheCall);
2121
2122 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2123 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2124 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2125 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2126 unsigned BuiltinID);
2127 bool BuiltinComplex(CallExpr *TheCall);
2128 bool BuiltinVSX(CallExpr *TheCall);
2129 bool BuiltinOSLogFormat(CallExpr *TheCall);
2130 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2131
2132 bool BuiltinPrefetch(CallExpr *TheCall);
2133 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2134 bool BuiltinArithmeticFence(CallExpr *TheCall);
2135 bool BuiltinAssume(CallExpr *TheCall);
2136 bool BuiltinAssumeAligned(CallExpr *TheCall);
2137 bool BuiltinLongjmp(CallExpr *TheCall);
2138 bool BuiltinSetjmp(CallExpr *TheCall);
2139 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2140 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2141 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2143 bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result);
2144 bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High,
2145 bool RangeIsError = true);
2146 bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
2147 unsigned Multiple);
2148 bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum);
2149 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
2150 unsigned ArgBits);
2151 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
2152 unsigned ArgBits);
2153 bool BuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall, int ArgNum,
2154 unsigned ExpectedFieldNum, bool AllowName);
2155 bool BuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall);
2156 bool BuiltinPPCMMACall(CallExpr *TheCall, unsigned BuiltinID,
2157 const char *TypeDesc);
2158
2159 bool CheckPPCMMAType(QualType Type, SourceLocation TypeLoc);
2160
2161 bool BuiltinElementwiseMath(CallExpr *TheCall);
2162 bool BuiltinElementwiseTernaryMath(CallExpr *TheCall,
2163 bool CheckForFloatArgs = true);
2164 bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall);
2165 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
2166
2167 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
2168
2169 // Matrix builtin handling.
2170 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
2171 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
2172 ExprResult CallResult);
2173 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
2174 ExprResult CallResult);
2175
2176 // WebAssembly builtin handling.
2177 bool BuiltinWasmRefNullExtern(CallExpr *TheCall);
2178 bool BuiltinWasmRefNullFunc(CallExpr *TheCall);
2179 bool BuiltinWasmTableGet(CallExpr *TheCall);
2180 bool BuiltinWasmTableSet(CallExpr *TheCall);
2181 bool BuiltinWasmTableSize(CallExpr *TheCall);
2182 bool BuiltinWasmTableGrow(CallExpr *TheCall);
2183 bool BuiltinWasmTableFill(CallExpr *TheCall);
2184 bool BuiltinWasmTableCopy(CallExpr *TheCall);
2185
2186 bool CheckFormatArguments(const FormatAttr *Format,
2187 ArrayRef<const Expr *> Args, bool IsCXXMember,
2188 VariadicCallType CallType, SourceLocation Loc,
2189 SourceRange Range,
2190 llvm::SmallBitVector &CheckedVarArgs);
2191 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
2192 FormatArgumentPassingKind FAPK, unsigned format_idx,
2193 unsigned firstDataArg, FormatStringType Type,
2194 VariadicCallType CallType, SourceLocation Loc,
2195 SourceRange range,
2196 llvm::SmallBitVector &CheckedVarArgs);
2197
2198 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
2199
2200 void CheckAbsoluteValueFunction(const CallExpr *Call,
2201 const FunctionDecl *FDecl);
2202
2203 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
2204
2205 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
2206 IdentifierInfo *FnName);
2207
2208 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2209
2210 void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2211
2212 void CheckFreeArguments(const CallExpr *E);
2213
2214 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
2215 SourceLocation ReturnLoc, bool isObjCMethod = false,
2216 const AttrVec *Attrs = nullptr,
2217 const FunctionDecl *FD = nullptr);
2218
2219 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
2220 void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
2221 void CheckForIntOverflow(const Expr *E);
2222 void CheckUnsequencedOperations(const Expr *E);
2223
2224 /// Perform semantic checks on a completed expression. This will either
2225 /// be a full-expression or a default argument expression.
2226 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
2227 bool IsConstexpr = false);
2228
2229 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
2230 Expr *Init);
2231 /// Check whether receiver is mutable ObjC container which
2232 /// attempts to add itself into the container
2233 void CheckObjCCircularContainer(ObjCMessageExpr *Message);
2234
2235 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2236 const NamedDecl *Callee);
2237
2238 /// A map from magic value to type information.
2239 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
2240 TypeTagForDatatypeMagicValues;
2241
2242 /// Peform checks on a call of a function with argument_with_type_tag
2243 /// or pointer_with_type_tag attributes.
2244 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
2245 const ArrayRef<const Expr *> ExprArgs,
2246 SourceLocation CallSiteLoc);
2247
2248 /// Check if we are taking the address of a packed field
2249 /// as this may be a problem if the pointer value is dereferenced.
2250 void CheckAddressOfPackedMember(Expr *rhs);
2251
2252 /// Helper class that collects misaligned member designations and
2253 /// their location info for delayed diagnostics.
2254 struct MisalignedMember {
2255 Expr *E;
2256 RecordDecl *RD;
2257 ValueDecl *MD;
2258 CharUnits Alignment;
2259
2260 MisalignedMember() : E(), RD(), MD() {}
2261 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
2262 CharUnits Alignment)
2263 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
2264 explicit MisalignedMember(Expr *E)
2265 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
2266
2267 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
2268 };
2269 /// Small set of gathered accesses to potentially misaligned members
2270 /// due to the packed attribute.
2271 SmallVector<MisalignedMember, 4> MisalignedMembers;
2272
2273 /// Adds an expression to the set of gathered misaligned members.
2274 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
2275 CharUnits Alignment);
2276 ///@}
2277
2278 //
2279 //
2280 // -------------------------------------------------------------------------
2281 //
2282 //
2283
2284 /// \name C++ Coroutines
2285 /// Implementations are in SemaCoroutine.cpp
2286 ///@{
2287
2288public:
2289 /// The C++ "std::coroutine_traits" template, which is defined in
2290 /// <coroutine_traits>
2292
2294 StringRef Keyword);
2298
2301 UnresolvedLookupExpr *Lookup);
2303 Expr *Awaiter, bool IsImplicit = false);
2305 UnresolvedLookupExpr *Lookup);
2308 bool IsImplicit = false);
2313
2314 // As a clang extension, enforces that a non-coroutine function must be marked
2315 // with [[clang::coro_wrapper]] if it returns a type marked with
2316 // [[clang::coro_return_type]].
2317 // Expects that FD is not a coroutine.
2319 /// Lookup 'coroutine_traits' in std namespace and std::experimental
2320 /// namespace. The namespace found is recorded in Namespace.
2322 SourceLocation FuncLoc);
2323 /// Check that the expression co_await promise.final_suspend() shall not be
2324 /// potentially-throwing.
2325 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
2326
2327 ///@}
2328
2329 //
2330 //
2331 // -------------------------------------------------------------------------
2332 //
2333 //
2334
2335 /// \name C++ Scope Specifiers
2336 /// Implementations are in SemaCXXScopeSpec.cpp
2337 ///@{
2338
2339public:
2340 // Marks SS invalid if it represents an incomplete type.
2342 // Complete an enum decl, maybe without a scope spec.
2344 CXXScopeSpec *SS = nullptr);
2345
2348 bool EnteringContext = false);
2351
2352 /// The parser has parsed a global nested-name-specifier '::'.
2353 ///
2354 /// \param CCLoc The location of the '::'.
2355 ///
2356 /// \param SS The nested-name-specifier, which will be updated in-place
2357 /// to reflect the parsed nested-name-specifier.
2358 ///
2359 /// \returns true if an error occurred, false otherwise.
2361
2362 /// The parser has parsed a '__super' nested-name-specifier.
2363 ///
2364 /// \param SuperLoc The location of the '__super' keyword.
2365 ///
2366 /// \param ColonColonLoc The location of the '::'.
2367 ///
2368 /// \param SS The nested-name-specifier, which will be updated in-place
2369 /// to reflect the parsed nested-name-specifier.
2370 ///
2371 /// \returns true if an error occurred, false otherwise.
2373 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
2374
2376 bool *CanCorrect = nullptr);
2378
2379 /// Keeps information about an identifier in a nested-name-spec.
2380 ///
2382 /// The type of the object, if we're parsing nested-name-specifier in
2383 /// a member access expression.
2385
2386 /// The identifier preceding the '::'.
2388
2389 /// The location of the identifier.
2391
2392 /// The location of the '::'.
2394
2395 /// Creates info object for the most typical case.
2397 SourceLocation ColonColonLoc,
2398 ParsedType ObjectType = ParsedType())
2399 : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
2400 CCLoc(ColonColonLoc) {}
2401
2403 SourceLocation ColonColonLoc, QualType ObjectType)
2404 : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
2405 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
2406 };
2407
2408 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2409 bool EnteringContext, CXXScopeSpec &SS,
2410 NamedDecl *ScopeLookupResult,
2411 bool ErrorRecoveryLookup,
2412 bool *IsCorrectedToColon = nullptr,
2413 bool OnlyNamespace = false);
2414
2415 /// The parser has parsed a nested-name-specifier 'identifier::'.
2416 ///
2417 /// \param S The scope in which this nested-name-specifier occurs.
2418 ///
2419 /// \param IdInfo Parser information about an identifier in the
2420 /// nested-name-spec.
2421 ///
2422 /// \param EnteringContext Whether we're entering the context nominated by
2423 /// this nested-name-specifier.
2424 ///
2425 /// \param SS The nested-name-specifier, which is both an input
2426 /// parameter (the nested-name-specifier before this type) and an
2427 /// output parameter (containing the full nested-name-specifier,
2428 /// including this new type).
2429 ///
2430 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
2431 /// are allowed. The bool value pointed by this parameter is set to 'true'
2432 /// if the identifier is treated as if it was followed by ':', not '::'.
2433 ///
2434 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2435 ///
2436 /// \returns true if an error occurred, false otherwise.
2437 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2438 bool EnteringContext, CXXScopeSpec &SS,
2439 bool *IsCorrectedToColon = nullptr,
2440 bool OnlyNamespace = false);
2441
2442 /// The parser has parsed a nested-name-specifier
2443 /// 'template[opt] template-name < template-args >::'.
2444 ///
2445 /// \param S The scope in which this nested-name-specifier occurs.
2446 ///
2447 /// \param SS The nested-name-specifier, which is both an input
2448 /// parameter (the nested-name-specifier before this type) and an
2449 /// output parameter (containing the full nested-name-specifier,
2450 /// including this new type).
2451 ///
2452 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
2453 /// \param TemplateName the template name.
2454 /// \param TemplateNameLoc The location of the template name.
2455 /// \param LAngleLoc The location of the opening angle bracket ('<').
2456 /// \param TemplateArgs The template arguments.
2457 /// \param RAngleLoc The location of the closing angle bracket ('>').
2458 /// \param CCLoc The location of the '::'.
2459 ///
2460 /// \param EnteringContext Whether we're entering the context of the
2461 /// nested-name-specifier.
2462 ///
2463 ///
2464 /// \returns true if an error occurred, false otherwise.
2466 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
2467 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
2468 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
2469 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
2470
2472 SourceLocation ColonColonLoc);
2473
2475 const DeclSpec &DS,
2476 SourceLocation ColonColonLoc,
2477 QualType Type);
2478
2480 NestedNameSpecInfo &IdInfo,
2481 bool EnteringContext);
2482
2483 /// Given a C++ nested-name-specifier, produce an annotation value
2484 /// that the parser can use later to reconstruct the given
2485 /// nested-name-specifier.
2486 ///
2487 /// \param SS A nested-name-specifier.
2488 ///
2489 /// \returns A pointer containing all of the information in the
2490 /// nested-name-specifier \p SS.
2492
2493 /// Given an annotation pointer for a nested-name-specifier, restore
2494 /// the nested-name-specifier structure.
2495 ///
2496 /// \param Annotation The annotation pointer, produced by
2497 /// \c SaveNestedNameSpecifierAnnotation().
2498 ///
2499 /// \param AnnotationRange The source range corresponding to the annotation.
2500 ///
2501 /// \param SS The nested-name-specifier that will be updated with the contents
2502 /// of the annotation pointer.
2503 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
2504 SourceRange AnnotationRange,
2505 CXXScopeSpec &SS);
2506
2507 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2508
2509 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2510 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2511 /// After this method is called, according to [C++ 3.4.3p3], names should be
2512 /// looked up in the declarator-id's scope, until the declarator is parsed and
2513 /// ActOnCXXExitDeclaratorScope is called.
2514 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2516
2517 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2518 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2519 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2520 /// Used to indicate that names should revert to being looked up in the
2521 /// defining scope.
2523
2524 ///@}
2525
2526 //
2527 //
2528 // -------------------------------------------------------------------------
2529 //
2530 //
2531
2532 /// \name Declarations
2533 /// Implementations are in SemaDecl.cpp
2534 ///@{
2535
2536public:
2538
2539 /// The index of the first InventedParameterInfo that refers to the current
2540 /// context.
2542
2543 /// A RAII object to temporarily push a declaration context.
2545 private:
2546 Sema &S;
2547 DeclContext *SavedContext;
2548 ProcessingContextState SavedContextState;
2549 QualType SavedCXXThisTypeOverride;
2550 unsigned SavedFunctionScopesStart;
2551 unsigned SavedInventedParameterInfosStart;
2552
2553 public:
2554 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
2555 : S(S), SavedContext(S.CurContext),
2556 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
2557 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
2558 SavedFunctionScopesStart(S.FunctionScopesStart),
2559 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
2560 assert(ContextToPush && "pushing null context");
2561 S.CurContext = ContextToPush;
2562 if (NewThisContext)
2563 S.CXXThisTypeOverride = QualType();
2564 // Any saved FunctionScopes do not refer to this context.
2565 S.FunctionScopesStart = S.FunctionScopes.size();
2566 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
2567 }
2568
2569 void pop() {
2570 if (!SavedContext)
2571 return;
2572 S.CurContext = SavedContext;
2573 S.DelayedDiagnostics.popUndelayed(SavedContextState);
2574 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
2575 S.FunctionScopesStart = SavedFunctionScopesStart;
2576 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
2577 SavedContext = nullptr;
2578 }
2579
2580 ~ContextRAII() { pop(); }
2581 };
2582
2583 void DiagnoseInvalidJumps(Stmt *Body);
2584
2585 /// The function definitions which were renamed as part of typo-correction
2586 /// to match their respective declarations. We want to keep track of them
2587 /// to ensure that we don't emit a "redefinition" error if we encounter a
2588 /// correctly named definition after the renamed definition.
2590
2591 /// A cache of the flags available in enumerations with the flag_bits
2592 /// attribute.
2593 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
2594
2595 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
2596 /// declared. Rare. May alias another identifier, declared or undeclared.
2597 ///
2598 /// For aliases, the target identifier is used as a key for eventual
2599 /// processing when the target is declared. For the single-identifier form,
2600 /// the sole identifier is used as the key. Each entry is a `SetVector`
2601 /// (ordered by parse order) of aliases (identified by the alias name) in case
2602 /// of multiple aliases to the same undeclared identifier.
2603 llvm::MapVector<
2605 llvm::SetVector<
2607 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
2609
2610 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
2611 /// \#pragma redefine_extname before declared. Used in Solaris system headers
2612 /// to define functions that occur in multiple standards to call the version
2613 /// in the currently selected standard.
2614 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
2615
2616 /// Set containing all typedefs that are likely unused.
2619
2623
2624 /// The set of file scoped decls seen so far that have not been used
2625 /// and must warn if not used. Only contains the first declaration.
2627
2631
2632 /// All the tentative definitions encountered in the TU.
2634
2635 /// All the external declarations encoutered and used in the TU.
2637
2638 /// Generally null except when we temporarily switch decl contexts,
2639 /// like in \see ActOnObjCTemporaryExitContainerContext.
2641
2642 /// Is the module scope we are in a C++ Header Unit?
2644 return ModuleScopes.empty() ? false
2645 : ModuleScopes.back().Module->isHeaderUnit();
2646 }
2647
2648 /// Get the module owning an entity.
2649 Module *getOwningModule(const Decl *Entity) {
2650 return Entity->getOwningModule();
2651 }
2652
2653 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
2654
2656 Scope *S, CXXScopeSpec *SS = nullptr,
2657 bool isClassName = false, bool HasTrailingDot = false,
2658 ParsedType ObjectType = nullptr,
2659 bool IsCtorOrDtorName = false,
2660 bool WantNontrivialTypeSourceInfo = false,
2661 bool IsClassTemplateDeductionContext = true,
2662 ImplicitTypenameContext AllowImplicitTypename =
2664 IdentifierInfo **CorrectedII = nullptr);
2666 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
2668 Scope *S, CXXScopeSpec *SS,
2669 ParsedType &SuggestedType,
2670 bool IsTemplateName = false);
2671
2672 /// Attempt to behave like MSVC in situations where lookup of an unqualified
2673 /// type name has failed in a dependent context. In these situations, we
2674 /// automatically form a DependentTypeName that will retry lookup in a related
2675 /// scope during instantiation.
2677 SourceLocation NameLoc,
2678 bool IsTemplateTypeArg);
2679
2680 /// Describes the result of the name lookup and resolution performed
2681 /// by \c ClassifyName().
2683 /// This name is not a type or template in this context, but might be
2684 /// something else.
2686 /// Classification failed; an error has been produced.
2688 /// The name has been typo-corrected to a keyword.
2690 /// The name was classified as a type.
2692 /// The name was classified as a specific non-type, non-template
2693 /// declaration. ActOnNameClassifiedAsNonType should be called to
2694 /// convert the declaration to an expression.
2696 /// The name was classified as an ADL-only function name.
2697 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
2698 /// result to an expression.
2700 /// The name denotes a member of a dependent type that could not be
2701 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
2702 /// convert the result to an expression.
2704 /// The name was classified as an overload set, and an expression
2705 /// representing that overload set has been formed.
2706 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
2707 /// expression referencing the overload set.
2709 /// The name was classified as a template whose specializations are types.
2711 /// The name was classified as a variable template name.
2713 /// The name was classified as a function template name.
2715 /// The name was classified as an ADL-only function template name.
2717 /// The name was classified as a concept name.
2719 };
2720
2723 union {
2728 };
2729
2730 explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
2731
2732 public:
2734
2735 NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
2736
2737 static NameClassification Error() { return NameClassification(NC_Error); }
2738
2740 return NameClassification(NC_Unknown);
2741 }
2742
2744 NameClassification Result(NC_OverloadSet);
2745 Result.Expr = E;
2746 return Result;
2747 }
2748
2750 NameClassification Result(NC_NonType);
2751 Result.NonTypeDecl = D;
2752 return Result;
2753 }
2754
2756 return NameClassification(NC_UndeclaredNonType);
2757 }
2758
2760 return NameClassification(NC_DependentNonType);
2761 }
2762
2764 NameClassification Result(NC_TypeTemplate);
2765 Result.Template = Name;
2766 return Result;
2767 }
2768
2770 NameClassification Result(NC_VarTemplate);
2771 Result.Template = Name;
2772 return Result;
2773 }
2774
2776 NameClassification Result(NC_FunctionTemplate);
2777 Result.Template = Name;
2778 return Result;
2779 }
2780
2782 NameClassification Result(NC_Concept);
2783 Result.Template = Name;
2784 return Result;
2785 }
2786
2788 NameClassification Result(NC_UndeclaredTemplate);
2789 Result.Template = Name;
2790 return Result;
2791 }
2792
2793 NameClassificationKind getKind() const { return Kind; }
2794
2796 assert(Kind == NC_OverloadSet);
2797 return Expr;
2798 }
2799
2801 assert(Kind == NC_Type);
2802 return Type;
2803 }
2804
2806 assert(Kind == NC_NonType);
2807 return NonTypeDecl;
2808 }
2809
2811 assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
2812 Kind == NC_VarTemplate || Kind == NC_Concept ||
2813 Kind == NC_UndeclaredTemplate);
2814 return Template;
2815 }
2816
2818 switch (Kind) {
2819 case NC_TypeTemplate:
2820 return TNK_Type_template;
2821 case NC_FunctionTemplate:
2822 return TNK_Function_template;
2823 case NC_VarTemplate:
2824 return TNK_Var_template;
2825 case NC_Concept:
2826 return TNK_Concept_template;
2827 case NC_UndeclaredTemplate:
2829 default:
2830 llvm_unreachable("unsupported name classification.");
2831 }
2832 }
2833 };
2834
2835 /// Perform name lookup on the given name, classifying it based on
2836 /// the results of name lookup and the following token.
2837 ///
2838 /// This routine is used by the parser to resolve identifiers and help direct
2839 /// parsing. When the identifier cannot be found, this routine will attempt
2840 /// to correct the typo and classify based on the resulting name.
2841 ///
2842 /// \param S The scope in which we're performing name lookup.
2843 ///
2844 /// \param SS The nested-name-specifier that precedes the name.
2845 ///
2846 /// \param Name The identifier. If typo correction finds an alternative name,
2847 /// this pointer parameter will be updated accordingly.
2848 ///
2849 /// \param NameLoc The location of the identifier.
2850 ///
2851 /// \param NextToken The token following the identifier. Used to help
2852 /// disambiguate the name.
2853 ///
2854 /// \param CCC The correction callback, if typo correction is desired.
2855 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
2856 IdentifierInfo *&Name, SourceLocation NameLoc,
2857 const Token &NextToken,
2858 CorrectionCandidateCallback *CCC = nullptr);
2859
2860 /// Act on the result of classifying a name as an undeclared (ADL-only)
2861 /// non-type declaration.
2863 SourceLocation NameLoc);
2864 /// Act on the result of classifying a name as an undeclared member of a
2865 /// dependent base class.
2867 IdentifierInfo *Name,
2868 SourceLocation NameLoc,
2869 bool IsAddressOfOperand);
2870 /// Act on the result of classifying a name as a specific non-type
2871 /// declaration.
2873 NamedDecl *Found,
2874 SourceLocation NameLoc,
2875 const Token &NextToken);
2876 /// Act on the result of classifying a name as an overload set.
2878
2879 /// Describes the detailed kind of a template name. Used in diagnostics.
2886 Concept,
2888 };
2891
2892 /// Determine whether it's plausible that E was intended to be a
2893 /// template-name.
2895 if (!getLangOpts().CPlusPlus || E.isInvalid())
2896 return false;
2897 Dependent = false;
2898 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
2899 return !DRE->hasExplicitTemplateArgs();
2900 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
2901 return !ME->hasExplicitTemplateArgs();
2902 Dependent = true;
2903 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
2904 return !DSDRE->hasExplicitTemplateArgs();
2905 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
2906 return !DSME->hasExplicitTemplateArgs();
2907 // Any additional cases recognized here should also be handled by
2908 // diagnoseExprIntendedAsTemplateName.
2909 return false;
2910 }
2911
2912 void warnOnReservedIdentifier(const NamedDecl *D);
2913
2915
2917 MultiTemplateParamsArg TemplateParameterLists);
2919 SourceLocation Loc,
2920 unsigned FailedFoldDiagID);
2925 TemplateIdAnnotation *TemplateId,
2926 bool IsMemberSpecialization);
2927
2928 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
2929
2930 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
2932 const LookupResult &R);
2935 const LookupResult &R);
2936 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
2937 const LookupResult &R);
2938 void CheckShadow(Scope *S, VarDecl *D);
2939
2940 /// Warn if 'E', which is an expression that is about to be modified, refers
2941 /// to a shadowing declaration.
2943
2945
2946 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
2947 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
2948 TypedefNameDecl *NewTD);
2951 TypeSourceInfo *TInfo,
2954 LookupResult &Previous, bool &Redeclaration);
2956 Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo,
2957 LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists,
2958 bool &AddToScope, ArrayRef<BindingDecl *> Bindings = std::nullopt);
2959
2960 // Returns true if the variable declaration is a redeclaration
2964
2966 TypeSourceInfo *TInfo,
2968 MultiTemplateParamsArg TemplateParamLists,
2969 bool &AddToScope);
2971
2972 // Returns true if the function declaration is a redeclaration
2975 bool IsMemberSpecialization, bool DeclIsDefn);
2978 QualType NewT, QualType OldT);
2979 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
2982 bool IsDefinition);
2985 SourceLocation ExplicitThisLoc = {});
2986 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
2987 QualType T);
2988 QualType AdjustParameterTypeForObjCAutoRefCount(QualType T,
2989 SourceLocation NameLoc,
2990 TypeSourceInfo *TSInfo);
2991 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
2992 SourceLocation NameLoc,
2993 const IdentifierInfo *Name, QualType T,
2994 TypeSourceInfo *TSInfo, StorageClass SC);
2995
2996 // Contexts where using non-trivial C union types can be disallowed. This is
2997 // passed to err_non_trivial_c_union_in_invalid_context.
2999 // Function parameter.
3001 // Function return.
3003 // Default-initialized object.
3005 // Variable with automatic storage duration.
3007 // Initializer expression that might copy from another object.
3009 // Assignment.
3011 // Compound literal.
3013 // Block capture.
3015 // lvalue-to-rvalue conversion of volatile type.
3017 };
3018
3019 /// Emit diagnostics if the initializer or any of its explicit or
3020 /// implicitly-generated subexpressions require copying or
3021 /// default-initializing a type that is or contains a C union type that is
3022 /// non-trivial to copy or default-initialize.
3024
3025 // These flags are passed to checkNonTrivialCUnion.
3030 };
3031
3032 /// Emit diagnostics if a non-trivial C union type or a struct that contains
3033 /// a non-trivial C union is used in an invalid context.
3035 NonTrivialCUnionContext UseContext,
3036 unsigned NonTrivialKind);
3037
3038 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
3039 void ActOnUninitializedDecl(Decl *dcl);
3040 void ActOnInitializerError(Decl *Dcl);
3041
3042 void ActOnCXXForRangeDecl(Decl *D);
3044 IdentifierInfo *Ident,
3045 ParsedAttributes &Attrs);
3046
3049 void FinalizeDeclaration(Decl *D);
3051 ArrayRef<Decl *> Group);
3053
3054 /// Should be called on all declarations that might have attached
3055 /// documentation comments.
3056 void ActOnDocumentableDecl(Decl *D);
3058
3059 enum class FnBodyKind {
3060 /// C++26 [dcl.fct.def.general]p1
3061 /// function-body:
3062 /// ctor-initializer[opt] compound-statement
3063 /// function-try-block
3064 Other,
3065 /// = default ;
3066 Default,
3067 /// deleted-function-body
3068 ///
3069 /// deleted-function-body:
3070 /// = delete ;
3071 /// = delete ( unevaluated-string ) ;
3072 Delete
3073 };
3074
3076 SourceLocation LocAfterDecls);
3078 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
3079 SkipBodyInfo *SkipBody = nullptr);
3081 MultiTemplateParamsArg TemplateParamLists,
3082 SkipBodyInfo *SkipBody = nullptr,
3083 FnBodyKind BodyKind = FnBodyKind::Other);
3085 SkipBodyInfo *SkipBody = nullptr,
3086 FnBodyKind BodyKind = FnBodyKind::Other);
3088
3089 /// Determine whether we can delay parsing the body of a function or
3090 /// function template until it is used, assuming we don't care about emitting
3091 /// code for that function.
3092 ///
3093 /// This will be \c false if we may need the body of the function in the
3094 /// middle of parsing an expression (where it's impractical to switch to
3095 /// parsing a different function), for instance, if it's constexpr in C++11
3096 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
3097 bool canDelayFunctionBody(const Declarator &D);
3098
3099 /// Determine whether we can skip parsing the body of a function
3100 /// definition, assuming we don't care about analyzing its body or emitting
3101 /// code for that function.
3102 ///
3103 /// This will be \c false only if we may need the body of the function in
3104 /// order to parse the rest of the program (for instance, if it is
3105 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
3106 bool canSkipFunctionBody(Decl *D);
3107
3110 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
3113
3114 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
3115 /// attribute for which parsing is delayed.
3117
3118 /// Diagnose any unused parameters in the given sequence of
3119 /// ParmVarDecl pointers.
3121
3122 /// Diagnose whether the size of parameters or return value of a
3123 /// function or obj-c method definition is pass-by-value and larger than a
3124 /// specified threshold.
3125 void
3127 QualType ReturnTy, NamedDecl *D);
3128
3130 SourceLocation RParenLoc);
3131
3134
3135 void ActOnPopScope(SourceLocation Loc, Scope *S);
3136
3138 const ParsedAttributesView &DeclAttrs,
3139 RecordDecl *&AnonRecord);
3141 const ParsedAttributesView &DeclAttrs,
3142 MultiTemplateParamsArg TemplateParams,
3143 bool IsExplicitInstantiation,
3144 RecordDecl *&AnonRecord);
3145
3148 const PrintingPolicy &Policy);
3149
3150 /// Called once it is known whether
3151 /// a tag declaration is an anonymous union or struct.
3153
3155
3158
3159 /// Common ways to introduce type names without a tag for use in diagnostics.
3160 /// Keep in sync with err_tag_reference_non_tag.
3171 };
3172
3173 /// Given a non-tag type declaration, returns an enum useful for indicating
3174 /// what kind of non-tag type this is.
3176
3178 bool isDefinition, SourceLocation NewTagLoc,
3179 const IdentifierInfo *Name);
3180
3182 TUK_Reference, // Reference to a tag: 'struct foo *X;'
3183 TUK_Declaration, // Fwd decl of a tag: 'struct foo;'
3184 TUK_Definition, // Definition of a tag: 'struct foo { int X; } Y;'
3185 TUK_Friend // Friend declaration: 'friend struct foo;'
3187
3189 // Not parsing a type within __builtin_offsetof.
3191 // Parsing a type within __builtin_offsetof.
3193 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
3194 // To improve our diagnostic message.
3196 };
3197
3198 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
3199 SourceLocation KWLoc, CXXScopeSpec &SS,
3200 IdentifierInfo *Name, SourceLocation NameLoc,
3202 SourceLocation ModulePrivateLoc,
3203 MultiTemplateParamsArg TemplateParameterLists,
3204 bool &OwnedDecl, bool &IsDependent,
3205 SourceLocation ScopedEnumKWLoc,
3206 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
3207 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
3208 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
3209
3210 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
3211 Declarator &D, Expr *BitfieldWidth);
3212
3213 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
3214 Declarator &D, Expr *BitfieldWidth,
3215 InClassInitStyle InitStyle, AccessSpecifier AS);
3216
3219 SourceLocation Loc, bool Mutable,
3220 Expr *BitfieldWidth, InClassInitStyle InitStyle,
3222 NamedDecl *PrevDecl, Declarator *D = nullptr);
3223
3225
3226 void ActOnLastBitfield(SourceLocation DeclStart,
3227 SmallVectorImpl<Decl *> &AllIvarDecls);
3228 Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D,
3229 Expr *BitWidth, tok::ObjCKeywordKind visibility);
3230
3231 // This is used for both record definitions and ObjC interface declarations.
3232 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
3233 ArrayRef<Decl *> Fields, SourceLocation LBrac,
3234 SourceLocation RBrac, const ParsedAttributesView &AttrList);
3235
3236 /// ActOnTagStartDefinition - Invoked when we have entered the
3237 /// scope of a tag's definition (e.g., for an enumeration, class,
3238 /// struct, or union).
3240
3241 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
3242 /// Differently from C++, actually parse the body and reject / error out
3243 /// in case of a structural mismatch.
3244 bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody);
3245
3247
3248 /// Invoked when we enter a tag definition that we're skipping.
3250
3252
3253 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
3254 /// C++ record definition's base-specifiers clause and are starting its
3255 /// member declarations.
3257 SourceLocation FinalLoc,
3258 bool IsFinalSpelledSealed,
3259 bool IsAbstract,
3260 SourceLocation LBraceLoc);
3261
3262 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
3263 /// the definition of a tag (enumeration, class, struct, or union).
3265 SourceRange BraceRange);
3266
3268
3270
3271 /// Invoked when we must temporarily exit the objective-c container
3272 /// scope for parsing/looking-up C constructs.
3273 ///
3274 /// Must be followed by a call to \see ActOnObjCReenterContainerContext
3277
3278 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
3279 /// error parsing the definition of a tag.
3281
3283 EnumConstantDecl *LastEnumConst,
3285 Expr *val);
3287 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
3288 QualType EnumUnderlyingTy, bool IsFixed,
3289 const EnumDecl *Prev);
3290
3291 /// Determine whether the body of an anonymous enumeration should be skipped.
3292 /// \param II The name of the first enumerator.
3294 SourceLocation IILoc);
3295
3296 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
3298 const ParsedAttributesView &Attrs,
3299 SourceLocation EqualLoc, Expr *Val);
3300 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
3301 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
3302 const ParsedAttributesView &Attr);
3303
3304 /// Set the current declaration context until it gets popped.
3305 void PushDeclContext(Scope *S, DeclContext *DC);
3306 void PopDeclContext();
3307
3308 /// EnterDeclaratorContext - Used when we must lookup names in the context
3309 /// of a declarator's nested name specifier.
3312
3313 /// Enter a template parameter scope, after it's been associated with a
3314 /// particular DeclContext. Causes lookup within the scope to chain through
3315 /// enclosing contexts in the correct order.
3317
3318 /// Push the parameters of D, which must be a function, into scope.
3321
3322 /// Add this decl to the scope shadowed decl chains.
3323 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
3324
3325 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
3326 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
3327 /// true if 'D' belongs to the given declaration context.
3328 ///
3329 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
3330 /// enclosing namespace set of the context, rather than contained
3331 /// directly within it.
3332 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
3333 bool AllowInlineNamespace = false) const;
3334
3335 /// Finds the scope corresponding to the given decl context, if it
3336 /// happens to be an enclosing scope. Otherwise return NULL.
3338
3339 /// Subroutines of ActOnDeclarator().
3341 TypeSourceInfo *TInfo);
3343
3344 /// Describes the kind of merge to perform for availability
3345 /// attributes (including "deprecated", "unavailable", and "availability").
3347 /// Don't merge availability attributes at all.
3349 /// Merge availability attributes for a redeclaration, which requires
3350 /// an exact match.
3352 /// Merge availability attributes for an override, which requires
3353 /// an exact match or a weakening of constraints.
3355 /// Merge availability attributes for an implementation of
3356 /// a protocol requirement.
3358 /// Merge availability attributes for an implementation of
3359 /// an optional protocol requirement.
3362
3363 void mergeDeclAttributes(NamedDecl *New, Decl *Old,
3366 LookupResult &OldDecls);
3367 bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
3368 bool MergeTypeWithOld, bool NewDeclIsDefn);
3370 Scope *S, bool MergeTypeWithOld);
3373 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
3374 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
3375 void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
3376
3378 bool ConsiderLinkage, bool AllowInlineNamespace);
3379
3383 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
3384
3386
3387 /// If it's a file scoped decl that must warn if not used, keep track
3388 /// of it.
3390
3391 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
3393
3396 DiagReceiverTy DiagReceiver);
3397 void DiagnoseUnusedDecl(const NamedDecl *ND);
3398 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
3399
3400 /// If VD is set but not otherwise used, diagnose, for a parameter or a
3401 /// variable.
3402 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
3403
3405 SourceLocation IdLoc,
3406 bool TypoCorrection = false);
3407
3409
3411 SourceLocation Loc);
3413 bool ForRedeclaration, SourceLocation Loc);
3414
3415 /// Get the outermost AttributedType node that sets a calling convention.
3416 /// Valid types should not have multiple attributes with different CCs.
3418
3421
3422 /// ParsingInitForAutoVars - a set of declarations with auto types for which
3423 /// we are currently parsing the initializer.
3425
3426 /// Look for a locally scoped extern "C" declaration by the given name.
3428
3430
3432
3434
3436
3437 /// Checks if the variant/multiversion functions are compatible.
3439 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
3440 const PartialDiagnostic &NoProtoDiagID,
3441 const PartialDiagnosticAt &NoteCausedDiagIDAt,
3442 const PartialDiagnosticAt &NoSupportDiagIDAt,
3443 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
3444 bool ConstexprSupported, bool CLinkageMayDiffer);
3445
3446 /// type checking declaration initializers (C99 6.7.8)
3448 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
3449
3452 SourceRange Range, bool DirectInit,
3453 Expr *Init);
3454
3456 Expr *Init);
3457
3459
3460 // Heuristically tells if the function is `get_return_object` member of a
3461 // coroutine promise_type by matching the function name.
3462 static bool CanBeGetReturnObject(const FunctionDecl *FD);
3463 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
3464
3466 Scope *S);
3468 FunctionDecl *FD);
3470
3471 /// VerifyBitField - verifies that a bit field expression is an ICE and has
3472 /// the correct width, and that the field type is valid.
3473 /// Returns false on success.
3475 const IdentifierInfo *FieldName, QualType FieldTy,
3476 bool IsMsStruct, Expr *BitWidth);
3477
3478 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
3479 /// enum. If AllowMask is true, then we also allow the complement of a valid
3480 /// value, to be used as a mask.
3481 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
3482 bool AllowMask) const;
3483
3484 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
3485 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
3486 SourceLocation WeakNameLoc);
3487
3488 /// ActOnPragmaRedefineExtname - Called on well formed
3489 /// \#pragma redefine_extname oldname newname.
3491 IdentifierInfo *AliasName,
3492 SourceLocation PragmaLoc,
3493 SourceLocation WeakNameLoc,
3494 SourceLocation AliasNameLoc);
3495
3496 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
3497 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
3498 SourceLocation PragmaLoc,
3499 SourceLocation WeakNameLoc,
3500 SourceLocation AliasNameLoc);
3501
3503
3504 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
3506 Emitted,
3507 CUDADiscarded, // Discarded due to CUDA/HIP hostness
3508 OMPDiscarded, // Discarded due to OpenMP hostness
3509 TemplateDiscarded, // Discarded due to uninstantiated templates
3510 Unknown,
3511 };
3512 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
3513 bool Final = false);
3514
3515 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
3517
3518private:
3519 /// Function or variable declarations to be checked for whether the deferred
3520 /// diagnostics should be emitted.
3521 llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
3522
3523 /// Map of current shadowing declarations to shadowed declarations. Warn if
3524 /// it looks like the user is trying to modify the shadowing declaration.
3525 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
3526
3527 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
3528
3529 ///@}
3530
3531 //
3532 //
3533 // -------------------------------------------------------------------------
3534 //
3535 //
3536
3537 /// \name Declaration Attribute Handling
3538 /// Implementations are in SemaDeclAttr.cpp
3539 ///@{
3540
3541public:
3542 /// Describes the kind of priority given to an availability attribute.
3543 ///
3544 /// The sum of priorities deteremines the final priority of the attribute.
3545 /// The final priority determines how the attribute will be merged.
3546 /// An attribute with a lower priority will always remove higher priority
3547 /// attributes for the specified platform when it is being applied. An
3548 /// attribute with a higher priority will not be applied if the declaration
3549 /// already has an availability attribute with a lower priority for the
3550 /// specified platform. The final prirority values are not expected to match
3551 /// the values in this enumeration, but instead should be treated as a plain
3552 /// integer value. This enumeration just names the priority weights that are
3553 /// used to calculate that final vaue.
3555 /// The availability attribute was specified explicitly next to the
3556 /// declaration.
3558
3559 /// The availability attribute was applied using '#pragma clang attribute'.
3561
3562 /// The availability attribute for a specific platform was inferred from
3563 /// an availability attribute for another platform.
3566
3567 /// Describes the reason a calling convention specification was ignored, used
3568 /// for diagnostics.
3570 ForThisTarget = 0,
3574 };
3575
3576 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
3577 /// \#pragma weak during processing of other Decls.
3578 /// I couldn't figure out a clean way to generate these in-line, so
3579 /// we store them here and handle separately -- which is a hack.
3580 /// It would be best to refactor this.
3582
3583 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
3585
3589
3590 /// ExtVectorDecls - This is a list all the extended vector types. This allows
3591 /// us to associate a raw vector type with one of the ext_vector type names.
3592 /// This is only necessary for issuing pretty diagnostics.
3594
3596 const Expr *E, StringRef &Str,
3597 SourceLocation *ArgLocation = nullptr);
3598 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
3599 StringRef &Str,
3600 SourceLocation *ArgLocation = nullptr);
3601
3602 /// Determine if type T is a valid subject for a nonnull and similar
3603 /// attributes. By default, we look through references (the behavior used by
3604 /// nonnull), but if the second parameter is true, then we treat a reference
3605 /// type as valid.
3606 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
3607
3608 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
3609 /// declaration.
3610 void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
3611 Expr *OE);
3612
3613 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
3614 /// declaration.
3615 void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
3616 Expr *ParamExpr);
3617
3618 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
3619 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
3620
3621 AvailabilityAttr *
3623 IdentifierInfo *Platform, bool Implicit,
3624 VersionTuple Introduced, VersionTuple Deprecated,
3625 VersionTuple Obsoleted, bool IsUnavailable,
3626 StringRef Message, bool IsStrict, StringRef Replacement,
3628 TypeVisibilityAttr *
3630 TypeVisibilityAttr::VisibilityType Vis);
3631 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
3632 VisibilityAttr::VisibilityType Vis);
3633 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
3634 StringRef Name);
3635
3636 llvm::Error isValidSectionSpecifier(StringRef Str);
3637 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
3638 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
3639 StringRef Name);
3640
3641 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
3642 bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
3643 StringRef &Str, bool &isDefault);
3645 SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
3646 Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
3647 SmallVectorImpl<SmallString<64>> &StringsBuffer);
3648
3649 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
3650 StringRef NewUserDiagnostic);
3651 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
3652 IdentifierInfo *Format, int FormatIdx,
3653 int FirstArg);
3654
3655 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
3656 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
3657 bool IsPackExpansion);
3659 bool IsPackExpansion);
3660
3661 /// AddAlignValueAttr - Adds an align_value attribute to a particular
3662 /// declaration.
3663 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
3664
3665 /// AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
3666 void AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI,
3667 StringRef Annot, MutableArrayRef<Expr *> Args);
3668
3670 bool BestCase,
3671 MSInheritanceModel SemanticSpelling);
3672
3674
3675 /// AddModeAttr - Adds a mode attribute to a particular declaration.
3676 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
3677 bool InInstantiation = false);
3678 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
3679 const AttributeCommonInfo &CI,
3680 const IdentifierInfo *Ident);
3681 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
3682 SwiftNameAttr *mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
3683 StringRef Name);
3684 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
3685 const AttributeCommonInfo &CI);
3686 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
3687 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
3688 const InternalLinkageAttr &AL);
3689
3690 /// Check validaty of calling convention attribute \p attr. If \p FD
3691 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
3692 /// target. Otherwise, it is specified by \p CFT.
3694 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
3696
3697 void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI,
3698 ParameterABI ABI);
3699 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
3700
3701 /// Create an CUDALaunchBoundsAttr attribute.
3702 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
3703 Expr *MaxThreads,
3704 Expr *MinBlocks,
3705 Expr *MaxBlocks);
3706
3707 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
3708 /// declaration.
3709 void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
3710 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
3711
3712 enum class RetainOwnershipKind { NS, CF, OS };
3713 void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI,
3714 RetainOwnershipKind K, bool IsTemplateInstantiation);
3715
3717
3718 /// Do a check to make sure \p Name looks like a legal argument for the
3719 /// swift_name attribute applied to decl \p D. Raise a diagnostic if the name
3720 /// is invalid for the given declaration.
3721 ///
3722 /// \p AL is used to provide caret diagnostics in case of a malformed name.
3723 ///
3724 /// \returns true if the name is a valid swift name for \p D, false otherwise.
3725 bool DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc,
3726 const ParsedAttr &AL, bool IsAsync);
3727
3728 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
3729 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
3730
3731 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
3732
3733 WebAssemblyImportNameAttr *
3734 mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL);
3735 WebAssemblyImportModuleAttr *
3736 mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL);
3737
3738 /// Create an AMDGPUWavesPerEUAttr attribute.
3739 AMDGPUFlatWorkGroupSizeAttr *
3741 Expr *Max);
3742
3743 /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
3744 /// attribute to a particular declaration.
3746 Expr *Min, Expr *Max);
3747
3748 /// Create an AMDGPUWavesPerEUAttr attribute.
3749 AMDGPUWavesPerEUAttr *
3751 Expr *Max);
3752
3753 /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
3754 /// particular declaration.
3756 Expr *Min, Expr *Max);
3757
3758 /// Create an AMDGPUMaxNumWorkGroupsAttr attribute.
3759 AMDGPUMaxNumWorkGroupsAttr *
3761 Expr *YExpr, Expr *ZExpr);
3762
3763 /// addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups
3764 /// attribute to a particular declaration.
3766 Expr *XExpr, Expr *YExpr, Expr *ZExpr);
3767
3768 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
3769 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
3770 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
3771 const AttributeCommonInfo &CI,
3772 bool BestCase,
3773 MSInheritanceModel Model);
3774
3775 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
3776 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
3777 const EnforceTCBLeafAttr &AL);
3778
3779 // Helper for delayed processing of attributes.
3781 const ParsedAttributesView &AttrList);
3782
3783 // Options for ProcessDeclAttributeList().
3786 : IncludeCXX11Attributes(true), IgnoreTypeAttributes(false) {}
3787
3789 ProcessDeclAttributeOptions Result = *this;
3790 Result.IncludeCXX11Attributes = Val;
3791 return Result;
3792 }
3793
3795 ProcessDeclAttributeOptions Result = *this;
3796 Result.IgnoreTypeAttributes = Val;
3797 return Result;
3798 }
3799
3800 // Should C++11 attributes be processed?
3802
3803 // Should any type attributes encountered be ignored?
3804 // If this option is false, a diagnostic will be emitted for any type
3805 // attributes of a kind that does not "slide" from the declaration to
3806 // the decl-specifier-seq.
3808 };
3809
3811 const ParsedAttributesView &AttrList,
3812 const ProcessDeclAttributeOptions &Options =
3815 const ParsedAttributesView &AttrList);
3816
3818
3820 SourceLocation Loc);
3821 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
3822
3823 void ProcessPragmaWeak(Scope *S, Decl *D);
3824 // Decl attributes - this routine is the top level dispatcher.
3825 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
3826
3828
3830
3831 ///@}
3832
3833 //
3834 //
3835 // -------------------------------------------------------------------------
3836 //
3837 //
3838
3839 /// \name C++ Declarations
3840 /// Implementations are in SemaDeclCXX.cpp
3841 ///@{
3842
3843public:
3845
3846 /// Called before parsing a function declarator belonging to a function
3847 /// declaration.
3849 unsigned TemplateParameterDepth);
3850
3851 /// Called after parsing a function declarator belonging to a function
3852 /// declaration.
3854
3855 // Act on C++ namespaces
3857 SourceLocation NamespaceLoc,
3858 SourceLocation IdentLoc, IdentifierInfo *Ident,
3859 SourceLocation LBrace,
3860 const ParsedAttributesView &AttrList,
3861 UsingDirectiveDecl *&UsingDecl, bool IsNested);
3862 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
3863
3866
3868 EnumDecl *getStdAlignValT() const;
3869
3871 const IdentifierInfo *MemberOrBase);
3872
3874 /// The '<=>' operator was used in an expression and a builtin operator
3875 /// was selected.
3877 /// A defaulted 'operator<=>' needed the comparison category. This
3878 /// typically only applies to 'std::strong_ordering', due to the implicit
3879 /// fallback return value.
3881 };
3882
3883 /// Lookup the specified comparison category types in the standard
3884 /// library, an check the VarDecls possibly returned by the operator<=>
3885 /// builtins for that type.
3886 ///
3887 /// \return The type of the comparison category type corresponding to the
3888 /// specified Kind, or a null type if an error occurs
3890 SourceLocation Loc,
3892
3893 /// Tests whether Ty is an instance of std::initializer_list and, if
3894 /// it is and Element is not NULL, assigns the element type to Element.
3895 bool isStdInitializerList(QualType Ty, QualType *Element);
3896
3897 /// Looks for the std::initializer_list template and instantiates it
3898 /// with Element, or emits an error if it's not found.
3899 ///
3900 /// \returns The instantiated template, or null on error.
3902
3903 /// Determine whether Ctor is an initializer-list constructor, as
3904 /// defined in [dcl.init.list]p2.
3905 bool isInitListConstructor(const FunctionDecl *Ctor);
3906
3907 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
3908 SourceLocation NamespcLoc, CXXScopeSpec &SS,
3909 SourceLocation IdentLoc,
3910 IdentifierInfo *NamespcName,
3911 const ParsedAttributesView &AttrList);
3912
3914
3915 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
3916 SourceLocation AliasLoc, IdentifierInfo *Alias,
3917 CXXScopeSpec &SS, SourceLocation IdentLoc,
3918 IdentifierInfo *Ident);
3919
3920 void FilterUsingLookup(Scope *S, LookupResult &lookup);
3921 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
3923 const LookupResult &PreviousDecls,
3924 UsingShadowDecl *&PrevShadow);
3927 UsingShadowDecl *PrevDecl);
3928
3930 bool HasTypenameKeyword,
3931 const CXXScopeSpec &SS,
3932 SourceLocation NameLoc,
3933 const LookupResult &Previous);
3934 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
3935 const CXXScopeSpec &SS,
3936 const DeclarationNameInfo &NameInfo,
3937 SourceLocation NameLoc,
3938 const LookupResult *R = nullptr,
3939 const UsingDecl *UD = nullptr);
3940
3942 SourceLocation UsingLoc,
3943 bool HasTypenameKeyword,
3944 SourceLocation TypenameLoc, CXXScopeSpec &SS,
3945 DeclarationNameInfo NameInfo,
3946 SourceLocation EllipsisLoc,
3947 const ParsedAttributesView &AttrList,
3948 bool IsInstantiation, bool IsUsingIfExists);
3950 SourceLocation UsingLoc,
3951 SourceLocation EnumLoc,
3952 SourceLocation NameLoc,
3954 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
3955 ArrayRef<NamedDecl *> Expansions);
3956
3958
3959 /// Given a derived-class using shadow declaration for a constructor and the
3960 /// correspnding base class constructor, find or create the implicit
3961 /// synthesized derived class constructor to use for this initialization.
3964 ConstructorUsingShadowDecl *DerivedShadow);
3965
3967 SourceLocation UsingLoc,
3968 SourceLocation TypenameLoc, CXXScopeSpec &SS,
3969 UnqualifiedId &Name, SourceLocation EllipsisLoc,
3970 const ParsedAttributesView &AttrList);
3972 SourceLocation UsingLoc,
3973 SourceLocation EnumLoc,
3974 SourceLocation IdentLoc, IdentifierInfo &II,
3975 CXXScopeSpec *SS = nullptr);
3977 MultiTemplateParamsArg TemplateParams,
3978 SourceLocation UsingLoc, UnqualifiedId &Name,
3979 const ParsedAttributesView &AttrList,
3980 TypeResult Type, Decl *DeclFromDeclSpec);
3981
3982 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
3983 /// including handling of its default argument expressions.
3984 ///
3985 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
3987 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
3988 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
3989 bool HadMultipleCandidates, bool IsListInitialization,
3990 bool IsStdInitListInitialization, bool RequiresZeroInit,
3991 CXXConstructionKind ConstructKind, SourceRange ParenRange);
3992
3993 /// Build a CXXConstructExpr whose constructor has already been resolved if
3994 /// it denotes an inherited constructor.
3996 SourceLocation ConstructLoc, QualType DeclInitType,
3997 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
3998 bool HadMultipleCandidates, bool IsListInitialization,
3999 bool IsStdInitListInitialization, bool RequiresZeroInit,
4000 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4001
4002 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4003 // the constructor can be elidable?
4005 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4006 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4007 bool HadMultipleCandidates, bool IsListInitialization,
4008 bool IsStdInitListInitialization, bool RequiresZeroInit,
4009 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4010
4012 SourceLocation InitLoc);
4013
4014 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4015 /// constructed variable.
4016 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
4017
4018 /// Helper class that collects exception specifications for
4019 /// implicitly-declared special member functions.
4021 // Pointer to allow copying
4022 Sema *Self;
4023 // We order exception specifications thus:
4024 // noexcept is the most restrictive, but is only used in C++11.
4025 // throw() comes next.
4026 // Then a throw(collected exceptions)
4027 // Finally no specification, which is expressed as noexcept(false).
4028 // throw(...) is used instead if any called function uses it.
4029 ExceptionSpecificationType ComputedEST;
4030 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
4031 SmallVector<QualType, 4> Exceptions;
4032
4033 void ClearExceptions() {
4034 ExceptionsSeen.clear();
4035 Exceptions.clear();
4036 }
4037
4038 public:
4040 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
4041 if (!Self.getLangOpts().CPlusPlus11)
4042 ComputedEST = EST_DynamicNone;
4043 }
4044
4045 /// Get the computed exception specification type.
4047 assert(!isComputedNoexcept(ComputedEST) &&
4048 "noexcept(expr) should not be a possible result");
4049 return ComputedEST;
4050 }
4051
4052 /// The number of exceptions in the exception specification.
4053 unsigned size() const { return Exceptions.size(); }
4054
4055 /// The set of exceptions in the exception specification.
4056 const QualType *data() const { return Exceptions.data(); }
4057
4058 /// Integrate another called method into the collected data.
4059 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
4060
4061 /// Integrate an invoked expression into the collected data.
4062 void CalledExpr(Expr *E) { CalledStmt(E); }
4063
4064 /// Integrate an invoked statement into the collected data.
4065 void CalledStmt(Stmt *S);
4066
4067 /// Overwrite an EPI's exception specification with this
4068 /// computed exception specification.
4071 ESI.Type = getExceptionSpecType();
4072 if (ESI.Type == EST_Dynamic) {
4073 ESI.Exceptions = Exceptions;
4074 } else if (ESI.Type == EST_None) {
4075 /// C++11 [except.spec]p14:
4076 /// The exception-specification is noexcept(false) if the set of
4077 /// potential exceptions of the special member function contains "any"
4078 ESI.Type = EST_NoexceptFalse;
4079 ESI.NoexceptExpr =
4080 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
4081 }
4082 return ESI;
4083 }
4084 };
4085
4086 /// Evaluate the implicit exception specification for a defaulted
4087 /// special member function.
4089
4090 /// Check the given exception-specification and update the
4091 /// exception specification information with the results.
4092 void checkExceptionSpecification(bool IsTopLevel,
4094 ArrayRef<ParsedType> DynamicExceptions,
4095 ArrayRef<SourceRange> DynamicExceptionRanges,
4096 Expr *NoexceptExpr,
4097 SmallVectorImpl<QualType> &Exceptions,
4099
4100 /// Add an exception-specification to the given member function
4101 /// (or member function template). The exception-specification was parsed
4102 /// after the method itself was declared.
4104 Decl *Method, ExceptionSpecificationType EST,
4105 SourceRange SpecificationRange, ArrayRef<ParsedType> DynamicExceptions,
4106 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
4107
4108 class InheritedConstructorInfo;
4109
4110 /// Determine if a special member function should have a deleted
4111 /// definition when it is defaulted.
4113 InheritedConstructorInfo *ICI = nullptr,
4114 bool Diagnose = false);
4115
4116 /// Produce notes explaining why a defaulted function was defined as deleted.
4118
4119 /// Declare the implicit default constructor for the given class.
4120 ///
4121 /// \param ClassDecl The class declaration into which the implicit
4122 /// default constructor will be added.
4123 ///
4124 /// \returns The implicitly-declared default constructor.
4127
4128 /// DefineImplicitDefaultConstructor - Checks for feasibility of
4129 /// defining this constructor as the default constructor.
4131 CXXConstructorDecl *Constructor);
4132
4133 /// Declare the implicit destructor for the given class.
4134 ///
4135 /// \param ClassDecl The class declaration into which the implicit
4136 /// destructor will be added.
4137 ///
4138 /// \returns The implicitly-declared destructor.
4140
4141 /// DefineImplicitDestructor - Checks for feasibility of
4142 /// defining this destructor as the default destructor.
4143 void DefineImplicitDestructor(SourceLocation CurrentLocation,
4145
4146 /// Build an exception spec for destructors that don't have one.
4147 ///
4148 /// C++11 says that user-defined destructors with no exception spec get one
4149 /// that looks as if the destructor was implicitly declared.
4151
4152 /// Define the specified inheriting constructor.
4154 CXXConstructorDecl *Constructor);
4155
4156 /// Declare the implicit copy constructor for the given class.
4157 ///
4158 /// \param ClassDecl The class declaration into which the implicit
4159 /// copy constructor will be added.
4160 ///
4161 /// \returns The implicitly-declared copy constructor.
4163
4164 /// DefineImplicitCopyConstructor - Checks for feasibility of
4165 /// defining this constructor as the copy constructor.
4166 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
4167 CXXConstructorDecl *Constructor);
4168
4169 /// Declare the implicit move constructor for the given class.
4170 ///
4171 /// \param ClassDecl The Class declaration into which the implicit
4172 /// move constructor will be added.
4173 ///
4174 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
4175 /// declared.
4177
4178 /// DefineImplicitMoveConstructor - Checks for feasibility of
4179 /// defining this constructor as the move constructor.
4180 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
4181 CXXConstructorDecl *Constructor);
4182
4183 /// Declare the implicit copy assignment operator for the given class.
4184 ///
4185 /// \param ClassDecl The class declaration into which the implicit
4186 /// copy assignment operator will be added.
4187 ///
4188 /// \returns The implicitly-declared copy assignment operator.
4190
4191 /// Defines an implicitly-declared copy assignment operator.
4192 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
4193 CXXMethodDecl *MethodDecl);
4194
4195 /// Declare the implicit move assignment operator for the given class.
4196 ///
4197 /// \param ClassDecl The Class declaration into which the implicit
4198 /// move assignment operator will be added.
4199 ///
4200 /// \returns The implicitly-declared move assignment operator, or NULL if it
4201 /// wasn't declared.
4203
4204 /// Defines an implicitly-declared move assignment operator.
4205 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
4206 CXXMethodDecl *MethodDecl);
4207
4208 /// Check a completed declaration of an implicit special member.
4210
4211 /// Determine whether the given function is an implicitly-deleted
4212 /// special member function.
4214
4215 /// Check whether 'this' shows up in the type of a static member
4216 /// function after the (naturally empty) cv-qualifier-seq would be.
4217 ///
4218 /// \returns true if an error occurred.
4220
4221 /// Whether this' shows up in the exception specification of a static
4222 /// member function.
4224
4225 /// Check whether 'this' shows up in the attributes of the given
4226 /// static member function.
4227 ///
4228 /// \returns true if an error occurred.
4230
4232 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
4233
4235
4237 QualType DeclInitType, MultiExprArg ArgsPtr,
4238 SourceLocation Loc,
4239 SmallVectorImpl<Expr *> &ConvertedArgs,
4240 bool AllowExplicit = false,
4241 bool IsListInitialization = false);
4242
4243 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
4244 /// initializer for the declaration 'Dcl'.
4245 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
4246 /// static data member of class X, names should be looked up in the scope of
4247 /// class X.
4249
4250 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
4251 /// initializer for the declaration 'Dcl'.
4252 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
4253
4254 /// Define the "body" of the conversion from a lambda object to a
4255 /// function pointer.
4256 ///
4257 /// This routine doesn't actually define a sensible body; rather, it fills
4258 /// in the initialization expression needed to copy the lambda object into
4259 /// the block, and IR generation actually generates the real body of the
4260 /// block pointer conversion.
4261 void
4263 CXXConversionDecl *Conv);
4264
4265 /// Define the "body" of the conversion from a lambda object to a
4266 /// block pointer.
4267 ///
4268 /// This routine doesn't actually define a sensible body; rather, it fills
4269 /// in the initialization expression needed to copy the lambda object into
4270 /// the block, and IR generation actually generates the real body of the
4271 /// block pointer conversion.
4273 CXXConversionDecl *Conv);
4274
4276 Expr *LangStr, SourceLocation LBraceLoc);
4278 SourceLocation RBraceLoc);
4279
4280 //===--------------------------------------------------------------------===//
4281 // C++ Classes
4282 //
4284 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
4285 const CXXScopeSpec *SS = nullptr);
4287
4289 SourceLocation ColonLoc,
4290 const ParsedAttributesView &Attrs);
4291
4292 NamedDecl *
4294 MultiTemplateParamsArg TemplateParameterLists,
4295 Expr *BitfieldWidth, const VirtSpecifiers &VS,
4296 InClassInitStyle InitStyle);
4297
4300 SourceLocation EqualLoc,
4301 Expr *Init);
4302
4304 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
4305 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
4306 const DeclSpec &DS, SourceLocation IdLoc,
4307 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
4308 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
4309
4310 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
4311 CXXScopeSpec &SS,
4312 IdentifierInfo *MemberOrBase,
4313 ParsedType TemplateTypeTy,
4314 const DeclSpec &DS, SourceLocation IdLoc,
4315 Expr *InitList, SourceLocation EllipsisLoc);
4316
4317 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
4318 CXXScopeSpec &SS,
4319 IdentifierInfo *MemberOrBase,
4320 ParsedType TemplateTypeTy,
4321 const DeclSpec &DS, SourceLocation IdLoc,
4322 Expr *Init, SourceLocation EllipsisLoc);
4323
4325 SourceLocation IdLoc);
4326
4328 TypeSourceInfo *BaseTInfo, Expr *Init,
4329 CXXRecordDecl *ClassDecl,
4330 SourceLocation EllipsisLoc);
4331
4333 CXXRecordDecl *ClassDecl);
4334
4337
4339 CXXConstructorDecl *Constructor, bool AnyErrors,
4340 ArrayRef<CXXCtorInitializer *> Initializers = std::nullopt);
4341
4342 void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
4343
4344 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
4345 /// mark all the non-trivial destructors of its members and bases as
4346 /// referenced.
4349
4350 /// Mark destructors of virtual bases of this class referenced. In the Itanium
4351 /// C++ ABI, this is done when emitting a destructor for any non-abstract
4352 /// class. In the Microsoft C++ ABI, this is done any time a class's
4353 /// destructor is referenced.
4355 SourceLocation Location, CXXRecordDecl *ClassDecl,
4356 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases = nullptr);
4357
4358 /// Do semantic checks to allow the complete destructor variant to be emitted
4359 /// when the destructor is defined in another translation unit. In the Itanium
4360 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
4361 /// can be emitted in separate TUs. To emit the complete variant, run a subset
4362 /// of the checks performed when emitting a regular destructor.
4364 CXXDestructorDecl *Dtor);
4365
4366 /// The list of classes whose vtables have been used within
4367 /// this translation unit, and the source locations at which the
4368 /// first use occurred.
4369 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
4370
4371 /// The list of vtables that are required but have not yet been
4372 /// materialized.
4374
4375 /// The set of classes whose vtables have been used within
4376 /// this translation unit, and a bit that will be true if the vtable is
4377 /// required to be emitted (otherwise, it should be emitted only if needed
4378 /// by code generation).
4379 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
4380
4381 /// Load any externally-stored vtable uses.
4383
4384 /// Note that the vtable for the given class was used at the
4385 /// given location.
4387 bool DefinitionRequired = false);
4388
4389 /// Mark the exception specifications of all virtual member functions
4390 /// in the given class as needed.
4392 const CXXRecordDecl *RD);
4393
4394 /// MarkVirtualMembersReferenced - Will mark all members of the given
4395 /// CXXRecordDecl referenced.
4397 bool ConstexprOnly = false);
4398
4399 /// Define all of the vtables that have been used in this
4400 /// translation unit and reference any virtual members used by those
4401 /// vtables.
4402 ///
4403 /// \returns true if any work was done, false otherwise.
4404 bool DefineUsedVTables();
4405
4407
4408 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
4410 bool AnyErrors);
4411
4412 /// Check class-level dllimport/dllexport attribute. The caller must
4413 /// ensure that referenceDLLExportedClassMethods is called some point later
4414 /// when all outer classes of Class are complete.
4417
4419
4421 CXXRecordDecl *Class, Attr *ClassAttr,
4422 ClassTemplateSpecializationDecl *BaseTemplateSpec,
4423 SourceLocation BaseLoc);
4424
4426
4427 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
4428 /// conditions that are needed for the attribute to have an effect.
4430
4432 Decl *TagDecl, SourceLocation LBrac,
4433 SourceLocation RBrac,
4434 const ParsedAttributesView &AttrList);
4437
4439 unsigned ActOnReenterTemplateScope(Decl *Template,
4440 llvm::function_ref<Scope *()> EnterScope);
4443 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
4447
4448 bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result,
4449 ASTContext &Ctx,
4450 bool ErrorOnInvalidMessage);
4452 Expr *AssertExpr, Expr *AssertMessageExpr,
4453 SourceLocation RParenLoc);
4455 Expr *AssertExpr, Expr *AssertMessageExpr,
4456 SourceLocation RParenLoc, bool Failed);
4457 void DiagnoseStaticAssertDetails(const Expr *E);
4458
4459 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
4460 MultiTemplateParamsArg TemplateParams);
4462 MultiTemplateParamsArg TemplateParams);
4463
4465 StorageClass &SC);
4466 void CheckConstructor(CXXConstructorDecl *Constructor);
4468 StorageClass &SC);
4473 StorageClass &SC);
4474
4476
4479 SourceLocation DefaultLoc);
4481
4482 /// Kinds of defaulted comparison operator functions.
4483 enum class DefaultedComparisonKind : unsigned char {
4484 /// This is not a defaultable comparison operator.
4485 None,
4486 /// This is an operator== that should be implemented as a series of
4487 /// subobject comparisons.
4488 Equal,
4489 /// This is an operator<=> that should be implemented as a series of
4490 /// subobject comparisons.
4491 ThreeWay,
4492 /// This is an operator!= that should be implemented as a rewrite in terms
4493 /// of a == comparison.
4494 NotEqual,
4495 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
4496 /// terms of a <=> comparison.
4497 Relational,
4498 };
4499
4503 FunctionDecl *Spaceship);
4506
4508 QualType R, bool IsLambda,
4509 DeclContext *DC = nullptr);
4511 DeclarationName Name, QualType R);
4513
4514 //===--------------------------------------------------------------------===//
4515 // C++ Derived Classes
4516 //
4517
4518 /// ActOnBaseSpecifier - Parsed a base specifier
4520 SourceRange SpecifierRange, bool Virtual,
4521 AccessSpecifier Access,
4522 TypeSourceInfo *TInfo,
4523 SourceLocation EllipsisLoc);
4524
4525 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
4526 const ParsedAttributesView &Attrs, bool Virtual,
4527 AccessSpecifier Access, ParsedType basetype,
4528 SourceLocation BaseLoc,
4529 SourceLocation EllipsisLoc);
4530
4533 void ActOnBaseSpecifiers(Decl *ClassDecl,
4535
4538 CXXBasePaths &Paths);
4539
4540 // FIXME: I don't like this name.
4541 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
4542
4544 SourceLocation Loc, SourceRange Range,
4545 CXXCastPath *BasePath = nullptr,
4546 bool IgnoreAccess = false);
4548 unsigned InaccessibleBaseID,
4549 unsigned AmbiguousBaseConvID,
4550 SourceLocation Loc, SourceRange Range,
4551 DeclarationName Name, CXXCastPath *BasePath,
4552 bool IgnoreAccess = false);
4553
4554 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
4555
4557 const CXXMethodDecl *Old);
4558
4559 /// CheckOverridingFunctionReturnType - Checks whether the return types are
4560 /// covariant, according to C++ [class.virtual]p5.
4562 const CXXMethodDecl *Old);
4563
4564 // Check that the overriding method has no explicit object parameter.
4566 const CXXMethodDecl *Old);
4567
4568 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
4569
4570 /// CheckOverrideControl - Check C++11 override control semantics.
4572
4573 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
4574 /// not used in the declaration of an overriding method.
4576
4577 /// CheckForFunctionMarkedFinal - Checks whether a virtual member function
4578 /// overrides a virtual member function marked 'final', according to
4579 /// C++11 [class.virtual]p4.
4581 const CXXMethodDecl *Old);
4582
4593
4594 struct TypeDiagnoser;
4595
4598 TypeDiagnoser &Diagnoser);
4599 template <typename... Ts>
4601 const Ts &...Args) {
4602 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
4603 return RequireNonAbstractType(Loc, T, Diagnoser);
4604 }
4605
4606 void DiagnoseAbstractType(const CXXRecordDecl *RD);
4607
4608 //===--------------------------------------------------------------------===//
4609 // C++ Overloaded Operators [C++ 13.5]
4610 //
4611
4613
4615
4616 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
4617 /// found in an explicit(bool) specifier.
4619
4620 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
4621 /// Returns true if the explicit specifier is now resolved.
4623
4625
4626 // Emitting members of dllexported classes is delayed until the class
4627 // (including field initializers) is fully parsed.
4630
4633
4634 /// Helpers for dealing with blocks and functions.
4637
4640 }
4641
4643 SourceLocation StartLoc,
4644 SourceLocation IdLoc,
4645 const IdentifierInfo *Id);
4646
4648
4650
4652 unsigned TagSpec, SourceLocation TagLoc,
4653 CXXScopeSpec &SS, IdentifierInfo *Name,
4654 SourceLocation NameLoc,
4656 MultiTemplateParamsArg TempParamLists);
4657
4659 SourceLocation DeclStart, Declarator &D,
4660 Expr *BitfieldWidth,
4661 InClassInitStyle InitStyle,
4662 AccessSpecifier AS,
4663 const ParsedAttr &MSPropertyAttr);
4664
4667
4669 /// The triviality of a method unaffected by "trivial_abi".
4671
4672 /// The triviality of a method affected by "trivial_abi".
4675
4678 bool Diagnose = false);
4679
4680 /// For a defaulted function, the kind of defaulted function that it is.
4682 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
4683 unsigned SpecialMember : 8;
4684 unsigned Comparison : 8;
4685
4686 public:
4688 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
4689 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
4691 : SpecialMember(llvm::to_underlying(CSM)),
4692 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
4694 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
4695 Comparison(llvm::to_underlying(Comp)) {}
4696
4697 bool isSpecialMember() const {
4698 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
4699 CXXSpecialMemberKind::Invalid;
4700 }
4701 bool isComparison() const {
4702 return static_cast<DefaultedComparisonKind>(Comparison) !=
4703 DefaultedComparisonKind::None;
4704 }
4705
4706 explicit operator bool() const {
4707 return isSpecialMember() || isComparison();
4708 }
4709
4711 return static_cast<CXXSpecialMemberKind>(SpecialMember);
4712 }
4714 return static_cast<DefaultedComparisonKind>(Comparison);
4715 }
4716
4717 /// Get the index of this function kind for use in diagnostics.
4718 unsigned getDiagnosticIndex() const {
4719 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
4720 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
4721 "invalid should have highest index");
4722 static_assert((unsigned)DefaultedComparisonKind::None == 0,
4723 "none should be equal to zero");
4724 return SpecialMember + Comparison;
4725 }
4726 };
4727
4728 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
4729
4730 /// Handle a C++11 empty-declaration and attribute-declaration.
4732 SourceLocation SemiLoc);
4733
4735 /// Diagnose issues that are non-constant or that are extensions.
4736 Diagnose,
4737 /// Identify whether this function satisfies the formal rules for constexpr
4738 /// functions in the current lanugage mode (with no extensions).
4740 };
4741
4743 CheckConstexprKind Kind);
4744
4746 void
4748 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
4749 void
4751 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
4752 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
4753 Expr *defarg);
4755 SourceLocation ArgLoc);
4757 Expr *DefaultArg);
4759 SourceLocation EqualLoc);
4760 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
4761 SourceLocation EqualLoc);
4762
4763 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
4764 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
4765 StringLiteral *Message = nullptr);
4766 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
4767
4768 void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
4769 StringLiteral *DeletedMessage = nullptr);
4773
4774 NamedDecl *
4776 MultiTemplateParamsArg TemplateParamLists);
4779 RecordDecl *ClassDecl,
4780 const IdentifierInfo *Name);
4781
4783
4784 /// Stack containing information needed when in C++2a an 'auto' is encountered
4785 /// in a function declaration parameter type specifier in order to invent a
4786 /// corresponding template parameter in the enclosing abbreviated function
4787 /// template. This information is also present in LambdaScopeInfo, stored in
4788 /// the FunctionScopes stack.
4790
4791 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
4792 std::unique_ptr<CXXFieldCollector> FieldCollector;
4793
4795 /// Set containing all declared private fields that are not used.
4797
4799
4800 /// PureVirtualClassDiagSet - a set of class declarations which we have
4801 /// emitted a list of pure virtual functions. Used to prevent emitting the
4802 /// same list more than once.
4803 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
4804
4808
4809 /// All the delegating constructors seen so far in the file, used for
4810 /// cycle detection at the end of the TU.
4812
4813 /// The C++ "std" namespace, where the standard library resides.
4815
4816 /// The C++ "std::initializer_list" template, which is defined in
4817 /// <initializer_list>.
4819
4820 // Contains the locations of the beginning of unparsed default
4821 // argument locations.
4822 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
4823
4824 /// UndefinedInternals - all the used, undefined objects which require a
4825 /// definition in this translation unit.
4826 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
4827
4828 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
4830
4831 /// The C++ special members which we are currently in the process of
4832 /// declaring. If this process recursively triggers the declaration of the
4833 /// same special member, we should act as if it is not yet declared.
4835
4837
4838 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
4839
4842 ParsingClassDepth++;
4844 }
4846 ParsingClassDepth--;
4848 }
4849
4850private:
4851 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
4852 QualType ResultTy,
4853 ArrayRef<QualType> Args);
4854
4855 // A cache representing if we've fully checked the various comparison category
4856 // types stored in ASTContext. The bit-index corresponds to the integer value
4857 // of a ComparisonCategoryType enumerator.
4858 llvm::SmallBitVector FullyCheckedComparisonCategories;
4859
4860 ValueDecl *tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl,
4861 CXXScopeSpec &SS,
4862 ParsedType TemplateTypeTy,
4863 IdentifierInfo *MemberOrBase);
4864
4865 /// Check if there is a field shadowing.
4866 void CheckShadowInheritedFields(const SourceLocation &Loc,
4867 DeclarationName FieldName,
4868 const CXXRecordDecl *RD,
4869 bool DeclIsField = true);
4870
4871 ///@}
4872
4873 //
4874 //
4875 // -------------------------------------------------------------------------
4876 //
4877 //
4878
4879 /// \name C++ Exception Specifications
4880 /// Implementations are in SemaExceptionSpec.cpp
4881 ///@{
4882
4883public:
4884 /// All the overriding functions seen during a class definition
4885 /// that had their exception spec checks delayed, plus the overridden
4886 /// function.
4889
4890 /// All the function redeclarations seen during a class definition that had
4891 /// their exception spec checks delayed, plus the prior declaration they
4892 /// should be checked against. Except during error recovery, the new decl
4893 /// should always be a friend declaration, as that's the only valid way to
4894 /// redeclare a special member before its class is complete.
4897
4898 /// Determine if we're in a case where we need to (incorrectly) eagerly
4899 /// parse an exception specification to work around a libstdc++ bug.
4901
4902 /// Check the given noexcept-specifier, convert its expression, and compute
4903 /// the appropriate ExceptionSpecificationType.
4904 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
4906
4907 CanThrowResult canThrow(const Stmt *E);
4908 /// Determine whether the callee of a particular function call can throw.
4909 /// E, D and Loc are all optional.
4910 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
4913 const FunctionProtoType *FPT);
4920 SourceLocation OldLoc,
4921 const FunctionProtoType *New,
4922 SourceLocation NewLoc);
4924 const PartialDiagnostic &NoteID,
4925 const FunctionProtoType *Old,
4926 SourceLocation OldLoc,
4927 const FunctionProtoType *New,
4928 SourceLocation NewLoc);
4929 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
4931 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
4932 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
4933 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
4934 SourceLocation SuperLoc, const FunctionProtoType *Subset,
4935 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
4937 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
4938 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
4939 SourceLocation TargetLoc, const FunctionProtoType *Source,
4940 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
4941
4942 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
4943
4944 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
4945 /// spec is a subset of base spec.
4947 const CXXMethodDecl *Old);
4948
4949 ///@}
4950
4951 //
4952 //
4953 // -------------------------------------------------------------------------
4954 //
4955 //
4956
4957 /// \name Expressions
4958 /// Implementations are in SemaExpr.cpp
4959 ///@{
4960
4961public:
4962 /// Describes how the expressions currently being parsed are
4963 /// evaluated at run-time, if at all.
4965 /// The current expression and its subexpressions occur within an
4966 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
4967 /// \c sizeof, where the type of the expression may be significant but
4968 /// no code will be generated to evaluate the value of the expression at
4969 /// run time.
4971
4972 /// The current expression occurs within a braced-init-list within
4973 /// an unevaluated operand. This is mostly like a regular unevaluated
4974 /// context, except that we still instantiate constexpr functions that are
4975 /// referenced here so that we can perform narrowing checks correctly.
4977
4978 /// The current expression occurs within a discarded statement.
4979 /// This behaves largely similarly to an unevaluated operand in preventing
4980 /// definitions from being required, but not in other ways.
4982
4983 /// The current expression occurs within an unevaluated
4984 /// operand that unconditionally permits abstract references to
4985 /// fields, such as a SIZE operator in MS-style inline assembly.
4987
4988 /// The current context is "potentially evaluated" in C++11 terms,
4989 /// but the expression is evaluated at compile-time (like the values of
4990 /// cases in a switch statement).
4992
4993 /// In addition of being constant evaluated, the current expression
4994 /// occurs in an immediate function context - either a consteval function
4995 /// or a consteval if statement.
4997
4998 /// The current expression is potentially evaluated at run time,
4999 /// which means that code may be generated to evaluate the value of the
5000 /// expression at run time.
5002
5003 /// The current expression is potentially evaluated, but any
5004 /// declarations referenced inside that expression are only used if
5005 /// in fact the current expression is used.
5006 ///
5007 /// This value is used when parsing default function arguments, for which
5008 /// we would like to provide diagnostics (e.g., passing non-POD arguments
5009 /// through varargs) but do not want to mark declarations as "referenced"
5010 /// until the default argument is used.
5012 };
5013
5014 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
5015 /// to a variable (constant) that may or may not be odr-used in this Expr, and
5016 /// we won't know until all lvalue-to-rvalue and discarded value conversions
5017 /// have been applied to all subexpressions of the enclosing full expression.
5018 /// This is cleared at the end of each full expression.
5021
5022 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
5023
5024 /// Data structure used to record current or nested
5025 /// expression evaluation contexts.
5027 /// The expression evaluation context.
5029
5030 /// Whether the enclosing context needed a cleanup.
5032
5033 /// The number of active cleanup objects when we entered
5034 /// this expression evaluation context.
5036
5037 /// The number of typos encountered during this expression evaluation
5038 /// context (i.e. the number of TypoExprs created).
5039 unsigned NumTypos;
5040
5042
5043 /// The lambdas that are present within this context, if it
5044 /// is indeed an unevaluated context.
5046
5047 /// The declaration that provides context for lambda expressions
5048 /// and block literals if the normal declaration context does not
5049 /// suffice, e.g., in a default function argument.
5051
5052 /// If we are processing a decltype type, a set of call expressions
5053 /// for which we have deferred checking the completeness of the return type.
5055
5056 /// If we are processing a decltype type, a set of temporary binding
5057 /// expressions for which we have deferred checking the destructor.
5059
5061
5062 /// Expressions appearing as the LHS of a volatile assignment in this
5063 /// context. We produce a warning for these when popping the context if
5064 /// they are not discarded-value expressions nor unevaluated operands.
5066
5067 /// Set of candidates for starting an immediate invocation.
5070
5071 /// Set of DeclRefExprs referencing a consteval function when used in a
5072 /// context not already known to be immediately invoked.
5074
5075 /// P2718R0 - Lifetime extension in range-based for loops.
5076 /// MaterializeTemporaryExprs in for-range-init expressions which need to
5077 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
5078 /// InLifetimeExtendingContext is true.
5080
5081 /// \brief Describes whether we are in an expression constext which we have
5082 /// to handle differently.
5087 EK_Other
5088 } ExprContext;
5089
5090 // A context can be nested in both a discarded statement context and
5091 // an immediate function context, so they need to be tracked independently.
5095
5096 bool IsCurrentlyCheckingDefaultArgumentOrInitializer = false;
5097
5098 // We are in a constant context, but we also allow
5099 // non constant expressions, for example for array bounds (which may be
5100 // VLAs).
5101 bool InConditionallyConstantEvaluateContext = false;
5102
5103 /// Whether we are currently in a context in which all temporaries must be
5104 /// lifetime-extended, even if they're not bound to a reference (for
5105 /// example, in a for-range initializer).
5106 bool InLifetimeExtendingContext = false;
5107
5108 // When evaluating immediate functions in the initializer of a default
5109 // argument or default member initializer, this is the declaration whose
5110 // default initializer is being evaluated and the location of the call
5111 // or constructor definition.
5114 DeclContext *Context)
5115 : Loc(Loc), Decl(Decl), Context(Context) {
5116 assert(Decl && Context && "invalid initialization context");
5117 }
5118
5120 ValueDecl *Decl = nullptr;
5121 DeclContext *Context = nullptr;
5122 };
5123 std::optional<InitializationContext> DelayedDefaultInitializationContext;
5124
5126 unsigned NumCleanupObjects,
5127 CleanupInfo ParentCleanup,
5128 Decl *ManglingContextDecl,
5129 ExpressionKind ExprContext)
5130 : Context(Context), ParentCleanup(ParentCleanup),
5131 NumCleanupObjects(NumCleanupObjects), NumTypos(0),
5132 ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext),
5133 InDiscardedStatement(false), InImmediateFunctionContext(false),
5134 InImmediateEscalatingFunctionContext(false) {}
5135
5136 bool isUnevaluated() const {
5137 return Context == ExpressionEvaluationContext::Unevaluated ||
5138 Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
5139 Context == ExpressionEvaluationContext::UnevaluatedList;
5140 }
5141
5142 bool isConstantEvaluated() const {
5143 return Context == ExpressionEvaluationContext::ConstantEvaluated ||
5144 Context == ExpressionEvaluationContext::ImmediateFunctionContext;
5145 }
5146
5148 return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
5149 (Context == ExpressionEvaluationContext::DiscardedStatement &&
5150 InImmediateFunctionContext) ||
5151 // C++23 [expr.const]p14:
5152 // An expression or conversion is in an immediate function
5153 // context if it is potentially evaluated and either:
5154 // * its innermost enclosing non-block scope is a function
5155 // parameter scope of an immediate function, or
5156 // * its enclosing statement is enclosed by the compound-
5157 // statement of a consteval if statement.
5158 (Context == ExpressionEvaluationContext::PotentiallyEvaluated &&
5159 InImmediateFunctionContext);
5160 }
5161
5163 return Context == ExpressionEvaluationContext::DiscardedStatement ||
5164 (Context ==
5165 ExpressionEvaluationContext::ImmediateFunctionContext &&
5166 InDiscardedStatement);
5167 }
5168 };
5169
5171 assert(!ExprEvalContexts.empty() &&
5172 "Must be in an expression evaluation context");
5173 return ExprEvalContexts.back();
5174 };
5175
5176 bool isBoundsAttrContext() const {
5177 return ExprEvalContexts.back().ExprContext ==
5180 }
5181
5182 /// Increment when we find a reference; decrement when we find an ignored
5183 /// assignment. Ultimately the value is 0 if every reference is an ignored
5184 /// assignment.
5185 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
5186
5187 /// Used to control the generation of ExprWithCleanups.
5189
5190 /// ExprCleanupObjects - This is the stack of objects requiring
5191 /// cleanup that are created by the current full expression.
5193
5194 // AssignmentAction - This is used by all the assignment diagnostic functions
5195 // to represent what is actually causing the operation
5206
5207 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
5208 // A version of DiagnoseUseOfDecl that should be used if overload resolution
5209 // has been used to find this declaration, which means we don't have to bother
5210 // checking the trailing requires clause.
5212 return DiagnoseUseOfDecl(
5213 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
5214 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
5215 /*SkipTrailingRequiresClause=*/true);
5216 }
5217
5219 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
5220 bool ObjCPropertyAccess = false,
5221 bool AvoidPartialAvailabilityChecks = false,
5222 ObjCInterfaceDecl *ClassReciever = nullptr,
5223 bool SkipTrailingRequiresClause = false);
5225
5227 ArrayRef<Expr *> Args);
5228
5230 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
5239
5241
5245
5247
5249
5250 // Functions for marking a declaration referenced. These functions also
5251 // contain the relevant logic for marking if a reference to a function or
5252 // variable is an odr-use (in the C++11 sense). There are separate variants
5253 // for expressions referring to a decl; these exist because odr-use marking
5254 // needs to be delayed for some constant variables when we build one of the
5255 // named expressions.
5256 //
5257 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
5258 // should usually be true. This only needs to be set to false if the lack of
5259 // odr-use cannot be determined from the current context (for instance,
5260 // because the name denotes a virtual function and was written without an
5261 // explicit nested-name-specifier).
5262 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
5264 bool MightBeOdrUse = true);
5266 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
5270 unsigned CapturingScopeIndex);
5271
5273 void CleanupVarDeclMarking();
5274
5280
5281 /// Try to capture the given variable.
5282 ///
5283 /// \param Var The variable to capture.
5284 ///
5285 /// \param Loc The location at which the capture occurs.
5286 ///
5287 /// \param Kind The kind of capture, which may be implicit (for either a
5288 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
5289 ///
5290 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
5291 /// an explicit lambda capture.
5292 ///
5293 /// \param BuildAndDiagnose Whether we are actually supposed to add the
5294 /// captures or diagnose errors. If false, this routine merely check whether
5295 /// the capture can occur without performing the capture itself or complaining
5296 /// if the variable cannot be captured.
5297 ///
5298 /// \param CaptureType Will be set to the type of the field used to capture
5299 /// this variable in the innermost block or lambda. Only valid when the
5300 /// variable can be captured.
5301 ///
5302 /// \param DeclRefType Will be set to the type of a reference to the capture
5303 /// from within the current scope. Only valid when the variable can be
5304 /// captured.
5305 ///
5306 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
5307 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
5308 /// This is useful when enclosing lambdas must speculatively capture
5309 /// variables that may or may not be used in certain specializations of
5310 /// a nested generic lambda.
5311 ///
5312 /// \returns true if an error occurred (i.e., the variable cannot be
5313 /// captured) and false if the capture succeeded.
5315 TryCaptureKind Kind, SourceLocation EllipsisLoc,
5316 bool BuildAndDiagnose, QualType &CaptureType,
5317 QualType &DeclRefType,
5318 const unsigned *const FunctionScopeIndexToStopAt);
5319
5320 /// Try to capture the given variable.
5323 SourceLocation EllipsisLoc = SourceLocation());
5324
5325 /// Checks if the variable must be captured.
5327
5328 /// Given a variable, determine the type that a reference to that
5329 /// variable will have in the given scope.
5331
5332 /// Mark all of the declarations referenced within a particular AST node as
5333 /// referenced. Used when template instantiation instantiates a non-dependent
5334 /// type -- entities referenced by the type are now referenced.
5337 Expr *E, bool SkipLocalVariables = false,
5338 ArrayRef<const Expr *> StopAt = std::nullopt);
5339
5340 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
5341 /// conversion.
5343
5344 /// Conditionally issue a diagnostic based on the statements's reachability
5345 /// analysis.
5346 ///
5347 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
5348 /// the function body is parsed, and then do a basic reachability analysis to
5349 /// determine if the statement is reachable. If it is unreachable, the
5350 /// diagnostic will not be emitted.
5352 const PartialDiagnostic &PD);
5353
5354 /// Conditionally issue a diagnostic based on the current
5355 /// evaluation context.
5356 ///
5357 /// \param Statement If Statement is non-null, delay reporting the
5358 /// diagnostic until the function body is parsed, and then do a basic
5359 /// reachability analysis to determine if the statement is reachable.
5360 /// If it is unreachable, the diagnostic will not be emitted.
5361 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
5362 const PartialDiagnostic &PD);
5363 /// Similar, but diagnostic is only produced if all the specified statements
5364 /// are reachable.
5366 const PartialDiagnostic &PD);
5367
5368 // Primary Expressions.
5369 SourceRange getExprRange(Expr *E) const;
5370
5372 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
5373 bool HasTrailingLParen, bool IsAddressOfOperand,
5374 CorrectionCandidateCallback *CCC = nullptr,
5375 bool IsInlineAsmIdentifier = false,
5376 Token *KeywordReplacement = nullptr);
5377
5380 DeclarationNameInfo &NameInfo,
5381 const TemplateArgumentListInfo *&TemplateArgs);
5382
5384
5385 bool
5388 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
5389 ArrayRef<Expr *> Args = std::nullopt,
5390 DeclContext *LookupCtx = nullptr,
5391 TypoExpr **Out = nullptr);
5392
5394 IdentifierInfo *II);
5396
5398 IdentifierInfo *II,
5399 bool AllowBuiltinCreation = false);
5400
5401 /// If \p D cannot be odr-used in the current expression evaluation context,
5402 /// return a reason explaining why. Otherwise, return NOUR_None.
5404
5406 SourceLocation Loc,
5407 const CXXScopeSpec *SS = nullptr);
5408 DeclRefExpr *
5410 const DeclarationNameInfo &NameInfo,
5411 const CXXScopeSpec *SS = nullptr,
5412 NamedDecl *FoundD = nullptr,
5413 SourceLocation TemplateKWLoc = SourceLocation(),
5414 const TemplateArgumentListInfo *TemplateArgs = nullptr);
5415 DeclRefExpr *
5417 const DeclarationNameInfo &NameInfo,
5418 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
5419 SourceLocation TemplateKWLoc = SourceLocation(),
5420 const TemplateArgumentListInfo *TemplateArgs = nullptr);
5421
5422 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
5423 bool HasTrailingLParen);
5424
5427 const DeclarationNameInfo &NameInfo,
5428 bool IsAddressOfOperand, const Scope *S,
5429 TypeSourceInfo **RecoveryTSI = nullptr);
5430
5432 bool NeedsADL,
5433 bool AcceptInvalidDecl = false);
5435 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
5436 NamedDecl *FoundD = nullptr,
5437 const TemplateArgumentListInfo *TemplateArgs = nullptr,
5438 bool AcceptInvalidDecl = false);
5439
5440 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
5441 // where Tokens representing function local predefined macros (such as
5442 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
5444
5448
5449 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
5450
5451 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
5453 Scope *UDLScope = nullptr);
5456 MultiExprArg Val);
5457
5458 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
5459 /// fragments (e.g. "foo" "bar" L"baz").
5461 Scope *UDLScope = nullptr);
5462
5464
5465 /// ControllingExprOrType is either an opaque pointer coming out of a
5466 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
5467 /// into two so we don't take a void *, but that's awkward because one of
5468 /// the operands is either a ParsedType or an Expr *, which doesn't lend
5469 /// itself to generic code very well.
5471 SourceLocation DefaultLoc,
5472 SourceLocation RParenLoc,
5473 bool PredicateIsExpr,
5474 void *ControllingExprOrType,
5475 ArrayRef<ParsedType> ArgTypes,
5476 ArrayRef<Expr *> ArgExprs);
5477 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
5478 /// it'd be better to split this interface into two so we don't take a
5479 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
5480 /// isn't a trivial change.
5482 SourceLocation DefaultLoc,
5483 SourceLocation RParenLoc,
5484 bool PredicateIsExpr,
5485 void *ControllingExprOrType,
5487 ArrayRef<Expr *> Exprs);
5488
5489 // Binary/Unary Operators. 'Tok' is the token for the operator.
5491 Expr *InputExpr, bool IsAfterAmp = false);
5493 Expr *Input, bool IsAfterAmp = false);
5495 Expr *Input, bool IsAfterAmp = false);
5496
5499 const Expr *Op,
5500 const CXXMethodDecl *MD);
5501
5503
5504 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
5505 SourceLocation OpLoc, SourceRange R);
5506 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
5507 SourceLocation OpLoc, SourceRange R);
5508
5510 SourceLocation OpLoc,
5511 UnaryExprOrTypeTrait ExprKind,
5512 SourceRange R);
5514 UnaryExprOrTypeTrait ExprKind);
5516 UnaryExprOrTypeTrait ExprKind,
5517 bool IsType, void *TyOrEx,
5518 SourceRange ArgRange);
5519
5521 bool CheckVecStepExpr(Expr *E);
5522
5525 SourceRange ExprRange,
5526 UnaryExprOrTypeTrait ExprKind,
5527 StringRef KWName);
5528
5530 tok::TokenKind Kind, Expr *Input);
5531
5533 MultiExprArg ArgExprs,
5534 SourceLocation RLoc);
5536 Expr *Idx, SourceLocation RLoc);
5537
5539 Expr *ColumnIdx,
5540 SourceLocation RBLoc);
5541
5543 const FunctionProtoType *Proto,
5544 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
5545 bool ExecConfig = false);
5547 const Expr *ArgExpr);
5548
5549 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
5550 /// This provides the location of the left/right parens and a list of comma
5551 /// locations.
5553 MultiExprArg ArgExprs, SourceLocation RParenLoc,
5554 Expr *ExecConfig = nullptr);
5556 MultiExprArg ArgExprs, SourceLocation RParenLoc,
5557 Expr *ExecConfig = nullptr,
5558 bool IsExecConfig = false,
5559 bool AllowRecovery = false);
5561 MultiExprArg CallArgs);
5562
5564
5566 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
5567 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
5568 Expr *Config = nullptr, bool IsExecConfig = false,
5569 ADLCallKind UsesADL = ADLCallKind::NotADL);
5570
5572 ParsedType &Ty, SourceLocation RParenLoc,
5573 Expr *CastExpr);
5574
5576
5577 /// Build an altivec or OpenCL literal.
5579 SourceLocation RParenLoc, Expr *E,
5580 TypeSourceInfo *TInfo);
5581
5583
5585 SourceLocation RParenLoc, Expr *InitExpr);
5586
5588 TypeSourceInfo *TInfo,
5589 SourceLocation RParenLoc,
5590 Expr *LiteralExpr);
5591
5592 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
5593 SourceLocation RBraceLoc);
5594
5595 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
5596 SourceLocation RBraceLoc);
5597
5599 Expr *LHSExpr, Expr *RHSExpr);
5601 Expr *LHSExpr, Expr *RHSExpr);
5603 Expr *LHSExpr, Expr *RHSExpr);
5605 UnresolvedSetImpl &Functions);
5606
5607 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
5608
5609 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
5610 /// in the case of a the GNU conditional expr extension.
5612 SourceLocation ColonLoc, Expr *CondExpr,
5613 Expr *LHSExpr, Expr *RHSExpr);
5614
5615 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
5617 LabelDecl *TheDecl);
5618
5619 void ActOnStartStmtExpr();
5620 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
5621 SourceLocation RPLoc);
5623 SourceLocation RPLoc, unsigned TemplateDepth);
5624 // Handle the final expression in a statement expression.
5626 void ActOnStmtExprError();
5627
5628 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
5631 bool isBrackets; // true if [expr], false if .ident
5632 union {
5635 } U;
5636 };
5637
5638 /// __builtin_offsetof(type, a.b[123][456].c)
5640 TypeSourceInfo *TInfo,
5641 ArrayRef<OffsetOfComponent> Components,
5642 SourceLocation RParenLoc);
5645 ParsedType ParsedArgTy,
5646 ArrayRef<OffsetOfComponent> Components,
5647 SourceLocation RParenLoc);
5648
5649 // __builtin_choose_expr(constExpr, expr1, expr2)
5650 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
5651 Expr *LHSExpr, Expr *RHSExpr,
5652 SourceLocation RPLoc);
5653
5654 // __builtin_va_arg(expr, type)
5656 SourceLocation RPLoc);
5658 TypeSourceInfo *TInfo, SourceLocation RPLoc);
5659
5660 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
5661 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
5663 SourceLocation BuiltinLoc,
5664 SourceLocation RPLoc);
5665
5666 // Build a potentially resolved SourceLocExpr.
5668 SourceLocation BuiltinLoc, SourceLocation RPLoc,
5669 DeclContext *ParentContext);
5670
5671 // __null
5673
5674 bool CheckCaseExpression(Expr *E);
5675
5676 //===------------------------- "Block" Extension ------------------------===//
5677
5678 /// ActOnBlockStart - This callback is invoked when a block literal is
5679 /// started.
5680 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
5681
5682 /// ActOnBlockArguments - This callback allows processing of block arguments.
5683 /// If there are no arguments, this is still invoked.
5684 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
5685 Scope *CurScope);
5686
5687 /// ActOnBlockError - If there is an error parsing a block, this callback
5688 /// is invoked to pop the information about the block from the action impl.
5689 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
5690
5691 /// ActOnBlockStmtExpr - This is called when the body of a block statement
5692 /// literal was successfully completed. ^(int x){...}
5694 Scope *CurScope);
5695
5696 //===---------------------------- Clang Extensions ----------------------===//
5697
5698 /// __builtin_convertvector(...)
5700 SourceLocation BuiltinLoc,
5701 SourceLocation RParenLoc);
5702
5703 //===---------------------------- OpenCL Features -----------------------===//
5704
5705 /// __builtin_astype(...)
5706 ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
5707 SourceLocation BuiltinLoc,
5708 SourceLocation RParenLoc);
5710 SourceLocation BuiltinLoc,
5711 SourceLocation RParenLoc);
5712
5713 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
5715 ArrayRef<Expr *> SubExprs,
5716 QualType T = QualType());
5717
5718 // Note that LK_String is intentionally after the other literals, as
5719 // this is used for diagnostics logic.
5727 LK_None
5730
5732 NestedNameSpecifier *Qualifier,
5733 NamedDecl *FoundDecl,
5734 NamedDecl *Member);
5735
5736 /// CheckCallReturnType - Checks that a call expression's return type is
5737 /// complete. Returns true on failure. The location passed in is the location
5738 /// that best represents the call.
5739 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
5740 CallExpr *CE, FunctionDecl *FD);
5741
5742 /// Emit a warning for all pending noderef expressions that we recorded.
5743 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
5744
5746
5747 /// Instantiate or parse a C++ default argument expression as necessary.
5748 /// Return true on error.
5750 ParmVarDecl *Param, Expr *Init = nullptr,
5751 bool SkipImmediateInvocations = true);
5752
5753 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
5754 /// the default expr if needed.
5756 ParmVarDecl *Param, Expr *Init = nullptr);
5757
5758 /// Wrap the expression in a ConstantExpr if it is a potential immediate
5759 /// invocation.
5761
5763
5764 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
5765
5767 const DeclContext *DC = getCurLexicalContext();
5768 // A category implicitly has the attribute of the interface.
5769 if (const ObjCCategoryDecl *CatD = dyn_cast<ObjCCategoryDecl>(DC))
5770 DC = CatD->getClassInterface();
5771 return DC;
5772 }
5773
5774 /// Abstract base class used for diagnosing integer constant
5775 /// expression violations.
5777 public:
5779
5780 VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {}
5781
5782 virtual SemaDiagnosticBuilder
5783 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
5785 SourceLocation Loc) = 0;
5786 virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc);
5788 };
5789
5793 };
5794
5795 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
5796 /// and reports the appropriate diagnostics. Returns false on success.
5797 /// Can optionally return the value of the expression.
5799 VerifyICEDiagnoser &Diagnoser,
5800 AllowFoldKind CanFold = NoFold);
5802 unsigned DiagID,
5803 AllowFoldKind CanFold = NoFold);
5805 llvm::APSInt *Result = nullptr,
5806 AllowFoldKind CanFold = NoFold);
5808 AllowFoldKind CanFold = NoFold) {
5809 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
5810 }
5811
5812 /// DiagnoseAssignmentAsCondition - Given that an expression is
5813 /// being used as a boolean condition, warn if it's an assignment.
5815
5816 /// Redundant parentheses over an equality comparison can indicate
5817 /// that the user intended an assignment used as condition.
5819
5821 public:
5822 FullExprArg() : E(nullptr) {}
5823 FullExprArg(Sema &actions) : E(nullptr) {}
5824
5825 ExprResult release() { return E; }
5826
5827 Expr *get() const { return E; }
5828
5829 Expr *operator->() { return E; }
5830
5831 private:
5832 // FIXME: No need to make the entire Sema class a friend when it's just
5833 // Sema::MakeFullExpr that needs access to the constructor below.
5834 friend class Sema;
5835
5836 explicit FullExprArg(Expr *expr) : E(expr) {}
5837
5838 Expr *E;
5839 };
5840
5842 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
5843 }
5845 return FullExprArg(
5846 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
5847 }
5849 ExprResult FE =
5850 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
5851 /*DiscardedValue*/ true);
5852 return FullExprArg(FE.get());
5853 }
5854
5856 Decl *ConditionVar;
5858 bool Invalid;
5859 std::optional<bool> KnownValue;
5860
5861 friend class Sema;
5862 ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
5863 bool IsConstexpr)
5864 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
5865 if (IsConstexpr && Condition.get()) {
5866 if (std::optional<llvm::APSInt> Val =
5867 Condition.get()->getIntegerConstantExpr(S.Context)) {
5868 KnownValue = !!(*Val);
5869 }
5870 }
5871 }
5872 explicit ConditionResult(bool Invalid)
5873 : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
5874 KnownValue(std::nullopt) {}
5875
5876 public:
5878 bool isInvalid() const { return Invalid; }
5879 std::pair<VarDecl *, Expr *> get() const {
5880 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
5881 Condition.get());
5882 }
5883 std::optional<bool> getKnownValue() const { return KnownValue; }
5884 };
5886
5887 /// CheckBooleanCondition - Diagnose problems involving the use of
5888 /// the given expression as a boolean condition (e.g. in an if
5889 /// statement). Also performs the standard function and array
5890 /// decays, possibly changing the input variable.
5891 ///
5892 /// \param Loc - A location associated with the condition, e.g. the
5893 /// 'if' keyword.
5894 /// \return true iff there were any errors
5896 bool IsConstexpr = false);
5897
5898 enum class ConditionKind {
5899 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
5900 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
5901 Switch ///< An integral condition for a 'switch' statement.
5902 };
5903
5904 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
5905 ConditionKind CK, bool MissingOK = false);
5906
5907 QualType CheckConditionalOperands( // C99 6.5.15
5908 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
5909 ExprObjectKind &OK, SourceLocation QuestionLoc);
5910
5912 SourceLocation QuestionLoc);
5913
5914 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
5915 SourceLocation QuestionLoc);
5916
5917 /// type checking for vector binary operators.
5919 SourceLocation Loc, bool IsCompAssign,
5920 bool AllowBothBool, bool AllowBoolConversion,
5921 bool AllowBoolOperation, bool ReportInvalid);
5925 SourceLocation Loc,
5926 BinaryOperatorKind Opc);
5928 SourceLocation Loc,
5929 BinaryOperatorKind Opc);
5931 SourceLocation Loc);
5932
5933 /// Context in which we're performing a usual arithmetic conversion.
5935 /// An arithmetic operation.
5937 /// A bitwise operation.
5939 /// A comparison.
5941 /// A conditional (?:) operator.
5943 /// A compound assignment expression.
5945 };
5946
5947 // type checking for sizeless vector binary operators.
5949 SourceLocation Loc, bool IsCompAssign,
5950 ArithConvKind OperationKind);
5951
5952 /// Type checking for matrix binary operators.
5954 SourceLocation Loc,
5955 bool IsCompAssign);
5957 SourceLocation Loc, bool IsCompAssign);
5958
5959 bool isValidSveBitcast(QualType srcType, QualType destType);
5960 bool isValidRVVBitcast(QualType srcType, QualType destType);
5961
5963
5964 bool areVectorTypesSameSize(QualType srcType, QualType destType);
5965 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
5966 bool isLaxVectorConversion(QualType srcType, QualType destType);
5967 bool anyAltivecTypes(QualType srcType, QualType destType);
5968
5969 // type checking C++ declaration initializers (C++ [dcl.init]).
5970
5973 ExprValueKind &VK, CXXCastPath &Path);
5974
5975 /// Force an expression with unknown-type to an expression of the
5976 /// given type.
5978
5979 /// Type-check an expression that's being passed to an
5980 /// __unknown_anytype parameter.
5982 QualType &paramType);
5983
5984 // CheckMatrixCast - Check type constraints for matrix casts.
5985 // We allow casting between matrixes of the same dimensions i.e. when they
5986 // have the same number of rows and column. Returns true if the cast is
5987 // invalid.
5988 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
5989 CastKind &Kind);
5990
5991 // CheckVectorCast - check type constraints for vectors.
5992 // Since vectors are an extension, there are no C standard reference for this.
5993 // We allow casting between vectors and integer datatypes of the same size.
5994 // returns true if the cast is invalid
5995 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
5996 CastKind &Kind);
5997
5998 /// Prepare `SplattedExpr` for a vector splat operation, adding
5999 /// implicit casts if necessary.
6000 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
6001
6002 // CheckExtVectorCast - check type constraints for extended vectors.
6003 // Since vectors are an extension, there are no C standard reference for this.
6004 // We allow casting between vectors and integer datatypes of the same size,
6005 // or vectors and the element type of that vector.
6006 // returns the cast expr
6008 CastKind &Kind);
6009
6012 }
6013
6014 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
6015 // functions and arrays to their respective pointers (C99 6.3.2.1).
6017
6018 /// CallExprUnaryConversions - a special case of an unary conversion
6019 /// performed on a function designator of a call expression.
6021
6022 // DefaultFunctionArrayConversion - converts functions and arrays
6023 // to their respective pointers (C99 6.3.2.1).
6025
6026 // DefaultFunctionArrayLvalueConversion - converts functions and
6027 // arrays to their respective pointers and performs the
6028 // lvalue-to-rvalue conversion.
6030 bool Diagnose = true);
6031
6032 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
6033 // the operand. This function is a no-op if the operand has a function type
6034 // or an array type.
6036
6037 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
6038 // do not have a prototype. Integer promotions are performed on each
6039 // argument, and arguments that have type float are promoted to double.
6041
6043 const FunctionProtoType *Proto,
6044 Expr *Fn);
6045
6046 // Used for determining in which context a type is allowed to be passed to a
6047 // vararg function.
6055
6056 // Determines which VarArgKind fits an expression.
6058
6059 /// Check to see if the given expression is a valid argument to a variadic
6060 /// function, issuing a diagnostic if not.
6061 void checkVariadicArgument(const Expr *E, VariadicCallType CT);
6062
6063 /// GatherArgumentsForCall - Collector argument expressions for various
6064 /// form of call prototypes.
6066 const FunctionProtoType *Proto,
6067 unsigned FirstParam, ArrayRef<Expr *> Args,
6068 SmallVectorImpl<Expr *> &AllArgs,
6070 bool AllowExplicit = false,
6071 bool IsListInitialization = false);
6072
6073 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
6074 // will create a runtime trap if the resulting type is not a POD type.
6076 FunctionDecl *FDecl);
6077
6078 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
6079 // operands and then handles various conversions that are common to binary
6080 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
6081 // routine returns the first non-arithmetic type found. The client is
6082 // responsible for emitting appropriate error diagnostics.
6084 SourceLocation Loc, ArithConvKind ACK);
6085
6086 /// AssignConvertType - All of the 'assignment' semantic checks return this
6087 /// enum to indicate whether the assignment was allowed. These checks are
6088 /// done for simple assignments, as well as initialization, return from
6089 /// function, argument passing, etc. The query is phrased in terms of a
6090 /// source and destination type.
6092 /// Compatible - the types are compatible according to the standard.
6094
6095 /// PointerToInt - The assignment converts a pointer to an int, which we
6096 /// accept as an extension.
6098
6099 /// IntToPointer - The assignment converts an int to a pointer, which we
6100 /// accept as an extension.
6102
6103 /// FunctionVoidPointer - The assignment is between a function pointer and
6104 /// void*, which the standard doesn't allow, but we accept as an extension.
6106
6107 /// IncompatiblePointer - The assignment is between two pointers types that
6108 /// are not compatible, but we accept them as an extension.
6110
6111 /// IncompatibleFunctionPointer - The assignment is between two function
6112 /// pointers types that are not compatible, but we accept them as an
6113 /// extension.
6115
6116 /// IncompatibleFunctionPointerStrict - The assignment is between two
6117 /// function pointer types that are not identical, but are compatible,
6118 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
6119 /// may trip an indirect call runtime check.
6121
6122 /// IncompatiblePointerSign - The assignment is between two pointers types
6123 /// which point to integers which have a different sign, but are otherwise
6124 /// identical. This is a subset of the above, but broken out because it's by
6125 /// far the most common case of incompatible pointers.
6127
6128 /// CompatiblePointerDiscardsQualifiers - The assignment discards
6129 /// c/v/r qualifiers, which we accept as an extension.
6131
6132 /// IncompatiblePointerDiscardsQualifiers - The assignment
6133 /// discards qualifiers that we don't permit to be discarded,
6134 /// like address spaces.
6136
6137 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
6138 /// changes address spaces in nested pointer types which is not allowed.
6139 /// For instance, converting __private int ** to __generic int ** is
6140 /// illegal even though __private could be converted to __generic.
6142
6143 /// IncompatibleNestedPointerQualifiers - The assignment is between two
6144 /// nested pointer types, and the qualifiers other than the first two
6145 /// levels differ e.g. char ** -> const char **, but we accept them as an
6146 /// extension.
6148
6149 /// IncompatibleVectors - The assignment is between two vector types that
6150 /// have the same size, which we accept as an extension.
6152
6153 /// IntToBlockPointer - The assignment converts an int to a block
6154 /// pointer. We disallow this.
6156
6157 /// IncompatibleBlockPointer - The assignment is between two block
6158 /// pointers types that are not compatible.
6160
6161 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
6162 /// id type and something else (that is incompatible with it). For example,
6163 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
6165
6166 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
6167 /// object with __weak qualifier.
6169
6170 /// Incompatible - We reject this conversion outright, it is invalid to
6171 /// represent it in the AST.
6174
6175 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
6176 /// assignment conversion type specified by ConvTy. This returns true if the
6177 /// conversion was invalid or false if the conversion was accepted.
6179 QualType DstType, QualType SrcType,
6180 Expr *SrcExpr, AssignmentAction Action,
6181 bool *Complained = nullptr);
6182
6183 /// CheckAssignmentConstraints - Perform type checking for assignment,
6184 /// argument passing, variable initialization, and function return values.
6185 /// C99 6.5.16.
6187 QualType LHSType,
6188 QualType RHSType);
6189
6190 /// Check assignment constraints and optionally prepare for a conversion of
6191 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
6192 /// is true.
6194 ExprResult &RHS, CastKind &Kind,
6195 bool ConvertRHS = true);
6196
6197 /// Check assignment constraints for an assignment of RHS to LHSType.
6198 ///
6199 /// \param LHSType The destination type for the assignment.
6200 /// \param RHS The source expression for the assignment.
6201 /// \param Diagnose If \c true, diagnostics may be produced when checking
6202 /// for assignability. If a diagnostic is produced, \p RHS will be
6203 /// set to ExprError(). Note that this function may still return
6204 /// without producing a diagnostic, even for an invalid assignment.
6205 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
6206 /// in an audited Core Foundation API and does not need to be checked
6207 /// for ARC retain issues.
6208 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
6209 /// conversions necessary to perform the assignment. If \c false,
6210 /// \p Diagnose must also be \c false.
6212 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
6213 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
6214
6215 // If the lhs type is a transparent union, check whether we
6216 // can initialize the transparent union with the given expression.
6218 ExprResult &RHS);
6219
6220 /// the following "Check" methods will return a valid/converted QualType
6221 /// or a null QualType (indicating an error diagnostic was issued).
6222
6223 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
6225 ExprResult &RHS);
6227 ExprResult &RHS);
6228
6230 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
6231 bool IsDivide);
6232 QualType CheckRemainderOperands( // C99 6.5.5
6233 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
6234 bool IsCompAssign = false);
6235 QualType CheckAdditionOperands( // C99 6.5.6
6236 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
6237 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
6239 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
6240 QualType *CompLHSTy = nullptr);
6241 QualType CheckShiftOperands( // C99 6.5.7
6242 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
6243 BinaryOperatorKind Opc, bool IsCompAssign = false);
6245 QualType CheckCompareOperands( // C99 6.5.8/9
6246 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
6247 BinaryOperatorKind Opc);
6248 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
6249 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
6250 BinaryOperatorKind Opc);
6251 QualType CheckLogicalOperands( // C99 6.5.[13,14]
6252 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
6253 BinaryOperatorKind Opc);
6254 // CheckAssignmentOperands is used for both simple and compound assignment.
6255 // For simple assignment, pass both expressions and a null converted type.
6256 // For compound assignment, pass both expressions and the converted type.
6257 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
6258 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
6259 BinaryOperatorKind Opc);
6260
6261 bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr,
6262 bool Diagnose = true);
6263
6264 /// To be used for checking whether the arguments being passed to
6265 /// function exceeds the number of parameters expected for it.
6266 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
6267 bool PartialOverloading = false) {
6268 // We check whether we're just after a comma in code-completion.
6269 if (NumArgs > 0 && PartialOverloading)
6270 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
6271 return NumArgs > NumParams;
6272 }
6273
6274 /// Whether the AST is currently being rebuilt to correct immediate
6275 /// invocations. Immediate invocation candidates and references to consteval
6276 /// functions aren't tracked when this is set.
6278
6283 }
6284
6285 /// Determines whether we are currently in a context that
6286 /// is not evaluated as per C++ [expr] p5.
6289 }
6290
6293 }
6294
6296 assert(!ExprEvalContexts.empty() &&
6297 "Must be in an expression evaluation context");
6298 return ExprEvalContexts.back().InLifetimeExtendingContext;
6299 }
6300
6303 return (Ctx.Context ==
6306 }
6307
6308 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
6310 assert(!ExprEvalContexts.empty() &&
6311 "Must be in an expression evaluation context");
6312 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
6314 Ctx.DelayedDefaultInitializationContext)
6315 return Ctx.DelayedDefaultInitializationContext;
6316 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
6317 Ctx.isUnevaluated())
6318 break;
6319 }
6320 return std::nullopt;
6321 }
6322
6323 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
6325 assert(!ExprEvalContexts.empty() &&
6326 "Must be in an expression evaluation context");
6327 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
6328 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
6330 !Ctx.DelayedDefaultInitializationContext && Res)
6331 break;
6332 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
6333 Ctx.isUnevaluated())
6334 break;
6335 Res = Ctx.DelayedDefaultInitializationContext;
6336 }
6337 return Res;
6338 }
6339
6340 /// keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext
6341 /// flag from previous context.
6343 if (ExprEvalContexts.size() > 2 &&
6345 .InLifetimeExtendingContext) {
6346 auto &LastRecord = ExprEvalContexts.back();
6347 auto &PrevRecord = ExprEvalContexts[ExprEvalContexts.size() - 2];
6348 LastRecord.InLifetimeExtendingContext =
6349 PrevRecord.InLifetimeExtendingContext;
6350 }
6351 }
6352
6355 }
6356
6357 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
6358 /// SelfAssigned when inside a CXXMethodDecl.
6359 const FieldDecl *
6361
6363
6364 template <typename... Ts>
6366 const Ts &...Args) {
6367 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6368 return RequireCompleteType(Loc, T, CompleteTypeKind::Normal, Diagnoser);
6369 }
6370
6371 template <typename... Ts>
6372 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
6373 const Ts &...Args) {
6374 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6376 }
6377
6378 /// Abstract class used to diagnose incomplete types.
6381
6382 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
6383 virtual ~TypeDiagnoser() {}
6384 };
6385
6386 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
6387 protected:
6388 unsigned DiagID;
6389 std::tuple<const Ts &...> Args;
6390
6391 template <std::size_t... Is>
6393 std::index_sequence<Is...>) const {
6394 // Apply all tuple elements to the builder in order.
6395 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
6396 (void)Dummy;
6397 }
6398
6399 public:
6400 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
6401 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
6402 assert(DiagID != 0 && "no diagnostic for type diagnoser");
6403 }
6404
6405 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
6406 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
6407 emit(DB, std::index_sequence_for<Ts...>());
6408 DB << T;
6409 }
6410 };
6411
6412 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
6413 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
6414 /// For example, a diagnostic with no other parameters would generally have
6415 /// the form "...%select{incomplete|sizeless}0 type %1...".
6416 template <typename... Ts>
6418 public:
6419 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
6420 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
6421
6422 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
6423 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
6424 this->emit(DB, std::index_sequence_for<Ts...>());
6425 DB << T->isSizelessType() << T;
6426 }
6427 };
6428
6429 /// Check an argument list for placeholders that we won't try to
6430 /// handle later.
6432
6433 /// The C++ "std::source_location::__impl" struct, defined in
6434 /// <source_location>.
6436
6437 /// A stack of expression evaluation contexts.
6439
6440 // Set of failed immediate invocations to avoid double diagnosing.
6442
6443 /// List of SourceLocations where 'self' is implicitly retained inside a
6444 /// block.
6447
6448private:
6449 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
6450
6451 /// Methods for marking which expressions involve dereferencing a pointer
6452 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
6453 /// they are parsed, meaning that a noderef pointer may not be accessed. For
6454 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
6455 /// `*p`, but need to check that `address of` is called on it. This requires
6456 /// keeping a container of all pending expressions and checking if the address
6457 /// of them are eventually taken.
6458 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
6459 void CheckAddressOfNoDeref(const Expr *E);
6460
6461 ///@}
6462
6463 //
6464 //
6465 // -------------------------------------------------------------------------
6466 //
6467 //
6468
6469 /// \name C++ Expressions
6470 /// Implementations are in SemaExprCXX.cpp
6471 ///@{
6472
6473public:
6474 /// The C++ "std::bad_alloc" class, which is defined by the C++
6475 /// standard library.
6477
6478 /// The C++ "std::align_val_t" enum class, which is defined by the C++
6479 /// standard library.
6481
6482 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
6484
6485 /// A flag to remember whether the implicit forms of operator new and delete
6486 /// have been declared.
6488
6489 /// Delete-expressions to be analyzed at the end of translation unit
6490 ///
6491 /// This list contains class members, and locations of delete-expressions
6492 /// that could not be proven as to whether they mismatch with new-expression
6493 /// used in initializer of the field.
6494 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
6495
6497 SourceLocation NameLoc,
6498 const IdentifierInfo &Name);
6499
6501 SourceLocation NameLoc, Scope *S,
6502 CXXScopeSpec &SS, bool EnteringContext);
6504 Scope *S, CXXScopeSpec &SS,
6505 ParsedType ObjectType, bool EnteringContext);
6506
6508 ParsedType ObjectType);
6509
6510 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
6511 TypeSourceInfo *Operand, SourceLocation RParenLoc);
6512 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
6513 Expr *Operand, SourceLocation RParenLoc);
6514
6515 /// ActOnCXXTypeid - Parse typeid( something ).
6517 bool isType, void *TyOrExpr,
6518 SourceLocation RParenLoc);
6519
6520 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
6521 TypeSourceInfo *Operand, SourceLocation RParenLoc);
6522 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
6523 Expr *Operand, SourceLocation RParenLoc);
6524
6525 /// ActOnCXXUuidof - Parse __uuidof( something ).
6527 bool isType, void *TyOrExpr,
6528 SourceLocation RParenLoc);
6529
6530 //// ActOnCXXThis - Parse 'this' pointer.
6532
6533 /// Check whether the type of 'this' is valid in the current context.
6535
6536 /// Build a CXXThisExpr and mark it referenced in the current context.
6537 Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
6538 void MarkThisReferenced(CXXThisExpr *This);
6539
6540 /// Try to retrieve the type of the 'this' pointer.
6541 ///
6542 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
6544
6545 /// When non-NULL, the C++ 'this' expression is allowed despite the
6546 /// current context not being a non-static member function. In such cases,
6547 /// this provides the type used for 'this'.
6549
6550 /// RAII object used to temporarily allow the C++ 'this' expression
6551 /// to be used, with the given qualifiers on the current class type.
6553 Sema &S;
6554 QualType OldCXXThisTypeOverride;
6555 bool Enabled;
6556
6557 public:
6558 /// Introduce a new scope where 'this' may be allowed (when enabled),
6559 /// using the given declaration (which is either a class template or a
6560 /// class) along with the given qualifiers.
6561 /// along with the qualifiers placed on '*this'.
6562 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
6563 bool Enabled = true);
6564
6566 };
6567
6568 /// Make sure the value of 'this' is actually available in the current
6569 /// context, if it is a potentially evaluated context.
6570 ///
6571 /// \param Loc The location at which the capture of 'this' occurs.
6572 ///
6573 /// \param Explicit Whether 'this' is explicitly captured in a lambda
6574 /// capture list.
6575 ///
6576 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
6577 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
6578 /// This is useful when enclosing lambdas must speculatively capture
6579 /// 'this' that may or may not be used in certain specializations of
6580 /// a nested generic lambda (depending on whether the name resolves to
6581 /// a non-static member function or a static function).
6582 /// \return returns 'true' if failed, 'false' if success.
6584 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
6585 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
6586 bool ByCopy = false);
6587
6588 /// Determine whether the given type is the type of *this that is used
6589 /// outside of the body of a member function for a type that is currently
6590 /// being defined.
6592
6593 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
6595
6596 /// ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
6598
6601 SourceLocation AtLoc, SourceLocation RParen);
6602
6603 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
6605
6606 //// ActOnCXXThrow - Parse throw expressions.
6609 bool IsThrownVarInScope);
6610 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
6611
6612 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
6613 /// Can be interpreted either as function-style casting ("int(x)")
6614 /// or class type construction ("ClassType(x,y,z)")
6615 /// or creation of a value-initialized type ("int()").
6617 SourceLocation LParenOrBraceLoc,
6618 MultiExprArg Exprs,
6619 SourceLocation RParenOrBraceLoc,
6620 bool ListInitialization);
6621
6623 SourceLocation LParenLoc,
6624 MultiExprArg Exprs,
6625 SourceLocation RParenLoc,
6626 bool ListInitialization);
6627
6628 /// ActOnCXXNew - Parsed a C++ 'new' expression.
6629 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
6630 SourceLocation PlacementLParen,
6631 MultiExprArg PlacementArgs,
6632 SourceLocation PlacementRParen,
6633 SourceRange TypeIdParens, Declarator &D,
6634 Expr *Initializer);
6636 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
6637 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
6638 SourceRange TypeIdParens, QualType AllocType,
6639 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
6640 SourceRange DirectInitRange, Expr *Initializer);
6641
6642 /// Determine whether \p FD is an aligned allocation or deallocation
6643 /// function that is unavailable.
6645
6646 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
6647 /// function that is unavailable.
6649 SourceLocation Loc);
6650
6651 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
6652 SourceRange R);
6653
6654 /// The scope in which to find allocation functions.
6656 /// Only look for allocation functions in the global scope.
6658 /// Only look for allocation functions in the scope of the
6659 /// allocated class.
6661 /// Look for allocation functions in both the global scope
6662 /// and in the scope of the allocated class.
6663 AFS_Both
6665
6666 /// Finds the overloads of operator new and delete that are appropriate
6667 /// for the allocation.
6669 AllocationFunctionScope NewScope,
6670 AllocationFunctionScope DeleteScope,
6671 QualType AllocType, bool IsArray,
6672 bool &PassAlignment, MultiExprArg PlaceArgs,
6673 FunctionDecl *&OperatorNew,
6674 FunctionDecl *&OperatorDelete,
6675 bool Diagnose = true);
6678 ArrayRef<QualType> Params);
6679
6681 DeclarationName Name, FunctionDecl *&Operator,
6682 bool Diagnose = true, bool WantSize = false,
6683 bool WantAligned = false);
6685 bool CanProvideSize,
6686 bool Overaligned,
6687 DeclarationName Name);
6689 CXXRecordDecl *RD);
6690
6691 /// ActOnCXXDelete - Parsed a C++ 'delete' expression
6692 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
6693 bool ArrayForm, Expr *Operand);
6695 bool IsDelete, bool CallCanBeVirtual,
6696 bool WarnOnNonAbstractTypes,
6697 SourceLocation DtorLoc);
6698
6700 Expr *Operand, SourceLocation RParen);
6702 SourceLocation RParen);
6703
6705 SourceLocation OpLoc,
6706 tok::TokenKind OpKind,
6707 ParsedType &ObjectType,
6708 bool &MayBePseudoDestructor);
6709
6711 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
6712 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
6713 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
6714
6716 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
6717 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
6718 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
6719
6721 SourceLocation OpLoc,
6722 tok::TokenKind OpKind,
6723 SourceLocation TildeLoc,
6724 const DeclSpec &DS);
6725
6726 /// MaybeCreateExprWithCleanups - If the current full-expression
6727 /// requires any cleanups, surround it with a ExprWithCleanups node.
6728 /// Otherwise, just returns the passed-in expression.
6732
6733 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
6734 return ActOnFinishFullExpr(
6735 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
6736 }
6738 bool DiscardedValue, bool IsConstexpr = false,
6739 bool IsTemplateArgument = false);
6741
6743
6744 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
6745 bool IsUDSuffix);
6746
6748
6749 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
6750 SourceLocation StmtLoc,
6751 ConditionKind CK);
6752
6754 SourceLocation StmtLoc, ConditionKind CK);
6755
6756 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
6757 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
6758
6760
6762 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
6763 AssignmentAction Action,
6766 const StandardConversionSequence &SCS,
6767 AssignmentAction Action,
6769
6770 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
6771
6772 /// Parsed one of the type trait support pseudo-functions.
6775 SourceLocation RParenLoc);
6778 SourceLocation RParenLoc);
6779
6780 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
6781 /// pseudo-functions.
6783 ParsedType LhsTy, Expr *DimExpr,
6784 SourceLocation RParen);
6785
6787 TypeSourceInfo *TSInfo, Expr *DimExpr,
6788 SourceLocation RParen);
6789
6790 /// ActOnExpressionTrait - Parsed one of the unary type trait support
6791 /// pseudo-functions.
6793 Expr *Queried, SourceLocation RParen);
6794
6796 Expr *Queried, SourceLocation RParen);
6797
6799 ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc,
6800 bool isIndirect);
6802 ExprResult &RHS,
6803 SourceLocation QuestionLoc);
6804
6806 ExprResult &LHS, ExprResult &RHS,
6807 SourceLocation QuestionLoc);
6808
6810 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
6811 ExprObjectKind &OK, SourceLocation questionLoc);
6812
6814 bool ConvertArgs = true);
6816 ExprResult &E2, bool ConvertArgs = true) {
6817 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
6818 QualType Composite =
6819 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
6820 E1 = E1Tmp;
6821 E2 = E2Tmp;
6822 return Composite;
6823 }
6824
6825 /// MaybeBindToTemporary - If the passed in expression has a record type with
6826 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
6827 /// it simply returns the passed in expression.
6829
6830 /// IgnoredValueConversions - Given that an expression's result is
6831 /// syntactically ignored, perform any conversions that are
6832 /// required.
6834
6836
6837 /// Process any TypoExprs in the given Expr and its children,
6838 /// generating diagnostics as appropriate and returning a new Expr if there
6839 /// were typos that were all successfully corrected and ExprError if one or
6840 /// more typos could not be corrected.
6841 ///
6842 /// \param E The Expr to check for TypoExprs.
6843 ///
6844 /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
6845 /// initializer.
6846 ///
6847 /// \param RecoverUncorrectedTypos If true, when typo correction fails, it
6848 /// will rebuild the given Expr with all TypoExprs degraded to RecoveryExprs.
6849 ///
6850 /// \param Filter A function applied to a newly rebuilt Expr to determine if
6851 /// it is an acceptable/usable result from a single combination of typo
6852 /// corrections. As long as the filter returns ExprError, different
6853 /// combinations of corrections will be tried until all are exhausted.
6855 Expr *E, VarDecl *InitDecl = nullptr,
6856 bool RecoverUncorrectedTypos = false,
6857 llvm::function_ref<ExprResult(Expr *)> Filter =
6858 [](Expr *E) -> ExprResult { return E; });
6859
6861 ExprResult ER, VarDecl *InitDecl = nullptr,
6862 bool RecoverUncorrectedTypos = false,
6863 llvm::function_ref<ExprResult(Expr *)> Filter =
6864 [](Expr *E) -> ExprResult { return E; }) {
6865 return ER.isInvalid()
6866 ? ER
6867 : CorrectDelayedTyposInExpr(ER.get(), InitDecl,
6868 RecoverUncorrectedTypos, Filter);
6869 }
6870
6871 /// Describes the result of an "if-exists" condition check.
6873 /// The symbol exists.
6875
6876 /// The symbol does not exist.
6878
6879 /// The name is a dependent name, so the results will differ
6880 /// from one instantiation to the next.
6882
6883 /// An error occurred.
6884 IER_Error
6886
6889 const DeclarationNameInfo &TargetNameInfo);
6890
6892 SourceLocation KeywordLoc,
6893 bool IsIfExists, CXXScopeSpec &SS,
6894 UnqualifiedId &Name);
6895
6898 ArrayRef<ParmVarDecl *> LocalParameters,
6899 Scope *BodyScope);
6903 CXXScopeSpec &SS,
6904 SourceLocation NameLoc,
6905 const IdentifierInfo *TypeName,
6906 TemplateIdAnnotation *TemplateId);
6908 SourceLocation NoexceptLoc);
6910 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
6911 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
6914 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
6918 bool IsSatisfied, SourceLocation NoexceptLoc,
6925 BuildNestedRequirement(StringRef InvalidConstraintEntity,
6926 const ASTConstraintSatisfaction &Satisfaction);
6929 SourceLocation LParenLoc,
6930 ArrayRef<ParmVarDecl *> LocalParameters,
6931 SourceLocation RParenLoc,
6933 SourceLocation ClosingBraceLoc);
6934
6935private:
6936 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
6937 bool IsDelete);
6938
6939 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
6940 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
6941 bool DeleteWasArrayForm);
6942
6943 ///@}
6944
6945 //
6946 //
6947 // -------------------------------------------------------------------------
6948 //
6949 //
6950
6951 /// \name Member Access Expressions
6952 /// Implementations are in SemaExprMember.cpp
6953 ///@{
6954
6955public:
6956 /// Check whether an expression might be an implicit class member access.
6958 bool IsAddressOfOperand);
6959
6961 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
6962 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
6963
6965 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6966 LookupResult &R,
6967 const TemplateArgumentListInfo *TemplateArgs,
6968 bool IsDefiniteInstance, const Scope *S);
6969
6971 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
6972 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
6973 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
6974 const TemplateArgumentListInfo *TemplateArgs);
6975
6977 tok::TokenKind OpKind, CXXScopeSpec &SS,
6978 SourceLocation TemplateKWLoc,
6979 UnqualifiedId &Member, Decl *ObjCImpDecl);
6980
6982 Expr *Base, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec *SS,
6983 SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl,
6984 bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo,
6986 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6987 MemberExpr *
6988 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
6989 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
6990 ValueDecl *Member, DeclAccessPair FoundDecl,
6991 bool HadMultipleCandidates,
6992 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
6994 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6995
6996 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
6997 const CXXScopeSpec &SS,
6998 const LookupResult &R);
6999
7000 // This struct is for use by ActOnMemberAccess to allow
7001 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
7002 // changing the access operator from a '.' to a '->' (to see if that is the
7003 // change needed to fix an error about an unknown member, e.g. when the class
7004 // defines a custom operator->).
7009 };
7010
7012 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
7013 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
7014 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
7015 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
7016 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
7017
7020 bool IsArrow, const CXXScopeSpec &SS,
7021 SourceLocation TemplateKWLoc,
7022 NamedDecl *FirstQualifierInScope, LookupResult &R,
7023 const TemplateArgumentListInfo *TemplateArgs,
7024 const Scope *S, bool SuppressQualifierCheck = false,
7025 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
7026
7027 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
7028 SourceLocation OpLoc,
7029 const CXXScopeSpec &SS, FieldDecl *Field,
7030 DeclAccessPair FoundDecl,
7031 const DeclarationNameInfo &MemberNameInfo);
7032
7034
7036 const CXXScopeSpec &SS, SourceLocation nameLoc,
7037 IndirectFieldDecl *indirectField,
7038 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
7039 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
7040
7041private:
7042 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
7043
7044 ///@}
7045
7046 //
7047 //
7048 // -------------------------------------------------------------------------
7049 //
7050 //
7051
7052 /// \name Initializers
7053 /// Implementations are in SemaInit.cpp
7054 ///@{
7055
7056public:
7057 /// Stack of types that correspond to the parameter entities that are
7058 /// currently being copy-initialized. Can be empty.
7060
7061 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
7063
7064 bool IsStringInit(Expr *Init, const ArrayType *AT);
7065
7067 const InitializedEntity &Entity, InitListExpr *From);
7068
7070 SourceLocation EqualOrColonLoc,
7071 bool GNUSyntax, ExprResult Init);
7072
7073 /// Check that the lifetime of the initializer (and its subobjects) is
7074 /// sufficient for initializing the entity, and perform lifetime extension
7075 /// (when permitted) if not.
7077
7080 bool BoundToLvalueReference);
7081
7082 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
7083 /// it as an xvalue. In C++98, the result will still be a prvalue, because
7084 /// we don't have xvalues there.
7086
7090
7094 SourceLocation EqualLoc, ExprResult Init,
7095 bool TopLevelOfInitList = false,
7096 bool AllowExplicit = false);
7097
7099 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
7100 const InitializationKind &Kind, MultiExprArg Init);
7101
7102 ///@}
7103
7104 //
7105 //
7106 // -------------------------------------------------------------------------
7107 //
7108 //
7109
7110 /// \name C++ Lambda Expressions
7111 /// Implementations are in SemaLambda.cpp
7112 ///@{
7113
7114public:
7115 /// Create a new lambda closure type.
7117 TypeSourceInfo *Info,
7118 unsigned LambdaDependencyKind,
7119 LambdaCaptureDefault CaptureDefault);
7120
7121 /// Number lambda for linkage purposes if necessary.
7123 std::optional<CXXRecordDecl::LambdaNumbering>
7124 NumberingOverride = std::nullopt);
7125
7126 /// Endow the lambda scope info with the relevant properties.
7127 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
7128 SourceRange IntroducerRange,
7129 LambdaCaptureDefault CaptureDefault,
7130 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
7131 bool Mutable);
7132
7135
7137 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
7138 TemplateParameterList *TemplateParams);
7139
7141 CXXMethodDecl *Method, SourceLocation LambdaLoc,
7142 SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause,
7143 TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind,
7145 bool HasExplicitResultType);
7146
7148
7149 /// Perform initialization analysis of the init-capture and perform
7150 /// any implicit conversions such as an lvalue-to-rvalue conversion if
7151 /// not being used to initialize a reference.
7153 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
7156 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
7158 }
7160 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
7161 std::optional<unsigned> NumExpansions, IdentifierInfo *Id,
7162 bool DirectInit, Expr *&Init);
7163
7164 /// Create a dummy variable within the declcontext of the lambda's
7165 /// call operator, for name lookup purposes for a lambda init capture.
7166 ///
7167 /// CodeGen handles emission of lambda captures, ignoring these dummy
7168 /// variables appropriately.
7170 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
7171 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
7172
7173 /// Add an init-capture to a lambda scope.
7174 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
7175
7176 /// Note that we have finished the explicit captures for the
7177 /// given lambda.
7179
7180 /// Deduce a block or lambda's return type based on the return
7181 /// statements present in the body.
7183
7184 /// Once the Lambdas capture are known, we can start to create the closure,
7185 /// call operator method, and keep track of the captures.
7186 /// We do the capture lookup here, but they are not actually captured until
7187 /// after we know what the qualifiers of the call operator are.
7189 Scope *CurContext);
7190
7191 /// This is called after parsing the explicit template parameter list
7192 /// on a lambda (if it exists) in C++2a.
7194 SourceLocation LAngleLoc,
7195 ArrayRef<NamedDecl *> TParams,
7196 SourceLocation RAngleLoc,
7197 ExprResult RequiresClause);
7198
7200 SourceLocation MutableLoc);
7201
7203 Scope *LambdaScope,
7205
7206 /// ActOnStartOfLambdaDefinition - This is called just before we start
7207 /// parsing the body of a lambda; it analyzes the explicit captures and
7208 /// arguments, and sets up various data-structures for the body of the
7209 /// lambda.
7211 Declarator &ParamInfo, const DeclSpec &DS);
7212
7213 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
7214 /// is invoked to pop the information about the lambda.
7215 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
7216 bool IsInstantiation = false);
7217
7218 /// ActOnLambdaExpr - This is called when the body of a lambda expression
7219 /// was successfully completed.
7221
7222 /// Does copying/destroying the captured variable have side effects?
7223 bool CaptureHasSideEffects(const sema::Capture &From);
7224
7225 /// Diagnose if an explicit lambda capture is unused. Returns true if a
7226 /// diagnostic is emitted.
7227 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
7228 const sema::Capture &From);
7229
7230 /// Build a FieldDecl suitable to hold the given capture.
7232
7233 /// Initialize the given capture with a suitable expression.
7235 SourceLocation ImplicitCaptureLoc,
7236 bool IsOpenMPMapping = false);
7237
7238 /// Complete a lambda-expression having processed and attached the
7239 /// lambda body.
7242
7243 /// Get the return type to use for a lambda's conversion function(s) to
7244 /// function pointer type, given the type of the call operator.
7245 QualType
7247 CallingConv CC);
7248
7250 SourceLocation ConvLocation,
7251 CXXConversionDecl *Conv, Expr *Src);
7252
7254 : private FunctionScopeRAII {
7255 public:
7257 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
7259 bool ShouldAddDeclsFromParentScope = true);
7260 };
7261
7262 /// Compute the mangling number context for a lambda expression or
7263 /// block literal. Also return the extra mangling decl if any.
7264 ///
7265 /// \param DC - The DeclContext containing the lambda expression or
7266 /// block literal.
7267 std::tuple<MangleNumberingContext *, Decl *>
7269
7270 ///@}
7271
7272 //
7273 //
7274 // -------------------------------------------------------------------------
7275 //
7276 //
7277
7278 /// \name Name Lookup
7279 ///
7280 /// These routines provide name lookup that is used during semantic
7281 /// analysis to resolve the various kinds of names (identifiers,
7282 /// overloaded operator names, constructor names, etc.) into zero or
7283 /// more declarations within a particular scope. The major entry
7284 /// points are LookupName, which performs unqualified name lookup,
7285 /// and LookupQualifiedName, which performs qualified name lookup.
7286 ///
7287 /// All name lookup is performed based on some specific criteria,
7288 /// which specify what names will be visible to name lookup and how
7289 /// far name lookup should work. These criteria are important both
7290 /// for capturing language semantics (certain lookups will ignore
7291 /// certain names, for example) and for performance, since name
7292 /// lookup is often a bottleneck in the compilation of C++. Name
7293 /// lookup criteria is specified via the LookupCriteria enumeration.
7294 ///
7295 /// The results of name lookup can vary based on the kind of name
7296 /// lookup performed, the current language, and the translation
7297 /// unit. In C, for example, name lookup will either return nothing
7298 /// (no entity found) or a single declaration. In C++, name lookup
7299 /// can additionally refer to a set of overloaded functions or
7300 /// result in an ambiguity. All of the possible results of name
7301 /// lookup are captured by the LookupResult class, which provides
7302 /// the ability to distinguish among them.
7303 ///
7304 /// Implementations are in SemaLookup.cpp
7305 ///@{
7306
7307public:
7308 /// Tracks whether we are in a context where typo correction is
7309 /// disabled.
7311
7312 /// The number of typos corrected by CorrectTypo.
7314
7315 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
7316 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
7317
7318 /// A cache containing identifiers for which typo correction failed and
7319 /// their locations, so that repeated attempts to correct an identifier in a
7320 /// given location are ignored if typo correction already failed for it.
7322
7323 /// SpecialMemberOverloadResult - The overloading result for a special member
7324 /// function.
7325 ///
7326 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
7327 /// integer are used to determine whether overload resolution succeeded.
7329 public:
7330 enum Kind { NoMemberOrDeleted, Ambiguous, Success };
7331
7332 private:
7333 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
7334
7335 public:
7338 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
7339
7340 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
7341 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
7342
7343 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
7344 void setKind(Kind K) { Pair.setInt(K); }
7345 };
7346
7347 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
7349 public:
7350 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
7351 : FastFoldingSetNode(ID) {}
7352 };
7353
7354 /// A cache of special member function overload resolution results
7355 /// for C++ records.
7356 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
7357
7358 /// Holds TypoExprs that are created from `createDelayedTypo`. This is used by
7359 /// `TransformTypos` in order to keep track of any TypoExprs that are created
7360 /// recursively during typo correction and wipe them away if the correction
7361 /// fails.
7363
7365
7366 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
7367 // TODO: make this is a typesafe union.
7370
7371 /// Describes the kind of name lookup to perform.
7373 /// Ordinary name lookup, which finds ordinary names (functions,
7374 /// variables, typedefs, etc.) in C and most kinds of names
7375 /// (functions, variables, members, types, etc.) in C++.
7377 /// Tag name lookup, which finds the names of enums, classes,
7378 /// structs, and unions.
7380 /// Label name lookup.
7382 /// Member name lookup, which finds the names of
7383 /// class/struct/union members.
7385 /// Look up of an operator name (e.g., operator+) for use with
7386 /// operator overloading. This lookup is similar to ordinary name
7387 /// lookup, but will ignore any declarations that are class members.
7389 /// Look up a name following ~ in a destructor name. This is an ordinary
7390 /// lookup, but prefers tags to typedefs.
7392 /// Look up of a name that precedes the '::' scope resolution
7393 /// operator in C++. This lookup completely ignores operator, object,
7394 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
7396 /// Look up a namespace name within a C++ using directive or
7397 /// namespace alias definition, ignoring non-namespace names (C++
7398 /// [basic.lookup.udir]p1).
7400 /// Look up all declarations in a scope with the given name,
7401 /// including resolved using declarations. This is appropriate
7402 /// for checking redeclarations for a using declaration.
7404 /// Look up an ordinary name that is going to be redeclared as a
7405 /// name with linkage. This lookup ignores any declarations that
7406 /// are outside of the current scope unless they have linkage. See
7407 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
7409 /// Look up a friend of a local class. This lookup does not look
7410 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
7412 /// Look up the name of an Objective-C protocol.
7414 /// Look up implicit 'self' parameter of an objective-c method.
7416 /// Look up the name of an OpenMP user-defined reduction operation.
7418 /// Look up the name of an OpenMP user-defined mapper.
7420 /// Look up any declaration with any name.
7423
7424 /// The possible outcomes of name lookup for a literal operator.
7426 /// The lookup resulted in an error.
7428 /// The lookup found no match but no diagnostic was issued.
7430 /// The lookup found a single 'cooked' literal operator, which
7431 /// expects a normal literal to be built and passed to it.
7433 /// The lookup found a single 'raw' literal operator, which expects
7434 /// a string literal containing the spelling of the literal token.
7436 /// The lookup found an overload set of literal operator templates,
7437 /// which expect the characters of the spelling of the literal token to be
7438 /// passed as a non-type template argument pack.
7440 /// The lookup found an overload set of literal operator templates,
7441 /// which expect the character type and characters of the spelling of the
7442 /// string literal token to be passed as template arguments.
7444 };
7445
7446 SpecialMemberOverloadResult
7448 bool VolatileArg, bool RValueThis, bool ConstThis,
7449 bool VolatileThis);
7450
7451 typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
7452 typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
7454
7456
7457 /// Look up a name, looking for a single declaration. Return
7458 /// null if the results were absent, ambiguous, or overloaded.
7459 ///
7460 /// It is preferable to use the elaborated form and explicitly handle
7461 /// ambiguity and overloaded.
7463 Scope *S, DeclarationName Name, SourceLocation Loc,
7464 LookupNameKind NameKind,
7465 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
7466 bool LookupBuiltin(LookupResult &R);
7467 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
7468 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
7469 bool ForceNoCPlusPlus = false);
7470 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
7471 bool InUnqualifiedLookup = false);
7472 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
7473 CXXScopeSpec &SS);
7475 bool AllowBuiltinCreation = false,
7476 bool EnteringContext = false);
7478 IdentifierInfo *II, SourceLocation IdLoc,
7479 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
7481
7483 UnresolvedSetImpl &Functions);
7484
7486 SourceLocation GnuLabelLoc = SourceLocation());
7487
7491 unsigned Quals);
7493 bool RValueThis, unsigned ThisQuals);
7495 unsigned Quals);
7497 bool RValueThis, unsigned ThisQuals);
7499
7500 /// Force the declaration of any implicitly-declared members of this
7501 /// class.
7503
7504 /// Make a merged definition of an existing hidden definition \p ND
7505 /// visible at the specified location.
7507
7508 /// Get the set of additional modules that should be checked during
7509 /// name lookup. A module and its imports become visible when instanting a
7510 /// template defined within it.
7512
7513 bool hasVisibleMergedDefinition(const NamedDecl *Def);
7515
7516 /// Determine if the template parameter \p D has a visible default argument.
7517 bool
7519 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7520 /// Determine if the template parameter \p D has a reachable default argument.
7522 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7523 /// Determine if the template parameter \p D has a reachable default argument.
7527
7528 /// Determine if there is a visible declaration of \p D that is an explicit
7529 /// specialization declaration for a specialization of a template. (For a
7530 /// member specialization, use hasVisibleMemberSpecialization.)
7532 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7533 /// Determine if there is a reachable declaration of \p D that is an explicit
7534 /// specialization declaration for a specialization of a template. (For a
7535 /// member specialization, use hasReachableMemberSpecialization.)
7537 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7538
7539 /// Determine if there is a visible declaration of \p D that is a member
7540 /// specialization declaration (as opposed to an instantiated declaration).
7542 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7543 /// Determine if there is a reachable declaration of \p D that is a member
7544 /// specialization declaration (as opposed to an instantiated declaration).
7546 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7547
7548 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
7549
7550 /// Determine whether any declaration of an entity is visible.
7551 bool
7553 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
7554 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
7555 }
7556
7559 /// Determine whether any declaration of an entity is reachable.
7560 bool
7562 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
7563 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
7564 }
7566 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
7567
7568 void diagnoseTypo(const TypoCorrection &Correction,
7569 const PartialDiagnostic &TypoDiag,
7570 bool ErrorRecovery = true);
7571
7572 void diagnoseTypo(const TypoCorrection &Correction,
7573 const PartialDiagnostic &TypoDiag,
7574 const PartialDiagnostic &PrevNote,
7575 bool ErrorRecovery = true);
7576
7578 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
7579 AssociatedNamespaceSet &AssociatedNamespaces,
7580 AssociatedClassSet &AssociatedClasses);
7581
7583
7586 bool AllowRaw, bool AllowTemplate,
7587 bool AllowStringTemplate, bool DiagnoseMissing,
7588 StringLiteral *StringLit = nullptr);
7589
7591 ArrayRef<Expr *> Args, ADLResult &Functions);
7592
7595 bool IncludeGlobalScope = true,
7596 bool LoadExternal = true);
7599 bool IncludeGlobalScope = true,
7600 bool IncludeDependentBases = false,
7601 bool LoadExternal = true);
7602
7604 CTK_NonError, // CorrectTypo used in a non error recovery situation.
7605 CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
7607
7609 Sema::LookupNameKind LookupKind, Scope *S,
7611 CorrectTypoKind Mode,
7612 DeclContext *MemberContext = nullptr,
7613 bool EnteringContext = false,
7614 const ObjCObjectPointerType *OPT = nullptr,
7615 bool RecordFailure = true);
7616
7618 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
7621 CorrectTypoKind Mode, DeclContext *MemberContext = nullptr,
7622 bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr);
7623
7624 /// Kinds of missing import. Note, the values of these enumerators correspond
7625 /// to %select values in diagnostics.
7628 Definition,
7632 };
7633
7634 /// Diagnose that the specified declaration needs to be visible but
7635 /// isn't, and suggest a module import that would resolve the problem.
7637 MissingImportKind MIK, bool Recover = true);
7639 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
7640 MissingImportKind MIK, bool Recover);
7641
7643 std::unique_ptr<TypoCorrectionConsumer> Consumer;
7646 TypoExprState();
7647 TypoExprState(TypoExprState &&other) noexcept;
7648 TypoExprState &operator=(TypoExprState &&other) noexcept;
7649 };
7650
7651 const TypoExprState &getTypoExprState(TypoExpr *TE) const;
7652
7653 /// Clears the state of the given TypoExpr.
7654 void clearDelayedTypo(TypoExpr *TE);
7655
7656 /// Called on #pragma clang __debug dump II
7658
7659 /// Called on #pragma clang __debug dump E
7660 void ActOnPragmaDump(Expr *E);
7661
7662private:
7663 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
7664 //
7665 // The boolean value will be true to indicate that the namespace was loaded
7666 // from an AST/PCH file, or false otherwise.
7667 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
7668
7669 /// Whether we have already loaded known namespaces from an extenal
7670 /// source.
7671 bool LoadedExternalKnownNamespaces;
7672
7673 bool CppLookupName(LookupResult &R, Scope *S);
7674
7675 bool isUsableModule(const Module *M);
7676
7677 /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
7678 /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
7679 /// should be skipped entirely.
7680 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
7681 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
7683 DeclContext *MemberContext, bool EnteringContext,
7684 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
7685
7686 /// The set of unhandled TypoExprs and their associated state.
7687 llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
7688
7689 /// Creates a new TypoExpr AST node.
7690 TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
7693
7694 /// Cache for module units which is usable for current module.
7695 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
7696
7697 /// Record the typo correction failure and return an empty correction.
7698 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
7699 bool RecordFailure = true) {
7700 if (RecordFailure)
7701 TypoCorrectionFailures[Typo].insert(TypoLoc);
7702 return TypoCorrection();
7703 }
7704
7705 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
7706
7707 /// Determine whether two declarations should be linked together, given that
7708 /// the old declaration might not be visible and the new declaration might
7709 /// not have external linkage.
7710 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
7711 const NamedDecl *New) {
7712 if (isVisible(Old))
7713 return true;
7714 // See comment in below overload for why it's safe to compute the linkage
7715 // of the new declaration here.
7716 if (New->isExternallyDeclarable()) {
7717 assert(Old->isExternallyDeclarable() &&
7718 "should not have found a non-externally-declarable previous decl");
7719 return true;
7720 }
7721 return false;
7722 }
7723 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
7724
7725 ///@}
7726
7727 //
7728 //
7729 // -------------------------------------------------------------------------
7730 //
7731 //
7732
7733 /// \name Modules
7734 /// Implementations are in SemaModule.cpp
7735 ///@{
7736
7737public:
7738 /// Get the module unit whose scope we are currently within.
7740 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
7741 }
7742
7743 /// Is the module scope we are an implementation unit?
7745 return ModuleScopes.empty()
7746 ? false
7747 : ModuleScopes.back().Module->isModuleImplementation();
7748 }
7749
7750 // When loading a non-modular PCH files, this is used to restore module
7751 // visibility.
7753 VisibleModules.setVisible(Mod, ImportLoc);
7754 }
7755
7756 enum class ModuleDeclKind {
7757 Interface, ///< 'export module X;'
7758 Implementation, ///< 'module X;'
7759 PartitionInterface, ///< 'export module X:Y;'
7760 PartitionImplementation, ///< 'module X:Y;'
7761 };
7762
7763 /// An enumeration to represent the transition of states in parsing module
7764 /// fragments and imports. If we are not parsing a C++20 TU, or we find
7765 /// an error in state transition, the state is set to NotACXX20Module.
7767 FirstDecl, ///< Parsing the first decl in a TU.
7768 GlobalFragment, ///< after 'module;' but before 'module X;'
7769 ImportAllowed, ///< after 'module X;' but before any non-import decl.
7770 ImportFinished, ///< after any non-import decl.
7771 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
7772 ///< non-import decl.
7773 PrivateFragmentImportFinished, ///< after 'module :private;' but a
7774 ///< non-import decl has already been seen.
7775 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
7776 };
7777
7778 /// The parser has processed a module-declaration that begins the definition
7779 /// of a module interface or implementation.
7781 SourceLocation ModuleLoc, ModuleDeclKind MDK,
7782 ModuleIdPath Path, ModuleIdPath Partition,
7783 ModuleImportState &ImportState);
7784
7785 /// The parser has processed a global-module-fragment declaration that begins
7786 /// the definition of the global module fragment of the current module unit.
7787 /// \param ModuleLoc The location of the 'module' keyword.
7789
7790 /// The parser has processed a private-module-fragment declaration that begins
7791 /// the definition of the private module fragment of the current module unit.
7792 /// \param ModuleLoc The location of the 'module' keyword.
7793 /// \param PrivateLoc The location of the 'private' keyword.
7795 SourceLocation PrivateLoc);
7796
7797 /// The parser has processed a module import declaration.
7798 ///
7799 /// \param StartLoc The location of the first token in the declaration. This
7800 /// could be the location of an '@', 'export', or 'import'.
7801 /// \param ExportLoc The location of the 'export' keyword, if any.
7802 /// \param ImportLoc The location of the 'import' keyword.
7803 /// \param Path The module toplevel name as an access path.
7804 /// \param IsPartition If the name is for a partition.
7806 SourceLocation ExportLoc,
7807 SourceLocation ImportLoc, ModuleIdPath Path,
7808 bool IsPartition = false);
7810 SourceLocation ExportLoc,
7811 SourceLocation ImportLoc, Module *M,
7812 ModuleIdPath Path = {});
7813
7814 /// The parser has processed a module import translated from a
7815 /// #include or similar preprocessing directive.
7816 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
7817 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
7818
7819 /// The parsed has entered a submodule.
7820 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
7821 /// The parser has left a submodule.
7822 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
7823
7824 /// Create an implicit import of the given module at the given
7825 /// source location, for error recovery, if possible.
7826 ///
7827 /// This routine is typically used when an entity found by name lookup
7828 /// is actually hidden within a module that we know about but the user
7829 /// has forgotten to import.
7830 void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
7831 Module *Mod);
7832
7833 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
7834 SourceLocation LBraceLoc);
7835 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
7836 SourceLocation RBraceLoc);
7837
7838private:
7839 /// The parser has begun a translation unit to be compiled as a C++20
7840 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
7841 void HandleStartOfHeaderUnit();
7842
7843 struct ModuleScope {
7844 SourceLocation BeginLoc;
7845 clang::Module *Module = nullptr;
7846 VisibleModuleSet OuterVisibleModules;
7847 };
7848 /// The modules we're currently parsing.
7850
7851 /// For an interface unit, this is the implicitly imported interface unit.
7852 clang::Module *ThePrimaryInterface = nullptr;
7853
7854 /// The explicit global module fragment of the current translation unit.
7855 /// The explicit Global Module Fragment, as specified in C++
7856 /// [module.global.frag].
7857 clang::Module *TheGlobalModuleFragment = nullptr;
7858
7859 /// The implicit global module fragments of the current translation unit.
7860 ///
7861 /// The contents in the implicit global module fragment can't be discarded.
7862 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
7863
7864 /// Namespace definitions that we will export when they finish.
7865 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
7866
7867 /// In a C++ standard module, inline declarations require a definition to be
7868 /// present at the end of a definition domain. This set holds the decls to
7869 /// be checked at the end of the TU.
7870 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
7871
7872 /// Helper function to judge if we are in module purview.
7873 /// Return false if we are not in a module.
7874 bool isCurrentModulePurview() const;
7875
7876 /// Enter the scope of the explicit global module fragment.
7877 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
7878 /// Leave the scope of the explicit global module fragment.
7879 void PopGlobalModuleFragment();
7880
7881 /// Enter the scope of an implicit global module fragment.
7882 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
7883 /// Leave the scope of an implicit global module fragment.
7884 void PopImplicitGlobalModuleFragment();
7885
7886 VisibleModuleSet VisibleModules;
7887
7888 ///@}
7889
7890 //
7891 //
7892 // -------------------------------------------------------------------------
7893 //
7894 //
7895
7896 /// \name C++ Overloading
7897 /// Implementations are in SemaOverload.cpp
7898 ///@{
7899
7900public:
7901 /// Whether deferrable diagnostics should be deferred.
7902 bool DeferDiags = false;
7903
7904 /// RAII class to control scope of DeferDiags.
7906 Sema &S;
7907 bool SavedDeferDiags = false;
7908
7909 public:
7910 DeferDiagsRAII(Sema &S, bool DeferDiags)
7911 : S(S), SavedDeferDiags(S.DeferDiags) {
7912 S.DeferDiags = DeferDiags;
7913 }
7914 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
7915 };
7916
7917 /// Flag indicating if Sema is building a recovery call expression.
7918 ///
7919 /// This flag is used to avoid building recovery call expressions
7920 /// if Sema is already doing so, which would cause infinite recursions.
7922
7924 /// This is a legitimate overload: the existing declarations are
7925 /// functions or function templates with different signatures.
7927
7928 /// This is not an overload because the signature exactly matches
7929 /// an existing declaration.
7931
7932 /// This is not an overload because the lookup results contain a
7933 /// non-function.
7937 const LookupResult &OldDecls, NamedDecl *&OldDecl,
7938 bool UseMemberUsingDeclRules);
7939 bool IsOverload(FunctionDecl *New, FunctionDecl *Old,
7940 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
7941
7942 // Checks whether MD constitutes an override the base class method BaseMD.
7943 // When checking for overrides, the object object members are ignored.
7944 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
7945 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
7946
7947 enum class AllowedExplicit {
7948 /// Allow no explicit functions to be used.
7949 None,
7950 /// Allow explicit conversion functions but not explicit constructors.
7952 /// Allow both explicit conversion functions and explicit constructors.
7953 All
7954 };
7955
7957 Expr *From, QualType ToType, bool SuppressUserConversions,
7958 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
7959 bool AllowObjCWritebackConversion);
7960
7962 AssignmentAction Action,
7963 bool AllowExplicit = false);
7964
7965 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
7966 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
7967 bool IsComplexPromotion(QualType FromType, QualType ToType);
7968 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
7969 bool InOverloadResolution, QualType &ConvertedType,
7970 bool &IncompatibleObjC);
7971 bool isObjCPointerConversion(QualType FromType, QualType ToType,
7972 QualType &ConvertedType, bool &IncompatibleObjC);
7973 bool isObjCWritebackConversion(QualType FromType, QualType ToType,
7974 QualType &ConvertedType);
7975 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
7976 QualType &ConvertedType);
7977
7980 unsigned *ArgPos = nullptr,
7981 bool Reversed = false);
7982
7984 const FunctionProtoType *NewType,
7985 unsigned *ArgPos = nullptr,
7986 bool Reversed = false);
7987
7988 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
7989 const FunctionDecl *NewFunction,
7990 unsigned *ArgPos = nullptr,
7991 bool Reversed = false);
7992
7994 QualType ToType);
7995
7996 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
7997 CXXCastPath &BasePath, bool IgnoreBaseAccess,
7998 bool Diagnose = true);
7999 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
8000 bool InOverloadResolution,
8001 QualType &ConvertedType);
8002 bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
8003 CXXCastPath &BasePath,
8004 bool IgnoreBaseAccess);
8005 bool IsQualificationConversion(QualType FromType, QualType ToType,
8006 bool CStyle, bool &ObjCLifetimeConversion);
8007 bool IsFunctionConversion(QualType FromType, QualType ToType,
8008 QualType &ResultTy);
8011 DeclarationName Name,
8012 OverloadCandidateSet &CandidateSet,
8013 FunctionDecl *Fn, MultiExprArg Args,
8014 bool IsMember = false);
8015
8017 FunctionDecl *Fun);
8019 Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl,
8020 CXXMethodDecl *Method);
8021
8024
8025 /// Contexts in which a converted constant expression is required.
8026 enum CCEKind {
8027 CCEK_CaseValue, ///< Expression in a case label.
8028 CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
8029 CCEK_TemplateArg, ///< Value of a non-type template parameter.
8030 CCEK_ArrayBound, ///< Array bound in array declarator or new-expression.
8031 CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier.
8032 CCEK_Noexcept, ///< Condition in a noexcept(bool) specifier.
8033 CCEK_StaticAssertMessageSize, ///< Call to size() in a static assert
8034 ///< message.
8035 CCEK_StaticAssertMessageData, ///< Call to data() in a static assert
8036 ///< message.
8037 };
8038
8040 CCEKind CCE,
8041 NamedDecl *Dest = nullptr);
8042
8044 llvm::APSInt &Value, CCEKind CCE);
8046 APValue &Value, CCEKind CCE,
8047 NamedDecl *Dest = nullptr);
8048
8051 CCEKind CCE, bool RequireInt,
8052 const APValue &PreNarrowingValue);
8053
8054 /// Abstract base class used to perform a contextual implicit
8055 /// conversion from an expression to any type passing a filter.
8057 public:
8060
8061 ContextualImplicitConverter(bool Suppress = false,
8062 bool SuppressConversion = false)
8063 : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
8064
8065 /// Determine whether the specified type is a valid destination type
8066 /// for this conversion.
8067 virtual bool match(QualType T) = 0;
8068
8069 /// Emits a diagnostic complaining that the expression does not have
8070 /// integral or enumeration type.
8072 QualType T) = 0;
8073
8074 /// Emits a diagnostic when the expression has incomplete class type.
8075 virtual SemaDiagnosticBuilder
8077
8078 /// Emits a diagnostic when the only matching conversion function
8079 /// is explicit.
8081 SourceLocation Loc,
8082 QualType T,
8083 QualType ConvTy) = 0;
8084
8085 /// Emits a note for the explicit conversion function.
8086 virtual SemaDiagnosticBuilder
8088
8089 /// Emits a diagnostic when there are multiple possible conversion
8090 /// functions.
8092 QualType T) = 0;
8093
8094 /// Emits a note for one of the candidate conversions.
8095 virtual SemaDiagnosticBuilder
8097
8098 /// Emits a diagnostic when we picked a conversion function
8099 /// (for cases when we are not allowed to pick a conversion function).
8101 SourceLocation Loc,
8102 QualType T,
8103 QualType ConvTy) = 0;
8104
8106 };
8107
8109 bool AllowScopedEnumerations;
8110
8111 public:
8112 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
8113 bool SuppressConversion)
8114 : ContextualImplicitConverter(Suppress, SuppressConversion),
8115 AllowScopedEnumerations(AllowScopedEnumerations) {}
8116
8117 /// Match an integral or (possibly scoped) enumeration type.
8118 bool match(QualType T) override;
8119
8121 QualType T) override {
8122 return diagnoseNotInt(S, Loc, T);
8123 }
8124
8125 /// Emits a diagnostic complaining that the expression does not have
8126 /// integral or enumeration type.
8128 QualType T) = 0;
8129 };
8130
8131 /// Perform a contextual implicit conversion.
8134 ContextualImplicitConverter &Converter);
8135
8136 /// ReferenceCompareResult - Expresses the result of comparing two
8137 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
8138 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
8140 /// Ref_Incompatible - The two types are incompatible, so direct
8141 /// reference binding is not possible.
8143 /// Ref_Related - The two types are reference-related, which means
8144 /// that their unqualified forms (T1 and T2) are either the same
8145 /// or T1 is a base class of T2.
8147 /// Ref_Compatible - The two types are reference-compatible.
8150
8151 // Fake up a scoped enumeration that still contextually converts to bool.
8153 /// The conversions that would be performed on an lvalue of type T2 when
8154 /// binding a reference of type T1 to it, as determined when evaluating
8155 /// whether T1 is reference-compatible with T2.
8157 Qualification = 0x1,
8158 NestedQualification = 0x2,
8160 DerivedToBase = 0x8,
8161 ObjC = 0x10,
8162 ObjCLifetime = 0x20,
8163
8164 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
8165 };
8166 };
8168
8171 ReferenceConversions *Conv = nullptr);
8172
8175 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
8176 bool PartialOverloading = false, bool AllowExplicit = true,
8177 bool AllowExplicitConversion = false,
8178 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
8179 ConversionSequenceList EarlyConversions = std::nullopt,
8181 bool AggregateCandidateDeduction = false);
8183 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
8184 OverloadCandidateSet &CandidateSet,
8185 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
8186 bool SuppressUserConversions = false, bool PartialOverloading = false,
8187 bool FirstArgumentIsBase = false);
8188 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
8189 Expr::Classification ObjectClassification,
8190 ArrayRef<Expr *> Args,
8191 OverloadCandidateSet &CandidateSet,
8192 bool SuppressUserConversion = false,
8194 void
8195 AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
8196 CXXRecordDecl *ActingContext, QualType ObjectType,
8197 Expr::Classification ObjectClassification,
8198 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
8199 bool SuppressUserConversions = false,
8200 bool PartialOverloading = false,
8201 ConversionSequenceList EarlyConversions = std::nullopt,
8204 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
8205 CXXRecordDecl *ActingContext,
8206 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
8207 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
8208 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
8209 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
8211 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
8212 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
8213 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
8214 bool PartialOverloading = false, bool AllowExplicit = true,
8215 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
8217 bool AggregateCandidateDeduction = false);
8219 FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes,
8220 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
8221 ConversionSequenceList &Conversions, bool SuppressUserConversions,
8222 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
8223 Expr::Classification ObjectClassification = {},
8226 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
8227 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
8228 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
8229 bool AllowExplicit, bool AllowResultConversion = true);
8231 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
8232 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
8233 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
8234 bool AllowExplicit, bool AllowResultConversion = true);
8235 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
8236 DeclAccessPair FoundDecl,
8237 CXXRecordDecl *ActingContext,
8238 const FunctionProtoType *Proto, Expr *Object,
8239 ArrayRef<Expr *> Args,
8240 OverloadCandidateSet &CandidateSet);
8242 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
8243 OverloadCandidateSet &CandidateSet,
8244 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
8246 SourceLocation OpLoc, ArrayRef<Expr *> Args,
8247 OverloadCandidateSet &CandidateSet,
8249 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
8250 OverloadCandidateSet &CandidateSet,
8251 bool IsAssignmentOperator = false,
8252 unsigned NumContextualBoolArguments = 0);
8254 SourceLocation OpLoc, ArrayRef<Expr *> Args,
8255 OverloadCandidateSet &CandidateSet);
8257 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
8258 TemplateArgumentListInfo *ExplicitTemplateArgs,
8259 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
8260
8261 /// Check the enable_if expressions on the given function. Returns the first
8262 /// failing attribute, or NULL if they were all successful.
8263 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
8264 ArrayRef<Expr *> Args,
8265 bool MissingImplicitThis = false);
8266
8267 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
8268 /// non-ArgDependent DiagnoseIfAttrs.
8269 ///
8270 /// Argument-dependent diagnose_if attributes should be checked each time a
8271 /// function is used as a direct callee of a function call.
8272 ///
8273 /// Returns true if any errors were emitted.
8274 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
8275 const Expr *ThisArg,
8276 ArrayRef<const Expr *> Args,
8277 SourceLocation Loc);
8278
8279 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
8280 /// ArgDependent DiagnoseIfAttrs.
8281 ///
8282 /// Argument-independent diagnose_if attributes should be checked on every use
8283 /// of a function.
8284 ///
8285 /// Returns true if any errors were emitted.
8286 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
8287 SourceLocation Loc);
8288
8289 /// Determine if \p A and \p B are equivalent internal linkage declarations
8290 /// from different modules, and thus an ambiguity error can be downgraded to
8291 /// an extension warning.
8292 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
8293 const NamedDecl *B);
8295 SourceLocation Loc, const NamedDecl *D,
8296 ArrayRef<const NamedDecl *> Equiv);
8297
8298 // Emit as a 'note' the specific overload candidate
8300 const NamedDecl *Found, const FunctionDecl *Fn,
8302 QualType DestType = QualType(), bool TakingAddress = false);
8303
8304 // Emit as a series of 'note's all template and non-templates identified by
8305 // the expression Expr
8306 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
8307 bool TakingAddress = false);
8308
8309 /// Returns whether the given function's address can be taken or not,
8310 /// optionally emitting a diagnostic if the address can't be taken.
8311 ///
8312 /// Returns false if taking the address of the function is illegal.
8313 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
8314 bool Complain = false,
8315 SourceLocation Loc = SourceLocation());
8316
8317 // [PossiblyAFunctionType] --> [Return]
8318 // NonFunctionType --> NonFunctionType
8319 // R (A) --> R(A)
8320 // R (*)(A) --> R (A)
8321 // R (&)(A) --> R (A)
8322 // R (S::*)(A) --> R (A)
8323 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
8324
8325 FunctionDecl *
8326 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
8327 bool Complain, DeclAccessPair &Found,
8328 bool *pHadMultipleCandidates = nullptr);
8329
8330 FunctionDecl *
8331 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
8332
8334 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
8335
8337 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
8338 TemplateSpecCandidateSet *FailedTSC = nullptr);
8339
8341 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
8342 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
8343 QualType DestTypeForComplaining = QualType(),
8344 unsigned DiagIDForComplaining = 0);
8345
8346 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
8347 ArrayRef<Expr *> Args,
8348 OverloadCandidateSet &CandidateSet,
8349 bool PartialOverloading = false);
8351 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
8352 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
8353
8354 // An enum used to represent the different possible results of building a
8355 // range-based for loop.
8361
8363 SourceLocation RangeLoc,
8364 const DeclarationNameInfo &NameInfo,
8365 LookupResult &MemberLookup,
8366 OverloadCandidateSet *CandidateSet,
8367 Expr *Range, ExprResult *CallExpr);
8368
8370 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
8371 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
8372 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
8373
8375 MultiExprArg Args, SourceLocation RParenLoc,
8376 OverloadCandidateSet *CandidateSet,
8378
8382 const UnresolvedSetImpl &Fns,
8383 bool PerformADL = true);
8384
8387 const UnresolvedSetImpl &Fns, Expr *input,
8388 bool RequiresADL = true);
8389
8392 const UnresolvedSetImpl &Fns,
8393 ArrayRef<Expr *> Args, bool RequiresADL = true);
8395 const UnresolvedSetImpl &Fns, Expr *LHS,
8396 Expr *RHS, bool RequiresADL = true,
8397 bool AllowRewrittenCandidates = true,
8398 FunctionDecl *DefaultedFn = nullptr);
8400 const UnresolvedSetImpl &Fns,
8401 Expr *LHS, Expr *RHS,
8402 FunctionDecl *DefaultedFn);
8403
8405 SourceLocation RLoc, Expr *Base,
8406 MultiExprArg Args);
8407
8409 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
8410 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
8411 bool IsExecConfig = false, bool AllowRecovery = false);
8413 SourceLocation LParenLoc,
8414 MultiExprArg Args,
8415 SourceLocation RParenLoc);
8416
8418 SourceLocation OpLoc,
8419 bool *NoArrowOperatorFound = nullptr);
8420
8422 CXXConversionDecl *Method,
8423 bool HadMultipleCandidates);
8424
8427 SourceLocation LitEndLoc,
8428 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
8429
8431 FunctionDecl *Fn);
8433 DeclAccessPair FoundDecl,
8434 FunctionDecl *Fn);
8435
8436private:
8437 /// - Returns a selector which best matches given argument list or
8438 /// nullptr if none could be found
8439 ObjCMethodDecl *SelectBestMethod(Selector Sel, MultiExprArg Args,
8440 bool IsInstance,
8442
8443 ///@}
8444
8445 //
8446 //
8447 // -------------------------------------------------------------------------
8448 //
8449 //
8450
8451 /// \name Pseudo-Object
8452 /// Implementations are in SemaPseudoObject.cpp
8453 ///@{
8454
8455public:
8458
8461
8463 UnaryOperatorKind Opcode, Expr *Op);
8465 BinaryOperatorKind Opcode, Expr *LHS,
8466 Expr *RHS);
8469
8470 ///@}
8471
8472 //
8473 //
8474 // -------------------------------------------------------------------------
8475 //
8476 //
8477
8478 /// \name Statements
8479 /// Implementations are in SemaStmt.cpp
8480 ///@{
8481
8482public:
8483 /// Stack of active SEH __finally scopes. Can be empty.
8485
8486 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
8488
8490 bool HasLeadingEmptyMacro = false);
8491
8493 SourceLocation EndLoc);
8495
8496 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
8497 /// whose result is unused, warn.
8498 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
8499
8500 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
8504 ArrayRef<Stmt *> Elts, bool isStmtExpr);
8505
8507
8510 SourceLocation DotDotDotLoc, ExprResult RHS,
8511 SourceLocation ColonLoc);
8512 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
8513
8515 SourceLocation ColonLoc, Stmt *SubStmt,
8516 Scope *CurScope);
8518 SourceLocation ColonLoc, Stmt *SubStmt);
8519
8521 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
8523 Stmt *SubStmt);
8524
8525 /// Check whether the given statement can have musttail applied to it,
8526 /// issuing a diagnostic and returning false if not. In the success case,
8527 /// the statement is rewritten to remove implicit nodes from the return
8528 /// value.
8529 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
8530
8532 SourceLocation LParenLoc, Stmt *InitStmt,
8533 ConditionResult Cond, SourceLocation RParenLoc,
8534 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
8536 SourceLocation LParenLoc, Stmt *InitStmt,
8537 ConditionResult Cond, SourceLocation RParenLoc,
8538 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
8539
8541
8543 SourceLocation LParenLoc, Stmt *InitStmt,
8544 ConditionResult Cond,
8545 SourceLocation RParenLoc);
8547 Stmt *Body);
8548
8549 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
8550 /// integer not in the range of enum values.
8551 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
8552 Expr *SrcExpr);
8553
8555 ConditionResult Cond, SourceLocation RParenLoc,
8556 Stmt *Body);
8558 SourceLocation WhileLoc, SourceLocation CondLParen,
8559 Expr *Cond, SourceLocation CondRParen);
8560
8562 Stmt *First, ConditionResult Second,
8563 FullExprArg Third, SourceLocation RParenLoc,
8564 Stmt *Body);
8565
8567
8569 Expr *collection);
8571 Expr *collection,
8572 SourceLocation RParenLoc);
8573 StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body);
8574
8576 /// Initial building of a for-range statement.
8578 /// Instantiation or recovery rebuild of a for-range statement. Don't
8579 /// attempt any typo-correction.
8581 /// Determining whether a for-range statement could be built. Avoid any
8582 /// unnecessary or irreversible actions.
8585
8587 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
8588 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
8589 SourceLocation RParenLoc, BuildForRangeKind Kind,
8590 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
8592 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
8593 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
8594 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
8595 BuildForRangeKind Kind,
8596 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
8597 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
8598
8599 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
8600 LabelDecl *TheDecl);
8601 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
8602 SourceLocation StarLoc, Expr *DestExp);
8603 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
8604 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
8605
8608
8609 enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
8611
8612 bool isMoveEligible() const { return S != None; };
8613 bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
8614 };
8616 NamedReturnInfo getNamedReturnInfo(
8618 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
8619 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
8620 QualType ReturnType);
8621
8624 const NamedReturnInfo &NRInfo, Expr *Value,
8625 bool SupressSimplerImplicitMoves = false);
8626
8628
8630 SourceLocation ReturnLoc, Expr *RetExpr,
8631 const AutoType *AT);
8632
8633 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
8634 Scope *CurScope);
8635 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
8636 bool AllowRecovery = false);
8638 NamedReturnInfo &NRInfo,
8639 bool SupressSimplerImplicitMoves);
8640
8642 Decl *Parm, Stmt *Body);
8643
8645
8647 MultiStmtArg Catch, Stmt *Finally);
8648
8651 Scope *CurScope);
8653 Expr *operand);
8655 Stmt *SynchBody);
8656
8658
8660 Stmt *HandlerBlock);
8662 ArrayRef<Stmt *> Handlers);
8663
8664 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
8665 SourceLocation TryLoc, Stmt *TryBlock,
8666 Stmt *Handler);
8668 Stmt *Block);
8673
8675 bool IsIfExists,
8676 NestedNameSpecifierLoc QualifierLoc,
8677 DeclarationNameInfo NameInfo,
8678 Stmt *Nested);
8680 bool IsIfExists, CXXScopeSpec &SS,
8681 UnqualifiedId &Name, Stmt *Nested);
8682
8683 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
8684 CapturedRegionKind Kind, unsigned NumParams);
8685 typedef std::pair<StringRef, QualType> CapturedParamNameType;
8686 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
8687 CapturedRegionKind Kind,
8689 unsigned OpenMPCaptureLevel = 0);
8693 SourceLocation Loc,
8694 unsigned NumParams);
8695
8696private:
8697 /// Check whether the given statement can have musttail applied to it,
8698 /// issuing a diagnostic and returning false if not.
8699 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
8700
8701 /// Check if the given expression contains 'break' or 'continue'
8702 /// statement that produces control flow different from GCC.
8703 void CheckBreakContinueBinding(Expr *E);
8704
8705 ///@}
8706
8707 //
8708 //
8709 // -------------------------------------------------------------------------
8710 //
8711 //
8712
8713 /// \name `inline asm` Statement
8714 /// Implementations are in SemaStmtAsm.cpp
8715 ///@{
8716
8717public:
8718 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
8719 bool IsVolatile, unsigned NumOutputs,
8720 unsigned NumInputs, IdentifierInfo **Names,
8721 MultiExprArg Constraints, MultiExprArg Exprs,
8722 Expr *AsmString, MultiExprArg Clobbers,
8723 unsigned NumLabels, SourceLocation RParenLoc);
8724
8726 llvm::InlineAsmIdentifierInfo &Info);
8728 SourceLocation TemplateKWLoc,
8730 bool IsUnevaluatedContext);
8731 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
8732 SourceLocation AsmLoc);
8734 SourceLocation AsmLoc);
8736 ArrayRef<Token> AsmToks, StringRef AsmString,
8737 unsigned NumOutputs, unsigned NumInputs,
8738 ArrayRef<StringRef> Constraints,
8739 ArrayRef<StringRef> Clobbers,
8740 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
8741 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
8742 SourceLocation Location, bool AlwaysCreate);
8743
8744 ///@}
8745
8746 //
8747 //
8748 // -------------------------------------------------------------------------
8749 //
8750 //
8751
8752 /// \name Statement Attribute Handling
8753 /// Implementations are in SemaStmtAttr.cpp
8754 ///@{
8755
8756public:
8757 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
8758 const AttributeCommonInfo &A);
8759 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
8760 const AttributeCommonInfo &A);
8761
8762 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
8764
8765 /// Process the attributes before creating an attributed statement. Returns
8766 /// the semantic attributes that have been processed.
8767 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
8769
8771 SourceRange Range);
8773 const IdentifierInfo *AttrName,
8774 SourceRange Range);
8775
8776 ///@}
8777
8778 //
8779 //
8780 // -------------------------------------------------------------------------
8781 //
8782 //
8783
8784 /// \name C++ Templates
8785 /// Implementations are in SemaTemplate.cpp
8786 ///@{
8787
8788public:
8789 // Saves the current floating-point pragma stack and clear it in this Sema.
8791 public:
8793 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
8794 S.FpPragmaStack.Stack.clear();
8795 }
8796 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
8797
8798 private:
8799 Sema &S;
8801 };
8802
8804 CurFPFeatures = FPO;
8805 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
8806 }
8807
8809 return llvm::ArrayRef(InventedParameterInfos.begin() +
8812 }
8813
8814 /// The number of SFINAE diagnostics that have been trapped.
8816
8819 FunctionScopes.end());
8820 }
8821
8822 typedef llvm::MapVector<const FunctionDecl *,
8823 std::unique_ptr<LateParsedTemplate>>
8826
8827 /// Determine the number of levels of enclosing template parameters. This is
8828 /// only usable while parsing. Note that this does not include dependent
8829 /// contexts in which no template parameters have yet been declared, such as
8830 /// in a terse function template or generic lambda before the first 'auto' is
8831 /// encountered.
8832 unsigned getTemplateDepth(Scope *S) const;
8833
8835 bool AllowFunctionTemplates = true,
8836 bool AllowDependent = true);
8838 bool AllowFunctionTemplates = true,
8839 bool AllowDependent = true,
8840 bool AllowNonTemplateFunctions = false);
8841 /// Try to interpret the lookup result D as a template-name.
8842 ///
8843 /// \param D A declaration found by name lookup.
8844 /// \param AllowFunctionTemplates Whether function templates should be
8845 /// considered valid results.
8846 /// \param AllowDependent Whether unresolved using declarations (that might
8847 /// name templates) should be considered valid results.
8849 bool AllowFunctionTemplates = true,
8850 bool AllowDependent = true);
8851
8853 /// Whether and why a template name is required in this lookup.
8855 public:
8856 /// Template name is required if TemplateKWLoc is valid.
8858 : TemplateKW(TemplateKWLoc) {}
8859 /// Template name is unconditionally required.
8861
8863 return TemplateKW.value_or(SourceLocation());
8864 }
8865 bool hasTemplateKeyword() const {
8866 return getTemplateKeywordLoc().isValid();
8867 }
8868 bool isRequired() const { return TemplateKW != SourceLocation(); }
8869 explicit operator bool() const { return isRequired(); }
8870
8871 private:
8872 std::optional<SourceLocation> TemplateKW;
8873 };
8874
8876 /// This is not assumed to be a template name.
8877 None,
8878 /// This is assumed to be a template name because lookup found nothing.
8880 /// This is assumed to be a template name because lookup found one or more
8881 /// functions (but no function templates).
8883 };
8884 bool LookupTemplateName(
8885 LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType,
8886 bool EnteringContext, bool &MemberOfUnknownSpecialization,
8887 RequiredTemplateKind RequiredTemplate = SourceLocation(),
8888 AssumedTemplateKind *ATK = nullptr, bool AllowTypoCorrection = true);
8889
8891 bool hasTemplateKeyword,
8892 const UnqualifiedId &Name,
8893 ParsedType ObjectType, bool EnteringContext,
8894 TemplateTy &Template,
8895 bool &MemberOfUnknownSpecialization,
8896 bool Disambiguation = false);
8897
8898 /// Try to resolve an undeclared template name as a type template.
8899 ///
8900 /// Sets II to the identifier corresponding to the template name, and updates
8901 /// Name to a corresponding (typo-corrected) type template name and TNK to
8902 /// the corresponding kind, if possible.
8904 TemplateNameKind &TNK,
8905 SourceLocation NameLoc,
8906 IdentifierInfo *&II);
8907
8909 SourceLocation NameLoc,
8910 bool Diagnose = true);
8911
8912 /// Determine whether a particular identifier might be the name in a C++1z
8913 /// deduction-guide declaration.
8914 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
8915 SourceLocation NameLoc, CXXScopeSpec &SS,
8916 ParsedTemplateTy *Template = nullptr);
8917
8919 SourceLocation IILoc, Scope *S,
8920 const CXXScopeSpec *SS,
8921 TemplateTy &SuggestedTemplate,
8922 TemplateNameKind &SuggestedKind);
8923
8924 bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
8925 NamedDecl *Instantiation,
8926 bool InstantiatedFromMember,
8927 const NamedDecl *Pattern,
8928 const NamedDecl *PatternDef,
8930 bool Complain = true);
8931
8932 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
8933 /// that the template parameter 'PrevDecl' is being shadowed by a new
8934 /// declaration at location Loc. Returns true to indicate that this is
8935 /// an error, and false otherwise.
8936 ///
8937 /// \param Loc The location of the declaration that shadows a template
8938 /// parameter.
8939 ///
8940 /// \param PrevDecl The template parameter that the declaration shadows.
8941 ///
8942 /// \param SupportedForCompatibility Whether to issue the diagnostic as
8943 /// a warning for compatibility with older versions of clang.
8944 /// Ignored when MSVC compatibility is enabled.
8946 bool SupportedForCompatibility = false);
8948
8950 SourceLocation EllipsisLoc,
8951 SourceLocation KeyLoc,
8952 IdentifierInfo *ParamName,
8953 SourceLocation ParamNameLoc, unsigned Depth,
8954 unsigned Position, SourceLocation EqualLoc,
8955 ParsedType DefaultArg, bool HasTypeConstraint);
8956
8958
8959 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
8961 TemplateTypeParmDecl *ConstrainedParameter,
8962 SourceLocation EllipsisLoc);
8963 bool BuildTypeConstraint(const CXXScopeSpec &SS,
8965 TemplateTypeParmDecl *ConstrainedParameter,
8966 SourceLocation EllipsisLoc,
8967 bool AllowUnexpandedPack);
8968
8970 DeclarationNameInfo NameInfo,
8971 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
8972 const TemplateArgumentListInfo *TemplateArgs,
8973 TemplateTypeParmDecl *ConstrainedParameter,
8974 SourceLocation EllipsisLoc);
8975
8977 NonTypeTemplateParmDecl *NewConstrainedParm,
8978 NonTypeTemplateParmDecl *OrigConstrainedParm,
8979 SourceLocation EllipsisLoc);
8980
8982
8984 SourceLocation Loc);
8986
8988 unsigned Depth, unsigned Position,
8989 SourceLocation EqualLoc,
8990 Expr *DefaultArg);
8992 Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params,
8993 bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
8994 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
8995 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
8996
8998 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
8999 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
9000 SourceLocation RAngleLoc, Expr *RequiresClause);
9001
9002 /// The context in which we are checking a template parameter list.
9013
9015 TemplateParameterList *OldParams,
9017 SkipBodyInfo *SkipBody = nullptr);
9019 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
9020 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
9021 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
9022 bool &IsMemberSpecialization, bool &Invalid,
9023 bool SuppressDiagnostic = false);
9024
9026 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
9027 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
9028 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
9029 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
9030 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
9031 TemplateParameterList **OuterTemplateParamLists,
9032 SkipBodyInfo *SkipBody = nullptr);
9033
9036
9038
9040
9042 SourceLocation TemplateLoc,
9043 TemplateArgumentListInfo &TemplateArgs);
9044
9047 TemplateTy Template, const IdentifierInfo *TemplateII,
9048 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
9049 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
9050 bool IsCtorOrDtorName = false, bool IsClassName = false,
9051 ImplicitTypenameContext AllowImplicitTypename =
9053
9054 /// Parsed an elaborated-type-specifier that refers to a template-id,
9055 /// such as \c class T::template apply<U>.
9057 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
9058 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
9059 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
9060 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
9061
9064 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
9066
9067 /// Get the specialization of the given variable template corresponding to
9068 /// the specified argument list, or a null-but-valid result if the arguments
9069 /// are dependent.
9071 SourceLocation TemplateLoc,
9072 SourceLocation TemplateNameLoc,
9073 const TemplateArgumentListInfo &TemplateArgs);
9074
9075 /// Form a reference to the specialization of the given variable template
9076 /// corresponding to the specified argument list, or a null-but-valid result
9077 /// if the arguments are dependent.
9079 const DeclarationNameInfo &NameInfo,
9080 VarTemplateDecl *Template, NamedDecl *FoundD,
9081 SourceLocation TemplateLoc,
9082 const TemplateArgumentListInfo *TemplateArgs);
9083
9085 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9086 const DeclarationNameInfo &ConceptNameInfo,
9087 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
9088 const TemplateArgumentListInfo *TemplateArgs);
9089
9091
9093 SourceLocation TemplateKWLoc, LookupResult &R,
9094 bool RequiresADL,
9095 const TemplateArgumentListInfo *TemplateArgs);
9096
9099 const DeclarationNameInfo &NameInfo,
9100 const TemplateArgumentListInfo *TemplateArgs);
9101
9103 SourceLocation TemplateKWLoc,
9104 const UnqualifiedId &Name,
9105 ParsedType ObjectType,
9106 bool EnteringContext, TemplateTy &Template,
9107 bool AllowInjectedClassName = false);
9108
9110 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
9111 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
9113 MultiTemplateParamsArg TemplateParameterLists,
9114 SkipBodyInfo *SkipBody = nullptr);
9115
9117 TemplateDecl *PrimaryTemplate,
9118 unsigned NumExplicitArgs,
9124
9126 MultiTemplateParamsArg TemplateParameterLists,
9127 Declarator &D);
9128
9130 SourceLocation NewLoc,
9131 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
9132 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
9133 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
9134
9136 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
9138
9140 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
9141 LookupResult &Previous, bool QualifiedFriend = false);
9144
9146 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
9147 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
9148 TemplateTy Template, SourceLocation TemplateNameLoc,
9149 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
9150 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
9151
9153 SourceLocation TemplateLoc,
9154 unsigned TagSpec, SourceLocation KWLoc,
9155 CXXScopeSpec &SS, IdentifierInfo *Name,
9156 SourceLocation NameLoc,
9157 const ParsedAttributesView &Attr);
9158
9160 SourceLocation TemplateLoc,
9161 Declarator &D);
9162
9164 TemplateDecl *Template, SourceLocation TemplateLoc,
9165 SourceLocation RAngleLoc, Decl *Param,
9166 ArrayRef<TemplateArgument> SugaredConverted,
9167 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
9168
9170
9171 /// Specifies the context in which a particular template
9172 /// argument is being checked.
9174 /// The template argument was specified in the code or was
9175 /// instantiated with some deduced template arguments.
9177
9178 /// The template argument was deduced via template argument
9179 /// deduction.
9181
9182 /// The template argument was deduced from an array bound
9183 /// via template argument deduction.
9186
9187 bool
9189 NamedDecl *Template, SourceLocation TemplateLoc,
9190 SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
9191 SmallVectorImpl<TemplateArgument> &SugaredConverted,
9192 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
9194
9195 /// Check that the given template arguments can be provided to
9196 /// the given template, converting the arguments along the way.
9197 ///
9198 /// \param Template The template to which the template arguments are being
9199 /// provided.
9200 ///
9201 /// \param TemplateLoc The location of the template name in the source.
9202 ///
9203 /// \param TemplateArgs The list of template arguments. If the template is
9204 /// a template template parameter, this function may extend the set of
9205 /// template arguments to also include substituted, defaulted template
9206 /// arguments.
9207 ///
9208 /// \param PartialTemplateArgs True if the list of template arguments is
9209 /// intentionally partial, e.g., because we're checking just the initial
9210 /// set of template arguments.
9211 ///
9212 /// \param Converted Will receive the converted, canonicalized template
9213 /// arguments.
9214 ///
9215 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
9216 /// contain the converted forms of the template arguments as written.
9217 /// Otherwise, \p TemplateArgs will not be modified.
9218 ///
9219 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
9220 /// receive true if the cause for the error is the associated constraints of
9221 /// the template not being satisfied by the template arguments.
9222 ///
9223 /// \returns true if an error occurred, false otherwise.
9225 TemplateDecl *Template, SourceLocation TemplateLoc,
9226 TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs,
9227 SmallVectorImpl<TemplateArgument> &SugaredConverted,
9228 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
9229 bool UpdateArgsWithConversions = true,
9230 bool *ConstraintsNotSatisfied = nullptr);
9231
9234 SmallVectorImpl<TemplateArgument> &SugaredConverted,
9235 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
9236
9239 QualType InstantiatedParamType, Expr *Arg,
9240 TemplateArgument &SugaredConverted,
9241 TemplateArgument &CanonicalConverted,
9244 TemplateParameterList *Params,
9245 TemplateArgumentLoc &Arg);
9246
9248 std::optional<SourceRange> ParamRange = {});
9249 void NoteTemplateParameterLocation(const NamedDecl &Decl);
9250
9252 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc);
9254 BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg,
9255 SourceLocation Loc);
9256
9257 /// Enumeration describing how template parameter lists are compared
9258 /// for equality.
9260 /// We are matching the template parameter lists of two templates
9261 /// that might be redeclarations.
9262 ///
9263 /// \code
9264 /// template<typename T> struct X;
9265 /// template<typename T> struct X;
9266 /// \endcode
9268
9269 /// We are matching the template parameter lists of two template
9270 /// template parameters as part of matching the template parameter lists
9271 /// of two templates that might be redeclarations.
9272 ///
9273 /// \code
9274 /// template<template<int I> class TT> struct X;
9275 /// template<template<int Value> class Other> struct X;
9276 /// \endcode
9278
9279 /// We are matching the template parameter lists of a template
9280 /// template argument against the template parameter lists of a template
9281 /// template parameter.
9282 ///
9283 /// \code
9284 /// template<template<int Value> class Metafun> struct X;
9285 /// template<int Value> struct integer_c;
9286 /// X<integer_c> xic;
9287 /// \endcode
9289
9290 /// We are determining whether the template-parameters are equivalent
9291 /// according to C++ [temp.over.link]/6. This comparison does not consider
9292 /// constraints.
9293 ///
9294 /// \code
9295 /// template<C1 T> void f(T);
9296 /// template<C2 T> void f(T);
9297 /// \endcode
9299 };
9300
9301 // A struct to represent the 'new' declaration, which is either itself just
9302 // the named decl, or the important information we need about it in order to
9303 // do constraint comparisons.
9305 const NamedDecl *ND = nullptr;
9306 const DeclContext *DC = nullptr;
9307 const DeclContext *LexicalDC = nullptr;
9308 SourceLocation Loc;
9309
9310 public:
9313 const DeclContext *LexicalDeclCtx,
9314 SourceLocation Loc)
9315
9316 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
9317 assert(DC && LexicalDC &&
9318 "Constructor only for cases where we have the information to put "
9319 "in here");
9320 }
9321
9322 // If this was constructed with no information, we cannot do substitution
9323 // for constraint comparison, so make sure we can check that.
9324 bool isInvalid() const { return !ND && !DC; }
9325
9326 const NamedDecl *getDecl() const { return ND; }
9327
9328 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
9329
9331 return ND ? ND->getLexicalDeclContext() : LexicalDC;
9332 }
9333
9335 return ND ? ND->getDeclContext() : DC;
9336 }
9337
9338 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
9339 };
9340
9342 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
9343 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
9345 SourceLocation TemplateArgLoc = SourceLocation());
9346
9348 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
9350 SourceLocation TemplateArgLoc = SourceLocation()) {
9351 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
9352 Kind, TemplateArgLoc);
9353 }
9354
9355 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
9356
9357 /// Called when the parser has parsed a C++ typename
9358 /// specifier, e.g., "typename T::type".
9359 ///
9360 /// \param S The scope in which this typename type occurs.
9361 /// \param TypenameLoc the location of the 'typename' keyword
9362 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
9363 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
9364 /// \param IdLoc the location of the identifier.
9365 /// \param IsImplicitTypename context where T::type refers to a type.
9367 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
9368 const IdentifierInfo &II, SourceLocation IdLoc,
9370
9371 /// Called when the parser has parsed a C++ typename
9372 /// specifier that ends in a template-id, e.g.,
9373 /// "typename MetaFun::template apply<T1, T2>".
9374 ///
9375 /// \param S The scope in which this typename type occurs.
9376 /// \param TypenameLoc the location of the 'typename' keyword
9377 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
9378 /// \param TemplateLoc the location of the 'template' keyword, if any.
9379 /// \param TemplateName The template name.
9380 /// \param TemplateII The identifier used to name the template.
9381 /// \param TemplateIILoc The location of the template name.
9382 /// \param LAngleLoc The location of the opening angle bracket ('<').
9383 /// \param TemplateArgs The template arguments.
9384 /// \param RAngleLoc The location of the closing angle bracket ('>').
9386 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
9387 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
9388 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
9389 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
9390 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
9391
9393 SourceLocation KeywordLoc,
9394 NestedNameSpecifierLoc QualifierLoc,
9395 const IdentifierInfo &II, SourceLocation IILoc,
9396 TypeSourceInfo **TSI, bool DeducedTSTContext);
9397
9399 SourceLocation KeywordLoc,
9400 NestedNameSpecifierLoc QualifierLoc,
9401 const IdentifierInfo &II, SourceLocation IILoc,
9402 bool DeducedTSTContext = true);
9403
9405 SourceLocation Loc,
9406 DeclarationName Name);
9408
9410 bool
9412
9413 std::string
9415 const TemplateArgumentList &Args);
9416
9417 std::string
9419 const TemplateArgument *Args,
9420 unsigned NumArgs);
9421
9425
9427 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9428 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
9429 const TemplateArgumentListInfo *TemplateArgs);
9430
9433 SourceLocation TemplateKWLoc,
9434 const DeclarationNameInfo &NameInfo,
9435 const TemplateArgumentListInfo *TemplateArgs);
9436
9437 // Calculates whether the expression Constraint depends on an enclosing
9438 // template, for the purposes of [temp.friend] p9.
9439 // TemplateDepth is the 'depth' of the friend function, which is used to
9440 // compare whether a declaration reference is referring to a containing
9441 // template, or just the current friend function. A 'lower' TemplateDepth in
9442 // the AST refers to a 'containing' template. As the constraint is
9443 // uninstantiated, this is relative to the 'top' of the TU.
9444 bool
9446 unsigned TemplateDepth,
9447 const Expr *Constraint);
9448
9449 /// Declare implicit deduction guides for a class template if we've
9450 /// not already done so.
9452 SourceLocation Loc);
9453
9455 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
9456 SourceLocation Loc);
9457
9458 /// Find the failed Boolean condition within a given Boolean
9459 /// constant expression, and describe it with a string.
9460 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
9461
9463
9465 MultiTemplateParamsArg TemplateParameterLists,
9466 const IdentifierInfo *Name,
9467 SourceLocation NameLoc, Expr *ConstraintExpr);
9468
9470 bool &AddToScope);
9471
9472 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
9473 const CXXScopeSpec &SS,
9474 const IdentifierInfo *Name,
9475 SourceLocation TagLoc, SourceLocation NameLoc);
9476
9478 CachedTokens &Toks);
9481
9482 /// We've found a use of a templated declaration that would trigger an
9483 /// implicit instantiation. Check that any relevant explicit specializations
9484 /// and partial specializations are visible/reachable, and diagnose if not.
9487
9488 ///@}
9489
9490 //
9491 //
9492 // -------------------------------------------------------------------------
9493 //
9494 //
9495
9496 /// \name C++ Template Argument Deduction
9497 /// Implementations are in SemaTemplateDeduction.cpp
9498 ///@{
9499
9500public:
9501 /// When true, access checking violations are treated as SFINAE
9502 /// failures rather than hard errors.
9504
9505 /// RAII class used to determine whether SFINAE has
9506 /// trapped any errors that occur during template argument
9507 /// deduction.
9509 Sema &SemaRef;
9510 unsigned PrevSFINAEErrors;
9511 bool PrevInNonInstantiationSFINAEContext;
9512 bool PrevAccessCheckingSFINAE;
9513 bool PrevLastDiagnosticIgnored;
9514
9515 public:
9516 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
9517 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
9518 PrevInNonInstantiationSFINAEContext(
9519 SemaRef.InNonInstantiationSFINAEContext),
9520 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
9521 PrevLastDiagnosticIgnored(
9522 SemaRef.getDiagnostics().isLastDiagnosticIgnored()) {
9523 if (!SemaRef.isSFINAEContext())
9524 SemaRef.InNonInstantiationSFINAEContext = true;
9525 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
9526 }
9527
9529 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
9531 PrevInNonInstantiationSFINAEContext;
9532 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
9534 PrevLastDiagnosticIgnored);
9535 }
9536
9537 /// Determine whether any SFINAE errors have been trapped.
9538 bool hasErrorOccurred() const {
9539 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
9540 }
9541 };
9542
9543 /// RAII class used to indicate that we are performing provisional
9544 /// semantic analysis to determine the validity of a construct, so
9545 /// typo-correction and diagnostics in the immediate context (not within
9546 /// implicitly-instantiated templates) should be suppressed.
9548 Sema &SemaRef;
9549 // FIXME: Using a SFINAETrap for this is a hack.
9550 SFINAETrap Trap;
9551 bool PrevDisableTypoCorrection;
9552
9553 public:
9554 explicit TentativeAnalysisScope(Sema &SemaRef)
9555 : SemaRef(SemaRef), Trap(SemaRef, true),
9556 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
9557 SemaRef.DisableTypoCorrection = true;
9558 }
9560 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
9561 }
9562 };
9563
9564 /// For each declaration that involved template argument deduction, the
9565 /// set of diagnostics that were suppressed during that template argument
9566 /// deduction.
9567 ///
9568 /// FIXME: Serialize this structure to the AST file.
9569 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
9572
9574
9576 QualType NTTPType,
9577 SourceLocation Loc);
9578
9579 /// Get a template argument mapping the given template parameter to itself,
9580 /// e.g. for X in \c template<int X>, this would return an expression template
9581 /// argument referencing X.
9583 SourceLocation Location);
9584
9585 /// Adjust the type \p ArgFunctionType to match the calling convention,
9586 /// noreturn, and optionally the exception specification of \p FunctionType.
9587 /// Deduction often wants to ignore these properties when matching function
9588 /// types.
9590 bool AdjustExceptionSpec = false);
9591
9594 ArrayRef<TemplateArgument> TemplateArgs,
9596
9599 ArrayRef<TemplateArgument> TemplateArgs,
9601
9606 bool NumberOfArgumentsMustMatch);
9607
9610 TemplateArgumentListInfo &ExplicitTemplateArgs,
9614
9615 /// brief A function argument from which we performed template argument
9616 // deduction for a call.
9618 OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
9619 unsigned ArgIdx, QualType OriginalArgType)
9620 : OriginalParamType(OriginalParamType),
9621 DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
9622 OriginalArgType(OriginalArgType) {}
9623
9626 unsigned ArgIdx;
9628 };
9629
9633 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
9635 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
9636 bool PartialOverloading = false,
9637 llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
9638
9641 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
9643 bool PartialOverloading, bool AggregateDeductionCandidate,
9644 QualType ObjectType, Expr::Classification ObjectClassification,
9645 llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
9646
9649 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
9651 bool IsAddressOfFunction = false);
9652
9655 Expr::Classification ObjectClassification, QualType ToType,
9657
9660 TemplateArgumentListInfo *ExplicitTemplateArgs,
9663 bool IsAddressOfFunction = false);
9664
9665 /// Substitute Replacement for \p auto in \p TypeWithAuto
9666 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
9667 /// Substitute Replacement for auto in TypeWithAuto
9669 QualType Replacement);
9670
9671 // Substitute auto in TypeWithAuto for a Dependent auto type
9673
9674 // Substitute auto in TypeWithAuto for a Dependent auto type
9677
9678 /// Completely replace the \c auto in \p TypeWithAuto by
9679 /// \p Replacement. This does not retain any \c auto type sugar.
9680 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
9682 QualType Replacement);
9683
9687 bool DependentDeduction = false,
9688 bool IgnoreConstraints = false,
9689 TemplateSpecCandidateSet *FailedTSC = nullptr);
9692 bool Diagnose = true);
9693
9695 SourceLocation Loc);
9696
9701
9704
9708
9711
9714
9715 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
9716 unsigned Depth, llvm::SmallBitVector &Used);
9717
9718 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
9719 bool OnlyDeduced, unsigned Depth,
9720 llvm::SmallBitVector &Used);
9721 void
9723 llvm::SmallBitVector &Deduced) {
9725 }
9726 static void
9729 llvm::SmallBitVector &Deduced);
9730
9733 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
9734 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false);
9735
9736 UnresolvedSetIterator
9737 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
9738 TemplateSpecCandidateSet &FailedCandidates,
9739 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
9740 const PartialDiagnostic &AmbigDiag,
9741 const PartialDiagnostic &CandidateDiag,
9742 bool Complain = true, QualType TargetType = QualType());
9743
9744 ///@}
9745
9746 //
9747 //
9748 // -------------------------------------------------------------------------
9749 //
9750 //
9751
9752 /// \name C++ Template Instantiation
9753 /// Implementations are in SemaTemplateInstantiate.cpp
9754 ///@{
9755
9756public:
9757 /// A helper class for building up ExtParameterInfos.
9760 bool HasInteresting = false;
9761
9762 public:
9763 /// Set the ExtParameterInfo for the parameter at the given index,
9764 ///
9765 void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
9766 assert(Infos.size() <= index);
9767 Infos.resize(index);
9768 Infos.push_back(info);
9769
9770 if (!HasInteresting)
9771 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
9772 }
9773
9774 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
9775 /// ExtParameterInfo array we've built up.
9777 getPointerOrNull(unsigned numParams) {
9778 if (!HasInteresting)
9779 return nullptr;
9780 Infos.resize(numParams);
9781 return Infos.data();
9782 }
9783 };
9784
9785 /// The current instantiation scope used to store local
9786 /// variables.
9788
9789 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
9791
9792 /// A mapping from parameters with unparsed default arguments to the
9793 /// set of instantiations of each parameter.
9794 ///
9795 /// This mapping is a temporary data structure used when parsing
9796 /// nested class templates or nested classes of class templates,
9797 /// where we might end up instantiating an inner class before the
9798 /// default arguments of its methods have been parsed.
9800
9801 /// A context in which code is being synthesized (where a source location
9802 /// alone is not sufficient to identify the context). This covers template
9803 /// instantiation and various forms of implicitly-generated functions.
9805 /// The kind of template instantiation we are performing
9807 /// We are instantiating a template declaration. The entity is
9808 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
9810
9811 /// We are instantiating a default argument for a template
9812 /// parameter. The Entity is the template parameter whose argument is
9813 /// being instantiated, the Template is the template, and the
9814 /// TemplateArgs/NumTemplateArguments provide the template arguments as
9815 /// specified.
9817
9818 /// We are instantiating a default argument for a function.
9819 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
9820 /// provides the template arguments as specified.
9822
9823 /// We are substituting explicit template arguments provided for
9824 /// a function template. The entity is a FunctionTemplateDecl.
9826
9827 /// We are substituting template argument determined as part of
9828 /// template argument deduction for either a class template
9829 /// partial specialization or a function template. The
9830 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
9831 /// a TemplateDecl.
9833
9834 /// We are substituting into a lambda expression.
9836
9837 /// We are substituting prior template arguments into a new
9838 /// template parameter. The template parameter itself is either a
9839 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
9841
9842 /// We are checking the validity of a default template argument that
9843 /// has been used when naming a template-id.
9845
9846 /// We are computing the exception specification for a defaulted special
9847 /// member function.
9849
9850 /// We are instantiating the exception specification for a function
9851 /// template which was deferred until it was needed.
9853
9854 /// We are instantiating a requirement of a requires expression.
9856
9857 /// We are checking the satisfaction of a nested requirement of a requires
9858 /// expression.
9860
9861 /// We are declaring an implicit special member function.
9863
9864 /// We are declaring an implicit 'operator==' for a defaulted
9865 /// 'operator<=>'.
9867
9868 /// We are defining a synthesized function (such as a defaulted special
9869 /// member).
9871
9872 // We are checking the constraints associated with a constrained entity or
9873 // the constraint expression of a concept. This includes the checks that
9874 // atomic constraints have the type 'bool' and that they can be constant
9875 // evaluated.
9877
9878 // We are substituting template arguments into a constraint expression.
9880
9881 // We are normalizing a constraint expression.
9883
9884 // Instantiating a Requires Expression parameter clause.
9886
9887 // We are substituting into the parameter mapping of an atomic constraint
9888 // during normalization.
9890
9891 /// We are rewriting a comparison operator in terms of an operator<=>.
9893
9894 /// We are initializing a structured binding.
9896
9897 /// We are marking a class as __dllexport.
9899
9900 /// We are building an implied call from __builtin_dump_struct. The
9901 /// arguments are in CallArgs.
9903
9904 /// Added for Template instantiation observation.
9905 /// Memoization means we are _not_ instantiating a template because
9906 /// it is already instantiated (but we entered a context where we
9907 /// would have had to if it was not already instantiated).
9909
9910 /// We are building deduction guides for a class.
9912
9913 /// We are instantiating a type alias template declaration.
9915 } Kind;
9916
9917 /// Was the enclosing context a non-instantiation SFINAE context?
9919
9920 /// The point of instantiation or synthesis within the source code.
9922
9923 /// The entity that is being synthesized.
9925
9926 /// The template (or partial specialization) in which we are
9927 /// performing the instantiation, for substitutions of prior template
9928 /// arguments.
9930
9931 union {
9932 /// The list of template arguments we are substituting, if they
9933 /// are not part of the entity.
9935
9936 /// The list of argument expressions in a synthesized call.
9937 const Expr *const *CallArgs;
9938 };
9939
9940 // FIXME: Wrap this union around more members, or perhaps store the
9941 // kind-specific members in the RAII object owning the context.
9942 union {
9943 /// The number of template arguments in TemplateArgs.
9945
9946 /// The number of expressions in CallArgs.
9947 unsigned NumCallArgs;
9948
9949 /// The special member being declared or defined.
9951 };
9952
9954 assert(Kind != DeclaringSpecialMember);
9955 return {TemplateArgs, NumTemplateArgs};
9956 }
9957
9958 /// The template deduction info object associated with the
9959 /// substitution or checking of explicit or deduced template arguments.
9961
9962 /// The source range that covers the construct that cause
9963 /// the instantiation, e.g., the template-id that causes a class
9964 /// template instantiation.
9966
9968 : Kind(TemplateInstantiation),
9969 SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
9970 Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
9971 DeductionInfo(nullptr) {}
9972
9973 /// Determines whether this template is an actual instantiation
9974 /// that should be counted toward the maximum instantiation depth.
9975 bool isInstantiationRecord() const;
9976 };
9977
9978 /// A stack object to be created when performing template
9979 /// instantiation.
9980 ///
9981 /// Construction of an object of type \c InstantiatingTemplate
9982 /// pushes the current instantiation onto the stack of active
9983 /// instantiations. If the size of this stack exceeds the maximum
9984 /// number of recursive template instantiations, construction
9985 /// produces an error and evaluates true.
9986 ///
9987 /// Destruction of this object will pop the named instantiation off
9988 /// the stack.
9990 /// Note that we are instantiating a class template,
9991 /// function template, variable template, alias template,
9992 /// or a member thereof.
9993 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
9994 Decl *Entity,
9995 SourceRange InstantiationRange = SourceRange());
9996
9998 /// Note that we are instantiating an exception specification
9999 /// of a function template.
10000 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10002 SourceRange InstantiationRange = SourceRange());
10003
10004 /// Note that we are instantiating a type alias template declaration.
10005 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10006 TypeAliasTemplateDecl *Entity,
10007 ArrayRef<TemplateArgument> TemplateArgs,
10008 SourceRange InstantiationRange = SourceRange());
10009
10010 /// Note that we are instantiating a default argument in a
10011 /// template-id.
10012 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10013 TemplateParameter Param, TemplateDecl *Template,
10014 ArrayRef<TemplateArgument> TemplateArgs,
10015 SourceRange InstantiationRange = SourceRange());
10016
10017 /// Note that we are substituting either explicitly-specified or
10018 /// deduced template arguments during function template argument deduction.
10019 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10020 FunctionTemplateDecl *FunctionTemplate,
10021 ArrayRef<TemplateArgument> TemplateArgs,
10023 sema::TemplateDeductionInfo &DeductionInfo,
10024 SourceRange InstantiationRange = SourceRange());
10025
10026 /// Note that we are instantiating as part of template
10027 /// argument deduction for a class template declaration.
10028 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10029 TemplateDecl *Template,
10030 ArrayRef<TemplateArgument> TemplateArgs,
10031 sema::TemplateDeductionInfo &DeductionInfo,
10032 SourceRange InstantiationRange = SourceRange());
10033
10034 /// Note that we are instantiating as part of template
10035 /// argument deduction for a class template partial
10036 /// specialization.
10037 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10039 ArrayRef<TemplateArgument> TemplateArgs,
10040 sema::TemplateDeductionInfo &DeductionInfo,
10041 SourceRange InstantiationRange = SourceRange());
10042
10043 /// Note that we are instantiating as part of template
10044 /// argument deduction for a variable template partial
10045 /// specialization.
10046 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10048 ArrayRef<TemplateArgument> TemplateArgs,
10049 sema::TemplateDeductionInfo &DeductionInfo,
10050 SourceRange InstantiationRange = SourceRange());
10051
10052 /// Note that we are instantiating a default argument for a function
10053 /// parameter.
10054 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10055 ParmVarDecl *Param,
10056 ArrayRef<TemplateArgument> TemplateArgs,
10057 SourceRange InstantiationRange = SourceRange());
10058
10059 /// Note that we are substituting prior template arguments into a
10060 /// non-type parameter.
10061 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10062 NamedDecl *Template, NonTypeTemplateParmDecl *Param,
10063 ArrayRef<TemplateArgument> TemplateArgs,
10064 SourceRange InstantiationRange);
10065
10066 /// Note that we are substituting prior template arguments into a
10067 /// template template parameter.
10068 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10069 NamedDecl *Template, TemplateTemplateParmDecl *Param,
10070 ArrayRef<TemplateArgument> TemplateArgs,
10071 SourceRange InstantiationRange);
10072
10073 /// Note that we are checking the default template argument
10074 /// against the template parameter for a given template-id.
10075 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10076 TemplateDecl *Template, NamedDecl *Param,
10077 ArrayRef<TemplateArgument> TemplateArgs,
10078 SourceRange InstantiationRange);
10079
10081 /// \brief Note that we are checking the constraints associated with some
10082 /// constrained entity (a concept declaration or a template with associated
10083 /// constraints).
10084 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10085 ConstraintsCheck, NamedDecl *Template,
10086 ArrayRef<TemplateArgument> TemplateArgs,
10087 SourceRange InstantiationRange);
10088
10090 /// \brief Note that we are checking a constraint expression associated
10091 /// with a template declaration or as part of the satisfaction check of a
10092 /// concept.
10093 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10095 sema::TemplateDeductionInfo &DeductionInfo,
10096 SourceRange InstantiationRange);
10097
10099 /// \brief Note that we are normalizing a constraint expression.
10100 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10102 SourceRange InstantiationRange);
10103
10105 /// \brief Note that we are subtituting into the parameter mapping of an
10106 /// atomic constraint during constraint normalization.
10107 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10109 SourceRange InstantiationRange);
10110
10111 /// \brief Note that we are substituting template arguments into a part of
10112 /// a requirement of a requires expression.
10113 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10115 sema::TemplateDeductionInfo &DeductionInfo,
10116 SourceRange InstantiationRange = SourceRange());
10117
10118 /// \brief Note that we are checking the satisfaction of the constraint
10119 /// expression inside of a nested requirement.
10120 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10122 SourceRange InstantiationRange = SourceRange());
10123
10124 /// \brief Note that we are checking a requires clause.
10125 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10126 const RequiresExpr *E,
10127 sema::TemplateDeductionInfo &DeductionInfo,
10128 SourceRange InstantiationRange);
10129
10131 /// \brief Note that we are building deduction guides.
10132 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
10134 SourceRange InstantiationRange = SourceRange());
10135
10136 /// Note that we have finished instantiating this template.
10137 void Clear();
10138
10140
10141 /// Determines whether we have exceeded the maximum
10142 /// recursive template instantiations.
10143 bool isInvalid() const { return Invalid; }
10144
10145 /// Determine whether we are already instantiating this
10146 /// specialization in some surrounding active instantiation.
10147 bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
10148
10149 private:
10150 Sema &SemaRef;
10151 bool Invalid;
10152 bool AlreadyInstantiating;
10153 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
10154 SourceRange InstantiationRange);
10155
10158 SourceLocation PointOfInstantiation, SourceRange InstantiationRange,
10159 Decl *Entity, NamedDecl *Template = nullptr,
10160 ArrayRef<TemplateArgument> TemplateArgs = std::nullopt,
10161 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
10162
10164
10165 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
10166 };
10167
10169 const MultiLevelTemplateArgumentList &TemplateArgs,
10170 TemplateArgumentLoc &Output);
10171 bool
10173 const MultiLevelTemplateArgumentList &TemplateArgs,
10174 TemplateArgumentListInfo &Outputs);
10175
10177 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
10178 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
10179 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
10180 bool ForConstraintInstantiation = false,
10181 bool SkipForSpecialization = false);
10182
10183 /// RAII object to handle the state changes required to synthesize
10184 /// a function body.
10186 Sema &S;
10187 Sema::ContextRAII SavedContext;
10188 bool PushedCodeSynthesisContext = false;
10189
10190 public:
10192 : S(S), SavedContext(S, DC) {
10193 auto *FD = dyn_cast<FunctionDecl>(DC);
10194 S.PushFunctionScope();
10195 S.PushExpressionEvaluationContext(
10196 (FD && FD->isConsteval())
10197 ? ExpressionEvaluationContext::ImmediateFunctionContext
10198 : ExpressionEvaluationContext::PotentiallyEvaluated);
10199 if (FD) {
10200 FD->setWillHaveBody(true);
10201 S.ExprEvalContexts.back().InImmediateFunctionContext =
10202 FD->isImmediateFunction() ||
10203 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
10204 .isConstantEvaluated();
10205 S.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
10206 S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating();
10207 } else
10208 assert(isa<ObjCMethodDecl>(DC));
10209 }
10210
10212 assert(!PushedCodeSynthesisContext);
10213
10215 Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
10216 Ctx.PointOfInstantiation = UseLoc;
10217 Ctx.Entity = cast<Decl>(S.CurContext);
10218 S.pushCodeSynthesisContext(Ctx);
10219
10220 PushedCodeSynthesisContext = true;
10221 }
10222
10224 if (PushedCodeSynthesisContext)
10225 S.popCodeSynthesisContext();
10226 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
10227 FD->setWillHaveBody(false);
10228 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
10229 }
10230 S.PopExpressionEvaluationContext();
10231 S.PopFunctionScopeInfo();
10232 }
10233 };
10234
10235 /// List of active code synthesis contexts.
10236 ///
10237 /// This vector is treated as a stack. As synthesis of one entity requires
10238 /// synthesis of another, additional contexts are pushed onto the stack.
10240
10241 /// Specializations whose definitions are currently being instantiated.
10243
10244 /// Non-dependent types used in templates that have already been instantiated
10245 /// by some template instantiation.
10247
10248 /// Extra modules inspected when performing a lookup during a template
10249 /// instantiation. Computed lazily.
10251
10252 /// Cache of additional modules that should be used for name lookup
10253 /// within the current template instantiation. Computed lazily; use
10254 /// getLookupModules() to get a complete set.
10256
10257 /// Map from the most recent declaration of a namespace to the most
10258 /// recent visible declaration of that namespace.
10259 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
10260
10261 /// Whether we are in a SFINAE context that is not associated with
10262 /// template instantiation.
10263 ///
10264 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
10265 /// of a template instantiation or template argument deduction.
10267
10268 /// The number of \p CodeSynthesisContexts that are not template
10269 /// instantiations and, therefore, should not be counted as part of the
10270 /// instantiation depth.
10271 ///
10272 /// When the instantiation depth reaches the user-configurable limit
10273 /// \p LangOptions::InstantiationDepth we will abort instantiation.
10274 // FIXME: Should we have a similar limit for other forms of synthesis?
10276
10277 /// The depth of the context stack at the point when the most recent
10278 /// error or warning was produced.
10279 ///
10280 /// This value is used to suppress printing of redundant context stacks
10281 /// when there are multiple errors or warnings in the same instantiation.
10282 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
10284
10285 /// The template instantiation callbacks to trace or track
10286 /// instantiations (objects can be chained).
10287 ///
10288 /// This callbacks is used to print, trace or track template
10289 /// instantiations as they are being constructed.
10290 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
10292
10293 /// The current index into pack expansion arguments that will be
10294 /// used for substitution of parameter packs.
10295 ///
10296 /// The pack expansion index will be -1 to indicate that parameter packs
10297 /// should be instantiated as themselves. Otherwise, the index specifies
10298 /// which argument within the parameter pack will be used for substitution.
10300
10301 /// RAII object used to change the argument pack substitution index
10302 /// within a \c Sema object.
10303 ///
10304 /// See \c ArgumentPackSubstitutionIndex for more information.
10306 Sema &Self;
10307 int OldSubstitutionIndex;
10308
10309 public:
10310 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
10311 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
10312 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
10313 }
10314
10316 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
10317 }
10318 };
10319
10321
10324
10326 if (!CodeSynthesisContexts.empty() &&
10330 }
10333 }
10335
10336 /// Determines whether we are currently in a context where
10337 /// template argument substitution failures are not considered
10338 /// errors.
10339 ///
10340 /// \returns An empty \c Optional if we're not in a SFINAE context.
10341 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
10342 /// template-deduction context object, which can be used to capture
10343 /// diagnostics that will be suppressed.
10344 std::optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
10345
10347 const MultiLevelTemplateArgumentList &TemplateArgs,
10348 SourceLocation Loc, DeclarationName Entity,
10349 bool AllowDeducedTST = false);
10350
10352 const MultiLevelTemplateArgumentList &TemplateArgs,
10353 SourceLocation Loc, DeclarationName Entity);
10354
10356 const MultiLevelTemplateArgumentList &TemplateArgs,
10357 SourceLocation Loc, DeclarationName Entity);
10358
10360 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
10361 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
10362 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
10363 void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
10364 const MultiLevelTemplateArgumentList &Args);
10367 SmallVectorImpl<QualType> &ExceptionStorage,
10368 const MultiLevelTemplateArgumentList &Args);
10369 ParmVarDecl *
10371 const MultiLevelTemplateArgumentList &TemplateArgs,
10372 int indexAdjustment, std::optional<unsigned> NumExpansions,
10373 bool ExpectParameterPack, bool EvaluateConstraints = true);
10375 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
10376 const MultiLevelTemplateArgumentList &TemplateArgs,
10377 SmallVectorImpl<QualType> &ParamTypes,
10379 ExtParameterInfoBuilder &ParamInfos);
10381 const MultiLevelTemplateArgumentList &TemplateArgs,
10382 bool ForCallExpr = false);
10384 const MultiLevelTemplateArgumentList &TemplateArgs);
10385
10386 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
10387 // to disable constraint evaluation, then restore the state.
10388 template <typename InstTy> struct ConstraintEvalRAII {
10389 InstTy &TI;
10391
10393 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
10394 TI.setEvaluateConstraints(false);
10395 }
10396 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
10397 };
10398
10399 // Must be used instead of SubstExpr at 'constraint checking' time.
10402 const MultiLevelTemplateArgumentList &TemplateArgs);
10403 // Unlike the above, this does not evaluates constraints.
10405 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
10406
10407 /// Substitute the given template arguments into a list of
10408 /// expressions, expanding pack expansions if required.
10409 ///
10410 /// \param Exprs The list of expressions to substitute into.
10411 ///
10412 /// \param IsCall Whether this is some form of call, in which case
10413 /// default arguments will be dropped.
10414 ///
10415 /// \param TemplateArgs The set of template arguments to substitute.
10416 ///
10417 /// \param Outputs Will receive all of the substituted arguments.
10418 ///
10419 /// \returns true if an error occurred, false otherwise.
10420 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
10421 const MultiLevelTemplateArgumentList &TemplateArgs,
10422 SmallVectorImpl<Expr *> &Outputs);
10423
10425 const MultiLevelTemplateArgumentList &TemplateArgs);
10426
10429 bool CXXDirectInit);
10430
10431 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
10432 const MultiLevelTemplateArgumentList &TemplateArgs);
10433
10434 bool InstantiateClass(SourceLocation PointOfInstantiation,
10435 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
10436 const MultiLevelTemplateArgumentList &TemplateArgs,
10437 TemplateSpecializationKind TSK, bool Complain = true);
10438
10439 bool InstantiateEnum(SourceLocation PointOfInstantiation,
10440 EnumDecl *Instantiation, EnumDecl *Pattern,
10441 const MultiLevelTemplateArgumentList &TemplateArgs,
10443
10445 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
10446 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
10447
10449 SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
10450
10452 SourceLocation PointOfInstantiation,
10453 ClassTemplateSpecializationDecl *ClassTemplateSpec,
10454 TemplateSpecializationKind TSK, bool Complain = true);
10455
10456 void
10457 InstantiateClassMembers(SourceLocation PointOfInstantiation,
10458 CXXRecordDecl *Instantiation,
10459 const MultiLevelTemplateArgumentList &TemplateArgs,
10461
10463 SourceLocation PointOfInstantiation,
10464 ClassTemplateSpecializationDecl *ClassTemplateSpec,
10466
10469 const MultiLevelTemplateArgumentList &TemplateArgs);
10470
10473 const MultiLevelTemplateArgumentList &TemplateArgs);
10476 SourceLocation Loc,
10477 const MultiLevelTemplateArgumentList &TemplateArgs);
10478
10480 const MultiLevelTemplateArgumentList &TemplateArgs,
10481 bool EvaluateConstraint);
10482
10483 /// Determine whether we are currently performing template instantiation.
10486 }
10487
10488 ///@}
10489
10490 //
10491 //
10492 // -------------------------------------------------------------------------
10493 //
10494 //
10495
10496 /// \name C++ Template Declaration Instantiation
10497 /// Implementations are in SemaTemplateInstantiateDecl.cpp
10498 ///@{
10499
10500public:
10501 /// An entity for which implicit template instantiation is required.
10502 ///
10503 /// The source location associated with the declaration is the first place in
10504 /// the source code where the declaration was "used". It is not necessarily
10505 /// the point of instantiation (which will be either before or after the
10506 /// namespace-scope declaration that triggered this implicit instantiation),
10507 /// However, it is the location that diagnostics should generally refer to,
10508 /// because users will need to know what code triggered the instantiation.
10509 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
10510
10511 /// The queue of implicit template instantiations that are required
10512 /// but have not yet been performed.
10513 std::deque<PendingImplicitInstantiation> PendingInstantiations;
10514
10515 /// Queue of implicit template instantiations that cannot be performed
10516 /// eagerly.
10518
10522
10523 /// The queue of implicit template instantiations that are required
10524 /// and must be performed within the current local scope.
10525 ///
10526 /// This queue is only used for member functions of local classes in
10527 /// templates, which must be instantiated in the same scope as their
10528 /// enclosing function, so that they can reference function-local
10529 /// types, static variables, enumerators, etc.
10530 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
10531
10533 public:
10535 SavedPendingLocalImplicitInstantiations.swap(
10536 S.PendingLocalImplicitInstantiations);
10537 }
10538
10539 void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
10540
10542 assert(S.PendingLocalImplicitInstantiations.empty() &&
10543 "there shouldn't be any pending local implicit instantiations");
10544 SavedPendingLocalImplicitInstantiations.swap(
10545 S.PendingLocalImplicitInstantiations);
10546 }
10547
10548 private:
10549 Sema &S;
10550 std::deque<PendingImplicitInstantiation>
10551 SavedPendingLocalImplicitInstantiations;
10552 };
10553
10554 /// Records and restores the CurFPFeatures state on entry/exit of compound
10555 /// statements.
10557 public:
10560 FPOptionsOverride getOverrides() { return OldOverrides; }
10561
10562 private:
10563 Sema &S;
10564 FPOptions OldFPFeaturesState;
10565 FPOptionsOverride OldOverrides;
10566 LangOptions::FPEvalMethodKind OldEvalMethod;
10567 SourceLocation OldFPPragmaLocation;
10568 };
10569
10571 public:
10573 : S(S), Enabled(Enabled) {
10574 if (!Enabled)
10575 return;
10576
10577 S.SavedPendingInstantiations.emplace_back();
10578 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
10579
10580 S.SavedVTableUses.emplace_back();
10581 S.SavedVTableUses.back().swap(S.VTableUses);
10582 }
10583
10584 void perform() {
10585 if (Enabled) {
10586 S.DefineUsedVTables();
10587 S.PerformPendingInstantiations();
10588 }
10589 }
10590
10592 if (!Enabled)
10593 return;
10594
10595 // Restore the set of pending vtables.
10596 assert(S.VTableUses.empty() &&
10597 "VTableUses should be empty before it is discarded.");
10598 S.VTableUses.swap(S.SavedVTableUses.back());
10599 S.SavedVTableUses.pop_back();
10600
10601 // Restore the set of pending implicit instantiations.
10602 if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
10603 assert(S.PendingInstantiations.empty() &&
10604 "PendingInstantiations should be empty before it is discarded.");
10605 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
10606 S.SavedPendingInstantiations.pop_back();
10607 } else {
10608 // Template instantiations in the PCH may be delayed until the TU.
10609 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
10610 S.PendingInstantiations.insert(
10611 S.PendingInstantiations.end(),
10612 S.SavedPendingInstantiations.back().begin(),
10613 S.SavedPendingInstantiations.back().end());
10614 S.SavedPendingInstantiations.pop_back();
10615 }
10616 }
10617
10618 private:
10619 Sema &S;
10620 bool Enabled;
10621 };
10622
10624 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
10625
10630
10632 Decl *D)
10633 : TmplAttr(A), Scope(S), NewDecl(D) {}
10634 };
10636
10637 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
10638 const Decl *Pattern, Decl *Inst,
10639 LateInstantiatedAttrVec *LateAttrs = nullptr,
10640 LocalInstantiationScope *OuterMostScope = nullptr);
10641 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
10642
10643 void
10645 const Decl *Pattern, Decl *Inst,
10646 LateInstantiatedAttrVec *LateAttrs = nullptr,
10647 LocalInstantiationScope *OuterMostScope = nullptr);
10648
10650
10652 ParmVarDecl *Param);
10653 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
10657 SourceLocation Loc,
10660 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
10662 bool Recursive = false,
10663 bool DefinitionRequired = false,
10664 bool AtEndOfTU = false);
10667 const TemplateArgumentList *PartialSpecArgs,
10668 const TemplateArgumentListInfo &TemplateArgsInfo,
10670 SourceLocation PointOfInstantiation,
10671 LateInstantiatedAttrVec *LateAttrs = nullptr,
10672 LocalInstantiationScope *StartingScope = nullptr);
10674 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
10675 const MultiLevelTemplateArgumentList &TemplateArgs);
10676 void
10678 const MultiLevelTemplateArgumentList &TemplateArgs,
10679 LateInstantiatedAttrVec *LateAttrs,
10680 DeclContext *Owner,
10681 LocalInstantiationScope *StartingScope,
10682 bool InstantiatingVarTemplate = false,
10683 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
10684
10686 VarDecl *Var, VarDecl *OldVar,
10687 const MultiLevelTemplateArgumentList &TemplateArgs);
10688 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
10689 VarDecl *Var, bool Recursive = false,
10690 bool DefinitionRequired = false,
10691 bool AtEndOfTU = false);
10692
10694 CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl,
10695 const MultiLevelTemplateArgumentList &TemplateArgs);
10696
10697 NamedDecl *
10699 const MultiLevelTemplateArgumentList &TemplateArgs,
10700 bool FindingInstantiatedContext = false);
10701 DeclContext *
10703 const MultiLevelTemplateArgumentList &TemplateArgs);
10704
10705 Decl *SubstDecl(Decl *D, DeclContext *Owner,
10706 const MultiLevelTemplateArgumentList &TemplateArgs);
10707
10708 /// Substitute the name and return type of a defaulted 'operator<=>' to form
10709 /// an implicit 'operator=='.
10711 FunctionDecl *Spaceship);
10712
10713 void PerformPendingInstantiations(bool LocalOnly = false);
10714
10717 const MultiLevelTemplateArgumentList &TemplateArgs,
10718 bool EvaluateConstraints = true);
10719
10721 const DeclContext *Pattern,
10722 const MultiLevelTemplateArgumentList &TemplateArgs);
10723
10724private:
10725 /// Introduce the instantiated local variables into the local
10726 /// instantiation scope.
10727 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
10728 const FunctionDecl *PatternDecl,
10730 /// Introduce the instantiated function parameters into the local
10731 /// instantiation scope, and set the parameter names to those used
10732 /// in the template.
10733 bool addInstantiatedParametersToScope(
10734 FunctionDecl *Function, const FunctionDecl *PatternDecl,
10736 const MultiLevelTemplateArgumentList &TemplateArgs);
10737
10738 int ParsingClassDepth = 0;
10739
10740 class SavePendingParsedClassStateRAII {
10741 public:
10742 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
10743
10744 ~SavePendingParsedClassStateRAII() {
10745 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
10746 "there shouldn't be any pending delayed exception spec checks");
10747 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
10748 "there shouldn't be any pending delayed exception spec checks");
10749 swapSavedState();
10750 }
10751
10752 private:
10753 Sema &S;
10754 decltype(DelayedOverridingExceptionSpecChecks)
10755 SavedOverridingExceptionSpecChecks;
10756 decltype(DelayedEquivalentExceptionSpecChecks)
10757 SavedEquivalentExceptionSpecChecks;
10758
10759 void swapSavedState() {
10760 SavedOverridingExceptionSpecChecks.swap(
10761 S.DelayedOverridingExceptionSpecChecks);
10762 SavedEquivalentExceptionSpecChecks.swap(
10763 S.DelayedEquivalentExceptionSpecChecks);
10764 }
10765 };
10766
10767 ///@}
10768
10769 //
10770 //
10771 // -------------------------------------------------------------------------
10772 //
10773 //
10774
10775 /// \name C++ Variadic Templates
10776 /// Implementations are in SemaTemplateVariadic.cpp
10777 ///@{
10778
10779public:
10780 /// Determine whether an unexpanded parameter pack might be permitted in this
10781 /// location. Useful for error recovery.
10783
10784 /// The context in which an unexpanded parameter pack is
10785 /// being diagnosed.
10786 ///
10787 /// Note that the values of this enumeration line up with the first
10788 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
10790 /// An arbitrary expression.
10792
10793 /// The base type of a class type.
10795
10796 /// The type of an arbitrary declaration.
10798
10799 /// The type of a data member.
10801
10802 /// The size of a bit-field.
10804
10805 /// The expression in a static assertion.
10807
10808 /// The fixed underlying type of an enumeration.
10810
10811 /// The enumerator value.
10813
10814 /// A using declaration.
10816
10817 /// A friend declaration.
10819
10820 /// A declaration qualifier.
10822
10823 /// An initializer.
10825
10826 /// A default argument.
10828
10829 /// The type of a non-type template parameter.
10831
10832 /// The type of an exception.
10834
10835 /// Explicit specialization.
10837
10838 /// Partial specialization.
10840
10841 /// Microsoft __if_exists.
10843
10844 /// Microsoft __if_not_exists.
10846
10847 /// Lambda expression.
10849
10850 /// Block expression.
10852
10853 /// A type constraint.
10855
10856 // A requirement in a requires-expression.
10858
10859 // A requires-clause.
10861 };
10862
10863 /// Diagnose unexpanded parameter packs.
10864 ///
10865 /// \param Loc The location at which we should emit the diagnostic.
10866 ///
10867 /// \param UPPC The context in which we are diagnosing unexpanded
10868 /// parameter packs.
10869 ///
10870 /// \param Unexpanded the set of unexpanded parameter packs.
10871 ///
10872 /// \returns true if an error occurred, false otherwise.
10876
10877 /// If the given type contains an unexpanded parameter pack,
10878 /// diagnose the error.
10879 ///
10880 /// \param Loc The source location where a diagnostc should be emitted.
10881 ///
10882 /// \param T The type that is being checked for unexpanded parameter
10883 /// packs.
10884 ///
10885 /// \returns true if an error occurred, false otherwise.
10888
10889 /// If the given expression contains an unexpanded parameter
10890 /// pack, diagnose the error.
10891 ///
10892 /// \param E The expression that is being checked for unexpanded
10893 /// parameter packs.
10894 ///
10895 /// \returns true if an error occurred, false otherwise.
10898
10899 /// If the given requirees-expression contains an unexpanded reference to one
10900 /// of its own parameter packs, diagnose the error.
10901 ///
10902 /// \param RE The requiress-expression that is being checked for unexpanded
10903 /// parameter packs.
10904 ///
10905 /// \returns true if an error occurred, false otherwise.
10907
10908 /// If the given nested-name-specifier contains an unexpanded
10909 /// parameter pack, diagnose the error.
10910 ///
10911 /// \param SS The nested-name-specifier that is being checked for
10912 /// unexpanded parameter packs.
10913 ///
10914 /// \returns true if an error occurred, false otherwise.
10917
10918 /// If the given name contains an unexpanded parameter pack,
10919 /// diagnose the error.
10920 ///
10921 /// \param NameInfo The name (with source location information) that
10922 /// is being checked for unexpanded parameter packs.
10923 ///
10924 /// \returns true if an error occurred, false otherwise.
10927
10928 /// If the given template name contains an unexpanded parameter pack,
10929 /// diagnose the error.
10930 ///
10931 /// \param Loc The location of the template name.
10932 ///
10933 /// \param Template The template name that is being checked for unexpanded
10934 /// parameter packs.
10935 ///
10936 /// \returns true if an error occurred, false otherwise.
10938 TemplateName Template,
10940
10941 /// If the given template argument contains an unexpanded parameter
10942 /// pack, diagnose the error.
10943 ///
10944 /// \param Arg The template argument that is being checked for unexpanded
10945 /// parameter packs.
10946 ///
10947 /// \returns true if an error occurred, false otherwise.
10950
10951 /// Collect the set of unexpanded parameter packs within the given
10952 /// template argument.
10953 ///
10954 /// \param Arg The template argument that will be traversed to find
10955 /// unexpanded parameter packs.
10957 TemplateArgument Arg,
10959
10960 /// Collect the set of unexpanded parameter packs within the given
10961 /// template argument.
10962 ///
10963 /// \param Arg The template argument that will be traversed to find
10964 /// unexpanded parameter packs.
10968
10969 /// Collect the set of unexpanded parameter packs within the given
10970 /// type.
10971 ///
10972 /// \param T The type that will be traversed to find
10973 /// unexpanded parameter packs.
10976
10977 /// Collect the set of unexpanded parameter packs within the given
10978 /// type.
10979 ///
10980 /// \param TL The type that will be traversed to find
10981 /// unexpanded parameter packs.
10984
10985 /// Collect the set of unexpanded parameter packs within the given
10986 /// nested-name-specifier.
10987 ///
10988 /// \param NNS The nested-name-specifier that will be traversed to find
10989 /// unexpanded parameter packs.
10993
10994 /// Collect the set of unexpanded parameter packs within the given
10995 /// name.
10996 ///
10997 /// \param NameInfo The name that will be traversed to find
10998 /// unexpanded parameter packs.
11000 const DeclarationNameInfo &NameInfo,
11002
11003 /// Invoked when parsing a template argument followed by an
11004 /// ellipsis, which creates a pack expansion.
11005 ///
11006 /// \param Arg The template argument preceding the ellipsis, which
11007 /// may already be invalid.
11008 ///
11009 /// \param EllipsisLoc The location of the ellipsis.
11011 SourceLocation EllipsisLoc);
11012
11013 /// Invoked when parsing a type followed by an ellipsis, which
11014 /// creates a pack expansion.
11015 ///
11016 /// \param Type The type preceding the ellipsis, which will become
11017 /// the pattern of the pack expansion.
11018 ///
11019 /// \param EllipsisLoc The location of the ellipsis.
11021
11022 /// Construct a pack expansion type from the pattern of the pack
11023 /// expansion.
11025 SourceLocation EllipsisLoc,
11026 std::optional<unsigned> NumExpansions);
11027
11028 /// Construct a pack expansion type from the pattern of the pack
11029 /// expansion.
11030 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
11031 SourceLocation EllipsisLoc,
11032 std::optional<unsigned> NumExpansions);
11033
11034 /// Invoked when parsing an expression followed by an ellipsis, which
11035 /// creates a pack expansion.
11036 ///
11037 /// \param Pattern The expression preceding the ellipsis, which will become
11038 /// the pattern of the pack expansion.
11039 ///
11040 /// \param EllipsisLoc The location of the ellipsis.
11041 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
11042
11043 /// Invoked when parsing an expression followed by an ellipsis, which
11044 /// creates a pack expansion.
11045 ///
11046 /// \param Pattern The expression preceding the ellipsis, which will become
11047 /// the pattern of the pack expansion.
11048 ///
11049 /// \param EllipsisLoc The location of the ellipsis.
11050 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
11051 std::optional<unsigned> NumExpansions);
11052
11053 /// Determine whether we could expand a pack expansion with the
11054 /// given set of parameter packs into separate arguments by repeatedly
11055 /// transforming the pattern.
11056 ///
11057 /// \param EllipsisLoc The location of the ellipsis that identifies the
11058 /// pack expansion.
11059 ///
11060 /// \param PatternRange The source range that covers the entire pattern of
11061 /// the pack expansion.
11062 ///
11063 /// \param Unexpanded The set of unexpanded parameter packs within the
11064 /// pattern.
11065 ///
11066 /// \param ShouldExpand Will be set to \c true if the transformer should
11067 /// expand the corresponding pack expansions into separate arguments. When
11068 /// set, \c NumExpansions must also be set.
11069 ///
11070 /// \param RetainExpansion Whether the caller should add an unexpanded
11071 /// pack expansion after all of the expanded arguments. This is used
11072 /// when extending explicitly-specified template argument packs per
11073 /// C++0x [temp.arg.explicit]p9.
11074 ///
11075 /// \param NumExpansions The number of separate arguments that will be in
11076 /// the expanded form of the corresponding pack expansion. This is both an
11077 /// input and an output parameter, which can be set by the caller if the
11078 /// number of expansions is known a priori (e.g., due to a prior substitution)
11079 /// and will be set by the callee when the number of expansions is known.
11080 /// The callee must set this value when \c ShouldExpand is \c true; it may
11081 /// set this value in other cases.
11082 ///
11083 /// \returns true if an error occurred (e.g., because the parameter packs
11084 /// are to be instantiated with arguments of different lengths), false
11085 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
11086 /// must be set.
11088 SourceLocation EllipsisLoc, SourceRange PatternRange,
11090 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
11091 bool &RetainExpansion, std::optional<unsigned> &NumExpansions);
11092
11093 /// Determine the number of arguments in the given pack expansion
11094 /// type.
11095 ///
11096 /// This routine assumes that the number of arguments in the expansion is
11097 /// consistent across all of the unexpanded parameter packs in its pattern.
11098 ///
11099 /// Returns an empty Optional if the type can't be expanded.
11100 std::optional<unsigned> getNumArgumentsInExpansion(
11101 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
11102
11103 /// Determine whether the given declarator contains any unexpanded
11104 /// parameter packs.
11105 ///
11106 /// This routine is used by the parser to disambiguate function declarators
11107 /// with an ellipsis prior to the ')', e.g.,
11108 ///
11109 /// \code
11110 /// void f(T...);
11111 /// \endcode
11112 ///
11113 /// To determine whether we have an (unnamed) function parameter pack or
11114 /// a variadic function.
11115 ///
11116 /// \returns true if the declarator contains any unexpanded parameter packs,
11117 /// false otherwise.
11119
11120 /// Returns the pattern of the pack expansion for a template argument.
11121 ///
11122 /// \param OrigLoc The template argument to expand.
11123 ///
11124 /// \param Ellipsis Will be set to the location of the ellipsis.
11125 ///
11126 /// \param NumExpansions Will be set to the number of expansions that will
11127 /// be generated from this pack expansion, if known a priori.
11129 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
11130 std::optional<unsigned> &NumExpansions) const;
11131
11132 /// Given a template argument that contains an unexpanded parameter pack, but
11133 /// which has already been substituted, attempt to determine the number of
11134 /// elements that will be produced once this argument is fully-expanded.
11135 ///
11136 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
11137 /// avoid actually expanding the pack where possible.
11138 std::optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
11139
11141 IdentifierInfo &Name,
11142 SourceLocation NameLoc,
11143 SourceLocation RParenLoc);
11144
11145 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
11146 SourceLocation EllipsisLoc,
11147 SourceLocation LSquareLoc, Expr *IndexExpr,
11148 SourceLocation RSquareLoc);
11149
11150 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
11151 SourceLocation EllipsisLoc, Expr *IndexExpr,
11152 SourceLocation RSquareLoc,
11153 ArrayRef<Expr *> ExpandedExprs = {},
11154 bool EmptyPack = false);
11155
11156 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
11157 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
11158 tok::TokenKind Operator,
11159 SourceLocation EllipsisLoc, Expr *RHS,
11160 SourceLocation RParenLoc);
11161 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
11162 SourceLocation LParenLoc, Expr *LHS,
11163 BinaryOperatorKind Operator,
11164 SourceLocation EllipsisLoc, Expr *RHS,
11165 SourceLocation RParenLoc,
11166 std::optional<unsigned> NumExpansions);
11167 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
11168 BinaryOperatorKind Operator);
11169
11170 ///@}
11171
11172 //
11173 //
11174 // -------------------------------------------------------------------------
11175 //
11176 //
11177
11178 /// \name Constraints and Concepts
11179 /// Implementations are in SemaConcept.cpp
11180 ///@{
11181
11182public:
11184 const llvm::FoldingSetNodeID &ID) {
11185 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
11186 SatisfactionStack.emplace_back(Can, ID);
11187 }
11188
11189 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
11190
11192 const llvm::FoldingSetNodeID &ID) const {
11193 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
11194 return llvm::find(SatisfactionStack, SatisfactionStackEntryTy{Can, ID}) !=
11195 SatisfactionStack.end();
11196 }
11197
11199 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
11200
11201 // Resets the current SatisfactionStack for cases where we are instantiating
11202 // constraints as a 'side effect' of normal instantiation in a way that is not
11203 // indicative of recursive definition.
11206 Sema &SemaRef;
11207
11208 public:
11210 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
11211 }
11212
11214 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
11215 }
11216 };
11217
11220 SatisfactionStack.swap(NewSS);
11221 }
11222
11223 /// Check whether the given expression is a valid constraint expression.
11224 /// A diagnostic is emitted if it is not, false is returned, and
11225 /// PossibleNonPrimary will be set to true if the failure might be due to a
11226 /// non-primary expression being used as an atomic constraint.
11227 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
11228 bool *PossibleNonPrimary = nullptr,
11229 bool IsTrailingRequiresClause = false);
11230
11231 /// \brief Check whether the given list of constraint expressions are
11232 /// satisfied (as if in a 'conjunction') given template arguments.
11233 /// \param Template the template-like entity that triggered the constraints
11234 /// check (either a concept or a constrained entity).
11235 /// \param ConstraintExprs a list of constraint expressions, treated as if
11236 /// they were 'AND'ed together.
11237 /// \param TemplateArgLists the list of template arguments to substitute into
11238 /// the constraint expression.
11239 /// \param TemplateIDRange The source range of the template id that
11240 /// caused the constraints check.
11241 /// \param Satisfaction if true is returned, will contain details of the
11242 /// satisfaction, with enough information to diagnose an unsatisfied
11243 /// expression.
11244 /// \returns true if an error occurred and satisfaction could not be checked,
11245 /// false otherwise.
11247 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
11248 const MultiLevelTemplateArgumentList &TemplateArgLists,
11249 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
11251 return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted,
11252 TemplateArgLists, TemplateIDRange,
11253 Satisfaction);
11254 }
11255
11256 /// \brief Check whether the given list of constraint expressions are
11257 /// satisfied (as if in a 'conjunction') given template arguments.
11258 /// Additionally, takes an empty list of Expressions which is populated with
11259 /// the instantiated versions of the ConstraintExprs.
11260 /// \param Template the template-like entity that triggered the constraints
11261 /// check (either a concept or a constrained entity).
11262 /// \param ConstraintExprs a list of constraint expressions, treated as if
11263 /// they were 'AND'ed together.
11264 /// \param ConvertedConstraints a out parameter that will get populated with
11265 /// the instantiated version of the ConstraintExprs if we successfully checked
11266 /// satisfaction.
11267 /// \param TemplateArgList the multi-level list of template arguments to
11268 /// substitute into the constraint expression. This should be relative to the
11269 /// top-level (hence multi-level), since we need to instantiate fully at the
11270 /// time of checking.
11271 /// \param TemplateIDRange The source range of the template id that
11272 /// caused the constraints check.
11273 /// \param Satisfaction if true is returned, will contain details of the
11274 /// satisfaction, with enough information to diagnose an unsatisfied
11275 /// expression.
11276 /// \returns true if an error occurred and satisfaction could not be checked,
11277 /// false otherwise.
11279 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
11280 llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
11281 const MultiLevelTemplateArgumentList &TemplateArgList,
11282 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
11283
11284 /// \brief Check whether the given non-dependent constraint expression is
11285 /// satisfied. Returns false and updates Satisfaction with the satisfaction
11286 /// verdict if successful, emits a diagnostic and returns true if an error
11287 /// occurred and satisfaction could not be determined.
11288 ///
11289 /// \returns true if an error occurred, false otherwise.
11290 bool CheckConstraintSatisfaction(const Expr *ConstraintExpr,
11291 ConstraintSatisfaction &Satisfaction);
11292
11293 /// Check whether the given function decl's trailing requires clause is
11294 /// satisfied, if any. Returns false and updates Satisfaction with the
11295 /// satisfaction verdict if successful, emits a diagnostic and returns true if
11296 /// an error occurred and satisfaction could not be determined.
11297 ///
11298 /// \returns true if an error occurred, false otherwise.
11300 ConstraintSatisfaction &Satisfaction,
11301 SourceLocation UsageLoc = SourceLocation(),
11302 bool ForOverloadResolution = false);
11303
11304 // Calculates whether two constraint expressions are equal irrespective of a
11305 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
11306 // 'New', which are the "source" of the constraint, since this is necessary
11307 // for figuring out the relative 'depth' of the constraint. The depth of the
11308 // 'primary template' and the 'instantiated from' templates aren't necessarily
11309 // the same, such as a case when one is a 'friend' defined in a class.
11311 const Expr *OldConstr,
11312 const TemplateCompareNewDeclInfo &New,
11313 const Expr *NewConstr);
11314
11315 // Calculates whether the friend function depends on an enclosing template for
11316 // the purposes of [temp.friend] p9.
11318
11319 /// \brief Ensure that the given template arguments satisfy the constraints
11320 /// associated with the given template, emitting a diagnostic if they do not.
11321 ///
11322 /// \param Template The template to which the template arguments are being
11323 /// provided.
11324 ///
11325 /// \param TemplateArgs The converted, canonicalized template arguments.
11326 ///
11327 /// \param TemplateIDRange The source range of the template id that
11328 /// caused the constraints check.
11329 ///
11330 /// \returns true if the constrains are not satisfied or could not be checked
11331 /// for satisfaction, false if the constraints are satisfied.
11333 TemplateDecl *Template,
11334 const MultiLevelTemplateArgumentList &TemplateArgs,
11335 SourceRange TemplateIDRange);
11336
11338 SourceLocation PointOfInstantiation, FunctionDecl *Decl,
11339 ArrayRef<TemplateArgument> TemplateArgs,
11340 ConstraintSatisfaction &Satisfaction);
11341
11342 /// \brief Emit diagnostics explaining why a constraint expression was deemed
11343 /// unsatisfied.
11344 /// \param First whether this is the first time an unsatisfied constraint is
11345 /// diagnosed for this error.
11347 bool First = true);
11348
11349 /// \brief Emit diagnostics explaining why a constraint expression was deemed
11350 /// unsatisfied.
11351 void
11353 bool First = true);
11354
11356 NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints);
11357
11358 /// \brief Check whether the given declaration's associated constraints are
11359 /// at least as constrained than another declaration's according to the
11360 /// partial ordering of constraints.
11361 ///
11362 /// \param Result If no error occurred, receives the result of true if D1 is
11363 /// at least constrained than D2, and false otherwise.
11364 ///
11365 /// \returns true if an error occurred, false otherwise.
11368 bool &Result);
11369
11370 /// If D1 was not at least as constrained as D2, but would've been if a pair
11371 /// of atomic constraints involved had been declared in a concept and not
11372 /// repeated in two separate places in code.
11373 /// \returns true if such a diagnostic was emitted, false otherwise.
11377
11378private:
11379 /// Caches pairs of template-like decls whose associated constraints were
11380 /// checked for subsumption and whether or not the first's constraints did in
11381 /// fact subsume the second's.
11382 llvm::DenseMap<std::pair<NamedDecl *, NamedDecl *>, bool> SubsumptionCache;
11383 /// Caches the normalized associated constraints of declarations (concepts or
11384 /// constrained declarations). If an error occurred while normalizing the
11385 /// associated constraints of the template or concept, nullptr will be cached
11386 /// here.
11387 llvm::DenseMap<NamedDecl *, NormalizedConstraint *> NormalizationCache;
11388
11389 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
11390 SatisfactionCache;
11391
11392 // The current stack of constraint satisfactions, so we can exit-early.
11394
11395 /// Introduce the instantiated captures of the lambda into the local
11396 /// instantiation scope.
11397 bool addInstantiatedCapturesToScope(
11398 FunctionDecl *Function, const FunctionDecl *PatternDecl,
11400 const MultiLevelTemplateArgumentList &TemplateArgs);
11401
11402 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in
11403 /// the case of lambdas) set up the LocalInstantiationScope of the current
11404 /// function.
11405 bool
11406 SetupConstraintScope(FunctionDecl *FD,
11407 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
11408 const MultiLevelTemplateArgumentList &MLTAL,
11410
11411 /// Used during constraint checking, sets up the constraint template argument
11412 /// lists, and calls SetupConstraintScope to set up the
11413 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
11414 std::optional<MultiLevelTemplateArgumentList>
11415 SetupConstraintCheckingTemplateArgumentsAndScope(
11416 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
11418
11419 ///@}
11420
11421 //
11422 //
11423 // -------------------------------------------------------------------------
11424 //
11425 //
11426
11427 /// \name Types
11428 /// Implementations are in SemaType.cpp
11429 ///@{
11430
11431public:
11432 /// A mapping that describes the nullability we've seen in each header file.
11434
11435 static int getPrintable(int I) { return I; }
11436 static unsigned getPrintable(unsigned I) { return I; }
11437 static bool getPrintable(bool B) { return B; }
11438 static const char *getPrintable(const char *S) { return S; }
11439 static StringRef getPrintable(StringRef S) { return S; }
11440 static const std::string &getPrintable(const std::string &S) { return S; }
11441 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
11442 return II;
11443 }
11445 static QualType getPrintable(QualType T) { return T; }
11446 static SourceRange getPrintable(SourceRange R) { return R; }
11448 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
11450
11451 enum class CompleteTypeKind {
11452 /// Apply the normal rules for complete types. In particular,
11453 /// treat all sizeless types as incomplete.
11454 Normal,
11455
11456 /// Relax the normal rules for complete types so that they include
11457 /// sizeless built-in types.
11459
11460 // FIXME: Eventually we should flip the default to Normal and opt in
11461 // to AcceptSizeless rather than opt out of it.
11463 };
11464
11465 /// Build a an Objective-C protocol-qualified 'id' type where no
11466 /// base type was specified.
11468 SourceLocation lAngleLoc, ArrayRef<Decl *> protocols,
11469 ArrayRef<SourceLocation> protocolLocs, SourceLocation rAngleLoc);
11470
11471 /// Build a specialized and/or protocol-qualified Objective-C type.
11473 Scope *S, SourceLocation Loc, ParsedType BaseType,
11474 SourceLocation TypeArgsLAngleLoc, ArrayRef<ParsedType> TypeArgs,
11475 SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc,
11476 ArrayRef<Decl *> Protocols, ArrayRef<SourceLocation> ProtocolLocs,
11477 SourceLocation ProtocolRAngleLoc);
11478
11479 /// Build an Objective-C type parameter type.
11481 SourceLocation ProtocolLAngleLoc,
11483 ArrayRef<SourceLocation> ProtocolLocs,
11484 SourceLocation ProtocolRAngleLoc,
11485 bool FailOnError = false);
11486
11487 /// Build an Objective-C object pointer type.
11489 QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc,
11490 ArrayRef<TypeSourceInfo *> TypeArgs, SourceLocation TypeArgsRAngleLoc,
11491 SourceLocation ProtocolLAngleLoc, ArrayRef<ObjCProtocolDecl *> Protocols,
11492 ArrayRef<SourceLocation> ProtocolLocs, SourceLocation ProtocolRAngleLoc,
11493 bool FailOnError, bool Rebuilding);
11494
11496 const DeclSpec *DS = nullptr);
11498 const DeclSpec *DS = nullptr);
11500 DeclarationName Entity);
11502 DeclarationName Entity);
11504 unsigned Quals, SourceRange Brackets,
11505 DeclarationName Entity);
11508 SourceLocation AttrLoc);
11509 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
11510 SourceLocation AttrLoc);
11511
11512 QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr);
11513
11514 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
11515 SourceLocation AttrLoc);
11516
11517 /// Same as above, but constructs the AddressSpace index if not provided.
11519 SourceLocation AttrLoc);
11520
11522
11524
11525 /// Build a function type.
11526 ///
11527 /// This routine checks the function type according to C++ rules and
11528 /// under the assumption that the result type and parameter types have
11529 /// just been instantiated from a template. It therefore duplicates
11530 /// some of the behavior of GetTypeForDeclarator, but in a much
11531 /// simpler form that is only suitable for this narrow use case.
11532 ///
11533 /// \param T The return type of the function.
11534 ///
11535 /// \param ParamTypes The parameter types of the function. This array
11536 /// will be modified to account for adjustments to the types of the
11537 /// function parameters.
11538 ///
11539 /// \param Loc The location of the entity whose type involves this
11540 /// function type or, if there is no such entity, the location of the
11541 /// type that will have function type.
11542 ///
11543 /// \param Entity The name of the entity that involves the function
11544 /// type, if known.
11545 ///
11546 /// \param EPI Extra information about the function type. Usually this will
11547 /// be taken from an existing function with the same prototype.
11548 ///
11549 /// \returns A suitable function type, if there are no errors. The
11550 /// unqualified type will always be a FunctionProtoType.
11551 /// Otherwise, returns a NULL type.
11553 SourceLocation Loc, DeclarationName Entity,
11555
11557 SourceLocation Loc, DeclarationName Entity);
11559 DeclarationName Entity);
11564 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
11565
11568
11569 /// Package the given type and TSI into a ParsedType.
11572 TypeSourceInfo **TInfo = nullptr);
11573
11575
11576 /// The parser has parsed the context-sensitive type 'instancetype'
11577 /// in an Objective-C message declaration. Return the appropriate type.
11579
11580 // Check whether the size of array element of type \p EltTy is a multiple of
11581 // its alignment and return false if it isn't.
11583
11584 void
11585 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
11586 SourceLocation FallbackLoc,
11587 SourceLocation ConstQualLoc = SourceLocation(),
11588 SourceLocation VolatileQualLoc = SourceLocation(),
11589 SourceLocation RestrictQualLoc = SourceLocation(),
11590 SourceLocation AtomicQualLoc = SourceLocation(),
11591 SourceLocation UnalignedQualLoc = SourceLocation());
11592
11593 /// Retrieve the keyword associated
11595
11596 /// The struct behind the CFErrorRef pointer.
11598 bool isCFError(RecordDecl *D);
11599
11600 /// Retrieve the identifier "NSError".
11602
11603 /// Adjust the calling convention of a method to be the ABI default if it
11604 /// wasn't specified explicitly. This handles method types formed from
11605 /// function type typedefs and typename template arguments.
11606 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
11607 bool IsCtorOrDtor, SourceLocation Loc);
11608
11609 // Check if there is an explicit attribute, but only look through parens.
11610 // The intent is to look for an attribute on the current declarator, but not
11611 // one that came from a typedef.
11613
11614 /// Check whether a nullability type specifier can be added to the given
11615 /// type through some means not written in source (e.g. API notes).
11616 ///
11617 /// \param Type The type to which the nullability specifier will be
11618 /// added. On success, this type will be updated appropriately.
11619 ///
11620 /// \param Nullability The nullability specifier to add.
11621 ///
11622 /// \param DiagLoc The location to use for diagnostics.
11623 ///
11624 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
11625 /// array type (e.g., because it will decay to a pointer).
11626 ///
11627 /// \param OverrideExisting Whether to override an existing, locally-specified
11628 /// nullability specifier rather than complaining about the conflict.
11629 ///
11630 /// \returns true if nullability cannot be applied, false otherwise.
11632 NullabilityKind Nullability,
11633 SourceLocation DiagLoc,
11634 bool AllowArrayTypes,
11635 bool OverrideExisting);
11636
11637 /// Get the type of expression E, triggering instantiation to complete the
11638 /// type if necessary -- that is, if the expression refers to a templated
11639 /// static data member of incomplete array type.
11640 ///
11641 /// May still return an incomplete type if instantiation was not possible or
11642 /// if the type is incomplete for a different reason. Use
11643 /// RequireCompleteExprType instead if a diagnostic is expected for an
11644 /// incomplete expression type.
11646
11649 TypeDiagnoser &Diagnoser);
11650 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
11651
11652 template <typename... Ts>
11653 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
11654 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
11656 }
11657
11659 const CXXScopeSpec &SS, QualType T,
11660 TagDecl *OwnedTagDecl = nullptr);
11661
11662 // Returns the underlying type of a decltype with the given expression.
11664
11666 /// If AsUnevaluated is false, E is treated as though it were an evaluated
11667 /// context, such as when building a type for decltype(auto).
11668 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
11669
11670 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
11671 SourceLocation Loc,
11672 SourceLocation EllipsisLoc);
11673 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
11674 SourceLocation Loc, SourceLocation EllipsisLoc,
11675 bool FullySubstituted = false,
11676 ArrayRef<QualType> Expansions = {});
11677
11680 SourceLocation Loc);
11686 SourceLocation Loc);
11688 SourceLocation Loc);
11690 SourceLocation Loc);
11692 SourceLocation Loc);
11694 SourceLocation Loc);
11695
11697 TypeDiagnoser &Diagnoser);
11698 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
11699
11700 template <typename... Ts>
11701 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
11702 const Ts &...Args) {
11703 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
11704 return RequireLiteralType(Loc, T, Diagnoser);
11705 }
11706
11709 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
11710 }
11712 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
11714 CompleteTypeKind Kind, unsigned DiagID);
11715
11717 TypeDiagnoser &Diagnoser) {
11718 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, Diagnoser);
11719 }
11720 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID) {
11721 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, DiagID);
11722 }
11723
11724 template <typename... Ts>
11725 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
11726 const Ts &...Args) {
11727 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
11728 return RequireCompleteType(Loc, T, Diagnoser);
11729 }
11730
11731 /// Determine whether a declaration is visible to name lookup.
11732 bool isVisible(const NamedDecl *D) {
11733 return D->isUnconditionallyVisible() ||
11734 isAcceptableSlow(D, AcceptableKind::Visible);
11735 }
11736
11737 /// Determine whether a declaration is reachable.
11738 bool isReachable(const NamedDecl *D) {
11739 // All visible declarations are reachable.
11740 return D->isUnconditionallyVisible() ||
11741 isAcceptableSlow(D, AcceptableKind::Reachable);
11742 }
11743
11744 /// Determine whether a declaration is acceptable (visible/reachable).
11746 return Kind == AcceptableKind::Visible ? isVisible(D) : isReachable(D);
11747 }
11748
11749 /// Determine if \p D and \p Suggested have a structurally compatible
11750 /// layout as described in C11 6.2.7/1.
11751 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
11752
11753 /// Determine if \p D has a visible definition. If not, suggest a declaration
11754 /// that should be made visible to expose the definition.
11755 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
11756 bool OnlyNeedComplete = false);
11758 NamedDecl *Hidden;
11759 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
11760 }
11761
11762 /// Determine if \p D has a reachable definition. If not, suggest a
11763 /// declaration that should be made reachable to expose the definition.
11764 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
11765 bool OnlyNeedComplete = false);
11767 NamedDecl *Hidden;
11768 return hasReachableDefinition(D, &Hidden);
11769 }
11770
11771 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
11772 AcceptableKind Kind,
11773 bool OnlyNeedComplete = false);
11775 NamedDecl *Hidden;
11776 return hasAcceptableDefinition(D, &Hidden, Kind);
11777 }
11778
11779private:
11780 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
11781 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
11782
11783 /// Nullability type specifiers.
11784 IdentifierInfo *Ident__Nonnull = nullptr;
11785 IdentifierInfo *Ident__Nullable = nullptr;
11786 IdentifierInfo *Ident__Nullable_result = nullptr;
11787 IdentifierInfo *Ident__Null_unspecified = nullptr;
11788
11789 IdentifierInfo *Ident_NSError = nullptr;
11790
11791 ///@}
11792
11793 //
11794 //
11795 // -------------------------------------------------------------------------
11796 //
11797 //
11798
11799 /// \name ObjC Declarations
11800 /// Implementations are in SemaDeclObjC.cpp
11801 ///@{
11802
11803public:
11812
11813 /// Method selectors used in a \@selector expression. Used for implementation
11814 /// of -Wselector.
11815 llvm::MapVector<Selector, SourceLocation> ReferencedSelectors;
11816
11818 public:
11819 using Lists = std::pair<ObjCMethodList, ObjCMethodList>;
11820 using iterator = llvm::DenseMap<Selector, Lists>::iterator;
11821 iterator begin() { return Methods.begin(); }
11822 iterator end() { return Methods.end(); }
11823 iterator find(Selector Sel) { return Methods.find(Sel); }
11824 std::pair<iterator, bool> insert(std::pair<Selector, Lists> &&Val) {
11825 return Methods.insert(Val);
11826 }
11827 int count(Selector Sel) const { return Methods.count(Sel); }
11828 bool empty() const { return Methods.empty(); }
11829
11830 private:
11831 llvm::DenseMap<Selector, Lists> Methods;
11832 };
11833
11834 /// Method Pool - allows efficient lookup when typechecking messages to "id".
11835 /// We need to maintain a list, since selectors can have differing signatures
11836 /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
11837 /// of selectors are "overloaded").
11838 /// At the head of the list it is recorded whether there were 0, 1, or >= 2
11839 /// methods inside categories with a particular selector.
11841
11842 /// Check ODR hashes for C/ObjC when merging types from modules.
11843 /// Differently from C++, actually parse the body and reject in case
11844 /// of a mismatch.
11845 template <typename T,
11846 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
11848 if (Duplicate->getODRHash() != Previous->getODRHash())
11849 return false;
11850
11851 // Make the previous decl visible.
11853 return true;
11854 }
11855
11857
11859
11870
11872 SourceLocation varianceLoc, unsigned index,
11873 IdentifierInfo *paramName,
11874 SourceLocation paramLoc,
11875 SourceLocation colonLoc, ParsedType typeBound);
11876
11878 ArrayRef<Decl *> typeParams,
11879 SourceLocation rAngleLoc);
11880 void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList);
11881
11883 Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
11884 SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
11885 IdentifierInfo *SuperName, SourceLocation SuperLoc,
11886 ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange,
11887 Decl *const *ProtoRefs, unsigned NumProtoRefs,
11888 const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
11889 const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody);
11890
11892 Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl,
11893 IdentifierInfo *ClassName, SourceLocation ClassLoc,
11894 IdentifierInfo *SuperName, SourceLocation SuperLoc,
11895 ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange);
11896
11898 SmallVectorImpl<SourceLocation> &ProtocolLocs,
11899 IdentifierInfo *SuperName,
11900 SourceLocation SuperLoc);
11901
11902 Decl *ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc,
11903 IdentifierInfo *AliasName,
11904 SourceLocation AliasLocation,
11905 IdentifierInfo *ClassName,
11906 SourceLocation ClassLocation);
11907
11909 IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc,
11910 const ObjCList<ObjCProtocolDecl> &PList);
11911
11913 SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName,
11914 SourceLocation ProtocolLoc, Decl *const *ProtoRefNames,
11915 unsigned NumProtoRefs, const SourceLocation *ProtoLocs,
11916 SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList,
11917 SkipBodyInfo *SkipBody);
11918
11920 SourceLocation AtInterfaceLoc, const IdentifierInfo *ClassName,
11921 SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
11922 const IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
11923 Decl *const *ProtoRefs, unsigned NumProtoRefs,
11924 const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
11925 const ParsedAttributesView &AttrList);
11926
11928 SourceLocation AtClassImplLoc, const IdentifierInfo *ClassName,
11929 SourceLocation ClassLoc, const IdentifierInfo *SuperClassname,
11930 SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList);
11931
11933 SourceLocation AtCatImplLoc, const IdentifierInfo *ClassName,
11934 SourceLocation ClassLoc, const IdentifierInfo *CatName,
11935 SourceLocation CatLoc, const ParsedAttributesView &AttrList);
11936
11938 ArrayRef<Decl *> Decls);
11939
11943 const ParsedAttributesView &attrList);
11944
11945 void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer,
11946 ArrayRef<IdentifierLocPair> ProtocolId,
11947 SmallVectorImpl<Decl *> &Protocols);
11948
11950 SourceLocation ProtocolLoc,
11951 IdentifierInfo *TypeArgId,
11952 SourceLocation TypeArgLoc,
11953 bool SelectProtocolFirst = false);
11954
11955 /// Given a list of identifiers (and their locations), resolve the
11956 /// names to either Objective-C protocol qualifiers or type
11957 /// arguments, as appropriate.
11959 Scope *S, ParsedType baseType, SourceLocation lAngleLoc,
11960 ArrayRef<IdentifierInfo *> identifiers,
11961 ArrayRef<SourceLocation> identifierLocs, SourceLocation rAngleLoc,
11962 SourceLocation &typeArgsLAngleLoc, SmallVectorImpl<ParsedType> &typeArgs,
11963 SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc,
11964 SmallVectorImpl<Decl *> &protocols, SourceLocation &protocolRAngleLoc,
11965 bool warnOnIncompleteProtocols);
11966
11969
11970 Decl *ActOnAtEnd(Scope *S, SourceRange AtEnd,
11971 ArrayRef<Decl *> allMethods = std::nullopt,
11972 ArrayRef<DeclGroupPtrTy> allTUVars = std::nullopt);
11973
11977 // The Type is null if no type was specified, and the DeclSpec is invalid
11978 // in this case.
11981
11982 /// ArgAttrs - Attribute list for this argument.
11984 };
11985
11987 Scope *S,
11988 SourceLocation BeginLoc, // location of the + or -.
11989 SourceLocation EndLoc, // location of the ; or {.
11990 tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
11991 ArrayRef<SourceLocation> SelectorLocs, Selector Sel,
11992 // optional arguments. The number of types/arguments is obtained
11993 // from the Sel.getNumArgs().
11994 ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo,
11995 unsigned CNumArgs, // c-style args
11996 const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind,
11997 bool isVariadic, bool MethodDefinition);
11998
11999 bool CheckARCMethodDecl(ObjCMethodDecl *method);
12000
12001 bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall);
12002
12003 /// Check whether the given new method is a valid override of the
12004 /// given overridden method, and set any properties that should be inherited.
12006 const ObjCMethodDecl *Overridden);
12007
12008 /// Describes the compatibility of a result type with its method.
12014
12016 ObjCMethodDecl *overridden);
12017
12019 ObjCInterfaceDecl *CurrentClass,
12021
12022 /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
12023 /// pool.
12025
12027 bool isObjCMethodDecl(Decl *D) { return D && isa<ObjCMethodDecl>(D); }
12028
12029 /// CheckImplementationIvars - This routine checks if the instance variables
12030 /// listed in the implelementation match those listed in the interface.
12032 ObjCIvarDecl **Fields, unsigned nIvars,
12033 SourceLocation Loc);
12034
12036 ObjCMethodDecl *MethodDecl,
12037 bool IsProtocolMethodDecl);
12038
12040 ObjCMethodDecl *Overridden,
12041 bool IsProtocolMethodDecl);
12042
12043 /// WarnExactTypedMethods - This routine issues a warning if method
12044 /// implementation declaration matches exactly that of its declaration.
12045 void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl,
12046 bool IsProtocolMethodDecl);
12047
12048 /// MatchAllMethodDeclarations - Check methods declaraed in interface or
12049 /// or protocol against those declared in their implementations.
12051 const SelectorSet &InsMap, const SelectorSet &ClsMap,
12052 SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl,
12053 ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass,
12054 bool WarnCategoryMethodImpl = false);
12055
12056 /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in
12057 /// category matches with those implemented in its primary class and
12058 /// warns each time an exact match is found.
12060
12061 /// ImplMethodsVsClassMethods - This is main routine to warn if any method
12062 /// remains unimplemented in the class or category \@implementation.
12064 ObjCContainerDecl *IDecl,
12065 bool IncompleteImpl = false);
12066
12068 SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs,
12069 ArrayRef<ObjCTypeParamList *> TypeParamLists, unsigned NumElts);
12070
12071 /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
12072 /// true, or false, accordingly.
12073 bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
12074 const ObjCMethodDecl *PrevMethod,
12075 MethodMatchStrategy strategy = MMS_strict);
12076
12077 /// Add the given method to the list of globally-known methods.
12079
12080 void ReadMethodPool(Selector Sel);
12082
12083 /// - Returns instance or factory methods in global method pool for
12084 /// given selector. It checks the desired kind first, if none is found, and
12085 /// parameter checkTheOther is set, it then checks the other kind. If no such
12086 /// method or only one method is found, function returns false; otherwise, it
12087 /// returns true.
12088 bool
12091 bool InstanceFirst, bool CheckTheOther,
12092 const ObjCObjectType *TypeBound = nullptr);
12093
12094 bool
12096 SourceRange R, bool receiverIdOrClass,
12098
12099 void
12101 Selector Sel, SourceRange R,
12102 bool receiverIdOrClass);
12103
12104 const ObjCMethodDecl *
12106 /// LookupImplementedMethodInGlobalPool - Returns the method which has an
12107 /// implementation.
12109
12111
12112 /// Checks that the Objective-C declaration is declared in the global scope.
12113 /// Emits an error and marks the declaration as invalid if it's not declared
12114 /// in the global scope.
12115 bool CheckObjCDeclScope(Decl *D);
12116
12117 void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart,
12118 const IdentifierInfo *ClassName,
12120
12122 SourceLocation StartLoc, SourceLocation IdLoc,
12123 const IdentifierInfo *Id,
12124 bool Invalid = false);
12125
12127
12128 /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
12129 /// initialization.
12130 void
12133
12135
12136 /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar
12137 /// which backs the property is not used in the property's accessor.
12139 const ObjCImplementationDecl *ImplD);
12140
12141 /// GetIvarBackingPropertyAccessor - If method is a property setter/getter and
12142 /// it property has a backing ivar, returns this ivar; otherwise, returns
12143 /// NULL. It also returns ivar's property on success.
12144 ObjCIvarDecl *
12146 const ObjCPropertyDecl *&PDecl) const;
12147
12148 /// AddInstanceMethodToGlobalPool - All instance methods in a translation
12149 /// unit are added to a global pool. This allows us to efficiently associate
12150 /// a selector with a method declaraation for purposes of typechecking
12151 /// messages sent to "id" (where the class of the object is unknown).
12153 bool impl = false) {
12154 AddMethodToGlobalPool(Method, impl, /*instance*/ true);
12155 }
12156
12157 /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
12158 void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl = false) {
12159 AddMethodToGlobalPool(Method, impl, /*instance*/ false);
12160 }
12161
12162private:
12163 /// AddMethodToGlobalPool - Add an instance or factory method to the global
12164 /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
12165 void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
12166
12167 /// LookupMethodInGlobalPool - Returns the instance or factory method and
12168 /// optionally warns if there are multiple signatures.
12169 ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
12170 bool receiverIdOrClass,
12171 bool instance);
12172
12173 ///@}
12174
12175 //
12176 //
12177 // -------------------------------------------------------------------------
12178 //
12179 //
12180
12181 /// \name ObjC Expressions
12182 /// Implementations are in SemaExprObjC.cpp
12183 ///@{
12184
12185public:
12186 /// Caches identifiers/selectors for NSFoundation APIs.
12187 std::unique_ptr<NSAPI> NSAPIObj;
12188
12189 /// The declaration of the Objective-C NSNumber class.
12191
12192 /// The declaration of the Objective-C NSValue class.
12194
12195 /// Pointer to NSNumber type (NSNumber *).
12197
12198 /// Pointer to NSValue type (NSValue *).
12200
12201 /// The Objective-C NSNumber methods used to create NSNumber literals.
12203
12204 /// The declaration of the Objective-C NSString class.
12206
12207 /// Pointer to NSString type (NSString *).
12209
12210 /// The declaration of the stringWithUTF8String: method.
12212
12213 /// The declaration of the valueWithBytes:objCType: method.
12215
12216 /// The declaration of the Objective-C NSArray class.
12218
12219 /// The declaration of the arrayWithObjects:count: method.
12221
12222 /// The declaration of the Objective-C NSDictionary class.
12224
12225 /// The declaration of the dictionaryWithObjects:forKeys:count: method.
12227
12228 /// id<NSCopying> type.
12230
12231 /// will hold 'respondsToSelector:'
12233
12235 Expr *BaseExpr, SourceLocation OpLoc,
12236 DeclarationName MemberName,
12237 SourceLocation MemberLoc,
12238 SourceLocation SuperLoc,
12239 QualType SuperType, bool Super);
12240
12242 const IdentifierInfo &propertyName,
12243 SourceLocation receiverNameLoc,
12244 SourceLocation propertyNameLoc);
12245
12246 // ParseObjCStringLiteral - Parse Objective-C string literals.
12248 ArrayRef<Expr *> Strings);
12249
12251
12252 /// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
12253 /// numeric literal expression. Type of the expression will be "NSNumber *"
12254 /// or "id" if NSNumber is unavailable.
12257 bool Value);
12259
12260 /// BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the
12261 /// '@' prefixed parenthesized expression. The type of the expression will
12262 /// either be "NSNumber *", "NSString *" or "NSValue *" depending on the type
12263 /// of ValueType, which is allowed to be a built-in numeric type, "char *",
12264 /// "const char *" or C structure with attribute 'objc_boxable'.
12266
12268 Expr *IndexExpr,
12269 ObjCMethodDecl *getterMethod,
12270 ObjCMethodDecl *setterMethod);
12271
12275
12277 TypeSourceInfo *EncodedTypeInfo,
12278 SourceLocation RParenLoc);
12279
12281 SourceLocation EncodeLoc,
12282 SourceLocation LParenLoc, ParsedType Ty,
12283 SourceLocation RParenLoc);
12284
12285 /// ParseObjCSelectorExpression - Build selector expression for \@selector
12287 SourceLocation SelLoc,
12288 SourceLocation LParenLoc,
12289 SourceLocation RParenLoc,
12290 bool WarnMultipleSelectors);
12291
12292 /// ParseObjCProtocolExpression - Build protocol expression for \@protocol
12294 SourceLocation AtLoc,
12295 SourceLocation ProtoLoc,
12296 SourceLocation LParenLoc,
12297 SourceLocation ProtoIdLoc,
12298 SourceLocation RParenLoc);
12299
12301
12302 /// Describes the kind of message expression indicated by a message
12303 /// send that starts with an identifier.
12305 /// The message is sent to 'super'.
12307 /// The message is an instance message.
12309 /// The message is a class message, and the identifier is a type
12310 /// name.
12313
12315 SourceLocation NameLoc, bool IsSuper,
12316 bool HasTrailingDot,
12317 ParsedType &ReceiverType);
12318
12320 SourceLocation LBracLoc,
12321 ArrayRef<SourceLocation> SelectorLocs,
12322 SourceLocation RBracLoc, MultiExprArg Args);
12323
12325 QualType ReceiverType, SourceLocation SuperLoc,
12326 Selector Sel, ObjCMethodDecl *Method,
12327 SourceLocation LBracLoc,
12328 ArrayRef<SourceLocation> SelectorLocs,
12329 SourceLocation RBracLoc, MultiExprArg Args,
12330 bool isImplicit = false);
12331
12333 bool isSuperReceiver, SourceLocation Loc,
12334 Selector Sel, ObjCMethodDecl *Method,
12335 MultiExprArg Args);
12336
12338 SourceLocation LBracLoc,
12339 ArrayRef<SourceLocation> SelectorLocs,
12340 SourceLocation RBracLoc, MultiExprArg Args);
12341
12342 ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType,
12343 SourceLocation SuperLoc, Selector Sel,
12344 ObjCMethodDecl *Method,
12345 SourceLocation LBracLoc,
12346 ArrayRef<SourceLocation> SelectorLocs,
12347 SourceLocation RBracLoc, MultiExprArg Args,
12348 bool isImplicit = false);
12349
12350 ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType,
12351 SourceLocation Loc, Selector Sel,
12352 ObjCMethodDecl *Method,
12353 MultiExprArg Args);
12354
12356 SourceLocation LBracLoc,
12357 ArrayRef<SourceLocation> SelectorLocs,
12358 SourceLocation RBracLoc, MultiExprArg Args);
12359
12361 ObjCBridgeCastKind Kind,
12362 SourceLocation BridgeKeywordLoc,
12363 TypeSourceInfo *TSInfo, Expr *SubExpr);
12364
12366 ObjCBridgeCastKind Kind,
12367 SourceLocation BridgeKeywordLoc,
12368 ParsedType Type, SourceLocation RParenLoc,
12369 Expr *SubExpr);
12370
12372
12374
12376 CastKind &Kind);
12377
12379 QualType SrcType,
12380 ObjCInterfaceDecl *&RelatedClass,
12381 ObjCMethodDecl *&ClassMethod,
12382 ObjCMethodDecl *&InstanceMethod,
12383 TypedefNameDecl *&TDNDecl, bool CfToNs,
12384 bool Diagnose = true);
12385
12387 QualType SrcType, Expr *&SrcExpr,
12388 bool Diagnose = true);
12389
12390 /// Private Helper predicate to check for 'self'.
12391 bool isSelfExpr(Expr *RExpr);
12392 bool isSelfExpr(Expr *RExpr, const ObjCMethodDecl *Method);
12393
12395 const ObjCObjectPointerType *OPT,
12396 bool IsInstance);
12398 bool IsInstance);
12399
12400 bool isKnownName(StringRef name);
12401
12403
12404 /// Checks for invalid conversions and casts between
12405 /// retainable pointers and other pointer kinds for ARC and Weak.
12407 QualType castType, Expr *&op,
12409 bool Diagnose = true,
12410 bool DiagnoseCFAudited = false,
12411 BinaryOperatorKind Opc = BO_PtrMemD);
12412
12415
12417 QualType ExprType);
12418
12419 /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
12420 /// \param Method - May be null.
12421 /// \param [out] ReturnType - The return type of the send.
12422 /// \return true iff there were any incompatible types.
12423 bool CheckMessageArgumentTypes(const Expr *Receiver, QualType ReceiverType,
12424 MultiExprArg Args, Selector Sel,
12425 ArrayRef<SourceLocation> SelectorLocs,
12426 ObjCMethodDecl *Method, bool isClassMessage,
12427 bool isSuperMessage, SourceLocation lbrac,
12428 SourceLocation rbrac, SourceRange RecRange,
12429 QualType &ReturnType, ExprValueKind &VK);
12430
12431 /// Determine the result of a message send expression based on
12432 /// the type of the receiver, the method expected to receive the message,
12433 /// and the form of the message send.
12434 QualType getMessageSendResultType(const Expr *Receiver, QualType ReceiverType,
12435 ObjCMethodDecl *Method, bool isClassMessage,
12436 bool isSuperMessage);
12437
12438 /// If the given expression involves a message send to a method
12439 /// with a related result type, emit a note describing what happened.
12440 void EmitRelatedResultTypeNote(const Expr *E);
12441
12442 /// Given that we had incompatible pointer types in a return
12443 /// statement, check whether we're in a method with a related result
12444 /// type, and if so, emit a note describing what happened.
12446
12447 /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
12448 /// there are multiple signatures.
12451 bool receiverIdOrClass = false) {
12452 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
12453 /*instance*/ true);
12454 }
12455
12456 /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
12457 /// there are multiple signatures.
12460 bool receiverIdOrClass = false) {
12461 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
12462 /*instance*/ false);
12463 }
12464
12465 ///@}
12466
12467 //
12468 //
12469 // -------------------------------------------------------------------------
12470 //
12471 //
12472
12473 /// \name ObjC @property and @synthesize
12474 /// Implementations are in SemaObjCProperty.cpp
12475 ///@{
12476
12477public:
12478 /// Ensure attributes are consistent with type.
12479 /// \param [in, out] Attributes The attributes to check; they will
12480 /// be modified to be consistent with \p PropertyTy.
12481 void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc,
12482 unsigned &Attributes,
12483 bool propertyInPrimaryClass);
12484
12485 /// Process the specified property declaration and create decls for the
12486 /// setters and getters as needed.
12487 /// \param property The property declaration being processed
12488 void ProcessPropertyDecl(ObjCPropertyDecl *property);
12489
12491 FieldDeclarator &FD, ObjCDeclSpec &ODS,
12492 Selector GetterSel, Selector SetterSel,
12493 tok::ObjCKeywordKind MethodImplKind,
12494 DeclContext *lexicalDC = nullptr);
12495
12497 SourceLocation PropertyLoc, bool ImplKind,
12498 IdentifierInfo *PropertyId,
12499 IdentifierInfo *PropertyIvar,
12500 SourceLocation PropertyIvarLoc,
12501 ObjCPropertyQueryKind QueryKind);
12502
12503 /// Called by ActOnProperty to handle \@property declarations in
12504 /// class extensions.
12506 Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc,
12507 FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc,
12508 Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite,
12509 unsigned &Attributes, const unsigned AttributesAsWritten, QualType T,
12510 TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind);
12511
12512 /// Called by ActOnProperty and HandlePropertyInClassExtension to
12513 /// handle creating the ObjcPropertyDecl for a category or \@interface.
12516 SourceLocation LParenLoc, FieldDeclarator &FD,
12517 Selector GetterSel, SourceLocation GetterNameLoc,
12518 Selector SetterSel, SourceLocation SetterNameLoc,
12519 const bool isReadWrite, const unsigned Attributes,
12520 const unsigned AttributesAsWritten, QualType T,
12521 TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind,
12522 DeclContext *lexicalDC = nullptr);
12523
12525 ObjCPropertyDecl *SuperProperty,
12526 const IdentifierInfo *Name,
12527 bool OverridingProtocolProperty);
12528
12530 ObjCMethodDecl *Getter,
12531 SourceLocation Loc);
12532
12533 /// DiagnoseUnimplementedProperties - This routine warns on those properties
12534 /// which must be implemented by this implementation.
12536 ObjCContainerDecl *CDecl,
12537 bool SynthesizeProperties);
12538
12539 /// Diagnose any null-resettable synthesized setters.
12541
12542 /// DefaultSynthesizeProperties - This routine default synthesizes all
12543 /// properties which must be synthesized in the class's \@implementation.
12545 ObjCInterfaceDecl *IDecl,
12546 SourceLocation AtEnd);
12548
12549 /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
12550 /// an ivar synthesized for 'Method' and 'Method' is a property accessor
12551 /// declared in class 'IFace'.
12553 ObjCMethodDecl *Method, ObjCIvarDecl *IV);
12554
12556
12557 void
12559 const ObjCInterfaceDecl *IFD);
12560
12561 /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
12562 /// warning) when atomic property has one but not the other user-declared
12563 /// setter or getter.
12565 ObjCInterfaceDecl *IDecl);
12566
12567 ///@}
12568
12569 //
12570 //
12571 // -------------------------------------------------------------------------
12572 //
12573 //
12574
12575 /// \name Code Completion
12576 /// Implementations are in SemaCodeComplete.cpp
12577 ///@{
12578
12579public:
12580 /// Code-completion consumer.
12582
12583 /// Describes the context in which code completion occurs.
12585 /// Code completion occurs at top-level or namespace context.
12587 /// Code completion occurs within a class, struct, or union.
12589 /// Code completion occurs within an Objective-C interface, protocol,
12590 /// or category.
12592 /// Code completion occurs within an Objective-C implementation or
12593 /// category implementation
12595 /// Code completion occurs within the list of instance variables
12596 /// in an Objective-C interface, protocol, category, or implementation.
12598 /// Code completion occurs following one or more template
12599 /// headers.
12601 /// Code completion occurs following one or more template
12602 /// headers within a class.
12604 /// Code completion occurs within an expression.
12606 /// Code completion occurs within a statement, which may
12607 /// also be an expression or a declaration.
12609 /// Code completion occurs at the beginning of the
12610 /// initialization statement (or expression) in a for loop.
12612 /// Code completion occurs within the condition of an if,
12613 /// while, switch, or for statement.
12615 /// Code completion occurs within the body of a function on a
12616 /// recovery path, where we do not have a specific handle on our position
12617 /// in the grammar.
12619 /// Code completion occurs where only a type is permitted.
12621 /// Code completion occurs in a parenthesized expression, which
12622 /// might also be a type cast.
12624 /// Code completion occurs within a sequence of declaration
12625 /// specifiers within a function, method, or block.
12627 /// Code completion occurs at top-level in a REPL session
12629 };
12630
12633 ParserCompletionContext CompletionContext);
12634 void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers,
12635 bool AllowNestedNameSpecifiers);
12636
12637 struct CodeCompleteExpressionData;
12638 void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data);
12639 void CodeCompleteExpression(Scope *S, QualType PreferredType,
12640 bool IsParenthesized = false);
12641 void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase,
12642 SourceLocation OpLoc, bool IsArrow,
12643 bool IsBaseExprStatement,
12644 QualType PreferredType);
12646 QualType PreferredType);
12647 void CodeCompleteTag(Scope *S, unsigned TagSpec);
12650 const VirtSpecifiers *VS = nullptr);
12652 void CodeCompleteCase(Scope *S);
12654 Attribute,
12655 Scope,
12656 None,
12657 };
12661 const IdentifierInfo *Scope = nullptr);
12662 /// Determines the preferred type of the current function argument, by
12663 /// examining the signatures of all possible overloads.
12664 /// Returns null if unknown or ambiguous, or if code completion is off.
12665 ///
12666 /// If the code completion point has been reached, also reports the function
12667 /// signatures that were considered.
12668 ///
12669 /// FIXME: rename to GuessCallArgumentType to reduce confusion.
12671 SourceLocation OpenParLoc);
12673 ArrayRef<Expr *> Args,
12674 SourceLocation OpenParLoc,
12675 bool Braced);
12677 Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy,
12678 ArrayRef<Expr *> ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc,
12679 bool Braced);
12682 void CodeCompleteInitializer(Scope *S, Decl *D);
12683 /// Trigger code completion for a record of \p BaseType. \p InitExprs are
12684 /// expressions in the initializer list seen so far and \p D is the current
12685 /// Designation being parsed.
12686 void CodeCompleteDesignator(const QualType BaseType,
12687 llvm::ArrayRef<Expr *> InitExprs,
12688 const Designation &D);
12689 void CodeCompleteAfterIf(Scope *S, bool IsBracedThen);
12690
12691 void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext,
12692 bool IsUsingDeclaration, QualType BaseType,
12693 QualType PreferredType);
12694 void CodeCompleteUsing(Scope *S);
12700 Decl *Constructor, ArrayRef<CXXCtorInitializer *> Initializers);
12701
12703 bool AfterAmpersand);
12705
12714 bool IsParameter);
12718 bool AtArgumentExpression);
12721 bool AtArgumentExpression,
12722 bool IsSuper = false);
12724 Scope *S, Expr *Receiver, ArrayRef<const IdentifierInfo *> SelIdents,
12725 bool AtArgumentExpression, ObjCInterfaceDecl *Super = nullptr);
12726 void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar);
12729 void
12735 SourceLocation ClassNameLoc);
12738 SourceLocation ClassNameLoc);
12740 IdentifierInfo *ClassName,
12741 SourceLocation ClassNameLoc);
12744 IdentifierInfo *PropertyName);
12746 std::optional<bool> IsInstanceMethod,
12747 ParsedType ReturnType);
12749 Scope *S, bool IsInstanceMethod, bool AtParameterName,
12750 ParsedType ReturnType, ArrayRef<const IdentifierInfo *> SelIdents);
12752 const IdentifierInfo &ClassName,
12753 SourceLocation ClassNameLoc,
12754 bool IsBaseExprStatement);
12755 void CodeCompletePreprocessorDirective(bool InConditional);
12757 void CodeCompletePreprocessorMacroName(bool IsDefinition);
12761 unsigned Argument);
12762 void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled);
12765 void
12767 CodeCompletionTUInfo &CCTUInfo,
12769
12770 ///@}
12771
12772 //
12773 //
12774 // -------------------------------------------------------------------------
12775 //
12776 //
12777
12778 /// \name FixIt Helpers
12779 /// Implementations are in SemaFixItUtils.cpp
12780 ///@{
12781
12782public:
12783 /// Get a string to suggest for zero-initialization of a type.
12785 SourceLocation Loc) const;
12786 std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
12787
12788 ///@}
12789
12790 //
12791 //
12792 // -------------------------------------------------------------------------
12793 //
12794 //
12795
12796 /// \name API Notes
12797 /// Implementations are in SemaAPINotes.cpp
12798 ///@{
12799
12800public:
12801 /// Map any API notes provided for this declaration to attributes on the
12802 /// declaration.
12803 ///
12804 /// Triggered by declaration-attribute processing.
12805 void ProcessAPINotes(Decl *D);
12806
12807 ///@}
12808 //
12809 //
12810 // -------------------------------------------------------------------------
12811 //
12812 //
12813
12814 /// \name Name Lookup for RISC-V Vector Intrinsic
12815 /// Implementations are in SemaRISCVVectorLookup.cpp
12816 ///@{
12817
12818public:
12819 /// Indicate RISC-V vector builtin functions enabled or not.
12821
12822 /// Indicate RISC-V SiFive vector builtin functions enabled or not.
12824
12825private:
12826 std::unique_ptr<sema::RISCVIntrinsicManager> RVIntrinsicManager;
12827
12828 ///@}
12829};
12830
12834
12835/// Contains a late templated function.
12836/// Will be parsed at the end of the translation unit, used by Sema & Parser.
12839 /// The template function declaration to be late parsed.
12841 /// Floating-point options in the point of definition.
12843};
12844
12845template <>
12847 PragmaMsStackAction Action,
12848 llvm::StringRef StackSlotLabel,
12850
12851std::unique_ptr<sema::RISCVIntrinsicManager>
12853} // end namespace clang
12854
12855#endif
This file provides AST data structures related to concepts.
#define V(N, I)
Definition: ASTContext.h:3284
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:82
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:2975
StringRef Identifier
Definition: Format.cpp:2979
llvm::MachO::Target Target
Definition: MachO.h:48
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:47
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:4399
SourceLocation Begin
StateNode * Previous
std::string Label
A class for storing results from argument-dependent lookup.
Definition: Lookup.h:867
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:86
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:3514
Attr - This represents one attribute.
Definition: Attr.h:42
Syntax
The style used to specify an attribute.
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:5600
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5977
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:4495
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:2491
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:73
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:4687
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.
An allocator used specifically for the purpose of code completion.
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:246
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:1898
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:3298
Represents an enum.
Definition: Decl.h:3868
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:5571
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:1025
Represents a member of a struct/union/class.
Definition: Decl.h:3058
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:266
FileNullability & operator[](FileID file)
Definition: Sema.h:277
FileNullability Nullability
Definition: Sema.h:273
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:4606
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4652
Declaration of a template function.
Definition: DeclTemplate.h:958
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition: Type.h:4278
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4252
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:3342
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
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4686
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
static const unsigned NumNSNumberLiteralMethods
Definition: NSAPI.h:191
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.
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2326
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2542
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:947
Captures information about "declaration specifiers" specific to Objective-C.
Definition: DeclSpec.h:896
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2594
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1950
ObjCList - This is a simple template class used to hold various lists of decls etc,...
Definition: DeclObjC.h:82
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:945
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition: Type.h:7004
Represents a class type in Objective C.
Definition: Type.h:6750
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:730
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2082
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:578
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:659
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:56
Tracks expected type during expression parsing, for use in code completion.
Definition: Sema.h:298
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:300
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
Definition: Sema.h:335
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:2559
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:4169
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:5545
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:352
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:1216
bool operator==(const AlignPackInfo &Info) const
Definition: Sema.h:1276
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:1248
unsigned getPackNumber() const
Definition: Sema.h:1266
bool IsXLStack() const
Definition: Sema.h:1274
bool IsPackSet() const
Definition: Sema.h:1268
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition: Sema.h:1222
bool IsAlignAttr() const
Definition: Sema.h:1262
bool IsPackAttr() const
Definition: Sema.h:1260
bool operator!=(const AlignPackInfo &Info) const
Definition: Sema.h:1282
AlignPackInfo(bool IsXL)
Definition: Sema.h:1226
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition: Sema.h:1233
Mode getAlignMode() const
Definition: Sema.h:1264
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:10305
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:10310
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:6400
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:6405
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition: Sema.h:6392
std::tuple< const Ts &... > Args
Definition: Sema.h:6389
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:6552
A RAII object to enter scope of a compound statement.
Definition: Sema.h:865
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:867
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:5879
bool isInvalid() const
Definition: Sema.h:5878
std::optional< bool > getKnownValue() const
Definition: Sema.h:5883
A RAII object to temporarily push a declaration context.
Definition: Sema.h:2544
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition: Sema.h:2554
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:8056
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:8061
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:4681
DefaultedComparisonKind asComparison() const
Definition: Sema.h:4713
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition: Sema.h:4690
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition: Sema.h:4718
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition: Sema.h:4693
CXXSpecialMemberKind asSpecialMember() const
Definition: Sema.h:4710
RAII class to control scope of DeferDiags.
Definition: Sema.h:7905
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition: Sema.h:7910
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition: Sema.h:937
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:956
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:980
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:949
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:952
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:966
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:972
A helper class for building up ExtParameterInfos.
Definition: Sema.h:9758
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:9777
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:9765
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:10556
FPOptionsOverride getOverrides()
Definition: Sema.h:10560
FullExprArg(Sema &actions)
Definition: Sema.h:5823
ExprResult release()
Definition: Sema.h:5825
Expr * get() const
Definition: Sema.h:5827
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:10572
llvm::DenseMap< Selector, Lists >::iterator iterator
Definition: Sema.h:11820
iterator find(Selector Sel)
Definition: Sema.h:11823
std::pair< ObjCMethodList, ObjCMethodList > Lists
Definition: Sema.h:11819
int count(Selector Sel) const
Definition: Sema.h:11827
std::pair< iterator, bool > insert(std::pair< Selector, Lists > &&Val)
Definition: Sema.h:11824
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:8120
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:8112
Helper class that collects exception specifications for implicitly-declared special member functions.
Definition: Sema.h:4020
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:4053
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:4046
const QualType * data() const
The set of exceptions in the exception specification.
Definition: Sema.h:4056
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
Definition: Sema.h:4062
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition: Sema.h:4069
static NameClassification DependentNonType()
Definition: Sema.h:2759
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:2769
ExprResult getExpression() const
Definition: Sema.h:2795
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:2735
static NameClassification Unknown()
Definition: Sema.h:2739
static NameClassification OverloadSet(ExprResult E)
Definition: Sema.h:2743
NameClassificationKind getKind() const
Definition: Sema.h:2793
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition: Sema.h:2787
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:2775
NamedDecl * getNonTypeDecl() const
Definition: Sema.h:2805
NameClassification(ParsedType Type)
Definition: Sema.h:2733
TemplateName getTemplateName() const
Definition: Sema.h:2810
ParsedType getType() const
Definition: Sema.h:2800
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:2817
static NameClassification NonType(NamedDecl *D)
Definition: Sema.h:2749
static NameClassification Concept(TemplateName Name)
Definition: Sema.h:2781
static NameClassification UndeclaredNonType()
Definition: Sema.h:2755
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:2763
static NameClassification Error()
Definition: Sema.h:2737
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
Definition: Sema.h:639
void operator()(sema::FunctionScopeInfo *Scope) const
Definition: Sema.cpp:2268
Whether and why a template name is required in this lookup.
Definition: Sema.h:8854
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition: Sema.h:8860
SourceLocation getTemplateKeywordLoc() const
Definition: Sema.h:8862
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition: Sema.h:8857
bool hasTemplateKeyword() const
Definition: Sema.h:8865
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:9508
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:9538
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:9516
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition: Sema.h:6417
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:6422
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:6419
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:7350
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:7328
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:7337
CXXMethodDecl * getMethod() const
Definition: Sema.h:7340
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:7341
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:10185
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:10211
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:10191
SourceLocation getLocation() const
Definition: Sema.h:9338
bool ContainsDecl(const NamedDecl *ND) const
Definition: Sema.h:9328
const DeclContext * getDeclContext() const
Definition: Sema.h:9334
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition: Sema.h:9312
const NamedDecl * getDecl() const
Definition: Sema.h:9326
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition: Sema.h:9311
const DeclContext * getLexicalDeclContext() const
Definition: Sema.h:9330
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:9547
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:9554
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:5776
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition: Sema.h:5780
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:457
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:14849
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:14401
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:9415
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.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
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:11101
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:2065
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
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:6794
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
Definition: SemaDecl.cpp:6827
ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXTypeid - Parse typeid( something ).
QualType getMessageSendResultType(const Expr *Receiver, QualType ReceiverType, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage)
Determine the result of a message send expression based on the type of the receiver,...
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
Definition: Sema.h:10255
void ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl)
Definition: SemaDecl.cpp:18344
void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn)
#pragma optimize("[optimization-list]", on | off).
Definition: SemaAttr.cpp:1158
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:6309
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:10239
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...
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< const IdentifierInfo * > SelIdents)
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:8484
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
Definition: Sema.h:11815
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:9787
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)
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition: Sema.h:698
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:2583
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
Definition: SemaType.cpp:9290
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:6745
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
Definition: SemaDecl.cpp:2544
SmallVector< SmallVector< VTableUse, 16 >, 8 > SavedVTableUses
Definition: Sema.h:10519
void CodeCompleteObjCProtocolDecl(Scope *S)
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Definition: SemaDecl.cpp:9871
void PopParsingClass(ParsingClassState state)
Definition: Sema.h:4845
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:2476
void CodeCompleteTag(Scope *S, unsigned TagSpec)
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...
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method,...
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
Definition: Sema.h:7921
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)
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
Definition: SemaExpr.cpp:8840
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
Definition: Sema.h:4834
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr)
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 CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
Definition: SemaType.cpp:2471
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:16077
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:6372
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:1583
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
Definition: SemaExpr.cpp:3848
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
Definition: SemaExpr.cpp:15753
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible and user declared,...
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:7746
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
bool isAlwaysConstantEvaluatedContext() const
Definition: Sema.h:6279
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:15291
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl * > Decls)
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Definition: SemaStmt.cpp:4748
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:1067
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:6365
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:2453
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition: Sema.h:4638
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:7372
@ LookupLabel
Label name lookup.
Definition: Sema.h:7381
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:7376
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition: Sema.h:7403
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition: Sema.h:7395
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:7417
@ LookupLocalFriendName
Look up a friend of a local class.
Definition: Sema.h:7411
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition: Sema.h:7413
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:7408
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:7388
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition: Sema.h:7415
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition: Sema.h:7399
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:7384
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition: Sema.h:7391
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:7379
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition: Sema.h:7419
@ LookupAnyName
Look up any declaration with any name.
Definition: Sema.h:7421
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:423
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition: Sema.h:7316
void CodeCompleteUsing(Scope *S)
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:3588
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:6763
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
Definition: SemaType.cpp:6903
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
Definition: SemaAttr.cpp:1074
ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, SourceLocation ProtoIdLoc, SourceLocation RParenLoc)
ParseObjCProtocolExpression - Build protocol expression for @protocol.
void ActOnPopScope(SourceLocation Loc, Scope *S)
Definition: SemaDecl.cpp:2235
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
Definition: SemaDecl.cpp:5402
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
Definition: SemaExpr.cpp:19890
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:13492
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
Definition: SemaDecl.cpp:16012
bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D, StringRef &Str, bool &isDefault)
bool checkObjCBridgeRelatedComponents(SourceLocation Loc, QualType DestType, QualType SrcType, ObjCInterfaceDecl *&RelatedClass, ObjCMethodDecl *&ClassMethod, ObjCMethodDecl *&InstanceMethod, TypedefNameDecl *&TDNDecl, bool CfToNs, bool Diagnose=true)
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:4600
VariadicCallType
Definition: Sema.h:2013
@ VariadicDoesNotApply
Definition: Sema.h:2018
@ VariadicFunction
Definition: Sema.h:2014
@ VariadicMethod
Definition: Sema.h:2016
@ VariadicConstructor
Definition: Sema.h:2017
@ VariadicBlock
Definition: Sema.h:2015
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
Definition: SemaDecl.cpp:13044
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.
ExprResult ActOnClassPropertyRefExpr(const IdentifierInfo &receiverName, const IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)
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)
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement, QualType PreferredType)
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:7230
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 CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
DelayedDiagnosticsState ParsingDeclState
Definition: Sema.h:932
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:2998
@ NTCUC_CopyInit
Definition: Sema.h:3008
@ NTCUC_AutoVar
Definition: Sema.h:3006
@ NTCUC_CompoundLiteral
Definition: Sema.h:3012
@ NTCUC_DefaultInitializedObject
Definition: Sema.h:3004
@ NTCUC_Assignment
Definition: Sema.h:3010
@ NTCUC_BlockCapture
Definition: Sema.h:3014
@ NTCUC_FunctionReturn
Definition: Sema.h:3002
@ NTCUC_LValueToRValueVolatile
Definition: Sema.h:3016
@ NTCUC_FunctionParam
Definition: Sema.h:3000
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:1481
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:3663
void CodeCompleteCase(Scope *S)
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:7626
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.
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *AArg, SourceLocation Loc)
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:7774
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:6232
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition: SemaStmt.cpp:4383
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
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
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
ExprResult BuildIvarRefExpr(Scope *S, SourceLocation Loc, ObjCIvarDecl *IV)
Definition: SemaExpr.cpp:3110
RetainOwnershipKind
Definition: Sema.h:3712
OpaquePtr< QualType > TypeTy
Definition: Sema.h:851
void CodeCompleteObjCMessageReceiver(Scope *S)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
Definition: SemaDecl.cpp:18467
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:167
ObjCMethodDecl * ArrayWithObjectsMethod
The declaration of the arrayWithObjects:count: method.
Definition: Sema.h:12220
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
ObjCMethodDecl * StringWithUTF8StringMethod
The declaration of the stringWithUTF8String: method.
Definition: Sema.h:12211
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:10325
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:2351
void CheckConflictingOverridingMethod(ObjCMethodDecl *Method, ObjCMethodDecl *Overridden, bool IsProtocolMethodDecl)
bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc, StringRef Keyword)
Decl * ActOnConceptDefinition(Scope *S, MultiTemplateParamsArg TemplateParameterLists, const IdentifierInfo *Name, SourceLocation NameLoc, Expr *ConstraintExpr)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
Definition: SemaType.cpp:2771
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:606
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e....
SemaOpenMP & OpenMP()
Definition: Sema.h:1013
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:6872
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:6877
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:6881
@ IER_Error
An error occurred.
Definition: Sema.h:6884
@ IER_Exists
The symbol exists.
Definition: Sema.h:6874
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:7315
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:16097
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:4629
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:7552
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
Definition: SemaExpr.cpp:17739
QualType ProduceCallSignatureHelp(Expr *Fn, ArrayRef< Expr * > Args, SourceLocation OpenParLoc)
Determines the preferred type of the current function argument, by examining the signatures of all po...
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
Definition: SemaExpr.cpp:16103
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition: Sema.h:924
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
Definition: SemaStmt.cpp:4737
DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S, IdentifierInfo *II)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
Definition: SemaExpr.cpp:3037
void CodeCompleteInitializer(Scope *S, Decl *D)
void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
Definition: SemaAttr.cpp:1336
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
ObjCInterfaceDecl * NSDictionaryDecl
The declaration of the Objective-C NSDictionary class.
Definition: Sema.h:12223
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:6199
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:2313
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:1561
bool CheckMessageArgumentTypes(const Expr *Receiver, QualType ReceiverType, MultiExprArg Args, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage, SourceLocation lbrac, SourceLocation rbrac, SourceRange RecRange, QualType &ReturnType, ExprValueKind &VK)
CheckMessageArgumentTypes - Check types in an Obj-C message send.
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition: Sema.h:11441
QualType ProduceConstructorSignatureHelp(QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args, SourceLocation OpenParLoc, bool Braced)
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:2226
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:825
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Definition: SemaDecl.cpp:18392
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
Definition: Sema.h:3505
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:2618
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:1188
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:12503
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:11757
ObjCContainerKind
Definition: Sema.h:11860
@ OCK_Interface
Definition: Sema.h:11862
@ OCK_ClassExtension
Definition: Sema.h:11865
@ OCK_Category
Definition: Sema.h:11864
@ OCK_Implementation
Definition: Sema.h:11866
@ OCK_CategoryImplementation
Definition: Sema.h:11867
@ OCK_None
Definition: Sema.h:11861
@ OCK_Protocol
Definition: Sema.h:11863
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:4811
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:16553
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:4792
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:88
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
Definition: SemaDecl.cpp:15168
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
Definition: Sema.h:12187
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)
QualType BuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError, bool Rebuilding)
Build an Objective-C object pointer type.
Definition: SemaType.cpp:1089
unsigned CapturingFunctionScopes
Track the number of currently active capturing scopes.
Definition: Sema.h:814
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:1109
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:998
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:17673
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures.
Definition: Sema.h:12450
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:1470
PragmaClangSectionAction
Definition: Sema.h:1178
@ PCSA_Set
Definition: Sema.h:1178
@ PCSA_Clear
Definition: Sema.h:1178
void CodeCompleteObjCAtDirective(Scope *S)
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:20639
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:5898
@ 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:901
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:1207
ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr)
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:11716
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:11447
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:2692
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.
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl * > typeParams, SourceLocation rAngleLoc)
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:7756
@ PartitionImplementation
'module X:Y;'
@ Interface
'export module X;'
@ PartitionInterface
'export module X:Y;'
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP)
CheckCategoryVsClassMethodMatches - Checks that methods implemented in category matches with those im...
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:807
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:1478
bool CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
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:11847
void ActOnTypedefedProtocols(SmallVectorImpl< Decl * > &ProtocolRefs, SmallVectorImpl< SourceLocation > &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc)
ActOnTypedefedProtocols - this action finds protocol list as part of the typedef'ed use for a qualifi...
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition: Sema.h:8139
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition: Sema.h:8142
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition: Sema.h:8148
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition: Sema.h:8146
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, const IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
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:1134
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:1072
@ AR_dependent
Definition: Sema.h:1075
@ AR_accessible
Definition: Sema.h:1073
@ AR_inaccessible
Definition: Sema.h:1074
@ AR_delayed
Definition: Sema.h:1076
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:2245
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:11451
@ Normal
Apply the normal rules for complete types.
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA)
Check whether the given statement can have musttail applied to it, issuing a diagnostic and returning...
Definition: SemaStmt.cpp:635
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
Definition: SemaCast.cpp:3366
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:526
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition: Sema.h:5170
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:2107
QualType GetSignedSizelessVectorType(QualType V)
Definition: SemaExpr.cpp:13066
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:10242
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
void ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, Scope *CurContext)
Once the Lambdas capture are known, we can start to create the closure, call operator method,...
FunctionTemplateDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition: SemaCast.cpp:395
void AddTemplateParametersToLambdaCallOperator(CXXMethodDecl *CallOperator, CXXRecordDecl *Class, TemplateParameterList *TemplateParams)
Definition: SemaLambda.cpp:957
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
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:6441
void deduceOpenCLAddressSpace(ValueDecl *decl)
Definition: SemaDecl.cpp:7025
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3788
ObjCCategoryImplDecl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *CatName, SourceLocation CatLoc, const ParsedAttributesView &AttrList)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3323
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:1419
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
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:6353
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:11448
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:1413
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:3975
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:1177
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:18703
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:2296
Decl * ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
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:3593
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition: SemaStmt.cpp:463
void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
WarnExactTypedMethods - This routine issues a warning if method implementation declaration matches ex...
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid,...
Definition: Sema.h:1490
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
Definition: SemaDecl.cpp:6360
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:17458
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
void CodeCompleteObjCAtExpression(Scope *S)
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Definition: SemaType.cpp:2845
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
Definition: SemaDecl.cpp:4906
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition: Sema.h:1408
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:8615
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
Definition: SemaExpr.cpp:6853
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:12466
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
Definition: SemaDecl.cpp:16769
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:2154
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:10529
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:2394
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3368
@ 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...
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
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:18486
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
Definition: SemaStmt.cpp:51
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:18586
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition: Sema.cpp:1120
ObjCImplementationDecl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList)
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:1420
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:7725
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.
QualType NSNumberPointer
Pointer to NSNumber type (NSNumber *).
Definition: Sema.h:12196
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
Definition: SemaExpr.cpp:12032
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
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:20424
FieldDecl * BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture)
Build a FieldDecl suitable to hold the given capture.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
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:14776
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
Definition: SemaExpr.cpp:16116
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:131
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:1454
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
SemaSYCL & SYCL()
Definition: Sema.h:1018
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...
ObjCPropertyDecl * HandlePropertyInClassExtension(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc, Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite, unsigned &Attributes, const unsigned AttributesAsWritten, QualType T, TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind)
Called by ActOnProperty to handle @property declarations in class extensions.
sema::LambdaScopeInfo * RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator)
Definition: SemaDecl.cpp:15654
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16769
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:2680
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods=std::nullopt, ArrayRef< DeclGroupPtrTy > allTUVars=std::nullopt)
StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:981
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
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition: SemaStmt.cpp:4339
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
Definition: SemaExpr.cpp:796
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:8825
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
Definition: SemaDecl.cpp:3530
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition: Sema.h:9173
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition: Sema.h:9184
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:9176
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition: Sema.h:9180
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:646
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:1689
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS, QualType PreferredType)
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
Definition: SemaType.cpp:1159
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:7310
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:1046
void CodeCompleteObjCClassForwardDecl(Scope *S)
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Definition: SemaExpr.cpp:14200
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:10259
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
Definition: SemaExpr.cpp:5233
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
Definition: SemaDecl.cpp:20570
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
Definition: SemaExpr.cpp:2003
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
Definition: SemaExpr.cpp:7868
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
Definition: SemaExpr.cpp:14490
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:15278
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
Definition: SemaStmt.cpp:1057
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
Decl * ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc, IdentifierInfo *AliasName, SourceLocation AliasLocation, IdentifierInfo *ClassName, SourceLocation ClassLocation)
ActOnCompatibilityAlias - this action is called after complete parsing of a @compatibility_alias decl...
ASTContext & Context
Definition: Sema.h:858
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:6266
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:2690
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:10224
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:20435
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Definition: SemaDecl.cpp:14798
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:4929
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
ARCConversionResult
Definition: Sema.h:12402
@ ACR_error
Definition: Sema.h:12402
@ ACR_unbridged
Definition: Sema.h:12402
@ ACR_okay
Definition: Sema.h:12402
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:7321
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:5844
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
Definition: SemaType.cpp:3084
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:11859
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:5898
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:10266
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
AMDGPUWavesPerEUAttr * CreateAMDGPUWavesPerEUAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD)
DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which backs the property is n...
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:2946
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:524
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:8135
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
Definition: SemaDecl.cpp:20591
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:3246
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:11701
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:21391
void resetFPOptions(FPOptions FPO)
Definition: Sema.h:8803
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition: Sema.h:11774
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition: SemaStmt.cpp:4439
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
QualType ProduceTemplateArgumentSignatureHelp(TemplateTy, ArrayRef< ParsedTemplateArgument >, SourceLocation LAngleLoc)
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:7744
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)
void CodeCompleteAfterIf(Scope *S, bool IsBracedThen)
static bool getPrintable(bool B)
Definition: Sema.h:11437
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Definition: SemaLookup.cpp:918
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:5411
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
Definition: SemaDecl.cpp:5016
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
Definition: SemaExpr.cpp:13331
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:2635
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....
void ActOnSuperClassOfClassInterface(Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange)
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:993
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition: SemaDecl.cpp:66
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:5790
@ AllowFold
Definition: Sema.h:5792
@ NoFold
Definition: Sema.h:5791
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:1521
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:2291
bool DeclareRISCVSiFiveVectorBuiltins
Indicate RISC-V SiFive vector builtin functions enabled or not.
Definition: Sema.h:12823
PragmaStack< bool > StrictGuardStackCheckStack
Definition: Sema.h:1416
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:2626
ObjCInterfaceDecl * NSStringDecl
The declaration of the Objective-C NSString class.
Definition: Sema.h:12205
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:19903
void CodeCompleteAvailabilityPlatformName()
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:762
bool isImmediateFunctionContext() const
Definition: Sema.h:6291
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:2440
ASTContext & getASTContext() const
Definition: Sema.h:527
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition: SemaExpr.cpp:774
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:5807
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:16084
bool IsFloatingPointPromotion(QualType FromType, QualType ToType)
IsFloatingPointPromotion - Determines whether the conversion from FromType to ToType is a floating po...
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>.
Definition: Sema.h:4818
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:16032
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:986
void CodeCompleteObjCPropertyDefinition(Scope *S)
void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules)
Definition: SemaAttr.cpp:934
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:19194
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:20154
ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C class message expression.
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Definition: SemaDecl.cpp:1754
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:4896
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:15546
NameClassificationKind
Describes the result of the name lookup and resolution performed by ClassifyName().
Definition: Sema.h:2682
@ NC_Unknown
This name is not a type or template in this context, but might be something else.
Definition: Sema.h:2685
@ NC_VarTemplate
The name was classified as a variable template name.
Definition: Sema.h:2712
@ NC_NonType
The name was classified as a specific non-type, non-template declaration.
Definition: Sema.h:2695
@ NC_TypeTemplate
The name was classified as a template whose specializations are types.
Definition: Sema.h:2710
@ NC_Error
Classification failed; an error has been produced.
Definition: Sema.h:2687
@ NC_FunctionTemplate
The name was classified as a function template name.
Definition: Sema.h:2714
@ NC_DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition: Sema.h:2703
@ NC_UndeclaredNonType
The name was classified as an ADL-only function name.
Definition: Sema.h:2699
@ NC_UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition: Sema.h:2716
@ NC_Keyword
The name has been typo-corrected to a keyword.
Definition: Sema.h:2689
@ NC_Type
The name was classified as a type.
Definition: Sema.h:2691
@ NC_OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition: Sema.h:2708
@ NC_Concept
The name was classified as a concept name.
Definition: Sema.h:2718
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:18099
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
Definition: SemaExpr.cpp:9967
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:1412
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: SemaStmt.cpp:4672
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:879
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:3736
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
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:684
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition: Sema.h:1862
ParsingClassState PushParsingClass()
Definition: Sema.h:4841
SmallVector< VarDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
Definition: Sema.h:2636
bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall)
Check whether the given method, which must be in the 'init' family, is a valid member of that family.
ForRangeStatus
Definition: Sema.h:8356
@ FRS_Success
Definition: Sema.h:8357
@ FRS_DiagnosticIssued
Definition: Sema.h:8359
@ FRS_NoViableFunction
Definition: Sema.h:8358
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
Definition: SemaExpr.cpp:6380
void ActOnPragmaCXLimitedRange(SourceLocation Loc, LangOptions::ComplexRangeKind Range)
ActOnPragmaCXLimitedRange - Called on well formed #pragma STDC CX_LIMITED_RANGE.
Definition: SemaAttr.cpp:1367
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
Definition: SemaExpr.cpp:3344
bool isBoundsAttrContext() const
Definition: Sema.h:5176
void ActOnPragmaFPExceptions(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called on well formed '#pragma clang fp' that has option 'exceptions'.
Definition: SemaAttr.cpp:1375
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:7244
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:16084
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:571
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:7369
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, SourceRange PlacementRange, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose=true)
Checks access to an overloaded operator new or delete.
void CodeCompleteUsingDirective(Scope *S)
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:7313
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:4861
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition: Sema.h:4483
@ 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:8151
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:7059
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:9662
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:7947
@ Conversions
Allow explicit conversion functions but not explicit constructors.
@ All
Allow both explicit conversion functions and explicit constructors.
void ActOnFinishRequiresExpr()
void MatchAllMethodDeclarations(const SelectorSet &InsMap, const SelectorSet &ClsMap, SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass, bool WarnCategoryMethodImpl=false)
MatchAllMethodDeclarations - Check methods declaraed in interface or or protocol against those declar...
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
Definition: Sema.h:797
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition: Sema.h:4829
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Definition: SemaExpr.cpp:13377
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 CheckObjCMethodDirectOverrides(ObjCMethodDecl *method, ObjCMethodDecl *overridden)
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...
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:20739
void CodeCompleteTypeQualifiers(DeclSpec &DS)
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)
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
Definition: SemaType.cpp:6842
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition: Sema.h:775
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:5568
void ActOnPragmaFPEvalMethod(SourceLocation Loc, LangOptions::FPEvalMethodKind Value)
Definition: SemaAttr.cpp:534
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
Definition: Sema.h:2649
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:17127
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:2385
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition: Sema.h:2541
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
Definition: SemaDecl.cpp:9137
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
Definition: SemaExpr.cpp:2206
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:8815
void setFunctionHasIndirectGoto()
Definition: Sema.cpp:2306
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:2380
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition: Sema.h:9259
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:9277
@ TPL_TemplateTemplateArgumentMatch
We are matching the template parameter lists of a template template argument against the template par...
Definition: Sema.h:9288
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:9267
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition: Sema.h:9298
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16372
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:3584
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:10027
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:1675
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:6476
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)
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
Definition: SemaExpr.cpp:7478
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:8875
@ 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:4443
void CodeCompleteInPreprocessorConditionalExclusion(Scope *S)
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Definition: SemaExpr.cpp:1973
QualType NSValuePointer
Pointer to NSValue type (NSValue *).
Definition: Sema.h:12199
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
Definition: SemaType.cpp:1970
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for.
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
bool isSameOrCompatibleFunctionType(QualType Param, QualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment,...
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Definition: SemaStmt.cpp:1245
AtomicArgumentOrder
Definition: Sema.h:1962
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:2126
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:1267
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
Definition: SemaCast.cpp:383
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
Definition: Sema.cpp:1524
SourceRange getExprRange(Expr *E) const
Definition: SemaExpr.cpp:518
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:3448
ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection)
Definition: SemaStmt.cpp:2240
void setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called to set exception behavior for floating point operations.
Definition: SemaAttr.cpp:1343
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:1139
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:2981
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
Definition: Sema.h:8808
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
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:648
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:2622
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:6324
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:11444
ObjCInterfaceDecl * getObjCInterfaceDecl(const IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
Definition: SemaDecl.cpp:2325
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition: Sema.h:3392
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
Definition: SemaDecl.cpp:17020
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:224
FPOptions & getCurFPFeatures()
Definition: Sema.h:522
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition: Sema.h:6435
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:907
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
Definition: SemaExpr.cpp:20670
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:63
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:2144
StmtResult ActOnCoreturnStmt(Scope *S, SourceLocation KwLoc, Expr *E)
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
void PopCompoundScope()
Definition: Sema.cpp:2283
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:11725
bool EnsureTemplateArgumentListConstraints(TemplateDecl *Template, const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange)
Ensure that the given template arguments satisfy the constraints associated with the given template,...
bool isObjCMethodDecl(Decl *D)
Definition: Sema.h:12027
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, QualType BaseType, QualType PreferredType)
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
Definition: SemaDecl.cpp:20046
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:10789
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition: Sema.h:10809
@ UPPC_RequiresClause
Definition: Sema.h:10860
@ UPPC_UsingDeclaration
A using declaration.
Definition: Sema.h:10815
@ UPPC_IfExists
Microsoft __if_exists.
Definition: Sema.h:10842
@ UPPC_Requirement
Definition: Sema.h:10857
@ UPPC_ExceptionType
The type of an exception.
Definition: Sema.h:10833
@ UPPC_EnumeratorValue
The enumerator value.
Definition: Sema.h:10812
@ UPPC_Lambda
Lambda expression.
Definition: Sema.h:10848
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition: Sema.h:10845
@ UPPC_PartialSpecialization
Partial specialization.
Definition: Sema.h:10839
@ UPPC_Initializer
An initializer.
Definition: Sema.h:10824
@ UPPC_BaseType
The base type of a class type.
Definition: Sema.h:10794
@ UPPC_FriendDeclaration
A friend declaration.
Definition: Sema.h:10818
@ UPPC_DefaultArgument
A default argument.
Definition: Sema.h:10827
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition: Sema.h:10797
@ UPPC_Expression
An arbitrary expression.
Definition: Sema.h:10791
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition: Sema.h:10836
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition: Sema.h:10821
@ UPPC_DataMemberType
The type of a data member.
Definition: Sema.h:10800
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition: Sema.h:10806
@ UPPC_Block
Block expression.
Definition: Sema.h:10851
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition: Sema.h:10803
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition: Sema.h:10830
@ UPPC_TypeConstraint
A type constraint.
Definition: Sema.h:10854
ObjCMethodDecl * ValueWithBytesObjCTypeMethod
The declaration of the valueWithBytes:objCType: method.
Definition: Sema.h:12214
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, const IdentifierInfo *ClassName, SmallVectorImpl< Decl * > &Decls)
Called whenever @defs(ClassName) is encountered in the source.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition: SemaStmt.cpp:4321
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
api_notes::APINotesManager APINotes
Definition: Sema.h:862
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:9570
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:520
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...
RecordDecl * CFError
The struct behind the CFErrorRef pointer.
Definition: Sema.h:11597
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
bool RequireCompleteExprType(Expr *E, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
Definition: SemaType.cpp:9246
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)
ObjCProtocolDecl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
Definition: Sema.h:4373
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:1719
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12530
SourceLocation CurInitSegLoc
Definition: Sema.h:1452
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:7493
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Definition: SemaExpr.cpp:13306
void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass)
Ensure attributes are consistent with type.
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition: SemaAttr.cpp:622
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition: Sema.h:2643
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:1008
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition: Sema.h:11218
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
Definition: SemaDecl.cpp:1411
ReuseLambdaContextDecl_t
Definition: Sema.h:5233
@ ReuseLambdaContextDecl
Definition: Sema.h:5233
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:6717
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:17774
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:6755
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
Definition: SemaDecl.cpp:1626
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:528
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
Definition: SemaExpr.cpp:2254
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.
void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E)
Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
Definition: SemaExpr.cpp:20301
void * OpaqueParser
Definition: Sema.h:905
Preprocessor & PP
Definition: Sema.h:857
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:11311
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
Definition: SemaExpr.cpp:5911
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)
void CodeCompleteObjCImplementationDecl(Scope *S)
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:6651
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9952
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:14455
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
Definition: Sema.h:1499
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:17043
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
Definition: SemaExpr.cpp:4948
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:898
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:1477
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:8340
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...
void updateOutOfDateSelector(Selector Sel)
bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy)
Are the two types matrix types and do they have the same dimensions i.e.
Definition: SemaExpr.cpp:7763
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:2630
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
Definition: Sema.h:12202
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:4794
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)
void CodeCompleteObjCPropertySetter(Scope *S)
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE)
CheckSubscriptingKind - This routine decide what type of indexing represented by "FromE" is being don...
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:11246
const LangOptions & LangOpts
Definition: Sema.h:856
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition: SemaStmt.cpp:3112
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 ...
ObjCMethodDecl * LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupFactoryMethodInGlobalPool - Returns the method and warns if there are multiple signatures.
Definition: Sema.h:12459
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
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:8572
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:16186
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:803
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:6860
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2360
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:6919
static const uint64_t MaximumAlignment
Definition: Sema.h:798
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
Definition: Sema.h:12152
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition: Sema.h:7062
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:17795
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
Definition: SemaInit.cpp:8554
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition: SemaStmt.cpp:394
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition: Sema.h:11738
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:15497
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:4796
SemaHLSL & HLSL()
Definition: Sema.h:1003
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
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:8824
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:801
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:7368
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:1883
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
Definition: SemaDecl.cpp:12046
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:18691
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
Definition: SemaExpr.cpp:17759
ObjCLiteralKind
Definition: Sema.h:5720
@ LK_Boxed
Definition: Sema.h:5724
@ LK_Dictionary
Definition: Sema.h:5722
@ LK_String
Definition: Sema.h:5725
@ LK_Array
Definition: Sema.h:5721
@ LK_Numeric
Definition: Sema.h:5723
@ LK_None
Definition: Sema.h:5727
@ LK_Block
Definition: Sema.h:5726
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
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:1189
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:97
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:1166
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:4379
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:3864
QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions, IdentifierInfo *Id, bool DirectInit, Expr *&Init)
Definition: SemaLambda.cpp:743
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
Definition: SemaExpr.cpp:204
void CheckCXXDefaultArguments(FunctionDecl *FD)
Helpers for dealing with blocks and functions.
ComparisonCategoryUsage
Definition: Sema.h:3873
@ 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:10517
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition: Sema.h:4789
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:71
ConditionResult ActOnConditionVariable(Decl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
Definition: Sema.h:12190
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:20311
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:10251
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:11439
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:1221
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
Definition: SemaStmt.cpp:3855
PragmaStack< AlignPackInfo > AlignPackStack
Definition: Sema.h:1401
ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
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:15970
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:4888
static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx)
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:5188
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:10291
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:4822
void CodeCompleteNamespaceDecl(Scope *S)
StmtResult ActOnExprStmtError()
Definition: SemaStmt.cpp:68
AcceptableKind
Definition: Sema.h:7364
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:1411
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:3543
void CodeCompleteDesignator(const QualType BaseType, llvm::ArrayRef< Expr * > InitExprs, const Designation &D)
Trigger code completion for a record of BaseType.
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed.
const ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
void completeExprArrayBound(Expr *E)
Definition: SemaType.cpp:9173
DeclContext * getCurLexicalContext() const
Definition: Sema.h:702
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition: Sema.h:916
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:1455
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:9761
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:8350
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:879
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
QualType NSStringPointer
Pointer to NSString type (NSString *).
Definition: Sema.h:12208
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
Definition: SemaStmt.cpp:73
OpenCLOptions OpenCLFeatures
Definition: Sema.h:853
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:10521
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Definition: SemaExpr.cpp:944
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:17098
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
Definition: Sema.h:1502
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
void ExitDeclaratorContext(Scope *S)
Definition: SemaDecl.cpp:1398
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
Definition: SemaExpr.cpp:15995
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:8492
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, 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...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition: Sema.cpp:727
void CodeCompleteNaturalLanguage()
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
void CodeCompleteOperatorName(Scope *S)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
Definition: SemaStmt.cpp:4772
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.
void AddCFAuditedAttribute(Decl *D)
AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and,...
Definition: SemaAttr.cpp:863
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:3340
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:4840
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, CastKind &Kind)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Definition: SemaDecl.cpp:12645
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition: Sema.h:11433
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:4840
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
void DiagnoseMisalignedMembers()
Diagnoses the current set of gathered accesses.
ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, SourceLocation NameLoc, bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType)
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:20072
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:892
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:2278
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:15030
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Definition: SemaDecl.cpp:2399
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...
ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
Definition: SemaDecl.cpp:2374
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
Definition: SemaExpr.cpp:3174
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:2724
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
Definition: SemaExpr.cpp:3886
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
Definition: SemaType.cpp:2273
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it's plausible that E was intended to be a template-name.
Definition: Sema.h:2894
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:1940
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Definition: SemaDecl.cpp:20625
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:10779
bool CheckNontrivialField(FieldDecl *FD)
Definition: SemaDecl.cpp:18881
void CodeCompleteObjCAtVisibility(Scope *S)
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
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:10019
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
Definition: SemaStmt.cpp:1663
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition: Sema.h:5185
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
Definition: SemaAttr.cpp:1231
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...
void CodeCompleteNamespaceAliasDecl(Scope *S)
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:18350
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...
void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, ObjCPropertyDecl *SuperProperty, const IdentifierInfo *Name, bool OverridingProtocolProperty)
DiagnosePropertyMismatch - Compares two properties for their attributes and types and warns on a vari...
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:2079
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:9799
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
Definition: SemaInit.cpp:10732
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:9010
void LateTemplateParserCleanupCB(void *P)
Definition: Sema.h:902
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:4369
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:651
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:10299
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:3432
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:11732
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S)
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition: Sema.h:6295
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:1451
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Definition: SemaDecl.cpp:20659
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition: Sema.h:7739
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
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:9032
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
Selector RespondsToSelectorSel
will hold 'respondsToSelector:'
Definition: Sema.h:12232
void CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
Definition: SemaExpr.cpp:7463
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:1797
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:1643
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:16561
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
Definition: SemaExpr.cpp:7909
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled)
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
Definition: SemaDecl.cpp:15600
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:2316
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
Definition: Sema.h:5211
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:4803
void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init)
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
Definition: SemaDecl.cpp:18335
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
Definition: SemaDecl.cpp:15527
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:996
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:8535
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
bool CollectMultipleMethodsInGlobalPool(Selector Sel, SmallVectorImpl< ObjCMethodDecl * > &Methods, bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound=nullptr)
We first select the type of the method: Instance or Factory, then collect all methods with that type.
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, ArrayRef< Expr * > Strings)
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
Definition: Sema.h:7451
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:21135
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc)
ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const,addrspace}_cast's.
Definition: SemaCast.cpp:274
DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc, SourceLocation PrivateLoc)
The parser has processed a private-module-fragment declaration that begins the definition of the priv...
Definition: SemaModule.cpp:510
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
Definition: SemaDecl.cpp:15070
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition: Sema.h:9571
@ VAK_Invalid
Definition: Sema.h:6053
@ VAK_Valid
Definition: Sema.h:6049
@ VAK_ValidInCXX11
Definition: Sema.h:6050
@ VAK_MSVCUndefined
Definition: Sema.h:6052
@ VAK_Undefined
Definition: Sema.h:6051
void ActOnPragmaMSFunction(SourceLocation Loc, const llvm::SmallVectorImpl< StringRef > &NoBuiltins)
Call on well formed #pragma function.
Definition: SemaAttr.cpp:1167
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
Definition: SemaDecl.cpp:5904
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:10530
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:9988
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:16925
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, SmallVectorImpl< ObjCMethodDecl * > &Methods)
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition: Sema.h:1577
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
Definition: SemaDecl.cpp:15364
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
Definition: SemaType.cpp:4237
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:11449
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:8160
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)
QualType QIDNSCopying
id<NSCopying> type.
Definition: Sema.h:12229
ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, ParsedType ObjectType)
TrivialABIHandling
Definition: Sema.h:4668
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:4670
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition: Sema.h:4673
FormatArgumentPassingKind
Definition: Sema.h:1872
@ FAPK_Fixed
Definition: Sema.h:1873
@ FAPK_Variadic
Definition: Sema.h:1874
@ FAPK_VAList
Definition: Sema.h:1875
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:20364
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:6287
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:9790
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:3649
MethodMatchStrategy
Definition: Sema.h:11858
@ MMS_strict
Definition: Sema.h:11858
@ MMS_loose
Definition: Sema.h:11858
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:7362
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition: Sema.h:6091
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition: Sema.h:6135
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition: Sema.h:6101
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:6159
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:6164
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition: Sema.h:6151
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:6130
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition: Sema.h:6109
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition: Sema.h:6168
@ Compatible
Compatible - the types are compatible according to the standard.
Definition: Sema.h:6093
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition: Sema.h:6120
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition: Sema.h:6172
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:6105
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition: Sema.h:6114
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:6126
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition: Sema.h:6147
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition: Sema.h:6141
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition: Sema.h:6097
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:6155
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
QualType ProduceCtorInitMemberSignatureHelp(Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr * > ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc, bool Braced)
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.
ParserCompletionContext
Describes the context in which code completion occurs.
Definition: Sema.h:12584
@ PCC_RecoveryInFunction
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
Definition: Sema.h:12618
@ PCC_LocalDeclarationSpecifiers
Code completion occurs within a sequence of declaration specifiers within a function,...
Definition: Sema.h:12626
@ PCC_Template
Code completion occurs following one or more template headers.
Definition: Sema.h:12600
@ PCC_MemberTemplate
Code completion occurs following one or more template headers within a class.
Definition: Sema.h:12603
@ PCC_Expression
Code completion occurs within an expression.
Definition: Sema.h:12605
@ PCC_ObjCInterface
Code completion occurs within an Objective-C interface, protocol, or category.
Definition: Sema.h:12591
@ PCC_TopLevelOrExpression
Code completion occurs at top-level in a REPL session.
Definition: Sema.h:12628
@ PCC_Class
Code completion occurs within a class, struct, or union.
Definition: Sema.h:12588
@ PCC_ObjCImplementation
Code completion occurs within an Objective-C implementation or category implementation.
Definition: Sema.h:12594
@ PCC_ParenthesizedExpression
Code completion occurs in a parenthesized expression, which might also be a type cast.
Definition: Sema.h:12623
@ PCC_Namespace
Code completion occurs at top-level or namespace context.
Definition: Sema.h:12586
@ PCC_Type
Code completion occurs where only a type is permitted.
Definition: Sema.h:12620
@ PCC_Condition
Code completion occurs within the condition of an if, while, switch, or for statement.
Definition: Sema.h:12614
@ PCC_ForInit
Code completion occurs at the beginning of the initialization statement (or expression) in a for loop...
Definition: Sema.h:12611
@ PCC_Statement
Code completion occurs within a statement, which may also be an expression or a declaration.
Definition: Sema.h:12608
@ PCC_ObjCInstanceVariableList
Code completion occurs within the list of instance variables in an Objective-C interface,...
Definition: Sema.h:12597
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:8534
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1309
StmtResult ActOnCapturedRegionEnd(Stmt *S)
Definition: SemaStmt.cpp:4944
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition: Sema.h:5934
@ ACK_Arithmetic
An arithmetic operation.
Definition: Sema.h:5936
@ ACK_CompAssign
A compound assignment expression.
Definition: Sema.h:5944
@ ACK_BitwiseOp
A bitwise operation.
Definition: Sema.h:5938
@ ACK_Conditional
A conditional (?:) operator.
Definition: Sema.h:5942
@ ACK_Comparison
A comparison.
Definition: Sema.h:5940
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
Definition: SemaDecl.cpp:4804
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
Definition: SemaExpr.cpp:20258
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
Definition: SemaDecl.cpp:15933
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:11745
ObjCMethodDecl * LookupImplementedMethodInGlobalPool(Selector Sel)
LookupImplementedMethodInGlobalPool - Returns the method which has an implementation.
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:9808
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, SourceLocation Loc)
DeclClonePragmaWeak - clone existing decl (maybe definition), #pragma weak needs a non-definition dec...
ObjCContainerDecl * getObjCDeclContext() const
Definition: SemaDecl.cpp:20655
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
bool CheckTypeConstraint(TemplateIdAnnotation *TypeConstraint)
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:2164
bool isKnownName(StringRef name)
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
Definition: SemaStmt.cpp:3338
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
Definition: Sema.h:6487
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:4339
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
Definition: SemaExpr.cpp:17010
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:2640
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition: Sema.h:5022
bool MSStructPragmaOn
Definition: Sema.h:1163
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:21227
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Definition: SemaType.cpp:9398
ExprResult TransformToPotentiallyEvaluated(Expr *E)
Definition: SemaExpr.cpp:17652
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:10275
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Definition: Sema.h:11840
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:15994
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:11121
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:10484
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:3161
@ NTK_Typedef
Definition: Sema.h:3166
@ NTK_NonUnion
Definition: Sema.h:3164
@ NTK_TypeAlias
Definition: Sema.h:3167
@ NTK_NonClass
Definition: Sema.h:3163
@ NTK_NonEnum
Definition: Sema.h:3165
@ NTK_NonStruct
Definition: Sema.h:3162
@ NTK_TemplateTemplateArgument
Definition: Sema.h:3170
@ NTK_TypeAliasTemplate
Definition: Sema.h:3169
@ NTK_Template
Definition: Sema.h:3168
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition: Sema.h:11720
void ActOnObjCContainerFinishDefinition()
Definition: SemaDecl.cpp:18451
SourceManager & getSourceManager() const
Definition: Sema.h:525
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
Definition: SemaModule.cpp:725
TryCaptureKind
Definition: Sema.h:5275
@ TryCapture_Implicit
Definition: Sema.h:5276
@ TryCapture_ExplicitByVal
Definition: Sema.h:5277
@ TryCapture_ExplicitByRef
Definition: Sema.h:5278
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:10004
bool isCFError(RecordDecl *D)
Definition: SemaType.cpp:4447
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition: Sema.h:6548
AssignmentAction
Definition: Sema.h:5196
@ AA_Returning
Definition: Sema.h:5199
@ AA_Passing_CFAudited
Definition: Sema.h:5204
@ AA_Initializing
Definition: Sema.h:5201
@ AA_Converting
Definition: Sema.h:5200
@ AA_Assigning
Definition: Sema.h:5197
@ AA_Passing
Definition: Sema.h:5198
@ AA_Casting
Definition: Sema.h:5203
@ AA_Sending
Definition: Sema.h:5202
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:3569
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:6886
ExprResult checkPseudoObjectRValue(Expr *E)
bool CheckVecStepExpr(Expr *E)
Definition: SemaExpr.cpp:4612
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:2593
ObjCCategoryDecl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, const IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
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)
void CodeCompleteBracketDeclarator(Scope *S)
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
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:4361
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:20327
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:1363
ClassTemplateDecl * lookupCoroutineTraits(SourceLocation KwLoc, SourceLocation FuncLoc)
Lookup 'coroutine_traits' in std namespace and std::experimental namespace.
StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)
Definition: SemaStmt.cpp:4365
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly.
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:9347
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:11293
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:3606
bool CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *MD, DefaultedComparisonKind DCK)
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, ObjCInterfaceDecl *ID)
DiagnoseClassExtensionDupMethods - Check for duplicate declaration of a class method in its extension...
ObjCInterfaceDecl * NSArrayDecl
The declaration of the Objective-C NSArray class.
Definition: Sema.h:12217
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:9166
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg)
Check a template argument against its corresponding template template parameter.
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:13082
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:10954
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:7356
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
Definition: SemaExpr.cpp:19867
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Definition: SemaType.cpp:9908
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:14039
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:18321
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:9503
void actOnDelayedExceptionSpecification(Decl *Method, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member function (or member function template).
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.
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc)
PragmaClangSection PragmaClangTextSection
Definition: Sema.h:1190
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
Definition: SemaExpr.cpp:21401
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
void WarnConflictingTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
CallExpr::ADLCallKind ADLCallKind
Definition: Sema.h:5563
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,...
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
NonTrivialCUnionKind
Definition: Sema.h:3026
@ NTCUK_Destruct
Definition: Sema.h:3028
@ NTCUK_Init
Definition: Sema.h:3027
@ NTCUK_Copy
Definition: Sema.h:3029
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:933
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:1300
QualType BuildAtomicType(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:10191
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:1187
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Definition: SemaExpr.cpp:20505
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Definition: SemaDecl.cpp:16022
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
Definition: SemaExpr.cpp:5714
llvm::Error isValidSectionSpecifier(StringRef Str)
Used to implement to perform semantic checking on attribute((section("foo"))) specifiers.
Decl * ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, ObjCPropertyQueryKind QueryKind)
ActOnPropertyImplDecl - This routine performs semantic checks and builds the AST node for a property ...
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:7152
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:14020
bool anyAltivecTypes(QualType srcType, QualType destType)
Definition: SemaExpr.cpp:7794
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:7840
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute.
Definition: SemaAttr.cpp:1380
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:1248
void keepInLifetimeExtendingContext()
keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext flag from previous context.
Definition: Sema.h:6342
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:2515
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition: Sema.cpp:2138
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:20598
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:1400
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:6813
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
Definition: Sema.h:12158
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
MaybeODRUseExprSet MaybeODRUseExprs
Definition: Sema.h:5020
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:530
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:811
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:1458
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:6815
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:227
static SourceRange getPrintable(SourceRange R)
Definition: Sema.h:11446
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:20582
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:8374
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:60
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:2058
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:11183
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition: SemaStmt.cpp:4316
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:4018
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed.
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition: Sema.h:11707
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition: Sema.h:708
void ActOnObjCReenterContainerContext(ObjCContainerDecl *ObjCCtx)
Definition: SemaDecl.cpp:18462
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15533
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:2686
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:2311
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:832
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:7942
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:6483
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
CorrectTypoKind
Definition: Sema.h:7603
@ CTK_NonError
Definition: Sema.h:7604
@ CTK_ErrorRecovery
Definition: Sema.h:7605
void CheckCompleteVariableDeclaration(VarDecl *VD)
Definition: SemaDecl.cpp:14430
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
Definition: SemaInit.cpp:3334
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
TUFragmentKind
Definition: Sema.h:606
@ Global
The global module fragment, between 'module;' and a module-declaration.
Definition: Sema.h:608
@ Private
The private module fragment, between 'module :private;' and the end of the translation unit.
Definition: Sema.h:615
@ Normal
A normal translation unit fragment.
Definition: Sema.h:612
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
void PopSatisfactionStackEntry()
Definition: Sema.h:11189
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
Definition: SemaType.cpp:2208
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:14953
void setFunctionHasBranchProtectedScope()
Definition: Sema.cpp:2301
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition: Sema.h:11766
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:4567
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:1864
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:4814
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
Definition: SemaStmt.cpp:4730
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:592
bool DeclareRISCVVBuiltins
Indicate RISC-V vector builtin functions enabled or not.
Definition: Sema.h:12820
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:11199
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:3378
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9971
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:8026
@ CCEK_StaticAssertMessageSize
Call to size() in a static assert message.
Definition: Sema.h:8033
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
Definition: Sema.h:8031
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
Definition: Sema.h:8032
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:8030
@ CCEK_CaseValue
Expression in a case label.
Definition: Sema.h:8027
@ CCEK_TemplateArg
Value of a non-type template parameter.
Definition: Sema.h:8029
@ CCEK_StaticAssertMessageData
Call to data() in a static assert message.
Definition: Sema.h:8035
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
Definition: Sema.h:8028
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:2774
ObjCInterfaceDecl * ActOnStartClassInterface(Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
ExprResult ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, SourceRange Range)
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
Definition: SemaStmt.cpp:1740
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
Definition: SemaDecl.cpp:19074
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:8685
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:1121
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
Definition: SemaDecl.cpp:3194
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:1946
ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition: Sema.h:2614
void actOnObjCTypeArgsOrProtocolQualifiers(Scope *S, ParsedType baseType, SourceLocation lAngleLoc, ArrayRef< IdentifierInfo * > identifiers, ArrayRef< SourceLocation > identifierLocs, SourceLocation rAngleLoc, SourceLocation &typeArgsLAngleLoc, SmallVectorImpl< ParsedType > &typeArgs, SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc, SmallVectorImpl< Decl * > &protocols, SourceLocation &protocolRAngleLoc, bool warnOnIncompleteProtocols)
Given a list of identifiers (and their locations), resolve the names to either Objective-C protocol q...
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:290
ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Definition: SemaDecl.cpp:19865
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
TypeResult actOnObjCProtocolQualifierType(SourceLocation lAngleLoc, ArrayRef< Decl * > protocols, ArrayRef< SourceLocation > protocolLocs, SourceLocation rAngleLoc)
Build a an Objective-C protocol-qualified 'id' type where no base type was specified.
Definition: SemaType.cpp:1121
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
Definition: SemaDecl.cpp:12680
ASTConsumer & Consumer
Definition: Sema.h:859
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
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:3424
const DeclContext * getCurObjCLexicalContext() const
Definition: Sema.h:5766
ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, SourceLocation EncodeLoc, SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc)
OverloadKind
Definition: Sema.h:7923
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
Definition: Sema.h:7934
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:7926
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:7930
PragmaAlignPackDiagnoseKind
Definition: Sema.h:1555
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:5192
void CodeCompleteObjCMethodDecl(Scope *S, std::optional< bool > IsInstanceMethod, ParsedType ReturnType)
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition: SemaExpr.cpp:120
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
Definition: SemaDecl.cpp:2103
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:897
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:10513
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Definition: SemaExpr.cpp:5356
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:7750
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:7766
@ 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 CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, const ObjCMethodDecl *PrevMethod, MethodMatchStrategy strategy=MMS_strict)
MatchTwoMethodDeclarations - Checks if two methods' type match and returns true, or 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:11445
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Definition: SemaExpr.cpp:3784
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
QualType GetSignedVectorType(QualType V)
Definition: SemaExpr.cpp:13023
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition: Sema.cpp:67
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
Definition: SemaStmt.cpp:4760
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition: Sema.h:834
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...
ObjCIvarDecl * GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const
GetIvarBackingPropertyAccessor - If method is a property setter/getter and it property has a backing ...
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:8648
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
Definition: SemaDecl.cpp:16691
void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool IncompleteImpl=false)
ImplMethodsVsClassMethods - This is main routine to warn if any method remains unimplemented in the c...
bool inferObjCARCLifetime(ValueDecl *decl)
Definition: SemaDecl.cpp:6981
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition: Sema.h:4964
@ 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 CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
Definition: SemaCast.cpp:2042
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:9876
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
Definition: Sema.h:10283
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:10135
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition: Sema.h:3554
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
Definition: Sema.h:3560
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition: Sema.h:3564
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition: Sema.h:3557
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition: Sema.h:3346
@ AMK_None
Don't merge availability attributes at all.
Definition: Sema.h:3348
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition: Sema.h:3354
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:3357
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition: Sema.h:3360
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition: Sema.h:3351
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
Definition: SemaDecl.cpp:15074
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
Definition: SemaExpr.cpp:6878
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4710
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
Definition: SemaExpr.cpp:4842
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
Definition: SemaType.cpp:6122
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
Definition: SemaDecl.cpp:14739
ExprResult BuildOperatorCoawaitLookupExpr(Scope *S, SourceLocation Loc)
std::pair< SourceLocation, bool > DeleteExprLoc
Definition: Sema.h:570
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:20511
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
Definition: SemaExpr.cpp:4449
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:17321
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:4886
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 addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
void CodeCompletePreprocessorMacroName(bool IsDefinition)
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:2151
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16762
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:398
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
Definition: SemaType.cpp:6235
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition: SemaStmt.cpp:78
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition: Sema.h:3581
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:9276
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Definition: SemaDecl.cpp:15449
void DiagnoseUseOfUnimplementedSelectors()
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Definition: Sema.h:830
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:1356
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaInternal.h:24
void DiagnoseUnterminatedPragmaAttribute()
Definition: SemaAttr.cpp:1145
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
Definition: SemaAttr.cpp:1251
bool SatisfactionStackContains(const NamedDecl *D, const llvm::FoldingSetNodeID &ID) const
Definition: Sema.h:11191
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
Definition: SemaExpr.cpp:21155
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:903
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:19320
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:19500
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Definition: SemaExpr.cpp:7977
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC #pragma optimize in scope,...
Definition: SemaAttr.cpp:1200
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
Definition: SemaAttr.cpp:1389
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Delete-expressions to be analyzed at the end of translation unit.
Definition: Sema.h:6494
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:11154
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:2633
ObjCPropertyDecl * CreatePropertyDecl(Scope *S, ObjCContainerDecl *CDecl, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc, Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite, const unsigned Attributes, const unsigned AttributesAsWritten, QualType T, TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
Called by ActOnProperty and HandlePropertyInClassExtension to handle creating the ObjcPropertyDecl fo...
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
void CodeCompleteObjCPropertyGetter(Scope *S)
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition: Sema.h:7902
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:8136
QualType getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType, CallingConv CC)
Get the return type to use for a lambda's conversion function(s) to function pointer type,...
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
Definition: SemaType.cpp:4263
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
Definition: Sema.h:6277
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition: Sema.cpp:81
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr)
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
Definition: Sema.h:12009
@ RTC_Incompatible
Definition: Sema.h:12011
@ RTC_Compatible
Definition: Sema.h:12010
@ RTC_Unknown
Definition: Sema.h:12012
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:2708
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:18177
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:10016
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
Definition: SemaExpr.cpp:19492
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:6438
void CodeCompleteObjCSelector(Scope *S, ArrayRef< const IdentifierInfo * > SelIdents)
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
Definition: SemaDecl.cpp:1328
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
Definition: SemaExpr.cpp:7889
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, bool &MemberOfUnknownSpecialization, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
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:7752
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
Definition: SemaType.cpp:9217
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
Definition: SemaStmt.cpp:623
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:10042
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition: Sema.h:861
MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec *SS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
TemplateNameIsRequiredTag
Definition: Sema.h:8852
@ TemplateNameIsRequired
Definition: Sema.h:8852
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:4933
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
Definition: SemaExpr.cpp:8050
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.
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.
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:5854
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:16079
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:4807
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:2414
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Definition: Sema.h:7453
DiagnosticsEngine & Diags
Definition: Sema.h:860
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
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:3405
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:5848
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:521
FPOptions CurFPFeatures
Definition: Sema.h:854
void ActOnStartSEHFinallyBlock()
Definition: SemaStmt.cpp:4722
void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI ABI)
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
static bool CanBeGetReturnObject(const FunctionDecl *FD)
Definition: SemaDecl.cpp:16075
NamespaceDecl * getStdNamespace() const
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9980
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition: Sema.h:4798
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
QualType AdjustParameterTypeForObjCAutoRefCount(QualType T, SourceLocation NameLoc, TypeSourceInfo *TSInfo)
Definition: SemaDecl.cpp:15333
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:6780
void CodeCompleteAfterFunctionEquals(Declarator &D)
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
Definition: SemaType.cpp:2503
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Definition: SemaExpr.cpp:527
PragmaStack< StringLiteral * > DataSegStack
Definition: Sema.h:1410
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:904
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:7824
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, ObjCMethodDecl *Getter, SourceLocation Loc)
@ TUK_Definition
Definition: Sema.h:3184
@ TUK_Declaration
Definition: Sema.h:3183
@ TUK_Friend
Definition: Sema.h:3185
@ TUK_Reference
Definition: Sema.h:3182
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Definition: SemaInit.cpp:10662
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Definition: SemaDecl.cpp:7398
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:15107
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:9003
@ TPC_ClassTemplate
Definition: Sema.h:9004
@ TPC_FriendFunctionTemplate
Definition: Sema.h:9009
@ TPC_ClassTemplateMember
Definition: Sema.h:9007
@ TPC_FunctionTemplate
Definition: Sema.h:9006
@ TPC_FriendClassTemplate
Definition: Sema.h:9008
@ TPC_FriendFunctionTemplateDefinition
Definition: Sema.h:9010
@ TPC_TypeAliasTemplate
Definition: Sema.h:9011
@ TPC_VarTemplate
Definition: Sema.h:9005
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
Definition: SemaAttr.cpp:1265
void ActOnAbortSEHFinallyBlock()
Definition: SemaStmt.cpp:4726
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:6867
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
Definition: SemaDecl.cpp:16538
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:2174
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:10635
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5788
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
void CodeCompleteObjCAtStatement(Scope *S)
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:20554
llvm::SmallPtrSet< Selector, 8 > SelectorSet
Definition: Sema.h:11856
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:1486
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:2121
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
friend class ArgumentPackSubstitutionRAII
Definition: Sema.h:10320
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:2356
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type,...
void PopDeclContext()
Definition: SemaDecl.cpp:1335
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
void CodeCompleteObjCInterfaceDecl(Scope *S)
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
ObjCMethodDecl * tryCaptureObjCSelf(SourceLocation Loc)
Try to capture an implicit reference to 'self'.
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)
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
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:3342
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13428
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:4826
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition: Sema.h:10250
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:16111
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
bool CheckObjCDeclScope(Decl *D)
Checks that the Objective-C declaration is declared in the global scope.
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:11436
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:999
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:6260
FormatStringType
Definition: Sema.h:1895
@ FST_NSString
Definition: Sema.h:1898
@ FST_Unknown
Definition: Sema.h:1905
@ FST_Strftime
Definition: Sema.h:1899
@ FST_Printf
Definition: Sema.h:1897
@ FST_FreeBSDKPrintf
Definition: Sema.h:1902
@ FST_Scanf
Definition: Sema.h:1896
@ FST_Strfmon
Definition: Sema.h:1900
@ FST_OSLog
Definition: Sema.h:1904
@ FST_Kprintf
Definition: Sema.h:1901
@ FST_OSTrace
Definition: Sema.h:1903
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:1161
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:1605
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:13143
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:816
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError=false)
Build an Objective-C type parameter type.
Definition: SemaType.cpp:1066
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
Definition: SemaType.cpp:2368
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...
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the numeric literal expression.
BuildForRangeKind
Definition: Sema.h:8575
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition: Sema.h:8583
@ BFRK_Build
Initial building of a for-range statement.
Definition: Sema.h:8577
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:8580
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
Definition: SemaExpr.cpp:9270
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Definition: Sema.h:12581
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:4431
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:14062
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:13226
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:1588
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
Definition: SemaDecl.cpp:16963
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:9890
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
Definition: Sema.cpp:2343
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition: SemaStmt.cpp:547
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
Definition: SemaExpr.cpp:16573
OffsetOfKind
Definition: Sema.h:3188
@ OOK_Outside
Definition: Sema.h:3190
@ OOK_Macro
Definition: Sema.h:3195
@ OOK_Builtin
Definition: Sema.h:3192
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
Definition: SemaDecl.cpp:13502
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
Definition: SemaType.cpp:9770
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
PragmaSectionKind
Definition: Sema.h:1430
@ PSK_ConstSeg
Definition: Sema.h:1433
@ PSK_DataSeg
Definition: Sema.h:1431
@ PSK_CodeSeg
Definition: Sema.h:1434
@ PSK_BSSSeg
Definition: Sema.h:1432
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:20281
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:297
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
Definition: SemaExpr.cpp:17125
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:4628
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:18576
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:18360
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
Definition: SemaExpr.cpp:16155
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:4993
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
Definition: SemaDecl.cpp:4397
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:14347
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:6138
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
Definition: SemaLambda.cpp:280
bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
Definition: SemaExpr.cpp:17051
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
Definition: SemaType.cpp:2905
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
Definition: SemaExpr.cpp:20612
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:2608
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:21454
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:9305
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, Expr *BaseExpr, SourceLocation OpLoc, DeclarationName MemberName, SourceLocation MemberLoc, SourceLocation SuperLoc, QualType SuperType, bool Super)
HandleExprPropertyRefExpr - Handle foo.bar where foo is a pointer to an objective C interface.
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15596
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:1186
Decl * ActOnDeclarator(Scope *S, Declarator &D)
Definition: SemaDecl.cpp:6166
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3920
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:920
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition: SemaStmt.cpp:4305
AbstractDiagSelID
Definition: Sema.h:4583
@ AbstractSynthesizedIvarType
Definition: Sema.h:4590
@ AbstractVariableType
Definition: Sema.h:4587
@ AbstractReturnType
Definition: Sema.h:4585
@ AbstractNone
Definition: Sema.h:4584
@ AbstractFieldType
Definition: Sema.h:4588
@ AbstractArrayType
Definition: Sema.h:4591
@ AbstractParamType
Definition: Sema.h:4586
@ AbstractIvarType
Definition: Sema.h:4589
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:3212
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:908
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
bool 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:7437
void CodeCompletePreprocessorDirective(bool InConditional)
PragmaOptionsAlignKind
Definition: Sema.h:1525
@ POAK_Power
Definition: Sema.h:1529
@ POAK_Reset
Definition: Sema.h:1531
@ POAK_Packed
Definition: Sema.h:1528
@ POAK_Mac68k
Definition: Sema.h:1530
@ POAK_Natural
Definition: Sema.h:1527
@ POAK_Native
Definition: Sema.h:1526
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:16411
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:94
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
Definition: SemaExpr.cpp:5066
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:1728
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition: Sema.h:6480
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:1257
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
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:15065
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
ExprResult BuildClassMessageImplicit(QualType ReceiverType, bool isSuperReceiver, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI)
Note that we have finished the explicit captures for the given lambda.
Definition: SemaLambda.cpp:500
ObjCSubscriptKind
Definition: Sema.h:8459
@ OS_Array
Definition: Sema.h:8459
@ OS_Dictionary
Definition: Sema.h:8459
@ OS_Error
Definition: Sema.h:8459
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:10109
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
Definition: SemaExpr.cpp:9545
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:1280
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:8364
SwiftNameAttr * mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name)
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
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:1151
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:6618
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:4916
QualType PreferredConditionType(ConditionKind K) const
Definition: Sema.h:6010
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.
ObjCMessageKind
Describes the kind of message expression indicated by a message send that starts with an identifier.
Definition: Sema.h:12304
@ ObjCSuperMessage
The message is sent to 'super'.
Definition: Sema.h:12306
@ ObjCClassMessage
The message is a class message, and the identifier is a type name.
Definition: Sema.h:12311
@ ObjCInstanceMessage
The message is an instance message.
Definition: Sema.h:12308
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
Definition: Sema.h:7425
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition: Sema.h:7429
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition: Sema.h:7435
@ LOLR_Error
The lookup resulted in an error.
Definition: Sema.h:7427
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:7432
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition: Sema.h:7443
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:7439
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Definition: SemaDecl.cpp:20637
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition: Sema.cpp:2331
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Definition: SemaExpr.cpp:16440
void CodeCompletePreprocessorExpression()
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:10993
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar)
CheckConstexprKind
Definition: Sema.h:4734
@ 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:10509
void CheckVariableDeclarationType(VarDecl *NewVD)
Definition: SemaDecl.cpp:8705
sema::CompoundScopeInfo & getCurCompoundScope() const
Definition: SemaStmt.cpp:410
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:2700
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:850
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
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
Definition: SemaDecl.cpp:18959
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
Definition: SemaInit.cpp:10647
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
Definition: SemaDecl.cpp:1342
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:13192
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:1351
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:3222
ObjCMethodDecl * DictionaryWithObjectsMethod
The declaration of the dictionaryWithObjects:forKeys:count: method.
Definition: Sema.h:12226
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:2589
void ActOnFinishOfCompoundStmt()
Definition: SemaStmt.cpp:406
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 CheckForwardProtocolDeclarationForCircularDependency(IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, const ObjCList< ObjCProtocolDecl > &PList)
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
Definition: SemaExpr.cpp:21420
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:1184
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:15959
ObjCSpecialMethodKind
Definition: Sema.h:11804
@ OSMK_Copy
Definition: Sema.h:11808
@ OSMK_NonRetainingInit
Definition: Sema.h:11810
@ OSMK_RetainingInit
Definition: Sema.h:11809
@ OSMK_None
Definition: Sema.h:11805
@ OSMK_Alloc
Definition: Sema.h:11806
@ OSMK_New
Definition: Sema.h:11807
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:11653
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:13478
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:11426
static ConditionResult ConditionError()
Definition: Sema.h:5885
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition: SemaStmt.cpp:414
void NoteTemplateParameterLocation(const NamedDecl &Decl)
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
Definition: SemaExpr.cpp:6905
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)
AttributeCompletion
Definition: Sema.h:12653
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:2537
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:10246
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
Definition: SemaExpr.cpp:21159
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition: SemaStmt.cpp:4421
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:20298
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:6000
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
Definition: SemaExpr.cpp:16353
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:2292
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:572
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition: Sema.h:8817
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:4559
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:5841
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:700
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:15307
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:6446
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:849
ObjCInterfaceDecl * NSValueDecl
The declaration of the Objective-C NSValue class.
Definition: Sema.h:12193
static int getPrintable(int I)
Definition: Sema.h:11435
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
QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr)
Definition: SemaType.cpp:9793
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
Definition: Sema.h:7561
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, ArrayRef< IdentifierLocPair > ProtocolId, SmallVectorImpl< Decl * > &Protocols)
FindProtocolDeclaration - This routine looks up protocols and issues an error if they are not declare...
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:9722
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition: SemaStmt.cpp:552
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
ObjCContainerKind getObjCContainerKind() const
ExprResult ActOnCXXThis(SourceLocation Loc)
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
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:2880
bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, QualType SrcTy)
Definition: SemaCast.cpp:2703
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:18185
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:11440
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:1169
@ PCSK_Invalid
Definition: Sema.h:1170
@ PCSK_BSS
Definition: Sema.h:1171
@ PCSK_Data
Definition: Sema.h:1172
@ PCSK_Text
Definition: Sema.h:1174
@ PCSK_Relro
Definition: Sema.h:1175
@ PCSK_Rodata
Definition: Sema.h:1173
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7369
void warnOnReservedIdentifier(const NamedDecl *D)
Definition: SemaDecl.cpp:6153
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition: SemaStmt.cpp:515
bool isCheckingDefaultArgumentOrInitializer() const
Definition: Sema.h:6301
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:17039
void ActOnObjCTemporaryExitContainerContext(ObjCContainerDecl *ObjCCtx)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
Definition: SemaDecl.cpp:18456
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:7566
ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C instance message expression.
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.
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
static const char * getPrintable(const char *S)
Definition: Sema.h:11438
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto)
CheckFunctionCall - Check a direct function call for various correctness and safety properties not st...
void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl, SourceLocation AtEnd)
DefaultSynthesizeProperties - This routine default synthesizes all properties which must be synthesiz...
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:3142
void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl< ObjCMethodDecl * > &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass)
AllocationFunctionScope
The scope in which to find allocation functions.
Definition: Sema.h:6655
@ AFS_Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition: Sema.h:6663
@ AFS_Class
Only look for allocation functions in the scope of the allocated class.
Definition: Sema.h:6660
@ AFS_Global
Only look for allocation functions in the global scope.
Definition: Sema.h:6657
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:5584
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression)
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:550
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Definition: SemaType.cpp:3205
PragmaMsStackAction
Definition: Sema.h:1192
@ PSK_Push_Set
Definition: Sema.h:1198
@ PSK_Reset
Definition: Sema.h:1193
@ PSK_Pop_Set
Definition: Sema.h:1199
@ PSK_Show
Definition: Sema.h:1197
@ PSK_Pop
Definition: Sema.h:1196
@ PSK_Set
Definition: Sema.h:1194
@ PSK_Push
Definition: Sema.h:1195
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3305
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:6733
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:5241
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Definition: SemaDecl.cpp:1284
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
ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
ParseObjCSelectorExpression - Build selector expression for @selector.
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:3585
Exposes information about the current target.
Definition: TargetInfo.h:213
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:4458
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:3391
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:7326
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:2454
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3535
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3433
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:1024
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3173
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3912
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:3965
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2778
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Definition: Lookup.h:834
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.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
void threadSafetyCleanup(BeforeSet *Cache)
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
Definition: TokenKinds.h:41
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:1881
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:131
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
ObjCPropertyQueryKind
Definition: DeclObjC.h:718
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:1532
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:2822
@ CopyInit
[a = b], [a = {b}]
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ Property
The type of a property.
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:3511
ParameterABI
Kinds of parameter ABI.
Definition: Specifiers.h:363
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
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:6295
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:1036
@ TU_Complete
The translation unit is a complete translation unit.
Definition: LangOptions.h:1038
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:1042
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:431
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:244
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:373
@ 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
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
Definition: DeclObjC.h:553
SourceLocIdentKind
Definition: Expr.h:4714
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:6270
@ 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:442
@ 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:5394
#define true
Definition: stdbool.h:21
#define false
Definition: stdbool.h:22
#define bool
Definition: stdbool.h:20
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...
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
Definition: DeclSpec.h:1329
A structure used to record information about a failed template argument deduction,...
This little struct is used to capture information about structure field declarators,...
Definition: DeclSpec.h:2768
Describes whether we've seen any nullability information for the given file.
Definition: Sema.h:248
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition: Sema.h:255
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition: Sema.h:251
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition: Sema.h:261
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition: Sema.h:258
Holds information about the various types of exception specification.
Definition: Type.h:4703
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:4705
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:4708
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:4711
Extra information about a function prototype.
Definition: Type.h:4731
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:100
Represents a complete lambda introducer.
Definition: DeclSpec.h:2830
Contains a late templated function.
Definition: Sema.h:12837
CachedTokens Toks
Definition: Sema.h:12838
FPOptions FPO
Floating-point options in the point of definition.
Definition: Sema.h:12842
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:12840
A normalized constraint, as defined in C++ [temp.constr.normal], is either an atomic constraint,...
Definition: SemaConcept.h:81
a linked list of methods with the same selector name but different signatures.
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1405
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:9804
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:9965
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:9918
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:9934
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:9960
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:9953
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition: Sema.h:9929
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:9921
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition: Sema.h:9947
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition: Sema.h:9937
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:9944
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:9806
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition: Sema.h:9898
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition: Sema.h:9816
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition: Sema.h:9825
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:9844
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition: Sema.h:9895
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:9852
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition: Sema.h:9859
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition: Sema.h:9902
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:9870
@ Memoization
Added for Template instantiation observation.
Definition: Sema.h:9908
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition: Sema.h:9835
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition: Sema.h:9914
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition: Sema.h:9911
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:9832
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:9840
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:9848
@ TemplateInstantiation
We are instantiating a template declaration.
Definition: Sema.h:9809
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition: Sema.h:9862
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition: Sema.h:9866
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition: Sema.h:9821
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:9892
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition: Sema.h:9855
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:9924
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition: Sema.h:9950
ConstraintEvalRAII(InstTy &TI)
Definition: Sema.h:10392
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition: Sema.h:5113
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:5026
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:5058
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition: Sema.h:5060
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:5050
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:5054
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition: Sema.h:5065
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:5073
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition: Sema.h:5069
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition: Sema.h:5079
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:5045
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:5083
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:5031
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:5039
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition: Sema.h:5123
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:5125
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:5028
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:5035
FormatArgumentPassingKind ArgPassingKind
Definition: Sema.h:1883
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:878
A stack object to be created when performing template instantiation.
Definition: Sema.h:9989
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:10143
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:10147
LocalInstantiationScope * Scope
Definition: Sema.h:10628
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:10631
bool isMoveEligible() const
Definition: Sema.h:8612
bool isCopyElidable() const
Definition: Sema.h:8613
const VarDecl * Candidate
Definition: Sema.h:8607
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2381
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition: Sema.h:2387
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:2396
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:2390
SourceLocation CCLoc
The location of the '::'.
Definition: Sema.h:2393
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition: Sema.h:2384
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:2402
IdentifierInfo * Name
Definition: Sema.h:11975
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.
Definition: Sema.h:11983
ObjCDeclSpec DeclSpec
Definition: Sema.h:11980
SourceLocation NameLoc
Definition: Sema.h:11976
SourceLocation LocEnd
Definition: Sema.h:5630
IdentifierInfo * IdentInfo
Definition: Sema.h:5633
brief A function argument from which we performed template argument
Definition: Sema.h:9617
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition: Sema.h:9618
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:1461
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:1464
A push'd group of PragmaAttributeEntries.
Definition: Sema.h:1469
SourceLocation Loc
The location of the push attribute.
Definition: Sema.h:1471
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition: Sema.h:1474
const IdentifierInfo * Namespace
The namespace of this push group.
Definition: Sema.h:1473
SourceLocation PragmaLocation
Definition: Sema.h:1183
PragmaMsStackAction Action
Definition: Sema.h:1203
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:1316
llvm::StringRef StackSlotLabel
Definition: Sema.h:1312
SourceLocation PragmaLocation
Definition: Sema.h:1314
SourceLocation PragmaPushLocation
Definition: Sema.h:1315
ValueType CurrentValue
Definition: Sema.h:1386
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:1372
bool hasValue() const
Definition: Sema.h:1382
SmallVector< Slot, 2 > Stack
Definition: Sema.h:1384
ValueType DefaultValue
Definition: Sema.h:1385
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1387
PragmaStack(const ValueType &Default)
Definition: Sema.h:1379
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition: Sema.h:1323
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition: Sema.h:3794
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition: Sema.h:3788
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition: Sema.h:8156
Abstract class used to diagnose incomplete types.
Definition: Sema.h:6379
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
virtual ~TypeDiagnoser()
Definition: Sema.h:6383
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:1924
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition: Sema.h:1933
std::unique_ptr< TypoCorrectionConsumer > Consumer
Definition: Sema.h:7643
TypoDiagnosticGenerator DiagHandler
Definition: Sema.h:7644
TypoRecoveryCallback RecoveryHandler
Definition: Sema.h:7645
bool CheckSameAsPrevious
Definition: Sema.h:359
NamedDecl * Previous
Definition: Sema.h:360
SkipBodyInfo()=default
NamedDecl * New
Definition: Sema.h:361
Information about a template-id annotation token.