clang 23.0.0git
Sema.h
Go to the documentation of this file.
1//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the Sema class, which performs semantic analysis and
10// builds ASTs.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SEMA_SEMA_H
15#define LLVM_CLANG_SEMA_SEMA_H
16
18#include "clang/AST/ASTFwd.h"
19#include "clang/AST/ASTLambda.h"
20#include "clang/AST/Attr.h"
22#include "clang/AST/CharUnits.h"
23#include "clang/AST/DeclBase.h"
24#include "clang/AST/DeclCXX.h"
27#include "clang/AST/Expr.h"
28#include "clang/AST/ExprCXX.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/Type.h"
35#include "clang/AST/TypeLoc.h"
40#include "clang/Basic/Cuda.h"
44#include "clang/Basic/LLVM.h"
45#include "clang/Basic/Lambda.h"
47#include "clang/Basic/Module.h"
59#include "clang/Sema/Attr.h"
61#include "clang/Sema/DeclSpec.h"
67#include "clang/Sema/Scope.h"
68#include "clang/Sema/SemaBase.h"
72#include "clang/Sema/Weak.h"
73#include "llvm/ADT/APInt.h"
74#include "llvm/ADT/ArrayRef.h"
75#include "llvm/ADT/BitmaskEnum.h"
76#include "llvm/ADT/DenseMap.h"
77#include "llvm/ADT/DenseSet.h"
78#include "llvm/ADT/FloatingPointMode.h"
79#include "llvm/ADT/FoldingSet.h"
80#include "llvm/ADT/MapVector.h"
81#include "llvm/ADT/PointerIntPair.h"
82#include "llvm/ADT/PointerUnion.h"
83#include "llvm/ADT/STLExtras.h"
84#include "llvm/ADT/STLForwardCompat.h"
85#include "llvm/ADT/STLFunctionalExtras.h"
86#include "llvm/ADT/SetVector.h"
87#include "llvm/ADT/SmallBitVector.h"
88#include "llvm/ADT/SmallPtrSet.h"
89#include "llvm/ADT/SmallSet.h"
90#include "llvm/ADT/SmallVector.h"
91#include "llvm/ADT/StringExtras.h"
92#include "llvm/ADT/StringMap.h"
93#include "llvm/ADT/TinyPtrVector.h"
94#include "llvm/Support/Allocator.h"
95#include "llvm/Support/Compiler.h"
96#include "llvm/Support/Error.h"
97#include "llvm/Support/ErrorHandling.h"
98#include <cassert>
99#include <climits>
100#include <cstddef>
101#include <cstdint>
102#include <deque>
103#include <functional>
104#include <iterator>
105#include <memory>
106#include <optional>
107#include <string>
108#include <tuple>
109#include <type_traits>
110#include <utility>
111#include <vector>
112
113namespace llvm {
114struct InlineAsmIdentifierInfo;
115} // namespace llvm
116
117namespace clang {
118class ADLResult;
119class APValue;
121class ASTConsumer;
122class ASTContext;
123class ASTDeclReader;
125class ASTReader;
126class ASTWriter;
127class CXXBasePath;
128class CXXBasePaths;
131enum class ComparisonCategoryType : unsigned char;
133class DarwinSDKInfo;
134class DeclGroupRef;
138class Designation;
139class IdentifierInfo;
145enum class LangAS : unsigned int;
147class LookupResult;
150class ModuleLoader;
154class ObjCMethodDecl;
155struct OverloadCandidate;
156enum class OverloadCandidateParamOrder : char;
157enum OverloadCandidateRewriteKind : unsigned;
159class Preprocessor;
160class SemaAMDGPU;
161class SemaARM;
162class SemaAVR;
163class SemaBPF;
165class SemaCUDA;
166class SemaDirectX;
167class SemaHLSL;
168class SemaHexagon;
169class SemaLoongArch;
170class SemaM68k;
171class SemaMIPS;
172class SemaMSP430;
173class SemaNVPTX;
174class SemaObjC;
175class SemaOpenACC;
176class SemaOpenCL;
177class SemaOpenMP;
178class SemaPPC;
179class SemaPseudoObject;
180class SemaRISCV;
181class SemaSPIRV;
182class SemaSYCL;
183class SemaSwift;
184class SemaSystemZ;
185class SemaWasm;
186class SemaX86;
188class TemplateArgument;
193class Token;
194class TypeConstraint;
199
200namespace sema {
201class BlockScopeInfo;
202class Capture;
209class LambdaScopeInfo;
210class SemaPPCallbacks;
212} // namespace sema
213
214// AssignmentAction - This is used by all the assignment diagnostic functions
215// to represent what is actually causing the operation
226
227namespace threadSafety {
228class BeforeSet;
229void threadSafetyCleanup(BeforeSet *Cache);
230} // namespace threadSafety
231
232// FIXME: No way to easily map from TemplateTypeParmTypes to
233// TemplateTypeParmDecls, so we have this horrible PointerUnion.
234typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *,
235 const TemplateSpecializationType *,
236 const SubstBuiltinTemplatePackType *>,
239
240/// Describes whether we've seen any nullability information for the given
241/// file.
243 /// The first pointer declarator (of any pointer kind) in the file that does
244 /// not have a corresponding nullability annotation.
246
247 /// The end location for the first pointer declarator in the file. Used for
248 /// placing fix-its.
250
251 /// Which kind of pointer declarator we saw.
252 uint8_t PointerKind;
253
254 /// Whether we saw any type nullability annotations in the given file.
255 bool SawTypeNullability = false;
256};
257
258/// A mapping from file IDs to a record of whether we've seen nullability
259/// information in that file.
261 /// A mapping from file IDs to the nullability information for each file ID.
262 llvm::DenseMap<FileID, FileNullability> Map;
263
264 /// A single-element cache based on the file ID.
265 struct {
268 } Cache;
269
270public:
272 // Check the single-element cache.
273 if (file == Cache.File)
274 return Cache.Nullability;
275
276 // It's not in the single-element cache; flush the cache if we have one.
277 if (!Cache.File.isInvalid()) {
278 Map[Cache.File] = Cache.Nullability;
279 }
280
281 // Pull this entry into the cache.
282 Cache.File = file;
283 Cache.Nullability = Map[file];
284 return Cache.Nullability;
285 }
286};
287
288/// Tracks expected type during expression parsing, for use in code completion.
289/// The type is tied to a particular token, all functions that update or consume
290/// the type take a start location of the token they are looking at as a
291/// parameter. This avoids updating the type on hot paths in the parser.
293public:
295 : Ctx(Ctx), Enabled(Enabled) {}
296
300 /// Handles e.g. BaseType{ .D = Tok...
302 const Designation &D);
303 /// Computing a type for the function argument may require running
304 /// overloading, so we postpone its computation until it is actually needed.
305 ///
306 /// Clients should be very careful when using this function, as it stores a
307 /// function_ref, clients should make sure all calls to get() with the same
308 /// location happen while function_ref is alive.
309 ///
310 /// The callback should also emit signature help as a side-effect, but only
311 /// if the completion point has been reached.
313 llvm::function_ref<QualType()> ComputeType);
314
317 SourceLocation OpLoc);
320 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
321 /// Handles all type casts, including C-style cast, C++ casts, etc.
323
324 /// Get the expected type associated with this location, if any.
325 ///
326 /// If the location is a function argument, determining the expected type
327 /// involves considering all function overloads and the arguments so far.
328 /// In this case, signature help for these function overloads will be reported
329 /// as a side-effect (only if the completion point has been reached).
331 if (!Enabled || Tok != ExpectedLoc)
332 return QualType();
333 if (!Type.isNull())
334 return Type;
335 if (ComputeType)
336 return ComputeType();
337 return QualType();
338 }
339
340private:
341 ASTContext *Ctx;
342 bool Enabled;
343 /// Start position of a token for which we store expected type.
344 SourceLocation ExpectedLoc;
345 /// Expected type for a token starting at ExpectedLoc.
347 /// A function to compute expected type at ExpectedLoc. It is only considered
348 /// if Type is null.
349 llvm::function_ref<QualType()> ComputeType;
350};
351
353 SkipBodyInfo() = default;
354 bool ShouldSkip = false;
356 NamedDecl *Previous = nullptr;
357 NamedDecl *New = nullptr;
358};
359
360/// Describes the result of template argument deduction.
361///
362/// The TemplateDeductionResult enumeration describes the result of
363/// template argument deduction, as returned from
364/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
365/// structure provides additional information about the results of
366/// template argument deduction, e.g., the deduced template argument
367/// list (if successful) or the specific template parameters or
368/// deduced arguments that were involved in the failure.
370 /// Template argument deduction was successful.
372 /// The declaration was invalid; do nothing.
374 /// Template argument deduction exceeded the maximum template
375 /// instantiation depth (which has already been diagnosed).
377 /// Template argument deduction did not deduce a value
378 /// for every template parameter.
380 /// Template argument deduction did not deduce a value for every
381 /// expansion of an expanded template parameter pack.
383 /// Template argument deduction produced inconsistent
384 /// deduced values for the given template parameter.
386 /// Template argument deduction failed due to inconsistent
387 /// cv-qualifiers on a template parameter type that would
388 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
389 /// but were given a non-const "X".
391 /// Substitution of the deduced template argument values
392 /// resulted in an error.
394 /// After substituting deduced template arguments, a dependent
395 /// parameter type did not match the corresponding argument.
397 /// After substituting deduced template arguments, an element of
398 /// a dependent parameter type did not match the corresponding element
399 /// of the corresponding argument (when deducing from an initializer list).
401 /// A non-depnedent component of the parameter did not match the
402 /// corresponding component of the argument.
404 /// When performing template argument deduction for a function
405 /// template, there were too many call arguments.
407 /// When performing template argument deduction for a function
408 /// template, there were too few call arguments.
410 /// The explicitly-specified template arguments were not valid
411 /// template arguments for the given template.
413 /// Checking non-dependent argument conversions failed.
415 /// The deduced arguments did not satisfy the constraints associated
416 /// with the template.
418 /// Deduction failed; that's all we know.
420 /// CUDA Target attributes do not match.
422 /// Some error which was already diagnosed.
424};
425
426/// Kinds of C++ special members.
436
437/// The kind of conversion being performed.
439 /// An implicit conversion.
441 /// A C-style cast.
443 /// A functional-style cast.
445 /// A cast other than a C-style cast.
447 /// A conversion for an operand of a builtin overloaded operator.
449};
450
451enum class TagUseKind {
452 Reference, // Reference to a tag: 'struct foo *X;'
453 Declaration, // Fwd decl of a tag: 'struct foo;'
454 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
455 Friend // Friend declaration: 'friend struct foo;'
456};
457
458/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
459enum class FunctionEffectMode : uint8_t {
460 None, // effect is not present.
461 False, // effect(false).
462 True, // effect(true).
463 Dependent // effect(expr) where expr is dependent.
464};
465
466/// pragma clang section kind
469 BSS = 1,
470 Data = 2,
472 Text = 4,
474};
475
476enum class PragmaClangSectionAction { Set = 0, Clear = 1 };
477
479 Native, // #pragma options align=native
480 Natural, // #pragma options align=natural
481 Packed, // #pragma options align=packed
482 Power, // #pragma options align=power
483 Mac68k, // #pragma options align=mac68k
484 Reset // #pragma options align=reset
485};
486
487enum class TUFragmentKind {
488 /// The global module fragment, between 'module;' and a module-declaration.
490 /// A normal translation unit fragment. For a non-module unit, this is the
491 /// entire translation unit. Otherwise, it runs from the module-declaration
492 /// to the private-module-fragment (if any) or the end of the TU (if not).
494 /// The private module fragment, between 'module :private;' and the end of
495 /// the translation unit.
497};
498
511
512// Used for emitting the right warning by DefaultVariadicArgumentPromotion
520
529
530// Contexts where using non-trivial C union types can be disallowed. This is
531// passed to err_non_trivial_c_union_in_invalid_context.
533 // Function parameter.
535 // Function return.
537 // Default-initialized object.
539 // Variable with automatic storage duration.
541 // Initializer expression that might copy from another object.
543 // Assignment.
545 // Compound literal.
547 // Block capture.
549 // lvalue-to-rvalue conversion of volatile type.
551};
552
553/// Describes the result of the name lookup and resolution performed
554/// by \c Sema::ClassifyName().
556 /// This name is not a type or template in this context, but might be
557 /// something else.
559 /// Classification failed; an error has been produced.
561 /// The name has been typo-corrected to a keyword.
563 /// The name was classified as a type.
565 /// The name was classified as a specific non-type, non-template
566 /// declaration. ActOnNameClassifiedAsNonType should be called to
567 /// convert the declaration to an expression.
569 /// The name was classified as an ADL-only function name.
570 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
571 /// result to an expression.
573 /// The name denotes a member of a dependent type that could not be
574 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
575 /// convert the result to an expression.
577 /// The name was classified as an overload set, and an expression
578 /// representing that overload set has been formed.
579 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
580 /// expression referencing the overload set.
582 /// The name was classified as a template whose specializations are types.
584 /// The name was classified as a variable template name.
586 /// The name was classified as a function template name.
588 /// The name was classified as an ADL-only function template name.
590 /// The name was classified as a concept name.
592};
593
595 // Address discrimination argument of __ptrauth.
597
598 // Extra discriminator argument of __ptrauth.
600};
601
602/// Common ways to introduce type names without a tag for use in diagnostics.
603/// Keep in sync with err_tag_reference_non_tag.
615
616enum class OffsetOfKind {
617 // Not parsing a type within __builtin_offsetof.
619 // Parsing a type within __builtin_offsetof.
621 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
622 // To improve our diagnostic message.
624};
625
626/// Describes the kind of merge to perform for availability
627/// attributes (including "deprecated", "unavailable", and "availability").
629 /// Don't merge availability attributes at all.
631 /// Merge availability attributes for a redeclaration, which requires
632 /// an exact match.
634 /// Merge availability attributes for an override, which requires
635 /// an exact match or a weakening of constraints.
637 /// Merge availability attributes for an implementation of
638 /// a protocol requirement.
640 /// Merge availability attributes for an implementation of
641 /// an optional protocol requirement.
643};
644
646 /// The triviality of a method unaffected by "trivial_abi".
648
649 /// The triviality of a method affected by "trivial_abi".
651};
652
654
655enum class AllowFoldKind {
658};
659
660/// Context in which we're performing a usual arithmetic conversion.
661enum class ArithConvKind {
662 /// An arithmetic operation.
664 /// A bitwise operation.
666 /// A comparison.
668 /// A conditional (?:) operator.
670 /// A compound assignment expression.
672};
673
674// Used for determining in which context a type is allowed to be passed to a
675// vararg function.
683
684/// AssignConvertType - All of the 'assignment' semantic checks return this
685/// enum to indicate whether the assignment was allowed. These checks are
686/// done for simple assignments, as well as initialization, return from
687/// function, argument passing, etc. The query is phrased in terms of a
688/// source and destination type.
690 /// Compatible - the types are compatible according to the standard.
692
693 /// CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because
694 /// a void * can implicitly convert to another pointer type, which we
695 /// differentiate for better diagnostic behavior.
697
698 /// PointerToInt - The assignment converts a pointer to an int, which we
699 /// accept as an extension.
701
702 /// IntToPointer - The assignment converts an int to a pointer, which we
703 /// accept as an extension.
705
706 /// FunctionVoidPointer - The assignment is between a function pointer and
707 /// void*, which the standard doesn't allow, but we accept as an extension.
709
710 /// IncompatiblePointer - The assignment is between two pointers types that
711 /// are not compatible, but we accept them as an extension.
713
714 /// IncompatibleFunctionPointer - The assignment is between two function
715 /// pointers types that are not compatible, but we accept them as an
716 /// extension.
718
719 /// IncompatibleFunctionPointerStrict - The assignment is between two
720 /// function pointer types that are not identical, but are compatible,
721 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
722 /// may trip an indirect call runtime check.
724
725 /// IncompatiblePointerSign - The assignment is between two pointers types
726 /// which point to integers which have a different sign, but are otherwise
727 /// identical. This is a subset of the above, but broken out because it's by
728 /// far the most common case of incompatible pointers.
730
731 /// CompatiblePointerDiscardsQualifiers - The assignment discards
732 /// c/v/r qualifiers, which we accept as an extension.
734
735 /// IncompatiblePointerDiscardsQualifiers - The assignment
736 /// discards qualifiers that we don't permit to be discarded,
737 /// like address spaces.
739
740 /// IncompatiblePointerDiscardsOverflowBehavior - The assignment
741 /// discards overflow behavior annotations between otherwise compatible
742 /// pointer types.
744
745 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
746 /// changes address spaces in nested pointer types which is not allowed.
747 /// For instance, converting __private int ** to __generic int ** is
748 /// illegal even though __private could be converted to __generic.
750
751 /// IncompatibleNestedPointerQualifiers - The assignment is between two
752 /// nested pointer types, and the qualifiers other than the first two
753 /// levels differ e.g. char ** -> const char **, but we accept them as an
754 /// extension.
756
757 /// IncompatibleVectors - The assignment is between two vector types that
758 /// have the same size, which we accept as an extension.
760
761 /// IntToBlockPointer - The assignment converts an int to a block
762 /// pointer. We disallow this.
764
765 /// IncompatibleBlockPointer - The assignment is between two block
766 /// pointers types that are not compatible.
768
769 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
770 /// id type and something else (that is incompatible with it). For example,
771 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
773
774 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
775 /// object with __weak qualifier.
777
778 /// IncompatibleOBTKinds - Assigning between incompatible OverflowBehaviorType
779 /// kinds, e.g., from __ob_trap to __ob_wrap or vice versa.
781
782 /// CompatibleOBTDiscards - Assignment discards overflow behavior
784
785 /// Incompatible - We reject this conversion outright, it is invalid to
786 /// represent it in the AST.
788};
789
790/// The scope in which to find allocation functions.
792 /// Only look for allocation functions in the global scope.
794 /// Only look for allocation functions in the scope of the
795 /// allocated class.
797 /// Look for allocation functions in both the global scope
798 /// and in the scope of the allocated class.
800};
801
802/// Describes the result of an "if-exists" condition check.
803enum class IfExistsResult {
804 /// The symbol exists.
806
807 /// The symbol does not exist.
809
810 /// The name is a dependent name, so the results will differ
811 /// from one instantiation to the next.
813
814 /// An error occurred.
816};
817
818enum class CorrectTypoKind {
819 NonError, // CorrectTypo used in a non error recovery situation.
820 ErrorRecovery // CorrectTypo used in normal error recovery.
821};
822
823enum class OverloadKind {
824 /// This is a legitimate overload: the existing declarations are
825 /// functions or function templates with different signatures.
827
828 /// This is not an overload because the signature exactly matches
829 /// an existing declaration.
831
832 /// This is not an overload because the lookup results contain a
833 /// non-function.
835};
836
837/// Contexts in which a converted constant expression is required.
838enum class CCEKind {
839 CaseValue, ///< Expression in a case label.
840 Enumerator, ///< Enumerator value with fixed underlying type.
841 TemplateArg, ///< Value of a non-type template parameter.
842 TempArgStrict, ///< As above, but applies strict template checking
843 ///< rules.
844 ArrayBound, ///< Array bound in array declarator or new-expression.
845 ExplicitBool, ///< Condition in an explicit(bool) specifier.
846 Noexcept, ///< Condition in a noexcept(bool) specifier.
847 StaticAssertMessageSize, ///< Call to size() in a static assert
848 ///< message.
849 StaticAssertMessageData, ///< Call to data() in a static assert
850 ///< message.
851};
852
853/// Enums for the diagnostics of target, target_version and target_clones.
854namespace DiagAttrParams {
858} // end namespace DiagAttrParams
859
860void inferNoReturnAttr(Sema &S, Decl *D);
861
862#ifdef __GNUC__
863#pragma GCC diagnostic push
864#pragma GCC diagnostic ignored "-Wattributes"
865#endif
866/// Sema - This implements semantic analysis and AST building for C.
867/// \nosubgrouping
868class Sema final : public SemaBase {
869#ifdef __GNUC__
870#pragma GCC diagnostic pop
871#endif
872 // Table of Contents
873 // -----------------
874 // 1. Semantic Analysis (Sema.cpp)
875 // 2. API Notes (SemaAPINotes.cpp)
876 // 3. C++ Access Control (SemaAccess.cpp)
877 // 4. Attributes (SemaAttr.cpp)
878 // 5. Availability Attribute Handling (SemaAvailability.cpp)
879 // 6. Bounds Safety (SemaBoundsSafety.cpp)
880 // 7. Casts (SemaCast.cpp)
881 // 8. Extra Semantic Checking (SemaChecking.cpp)
882 // 9. C++ Coroutines (SemaCoroutine.cpp)
883 // 10. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
884 // 11. Declarations (SemaDecl.cpp)
885 // 12. Declaration Attribute Handling (SemaDeclAttr.cpp)
886 // 13. C++ Declarations (SemaDeclCXX.cpp)
887 // 14. C++ Exception Specifications (SemaExceptionSpec.cpp)
888 // 15. Expressions (SemaExpr.cpp)
889 // 16. C++ Expressions (SemaExprCXX.cpp)
890 // 17. Member Access Expressions (SemaExprMember.cpp)
891 // 18. Initializers (SemaInit.cpp)
892 // 19. C++ Lambda Expressions (SemaLambda.cpp)
893 // 20. Name Lookup (SemaLookup.cpp)
894 // 21. Modules (SemaModule.cpp)
895 // 22. C++ Overloading (SemaOverload.cpp)
896 // 23. Statements (SemaStmt.cpp)
897 // 24. `inline asm` Statement (SemaStmtAsm.cpp)
898 // 25. Statement Attribute Handling (SemaStmtAttr.cpp)
899 // 26. C++ Templates (SemaTemplate.cpp)
900 // 27. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
901 // 28. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
902 // 29. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
903 // 30. C++ Template Declaration Instantiation
904 // (SemaTemplateInstantiateDecl.cpp)
905 // 31. C++ Variadic Templates (SemaTemplateVariadic.cpp)
906 // 32. Constraints and Concepts (SemaConcept.cpp)
907 // 33. Types (SemaType.cpp)
908 // 34. FixIt Helpers (SemaFixItUtils.cpp)
909 // 35. Function Effects (SemaFunctionEffects.cpp)
910
911 /// \name Semantic Analysis
912 /// Implementations are in Sema.cpp
913 ///@{
914
915public:
916 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
918 CodeCompleteConsumer *CompletionConsumer = nullptr);
919 ~Sema();
920
921 /// Perform initialization that occurs after the parser has been
922 /// initialized but before it parses anything.
923 void Initialize();
924
925 /// This virtual key function only exists to limit the emission of debug info
926 /// describing the Sema class. GCC and Clang only emit debug info for a class
927 /// with a vtable when the vtable is emitted. Sema is final and not
928 /// polymorphic, but the debug info size savings are so significant that it is
929 /// worth adding a vtable just to take advantage of this optimization.
931
932 const LangOptions &getLangOpts() const { return LangOpts; }
935
938 Preprocessor &getPreprocessor() const { return PP; }
939 ASTContext &getASTContext() const { return Context; }
943
945 StringRef Platform);
947
948 /// Registers an external source. If an external source already exists,
949 /// creates a multiplex external source and appends to it.
950 ///
951 ///\param[in] E - A non-null external sema source.
952 ///
954
955 /// Print out statistics about the semantic analysis.
956 void PrintStats() const;
957
958 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
959 /// guaranteed). Produces a warning if we're low on stack space and allocates
960 /// more in that case. Use this in code that may recurse deeply (for example,
961 /// in template instantiation) to avoid stack overflow.
963 llvm::function_ref<void()> Fn);
964
965 /// Returns default addr space for method qualifiers.
967
968 /// Load weak undeclared identifiers from the external source.
970
971 /// Load #pragma redefine_extname'd undeclared identifiers from the external
972 /// source.
974
975 /// Determine if VD, which must be a variable or function, is an external
976 /// symbol that nonetheless can't be referenced from outside this translation
977 /// unit because its type has no linkage and it's not extern "C".
978 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
979
980 /// Determines whether the given source location is in the main file
981 /// and we're in a context where we should warn about unused entities.
982 bool isMainFileLoc(SourceLocation Loc) const;
983
984 /// Obtain a sorted list of functions that are undefined but ODR-used.
986 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
987
988 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
990 /// Retrieves list of suspicious delete-expressions that will be checked at
991 /// the end of translation unit.
992 const llvm::MapVector<FieldDecl *, DeleteLocs> &
994
995 /// Cause the built diagnostic to be emitted on the DiagosticsEngine.
996 /// This is closely coupled to the SemaDiagnosticBuilder class and
997 /// should not be used elsewhere.
998 void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB);
999
1000 void addImplicitTypedef(StringRef Name, QualType T);
1001
1002 /// Whether uncompilable error has occurred. This includes error happens
1003 /// in deferred diagnostics.
1004 bool hasUncompilableErrorOccurred() const;
1005
1006 /// Looks through the macro-expansion chain for the given
1007 /// location, looking for a macro expansion with the given name.
1008 /// If one is found, returns true and sets the location to that
1009 /// expansion loc.
1010 bool findMacroSpelling(SourceLocation &loc, StringRef name);
1011
1012 /// Calls \c Lexer::getLocForEndOfToken()
1013 SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
1014
1015 /// Calls \c Lexer::findNextToken() to find the next token, and if the
1016 /// locations of both ends of the token can be resolved it return that
1017 /// range; Otherwise it returns an invalid SourceRange.
1019 SourceLocation Loc, bool IncludeMacros, bool IncludeComments,
1020 std::optional<tok::TokenKind> ExpectedToken = std::nullopt);
1021
1022 /// Retrieve the module loader associated with the preprocessor.
1024
1025 /// Invent a new identifier for parameters of abbreviated templates.
1028 unsigned Index);
1029
1031
1032 // Emit all deferred diagnostics.
1033 void emitDeferredDiags();
1034
1035 /// This is called before the very first declaration in the translation unit
1036 /// is parsed. Note that the ASTContext may have already injected some
1037 /// declarations.
1039 /// ActOnEndOfTranslationUnit - This is called at the very end of the
1040 /// translation unit when EOF is reached and all but the top-level scope is
1041 /// popped.
1044
1045 /// Determines the active Scope associated with the given declaration
1046 /// context.
1047 ///
1048 /// This routine maps a declaration context to the active Scope object that
1049 /// represents that declaration context in the parser. It is typically used
1050 /// from "scope-less" code (e.g., template instantiation, lazy creation of
1051 /// declarations) that injects a name for name-lookup purposes and, therefore,
1052 /// must update the Scope.
1053 ///
1054 /// \returns The scope corresponding to the given declaraion context, or NULL
1055 /// if no such scope is open.
1057
1058 void PushFunctionScope();
1059 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
1061
1062 /// This is used to inform Sema what the current TemplateParameterDepth
1063 /// is during Parsing. Currently it is used to pass on the depth
1064 /// when parsing generic lambda 'auto' parameters.
1065 void RecordParsingTemplateParameterDepth(unsigned Depth);
1066
1067 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
1069 unsigned OpenMPCaptureLevel = 0);
1070
1071 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
1072 /// time after they've been popped.
1074 Sema *Self;
1075
1076 public:
1077 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
1079 };
1080
1082 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
1083
1084 /// Pop a function (or block or lambda or captured region) scope from the
1085 /// stack.
1086 ///
1087 /// \param WP The warning policy to use for CFG-based warnings, or null if
1088 /// such warnings should not be produced.
1089 /// \param D The declaration corresponding to this function scope, if
1090 /// producing CFG-based warnings.
1091 /// \param BlockType The type of the block expression, if D is a BlockDecl.
1094 Decl *D = nullptr, QualType BlockType = QualType());
1095
1097
1102
1103 void PushCompoundScope(bool IsStmtExpr);
1104 void PopCompoundScope();
1105
1106 /// Determine whether any errors occurred within this function/method/
1107 /// block.
1109
1110 /// Retrieve the current block, if any.
1112
1113 /// Get the innermost lambda or block enclosing the current location, if any.
1114 /// This looks through intervening non-lambda, non-block scopes such as local
1115 /// functions.
1117
1118 /// Retrieve the current lambda scope info, if any.
1119 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
1120 /// lambda scope info ignoring all inner capturing scopes that are not
1121 /// lambda scopes.
1123 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
1124
1125 /// Retrieve the current generic lambda info, if any.
1127
1128 /// Retrieve the current captured region, if any.
1130
1131 void ActOnComment(SourceRange Comment);
1132
1133 /// Retrieve the parser's current scope.
1134 ///
1135 /// This routine must only be used when it is certain that semantic analysis
1136 /// and the parser are in precisely the same context, which is not the case
1137 /// when, e.g., we are performing any kind of template instantiation.
1138 /// Therefore, the only safe places to use this scope are in the parser
1139 /// itself and in routines directly invoked from the parser and *never* from
1140 /// template substitution or instantiation.
1141 Scope *getCurScope() const { return CurScope; }
1142
1144
1148
1149 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
1150 const FunctionDecl *FD = nullptr);
1152 const PartialDiagnostic &PD,
1153 const FunctionDecl *FD = nullptr) {
1154 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
1155 }
1156
1157 /// Check if the type is allowed to be used for the current target.
1159 ValueDecl *D = nullptr);
1160
1161 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
1162 /// cast. If there is already an implicit cast, merge into the existing one.
1163 /// If isLvalue, the result of the cast is an lvalue.
1166 const CXXCastPath *BasePath = nullptr,
1168
1169 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
1170 /// to the conversion from scalar type ScalarTy to the Boolean type.
1172
1173 /// If \p AllowLambda is true, treat lambda as function.
1174 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
1175
1176 /// Returns a pointer to the innermost enclosing function, or nullptr if the
1177 /// current context is not inside a function. If \p AllowLambda is true,
1178 /// this can return the call operator of an enclosing lambda, otherwise
1179 /// lambdas are skipped when looking for an enclosing function.
1180 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
1181
1182 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
1183 /// the method decl for the method being parsed. If we're currently
1184 /// in a 'block', this returns the containing context.
1186
1187 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
1188 /// or C function we're in, otherwise return null. If we're currently
1189 /// in a 'block', this returns the containing context.
1191
1192 /// Warn if we're implicitly casting from a _Nullable pointer type to a
1193 /// _Nonnull one.
1195 SourceLocation Loc);
1196
1197 /// Warn when implicitly casting 0 to nullptr.
1198 void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
1199
1200 /// Warn when implicitly changing function effects.
1202 SourceLocation Loc);
1203
1204 /// makeUnavailableInSystemHeader - There is an error in the current
1205 /// context. If we're still in a system header, and we can plausibly
1206 /// make the relevant declaration unavailable instead of erroring, do
1207 /// so and return true.
1209 UnavailableAttr::ImplicitReason reason);
1210
1211 /// Retrieve a suitable printing policy for diagnostics.
1215
1216 /// Retrieve a suitable printing policy for diagnostics.
1218 const Preprocessor &PP);
1219
1220 /// Scope actions.
1222
1223 /// Determine whether \param D is function like (function or function
1224 /// template) for parsing.
1226
1227 /// The maximum alignment, same as in llvm::Value. We duplicate them here
1228 /// because that allows us not to duplicate the constants in clang code,
1229 /// which we must to since we can't directly use the llvm constants.
1230 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
1231 ///
1232 /// This is the greatest alignment value supported by load, store, and alloca
1233 /// instructions, and global values.
1234 static const unsigned MaxAlignmentExponent = 32;
1235 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
1236
1237 /// Flag indicating whether or not to collect detailed statistics.
1239
1240 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
1241
1242 /// Stack containing information about each of the nested
1243 /// function, block, and method scopes that are currently active.
1245
1246 /// The index of the first FunctionScope that corresponds to the current
1247 /// context.
1249
1250 /// Track the number of currently active capturing scopes.
1252
1253 llvm::BumpPtrAllocator BumpAlloc;
1254
1255 /// The kind of translation unit we are processing.
1256 ///
1257 /// When we're processing a complete translation unit, Sema will perform
1258 /// end-of-translation-unit semantic tasks (such as creating
1259 /// initializers for tentative definitions in C) once parsing has
1260 /// completed. Modules and precompiled headers perform different kinds of
1261 /// checks.
1263
1264 /// Translation Unit Scope - useful to Objective-C actions that need
1265 /// to lookup file scope declarations in the "ordinary" C decl namespace.
1266 /// For example, user-defined classes, built-in "id" type, etc.
1268
1270 return CurScope->incrementMSManglingNumber();
1271 }
1272
1273 /// Try to recover by turning the given expression into a
1274 /// call. Returns true if recovery was attempted or an error was
1275 /// emitted; this may also leave the ExprResult invalid.
1277 bool ForceComplain = false,
1278 bool (*IsPlausibleResult)(QualType) = nullptr);
1279
1280 // Adds implicit lifetime bound attribute for implicit this to its
1281 // TypeSourceInfo.
1283
1284 /// Figure out if an expression could be turned into a call.
1285 ///
1286 /// Use this when trying to recover from an error where the programmer may
1287 /// have written just the name of a function instead of actually calling it.
1288 ///
1289 /// \param E - The expression to examine.
1290 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
1291 /// with no arguments, this parameter is set to the type returned by such a
1292 /// call; otherwise, it is set to an empty QualType.
1293 /// \param OverloadSet - If the expression is an overloaded function
1294 /// name, this parameter is populated with the decls of the various
1295 /// overloads.
1296 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
1297 UnresolvedSetImpl &NonTemplateOverloads);
1298
1302
1305
1313
1314 /// A RAII object to enter scope of a compound statement.
1316 public:
1317 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
1318 S.ActOnStartOfCompoundStmt(IsStmtExpr);
1319 }
1320
1321 ~CompoundScopeRAII() { S.ActOnFinishOfCompoundStmt(); }
1324
1325 private:
1326 Sema &S;
1327 };
1328
1329 /// An RAII helper that pops function a function scope on exit.
1335 if (Active)
1336 S.PopFunctionScopeInfo();
1337 }
1338 void disable() { Active = false; }
1339 };
1340
1342 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
1343 }
1344
1345 /// Worker object for performing CFG-based warnings.
1348
1349 /// Callback to the parser to parse templated functions when needed.
1350 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
1353
1355 LateTemplateParser = LTP;
1356 OpaqueParser = P;
1357 }
1358
1359 /// Callback to the parser to parse a type expressed as a string.
1360 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
1362
1363 /// VAListTagName - The declaration name corresponding to __va_list_tag.
1364 /// This is used as part of a hack to omit that class from ADL results.
1366
1367 /// Is the last error level diagnostic immediate. This is used to determined
1368 /// whether the next info diagnostic should be immediate.
1370
1371 /// Track if we're currently analyzing overflow behavior types in assignment
1372 /// context.
1374
1375 class DelayedDiagnostics;
1376
1378 sema::DelayedDiagnosticPool *SavedPool = nullptr;
1380 };
1383
1384 /// A class which encapsulates the logic for delaying diagnostics
1385 /// during parsing and other processing.
1387 /// The current pool of diagnostics into which delayed
1388 /// diagnostics should go.
1389 sema::DelayedDiagnosticPool *CurPool = nullptr;
1390
1391 public:
1393
1394 /// Adds a delayed diagnostic.
1395 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
1396
1397 /// Determines whether diagnostics should be delayed.
1398 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
1399
1400 /// Returns the current delayed-diagnostics pool.
1401 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1402
1403 /// Enter a new scope. Access and deprecation diagnostics will be
1404 /// collected in this pool.
1407 state.SavedPool = CurPool;
1408 CurPool = &pool;
1409 return state;
1410 }
1411
1412 /// Leave a delayed-diagnostic state that was previously pushed.
1413 /// Do not emit any of the diagnostics. This is performed as part
1414 /// of the bookkeeping of popping a pool "properly".
1416 CurPool = state.SavedPool;
1417 }
1418
1419 /// Enter a new scope where access and deprecation diagnostics are
1420 /// not delayed.
1423 state.SavedPool = CurPool;
1424 CurPool = nullptr;
1425 return state;
1426 }
1427
1428 /// Undo a previous pushUndelayed().
1430 assert(CurPool == nullptr);
1431 CurPool = state.SavedPool;
1432 }
1434
1438
1439 /// Diagnostics that are emitted only if we discover that the given function
1440 /// must be codegen'ed. Because handling these correctly adds overhead to
1441 /// compilation, this is currently only used for offload languages like CUDA,
1442 /// OpenMP, and SYCL.
1443 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1444
1445 /// CurContext - This is the current declaration context of parsing.
1447
1449 assert(AMDGPUPtr);
1450 return *AMDGPUPtr;
1451 }
1452
1454 assert(ARMPtr);
1455 return *ARMPtr;
1456 }
1457
1459 assert(AVRPtr);
1460 return *AVRPtr;
1461 }
1462
1464 assert(BPFPtr);
1465 return *BPFPtr;
1466 }
1467
1469 assert(CodeCompletionPtr);
1470 return *CodeCompletionPtr;
1471 }
1472
1474 assert(CUDAPtr);
1475 return *CUDAPtr;
1476 }
1477
1479 assert(DirectXPtr);
1480 return *DirectXPtr;
1481 }
1482
1484 assert(HLSLPtr);
1485 return *HLSLPtr;
1486 }
1487
1489 assert(HexagonPtr);
1490 return *HexagonPtr;
1491 }
1492
1494 assert(LoongArchPtr);
1495 return *LoongArchPtr;
1496 }
1497
1499 assert(M68kPtr);
1500 return *M68kPtr;
1501 }
1502
1504 assert(MIPSPtr);
1505 return *MIPSPtr;
1506 }
1507
1509 assert(MSP430Ptr);
1510 return *MSP430Ptr;
1511 }
1512
1514 assert(NVPTXPtr);
1515 return *NVPTXPtr;
1516 }
1517
1519 assert(ObjCPtr);
1520 return *ObjCPtr;
1521 }
1522
1524 assert(OpenACCPtr);
1525 return *OpenACCPtr;
1526 }
1527
1529 assert(OpenCLPtr);
1530 return *OpenCLPtr;
1531 }
1532
1534 assert(OpenMPPtr && "SemaOpenMP is dead");
1535 return *OpenMPPtr;
1536 }
1537
1539 assert(PPCPtr);
1540 return *PPCPtr;
1541 }
1542
1544 assert(PseudoObjectPtr);
1545 return *PseudoObjectPtr;
1546 }
1547
1549 assert(RISCVPtr);
1550 return *RISCVPtr;
1551 }
1552
1554 assert(SPIRVPtr);
1555 return *SPIRVPtr;
1556 }
1557
1559 assert(SYCLPtr);
1560 return *SYCLPtr;
1561 }
1562
1564 assert(SwiftPtr);
1565 return *SwiftPtr;
1566 }
1567
1569 assert(SystemZPtr);
1570 return *SystemZPtr;
1571 }
1572
1574 assert(WasmPtr);
1575 return *WasmPtr;
1576 }
1577
1579 assert(X86Ptr);
1580 return *X86Ptr;
1581 }
1582
1583 /// Source of additional semantic information.
1585
1586protected:
1587 friend class Parser;
1589 friend class ASTReader;
1590 friend class ASTDeclReader;
1591 friend class ASTWriter;
1592
1593private:
1594 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1595 bool WarnedDarwinSDKInfoMissing = false;
1596
1597 StackExhaustionHandler StackHandler;
1598
1599 Sema(const Sema &) = delete;
1600 void operator=(const Sema &) = delete;
1601
1602 /// The handler for the FileChanged preprocessor events.
1603 ///
1604 /// Used for diagnostics that implement custom semantic analysis for #include
1605 /// directives, like -Wpragma-pack.
1606 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1607
1608 /// The parser's current scope.
1609 ///
1610 /// The parser maintains this state here.
1611 Scope *CurScope;
1612
1613 mutable IdentifierInfo *Ident_super;
1614
1615 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1616 std::unique_ptr<SemaARM> ARMPtr;
1617 std::unique_ptr<SemaAVR> AVRPtr;
1618 std::unique_ptr<SemaBPF> BPFPtr;
1619 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1620 std::unique_ptr<SemaCUDA> CUDAPtr;
1621 std::unique_ptr<SemaDirectX> DirectXPtr;
1622 std::unique_ptr<SemaHLSL> HLSLPtr;
1623 std::unique_ptr<SemaHexagon> HexagonPtr;
1624 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1625 std::unique_ptr<SemaM68k> M68kPtr;
1626 std::unique_ptr<SemaMIPS> MIPSPtr;
1627 std::unique_ptr<SemaMSP430> MSP430Ptr;
1628 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1629 std::unique_ptr<SemaObjC> ObjCPtr;
1630 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1631 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1632 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1633 std::unique_ptr<SemaPPC> PPCPtr;
1634 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1635 std::unique_ptr<SemaRISCV> RISCVPtr;
1636 std::unique_ptr<SemaSPIRV> SPIRVPtr;
1637 std::unique_ptr<SemaSYCL> SYCLPtr;
1638 std::unique_ptr<SemaSwift> SwiftPtr;
1639 std::unique_ptr<SemaSystemZ> SystemZPtr;
1640 std::unique_ptr<SemaWasm> WasmPtr;
1641 std::unique_ptr<SemaX86> X86Ptr;
1642
1643 ///@}
1644
1645 //
1646 //
1647 // -------------------------------------------------------------------------
1648 //
1649 //
1650
1651 /// \name API Notes
1652 /// Implementations are in SemaAPINotes.cpp
1653 ///@{
1654
1655public:
1656 /// Map any API notes provided for this declaration to attributes on the
1657 /// declaration.
1658 ///
1659 /// Triggered by declaration-attribute processing.
1660 void ProcessAPINotes(Decl *D);
1661 /// Apply the 'Nullability:' annotation to the specified declaration
1662 void ApplyNullability(Decl *D, NullabilityKind Nullability);
1663 /// Apply the 'Type:' annotation to the specified declaration
1664 void ApplyAPINotesType(Decl *D, StringRef TypeString);
1665
1666 /// Whether APINotes should be gathered for all applicable Swift language
1667 /// versions, without being applied. Leaving clients of the current module
1668 /// to select and apply the correct version.
1670 return APINotes.captureVersionIndependentSwift();
1671 }
1672 ///@}
1673
1674 //
1675 //
1676 // -------------------------------------------------------------------------
1677 //
1678 //
1679
1680 /// \name C++ Access Control
1681 /// Implementations are in SemaAccess.cpp
1682 ///@{
1683
1684public:
1691
1692 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1693 /// Returns true on error (when the previous member decl access specifier
1694 /// is different from the new member decl access specifier).
1695 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1696 NamedDecl *PrevMemberDecl,
1697 AccessSpecifier LexicalAS);
1698
1699 /// Perform access-control checking on a previously-unresolved member
1700 /// access which has now been resolved to a member.
1702 DeclAccessPair FoundDecl);
1704 DeclAccessPair FoundDecl);
1705
1706 /// Checks access to an overloaded operator new or delete.
1708 SourceRange PlacementRange,
1709 CXXRecordDecl *NamingClass,
1710 DeclAccessPair FoundDecl,
1711 bool Diagnose = true);
1712
1713 /// Checks access to a constructor.
1715 DeclAccessPair FoundDecl,
1716 const InitializedEntity &Entity,
1717 bool IsCopyBindingRefToTemp = false);
1718
1719 /// Checks access to a constructor.
1721 DeclAccessPair FoundDecl,
1722 const InitializedEntity &Entity,
1723 const PartialDiagnostic &PDiag);
1725 CXXDestructorDecl *Dtor,
1726 const PartialDiagnostic &PDiag,
1727 QualType objectType = QualType());
1728
1729 /// Checks access to the target of a friend declaration.
1731
1732 /// Checks access to a member.
1734 CXXRecordDecl *NamingClass,
1736
1737 /// Checks implicit access to a member in a structured binding.
1740 CXXRecordDecl *DecomposedClass,
1741 DeclAccessPair Field);
1743 const SourceRange &,
1744 DeclAccessPair FoundDecl);
1745
1746 /// Checks access to an overloaded member operator, including
1747 /// conversion operators.
1749 Expr *ArgExpr,
1750 DeclAccessPair FoundDecl);
1752 ArrayRef<Expr *> ArgExprs,
1753 DeclAccessPair FoundDecl);
1755 DeclAccessPair FoundDecl);
1756
1757 /// Checks access for a hierarchy conversion.
1758 ///
1759 /// \param ForceCheck true if this check should be performed even if access
1760 /// control is disabled; some things rely on this for semantics
1761 /// \param ForceUnprivileged true if this check should proceed as if the
1762 /// context had no special privileges
1764 QualType Derived, const CXXBasePath &Path,
1765 unsigned DiagID, bool ForceCheck = false,
1766 bool ForceUnprivileged = false);
1767
1769 SourceLocation AccessLoc, CXXRecordDecl *Base, CXXRecordDecl *Derived,
1770 const CXXBasePath &Path, unsigned DiagID,
1771 llvm::function_ref<void(PartialDiagnostic &PD)> SetupPDiag,
1772 bool ForceCheck = false, bool ForceUnprivileged = false);
1773
1774 /// Checks access to all the declarations in the given result set.
1775 void CheckLookupAccess(const LookupResult &R);
1776
1777 /// Checks access to Target from the given class. The check will take access
1778 /// specifiers into account, but no member access expressions and such.
1779 ///
1780 /// \param Target the declaration to check if it can be accessed
1781 /// \param NamingClass the class in which the lookup was started.
1782 /// \param BaseType type of the left side of member access expression.
1783 /// \p BaseType and \p NamingClass are used for C++ access control.
1784 /// Depending on the lookup case, they should be set to the following:
1785 /// - lhs.target (member access without a qualifier):
1786 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1787 /// - lhs.X::target (member access with a qualifier):
1788 /// BaseType is the type of 'lhs', NamingClass is 'X'
1789 /// - X::target (qualified lookup without member access):
1790 /// BaseType is null, NamingClass is 'X'.
1791 /// - target (unqualified lookup).
1792 /// BaseType is null, NamingClass is the parent class of 'target'.
1793 /// \return true if the Target is accessible from the Class, false otherwise.
1794 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1795 QualType BaseType);
1796
1797 /// Is the given member accessible for the purposes of deciding whether to
1798 /// define a special member function as deleted?
1800 DeclAccessPair Found, QualType ObjectType,
1801 SourceLocation Loc,
1802 const PartialDiagnostic &Diag);
1805 QualType ObjectType) {
1806 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1807 SourceLocation(), PDiag());
1808 }
1809
1811 const DependentDiagnostic &DD,
1812 const MultiLevelTemplateArgumentList &TemplateArgs);
1814
1815 ///@}
1816
1817 //
1818 //
1819 // -------------------------------------------------------------------------
1820 //
1821 //
1822
1823 /// \name Attributes
1824 /// Implementations are in SemaAttr.cpp
1825 ///@{
1826
1827public:
1828 /// Controls member pointer representation format under the MS ABI.
1831
1832 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1833
1834 /// Source location for newly created implicit MSInheritanceAttrs
1836
1842
1848
1850 PSK_Reset = 0x0, // #pragma ()
1851 PSK_Set = 0x1, // #pragma (value)
1852 PSK_Push = 0x2, // #pragma (push[, id])
1853 PSK_Pop = 0x4, // #pragma (pop[, id])
1854 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1855 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1856 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1857 };
1858
1864
1865 // #pragma pack and align.
1867 public:
1868 // `Native` represents default align mode, which may vary based on the
1869 // platform.
1870 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1871
1872 // #pragma pack info constructor
1873 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1874 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1875 assert(Num == PackNumber && "The pack number has been truncated.");
1876 }
1877
1878 // #pragma align info constructor
1880 : PackAttr(false), AlignMode(M),
1881 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1882
1883 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1884
1886
1887 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1888 // integer encoding for it. This should only be passed to
1889 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1890 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1891 std::uint32_t Encoding{};
1892 if (Info.IsXLStack())
1893 Encoding |= IsXLMask;
1894
1895 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1896
1897 if (Info.IsPackAttr())
1898 Encoding |= PackAttrMask;
1899
1900 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1901
1902 return Encoding;
1903 }
1904
1905 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1906 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1908 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1909 int PackNumber = (Encoding & PackNumMask) >> 4;
1910
1911 if (Encoding & PackAttrMask)
1912 return AlignPackInfo(M, PackNumber, IsXL);
1913
1914 return AlignPackInfo(M, IsXL);
1915 }
1916
1917 bool IsPackAttr() const { return PackAttr; }
1918
1919 bool IsAlignAttr() const { return !PackAttr; }
1920
1921 Mode getAlignMode() const { return AlignMode; }
1922
1923 unsigned getPackNumber() const { return PackNumber; }
1924
1925 bool IsPackSet() const {
1926 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1927 // attriute on a decl.
1928 return PackNumber != UninitPackVal && PackNumber != 0;
1929 }
1930
1931 bool IsXLStack() const { return XLStack; }
1932
1933 bool operator==(const AlignPackInfo &Info) const {
1934 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1935 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1936 Info.XLStack);
1937 }
1938
1939 bool operator!=(const AlignPackInfo &Info) const {
1940 return !(*this == Info);
1941 }
1942
1943 private:
1944 /// \brief True if this is a pragma pack attribute,
1945 /// not a pragma align attribute.
1946 bool PackAttr;
1947
1948 /// \brief The alignment mode that is in effect.
1949 Mode AlignMode;
1950
1951 /// \brief The pack number of the stack.
1952 unsigned char PackNumber;
1953
1954 /// \brief True if it is a XL #pragma align/pack stack.
1955 bool XLStack;
1956
1957 /// \brief Uninitialized pack value.
1958 static constexpr unsigned char UninitPackVal = -1;
1959
1960 // Masks to encode and decode an AlignPackInfo.
1961 static constexpr uint32_t IsXLMask{0x0000'0001};
1962 static constexpr uint32_t AlignModeMask{0x0000'0006};
1963 static constexpr uint32_t PackAttrMask{0x00000'0008};
1964 static constexpr uint32_t PackNumMask{0x0000'01F0};
1965 };
1966
1967 template <typename ValueType> struct PragmaStack {
1979
1980 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1981 llvm::StringRef StackSlotLabel, ValueType Value) {
1982 if (Action == PSK_Reset) {
1984 CurrentPragmaLocation = PragmaLocation;
1985 return;
1986 }
1987 if (Action & PSK_Push)
1988 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1989 PragmaLocation);
1990 else if (Action & PSK_Pop) {
1991 if (!StackSlotLabel.empty()) {
1992 // If we've got a label, try to find it and jump there.
1993 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1994 return x.StackSlotLabel == StackSlotLabel;
1995 });
1996 // If we found the label so pop from there.
1997 if (I != Stack.rend()) {
1998 CurrentValue = I->Value;
1999 CurrentPragmaLocation = I->PragmaLocation;
2000 Stack.erase(std::prev(I.base()), Stack.end());
2001 }
2002 } else if (!Stack.empty()) {
2003 // We do not have a label, just pop the last entry.
2004 CurrentValue = Stack.back().Value;
2005 CurrentPragmaLocation = Stack.back().PragmaLocation;
2006 Stack.pop_back();
2007 }
2008 }
2009 if (Action & PSK_Set) {
2011 CurrentPragmaLocation = PragmaLocation;
2012 }
2013 }
2014
2015 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
2016 // method body to restore the stacks on exit, so it works like this:
2017 //
2018 // struct S {
2019 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
2020 // void Method {}
2021 // #pragma <name>(pop, InternalPragmaSlot)
2022 // };
2023 //
2024 // It works even with #pragma vtordisp, although MSVC doesn't support
2025 // #pragma vtordisp(push [, id], n)
2026 // syntax.
2027 //
2028 // Push / pop a named sentinel slot.
2029 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
2030 assert((Action == PSK_Push || Action == PSK_Pop) &&
2031 "Can only push / pop #pragma stack sentinels!");
2032 Act(CurrentPragmaLocation, Action, Label, CurrentValue);
2033 }
2034
2035 // Constructors.
2036 explicit PragmaStack(const ValueType &Default)
2038
2039 bool hasValue() const { return CurrentValue != DefaultValue; }
2040
2042 ValueType DefaultValue; // Value used for PSK_Reset action.
2043 ValueType CurrentValue;
2045 };
2046 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
2047 // we shouldn't do so if they're in a module).
2048
2049 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
2050 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
2051 ///
2052 /// 0: Suppress all vtordisps
2053 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
2054 /// structors
2055 /// 2: Always insert vtordisps to support RTTI on partially constructed
2056 /// objects
2059 // The current #pragma align/pack values and locations at each #include.
2066 // Segment #pragmas.
2071
2072 // #pragma strict_gs_check.
2074
2075 // This stack tracks the current state of Sema.CurFPFeatures.
2078 FPOptionsOverride result;
2079 if (!FpPragmaStack.hasValue()) {
2080 result = FPOptionsOverride();
2081 } else {
2082 result = FpPragmaStack.CurrentValue;
2083 }
2084 return result;
2085 }
2086
2093
2094 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
2095 // Actions should be performed only if we enter / exit a C++ method body.
2097 public:
2098 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
2103
2104 private:
2105 Sema &S;
2106 StringRef SlotLabel;
2107 bool ShouldAct;
2108 };
2109
2110 /// Last section used with #pragma init_seg.
2113
2114 /// Sections used with #pragma alloc_text.
2115 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
2116
2117 /// VisContext - Manages the stack for \#pragma GCC visibility.
2118 void *VisContext; // Really a "PragmaVisStack*"
2119
2120 /// This an attribute introduced by \#pragma clang attribute.
2127
2128 /// A push'd group of PragmaAttributeEntries.
2130 /// The location of the push attribute.
2132 /// The namespace of this push group.
2135 };
2136
2138
2139 /// The declaration that is currently receiving an attribute from the
2140 /// #pragma attribute stack.
2142
2143 /// This represents the last location of a "#pragma clang optimize off"
2144 /// directive if such a directive has not been closed by an "on" yet. If
2145 /// optimizations are currently "on", this is set to an invalid location.
2147
2148 /// Get the location for the currently active "\#pragma clang optimize
2149 /// off". If this location is invalid, then the state of the pragma is "on".
2153
2154 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
2155 /// whether the optimizations in the list passed to the pragma should be
2156 /// turned off or on. This boolean is true by default because command line
2157 /// options are honored when `#pragma optimize("", on)`.
2158 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
2160
2161 /// Set of no-builtin functions listed by \#pragma function.
2163
2164 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
2165 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
2167
2168 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
2170
2171 /// Add gsl::Pointer attribute to std::container::iterator
2172 /// \param ND The declaration that introduces the name
2173 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
2174 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
2175
2176 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
2178
2179 /// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
2181
2182 /// Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
2184
2185 /// Add [[gsl::Pointer]] attributes for std:: types.
2187
2188 LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
2189 StringRef ParamName);
2190 // Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'
2191 // can be the name of a function parameter, we need to parse the function
2192 // declaration and rest of the parameters before processesing 'X'. Therefore
2193 // do this lazily instead of processing while parsing the annotation itself.
2195
2196 /// Add _Nullable attributes for std:: types.
2198
2199 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
2202 PragmaClangSectionKind SecKind,
2203 StringRef SecName);
2204
2205 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
2207 SourceLocation PragmaLoc);
2208
2209 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
2210 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
2211 StringRef SlotLabel, Expr *Alignment);
2212
2213 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
2214 /// (unless they are value dependent or type dependent). Returns false
2215 /// and emits a diagnostic if one or more of the arguments could not be
2216 /// folded into a constant.
2219
2224
2226 SourceLocation IncludeLoc);
2228
2229 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
2231
2232 /// ActOnPragmaMSComment - Called on well formed
2233 /// \#pragma comment(kind, "arg").
2235 StringRef Arg);
2236
2237 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
2238 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
2239 StringRef Value);
2240
2241 /// Are precise floating point semantics currently enabled?
2243 return !CurFPFeatures.getAllowFPReassociate() &&
2244 !CurFPFeatures.getNoSignedZero() &&
2245 !CurFPFeatures.getAllowReciprocal() &&
2246 !CurFPFeatures.getAllowApproxFunc();
2247 }
2248
2251
2252 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
2253 void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action,
2255
2256 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
2257 /// pointers_to_members(representation method[, general purpose
2258 /// representation]).
2261 SourceLocation PragmaLoc);
2262
2263 /// Called on well formed \#pragma vtordisp().
2264 void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
2266
2267 bool UnifySection(StringRef SectionName, int SectionFlags,
2268 NamedDecl *TheDecl);
2269 bool UnifySection(StringRef SectionName, int SectionFlags,
2270 SourceLocation PragmaSectionLocation);
2271
2272 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
2273 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
2274 PragmaMsStackAction Action,
2275 llvm::StringRef StackSlotLabel,
2276 StringLiteral *SegmentName, llvm::StringRef PragmaName);
2277
2278 /// Called on well formed \#pragma section().
2279 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
2280 StringLiteral *SegmentName);
2281
2282 /// Called on well-formed \#pragma init_seg().
2283 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
2284 StringLiteral *SegmentName);
2285
2286 /// Called on well-formed \#pragma alloc_text().
2288 SourceLocation PragmaLocation, StringRef Section,
2289 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
2290 &Functions);
2291
2292 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
2293 /// strict_gs_check.
2295 PragmaMsStackAction Action,
2296 bool Value);
2297
2298 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
2299 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
2300 SourceLocation PragmaLoc);
2301
2303 SourceLocation PragmaLoc,
2306 const IdentifierInfo *Namespace);
2307
2308 /// Called on well-formed '\#pragma clang attribute pop'.
2310 const IdentifierInfo *Namespace);
2311
2312 /// Adds the attributes that have been specified using the
2313 /// '\#pragma clang attribute push' directives to the given declaration.
2314 void AddPragmaAttributes(Scope *S, Decl *D);
2315
2317 llvm::function_ref<void(SourceLocation, PartialDiagnostic)>;
2319 return [this](SourceLocation Loc, PartialDiagnostic PD) {
2320 // This bypasses a lot of the filters in the diag engine, as it's
2321 // to be used to attach notes to diagnostics which have already
2322 // been filtered through.
2323 DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
2324 PD.Emit(Builder);
2325 };
2326 }
2327
2333
2335
2336 /// Called on well formed \#pragma clang optimize.
2337 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
2338
2339 /// #pragma optimize("[optimization-list]", on | off).
2340 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
2341
2342 /// Call on well formed \#pragma function.
2343 void
2345 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
2346
2348 SourceLocation NameLoc,
2349 Scope *curScope);
2350
2351 /// Information from a C++ #pragma export, for a symbol that we
2352 /// haven't seen the declaration for yet.
2357
2358 llvm::DenseMap<IdentifierInfo *, PendingPragmaInfo> PendingExportedNames;
2359
2360 /// ActonPragmaExport - called on well-formed '\#pragma export'.
2361 void ActOnPragmaExport(IdentifierInfo *IdentId, SourceLocation ExportNameLoc,
2362 Scope *curScope);
2363
2364 /// Only called on function definitions; if there is a pragma in scope
2365 /// with the effect of a range-based optnone, consider marking the function
2366 /// with attribute optnone.
2368
2369 /// Only called on function definitions; if there is a `#pragma alloc_text`
2370 /// that decides which code section the function should be in, add
2371 /// attribute section to the function.
2373
2374 /// Adds the 'optnone' attribute to the function declaration if there
2375 /// are no conflicts; Loc represents the location causing the 'optnone'
2376 /// attribute to be added (usually because of a pragma).
2378
2379 /// Only called on function definitions; if there is a MSVC #pragma optimize
2380 /// in scope, consider changing the function's attributes based on the
2381 /// optimization list passed to the pragma.
2383
2384 /// Only called on function definitions; if there is a pragma in scope
2385 /// with the effect of a range-based no_builtin, consider marking the function
2386 /// with attribute no_builtin.
2388
2389 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
2390 /// add an appropriate visibility attribute.
2392
2393 /// FreeVisContext - Deallocate and null out VisContext.
2394 void FreeVisContext();
2395
2396 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
2397 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
2398 SourceLocation PragmaLoc);
2399
2400 /// ActOnPragmaFPContract - Called on well formed
2401 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
2402 /// \#pragma clang fp contract
2404
2405 /// Called on well formed
2406 /// \#pragma clang fp reassociate
2407 /// or
2408 /// \#pragma clang fp reciprocal
2410 bool IsEnabled);
2411
2412 /// ActOnPragmaFenvAccess - Called on well formed
2413 /// \#pragma STDC FENV_ACCESS
2414 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
2415
2416 /// ActOnPragmaCXLimitedRange - Called on well formed
2417 /// \#pragma STDC CX_LIMITED_RANGE
2420
2421 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
2424
2425 /// Called to set constant rounding mode for floating point operations.
2426 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
2427
2428 /// Called to set exception behavior for floating point operations.
2430
2431 /// PushNamespaceVisibilityAttr - Note that we've entered a
2432 /// namespace with a visibility attribute.
2433 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
2434 SourceLocation Loc);
2435
2436 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
2437 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2438 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2439
2440 /// Handles semantic checking for features that are common to all attributes,
2441 /// such as checking whether a parameter was properly specified, or the
2442 /// correct number of arguments were passed, etc. Returns true if the
2443 /// attribute has been diagnosed.
2444 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2445 bool SkipArgCountCheck = false);
2446 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2447 bool SkipArgCountCheck = false);
2448
2449 ///@}
2450
2451 //
2452 //
2453 // -------------------------------------------------------------------------
2454 //
2455 //
2456
2457 /// \name Availability Attribute Handling
2458 /// Implementations are in SemaAvailability.cpp
2459 ///@{
2460
2461public:
2462 /// Issue any -Wunguarded-availability warnings in \c FD
2464
2466
2467 /// Retrieve the current function, if any, that should be analyzed for
2468 /// potential availability violations.
2470
2472 const ObjCInterfaceDecl *UnknownObjCClass,
2473 bool ObjCPropertyAccess,
2474 bool AvoidPartialAvailabilityChecks,
2475 ObjCInterfaceDecl *ClassReceiver);
2476
2478
2479 std::pair<AvailabilityResult, const NamedDecl *>
2480 ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message,
2481 ObjCInterfaceDecl *ClassReceiver);
2482 ///@}
2483
2484 //
2485 //
2486 // -------------------------------------------------------------------------
2487 //
2488 //
2489
2490 /// \name Bounds Safety
2491 /// Implementations are in SemaBoundsSafety.cpp
2492 ///@{
2493public:
2494 /// Check if applying the specified attribute variant from the "counted by"
2495 /// family of attributes to FieldDecl \p FD is semantically valid. If
2496 /// semantically invalid diagnostics will be emitted explaining the problems.
2497 ///
2498 /// \param FD The FieldDecl to apply the attribute to
2499 /// \param E The count expression on the attribute
2500 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2501 /// attributes. If the false the attribute is from
2502 /// "counted_by" family of attributes.
2503 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2504 /// of attributes. If false the attribute does not have the
2505 /// suffix.
2506 ///
2507 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2508 /// \p CountInBytes and \p OrNull both being true indicates the
2509 /// `counted_by_or_null` attribute.
2510 ///
2511 /// \returns false iff semantically valid.
2512 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2513 bool OrNull);
2514
2515 /// Perform Bounds Safety Semantic checks for assigning to a `__counted_by` or
2516 /// `__counted_by_or_null` pointer type \param LHSTy.
2517 ///
2518 /// \param LHSTy The type being assigned to. Checks will only be performed if
2519 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2520 /// \param RHSExpr The expression being assigned from.
2521 /// \param Action The type assignment being performed
2522 /// \param Loc The SourceLocation to use for error diagnostics
2523 /// \param Assignee The ValueDecl being assigned. This is used to compute
2524 /// the name of the assignee. If the assignee isn't known this can
2525 /// be set to nullptr.
2526 /// \param ShowFullyQualifiedAssigneeName If set to true when using \p
2527 /// Assignee to compute the name of the assignee use the fully
2528 /// qualified name, otherwise use the unqualified name.
2529 ///
2530 /// \returns True iff no diagnostic where emitted, false otherwise.
2532 QualType LHSTy, Expr *RHSExpr, AssignmentAction Action,
2533 SourceLocation Loc, const ValueDecl *Assignee,
2534 bool ShowFullyQualifiedAssigneeName);
2535
2536 /// Perform Bounds Safety Semantic checks for initializing a Bounds Safety
2537 /// pointer.
2538 ///
2539 /// \param Entity The entity being initialized
2540 /// \param Kind The kind of initialization being performed
2541 /// \param Action The type assignment being performed
2542 /// \param LHSTy The type being assigned to. Checks will only be performed if
2543 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2544 /// \param RHSExpr The expression being used for initialization.
2545 ///
2546 /// \returns True iff no diagnostic where emitted, false otherwise.
2548 const InitializationKind &Kind,
2549 AssignmentAction Action,
2550 QualType LHSType, Expr *RHSExpr);
2551
2552 /// Perform Bounds Safety semantic checks for uses of invalid uses counted_by
2553 /// or counted_by_or_null pointers in \param E.
2554 ///
2555 /// \param E the expression to check
2556 ///
2557 /// \returns True iff no diagnostic where emitted, false otherwise.
2559 ///@}
2560
2561 //
2562 //
2563 // -------------------------------------------------------------------------
2564 //
2565 //
2566
2567 /// \name Casts
2568 /// Implementations are in SemaCast.cpp
2569 ///@{
2570
2571public:
2577
2578 /// ActOnCXXNamedCast - Parse
2579 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2581 SourceLocation LAngleBracketLoc, Declarator &D,
2582 SourceLocation RAngleBracketLoc,
2583 SourceLocation LParenLoc, Expr *E,
2584 SourceLocation RParenLoc);
2585
2587 TypeSourceInfo *Ty, Expr *E,
2588 SourceRange AngleBrackets, SourceRange Parens);
2589
2591 ExprResult Operand,
2592 SourceLocation RParenLoc);
2593
2595 Expr *Operand, SourceLocation RParenLoc);
2596
2597 // Checks that reinterpret casts don't have undefined behavior.
2598 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2599 bool IsDereference, SourceRange Range);
2600
2601 // Checks that the vector type should be initialized from a scalar
2602 // by splatting the value rather than populating a single element.
2603 // This is the case for AltiVecVector types as well as with
2604 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2605 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2606
2607 // Checks if the -faltivec-src-compat=gcc option is specified.
2608 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2609 // treated the same way as they are when trying to initialize
2610 // these vectors on gcc (an error is emitted).
2612 QualType SrcTy);
2613
2615 SourceLocation RParenLoc, Expr *Op);
2616
2618 SourceLocation LParenLoc,
2619 Expr *CastExpr,
2620 SourceLocation RParenLoc);
2621
2622 ///@}
2623
2624 //
2625 //
2626 // -------------------------------------------------------------------------
2627 //
2628 //
2629
2630 /// \name Extra Semantic Checking
2631 /// Implementations are in SemaChecking.cpp
2632 ///@{
2633
2634public:
2635 /// Used to change context to isConstantEvaluated without pushing a heavy
2636 /// ExpressionEvaluationContextRecord object.
2638
2643
2645 unsigned ByteNo) const;
2646
2648 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2649 FAPK_Variadic, // values to format are passed as variadic arguments
2650 FAPK_VAList, // values to format are passed in a va_list
2651 FAPK_Elsewhere, // values to format are not passed to this function
2652 };
2653
2654 // Used to grab the relevant information from a FormatAttr and a
2655 // FunctionDeclaration.
2661
2662 /// Given a function and its FormatAttr or FormatMatchesAttr info, attempts to
2663 /// populate the FormatStringInfo parameter with the attribute's correct
2664 /// format_idx and firstDataArg. Returns true when the format fits the
2665 /// function and the FormatStringInfo has been populated.
2666 static bool getFormatStringInfo(const Decl *Function, unsigned FormatIdx,
2667 unsigned FirstArg, FormatStringInfo *FSI);
2668 static bool getFormatStringInfo(unsigned FormatIdx, unsigned FirstArg,
2669 bool HasImplicitThisParam, bool IsVariadic,
2670 FormatStringInfo *FSI);
2671
2672 // Used by C++ template instantiation.
2674
2675 /// ConvertVectorExpr - Handle __builtin_convertvector
2677 SourceLocation BuiltinLoc,
2678 SourceLocation RParenLoc);
2679
2680 static StringRef GetFormatStringTypeName(FormatStringType FST);
2681 static FormatStringType GetFormatStringType(StringRef FormatFlavor);
2682 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2683 static FormatStringType GetFormatStringType(const FormatMatchesAttr *Format);
2684
2685 bool FormatStringHasSArg(const StringLiteral *FExpr);
2686
2687 /// Check for comparisons of floating-point values using == and !=. Issue a
2688 /// warning if the comparison is not likely to do what the programmer
2689 /// intended.
2690 void CheckFloatComparison(SourceLocation Loc, const Expr *LHS,
2691 const Expr *RHS, BinaryOperatorKind Opcode);
2692
2693 /// Register a magic integral constant to be used as a type tag.
2694 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2695 uint64_t MagicValue, QualType Type,
2696 bool LayoutCompatible, bool MustBeNull);
2697
2700
2704
2706
2707 /// If true, \c Type should be compared with other expression's types for
2708 /// layout-compatibility.
2709 LLVM_PREFERRED_TYPE(bool)
2711 LLVM_PREFERRED_TYPE(bool)
2712 unsigned MustBeNull : 1;
2713 };
2714
2715 /// A pair of ArgumentKind identifier and magic value. This uniquely
2716 /// identifies the magic value.
2717 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2718
2719 /// Diagnoses the current set of gathered accesses. This happens at the end of
2720 /// each expression evaluation context. Diagnostics are emitted only for
2721 /// accesses gathered in the current evaluation context.
2723
2724 /// This function checks if the expression is in the sef of potentially
2725 /// misaligned members and it is converted to some pointer type T with lower
2726 /// or equal alignment requirements. If so it removes it. This is used when
2727 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2728 /// void*).
2729 void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
2730
2731 /// Returns true if `From` is a function or pointer to a function with the
2732 /// `cfi_unchecked_callee` attribute but `To` is a function or pointer to
2733 /// function without this attribute.
2734 bool DiscardingCFIUncheckedCallee(QualType From, QualType To) const;
2735
2736 /// This function calls Action when it determines that E designates a
2737 /// misaligned member due to the packed attribute. This is used to emit
2738 /// local diagnostics like in reference binding.
2740 Expr *E,
2741 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2742 Action);
2743
2744 enum class AtomicArgumentOrder { API, AST };
2746 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2747 SourceLocation RParenLoc, MultiExprArg Args,
2750
2751 /// Check to see if a given expression could have '.c_str()' called on it.
2752 bool hasCStrMethod(const Expr *E);
2753
2754 /// Diagnose pointers that are always non-null.
2755 /// \param E the expression containing the pointer
2756 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2757 /// compared to a null pointer
2758 /// \param IsEqual True when the comparison is equal to a null pointer
2759 /// \param Range Extra SourceRange to highlight in the diagnostic
2762 bool IsEqual, SourceRange Range);
2763
2764 /// CheckParmsForFunctionDef - Check that the parameters of the given
2765 /// function are appropriate for the definition of a function. This
2766 /// takes care of any checks that cannot be performed on the
2767 /// declaration itself, e.g., that the types of each of the function
2768 /// parameters are complete.
2770 bool CheckParameterNames);
2771
2772 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2773 /// pointer cast increases the alignment requirements.
2774 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2775
2776 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2777 /// to weak/__unsafe_unretained type.
2778 bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
2779
2780 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2781 /// to weak/__unsafe_unretained expression.
2782 void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
2783
2784 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2785 /// statement as a \p Body, and it is located on the same line.
2786 ///
2787 /// This helps prevent bugs due to typos, such as:
2788 /// if (condition);
2789 /// do_stuff();
2790 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2791 unsigned DiagID);
2792
2793 /// Warn if a for/while loop statement \p S, which is followed by
2794 /// \p PossibleBody, has a suspicious null statement as a body.
2795 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2796
2797 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2798 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2799 SourceLocation OpLoc);
2800
2801 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2803 const TypeSourceInfo *Derived);
2804
2805 /// CheckFunctionCall - Check a direct function call for various correctness
2806 /// and safety properties not strictly enforced by the C type system.
2807 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2808 const FunctionProtoType *Proto);
2809
2816
2817 /// \param FPOnly restricts the arguments to floating-point types.
2818 std::optional<QualType>
2819 BuiltinVectorMath(CallExpr *TheCall,
2822 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2823
2824 void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
2825 const Expr *ThisArg, ArrayRef<const Expr *> Args);
2826
2827 /// Handles the checks for format strings, non-POD arguments to vararg
2828 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2829 /// attributes and AArch64 SME attributes.
2830 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2831 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2832 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2833 VariadicCallType CallType);
2834
2835 /// Verify that two format strings (as understood by attribute(format) and
2836 /// attribute(format_matches) are compatible. If they are incompatible,
2837 /// diagnostics are emitted with the assumption that \c
2838 /// AuthoritativeFormatString is correct and
2839 /// \c TestedFormatString is wrong. If \c FunctionCallArg is provided,
2840 /// diagnostics will point to it and a note will refer to \c
2841 /// TestedFormatString or \c AuthoritativeFormatString as appropriate.
2842 bool
2844 const StringLiteral *AuthoritativeFormatString,
2845 const StringLiteral *TestedFormatString,
2846 const Expr *FunctionCallArg = nullptr);
2847
2848 /// Verify that one format string (as understood by attribute(format)) is
2849 /// self-consistent; for instance, that it doesn't have multiple positional
2850 /// arguments referring to the same argument in incompatible ways. Diagnose
2851 /// if it isn't.
2853
2854 /// \brief Enforce the bounds of a TCB
2855 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2856 /// directly calls other functions in the same TCB as marked by the
2857 /// enforce_tcb and enforce_tcb_leaf attributes.
2858 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2859 const NamedDecl *Callee);
2860
2861 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2862
2863 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2864 /// TheCall is a constant expression.
2865 bool BuiltinConstantArg(CallExpr *TheCall, unsigned ArgNum,
2866 llvm::APSInt &Result);
2867
2868 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2869 /// TheCall is a constant expression in the range [Low, High].
2870 bool BuiltinConstantArgRange(CallExpr *TheCall, unsigned ArgNum, int Low,
2871 int High, bool RangeIsError = true);
2872
2873 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2874 /// TheCall is a constant expression is a multiple of Num..
2875 bool BuiltinConstantArgMultiple(CallExpr *TheCall, unsigned ArgNum,
2876 unsigned Multiple);
2877
2878 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2879 /// constant expression representing a power of 2.
2880 bool BuiltinConstantArgPower2(CallExpr *TheCall, unsigned ArgNum);
2881
2882 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2883 /// a constant expression representing an arbitrary byte value shifted left by
2884 /// a multiple of 8 bits.
2885 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, unsigned ArgNum,
2886 unsigned ArgBits);
2887
2888 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2889 /// TheCall is a constant expression representing either a shifted byte value,
2890 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2891 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2892 /// Arm MVE intrinsics.
2893 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, unsigned ArgNum,
2894 unsigned ArgBits);
2895
2896 /// Checks that a call expression's argument count is at least the desired
2897 /// number. This is useful when doing custom type-checking on a variadic
2898 /// function. Returns true on error.
2899 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2900
2901 /// Checks that a call expression's argument count is at most the desired
2902 /// number. This is useful when doing custom type-checking on a variadic
2903 /// function. Returns true on error.
2904 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2905
2906 /// Checks that a call expression's argument count is in the desired range.
2907 /// This is useful when doing custom type-checking on a variadic function.
2908 /// Returns true on error.
2909 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2910 unsigned MaxArgCount);
2911
2912 /// Checks that a call expression's argument count is the desired number.
2913 /// This is useful when doing custom type-checking. Returns true on error.
2914 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2915
2916 /// Returns true if the argument consists of one contiguous run of 1s with any
2917 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2918 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2919 /// since all 1s are not contiguous.
2920 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2921
2923 bool *ICContext = nullptr,
2924 bool IsListInit = false);
2925
2926 /// Check for overflow behavior type related implicit conversion diagnostics.
2927 /// Returns true if OBT-related diagnostic was issued, false otherwise.
2929 SourceLocation CC);
2930
2931 bool
2936 CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr =
2938
2939private:
2940 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2941 const ArraySubscriptExpr *ASE = nullptr,
2942 bool AllowOnePastEnd = true, bool IndexNegated = false);
2943 void CheckArrayAccess(const Expr *E);
2944
2945 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2946 const FunctionProtoType *Proto);
2947
2948 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
2949 /// such as function pointers returned from functions.
2950 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2951
2952 /// CheckConstructorCall - Check a constructor call for correctness and safety
2953 /// properties not enforced by the C type system.
2954 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2956 const FunctionProtoType *Proto, SourceLocation Loc);
2957
2958 /// Warn if a pointer or reference argument passed to a function points to an
2959 /// object that is less aligned than the parameter. This can happen when
2960 /// creating a typedef with a lower alignment than the original type and then
2961 /// calling functions defined in terms of the original type.
2962 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2963 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2964
2965 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2966
2967 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2968 CallExpr *TheCall);
2969
2970 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2971 CallExpr *TheCall);
2972
2973 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2974
2975 /// Check the arguments to '__builtin_va_start', '__builtin_ms_va_start',
2976 /// or '__builtin_c23_va_start' for validity. Emit an error and return true
2977 /// on failure; return false on success.
2978 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2979 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2980
2981 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
2982 /// friends. This is declared to take (...), so we have to check everything.
2983 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2984
2985 /// BuiltinSemaBuiltinFPClassification - Handle functions like
2986 /// __builtin_isnan and friends. This is declared to take (...), so we have
2987 /// to check everything.
2988 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2989 unsigned BuiltinID);
2990
2991 /// Perform semantic analysis for a call to __builtin_complex.
2992 bool BuiltinComplex(CallExpr *TheCall);
2993 bool BuiltinOSLogFormat(CallExpr *TheCall);
2994
2995 /// BuiltinPrefetch - Handle __builtin_prefetch.
2996 /// This is declared to take (const void*, ...) and can take two
2997 /// optional constant int args.
2998 bool BuiltinPrefetch(CallExpr *TheCall);
2999
3000 /// Handle __builtin_alloca_with_align. This is declared
3001 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
3002 /// than 8.
3003 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
3004
3005 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
3006 bool BuiltinArithmeticFence(CallExpr *TheCall);
3007
3008 /// BuiltinAssume - Handle __assume (MS Extension).
3009 /// __assume does not evaluate its arguments, and should warn if its argument
3010 /// has side effects.
3011 bool BuiltinAssume(CallExpr *TheCall);
3012
3013 /// Handle __builtin_assume_aligned. This is declared
3014 /// as (const void*, size_t, ...) and can take one optional constant int arg.
3015 bool BuiltinAssumeAligned(CallExpr *TheCall);
3016
3017 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
3018 /// This checks that the target supports __builtin_longjmp and
3019 /// that val is a constant 1.
3020 bool BuiltinLongjmp(CallExpr *TheCall);
3021
3022 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
3023 /// This checks that the target supports __builtin_setjmp.
3024 bool BuiltinSetjmp(CallExpr *TheCall);
3025
3026 /// We have a call to a function like __sync_fetch_and_add, which is an
3027 /// overloaded function based on the pointer type of its first argument.
3028 /// The main BuildCallExpr routines have already promoted the types of
3029 /// arguments because all of these calls are prototyped as void(...).
3030 ///
3031 /// This function goes through and does final semantic checking for these
3032 /// builtins, as well as generating any warnings.
3033 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
3034
3035 /// BuiltinNontemporalOverloaded - We have a call to
3036 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
3037 /// overloaded function based on the pointer type of its last argument.
3038 ///
3039 /// This function goes through and does final semantic checking for these
3040 /// builtins.
3041 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
3042 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
3044
3045 /// \param FPOnly restricts the arguments to floating-point types.
3046 bool BuiltinElementwiseMath(CallExpr *TheCall,
3049 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
3050
3051 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
3052
3053 bool CheckInvalidBuiltinCountedByRef(const Expr *E,
3055 bool BuiltinCountedByRef(CallExpr *TheCall);
3056
3057 // Matrix builtin handling.
3058 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
3059 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
3060 ExprResult CallResult);
3061 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
3062 ExprResult CallResult);
3063
3064 /// CheckFormatArguments - Check calls to printf and scanf (and similar
3065 /// functions) for correct use of format strings.
3066 /// Returns true if a format string has been fully checked.
3067 bool CheckFormatArguments(const FormatAttr *Format,
3068 ArrayRef<const Expr *> Args, bool IsCXXMember,
3069 VariadicCallType CallType, SourceLocation Loc,
3070 SourceRange Range,
3071 llvm::SmallBitVector &CheckedVarArgs);
3072 bool CheckFormatString(const FormatMatchesAttr *Format,
3073 ArrayRef<const Expr *> Args, bool IsCXXMember,
3074 VariadicCallType CallType, SourceLocation Loc,
3075 SourceRange Range,
3076 llvm::SmallBitVector &CheckedVarArgs);
3077 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
3078 FormatArgumentPassingKind FAPK,
3079 StringLiteral *ReferenceFormatString,
3080 unsigned format_idx, unsigned firstDataArg,
3082 SourceLocation Loc, SourceRange range,
3083 llvm::SmallBitVector &CheckedVarArgs);
3084
3085 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
3086
3087 /// Warn when using the wrong abs() function.
3088 void CheckAbsoluteValueFunction(const CallExpr *Call,
3089 const FunctionDecl *FDecl);
3090
3091 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
3092
3093 /// Check for dangerous or invalid arguments to memset().
3094 ///
3095 /// This issues warnings on known problematic, dangerous or unspecified
3096 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
3097 /// function calls.
3098 ///
3099 /// \param Call The call expression to diagnose.
3100 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
3101 IdentifierInfo *FnName);
3102
3103 bool CheckSizeofMemaccessArgument(const Expr *SizeOfArg, const Expr *Dest,
3104 IdentifierInfo *FnName);
3105 // Warn if the user has made the 'size' argument to strlcpy or strlcat
3106 // be the size of the source, instead of the destination.
3107 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
3108
3109 // Warn on anti-patterns as the 'size' argument to strncat.
3110 // The correct size argument should look like following:
3111 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
3112 void CheckStrncatArguments(const CallExpr *Call,
3113 const IdentifierInfo *FnName);
3114
3115 /// Alerts the user that they are attempting to free a non-malloc'd object.
3116 void CheckFreeArguments(const CallExpr *E);
3117
3118 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
3119 SourceLocation ReturnLoc, bool isObjCMethod = false,
3120 const AttrVec *Attrs = nullptr,
3121 const FunctionDecl *FD = nullptr);
3122
3123 /// Diagnoses "dangerous" implicit conversions within the given
3124 /// expression (which is a full expression). Implements -Wconversion
3125 /// and -Wsign-compare.
3126 ///
3127 /// \param CC the "context" location of the implicit conversion, i.e.
3128 /// the most location of the syntactic entity requiring the implicit
3129 /// conversion
3130 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
3131
3132 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
3133 /// Input argument E is a logical expression.
3135
3136 /// Diagnose when expression is an integer constant expression and its
3137 /// evaluation results in integer overflow
3138 void CheckForIntOverflow(const Expr *E);
3139 void CheckUnsequencedOperations(const Expr *E);
3140
3141 /// Perform semantic checks on a completed expression. This will either
3142 /// be a full-expression or a default argument expression.
3143 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
3144 bool IsConstexpr = false);
3145
3146 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
3147 Expr *Init);
3148
3149 /// A map from magic value to type information.
3150 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
3151 TypeTagForDatatypeMagicValues;
3152
3153 /// Peform checks on a call of a function with argument_with_type_tag
3154 /// or pointer_with_type_tag attributes.
3155 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
3156 const ArrayRef<const Expr *> ExprArgs,
3157 SourceLocation CallSiteLoc);
3158
3159 /// Check if we are taking the address of a packed field
3160 /// as this may be a problem if the pointer value is dereferenced.
3161 void CheckAddressOfPackedMember(Expr *rhs);
3162
3163 /// Helper class that collects misaligned member designations and
3164 /// their location info for delayed diagnostics.
3165 struct MisalignedMember {
3166 Expr *E;
3167 RecordDecl *RD;
3168 ValueDecl *MD;
3169 CharUnits Alignment;
3170
3171 MisalignedMember() : E(), RD(), MD() {}
3172 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
3173 CharUnits Alignment)
3174 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
3175 explicit MisalignedMember(Expr *E)
3176 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
3177
3178 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
3179 };
3180
3181 /// Adds an expression to the set of gathered misaligned members.
3182 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
3183 CharUnits Alignment);
3184 ///@}
3185
3186 //
3187 //
3188 // -------------------------------------------------------------------------
3189 //
3190 //
3191
3192 /// \name C++ Coroutines
3193 /// Implementations are in SemaCoroutine.cpp
3194 ///@{
3195
3196public:
3197 /// The C++ "std::coroutine_traits" template, which is defined in
3198 /// <coroutine_traits>
3200
3202 StringRef Keyword);
3206
3209 UnresolvedLookupExpr *Lookup);
3211 Expr *Awaiter, bool IsImplicit = false);
3213 UnresolvedLookupExpr *Lookup);
3216 bool IsImplicit = false);
3221
3222 // As a clang extension, enforces that a non-coroutine function must be marked
3223 // with [[clang::coro_wrapper]] if it returns a type marked with
3224 // [[clang::coro_return_type]].
3225 // Expects that FD is not a coroutine.
3227 /// Lookup 'coroutine_traits' in std namespace and std::experimental
3228 /// namespace. The namespace found is recorded in Namespace.
3230 SourceLocation FuncLoc);
3231 /// Check that the expression co_await promise.final_suspend() shall not be
3232 /// potentially-throwing.
3233 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
3234
3235 ///@}
3236
3237 //
3238 //
3239 // -------------------------------------------------------------------------
3240 //
3241 //
3242
3243 /// \name C++ Scope Specifiers
3244 /// Implementations are in SemaCXXScopeSpec.cpp
3245 ///@{
3246
3247public:
3248 // Marks SS invalid if it represents an incomplete type.
3250 // Complete an enum decl, maybe without a scope spec.
3252 CXXScopeSpec *SS = nullptr);
3253
3254 /// Compute the DeclContext that is associated with the given type.
3255 ///
3256 /// \param T the type for which we are attempting to find a DeclContext.
3257 ///
3258 /// \returns the declaration context represented by the type T,
3259 /// or NULL if the declaration context cannot be computed (e.g., because it is
3260 /// dependent and not the current instantiation).
3262
3263 /// Compute the DeclContext that is associated with the given
3264 /// scope specifier.
3265 ///
3266 /// \param SS the C++ scope specifier as it appears in the source
3267 ///
3268 /// \param EnteringContext when true, we will be entering the context of
3269 /// this scope specifier, so we can retrieve the declaration context of a
3270 /// class template or class template partial specialization even if it is
3271 /// not the current instantiation.
3272 ///
3273 /// \returns the declaration context represented by the scope specifier @p SS,
3274 /// or NULL if the declaration context cannot be computed (e.g., because it is
3275 /// dependent and not the current instantiation).
3277 bool EnteringContext = false);
3279
3280 /// If the given nested name specifier refers to the current
3281 /// instantiation, return the declaration that corresponds to that
3282 /// current instantiation (C++0x [temp.dep.type]p1).
3283 ///
3284 /// \param NNS a dependent nested name specifier.
3286
3287 /// The parser has parsed a global nested-name-specifier '::'.
3288 ///
3289 /// \param CCLoc The location of the '::'.
3290 ///
3291 /// \param SS The nested-name-specifier, which will be updated in-place
3292 /// to reflect the parsed nested-name-specifier.
3293 ///
3294 /// \returns true if an error occurred, false otherwise.
3296
3297 /// The parser has parsed a '__super' nested-name-specifier.
3298 ///
3299 /// \param SuperLoc The location of the '__super' keyword.
3300 ///
3301 /// \param ColonColonLoc The location of the '::'.
3302 ///
3303 /// \param SS The nested-name-specifier, which will be updated in-place
3304 /// to reflect the parsed nested-name-specifier.
3305 ///
3306 /// \returns true if an error occurred, false otherwise.
3308 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
3309
3310 /// Determines whether the given declaration is an valid acceptable
3311 /// result for name lookup of a nested-name-specifier.
3312 /// \param SD Declaration checked for nested-name-specifier.
3313 /// \param IsExtension If not null and the declaration is accepted as an
3314 /// extension, the pointed variable is assigned true.
3316 bool *CanCorrect = nullptr);
3317
3318 /// If the given nested-name-specifier begins with a bare identifier
3319 /// (e.g., Base::), perform name lookup for that identifier as a
3320 /// nested-name-specifier within the given scope, and return the result of
3321 /// that name lookup.
3323
3324 /// Keeps information about an identifier in a nested-name-spec.
3325 ///
3327 /// The type of the object, if we're parsing nested-name-specifier in
3328 /// a member access expression.
3330
3331 /// The identifier preceding the '::'.
3333
3334 /// The location of the identifier.
3336
3337 /// The location of the '::'.
3339
3340 /// Creates info object for the most typical case.
3342 SourceLocation ColonColonLoc,
3345 CCLoc(ColonColonLoc) {}
3346
3348 SourceLocation ColonColonLoc, QualType ObjectType)
3350 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
3351 };
3352
3353 /// Build a new nested-name-specifier for "identifier::", as described
3354 /// by ActOnCXXNestedNameSpecifier.
3355 ///
3356 /// \param S Scope in which the nested-name-specifier occurs.
3357 /// \param IdInfo Parser information about an identifier in the
3358 /// nested-name-spec.
3359 /// \param EnteringContext If true, enter the context specified by the
3360 /// nested-name-specifier.
3361 /// \param SS Optional nested name specifier preceding the identifier.
3362 /// \param ScopeLookupResult Provides the result of name lookup within the
3363 /// scope of the nested-name-specifier that was computed at template
3364 /// definition time.
3365 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
3366 /// error recovery and what kind of recovery is performed.
3367 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
3368 /// are allowed. The bool value pointed by this parameter is set to
3369 /// 'true' if the identifier is treated as if it was followed by ':',
3370 /// not '::'.
3371 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3372 ///
3373 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
3374 /// that it contains an extra parameter \p ScopeLookupResult, which provides
3375 /// the result of name lookup within the scope of the nested-name-specifier
3376 /// that was computed at template definition time.
3377 ///
3378 /// If ErrorRecoveryLookup is true, then this call is used to improve error
3379 /// recovery. This means that it should not emit diagnostics, it should
3380 /// just return true on failure. It also means it should only return a valid
3381 /// scope if it *knows* that the result is correct. It should not return in a
3382 /// dependent context, for example. Nor will it extend \p SS with the scope
3383 /// specifier.
3384 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3385 bool EnteringContext, CXXScopeSpec &SS,
3386 NamedDecl *ScopeLookupResult,
3387 bool ErrorRecoveryLookup,
3388 bool *IsCorrectedToColon = nullptr,
3389 bool OnlyNamespace = false);
3390
3391 /// The parser has parsed a nested-name-specifier 'identifier::'.
3392 ///
3393 /// \param S The scope in which this nested-name-specifier occurs.
3394 ///
3395 /// \param IdInfo Parser information about an identifier in the
3396 /// nested-name-spec.
3397 ///
3398 /// \param EnteringContext Whether we're entering the context nominated by
3399 /// this nested-name-specifier.
3400 ///
3401 /// \param SS The nested-name-specifier, which is both an input
3402 /// parameter (the nested-name-specifier before this type) and an
3403 /// output parameter (containing the full nested-name-specifier,
3404 /// including this new type).
3405 ///
3406 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
3407 /// are allowed. The bool value pointed by this parameter is set to 'true'
3408 /// if the identifier is treated as if it was followed by ':', not '::'.
3409 ///
3410 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3411 ///
3412 /// \returns true if an error occurred, false otherwise.
3413 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3414 bool EnteringContext, CXXScopeSpec &SS,
3415 bool *IsCorrectedToColon = nullptr,
3416 bool OnlyNamespace = false);
3417
3418 /// The parser has parsed a nested-name-specifier
3419 /// 'template[opt] template-name < template-args >::'.
3420 ///
3421 /// \param S The scope in which this nested-name-specifier occurs.
3422 ///
3423 /// \param SS The nested-name-specifier, which is both an input
3424 /// parameter (the nested-name-specifier before this type) and an
3425 /// output parameter (containing the full nested-name-specifier,
3426 /// including this new type).
3427 ///
3428 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
3429 /// \param TemplateName the template name.
3430 /// \param TemplateNameLoc The location of the template name.
3431 /// \param LAngleLoc The location of the opening angle bracket ('<').
3432 /// \param TemplateArgs The template arguments.
3433 /// \param RAngleLoc The location of the closing angle bracket ('>').
3434 /// \param CCLoc The location of the '::'.
3435 ///
3436 /// \param EnteringContext Whether we're entering the context of the
3437 /// nested-name-specifier.
3438 ///
3439 ///
3440 /// \returns true if an error occurred, false otherwise.
3442 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
3443 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
3444 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
3445 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
3446
3448 SourceLocation ColonColonLoc);
3449
3451 const DeclSpec &DS,
3452 SourceLocation ColonColonLoc,
3453 QualType Type);
3454
3455 /// IsInvalidUnlessNestedName - This method is used for error recovery
3456 /// purposes to determine whether the specified identifier is only valid as
3457 /// a nested name specifier, for example a namespace name. It is
3458 /// conservatively correct to always return false from this method.
3459 ///
3460 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
3462 NestedNameSpecInfo &IdInfo,
3463 bool EnteringContext);
3464
3465 /// Given a C++ nested-name-specifier, produce an annotation value
3466 /// that the parser can use later to reconstruct the given
3467 /// nested-name-specifier.
3468 ///
3469 /// \param SS A nested-name-specifier.
3470 ///
3471 /// \returns A pointer containing all of the information in the
3472 /// nested-name-specifier \p SS.
3474
3475 /// Given an annotation pointer for a nested-name-specifier, restore
3476 /// the nested-name-specifier structure.
3477 ///
3478 /// \param Annotation The annotation pointer, produced by
3479 /// \c SaveNestedNameSpecifierAnnotation().
3480 ///
3481 /// \param AnnotationRange The source range corresponding to the annotation.
3482 ///
3483 /// \param SS The nested-name-specifier that will be updated with the contents
3484 /// of the annotation pointer.
3485 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
3486 SourceRange AnnotationRange,
3487 CXXScopeSpec &SS);
3488
3489 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
3490
3491 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
3492 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
3493 /// After this method is called, according to [C++ 3.4.3p3], names should be
3494 /// looked up in the declarator-id's scope, until the declarator is parsed and
3495 /// ActOnCXXExitDeclaratorScope is called.
3496 /// The 'SS' should be a non-empty valid CXXScopeSpec.
3498
3499 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
3500 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
3501 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
3502 /// Used to indicate that names should revert to being looked up in the
3503 /// defining scope.
3505
3506 ///@}
3507
3508 //
3509 //
3510 // -------------------------------------------------------------------------
3511 //
3512 //
3513
3514 /// \name Declarations
3515 /// Implementations are in SemaDecl.cpp
3516 ///@{
3517
3518public:
3520
3521 /// The index of the first InventedParameterInfo that refers to the current
3522 /// context.
3524
3525 /// A RAII object to temporarily push a declaration context.
3527 private:
3528 Sema &S;
3529 DeclContext *SavedContext;
3530 ProcessingContextState SavedContextState;
3531 QualType SavedCXXThisTypeOverride;
3532 unsigned SavedFunctionScopesStart;
3533 unsigned SavedInventedParameterInfosStart;
3534
3535 public:
3536 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3537 : S(S), SavedContext(S.CurContext),
3538 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3539 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3540 SavedFunctionScopesStart(S.FunctionScopesStart),
3541 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3542 assert(ContextToPush && "pushing null context");
3543 S.CurContext = ContextToPush;
3544 if (NewThisContext)
3545 S.CXXThisTypeOverride = QualType();
3546 // Any saved FunctionScopes do not refer to this context.
3547 S.FunctionScopesStart = S.FunctionScopes.size();
3548 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3549 }
3550
3551 void pop() {
3552 if (!SavedContext)
3553 return;
3554 S.CurContext = SavedContext;
3555 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3556 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3557 S.FunctionScopesStart = SavedFunctionScopesStart;
3558 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3559 SavedContext = nullptr;
3560 }
3561
3563 ContextRAII(const ContextRAII &) = delete;
3565 };
3566
3567 void DiagnoseInvalidJumps(Stmt *Body);
3568
3569 /// The function definitions which were renamed as part of typo-correction
3570 /// to match their respective declarations. We want to keep track of them
3571 /// to ensure that we don't emit a "redefinition" error if we encounter a
3572 /// correctly named definition after the renamed definition.
3574
3575 /// A cache of the flags available in enumerations with the flag_bits
3576 /// attribute.
3577 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3578
3579 /// A cache of enumerator values for enums checked by -Wassign-enum.
3580 llvm::DenseMap<const EnumDecl *, llvm::SmallVector<llvm::APSInt>>
3582
3583 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3584 /// declared. Rare. May alias another identifier, declared or undeclared.
3585 ///
3586 /// For aliases, the target identifier is used as a key for eventual
3587 /// processing when the target is declared. For the single-identifier form,
3588 /// the sole identifier is used as the key. Each entry is a `SetVector`
3589 /// (ordered by parse order) of aliases (identified by the alias name) in case
3590 /// of multiple aliases to the same undeclared identifier.
3591 llvm::MapVector<
3593 llvm::SetVector<
3595 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3597
3598 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3599 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3600 /// to define functions that occur in multiple standards to call the version
3601 /// in the currently selected standard.
3602 llvm::MapVector<IdentifierInfo *, AsmLabelAttr *>
3604
3605 /// Set containing all typedefs that are likely unused.
3608
3612
3613 /// The set of file scoped decls seen so far that have not been used
3614 /// and must warn if not used. Only contains the first declaration.
3616
3620
3621 /// All the tentative definitions encountered in the TU.
3623
3624 /// All the external declarations encoutered and used in the TU.
3626
3627 /// Generally null except when we temporarily switch decl contexts,
3628 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3630
3631 /// Is the module scope we are in a C++ Header Unit?
3633 return ModuleScopes.empty() ? false
3634 : ModuleScopes.back().Module->isHeaderUnit();
3635 }
3636
3637 /// Get the module owning an entity.
3638 Module *getOwningModule(const Decl *Entity) {
3639 return Entity->getOwningModule();
3640 }
3641
3642 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3643
3645 /// Returns the TypeDeclType for the given type declaration,
3646 /// as ASTContext::getTypeDeclType would, but
3647 /// performs the required semantic checks for name lookup of said entity.
3648 void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD,
3649 SourceLocation NameLoc);
3650
3651 /// If the identifier refers to a type name within this scope,
3652 /// return the declaration of that type.
3653 ///
3654 /// This routine performs ordinary name lookup of the identifier II
3655 /// within the given scope, with optional C++ scope specifier SS, to
3656 /// determine whether the name refers to a type. If so, returns an
3657 /// opaque pointer (actually a QualType) corresponding to that
3658 /// type. Otherwise, returns NULL.
3660 Scope *S, CXXScopeSpec *SS = nullptr,
3661 bool isClassName = false, bool HasTrailingDot = false,
3662 ParsedType ObjectType = nullptr,
3663 bool IsCtorOrDtorName = false,
3664 bool WantNontrivialTypeSourceInfo = false,
3665 bool IsClassTemplateDeductionContext = true,
3666 ImplicitTypenameContext AllowImplicitTypename =
3668 IdentifierInfo **CorrectedII = nullptr);
3669
3670 /// isTagName() - This method is called *for error recovery purposes only*
3671 /// to determine if the specified name is a valid tag name ("struct foo"). If
3672 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3673 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3674 /// diagnose cases in C where the user forgot to specify the tag.
3676
3677 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3678 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3679 /// then downgrade the missing typename error to a warning.
3680 /// This is needed for MSVC compatibility; Example:
3681 /// @code
3682 /// template<class T> class A {
3683 /// public:
3684 /// typedef int TYPE;
3685 /// };
3686 /// template<class T> class B : public A<T> {
3687 /// public:
3688 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3689 /// };
3690 /// @endcode
3691 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3693 Scope *S, CXXScopeSpec *SS,
3694 ParsedType &SuggestedType,
3695 bool IsTemplateName = false);
3696
3697 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3698 /// type name has failed in a dependent context. In these situations, we
3699 /// automatically form a DependentTypeName that will retry lookup in a related
3700 /// scope during instantiation.
3702 SourceLocation NameLoc,
3703 bool IsTemplateTypeArg);
3704
3705 class NameClassification {
3707 union {
3712 };
3713
3714 explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
3715
3716 public:
3719
3722
3723 static NameClassification Error() {
3724 return NameClassification(NameClassificationKind::Error);
3725 }
3726
3727 static NameClassification Unknown() {
3728 return NameClassification(NameClassificationKind::Unknown);
3729 }
3730
3731 static NameClassification OverloadSet(ExprResult E) {
3732 NameClassification Result(NameClassificationKind::OverloadSet);
3733 Result.Expr = E;
3734 return Result;
3735 }
3736
3737 static NameClassification NonType(NamedDecl *D) {
3738 NameClassification Result(NameClassificationKind::NonType);
3739 Result.NonTypeDecl = D;
3740 return Result;
3741 }
3742
3743 static NameClassification UndeclaredNonType() {
3744 return NameClassification(NameClassificationKind::UndeclaredNonType);
3745 }
3746
3747 static NameClassification DependentNonType() {
3748 return NameClassification(NameClassificationKind::DependentNonType);
3749 }
3750
3751 static NameClassification TypeTemplate(TemplateName Name) {
3752 NameClassification Result(NameClassificationKind::TypeTemplate);
3753 Result.Template = Name;
3754 return Result;
3755 }
3756
3757 static NameClassification VarTemplate(TemplateName Name) {
3758 NameClassification Result(NameClassificationKind::VarTemplate);
3759 Result.Template = Name;
3760 return Result;
3761 }
3762
3763 static NameClassification FunctionTemplate(TemplateName Name) {
3765 Result.Template = Name;
3766 return Result;
3767 }
3768
3769 static NameClassification Concept(TemplateName Name) {
3770 NameClassification Result(NameClassificationKind::Concept);
3771 Result.Template = Name;
3772 return Result;
3773 }
3774
3775 static NameClassification UndeclaredTemplate(TemplateName Name) {
3777 Result.Template = Name;
3778 return Result;
3779 }
3780
3781 NameClassificationKind getKind() const { return Kind; }
3782
3785 return Expr;
3786 }
3787
3789 assert(Kind == NameClassificationKind::Type);
3790 return Type;
3791 }
3792
3794 assert(Kind == NameClassificationKind::NonType);
3795 return NonTypeDecl;
3796 }
3797
3806
3808 switch (Kind) {
3810 return TNK_Type_template;
3812 return TNK_Function_template;
3814 return TNK_Var_template;
3816 return TNK_Concept_template;
3819 default:
3820 llvm_unreachable("unsupported name classification.");
3821 }
3822 }
3823 };
3824
3825 /// Perform name lookup on the given name, classifying it based on
3826 /// the results of name lookup and the following token.
3827 ///
3828 /// This routine is used by the parser to resolve identifiers and help direct
3829 /// parsing. When the identifier cannot be found, this routine will attempt
3830 /// to correct the typo and classify based on the resulting name.
3831 ///
3832 /// \param S The scope in which we're performing name lookup.
3833 ///
3834 /// \param SS The nested-name-specifier that precedes the name.
3835 ///
3836 /// \param Name The identifier. If typo correction finds an alternative name,
3837 /// this pointer parameter will be updated accordingly.
3838 ///
3839 /// \param NameLoc The location of the identifier.
3840 ///
3841 /// \param NextToken The token following the identifier. Used to help
3842 /// disambiguate the name.
3843 ///
3844 /// \param CCC The correction callback, if typo correction is desired.
3845 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3846 IdentifierInfo *&Name, SourceLocation NameLoc,
3847 const Token &NextToken,
3848 CorrectionCandidateCallback *CCC = nullptr);
3849
3850 /// Act on the result of classifying a name as an undeclared (ADL-only)
3851 /// non-type declaration.
3853 SourceLocation NameLoc);
3854 /// Act on the result of classifying a name as an undeclared member of a
3855 /// dependent base class.
3857 IdentifierInfo *Name,
3858 SourceLocation NameLoc,
3859 bool IsAddressOfOperand);
3860 /// Act on the result of classifying a name as a specific non-type
3861 /// declaration.
3864 SourceLocation NameLoc,
3865 const Token &NextToken);
3866 /// Act on the result of classifying a name as an overload set.
3868
3869 /// Describes the detailed kind of a template name. Used in diagnostics.
3881
3882 /// Determine whether it's plausible that E was intended to be a
3883 /// template-name.
3885 if (!getLangOpts().CPlusPlus || E.isInvalid())
3886 return false;
3887 Dependent = false;
3888 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3889 return !DRE->hasExplicitTemplateArgs();
3890 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3891 return !ME->hasExplicitTemplateArgs();
3892 Dependent = true;
3893 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3894 return !DSDRE->hasExplicitTemplateArgs();
3895 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3896 return !DSME->hasExplicitTemplateArgs();
3897 // Any additional cases recognized here should also be handled by
3898 // diagnoseExprIntendedAsTemplateName.
3899 return false;
3900 }
3901
3902 void warnOnReservedIdentifier(const NamedDecl *D);
3904
3905 void ProcessPragmaExport(DeclaratorDecl *newDecl);
3906
3908
3910 MultiTemplateParamsArg TemplateParameterLists);
3911
3912 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3913 /// true if we were successful.
3915 SourceLocation Loc,
3916 unsigned FailedFoldDiagID);
3917
3918 /// Register the given locally-scoped extern "C" declaration so
3919 /// that it can be found later for redeclarations. We include any extern "C"
3920 /// declaration that is not visible in the translation unit here, not just
3921 /// function-scope declarations.
3923
3924 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3925 /// If T is the name of a class, then each of the following shall have a
3926 /// name different from T:
3927 /// - every static data member of class T;
3928 /// - every member function of class T
3929 /// - every member of class T that is itself a type;
3930 /// \returns true if the declaration name violates these rules.
3932
3933 /// Diagnose a declaration whose declarator-id has the given
3934 /// nested-name-specifier.
3935 ///
3936 /// \param SS The nested-name-specifier of the declarator-id.
3937 ///
3938 /// \param DC The declaration context to which the nested-name-specifier
3939 /// resolves.
3940 ///
3941 /// \param Name The name of the entity being declared.
3942 ///
3943 /// \param Loc The location of the name of the entity being declared.
3944 ///
3945 /// \param IsMemberSpecialization Whether we are declaring a member
3946 /// specialization.
3947 ///
3948 /// \param TemplateId The template-id, if any.
3949 ///
3950 /// \returns true if we cannot safely recover from this error, false
3951 /// otherwise.
3954 TemplateIdAnnotation *TemplateId,
3955 bool IsMemberSpecialization);
3956
3958
3959 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
3960
3962 unsigned &IntVal);
3963
3964 /// Diagnose function specifiers on a declaration of an identifier that
3965 /// does not identify a function.
3966 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
3967
3968 /// Return the declaration shadowed by the given typedef \p D, or null
3969 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3971 const LookupResult &R);
3972
3973 /// Return the declaration shadowed by the given variable \p D, or null
3974 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3976
3977 /// Return the declaration shadowed by the given variable \p D, or null
3978 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3980 const LookupResult &R);
3981 /// Diagnose variable or built-in function shadowing. Implements
3982 /// -Wshadow.
3983 ///
3984 /// This method is called whenever a VarDecl is added to a "useful"
3985 /// scope.
3986 ///
3987 /// \param ShadowedDecl the declaration that is shadowed by the given variable
3988 /// \param R the lookup of the name
3989 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
3990 const LookupResult &R);
3991
3992 /// Check -Wshadow without the advantage of a previous lookup.
3993 void CheckShadow(Scope *S, VarDecl *D);
3994
3995 /// Warn if 'E', which is an expression that is about to be modified, refers
3996 /// to a shadowing declaration.
3998
3999 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
4000 /// when these variables are captured by the lambda.
4002
4003 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
4004 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
4005 TypedefNameDecl *NewTD);
4008 TypeSourceInfo *TInfo,
4010
4011 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
4012 /// declares a typedef-name, either using the 'typedef' type specifier or via
4013 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
4017 TypeSourceInfo *TInfo,
4019 MultiTemplateParamsArg TemplateParamLists,
4020 bool &AddToScope,
4022
4023private:
4024 // Perform a check on an AsmLabel to verify its consistency and emit
4025 // diagnostics in case of an error.
4026 void CheckAsmLabel(Scope *S, Expr *AsmLabelExpr, StorageClass SC,
4027 TypeSourceInfo *TInfo, VarDecl *);
4028
4029public:
4030 /// Perform semantic checking on a newly-created variable
4031 /// declaration.
4032 ///
4033 /// This routine performs all of the type-checking required for a
4034 /// variable declaration once it has been built. It is used both to
4035 /// check variables after they have been parsed and their declarators
4036 /// have been translated into a declaration, and to check variables
4037 /// that have been instantiated from a template.
4038 ///
4039 /// Sets NewVD->isInvalidDecl() if an error was encountered.
4040 ///
4041 /// Returns true if the variable declaration is a redeclaration.
4042 bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
4043 void CheckVariableDeclarationType(VarDecl *NewVD);
4044 void CheckCompleteVariableDeclaration(VarDecl *VD);
4045
4046 NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
4047 TypeSourceInfo *TInfo,
4048 LookupResult &Previous,
4049 MultiTemplateParamsArg TemplateParamLists,
4050 bool &AddToScope);
4051
4052 /// AddOverriddenMethods - See if a method overrides any in the base classes,
4053 /// and if so, check that it's a valid override and remember it.
4054 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
4055
4056 /// Perform semantic checking of a new function declaration.
4057 ///
4058 /// Performs semantic analysis of the new function declaration
4059 /// NewFD. This routine performs all semantic checking that does not
4060 /// require the actual declarator involved in the declaration, and is
4061 /// used both for the declaration of functions as they are parsed
4062 /// (called via ActOnDeclarator) and for the declaration of functions
4063 /// that have been instantiated via C++ template instantiation (called
4064 /// via InstantiateDecl).
4065 ///
4066 /// \param IsMemberSpecialization whether this new function declaration is
4067 /// a member specialization (that replaces any definition provided by the
4068 /// previous declaration).
4069 ///
4070 /// This sets NewFD->isInvalidDecl() to true if there was an error.
4071 ///
4072 /// \returns true if the function declaration is a redeclaration.
4073 bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
4074 LookupResult &Previous,
4075 bool IsMemberSpecialization, bool DeclIsDefn);
4076
4077 /// Checks if the new declaration declared in dependent context must be
4078 /// put in the same redeclaration chain as the specified declaration.
4079 ///
4080 /// \param D Declaration that is checked.
4081 /// \param PrevDecl Previous declaration found with proper lookup method for
4082 /// the same declaration name.
4083 /// \returns True if D must be added to the redeclaration chain which PrevDecl
4084 /// belongs to.
4085 bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
4086
4087 /// Determines if we can perform a correct type check for \p D as a
4088 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
4089 /// best-effort check.
4090 ///
4091 /// \param NewD The new declaration.
4092 /// \param OldD The old declaration.
4093 /// \param NewT The portion of the type of the new declaration to check.
4094 /// \param OldT The portion of the type of the old declaration to check.
4095 bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
4096 QualType NewT, QualType OldT);
4097 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
4098 void CheckMSVCRTEntryPoint(FunctionDecl *FD);
4099
4100 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
4101 /// containing class. Otherwise it will return implicit SectionAttr if the
4102 /// function is a definition and there is an active value on CodeSegStack
4103 /// (from the current #pragma code-seg value).
4104 ///
4105 /// \param FD Function being declared.
4106 /// \param IsDefinition Whether it is a definition or just a declaration.
4107 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
4108 /// nullptr if no attribute should be added.
4109 Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
4110 bool IsDefinition);
4111
4112 /// Common checks for a parameter-declaration that should apply to both
4113 /// function parameters and non-type template parameters.
4114 void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
4115
4116 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
4117 /// to introduce parameters into function prototype scope.
4118 Decl *ActOnParamDeclarator(Scope *S, Declarator &D,
4119 SourceLocation ExplicitThisLoc = {});
4120
4121 /// Synthesizes a variable for a parameter arising from a
4122 /// typedef.
4123 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
4124 QualType T);
4125 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
4126 SourceLocation NameLoc,
4127 const IdentifierInfo *Name, QualType T,
4128 TypeSourceInfo *TSInfo, StorageClass SC);
4129
4130 /// Emit diagnostics if the initializer or any of its explicit or
4131 /// implicitly-generated subexpressions require copying or
4132 /// default-initializing a type that is or contains a C union type that is
4133 /// non-trivial to copy or default-initialize.
4134 void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc);
4135
4136 // These flags are passed to checkNonTrivialCUnion.
4142
4143 /// Emit diagnostics if a non-trivial C union type or a struct that contains
4144 /// a non-trivial C union is used in an invalid context.
4146 NonTrivialCUnionContext UseContext,
4147 unsigned NonTrivialKind);
4148
4149 /// Certain globally-unique variables might be accidentally duplicated if
4150 /// built into multiple shared libraries with hidden visibility. This can
4151 /// cause problems if the variable is mutable, its initialization is
4152 /// effectful, or its address is taken.
4155
4156 /// AddInitializerToDecl - Adds the initializer Init to the
4157 /// declaration dcl. If DirectInit is true, this is C++ direct
4158 /// initialization rather than copy initialization.
4159 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
4160 void ActOnUninitializedDecl(Decl *dcl);
4161
4162 /// ActOnInitializerError - Given that there was an error parsing an
4163 /// initializer for the given declaration, try to at least re-establish
4164 /// invariants such as whether a variable's type is either dependent or
4165 /// complete.
4166 void ActOnInitializerError(Decl *Dcl);
4167
4168 void ActOnCXXForRangeDecl(Decl *D);
4170 IdentifierInfo *Ident,
4171 ParsedAttributes &Attrs);
4172
4173 /// Check if VD needs to be dllexport/dllimport due to being in a
4174 /// dllexport/import function.
4177
4178 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
4179 /// any semantic actions necessary after any initializer has been attached.
4180 void FinalizeDeclaration(Decl *D);
4182 ArrayRef<Decl *> Group);
4183
4184 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
4185 /// group, performing any necessary semantic checking.
4187
4188 /// Should be called on all declarations that might have attached
4189 /// documentation comments.
4190 void ActOnDocumentableDecl(Decl *D);
4192
4193 enum class FnBodyKind {
4194 /// C++26 [dcl.fct.def.general]p1
4195 /// function-body:
4196 /// ctor-initializer[opt] compound-statement
4197 /// function-try-block
4199 /// = default ;
4201 /// deleted-function-body
4202 ///
4203 /// deleted-function-body:
4204 /// = delete ;
4205 /// = delete ( unevaluated-string ) ;
4207 };
4208
4210 SourceLocation LocAfterDecls);
4212 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
4213 SkipBodyInfo *SkipBody = nullptr);
4215 MultiTemplateParamsArg TemplateParamLists,
4216 SkipBodyInfo *SkipBody = nullptr,
4217 FnBodyKind BodyKind = FnBodyKind::Other);
4219 SkipBodyInfo *SkipBody = nullptr,
4220 FnBodyKind BodyKind = FnBodyKind::Other);
4222
4223 /// Determine whether we can delay parsing the body of a function or
4224 /// function template until it is used, assuming we don't care about emitting
4225 /// code for that function.
4226 ///
4227 /// This will be \c false if we may need the body of the function in the
4228 /// middle of parsing an expression (where it's impractical to switch to
4229 /// parsing a different function), for instance, if it's constexpr in C++11
4230 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
4231 bool canDelayFunctionBody(const Declarator &D);
4232
4233 /// Determine whether we can skip parsing the body of a function
4234 /// definition, assuming we don't care about analyzing its body or emitting
4235 /// code for that function.
4236 ///
4237 /// This will be \c false only if we may need the body of the function in
4238 /// order to parse the rest of the program (for instance, if it is
4239 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
4240 bool canSkipFunctionBody(Decl *D);
4241
4242 /// Given the set of return statements within a function body,
4243 /// compute the variables that are subject to the named return value
4244 /// optimization.
4245 ///
4246 /// Each of the variables that is subject to the named return value
4247 /// optimization will be marked as NRVO variables in the AST, and any
4248 /// return statement that has a marked NRVO variable as its NRVO candidate can
4249 /// use the named return value optimization.
4250 ///
4251 /// This function applies a very simplistic algorithm for NRVO: if every
4252 /// return statement in the scope of a variable has the same NRVO candidate,
4253 /// that candidate is an NRVO variable.
4255
4256 /// Performs semantic analysis at the end of a function body.
4257 ///
4258 /// \param RetainFunctionScopeInfo If \c true, the client is responsible for
4259 /// releasing the associated \p FunctionScopeInfo. This is useful when
4260 /// building e.g. LambdaExprs.
4262 bool IsInstantiation = false,
4263 bool RetainFunctionScopeInfo = false);
4266
4267 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
4268 /// attribute for which parsing is delayed.
4270
4271 /// Diagnose any unused parameters in the given sequence of
4272 /// ParmVarDecl pointers.
4274
4275 /// Diagnose whether the size of parameters or return value of a
4276 /// function or obj-c method definition is pass-by-value and larger than a
4277 /// specified threshold.
4278 void
4280 QualType ReturnTy, NamedDecl *D);
4281
4283 SourceLocation RParenLoc);
4284
4287
4288 void ActOnPopScope(SourceLocation Loc, Scope *S);
4289
4290 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4291 /// no declarator (e.g. "struct foo;") is parsed.
4293 const ParsedAttributesView &DeclAttrs,
4294 RecordDecl *&AnonRecord);
4295
4296 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4297 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
4298 /// parameters to cope with template friend declarations.
4300 const ParsedAttributesView &DeclAttrs,
4301 MultiTemplateParamsArg TemplateParams,
4302 bool IsExplicitInstantiation,
4303 RecordDecl *&AnonRecord,
4304 SourceLocation EllipsisLoc = {});
4305
4306 /// BuildAnonymousStructOrUnion - Handle the declaration of an
4307 /// anonymous structure or union. Anonymous unions are a C++ feature
4308 /// (C++ [class.union]) and a C11 feature; anonymous structures
4309 /// are a C11 feature and GNU C++ extension.
4310 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
4311 RecordDecl *Record,
4312 const PrintingPolicy &Policy);
4313
4314 /// Called once it is known whether
4315 /// a tag declaration is an anonymous union or struct.
4317
4318 /// Emit diagnostic warnings for placeholder members.
4319 /// We can only do that after the class is fully constructed,
4320 /// as anonymous union/structs can insert placeholders
4321 /// in their parent scope (which might be a Record).
4323
4324 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
4325 /// Microsoft C anonymous structure.
4326 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
4327 /// Example:
4328 ///
4329 /// struct A { int a; };
4330 /// struct B { struct A; int b; };
4331 ///
4332 /// void foo() {
4333 /// B var;
4334 /// var.a = 3;
4335 /// }
4336 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
4337 RecordDecl *Record);
4338
4339 /// Given a non-tag type declaration, returns an enum useful for indicating
4340 /// what kind of non-tag type this is.
4341 NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
4342
4343 /// Determine whether a tag with a given kind is acceptable
4344 /// as a redeclaration of the given tag declaration.
4345 ///
4346 /// \returns true if the new tag kind is acceptable, false otherwise.
4348 bool isDefinition, SourceLocation NewTagLoc,
4349 const IdentifierInfo *Name);
4350
4351 /// This is invoked when we see 'struct foo' or 'struct {'. In the
4352 /// former case, Name will be non-null. In the later case, Name will be null.
4353 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
4354 /// a reference/declaration/definition of a tag.
4355 ///
4356 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
4357 /// trailing-type-specifier) other than one in an alias-declaration.
4358 ///
4359 /// \param SkipBody If non-null, will be set to indicate if the caller should
4360 /// skip the definition of this tag and treat it as if it were a declaration.
4361 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
4362 SourceLocation KWLoc, CXXScopeSpec &SS,
4363 IdentifierInfo *Name, SourceLocation NameLoc,
4364 const ParsedAttributesView &Attr, AccessSpecifier AS,
4365 SourceLocation ModulePrivateLoc,
4366 MultiTemplateParamsArg TemplateParameterLists,
4367 bool &OwnedDecl, bool &IsDependent,
4368 SourceLocation ScopedEnumKWLoc,
4369 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
4370 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
4371 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
4372
4373 /// ActOnField - Each field of a C struct/union is passed into this in order
4374 /// to create a FieldDecl object for it.
4375 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
4376 Declarator &D, Expr *BitfieldWidth);
4377
4378 /// HandleField - Analyze a field of a C struct or a C++ data member.
4379 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
4380 Declarator &D, Expr *BitfieldWidth,
4381 InClassInitStyle InitStyle, AccessSpecifier AS);
4382
4383 /// Build a new FieldDecl and check its well-formedness.
4384 ///
4385 /// This routine builds a new FieldDecl given the fields name, type,
4386 /// record, etc. \p PrevDecl should refer to any previous declaration
4387 /// with the same name and in the same scope as the field to be
4388 /// created.
4389 ///
4390 /// \returns a new FieldDecl.
4391 ///
4392 /// \todo The Declarator argument is a hack. It will be removed once
4393 FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
4394 TypeSourceInfo *TInfo, RecordDecl *Record,
4395 SourceLocation Loc, bool Mutable,
4396 Expr *BitfieldWidth, InClassInitStyle InitStyle,
4397 SourceLocation TSSL, AccessSpecifier AS,
4398 NamedDecl *PrevDecl, Declarator *D = nullptr);
4399
4401
4402 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
4403 /// class and class extensions. For every class \@interface and class
4404 /// extension \@interface, if the last ivar is a bitfield of any type,
4405 /// then add an implicit `char :0` ivar to the end of that interface.
4406 void ActOnLastBitfield(SourceLocation DeclStart,
4407 SmallVectorImpl<Decl *> &AllIvarDecls);
4408
4409 // This is used for both record definitions and ObjC interface declarations.
4410 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
4411 ArrayRef<Decl *> Fields, SourceLocation LBrac,
4412 SourceLocation RBrac, const ParsedAttributesView &AttrList);
4413
4414 /// ActOnTagStartDefinition - Invoked when we have entered the
4415 /// scope of a tag's definition (e.g., for an enumeration, class,
4416 /// struct, or union).
4417 void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
4418
4419 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
4420 /// Differently from C++, actually parse the body and reject / error out
4421 /// in case of a structural mismatch.
4422 bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody);
4423
4425
4426 /// Invoked when we enter a tag definition that we're skipping.
4428
4429 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
4430 /// C++ record definition's base-specifiers clause and are starting its
4431 /// member declarations.
4433 SourceLocation FinalLoc,
4434 bool IsFinalSpelledSealed,
4435 bool IsAbstract,
4436 SourceLocation LBraceLoc);
4437
4438 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
4439 /// the definition of a tag (enumeration, class, struct, or union).
4441 SourceRange BraceRange);
4442
4445
4447
4448 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
4449 /// error parsing the definition of a tag.
4451
4453 EnumConstantDecl *LastEnumConst,
4454 SourceLocation IdLoc, IdentifierInfo *Id,
4455 Expr *val);
4456
4457 /// Check that this is a valid underlying type for an enum declaration.
4459
4460 /// Check whether this is a valid redeclaration of a previous enumeration.
4461 /// \return true if the redeclaration was invalid.
4462 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
4463 QualType EnumUnderlyingTy, bool IsFixed,
4464 const EnumDecl *Prev);
4465
4466 /// Determine whether the body of an anonymous enumeration should be skipped.
4467 /// \param II The name of the first enumerator.
4469 SourceLocation IILoc);
4470
4471 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
4472 SourceLocation IdLoc, IdentifierInfo *Id,
4473 const ParsedAttributesView &Attrs,
4474 SourceLocation EqualLoc, Expr *Val,
4475 SkipBodyInfo *SkipBody = nullptr);
4476 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
4477 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
4478 const ParsedAttributesView &Attr);
4479
4480 /// Set the current declaration context until it gets popped.
4481 void PushDeclContext(Scope *S, DeclContext *DC);
4482 void PopDeclContext();
4483
4484 /// EnterDeclaratorContext - Used when we must lookup names in the context
4485 /// of a declarator's nested name specifier.
4488
4489 /// Enter a template parameter scope, after it's been associated with a
4490 /// particular DeclContext. Causes lookup within the scope to chain through
4491 /// enclosing contexts in the correct order.
4493
4494 /// Push the parameters of D, which must be a function, into scope.
4497
4498 /// Add this decl to the scope shadowed decl chains.
4499 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4500
4501 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4502 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4503 /// true if 'D' belongs to the given declaration context.
4504 ///
4505 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4506 /// enclosing namespace set of the context, rather than contained
4507 /// directly within it.
4508 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4509 bool AllowInlineNamespace = false) const;
4510
4511 /// Finds the scope corresponding to the given decl context, if it
4512 /// happens to be an enclosing scope. Otherwise return NULL.
4514
4515 /// Subroutines of ActOnDeclarator().
4517 TypeSourceInfo *TInfo);
4519
4520 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4522 NamedDecl *New, Decl *Old,
4524
4525 /// CheckAttributesOnDeducedType - Calls Sema functions for attributes that
4526 /// requires the type to be deduced.
4528
4529 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4530 /// same name and scope as a previous declaration 'Old'. Figure out
4531 /// how to resolve this situation, merging decls or emitting
4532 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4534 LookupResult &OldDecls);
4535
4536 /// CleanupMergedEnum - We have just merged the decl 'New' by making another
4537 /// definition visible.
4538 /// This method performs any necessary cleanup on the parser state to discard
4539 /// child nodes from newly parsed decl we are retiring.
4540 void CleanupMergedEnum(Scope *S, Decl *New);
4541
4542 /// MergeFunctionDecl - We just parsed a function 'New' from
4543 /// declarator D which has the same name and scope as a previous
4544 /// declaration 'Old'. Figure out how to resolve this situation,
4545 /// merging decls or emitting diagnostics as appropriate.
4546 ///
4547 /// In C++, New and Old must be declarations that are not
4548 /// overloaded. Use IsOverload to determine whether New and Old are
4549 /// overloaded, and to select the Old declaration that New should be
4550 /// merged with.
4551 ///
4552 /// Returns true if there was an error, false otherwise.
4554 bool MergeTypeWithOld, bool NewDeclIsDefn);
4555
4556 /// Completes the merge of two function declarations that are
4557 /// known to be compatible.
4558 ///
4559 /// This routine handles the merging of attributes and other
4560 /// properties of function declarations from the old declaration to
4561 /// the new declaration, once we know that New is in fact a
4562 /// redeclaration of Old.
4563 ///
4564 /// \returns false
4566 Scope *S, bool MergeTypeWithOld);
4568
4569 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4570 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4571 /// situation, merging decls or emitting diagnostics as appropriate.
4572 ///
4573 /// Tentative definition rules (C99 6.9.2p2) are checked by
4574 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4575 /// definitions here, since the initializer hasn't been attached.
4577
4578 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4579 /// scope as a previous declaration 'Old'. Figure out how to merge their
4580 /// types, emitting diagnostics as appropriate.
4581 ///
4582 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4583 /// back to here in AddInitializerToDecl. We can't check them before the
4584 /// initializer is attached.
4585 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4586
4587 /// We've just determined that \p Old and \p New both appear to be definitions
4588 /// of the same variable. Either diagnose or fix the problem.
4589 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4591
4592 /// Filters out lookup results that don't fall within the given scope
4593 /// as determined by isDeclInScope.
4595 bool ConsiderLinkage, bool AllowInlineNamespace);
4596
4597 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4598 /// have compatible owning modules.
4600
4601 /// [module.interface]p6:
4602 /// A redeclaration of an entity X is implicitly exported if X was introduced
4603 /// by an exported declaration; otherwise it shall not be exported.
4605
4606 /// A wrapper function for checking the semantic restrictions of
4607 /// a redeclaration within a module.
4609
4610 /// Check the redefinition in C++20 Modules.
4611 ///
4612 /// [basic.def.odr]p14:
4613 /// For any definable item D with definitions in multiple translation units,
4614 /// - if D is a non-inline non-templated function or variable, or
4615 /// - if the definitions in different translation units do not satisfy the
4616 /// following requirements,
4617 /// the program is ill-formed; a diagnostic is required only if the
4618 /// definable item is attached to a named module and a prior definition is
4619 /// reachable at the point where a later definition occurs.
4620 /// - Each such definition shall not be attached to a named module
4621 /// ([module.unit]).
4622 /// - Each such definition shall consist of the same sequence of tokens, ...
4623 /// ...
4624 ///
4625 /// Return true if the redefinition is not allowed. Return false otherwise.
4626 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4627
4629
4630 /// If it's a file scoped decl that must warn if not used, keep track
4631 /// of it.
4633
4634 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4636
4639 DiagReceiverTy DiagReceiver);
4640 void DiagnoseUnusedDecl(const NamedDecl *ND);
4641
4642 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4643 /// unless they are marked attr(unused).
4644 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4645
4646 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4647 /// variable.
4648 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4649
4650 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4651 /// from S, where a non-field would be declared. This routine copes
4652 /// with the difference between C and C++ scoping rules in structs and
4653 /// unions. For example, the following code is well-formed in C but
4654 /// ill-formed in C++:
4655 /// @code
4656 /// struct S6 {
4657 /// enum { BAR } e;
4658 /// };
4659 ///
4660 /// void test_S6() {
4661 /// struct S6 a;
4662 /// a.e = BAR;
4663 /// }
4664 /// @endcode
4665 /// For the declaration of BAR, this routine will return a different
4666 /// scope. The scope S will be the scope of the unnamed enumeration
4667 /// within S6. In C++, this routine will return the scope associated
4668 /// with S6, because the enumeration's scope is a transparent
4669 /// context but structures can contain non-field names. In C, this
4670 /// routine will return the translation unit scope, since the
4671 /// enumeration's scope is a transparent context and structures cannot
4672 /// contain non-field names.
4674
4676 SourceLocation Loc);
4677
4678 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4679 /// file scope. lazily create a decl for it. ForRedeclaration is true
4680 /// if we're creating this built-in in anticipation of redeclaring the
4681 /// built-in.
4682 NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S,
4683 bool ForRedeclaration, SourceLocation Loc);
4684
4685 /// Get the outermost AttributedType node that sets a calling convention.
4686 /// Valid types should not have multiple attributes with different CCs.
4687 const AttributedType *getCallingConvAttributedType(QualType T) const;
4688
4689 /// GetNameForDeclarator - Determine the full declaration name for the
4690 /// given Declarator.
4692
4693 /// Retrieves the declaration name from a parsed unqualified-id.
4695
4696 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4697 /// we are currently parsing the initializer.
4699
4700 /// Look for a locally scoped extern "C" declaration by the given name.
4702
4705
4706 /// Adjust the \c DeclContext for a function or variable that might be a
4707 /// function-local external declaration.
4709
4711
4712 /// Checks if the variant/multiversion functions are compatible.
4714 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4715 const PartialDiagnostic &NoProtoDiagID,
4716 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4717 const PartialDiagnosticAt &NoSupportDiagIDAt,
4718 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4719 bool ConstexprSupported, bool CLinkageMayDiffer);
4720
4721 /// type checking declaration initializers (C99 6.7.8)
4723 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4724
4727 SourceRange Range, bool DirectInit,
4728 Expr *Init);
4729
4731 Expr *Init);
4732
4734
4735 // Heuristically tells if the function is `get_return_object` member of a
4736 // coroutine promise_type by matching the function name.
4737 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4738 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4739
4740 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4741 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4743 Scope *S);
4744
4745 /// If this function is a C++ replaceable global allocation function
4746 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4747 /// adds any function attributes that we know a priori based on the standard.
4748 ///
4749 /// We need to check for duplicate attributes both here and where user-written
4750 /// attributes are applied to declarations.
4752 FunctionDecl *FD);
4753
4754 /// Adds any function attributes that we know a priori based on
4755 /// the declaration of this function.
4756 ///
4757 /// These attributes can apply both to implicitly-declared builtins
4758 /// (like __builtin___printf_chk) or to library-declared functions
4759 /// like NSLog or printf.
4760 ///
4761 /// We need to check for duplicate attributes both here and where user-written
4762 /// attributes are applied to declarations.
4764
4765 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4766 /// the correct width, and that the field type is valid.
4767 /// Returns false on success.
4769 const IdentifierInfo *FieldName, QualType FieldTy,
4770 bool IsMsStruct, Expr *BitWidth);
4771
4772 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4773 /// enum. If AllowMask is true, then we also allow the complement of a valid
4774 /// value, to be used as a mask.
4775 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4776 bool AllowMask) const;
4777
4778 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4779 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4780 SourceLocation WeakNameLoc);
4781
4782 /// ActOnPragmaRedefineExtname - Called on well formed
4783 /// \#pragma redefine_extname oldname newname.
4785 IdentifierInfo *AliasName,
4786 SourceLocation PragmaLoc,
4787 SourceLocation WeakNameLoc,
4788 SourceLocation AliasNameLoc);
4789
4790 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4791 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4792 SourceLocation PragmaLoc,
4793 SourceLocation WeakNameLoc,
4794 SourceLocation AliasNameLoc);
4795
4796 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4799 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4800 OMPDiscarded, // Discarded due to OpenMP hostness
4801 TemplateDiscarded, // Discarded due to uninstantiated templates
4803 };
4804 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4805 bool Final = false);
4806
4807 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4809
4810 /// Function or variable declarations to be checked for whether the deferred
4811 /// diagnostics should be emitted.
4813
4814private:
4815 /// Map of current shadowing declarations to shadowed declarations. Warn if
4816 /// it looks like the user is trying to modify the shadowing declaration.
4817 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4818
4819 // We need this to handle
4820 //
4821 // typedef struct {
4822 // void *foo() { return 0; }
4823 // } A;
4824 //
4825 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4826 // for example. If 'A', foo will have external linkage. If we have '*A',
4827 // foo will have no linkage. Since we can't know until we get to the end
4828 // of the typedef, this function finds out if D might have non-external
4829 // linkage. Callers should verify at the end of the TU if it D has external
4830 // linkage or not.
4831 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4832
4833#include "clang/Sema/AttrIsTypeDependent.inc"
4834
4835 ///@}
4836
4837 //
4838 //
4839 // -------------------------------------------------------------------------
4840 //
4841 //
4842
4843 /// \name Declaration Attribute Handling
4844 /// Implementations are in SemaDeclAttr.cpp
4845 ///@{
4846
4847public:
4848 /// Describes the kind of priority given to an availability attribute.
4849 ///
4850 /// The sum of priorities deteremines the final priority of the attribute.
4851 /// The final priority determines how the attribute will be merged.
4852 /// An attribute with a lower priority will always remove higher priority
4853 /// attributes for the specified platform when it is being applied. An
4854 /// attribute with a higher priority will not be applied if the declaration
4855 /// already has an availability attribute with a lower priority for the
4856 /// specified platform. The final prirority values are not expected to match
4857 /// the values in this enumeration, but instead should be treated as a plain
4858 /// integer value. This enumeration just names the priority weights that are
4859 /// used to calculate that final vaue.
4861 /// The availability attribute was specified explicitly next to the
4862 /// declaration.
4864
4865 /// The availability attribute was applied using '#pragma clang attribute'.
4867
4868 /// The availability attribute for a specific platform was inferred from
4869 /// an availability attribute for another platform.
4871
4872 /// The availability attribute was inferred from an 'anyAppleOS'
4873 /// availability attribute.
4875
4876 /// The availability attribute was inferred from an 'anyAppleOS'
4877 /// availability attribute that was applied using '#pragma clang attribute'.
4878 /// This has the lowest priority.
4880 };
4881
4882 /// Describes the reason a calling convention specification was ignored, used
4883 /// for diagnostics.
4890
4891 /// A helper function to provide Attribute Location for the Attr types
4892 /// AND the ParsedAttr.
4893 template <typename AttrInfo>
4894 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4895 getAttrLoc(const AttrInfo &AL) {
4896 return AL.getLocation();
4897 }
4899
4900 /// If Expr is a valid integer constant, get the value of the integer
4901 /// expression and return success or failure. May output an error.
4902 ///
4903 /// Negative argument is implicitly converted to unsigned, unless
4904 /// \p StrictlyUnsigned is true.
4905 template <typename AttrInfo>
4906 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4907 unsigned Idx = UINT_MAX,
4908 bool StrictlyUnsigned = false) {
4909 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4910 if (Expr->isTypeDependent() ||
4912 if (Idx != UINT_MAX)
4913 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4914 << &AI << Idx << AANT_ArgumentIntegerConstant
4915 << Expr->getSourceRange();
4916 else
4917 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4919 return false;
4920 }
4921
4922 if (!I->isIntN(32)) {
4923 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4924 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4925 return false;
4926 }
4927
4928 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
4929 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
4930 << &AI << /*non-negative*/ 1;
4931 return false;
4932 }
4933
4934 Val = (uint32_t)I->getZExtValue();
4935 return true;
4936 }
4937
4938 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
4939 /// \#pragma weak during processing of other Decls.
4940 /// I couldn't figure out a clean way to generate these in-line, so
4941 /// we store them here and handle separately -- which is a hack.
4942 /// It would be best to refactor this.
4944
4945 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
4947
4951
4952 /// ExtVectorDecls - This is a list all the extended vector types. This allows
4953 /// us to associate a raw vector type with one of the ext_vector type names.
4954 /// This is only necessary for issuing pretty diagnostics.
4956
4957 /// Check if the argument \p E is a ASCII string literal. If not emit an error
4958 /// and return false, otherwise set \p Str to the value of the string literal
4959 /// and return true.
4961 const Expr *E, StringRef &Str,
4962 SourceLocation *ArgLocation = nullptr);
4963
4964 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
4965 /// If not emit an error and return false. If the argument is an identifier it
4966 /// will emit an error with a fixit hint and treat it as if it was a string
4967 /// literal.
4968 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
4969 StringRef &Str,
4970 SourceLocation *ArgLocation = nullptr);
4971
4972 /// Determine if type T is a valid subject for a nonnull and similar
4973 /// attributes. Dependent types are considered valid so they can be checked
4974 /// during instantiation time. By default, we look through references (the
4975 /// behavior used by nonnull), but if the second parameter is true, then we
4976 /// treat a reference type as valid.
4977 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
4978
4979 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
4980 /// declaration.
4981 void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4982 Expr *OE);
4983
4984 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
4985 /// declaration.
4986 void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
4987 Expr *ParamExpr);
4988
4989 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
4990 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
4991
4992 AvailabilityAttr *
4994 const IdentifierInfo *Platform, bool Implicit,
4995 VersionTuple Introduced, VersionTuple Deprecated,
4996 VersionTuple Obsoleted, bool IsUnavailable,
4997 StringRef Message, bool IsStrict, StringRef Replacement,
4998 AvailabilityMergeKind AMK, int Priority,
4999 const IdentifierInfo *IIEnvironment,
5000 const IdentifierInfo *InferredPlatformII = nullptr);
5001
5002 AvailabilityAttr *mergeAndInferAvailabilityAttr(
5003 NamedDecl *D, const AttributeCommonInfo &CI,
5004 const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced,
5005 VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable,
5006 StringRef Message, bool IsStrict, StringRef Replacement,
5007 AvailabilityMergeKind AMK, int Priority,
5008 const IdentifierInfo *IIEnvironment,
5009 const IdentifierInfo *InferredPlatformII);
5010
5011 TypeVisibilityAttr *
5013 TypeVisibilityAttr::VisibilityType Vis);
5014 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
5015 VisibilityAttr::VisibilityType Vis);
5017 VisibilityAttr::VisibilityType Type);
5018 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
5019 StringRef Name);
5020
5021 /// Used to implement to perform semantic checking on
5022 /// attribute((section("foo"))) specifiers.
5023 ///
5024 /// In this case, "foo" is passed in to be checked. If the section
5025 /// specifier is invalid, return an Error that indicates the problem.
5026 ///
5027 /// This is a simple quality of implementation feature to catch errors
5028 /// and give good diagnostics in cases when the assembler or code generator
5029 /// would otherwise reject the section specifier.
5030 llvm::Error isValidSectionSpecifier(StringRef Str);
5031 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
5032 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
5033 StringRef Name);
5034
5035 // Check for things we'd like to warn about. Multiversioning issues are
5036 // handled later in the process, once we know how many exist.
5037 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
5038
5039 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
5040 StringRef NewUserDiagnostic);
5041 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
5042 const IdentifierInfo *Format, int FormatIdx,
5043 int FirstArg);
5044 FormatMatchesAttr *mergeFormatMatchesAttr(Decl *D,
5045 const AttributeCommonInfo &CI,
5046 const IdentifierInfo *Format,
5047 int FormatIdx,
5048 StringLiteral *FormatStr);
5049 ModularFormatAttr *mergeModularFormatAttr(Decl *D,
5050 const AttributeCommonInfo &CI,
5051 const IdentifierInfo *ModularImplFn,
5052 StringRef ImplName,
5054
5055 PersonalityAttr *mergePersonalityAttr(Decl *D, FunctionDecl *Routine,
5056 const AttributeCommonInfo &CI);
5057
5058 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
5059 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
5060 bool IsPackExpansion);
5062 bool IsPackExpansion);
5063
5064 /// AddAlignValueAttr - Adds an align_value attribute to a particular
5065 /// declaration.
5066 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
5067
5068 /// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
5069 Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
5072
5074 bool BestCase,
5075 MSInheritanceModel SemanticSpelling);
5076
5078
5079 /// AddModeAttr - Adds a mode attribute to a particular declaration.
5080 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
5081 const IdentifierInfo *Name, bool InInstantiation = false);
5082 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
5083 const AttributeCommonInfo &CI,
5084 const IdentifierInfo *Ident);
5085 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
5086 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
5087 const AttributeCommonInfo &CI);
5088 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
5089 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
5090 const InternalLinkageAttr &AL);
5091
5092 /// Check validaty of calling convention attribute \p attr. If \p FD
5093 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
5094 /// target. Otherwise, it is specified by \p CFT.
5096 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
5098
5099 /// Checks a regparm attribute, returning true if it is ill-formed and
5100 /// otherwise setting numParams to the appropriate value.
5101 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
5102
5103 /// Create a CUDALaunchBoundsAttr attribute. By default, the function only
5104 /// supports nvptx target architectures and skips MaxBlocks if it is previous
5105 /// to sm_90. Use \p IgnoreArch to skip the architecture check.
5106 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
5107 Expr *MaxThreads,
5108 Expr *MinBlocks, Expr *MaxBlocks,
5109 bool IgnoreArch = false);
5110
5111 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
5112 /// declaration.
5113 void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
5114 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
5115
5116 /// Add a cluster_dims attribute to a particular declaration.
5117 CUDAClusterDimsAttr *createClusterDimsAttr(const AttributeCommonInfo &CI,
5118 Expr *X, Expr *Y, Expr *Z);
5119 void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X,
5120 Expr *Y, Expr *Z);
5121 /// Add a no_cluster attribute to a particular declaration.
5122 void addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI);
5123
5124 enum class RetainOwnershipKind { NS, CF, OS };
5125
5126 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
5127 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
5128
5129 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
5130
5131 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
5132 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
5133 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
5134 const AttributeCommonInfo &CI,
5135 bool BestCase,
5136 MSInheritanceModel Model);
5137
5138 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
5139 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
5140 const EnforceTCBLeafAttr &AL);
5141
5142 /// Helper for delayed processing TransparentUnion or
5143 /// BPFPreserveAccessIndexAttr attribute.
5145 const ParsedAttributesView &AttrList);
5146
5147 // Options for ProcessDeclAttributeList().
5151
5154 Result.IncludeCXX11Attributes = Val;
5155 return Result;
5156 }
5157
5160 Result.IgnoreTypeAttributes = Val;
5161 return Result;
5162 }
5163
5164 // Should C++11 attributes be processed?
5166
5167 // Should any type attributes encountered be ignored?
5168 // If this option is false, a diagnostic will be emitted for any type
5169 // attributes of a kind that does not "slide" from the declaration to
5170 // the decl-specifier-seq.
5172 };
5173
5174 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
5175 /// attribute list to the specified decl, ignoring any type attributes.
5177 const ParsedAttributesView &AttrList,
5178 const ProcessDeclAttributeOptions &Options =
5180
5181 /// Annotation attributes are the only attributes allowed after an access
5182 /// specifier.
5184 const ParsedAttributesView &AttrList);
5185
5186 /// checkUnusedDeclAttributes - Given a declarator which is not being
5187 /// used to build a declaration, complain about any decl attributes
5188 /// which might be lying around on it.
5190
5191 void DiagnoseUnknownAttribute(const ParsedAttr &AL);
5192
5193 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
5194 /// \#pragma weak needs a non-definition decl and source may not have one.
5196 SourceLocation Loc);
5197
5198 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
5199 /// applied to it, possibly with an alias.
5200 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
5201
5202 void ProcessPragmaWeak(Scope *S, Decl *D);
5203 // Decl attributes - this routine is the top level dispatcher.
5204 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
5205
5207
5208 /// Given a set of delayed diagnostics, re-emit them as if they had
5209 /// been delayed in the current context instead of in the given pool.
5210 /// Essentially, this just moves them to the current pool.
5212
5213 /// Check that the type is a plain record with one field being a pointer
5214 /// type and the other field being an integer. This matches the common
5215 /// implementation of std::span or sized_allocation_t in P0901R11.
5216 bool CheckSpanLikeType(const AttributeCommonInfo &CI, const QualType &Ty);
5217
5218 /// Check if IdxExpr is a valid parameter index for a function or
5219 /// instance method D. May output an error.
5220 ///
5221 /// \returns true if IdxExpr is a valid index.
5222 template <typename AttrInfo>
5224 const Decl *D, const AttrInfo &AI, unsigned AttrArgNum,
5225 const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis = false,
5226 bool CanIndexVariadicArguments = false) {
5228
5229 // In C++ the implicit 'this' function parameter also counts.
5230 // Parameters are counted from one.
5231 bool HP = hasFunctionProto(D);
5232 bool HasImplicitThisParam = hasImplicitObjectParameter(D);
5233 bool IV = HP && isFunctionOrMethodVariadic(D);
5234 unsigned NumParams =
5235 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
5236
5237 std::optional<llvm::APSInt> IdxInt;
5238 if (IdxExpr->isTypeDependent() ||
5239 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
5240 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
5241 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
5242 << IdxExpr->getSourceRange();
5243 return false;
5244 }
5245
5246 constexpr unsigned Limit = 1 << ParamIdx::IdxBitWidth;
5247 unsigned IdxSource = IdxInt->getLimitedValue(Limit);
5248 if (IdxSource < 1 || IdxSource == Limit ||
5249 ((!IV || !CanIndexVariadicArguments) && IdxSource > NumParams)) {
5250 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
5251 << &AI << AttrArgNum << IdxExpr->getSourceRange();
5252 return false;
5253 }
5254 if (HasImplicitThisParam && !CanIndexImplicitThis) {
5255 if (IdxSource == 1) {
5256 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
5257 << &AI << IdxExpr->getSourceRange();
5258 return false;
5259 }
5260 }
5261
5262 Idx = ParamIdx(IdxSource, D);
5263 return true;
5264 }
5265
5266 ///@}
5267
5268 //
5269 //
5270 // -------------------------------------------------------------------------
5271 //
5272 //
5273
5274 /// \name C++ Declarations
5275 /// Implementations are in SemaDeclCXX.cpp
5276 ///@{
5277
5278public:
5280
5281 /// Called before parsing a function declarator belonging to a function
5282 /// declaration.
5284 unsigned TemplateParameterDepth);
5285
5286 /// Called after parsing a function declarator belonging to a function
5287 /// declaration.
5289
5290 // Act on C++ namespaces
5292 SourceLocation NamespaceLoc,
5293 SourceLocation IdentLoc, IdentifierInfo *Ident,
5294 SourceLocation LBrace,
5295 const ParsedAttributesView &AttrList,
5296 UsingDirectiveDecl *&UsingDecl, bool IsNested);
5297
5298 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
5299 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
5300 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
5301
5303
5304 /// Retrieve the special "std" namespace, which may require us to
5305 /// implicitly define the namespace.
5307
5309 EnumDecl *getStdAlignValT() const;
5310
5313 QualType AllocType, SourceLocation);
5314
5316 const IdentifierInfo *MemberOrBase);
5317
5319 /// The '<=>' operator was used in an expression and a builtin operator
5320 /// was selected.
5322 /// A defaulted 'operator<=>' needed the comparison category. This
5323 /// typically only applies to 'std::strong_ordering', due to the implicit
5324 /// fallback return value.
5326 };
5327
5328 /// Lookup the specified comparison category types in the standard
5329 /// library, an check the VarDecls possibly returned by the operator<=>
5330 /// builtins for that type.
5331 ///
5332 /// \return The type of the comparison category type corresponding to the
5333 /// specified Kind, or a null type if an error occurs
5335 SourceLocation Loc,
5337
5338 /// Tests whether Ty is an instance of std::initializer_list and, if
5339 /// it is and Element is not NULL, assigns the element type to Element.
5340 bool isStdInitializerList(QualType Ty, QualType *Element);
5341
5342 /// Tests whether Ty is an instance of std::type_identity and, if
5343 /// it is and TypeArgument is not NULL, assigns the element type to Element.
5344 /// If MalformedDecl is not null, and type_identity was ruled out due to being
5345 /// incorrectly structured despite having the correct name, the faulty Decl
5346 /// will be assigned to MalformedDecl.
5347 bool isStdTypeIdentity(QualType Ty, QualType *TypeArgument,
5348 const Decl **MalformedDecl = nullptr);
5349
5350 /// Looks for the std::initializer_list template and instantiates it
5351 /// with Element, or emits an error if it's not found.
5352 ///
5353 /// \returns The instantiated template, or null on error.
5355
5356 /// Looks for the std::type_identity template and instantiates it
5357 /// with Type, or returns a null type if type_identity has not been declared
5358 ///
5359 /// \returns The instantiated template, or null if std::type_identity is not
5360 /// declared
5362
5363 /// Determine whether Ctor is an initializer-list constructor, as
5364 /// defined in [dcl.init.list]p2.
5365 bool isInitListConstructor(const FunctionDecl *Ctor);
5366
5367 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
5368 SourceLocation NamespcLoc, CXXScopeSpec &SS,
5369 SourceLocation IdentLoc,
5370 IdentifierInfo *NamespcName,
5371 const ParsedAttributesView &AttrList);
5372
5374
5375 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
5376 SourceLocation AliasLoc, IdentifierInfo *Alias,
5377 CXXScopeSpec &SS, SourceLocation IdentLoc,
5378 IdentifierInfo *Ident);
5379
5380 /// Remove decls we can't actually see from a lookup being used to declare
5381 /// shadow using decls.
5382 ///
5383 /// \param S - The scope of the potential shadow decl
5384 /// \param Previous - The lookup of a potential shadow decl's name.
5385 void FilterUsingLookup(Scope *S, LookupResult &lookup);
5386
5387 /// Hides a using shadow declaration. This is required by the current
5388 /// using-decl implementation when a resolvable using declaration in a
5389 /// class is followed by a declaration which would hide or override
5390 /// one or more of the using decl's targets; for example:
5391 ///
5392 /// struct Base { void foo(int); };
5393 /// struct Derived : Base {
5394 /// using Base::foo;
5395 /// void foo(int);
5396 /// };
5397 ///
5398 /// The governing language is C++03 [namespace.udecl]p12:
5399 ///
5400 /// When a using-declaration brings names from a base class into a
5401 /// derived class scope, member functions in the derived class
5402 /// override and/or hide member functions with the same name and
5403 /// parameter types in a base class (rather than conflicting).
5404 ///
5405 /// There are two ways to implement this:
5406 /// (1) optimistically create shadow decls when they're not hidden
5407 /// by existing declarations, or
5408 /// (2) don't create any shadow decls (or at least don't make them
5409 /// visible) until we've fully parsed/instantiated the class.
5410 /// The problem with (1) is that we might have to retroactively remove
5411 /// a shadow decl, which requires several O(n) operations because the
5412 /// decl structures are (very reasonably) not designed for removal.
5413 /// (2) avoids this but is very fiddly and phase-dependent.
5414 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
5415
5416 /// Determines whether to create a using shadow decl for a particular
5417 /// decl, given the set of decls existing prior to this using lookup.
5419 const LookupResult &PreviousDecls,
5420 UsingShadowDecl *&PrevShadow);
5421
5422 /// Builds a shadow declaration corresponding to a 'using' declaration.
5425 UsingShadowDecl *PrevDecl);
5426
5427 /// Checks that the given using declaration is not an invalid
5428 /// redeclaration. Note that this is checking only for the using decl
5429 /// itself, not for any ill-formedness among the UsingShadowDecls.
5431 bool HasTypenameKeyword,
5432 const CXXScopeSpec &SS,
5433 SourceLocation NameLoc,
5434 const LookupResult &Previous);
5435
5436 /// Checks that the given nested-name qualifier used in a using decl
5437 /// in the current context is appropriately related to the current
5438 /// scope. If an error is found, diagnoses it and returns true.
5439 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
5440 /// the result of that lookup. UD is likewise nullptr, except when we have an
5441 /// already-populated UsingDecl whose shadow decls contain the same
5442 /// information (i.e. we're instantiating a UsingDecl with non-dependent
5443 /// scope).
5444 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
5445 const CXXScopeSpec &SS,
5446 const DeclarationNameInfo &NameInfo,
5447 SourceLocation NameLoc,
5448 const LookupResult *R = nullptr,
5449 const UsingDecl *UD = nullptr);
5450
5451 /// Builds a using declaration.
5452 ///
5453 /// \param IsInstantiation - Whether this call arises from an
5454 /// instantiation of an unresolved using declaration. We treat
5455 /// the lookup differently for these declarations.
5457 SourceLocation UsingLoc,
5458 bool HasTypenameKeyword,
5459 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5460 DeclarationNameInfo NameInfo,
5461 SourceLocation EllipsisLoc,
5462 const ParsedAttributesView &AttrList,
5463 bool IsInstantiation, bool IsUsingIfExists);
5465 SourceLocation UsingLoc,
5466 SourceLocation EnumLoc,
5467 SourceLocation NameLoc,
5468 TypeSourceInfo *EnumType, EnumDecl *ED);
5469 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
5470 ArrayRef<NamedDecl *> Expansions);
5471
5472 /// Additional checks for a using declaration referring to a constructor name.
5474
5475 /// Given a derived-class using shadow declaration for a constructor and the
5476 /// correspnding base class constructor, find or create the implicit
5477 /// synthesized derived class constructor to use for this initialization.
5480 ConstructorUsingShadowDecl *DerivedShadow);
5481
5483 SourceLocation UsingLoc,
5484 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5485 UnqualifiedId &Name, SourceLocation EllipsisLoc,
5486 const ParsedAttributesView &AttrList);
5488 SourceLocation UsingLoc,
5489 SourceLocation EnumLoc, SourceRange TyLoc,
5490 const IdentifierInfo &II, ParsedType Ty,
5491 const CXXScopeSpec &SS);
5493 MultiTemplateParamsArg TemplateParams,
5494 SourceLocation UsingLoc, UnqualifiedId &Name,
5495 const ParsedAttributesView &AttrList,
5496 TypeResult Type, Decl *DeclFromDeclSpec);
5497
5498 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
5499 /// including handling of its default argument expressions.
5500 ///
5501 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
5503 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5505 bool HadMultipleCandidates, bool IsListInitialization,
5506 bool IsStdInitListInitialization, bool RequiresZeroInit,
5507 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5508
5509 /// Build a CXXConstructExpr whose constructor has already been resolved if
5510 /// it denotes an inherited constructor.
5512 SourceLocation ConstructLoc, QualType DeclInitType,
5513 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5514 bool HadMultipleCandidates, bool IsListInitialization,
5515 bool IsStdInitListInitialization, bool RequiresZeroInit,
5516 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5517
5518 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
5519 // the constructor can be elidable?
5521 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5522 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5523 bool HadMultipleCandidates, bool IsListInitialization,
5524 bool IsStdInitListInitialization, bool RequiresZeroInit,
5525 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5526
5528 SourceLocation InitLoc);
5529
5530 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
5531 /// constructed variable.
5532 void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit);
5533
5534 /// Helper class that collects exception specifications for
5535 /// implicitly-declared special member functions.
5537 // Pointer to allow copying
5538 Sema *Self;
5539 // We order exception specifications thus:
5540 // noexcept is the most restrictive, but is only used in C++11.
5541 // throw() comes next.
5542 // Then a throw(collected exceptions)
5543 // Finally no specification, which is expressed as noexcept(false).
5544 // throw(...) is used instead if any called function uses it.
5545 ExceptionSpecificationType ComputedEST;
5546 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5547 SmallVector<QualType, 4> Exceptions;
5548
5549 void ClearExceptions() {
5550 ExceptionsSeen.clear();
5551 Exceptions.clear();
5552 }
5553
5554 public:
5556 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5557 if (!Self.getLangOpts().CPlusPlus11)
5558 ComputedEST = EST_DynamicNone;
5559 }
5560
5561 /// Get the computed exception specification type.
5563 assert(!isComputedNoexcept(ComputedEST) &&
5564 "noexcept(expr) should not be a possible result");
5565 return ComputedEST;
5566 }
5567
5568 /// The number of exceptions in the exception specification.
5569 unsigned size() const { return Exceptions.size(); }
5570
5571 /// The set of exceptions in the exception specification.
5572 const QualType *data() const { return Exceptions.data(); }
5573
5574 /// Integrate another called method into the collected data.
5575 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5576
5577 /// Integrate an invoked expression into the collected data.
5578 void CalledExpr(Expr *E) { CalledStmt(E); }
5579
5580 /// Integrate an invoked statement into the collected data.
5581 void CalledStmt(Stmt *S);
5582
5583 /// Overwrite an EPI's exception specification with this
5584 /// computed exception specification.
5587 ESI.Type = getExceptionSpecType();
5588 if (ESI.Type == EST_Dynamic) {
5589 ESI.Exceptions = Exceptions;
5590 } else if (ESI.Type == EST_None) {
5591 /// C++11 [except.spec]p14:
5592 /// The exception-specification is noexcept(false) if the set of
5593 /// potential exceptions of the special member function contains "any"
5594 ESI.Type = EST_NoexceptFalse;
5595 ESI.NoexceptExpr =
5596 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5597 }
5598 return ESI;
5599 }
5600 };
5601
5602 /// Evaluate the implicit exception specification for a defaulted
5603 /// special member function.
5605
5606 /// Check the given exception-specification and update the
5607 /// exception specification information with the results.
5608 void checkExceptionSpecification(bool IsTopLevel,
5610 ArrayRef<ParsedType> DynamicExceptions,
5611 ArrayRef<SourceRange> DynamicExceptionRanges,
5612 Expr *NoexceptExpr,
5613 SmallVectorImpl<QualType> &Exceptions,
5615
5616 /// Add an exception-specification to the given member or friend function
5617 /// (or function template). The exception-specification was parsed
5618 /// after the function itself was declared.
5620 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5621 ArrayRef<ParsedType> DynamicExceptions,
5622 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5623
5624 class InheritedConstructorInfo;
5625
5626 /// Determine if a special member function should have a deleted
5627 /// definition when it is defaulted.
5629 InheritedConstructorInfo *ICI = nullptr,
5630 bool Diagnose = false);
5631
5632 /// Produce notes explaining why a defaulted function was defined as deleted.
5634
5635 /// Declare the implicit default constructor for the given class.
5636 ///
5637 /// \param ClassDecl The class declaration into which the implicit
5638 /// default constructor will be added.
5639 ///
5640 /// \returns The implicitly-declared default constructor.
5643
5644 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5645 /// defining this constructor as the default constructor.
5648
5649 /// Declare the implicit destructor for the given class.
5650 ///
5651 /// \param ClassDecl The class declaration into which the implicit
5652 /// destructor will be added.
5653 ///
5654 /// \returns The implicitly-declared destructor.
5656
5657 /// DefineImplicitDestructor - Checks for feasibility of
5658 /// defining this destructor as the default destructor.
5659 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5661
5662 /// Build an exception spec for destructors that don't have one.
5663 ///
5664 /// C++11 says that user-defined destructors with no exception spec get one
5665 /// that looks as if the destructor was implicitly declared.
5667
5668 /// Define the specified inheriting constructor.
5671
5672 /// Declare the implicit copy constructor for the given class.
5673 ///
5674 /// \param ClassDecl The class declaration into which the implicit
5675 /// copy constructor will be added.
5676 ///
5677 /// \returns The implicitly-declared copy constructor.
5679
5680 /// DefineImplicitCopyConstructor - Checks for feasibility of
5681 /// defining this constructor as the copy constructor.
5682 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5684
5685 /// Declare the implicit move constructor for the given class.
5686 ///
5687 /// \param ClassDecl The Class declaration into which the implicit
5688 /// move constructor will be added.
5689 ///
5690 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5691 /// declared.
5693
5694 /// DefineImplicitMoveConstructor - Checks for feasibility of
5695 /// defining this constructor as the move constructor.
5696 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5698
5699 /// Declare the implicit copy assignment operator for the given class.
5700 ///
5701 /// \param ClassDecl The class declaration into which the implicit
5702 /// copy assignment operator will be added.
5703 ///
5704 /// \returns The implicitly-declared copy assignment operator.
5706
5707 /// Defines an implicitly-declared copy assignment operator.
5708 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5709 CXXMethodDecl *MethodDecl);
5710
5711 /// Declare the implicit move assignment operator for the given class.
5712 ///
5713 /// \param ClassDecl The Class declaration into which the implicit
5714 /// move assignment operator will be added.
5715 ///
5716 /// \returns The implicitly-declared move assignment operator, or NULL if it
5717 /// wasn't declared.
5719
5720 /// Defines an implicitly-declared move assignment operator.
5721 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5722 CXXMethodDecl *MethodDecl);
5723
5724 /// Check a completed declaration of an implicit special member.
5726
5727 /// Determine whether the given function is an implicitly-deleted
5728 /// special member function.
5730
5731 /// Check whether 'this' shows up in the type of a static member
5732 /// function after the (naturally empty) cv-qualifier-seq would be.
5733 ///
5734 /// \returns true if an error occurred.
5736
5737 /// Whether this' shows up in the exception specification of a static
5738 /// member function.
5740
5741 /// Check whether 'this' shows up in the attributes of the given
5742 /// static member function.
5743 ///
5744 /// \returns true if an error occurred.
5746
5748 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5749
5751
5752 /// Given a constructor and the set of arguments provided for the
5753 /// constructor, convert the arguments and add any required default arguments
5754 /// to form a proper call to this constructor.
5755 ///
5756 /// \returns true if an error occurred, false otherwise.
5758 QualType DeclInitType, MultiExprArg ArgsPtr,
5759 SourceLocation Loc,
5760 SmallVectorImpl<Expr *> &ConvertedArgs,
5761 bool AllowExplicit = false,
5762 bool IsListInitialization = false);
5763
5764 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5765 /// initializer for the declaration 'Dcl'.
5766 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5767 /// static data member of class X, names should be looked up in the scope of
5768 /// class X.
5770
5771 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5772 /// initializer for the declaration 'Dcl'.
5773 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5774
5775 /// Define the "body" of the conversion from a lambda object to a
5776 /// function pointer.
5777 ///
5778 /// This routine doesn't actually define a sensible body; rather, it fills
5779 /// in the initialization expression needed to copy the lambda object into
5780 /// the block, and IR generation actually generates the real body of the
5781 /// block pointer conversion.
5782 void
5784 CXXConversionDecl *Conv);
5785
5786 /// Define the "body" of the conversion from a lambda object to a
5787 /// block pointer.
5788 ///
5789 /// This routine doesn't actually define a sensible body; rather, it fills
5790 /// in the initialization expression needed to copy the lambda object into
5791 /// the block, and IR generation actually generates the real body of the
5792 /// block pointer conversion.
5794 CXXConversionDecl *Conv);
5795
5796 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5797 /// linkage specification, including the language and (if present)
5798 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5799 /// language string literal. LBraceLoc, if valid, provides the location of
5800 /// the '{' brace. Otherwise, this linkage specification does not
5801 /// have any braces.
5803 Expr *LangStr, SourceLocation LBraceLoc);
5804
5805 /// ActOnFinishLinkageSpecification - Complete the definition of
5806 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5807 /// valid, it's the position of the closing '}' brace in a linkage
5808 /// specification that uses braces.
5810 SourceLocation RBraceLoc);
5811
5812 //===--------------------------------------------------------------------===//
5813 // C++ Classes
5814 //
5815
5816 /// Get the class that is directly named by the current context. This is the
5817 /// class for which an unqualified-id in this scope could name a constructor
5818 /// or destructor.
5819 ///
5820 /// If the scope specifier denotes a class, this will be that class.
5821 /// If the scope specifier is empty, this will be the class whose
5822 /// member-specification we are currently within. Otherwise, there
5823 /// is no such class.
5825
5826 /// isCurrentClassName - Determine whether the identifier II is the
5827 /// name of the class type currently being defined. In the case of
5828 /// nested classes, this will only return true if II is the name of
5829 /// the innermost class.
5830 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5831 const CXXScopeSpec *SS = nullptr);
5832
5833 /// Determine whether the identifier II is a typo for the name of
5834 /// the class type currently being defined. If so, update it to the identifier
5835 /// that should have been used.
5837
5838 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5840 SourceLocation ColonLoc,
5841 const ParsedAttributesView &Attrs);
5842
5843 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5844 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5845 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5846 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5847 /// present (but parsing it has been deferred).
5848 NamedDecl *
5850 MultiTemplateParamsArg TemplateParameterLists,
5851 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5852 InClassInitStyle InitStyle);
5853
5854 /// Enter a new C++ default initializer scope. After calling this, the
5855 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5856 /// parsing or instantiating the initializer failed.
5858
5859 /// This is invoked after parsing an in-class initializer for a
5860 /// non-static C++ class member, and after instantiating an in-class
5861 /// initializer in a class template. Such actions are deferred until the class
5862 /// is complete.
5864 SourceLocation EqualLoc,
5866
5867 /// Handle a C++ member initializer using parentheses syntax.
5869 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5870 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5871 const DeclSpec &DS, SourceLocation IdLoc,
5872 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5873 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5874
5875 /// Handle a C++ member initializer using braced-init-list syntax.
5876 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5877 CXXScopeSpec &SS,
5878 IdentifierInfo *MemberOrBase,
5879 ParsedType TemplateTypeTy,
5880 const DeclSpec &DS, SourceLocation IdLoc,
5881 Expr *InitList, SourceLocation EllipsisLoc);
5882
5883 /// Handle a C++ member initializer.
5884 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5885 CXXScopeSpec &SS,
5886 IdentifierInfo *MemberOrBase,
5887 ParsedType TemplateTypeTy,
5888 const DeclSpec &DS, SourceLocation IdLoc,
5889 Expr *Init, SourceLocation EllipsisLoc);
5890
5892 SourceLocation IdLoc);
5893
5895 TypeSourceInfo *BaseTInfo, Expr *Init,
5896 CXXRecordDecl *ClassDecl,
5897 SourceLocation EllipsisLoc);
5898
5900 CXXRecordDecl *ClassDecl);
5901
5904
5906 ArrayRef<CXXCtorInitializer *> Initializers = {});
5907
5908 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5909 /// mark all the non-trivial destructors of its members and bases as
5910 /// referenced.
5911 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
5912 CXXRecordDecl *Record);
5913
5914 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5915 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5916 /// class. In the Microsoft C++ ABI, this is done any time a class's
5917 /// destructor is referenced.
5919 SourceLocation Location, CXXRecordDecl *ClassDecl,
5920 llvm::SmallPtrSetImpl<const CXXRecordDecl *> *DirectVirtualBases =
5921 nullptr);
5922
5923 /// Do semantic checks to allow the complete destructor variant to be emitted
5924 /// when the destructor is defined in another translation unit. In the Itanium
5925 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
5926 /// can be emitted in separate TUs. To emit the complete variant, run a subset
5927 /// of the checks performed when emitting a regular destructor.
5928 void CheckCompleteDestructorVariant(SourceLocation CurrentLocation,
5929 CXXDestructorDecl *Dtor);
5930
5931 /// The list of classes whose vtables have been used within
5932 /// this translation unit, and the source locations at which the
5933 /// first use occurred.
5934 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
5935
5936 /// The list of vtables that are required but have not yet been
5937 /// materialized.
5939
5940 /// The set of classes whose vtables have been used within
5941 /// this translation unit, and a bit that will be true if the vtable is
5942 /// required to be emitted (otherwise, it should be emitted only if needed
5943 /// by code generation).
5944 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5945
5946 /// Load any externally-stored vtable uses.
5948
5949 /// Note that the vtable for the given class was used at the
5950 /// given location.
5952 bool DefinitionRequired = false);
5953
5954 /// Mark the exception specifications of all virtual member functions
5955 /// in the given class as needed.
5957 const CXXRecordDecl *RD);
5958
5959 /// MarkVirtualMembersReferenced - Will mark all members of the given
5960 /// CXXRecordDecl referenced.
5962 bool ConstexprOnly = false);
5963
5964 /// Define all of the vtables that have been used in this
5965 /// translation unit and reference any virtual members used by those
5966 /// vtables.
5967 ///
5968 /// \returns true if any work was done, false otherwise.
5969 bool DefineUsedVTables();
5970
5971 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
5972 /// special functions, such as the default constructor, copy
5973 /// constructor, or destructor, to the given C++ class (C++
5974 /// [special]p1). This routine can only be executed just before the
5975 /// definition of the class is complete.
5977
5978 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5979 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
5981 bool AnyErrors);
5982
5983 /// Check class-level dllimport/dllexport attribute. The caller must
5984 /// ensure that referenceDLLExportedClassMethods is called some point later
5985 /// when all outer classes of Class are complete.
5988
5990
5991 /// Perform propagation of DLL attributes from a derived class to a
5992 /// templated base class for MS compatibility.
5994 CXXRecordDecl *Class, Attr *ClassAttr,
5995 ClassTemplateSpecializationDecl *BaseTemplateSpec,
5996 SourceLocation BaseLoc);
5997
5998 /// Perform semantic checks on a class definition that has been
5999 /// completing, introducing implicitly-declared members, checking for
6000 /// abstract types, etc.
6001 ///
6002 /// \param S The scope in which the class was parsed. Null if we didn't just
6003 /// parse a class definition.
6004 /// \param Record The completed class.
6006
6007 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
6008 /// conditions that are needed for the attribute to have an effect.
6010
6011 /// Check that VTable Pointer authentication is only being set on the first
6012 /// first instantiation of the vtable
6014
6016 Decl *TagDecl, SourceLocation LBrac,
6017 SourceLocation RBrac,
6018 const ParsedAttributesView &AttrList);
6019
6020 /// Perform any semantic analysis which needs to be delayed until all
6021 /// pending class member declarations have been parsed.
6024
6025 /// This is used to implement the constant expression evaluation part of the
6026 /// attribute enable_if extension. There is nothing in standard C++ which
6027 /// would require reentering parameters.
6030 llvm::function_ref<Scope *()> EnterScope);
6032
6033 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
6034 /// parsing a top-level (non-nested) C++ class, and we are now
6035 /// parsing those parts of the given Method declaration that could
6036 /// not be parsed earlier (C++ [class.mem]p2), such as default
6037 /// arguments. This action should enter the scope of the given
6038 /// Method declaration as if we had just parsed the qualified method
6039 /// name. However, it should not bring the parameters into scope;
6040 /// that will be performed by ActOnDelayedCXXMethodParameter.
6042 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
6044
6045 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
6046 /// processing the delayed method declaration for Method. The method
6047 /// declaration is now considered finished. There may be a separate
6048 /// ActOnStartOfFunctionDef action later (not necessarily
6049 /// immediately!) for this method, if it was also defined inside the
6050 /// class body.
6053
6055
6056 bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx,
6057 StringEvaluationContext EvalContext,
6058 bool ErrorOnInvalidMessage);
6059 bool EvaluateAsString(Expr *Message, std::string &Result, ASTContext &Ctx,
6060 StringEvaluationContext EvalContext,
6061 bool ErrorOnInvalidMessage);
6062
6064 Expr *AssertExpr, Expr *AssertMessageExpr,
6065 SourceLocation RParenLoc);
6067 Expr *AssertExpr, Expr *AssertMessageExpr,
6068 SourceLocation RParenLoc, bool Failed);
6069
6070 /// Try to print more useful information about a failed static_assert
6071 /// with expression \E
6072 void DiagnoseStaticAssertDetails(const Expr *E);
6073
6074 /// If E represents a built-in type trait, or a known standard type trait,
6075 /// try to print more information about why the type type-trait failed.
6076 /// This assumes we already evaluated the expression to a false boolean value.
6077 void DiagnoseTypeTraitDetails(const Expr *E);
6078
6079 /// Handle a friend type declaration. This works in tandem with
6080 /// ActOnTag.
6081 ///
6082 /// Notes on friend class templates:
6083 ///
6084 /// We generally treat friend class declarations as if they were
6085 /// declaring a class. So, for example, the elaborated type specifier
6086 /// in a friend declaration is required to obey the restrictions of a
6087 /// class-head (i.e. no typedefs in the scope chain), template
6088 /// parameters are required to match up with simple template-ids, &c.
6089 /// However, unlike when declaring a template specialization, it's
6090 /// okay to refer to a template specialization without an empty
6091 /// template parameter declaration, e.g.
6092 /// friend class A<T>::B<unsigned>;
6093 /// We permit this as a special case; if there are any template
6094 /// parameters present at all, require proper matching, i.e.
6095 /// template <> template <class T> friend class A<int>::B;
6096 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
6097 MultiTemplateParamsArg TemplateParams,
6098 SourceLocation EllipsisLoc);
6100 MultiTemplateParamsArg TemplateParams);
6101
6102 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
6103 /// the well-formedness of the constructor declarator @p D with type @p
6104 /// R. If there are any errors in the declarator, this routine will
6105 /// emit diagnostics and set the invalid bit to true. In any case, the type
6106 /// will be updated to reflect a well-formed type for the constructor and
6107 /// returned.
6109 StorageClass &SC);
6110
6111 /// CheckConstructor - Checks a fully-formed constructor for
6112 /// well-formedness, issuing any diagnostics required. Returns true if
6113 /// the constructor declarator is invalid.
6115
6116 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
6117 /// the well-formednes of the destructor declarator @p D with type @p
6118 /// R. If there are any errors in the declarator, this routine will
6119 /// emit diagnostics and set the declarator to invalid. Even if this happens,
6120 /// will be updated to reflect a well-formed type for the destructor and
6121 /// returned.
6123 StorageClass &SC);
6124
6125 /// CheckDestructor - Checks a fully-formed destructor definition for
6126 /// well-formedness, issuing any diagnostics required. Returns true
6127 /// on error.
6129
6130 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
6131 /// well-formednes of the conversion function declarator @p D with
6132 /// type @p R. If there are any errors in the declarator, this routine
6133 /// will emit diagnostics and return true. Otherwise, it will return
6134 /// false. Either way, the type @p R will be updated to reflect a
6135 /// well-formed type for the conversion operator.
6137
6138 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
6139 /// the declaration of the given C++ conversion function. This routine
6140 /// is responsible for recording the conversion function in the C++
6141 /// class, if possible.
6143
6144 /// Check the validity of a declarator that we parsed for a deduction-guide.
6145 /// These aren't actually declarators in the grammar, so we need to check that
6146 /// the user didn't specify any pieces that are not part of the
6147 /// deduction-guide grammar. Return true on invalid deduction-guide.
6149 StorageClass &SC);
6150
6152
6155 SourceLocation DefaultLoc);
6157
6158 /// Kinds of defaulted comparison operator functions.
6159 enum class DefaultedComparisonKind : unsigned char {
6160 /// This is not a defaultable comparison operator.
6162 /// This is an operator== that should be implemented as a series of
6163 /// subobject comparisons.
6165 /// This is an operator<=> that should be implemented as a series of
6166 /// subobject comparisons.
6168 /// This is an operator!= that should be implemented as a rewrite in terms
6169 /// of a == comparison.
6171 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
6172 /// terms of a <=> comparison.
6174 };
6175
6179 FunctionDecl *Spaceship);
6182
6184 QualType R, bool IsLambda,
6185 DeclContext *DC = nullptr);
6187 DeclarationName Name, QualType R);
6189
6190 //===--------------------------------------------------------------------===//
6191 // C++ Derived Classes
6192 //
6193
6194 /// Check the validity of a C++ base class specifier.
6195 ///
6196 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
6197 /// and returns NULL otherwise.
6199 SourceRange SpecifierRange, bool Virtual,
6200 AccessSpecifier Access,
6201 TypeSourceInfo *TInfo,
6202 SourceLocation EllipsisLoc);
6203
6204 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
6205 /// one entry in the base class list of a class specifier, for
6206 /// example:
6207 /// class foo : public bar, virtual private baz {
6208 /// 'public bar' and 'virtual private baz' are each base-specifiers.
6209 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
6210 const ParsedAttributesView &Attrs, bool Virtual,
6211 AccessSpecifier Access, ParsedType basetype,
6212 SourceLocation BaseLoc,
6213 SourceLocation EllipsisLoc);
6214
6215 /// Performs the actual work of attaching the given base class
6216 /// specifiers to a C++ class.
6219
6220 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
6221 /// class, after checking whether there are any duplicate base
6222 /// classes.
6223 void ActOnBaseSpecifiers(Decl *ClassDecl,
6225
6226 /// Determine whether the type \p Derived is a C++ class that is
6227 /// derived from the type \p Base.
6228 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6230 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6234 CXXBasePaths &Paths);
6235
6236 // FIXME: I don't like this name.
6237 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
6238
6240 SourceLocation Loc, SourceRange Range,
6241 CXXCastPath *BasePath = nullptr,
6242 bool IgnoreAccess = false);
6243
6244 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
6245 /// conversion (where Derived and Base are class types) is
6246 /// well-formed, meaning that the conversion is unambiguous (and
6247 /// that all of the base classes are accessible). Returns true
6248 /// and emits a diagnostic if the code is ill-formed, returns false
6249 /// otherwise. Loc is the location where this routine should point to
6250 /// if there is an error, and Range is the source range to highlight
6251 /// if there is an error.
6252 ///
6253 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
6254 /// diagnostic for the respective type of error will be suppressed, but the
6255 /// check for ill-formed code will still be performed.
6257 unsigned InaccessibleBaseID,
6258 unsigned AmbiguousBaseConvID,
6259 SourceLocation Loc, SourceRange Range,
6260 DeclarationName Name, CXXCastPath *BasePath,
6261 bool IgnoreAccess = false);
6262
6263 /// Builds a string representing ambiguous paths from a
6264 /// specific derived class to different subobjects of the same base
6265 /// class.
6266 ///
6267 /// This function builds a string that can be used in error messages
6268 /// to show the different paths that one can take through the
6269 /// inheritance hierarchy to go from the derived class to different
6270 /// subobjects of a base class. The result looks something like this:
6271 /// @code
6272 /// struct D -> struct B -> struct A
6273 /// struct D -> struct C -> struct A
6274 /// @endcode
6275 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
6276
6278 const CXXMethodDecl *Old);
6279
6280 /// CheckOverridingFunctionReturnType - Checks whether the return types are
6281 /// covariant, according to C++ [class.virtual]p5.
6283 const CXXMethodDecl *Old);
6284
6285 // Check that the overriding method has no explicit object parameter.
6287 const CXXMethodDecl *Old);
6288
6289 /// Mark the given method pure.
6290 ///
6291 /// \param Method the method to be marked pure.
6292 ///
6293 /// \param InitRange the source range that covers the "0" initializer.
6295
6296 /// CheckOverrideControl - Check C++11 override control semantics.
6298
6299 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
6300 /// not used in the declaration of an overriding method.
6302
6303 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
6304 /// function overrides a virtual member function marked 'final', according to
6305 /// C++11 [class.virtual]p4.
6307 const CXXMethodDecl *Old);
6308
6319
6320 struct TypeDiagnoser;
6321
6324 TypeDiagnoser &Diagnoser);
6325 template <typename... Ts>
6326 bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
6327 const Ts &...Args) {
6328 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6329 return RequireNonAbstractType(Loc, T, Diagnoser);
6330 }
6331
6332 void DiagnoseAbstractType(const CXXRecordDecl *RD);
6333
6334 //===--------------------------------------------------------------------===//
6335 // C++ Overloaded Operators [C++ 13.5]
6336 //
6337
6338 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
6339 /// of this overloaded operator is well-formed. If so, returns false;
6340 /// otherwise, emits appropriate diagnostics and returns true.
6342
6343 /// CheckLiteralOperatorDeclaration - Check whether the declaration
6344 /// of this literal operator function is well-formed. If so, returns
6345 /// false; otherwise, emits appropriate diagnostics and returns true.
6347
6348 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
6349 /// found in an explicit(bool) specifier.
6351
6352 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
6353 /// Returns true if the explicit specifier is now resolved.
6355
6356 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
6357 /// C++ if/switch/while/for statement.
6358 /// e.g: "if (int x = f()) {...}"
6360
6361 // Emitting members of dllexported classes is delayed until the class
6362 // (including field initializers) is fully parsed.
6365
6366 /// Merge the exception specifications of two variable declarations.
6367 ///
6368 /// This is called when there's a redeclaration of a VarDecl. The function
6369 /// checks if the redeclaration might have an exception specification and
6370 /// validates compatibility and merges the specs if necessary.
6372
6373 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
6374 /// function, once we already know that they have the same
6375 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
6376 /// error, false otherwise.
6378
6379 /// Helpers for dealing with blocks and functions.
6381
6382 /// CheckExtraCXXDefaultArguments - Check for any extra default
6383 /// arguments in the declarator, which is not a function declaration
6384 /// or definition and therefore is not permitted to have default
6385 /// arguments. This routine should be invoked for every declarator
6386 /// that is not a function declaration or definition.
6388
6392
6393 /// Perform semantic analysis for the variable declaration that
6394 /// occurs within a C++ catch clause, returning the newly-created
6395 /// variable.
6397 SourceLocation StartLoc,
6398 SourceLocation IdLoc,
6399 const IdentifierInfo *Id);
6400
6401 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
6402 /// handler.
6404
6406
6407 /// Handle a friend tag declaration where the scope specifier was
6408 /// templated.
6410 unsigned TagSpec, SourceLocation TagLoc,
6411 CXXScopeSpec &SS, IdentifierInfo *Name,
6412 SourceLocation NameLoc,
6413 SourceLocation EllipsisLoc,
6415 MultiTemplateParamsArg TempParamLists);
6416
6418 SourceLocation DeclStart, Declarator &D,
6419 Expr *BitfieldWidth,
6420 InClassInitStyle InitStyle,
6421 AccessSpecifier AS,
6422 const ParsedAttr &MSPropertyAttr);
6423
6424 /// Diagnose why the specified class does not have a trivial special member of
6425 /// the given kind.
6428
6429 /// Determine whether a defaulted or deleted special member function is
6430 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
6431 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
6435 bool Diagnose = false);
6436
6437 /// For a defaulted function, the kind of defaulted function that it is.
6439 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
6440 unsigned SpecialMember : 8;
6441 unsigned Comparison : 8;
6442
6443 public:
6445 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
6446 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
6448 : SpecialMember(llvm::to_underlying(CSM)),
6449 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
6451 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
6452 Comparison(llvm::to_underlying(Comp)) {}
6453
6454 bool isSpecialMember() const {
6455 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
6457 }
6458 bool isComparison() const {
6459 return static_cast<DefaultedComparisonKind>(Comparison) !=
6461 }
6462
6463 explicit operator bool() const {
6464 return isSpecialMember() || isComparison();
6465 }
6466
6468 return static_cast<CXXSpecialMemberKind>(SpecialMember);
6469 }
6471 return static_cast<DefaultedComparisonKind>(Comparison);
6472 }
6473
6474 /// Get the index of this function kind for use in diagnostics.
6475 unsigned getDiagnosticIndex() const {
6476 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
6477 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
6478 "invalid should have highest index");
6479 static_assert((unsigned)DefaultedComparisonKind::None == 0,
6480 "none should be equal to zero");
6481 return SpecialMember + Comparison;
6482 }
6483 };
6484
6485 /// Determine the kind of defaulting that would be done for a given function.
6486 ///
6487 /// If the function is both a default constructor and a copy / move
6488 /// constructor (due to having a default argument for the first parameter),
6489 /// this picks CXXSpecialMemberKind::DefaultConstructor.
6490 ///
6491 /// FIXME: Check that case is properly handled by all callers.
6492 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
6493
6494 /// Handle a C++11 empty-declaration and attribute-declaration.
6496 SourceLocation SemiLoc);
6497
6499 /// Diagnose issues that are non-constant or that are extensions.
6501 /// Identify whether this function satisfies the formal rules for constexpr
6502 /// functions in the current lanugage mode (with no extensions).
6504 };
6505
6506 // Check whether a function declaration satisfies the requirements of a
6507 // constexpr function definition or a constexpr constructor definition. If so,
6508 // return true. If not, produce appropriate diagnostics (unless asked not to
6509 // by Kind) and return false.
6510 //
6511 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
6513 CheckConstexprKind Kind);
6514
6515 /// Diagnose methods which overload virtual methods in a base class
6516 /// without overriding any.
6518
6519 /// Check if a method overloads virtual methods in a base class without
6520 /// overriding any.
6521 void
6523 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6524 void
6526 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6527
6528 /// ActOnParamDefaultArgument - Check whether the default argument
6529 /// provided for a function parameter is well-formed. If so, attach it
6530 /// to the parameter declaration.
6531 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
6532 Expr *defarg);
6533
6534 /// ActOnParamUnparsedDefaultArgument - We've seen a default
6535 /// argument for a function parameter, but we can't parse it yet
6536 /// because we're inside a class definition. Note that this default
6537 /// argument will be parsed later.
6539 SourceLocation ArgLoc);
6540
6541 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
6542 /// the default argument for the parameter param failed.
6544 Expr *DefaultArg);
6546 SourceLocation EqualLoc);
6547 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
6548 SourceLocation EqualLoc);
6549
6550 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
6551 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
6552 StringLiteral *Message = nullptr);
6553 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6554
6555 void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
6556 StringLiteral *DeletedMessage = nullptr);
6560
6561 NamedDecl *
6563 MultiTemplateParamsArg TemplateParamLists);
6566 RecordDecl *ClassDecl,
6567 const IdentifierInfo *Name);
6568
6570 SourceLocation Loc);
6572
6573 /// Stack containing information needed when in C++2a an 'auto' is encountered
6574 /// in a function declaration parameter type specifier in order to invent a
6575 /// corresponding template parameter in the enclosing abbreviated function
6576 /// template. This information is also present in LambdaScopeInfo, stored in
6577 /// the FunctionScopes stack.
6579
6580 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6581 std::unique_ptr<CXXFieldCollector> FieldCollector;
6582
6584 /// Set containing all declared private fields that are not used.
6586
6588
6589 /// PureVirtualClassDiagSet - a set of class declarations which we have
6590 /// emitted a list of pure virtual functions. Used to prevent emitting the
6591 /// same list more than once.
6592 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6593
6597
6598 /// All the delegating constructors seen so far in the file, used for
6599 /// cycle detection at the end of the TU.
6601
6602 /// The C++ "std" namespace, where the standard library resides.
6604
6605 /// The C++ "std::initializer_list" template, which is defined in
6606 /// <initializer_list>.
6608
6609 /// The C++ "std::type_identity" template, which is defined in
6610 /// <type_traits>.
6612
6613 // Contains the locations of the beginning of unparsed default
6614 // argument locations.
6615 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6616
6617 /// UndefinedInternals - all the used, undefined objects which require a
6618 /// definition in this translation unit.
6619 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6620
6621 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6623
6624 /// The C++ special members which we are currently in the process of
6625 /// declaring. If this process recursively triggers the declaration of the
6626 /// same special member, we should act as if it is not yet declared.
6628
6630
6631 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6632
6635 ParsingClassDepth++;
6637 }
6639 ParsingClassDepth--;
6641 }
6642
6644 CXXScopeSpec &SS,
6645 ParsedType TemplateTypeTy,
6646 IdentifierInfo *MemberOrBase);
6647
6648private:
6649 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6650 QualType ResultTy,
6651 ArrayRef<QualType> Args);
6652 // Helper for ActOnFields to check for all function pointer members.
6653 bool EntirelyFunctionPointers(const RecordDecl *Record);
6654
6655 // A cache representing if we've fully checked the various comparison category
6656 // types stored in ASTContext. The bit-index corresponds to the integer value
6657 // of a ComparisonCategoryType enumerator.
6658 llvm::SmallBitVector FullyCheckedComparisonCategories;
6659
6660 /// Check if there is a field shadowing.
6661 void CheckShadowInheritedFields(const SourceLocation &Loc,
6662 DeclarationName FieldName,
6663 const CXXRecordDecl *RD,
6664 bool DeclIsField = true);
6665
6666 ///@}
6667
6668 //
6669 //
6670 // -------------------------------------------------------------------------
6671 //
6672 //
6673
6674 /// \name C++ Exception Specifications
6675 /// Implementations are in SemaExceptionSpec.cpp
6676 ///@{
6677
6678public:
6679 /// All the overriding functions seen during a class definition
6680 /// that had their exception spec checks delayed, plus the overridden
6681 /// function.
6684
6685 /// All the function redeclarations seen during a class definition that had
6686 /// their exception spec checks delayed, plus the prior declaration they
6687 /// should be checked against. Except during error recovery, the new decl
6688 /// should always be a friend declaration, as that's the only valid way to
6689 /// redeclare a special member before its class is complete.
6692
6693 /// Determine if we're in a case where we need to (incorrectly) eagerly
6694 /// parse an exception specification to work around a libstdc++ bug.
6696
6697 /// Check the given noexcept-specifier, convert its expression, and compute
6698 /// the appropriate ExceptionSpecificationType.
6699 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6701
6702 CanThrowResult canThrow(const Stmt *E);
6703 /// Determine whether the callee of a particular function call can throw.
6704 /// E, D and Loc are all optional.
6705 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6708 const FunctionProtoType *FPT);
6711
6712 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6713 /// exception specification. Incomplete types, or pointers to incomplete types
6714 /// other than void are not allowed.
6715 ///
6716 /// \param[in,out] T The exception type. This will be decayed to a pointer
6717 /// type
6718 /// when the input is an array or a function type.
6720
6721 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6722 /// pointer to member to a function with an exception specification. This
6723 /// means that it is invalid to add another level of indirection.
6726
6727 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6728 /// exception specifications. Exception specifications are equivalent if
6729 /// they allow exactly the same set of exception types. It does not matter how
6730 /// that is achieved. See C++ [except.spec]p2.
6732 SourceLocation OldLoc,
6733 const FunctionProtoType *New,
6734 SourceLocation NewLoc);
6736 const PartialDiagnostic &NoteID,
6737 const FunctionProtoType *Old,
6738 SourceLocation OldLoc,
6739 const FunctionProtoType *New,
6740 SourceLocation NewLoc);
6741 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6742
6743 /// CheckExceptionSpecSubset - Check whether the second function type's
6744 /// exception specification is a subset (or equivalent) of the first function
6745 /// type. This is used by override and pointer assignment checks.
6747 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6748 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6749 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6750 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6751 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6752
6753 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6754 /// two functions have equivalent exception specs. This is part of the
6755 /// assignment and override compatibility check. We do not check the
6756 /// parameters of parameter function pointers recursively, as no sane
6757 /// programmer would even be able to write such a function type.
6759 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6760 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6761 SourceLocation TargetLoc, const FunctionProtoType *Source,
6762 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6763
6764 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6765
6766 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6767 /// spec is a subset of base spec.
6769 const CXXMethodDecl *Old);
6770
6771 ///@}
6772
6773 //
6774 //
6775 // -------------------------------------------------------------------------
6776 //
6777 //
6778
6779 /// \name Expressions
6780 /// Implementations are in SemaExpr.cpp
6781 ///@{
6782
6783public:
6784 /// Describes how the expressions currently being parsed are
6785 /// evaluated at run-time, if at all.
6787 /// The current expression and its subexpressions occur within an
6788 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6789 /// \c sizeof, where the type of the expression may be significant but
6790 /// no code will be generated to evaluate the value of the expression at
6791 /// run time.
6793
6794 /// The current expression occurs within a braced-init-list within
6795 /// an unevaluated operand. This is mostly like a regular unevaluated
6796 /// context, except that we still instantiate constexpr functions that are
6797 /// referenced here so that we can perform narrowing checks correctly.
6799
6800 /// The current expression occurs within a discarded statement.
6801 /// This behaves largely similarly to an unevaluated operand in preventing
6802 /// definitions from being required, but not in other ways.
6804
6805 /// The current expression occurs within an unevaluated
6806 /// operand that unconditionally permits abstract references to
6807 /// fields, such as a SIZE operator in MS-style inline assembly.
6809
6810 /// The current context is "potentially evaluated" in C++11 terms,
6811 /// but the expression is evaluated at compile-time (like the values of
6812 /// cases in a switch statement).
6814
6815 /// In addition of being constant evaluated, the current expression
6816 /// occurs in an immediate function context - either a consteval function
6817 /// or a consteval if statement.
6819
6820 /// The current expression is potentially evaluated at run time,
6821 /// which means that code may be generated to evaluate the value of the
6822 /// expression at run time.
6824
6825 /// The current expression is potentially evaluated, but any
6826 /// declarations referenced inside that expression are only used if
6827 /// in fact the current expression is used.
6828 ///
6829 /// This value is used when parsing default function arguments, for which
6830 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6831 /// through varargs) but do not want to mark declarations as "referenced"
6832 /// until the default argument is used.
6834 };
6835
6836 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6837 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6838 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6839 /// have been applied to all subexpressions of the enclosing full expression.
6840 /// This is cleared at the end of each full expression.
6843
6844 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6845
6846 /// Data structure used to record current or nested
6847 /// expression evaluation contexts.
6849 /// The expression evaluation context.
6851
6852 /// Whether the enclosing context needed a cleanup.
6854
6855 /// The number of active cleanup objects when we entered
6856 /// this expression evaluation context.
6858
6860
6861 /// The lambdas that are present within this context, if it
6862 /// is indeed an unevaluated context.
6864
6865 /// The declaration that provides context for lambda expressions
6866 /// and block literals if the normal declaration context does not
6867 /// suffice, e.g., in a default function argument.
6869
6870 /// Declaration for initializer if one is currently being
6871 /// parsed. Used when an expression has a possibly unreachable
6872 /// diagnostic to reference the declaration as a whole.
6874
6875 /// If we are processing a decltype type, a set of call expressions
6876 /// for which we have deferred checking the completeness of the return type.
6878
6879 /// If we are processing a decltype type, a set of temporary binding
6880 /// expressions for which we have deferred checking the destructor.
6882
6884
6885 /// Expressions appearing as the LHS of a volatile assignment in this
6886 /// context. We produce a warning for these when popping the context if
6887 /// they are not discarded-value expressions nor unevaluated operands.
6889
6890 /// Set of candidates for starting an immediate invocation.
6893
6894 /// Set of DeclRefExprs referencing a consteval function when used in a
6895 /// context not already known to be immediately invoked.
6897
6898 /// P2718R0 - Lifetime extension in range-based for loops.
6899 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6900 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6901 /// InLifetimeExtendingContext is true.
6903
6904 /// Small set of gathered accesses to potentially misaligned members
6905 /// due to the packed attribute.
6907
6908 /// \brief Describes whether we are in an expression constext which we have
6909 /// to handle differently.
6917
6918 // A context can be nested in both a discarded statement context and
6919 // an immediate function context, so they need to be tracked independently.
6923
6925
6926 // We are in a constant context, but we also allow
6927 // non constant expressions, for example for array bounds (which may be
6928 // VLAs).
6930
6931 /// Whether we are currently in a context in which all temporaries must be
6932 /// lifetime-extended, even if they're not bound to a reference (for
6933 /// example, in a for-range initializer).
6935
6936 /// Whether evaluating an expression for a switch case label.
6937 bool IsCaseExpr = false;
6938
6939 /// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
6941
6942 // When evaluating immediate functions in the initializer of a default
6943 // argument or default member initializer, this is the declaration whose
6944 // default initializer is being evaluated and the location of the call
6945 // or constructor definition.
6949 : Loc(Loc), Decl(Decl), Context(Context) {
6950 assert(Decl && Context && "invalid initialization context");
6951 }
6952
6954 ValueDecl *Decl = nullptr;
6956 };
6957 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6958
6969
6975
6982
6987
6992 // C++23 [expr.const]p14:
6993 // An expression or conversion is in an immediate function
6994 // context if it is potentially evaluated and either:
6995 // * its innermost enclosing non-block scope is a function
6996 // parameter scope of an immediate function, or
6997 // * its enclosing statement is enclosed by the compound-
6998 // statement of a consteval if statement.
7001 }
7002
7010 };
7011
7013 assert(!ExprEvalContexts.empty() &&
7014 "Must be in an expression evaluation context");
7015 return ExprEvalContexts.back();
7016 }
7017
7019 assert(!ExprEvalContexts.empty() &&
7020 "Must be in an expression evaluation context");
7021 return ExprEvalContexts.back();
7022 }
7023
7025 assert(ExprEvalContexts.size() >= 2 &&
7026 "Must be in an expression evaluation context");
7027 return ExprEvalContexts[ExprEvalContexts.size() - 2];
7028 }
7029
7031 return const_cast<Sema *>(this)->parentEvaluationContext();
7032 }
7033
7038
7039 /// Increment when we find a reference; decrement when we find an ignored
7040 /// assignment. Ultimately the value is 0 if every reference is an ignored
7041 /// assignment.
7042 ///
7043 /// Uses canonical VarDecl as key so in-class decls and out-of-class defs of
7044 /// static data members get tracked as a single entry.
7045 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
7046
7047 /// Used to control the generation of ExprWithCleanups.
7049
7050 /// ExprCleanupObjects - This is the stack of objects requiring
7051 /// cleanup that are created by the current full expression.
7053
7054 /// Determine whether the use of this declaration is valid, without
7055 /// emitting diagnostics.
7056 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
7057 // A version of DiagnoseUseOfDecl that should be used if overload resolution
7058 // has been used to find this declaration, which means we don't have to bother
7059 // checking the trailing requires clause.
7061 return DiagnoseUseOfDecl(
7062 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
7063 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
7064 /*SkipTrailingRequiresClause=*/true);
7065 }
7066
7067 /// Determine whether the use of this declaration is valid, and
7068 /// emit any corresponding diagnostics.
7069 ///
7070 /// This routine diagnoses various problems with referencing
7071 /// declarations that can occur when using a declaration. For example,
7072 /// it might warn if a deprecated or unavailable declaration is being
7073 /// used, or produce an error (and return true) if a C++0x deleted
7074 /// function is being used.
7075 ///
7076 /// \returns true if there was an error (this declaration cannot be
7077 /// referenced), false otherwise.
7079 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
7080 bool ObjCPropertyAccess = false,
7081 bool AvoidPartialAvailabilityChecks = false,
7082 ObjCInterfaceDecl *ClassReceiver = nullptr,
7083 bool SkipTrailingRequiresClause = false);
7084
7085 /// Emit a note explaining that this function is deleted.
7087
7088 /// DiagnoseSentinelCalls - This routine checks whether a call or
7089 /// message-send is to a declaration with the sentinel attribute, and
7090 /// if so, it checks that the requirements of the sentinel are
7091 /// satisfied.
7093 ArrayRef<Expr *> Args);
7094
7096 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
7099
7101 ExpressionEvaluationContext NewContext, FunctionDecl *FD);
7102
7105 ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
7109
7111
7115
7116 /// Check whether E, which is either a discarded-value expression or an
7117 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
7118 /// lvalue, and if so, remove it from the list of volatile-qualified
7119 /// assignments that we are going to warn are deprecated.
7121
7123
7124 // Functions for marking a declaration referenced. These functions also
7125 // contain the relevant logic for marking if a reference to a function or
7126 // variable is an odr-use (in the C++11 sense). There are separate variants
7127 // for expressions referring to a decl; these exist because odr-use marking
7128 // needs to be delayed for some constant variables when we build one of the
7129 // named expressions.
7130 //
7131 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
7132 // should usually be true. This only needs to be set to false if the lack of
7133 // odr-use cannot be determined from the current context (for instance,
7134 // because the name denotes a virtual function and was written without an
7135 // explicit nested-name-specifier).
7136 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
7137
7138 /// Mark a function referenced, and check whether it is odr-used
7139 /// (C++ [basic.def.odr]p2, C99 6.9p3)
7141 bool MightBeOdrUse = true);
7142
7143 /// Mark a variable referenced, and check whether it is odr-used
7144 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
7145 /// used directly for normal expressions referring to VarDecl.
7147
7148 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
7149 ///
7150 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
7151 /// be handled with care if the DeclRefExpr is not newly-created.
7152 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
7153
7154 /// Perform reference-marking and odr-use handling for a MemberExpr.
7156
7157 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
7160 unsigned CapturingScopeIndex);
7161
7163 void CleanupVarDeclMarking();
7164
7165 /// Try to capture the given variable.
7166 ///
7167 /// \param Var The variable to capture.
7168 ///
7169 /// \param Loc The location at which the capture occurs.
7170 ///
7171 /// \param Kind The kind of capture, which may be implicit (for either a
7172 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
7173 ///
7174 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
7175 /// an explicit lambda capture.
7176 ///
7177 /// \param BuildAndDiagnose Whether we are actually supposed to add the
7178 /// captures or diagnose errors. If false, this routine merely check whether
7179 /// the capture can occur without performing the capture itself or complaining
7180 /// if the variable cannot be captured.
7181 ///
7182 /// \param CaptureType Will be set to the type of the field used to capture
7183 /// this variable in the innermost block or lambda. Only valid when the
7184 /// variable can be captured.
7185 ///
7186 /// \param DeclRefType Will be set to the type of a reference to the capture
7187 /// from within the current scope. Only valid when the variable can be
7188 /// captured.
7189 ///
7190 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
7191 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
7192 /// This is useful when enclosing lambdas must speculatively capture
7193 /// variables that may or may not be used in certain specializations of
7194 /// a nested generic lambda.
7195 ///
7196 /// \returns true if an error occurred (i.e., the variable cannot be
7197 /// captured) and false if the capture succeeded.
7199 TryCaptureKind Kind, SourceLocation EllipsisLoc,
7200 bool BuildAndDiagnose, QualType &CaptureType,
7201 QualType &DeclRefType,
7202 const unsigned *const FunctionScopeIndexToStopAt);
7203
7204 /// Try to capture the given variable.
7207 SourceLocation EllipsisLoc = SourceLocation());
7208
7209 /// Checks if the variable must be captured.
7211
7212 /// Given a variable, determine the type that a reference to that
7213 /// variable will have in the given scope.
7215
7216 /// Mark all of the declarations referenced within a particular AST node as
7217 /// referenced. Used when template instantiation instantiates a non-dependent
7218 /// type -- entities referenced by the type are now referenced.
7220
7221 /// Mark any declarations that appear within this expression or any
7222 /// potentially-evaluated subexpressions as "referenced".
7223 ///
7224 /// \param SkipLocalVariables If true, don't mark local variables as
7225 /// 'referenced'.
7226 /// \param StopAt Subexpressions that we shouldn't recurse into.
7228 bool SkipLocalVariables = false,
7229 ArrayRef<const Expr *> StopAt = {});
7230
7231 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
7232 /// conversion.
7233 ExprResult tryConvertExprToType(Expr *E, QualType Ty);
7234
7235 /// Conditionally issue a diagnostic based on the statements's reachability
7236 /// analysis.
7237 ///
7238 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
7239 /// the function body is parsed, and then do a basic reachability analysis to
7240 /// determine if the statement is reachable. If it is unreachable, the
7241 /// diagnostic will not be emitted.
7242 bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7243 const PartialDiagnostic &PD);
7244
7245 /// Conditionally issue a diagnostic based on the current
7246 /// evaluation context.
7247 ///
7248 /// \param Statement If Statement is non-null, delay reporting the
7249 /// diagnostic until the function body is parsed, and then do a basic
7250 /// reachability analysis to determine if the statement is reachable.
7251 /// If it is unreachable, the diagnostic will not be emitted.
7252 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
7253 const PartialDiagnostic &PD);
7254 /// Similar, but diagnostic is only produced if all the specified statements
7255 /// are reachable.
7256 bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7257 const PartialDiagnostic &PD);
7258
7259 // Primary Expressions.
7260 SourceRange getExprRange(Expr *E) const;
7261
7262 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
7263 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
7264 bool HasTrailingLParen, bool IsAddressOfOperand,
7265 CorrectionCandidateCallback *CCC = nullptr,
7266 bool IsInlineAsmIdentifier = false);
7267
7268 /// Decomposes the given name into a DeclarationNameInfo, its location, and
7269 /// possibly a list of template arguments.
7270 ///
7271 /// If this produces template arguments, it is permitted to call
7272 /// DecomposeTemplateName.
7273 ///
7274 /// This actually loses a lot of source location information for
7275 /// non-standard name kinds; we should consider preserving that in
7276 /// some way.
7277 void DecomposeUnqualifiedId(const UnqualifiedId &Id,
7278 TemplateArgumentListInfo &Buffer,
7279 DeclarationNameInfo &NameInfo,
7280 const TemplateArgumentListInfo *&TemplateArgs);
7281
7282 /// Diagnose a lookup that found results in an enclosing class during error
7283 /// recovery. This usually indicates that the results were found in a
7284 /// dependent base class that could not be searched as part of a template
7285 /// definition. Always issues a diagnostic (though this may be only a warning
7286 /// in MS compatibility mode).
7287 ///
7288 /// Return \c true if the error is unrecoverable, or \c false if the caller
7289 /// should attempt to recover using these lookup results.
7290 bool DiagnoseDependentMemberLookup(const LookupResult &R);
7291
7292 /// Diagnose an empty lookup.
7293 ///
7294 /// \return false if new lookup candidates were found
7295 bool
7296 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
7297 CorrectionCandidateCallback &CCC,
7298 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
7299 ArrayRef<Expr *> Args = {},
7300 DeclContext *LookupCtx = nullptr);
7301
7302 /// If \p D cannot be odr-used in the current expression evaluation context,
7303 /// return a reason explaining why. Otherwise, return NOUR_None.
7305
7306 DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7307 SourceLocation Loc,
7308 const CXXScopeSpec *SS = nullptr);
7309 DeclRefExpr *
7310 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7311 const DeclarationNameInfo &NameInfo,
7312 const CXXScopeSpec *SS = nullptr,
7313 NamedDecl *FoundD = nullptr,
7314 SourceLocation TemplateKWLoc = SourceLocation(),
7315 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7316
7317 /// BuildDeclRefExpr - Build an expression that references a
7318 /// declaration that does not require a closure capture.
7319 DeclRefExpr *
7320 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7321 const DeclarationNameInfo &NameInfo,
7322 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
7323 SourceLocation TemplateKWLoc = SourceLocation(),
7324 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7325
7326 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
7327 bool HasTrailingLParen);
7328
7329 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
7330 /// declaration name, generally during template instantiation.
7331 /// There's a large number of things which don't need to be done along
7332 /// this path.
7334 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
7335 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
7336
7337 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
7338 bool NeedsADL,
7339 bool AcceptInvalidDecl = false);
7340
7341 /// Complete semantic analysis for a reference to the given declaration.
7343 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
7344 NamedDecl *FoundD = nullptr,
7345 const TemplateArgumentListInfo *TemplateArgs = nullptr,
7346 bool AcceptInvalidDecl = false);
7347
7348 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
7349 // where Tokens representing function local predefined macros (such as
7350 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
7351 std::vector<Token> ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks);
7352
7353 ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK);
7354 ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
7355 ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
7356
7357 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
7358
7359 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
7361 Scope *UDLScope = nullptr);
7362 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
7363 ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
7364 MultiExprArg Val);
7365 ExprResult ActOnCXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
7366 unsigned NumUserSpecifiedExprs,
7367 SourceLocation InitLoc,
7368 SourceLocation LParenLoc,
7369 SourceLocation RParenLoc);
7370
7371 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
7372 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
7373 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
7374 /// from multiple tokens. However, the common case is that StringToks points
7375 /// to one string.
7376 ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
7377 Scope *UDLScope = nullptr);
7378
7379 ExprResult ActOnUnevaluatedStringLiteral(ArrayRef<Token> StringToks);
7380
7381 /// ControllingExprOrType is either an opaque pointer coming out of a
7382 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
7383 /// into two so we don't take a void *, but that's awkward because one of
7384 /// the operands is either a ParsedType or an Expr *, which doesn't lend
7385 /// itself to generic code very well.
7386 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
7387 SourceLocation DefaultLoc,
7388 SourceLocation RParenLoc,
7389 bool PredicateIsExpr,
7390 void *ControllingExprOrType,
7391 ArrayRef<ParsedType> ArgTypes,
7392 ArrayRef<Expr *> ArgExprs);
7393 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
7394 /// it'd be better to split this interface into two so we don't take a
7395 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
7396 /// isn't a trivial change.
7397 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
7398 SourceLocation DefaultLoc,
7399 SourceLocation RParenLoc,
7400 bool PredicateIsExpr,
7401 void *ControllingExprOrType,
7402 ArrayRef<TypeSourceInfo *> Types,
7403 ArrayRef<Expr *> Exprs);
7404
7405 // Binary/Unary Operators. 'Tok' is the token for the operator.
7406 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
7407 Expr *InputExpr, bool IsAfterAmp = false);
7408 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc,
7409 Expr *Input, bool IsAfterAmp = false);
7410
7411 /// Unary Operators. 'Tok' is the token for the operator.
7412 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op,
7413 Expr *Input, bool IsAfterAmp = false);
7414
7415 /// Determine whether the given expression is a qualified member
7416 /// access expression, of a form that could be turned into a pointer to member
7417 /// with the address-of operator.
7418 bool isQualifiedMemberAccess(Expr *E);
7419 bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
7420 const Expr *Op,
7421 const CXXMethodDecl *MD);
7422
7423 /// CheckAddressOfOperand - The operand of & must be either a function
7424 /// designator or an lvalue designating an object. If it is an lvalue, the
7425 /// object cannot be declared with storage class register or be a bit field.
7426 /// Note: The usual conversions are *not* applied to the operand of the &
7427 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
7428 /// In C++, the operand might be an overloaded function name, in which case
7429 /// we allow the '&' but retain the overloaded-function type.
7430 QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
7431
7432 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
7433 /// _Alignas(type-name) .
7434 /// [dcl.align] An alignment-specifier of the form
7435 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
7436 ///
7437 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
7438 /// _Alignas(_Alignof(type-name)).
7439 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
7440 SourceLocation OpLoc, SourceRange R);
7441 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
7442 SourceLocation OpLoc, SourceRange R);
7443
7444 /// Build a sizeof or alignof expression given a type operand.
7445 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
7446 SourceLocation OpLoc,
7447 UnaryExprOrTypeTrait ExprKind,
7448 SourceRange R);
7449
7450 /// Build a sizeof or alignof expression given an expression
7451 /// operand.
7452 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
7453 UnaryExprOrTypeTrait ExprKind);
7454
7455 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
7456 /// expr and the same for @c alignof and @c __alignof
7457 /// Note that the ArgRange is invalid if isType is false.
7458 ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
7459 UnaryExprOrTypeTrait ExprKind,
7460 bool IsType, void *TyOrEx,
7461 SourceRange ArgRange);
7462
7463 /// Check for operands with placeholder types and complain if found.
7464 /// Returns ExprError() if there was an error and no recovery was possible.
7466 bool CheckVecStepExpr(Expr *E);
7467
7468 /// Check the constraints on expression operands to unary type expression
7469 /// and type traits.
7470 ///
7471 /// Completes any types necessary and validates the constraints on the operand
7472 /// expression. The logic mostly mirrors the type-based overload, but may
7473 /// modify the expression as it completes the type for that expression through
7474 /// template instantiation, etc.
7476
7477 /// Check the constraints on operands to unary expression and type
7478 /// traits.
7479 ///
7480 /// This will complete any types necessary, and validate the various
7481 /// constraints on those operands.
7482 ///
7483 /// The UsualUnaryConversions() function is *not* called by this routine.
7484 /// C99 6.3.2.1p[2-4] all state:
7485 /// Except when it is the operand of the sizeof operator ...
7486 ///
7487 /// C++ [expr.sizeof]p4
7488 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
7489 /// standard conversions are not applied to the operand of sizeof.
7490 ///
7491 /// This policy is followed for all of the unary trait expressions.
7492 bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
7493 SourceRange ExprRange,
7494 UnaryExprOrTypeTrait ExprKind,
7495 StringRef KWName);
7496
7497 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
7498 tok::TokenKind Kind, Expr *Input);
7499
7500 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
7501 MultiExprArg ArgExprs,
7502 SourceLocation RLoc);
7503 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
7504 Expr *Idx, SourceLocation RLoc);
7505
7506 ExprResult CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx,
7507 SourceLocation RBLoc);
7508
7509 ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx,
7510 Expr *ColumnIdx,
7511 SourceLocation RBLoc);
7512
7513 /// ConvertArgumentsForCall - Converts the arguments specified in
7514 /// Args/NumArgs to the parameter types of the function FDecl with
7515 /// function prototype Proto. Call is the call expression itself, and
7516 /// Fn is the function expression. For a C++ member function, this
7517 /// routine does not attempt to convert the object argument. Returns
7518 /// true if the call is ill-formed.
7519 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl,
7520 const FunctionProtoType *Proto,
7521 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
7522 bool ExecConfig = false);
7523
7524 /// CheckStaticArrayArgument - If the given argument corresponds to a static
7525 /// array parameter, check that it is non-null, and that if it is formed by
7526 /// array-to-pointer decay, the underlying array is sufficiently large.
7527 ///
7528 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
7529 /// the array type derivation, then for each call to the function, the value
7530 /// of the corresponding actual argument shall provide access to the first
7531 /// element of an array with at least as many elements as specified by the
7532 /// size expression.
7533 void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
7534 const Expr *ArgExpr);
7535
7536 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
7537 /// This provides the location of the left/right parens and a list of comma
7538 /// locations.
7539 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7540 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7541 Expr *ExecConfig = nullptr);
7542
7543 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
7544 /// This provides the location of the left/right parens and a list of comma
7545 /// locations.
7546 ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7547 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7548 Expr *ExecConfig = nullptr,
7549 bool IsExecConfig = false,
7550 bool AllowRecovery = false);
7551
7552 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
7553 // with the specified CallArgs
7554 Expr *BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id,
7555 MultiExprArg CallArgs);
7556
7558
7559 /// BuildResolvedCallExpr - Build a call to a resolved expression,
7560 /// i.e. an expression not of \p OverloadTy. The expression should
7561 /// unary-convert to an expression of function-pointer or
7562 /// block-pointer type.
7563 ///
7564 /// \param NDecl the declaration being called, if available
7566 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
7567 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
7568 Expr *Config = nullptr, bool IsExecConfig = false,
7569 ADLCallKind UsesADL = ADLCallKind::NotADL);
7570
7572 ParsedType &Ty, SourceLocation RParenLoc,
7573 Expr *CastExpr);
7574
7575 /// Prepares for a scalar cast, performing all the necessary stages
7576 /// except the final cast and returning the kind required.
7578
7579 /// Build an altivec or OpenCL literal.
7581 SourceLocation RParenLoc, Expr *E,
7582 TypeSourceInfo *TInfo);
7583
7584 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7585 /// the ParenListExpr into a sequence of comma binary operators.
7587
7589 SourceLocation RParenLoc, Expr *InitExpr);
7590
7592 TypeSourceInfo *TInfo,
7593 SourceLocation RParenLoc,
7594 Expr *LiteralExpr);
7595
7596 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7597 SourceLocation RBraceLoc);
7598
7599 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7600 SourceLocation RBraceLoc, bool IsExplicit);
7601
7602 /// Binary Operators. 'Tok' is the token for the operator.
7604 Expr *LHSExpr, Expr *RHSExpr);
7606 Expr *LHSExpr, Expr *RHSExpr,
7607 bool ForFoldExpression = false);
7608
7609 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7610 /// operator @p Opc at location @c TokLoc. This routine only supports
7611 /// built-in operations; ActOnBinOp handles overloaded operators.
7613 Expr *LHSExpr, Expr *RHSExpr,
7614 bool ForFoldExpression = false);
7616 UnresolvedSetImpl &Functions);
7617
7618 /// Look for instances where it is likely the comma operator is confused with
7619 /// another operator. There is an explicit list of acceptable expressions for
7620 /// the left hand side of the comma operator, otherwise emit a warning.
7621 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7622
7623 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7624 /// in the case of a the GNU conditional expr extension.
7626 SourceLocation ColonLoc, Expr *CondExpr,
7627 Expr *LHSExpr, Expr *RHSExpr);
7628
7629 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7631 LabelDecl *TheDecl);
7632
7633 void ActOnStartStmtExpr();
7634 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7635 SourceLocation RPLoc);
7637 SourceLocation RPLoc, unsigned TemplateDepth);
7638 // Handle the final expression in a statement expression.
7640 void ActOnStmtExprError();
7641
7642 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
7645 bool isBrackets; // true if [expr], false if .ident
7646 union {
7649 } U;
7650 };
7651
7652 /// __builtin_offsetof(type, a.b[123][456].c)
7654 TypeSourceInfo *TInfo,
7655 ArrayRef<OffsetOfComponent> Components,
7656 SourceLocation RParenLoc);
7659 ParsedType ParsedArgTy,
7660 ArrayRef<OffsetOfComponent> Components,
7661 SourceLocation RParenLoc);
7662
7663 // __builtin_choose_expr(constExpr, expr1, expr2)
7664 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7665 Expr *LHSExpr, Expr *RHSExpr,
7666 SourceLocation RPLoc);
7667
7668 // __builtin_va_arg(expr, type)
7670 SourceLocation RPLoc);
7672 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7673
7674 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7675 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7677 SourceLocation BuiltinLoc,
7678 SourceLocation RPLoc);
7679
7680 // #embed
7682 StringLiteral *BinaryData, StringRef FileName);
7683
7684 // Build a potentially resolved SourceLocExpr.
7686 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7687 DeclContext *ParentContext);
7688
7689 // __null
7691
7692 bool CheckCaseExpression(Expr *E);
7693
7694 //===------------------------- "Block" Extension ------------------------===//
7695
7696 /// ActOnBlockStart - This callback is invoked when a block literal is
7697 /// started.
7698 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7699
7700 /// ActOnBlockArguments - This callback allows processing of block arguments.
7701 /// If there are no arguments, this is still invoked.
7702 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7703 Scope *CurScope);
7704
7705 /// ActOnBlockError - If there is an error parsing a block, this callback
7706 /// is invoked to pop the information about the block from the action impl.
7707 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7708
7709 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7710 /// literal was successfully completed. ^(int x){...}
7712 Scope *CurScope);
7713
7714 //===---------------------------- Clang Extensions ----------------------===//
7715
7716 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7717 /// provided arguments.
7718 ///
7719 /// __builtin_convertvector( value, dst type )
7720 ///
7722 SourceLocation BuiltinLoc,
7723 SourceLocation RParenLoc);
7724
7725 //===---------------------------- OpenCL Features -----------------------===//
7726
7727 /// Parse a __builtin_astype expression.
7728 ///
7729 /// __builtin_astype( value, dst type )
7730 ///
7731 ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
7732 SourceLocation BuiltinLoc,
7733 SourceLocation RParenLoc);
7734
7735 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7737 SourceLocation BuiltinLoc,
7738 SourceLocation RParenLoc);
7739
7740 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7742 ArrayRef<Expr *> SubExprs,
7743 QualType T = QualType());
7744
7745 /// Cast a base object to a member's actual type.
7746 ///
7747 /// There are two relevant checks:
7748 ///
7749 /// C++ [class.access.base]p7:
7750 ///
7751 /// If a class member access operator [...] is used to access a non-static
7752 /// data member or non-static member function, the reference is ill-formed
7753 /// if the left operand [...] cannot be implicitly converted to a pointer to
7754 /// the naming class of the right operand.
7755 ///
7756 /// C++ [expr.ref]p7:
7757 ///
7758 /// If E2 is a non-static data member or a non-static member function, the
7759 /// program is ill-formed if the class of which E2 is directly a member is
7760 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7761 ///
7762 /// Note that the latter check does not consider access; the access of the
7763 /// "real" base class is checked as appropriate when checking the access of
7764 /// the member name.
7766 NestedNameSpecifier Qualifier,
7767 NamedDecl *FoundDecl,
7768 NamedDecl *Member);
7769
7770 /// CheckCallReturnType - Checks that a call expression's return type is
7771 /// complete. Returns true on failure. The location passed in is the location
7772 /// that best represents the call.
7773 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
7774 CallExpr *CE, FunctionDecl *FD);
7775
7776 /// Emit a warning for all pending noderef expressions that we recorded.
7777 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
7778
7780
7781 /// Instantiate or parse a C++ default argument expression as necessary.
7782 /// Return true on error.
7784 ParmVarDecl *Param, Expr *Init = nullptr,
7785 bool SkipImmediateInvocations = true);
7786
7787 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7788 /// the default expr if needed.
7790 ParmVarDecl *Param, Expr *Init = nullptr);
7791
7792 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7793 /// invocation.
7795
7797
7798 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7799 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7800
7801 /// Abstract base class used for diagnosing integer constant
7802 /// expression violations.
7804 public:
7806
7808
7809 virtual SemaDiagnosticBuilder
7810 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7812 SourceLocation Loc) = 0;
7815 };
7816
7817 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7818 /// and reports the appropriate diagnostics. Returns false on success.
7819 /// Can optionally return the value of the expression.
7822 VerifyICEDiagnoser &Diagnoser,
7826 unsigned DiagID,
7829 VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result = nullptr,
7833 AllowFoldKind CanFold = AllowFoldKind::No) {
7834 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7835 }
7836
7837 /// DiagnoseAssignmentAsCondition - Given that an expression is
7838 /// being used as a boolean condition, warn if it's an assignment.
7840
7841 /// Redundant parentheses over an equality comparison can indicate
7842 /// that the user intended an assignment used as condition.
7844
7846 public:
7848 FullExprArg(Sema &actions) : E(nullptr) {}
7849
7850 ExprResult release() { return E; }
7851
7852 Expr *get() const { return E; }
7853
7854 Expr *operator->() { return E; }
7855
7856 private:
7857 // FIXME: No need to make the entire Sema class a friend when it's just
7858 // Sema::MakeFullExpr that needs access to the constructor below.
7859 friend class Sema;
7860
7861 explicit FullExprArg(Expr *expr) : E(expr) {}
7862
7863 Expr *E;
7864 };
7865
7867 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7868 }
7870 return FullExprArg(
7871 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7872 }
7874 ExprResult FE =
7875 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7876 /*DiscardedValue*/ true);
7877 return FullExprArg(FE.get());
7878 }
7879
7880 class ConditionResult {
7881 Decl *ConditionVar;
7882 ExprResult Condition;
7883 bool Invalid;
7884 std::optional<bool> KnownValue;
7885
7886 friend class Sema;
7887 ConditionResult(Sema &S, Decl *ConditionVar, ExprResult Condition,
7888 bool IsConstexpr)
7889 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7890 if (IsConstexpr && Condition.get()) {
7891 if (std::optional<llvm::APSInt> Val =
7892 Condition.get()->getIntegerConstantExpr(S.Context)) {
7893 KnownValue = !!(*Val);
7894 }
7895 }
7896 }
7897 explicit ConditionResult(bool Invalid)
7898 : ConditionVar(nullptr), Condition(Invalid), Invalid(Invalid),
7899 KnownValue(std::nullopt) {}
7900
7901 public:
7902 ConditionResult() : ConditionResult(false) {}
7903 bool isInvalid() const { return Invalid; }
7904 std::pair<VarDecl *, Expr *> get() const {
7905 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7906 Condition.get());
7907 }
7908 std::optional<bool> getKnownValue() const { return KnownValue; }
7909 };
7911
7912 /// CheckBooleanCondition - Diagnose problems involving the use of
7913 /// the given expression as a boolean condition (e.g. in an if
7914 /// statement). Also performs the standard function and array
7915 /// decays, possibly changing the input variable.
7916 ///
7917 /// \param Loc - A location associated with the condition, e.g. the
7918 /// 'if' keyword.
7919 /// \return true iff there were any errors
7921 bool IsConstexpr = false);
7922
7923 enum class ConditionKind {
7924 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7925 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7926 Switch ///< An integral condition for a 'switch' statement.
7927 };
7928
7929 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7930 ConditionKind CK, bool MissingOK = false);
7931
7932 QualType CheckConditionalOperands( // C99 6.5.15
7934 ExprObjectKind &OK, SourceLocation QuestionLoc);
7935
7936 /// Emit a specialized diagnostic when one expression is a null pointer
7937 /// constant and the other is not a pointer. Returns true if a diagnostic is
7938 /// emitted.
7939 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7940 SourceLocation QuestionLoc);
7941
7942 /// type checking for vector binary operators.
7944 SourceLocation Loc, bool IsCompAssign,
7945 bool AllowBothBool, bool AllowBoolConversion,
7946 bool AllowBoolOperation, bool ReportInvalid);
7947
7948 /// Return a signed ext_vector_type that is of identical size and number of
7949 /// elements. For floating point vectors, return an integer type of identical
7950 /// size and number of elements. In the non ext_vector_type case, search from
7951 /// the largest type to the smallest type to avoid cases where long long ==
7952 /// long, where long gets picked over long long.
7955
7956 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7957 /// operates on extended vector types. Instead of producing an IntTy result,
7958 /// like a scalar comparison, a vector comparison produces a vector of integer
7959 /// types.
7961 SourceLocation Loc,
7962 BinaryOperatorKind Opc);
7964 SourceLocation Loc,
7965 BinaryOperatorKind Opc);
7967 SourceLocation Loc,
7968 BinaryOperatorKind Opc);
7970 SourceLocation Loc,
7971 BinaryOperatorKind Opc);
7972 // type checking for sizeless vector binary operators.
7974 SourceLocation Loc, bool IsCompAssign,
7975 ArithConvKind OperationKind);
7976
7977 /// Type checking for matrix binary operators.
7979 SourceLocation Loc,
7980 bool IsCompAssign);
7982 SourceLocation Loc, bool IsCompAssign);
7983
7984 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
7985 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
7986 /// VLST) allowed?
7987 ///
7988 /// This will also return false if the two given types do not make sense from
7989 /// the perspective of SVE bitcasts.
7990 bool isValidSveBitcast(QualType srcType, QualType destType);
7991
7992 /// Are the two types matrix types and do they have the same dimensions i.e.
7993 /// do they have the same number of rows and the same number of columns?
7995
7996 bool areVectorTypesSameSize(QualType srcType, QualType destType);
7997
7998 /// Are the two types lax-compatible vector types? That is, given
7999 /// that one of them is a vector, do they have equal storage sizes,
8000 /// where the storage size is the number of elements times the element
8001 /// size?
8002 ///
8003 /// This will also return false if either of the types is neither a
8004 /// vector nor a real type.
8005 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
8006
8007 /// Is this a legal conversion between two types, one of which is
8008 /// known to be a vector type?
8009 bool isLaxVectorConversion(QualType srcType, QualType destType);
8010
8011 // This returns true if at least one of the types is an altivec vector.
8012 bool anyAltivecTypes(QualType srcType, QualType destType);
8013
8014 // type checking C++ declaration initializers (C++ [dcl.init]).
8015
8016 /// Check a cast of an unknown-any type. We intentionally only
8017 /// trigger this for C-style casts.
8020 ExprValueKind &VK, CXXCastPath &Path);
8021
8022 /// Force an expression with unknown-type to an expression of the
8023 /// given type.
8025
8026 /// Type-check an expression that's being passed to an
8027 /// __unknown_anytype parameter.
8029 QualType &paramType);
8030
8031 // CheckMatrixCast - Check type constraints for matrix casts.
8032 // We allow casting between matrixes of the same dimensions i.e. when they
8033 // have the same number of rows and column. Returns true if the cast is
8034 // invalid.
8035 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
8036 CastKind &Kind);
8037
8038 // CheckVectorCast - check type constraints for vectors.
8039 // Since vectors are an extension, there are no C standard reference for this.
8040 // We allow casting between vectors and integer datatypes of the same size.
8041 // returns true if the cast is invalid
8042 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
8043 CastKind &Kind);
8044
8045 /// Prepare `SplattedExpr` for a vector splat operation, adding
8046 /// implicit casts if necessary.
8047 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
8048
8049 /// Prepare `SplattedExpr` for a matrix splat operation, adding
8050 /// implicit casts if necessary.
8051 ExprResult prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr);
8052
8053 // CheckExtVectorCast - check type constraints for extended vectors.
8054 // Since vectors are an extension, there are no C standard reference for this.
8055 // We allow casting between vectors and integer datatypes of the same size,
8056 // or vectors and the element type of that vector.
8057 // returns the cast expr
8059 CastKind &Kind);
8060
8062 return K == ConditionKind::Switch ? Context.IntTy : Context.BoolTy;
8063 }
8064
8065 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2), converts
8066 // functions and arrays to their respective pointers (C99 6.3.2.1), and
8067 // promotes floating-piont types according to the language semantics.
8069
8070 // UsualUnaryFPConversions - promotes floating-point types according to the
8071 // current language semantics.
8073
8074 /// CallExprUnaryConversions - a special case of an unary conversion
8075 /// performed on a function designator of a call expression.
8077
8078 // DefaultFunctionArrayConversion - converts functions and arrays
8079 // to their respective pointers (C99 6.3.2.1).
8081
8082 // DefaultFunctionArrayLvalueConversion - converts functions and
8083 // arrays to their respective pointers and performs the
8084 // lvalue-to-rvalue conversion.
8086 bool Diagnose = true);
8087
8088 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
8089 // the operand. This function is a no-op if the operand has a function type
8090 // or an array type.
8092
8093 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
8094 // do not have a prototype. Integer promotions are performed on each
8095 // argument, and arguments that have type float are promoted to double.
8097
8099 const FunctionProtoType *Proto,
8100 Expr *Fn);
8101
8102 /// Determine the degree of POD-ness for an expression.
8103 /// Incomplete types are considered POD, since this check can be performed
8104 /// when we're in an unevaluated context.
8106
8107 /// Check to see if the given expression is a valid argument to a variadic
8108 /// function, issuing a diagnostic if not.
8109 void checkVariadicArgument(const Expr *E, VariadicCallType CT);
8110
8111 /// GatherArgumentsForCall - Collector argument expressions for various
8112 /// form of call prototypes.
8114 SourceLocation CallLoc, FunctionDecl *FDecl,
8115 const FunctionProtoType *Proto, unsigned FirstParam,
8118 bool AllowExplicit = false, bool IsListInitialization = false);
8119
8120 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
8121 // will create a runtime trap if the resulting type is not a POD type.
8123 FunctionDecl *FDecl);
8124
8125 // Check that the usual arithmetic conversions can be performed on this pair
8126 // of expressions that might be of enumeration type.
8128 ArithConvKind ACK);
8129
8130 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
8131 // operands and then handles various conversions that are common to binary
8132 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
8133 // routine returns the first non-arithmetic type found. The client is
8134 // responsible for emitting appropriate error diagnostics.
8136 SourceLocation Loc, ArithConvKind ACK);
8137
8139 switch (ConvTy) {
8140 default:
8141 return false;
8145 return true;
8146 }
8147 llvm_unreachable("impossible");
8148 }
8149
8150 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
8151 /// assignment conversion type specified by ConvTy. This returns true if the
8152 /// conversion was invalid or false if the conversion was accepted.
8154 QualType DstType, QualType SrcType,
8155 Expr *SrcExpr, AssignmentAction Action,
8156 bool *Complained = nullptr);
8157
8158 /// CheckAssignmentConstraints - Perform type checking for assignment,
8159 /// argument passing, variable initialization, and function return values.
8160 /// C99 6.5.16.
8162 QualType LHSType,
8163 QualType RHSType);
8164
8165 /// Check assignment constraints and optionally prepare for a conversion of
8166 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
8167 /// is true.
8169 ExprResult &RHS, CastKind &Kind,
8170 bool ConvertRHS = true);
8171
8172 /// Check assignment constraints for an assignment of RHS to LHSType.
8173 ///
8174 /// \param LHSType The destination type for the assignment.
8175 /// \param RHS The source expression for the assignment.
8176 /// \param Diagnose If \c true, diagnostics may be produced when checking
8177 /// for assignability. If a diagnostic is produced, \p RHS will be
8178 /// set to ExprError(). Note that this function may still return
8179 /// without producing a diagnostic, even for an invalid assignment.
8180 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
8181 /// in an audited Core Foundation API and does not need to be checked
8182 /// for ARC retain issues.
8183 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
8184 /// conversions necessary to perform the assignment. If \c false,
8185 /// \p Diagnose must also be \c false.
8187 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
8188 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
8189
8190 // If the lhs type is a transparent union, check whether we
8191 // can initialize the transparent union with the given expression.
8193 ExprResult &RHS);
8194
8195 /// the following "Check" methods will return a valid/converted QualType
8196 /// or a null QualType (indicating an error diagnostic was issued).
8197
8198 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
8200 ExprResult &RHS);
8201
8202 /// Diagnose cases where a scalar was implicitly converted to a vector and
8203 /// diagnose the underlying types. Otherwise, diagnose the error
8204 /// as invalid vector logical operands for non-C++ cases.
8206 ExprResult &RHS);
8207
8209 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8210 BinaryOperatorKind Opc);
8211 QualType CheckRemainderOperands( // C99 6.5.5
8212 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8213 bool IsCompAssign = false);
8214 QualType CheckAdditionOperands( // C99 6.5.6
8215 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8216 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8218 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8219 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8220 QualType CheckShiftOperands( // C99 6.5.7
8221 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8222 BinaryOperatorKind Opc, bool IsCompAssign = false);
8224 QualType CheckCompareOperands( // C99 6.5.8/9
8225 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8226 BinaryOperatorKind Opc);
8227 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
8228 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8229 BinaryOperatorKind Opc);
8230 QualType CheckLogicalOperands( // C99 6.5.[13,14]
8231 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8232 BinaryOperatorKind Opc);
8233 // CheckAssignmentOperands is used for both simple and compound assignment.
8234 // For simple assignment, pass both expressions and a null converted type.
8235 // For compound assignment, pass both expressions and the converted type.
8236 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
8237 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
8238 BinaryOperatorKind Opc);
8239
8240 /// To be used for checking whether the arguments being passed to
8241 /// function exceeds the number of parameters expected for it.
8242 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
8243 bool PartialOverloading = false) {
8244 // We check whether we're just after a comma in code-completion.
8245 if (NumArgs > 0 && PartialOverloading)
8246 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
8247 return NumArgs > NumParams;
8248 }
8249
8250 /// Whether the AST is currently being rebuilt to correct immediate
8251 /// invocations. Immediate invocation candidates and references to consteval
8252 /// functions aren't tracked when this is set.
8254
8260
8261 /// Determines whether we are currently in a context that
8262 /// is not evaluated as per C++ [expr] p5.
8265 }
8266
8270
8274
8278
8285
8286 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8288 assert(!ExprEvalContexts.empty() &&
8289 "Must be in an expression evaluation context");
8290 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8292 Ctx.DelayedDefaultInitializationContext)
8293 return Ctx.DelayedDefaultInitializationContext;
8294 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8295 Ctx.isUnevaluated())
8296 break;
8297 }
8298 return std::nullopt;
8299 }
8300
8301 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8303 assert(!ExprEvalContexts.empty() &&
8304 "Must be in an expression evaluation context");
8305 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
8306 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8308 !Ctx.DelayedDefaultInitializationContext && Res)
8309 break;
8310 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8311 Ctx.isUnevaluated())
8312 break;
8313 Res = Ctx.DelayedDefaultInitializationContext;
8314 }
8315 return Res;
8316 }
8317
8321
8322 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
8323 /// SelfAssigned when inside a CXXMethodDecl.
8324 const FieldDecl *
8326
8328
8329 template <typename... Ts>
8331 const Ts &...Args) {
8332 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8333 return RequireCompleteType(Loc, T, CompleteTypeKind::Normal, Diagnoser);
8334 }
8335
8336 template <typename... Ts>
8337 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
8338 const Ts &...Args) {
8339 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8341 }
8342
8343 /// Abstract class used to diagnose incomplete types.
8346
8347 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
8348 virtual ~TypeDiagnoser() {}
8349 };
8350
8351 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
8352 protected:
8353 unsigned DiagID;
8354 std::tuple<const Ts &...> Args;
8355
8356 template <std::size_t... Is>
8358 std::index_sequence<Is...>) const {
8359 // Apply all tuple elements to the builder in order.
8360 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
8361 (void)Dummy;
8362 }
8363
8364 public:
8365 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8366 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
8367 assert(DiagID != 0 && "no diagnostic for type diagnoser");
8368 }
8369
8370 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8371 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
8372 emit(DB, std::index_sequence_for<Ts...>());
8373 DB << T;
8374 }
8375 };
8376
8377 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
8378 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
8379 /// For example, a diagnostic with no other parameters would generally have
8380 /// the form "...%select{incomplete|sizeless}0 type %1...".
8381 template <typename... Ts>
8383 public:
8384 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8385 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
8386
8387 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8388 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
8389 this->emit(DB, std::index_sequence_for<Ts...>());
8390 DB << T->isSizelessType() << T;
8391 }
8392 };
8393
8394 /// Check an argument list for placeholders that we won't try to
8395 /// handle later.
8397
8398 /// The C++ "std::source_location::__impl" struct, defined in
8399 /// <source_location>.
8401
8402 /// A stack of expression evaluation contexts.
8404
8405 // Set of failed immediate invocations to avoid double diagnosing.
8407
8408 /// List of SourceLocations where 'self' is implicitly retained inside a
8409 /// block.
8412
8413 /// Do an explicit extend of the given block pointer if we're in ARC.
8415
8416 std::vector<std::pair<QualType, unsigned>> ExcessPrecisionNotSatisfied;
8419
8420private:
8421 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
8422
8423 /// Methods for marking which expressions involve dereferencing a pointer
8424 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
8425 /// they are parsed, meaning that a noderef pointer may not be accessed. For
8426 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
8427 /// `*p`, but need to check that `address of` is called on it. This requires
8428 /// keeping a container of all pending expressions and checking if the address
8429 /// of them are eventually taken.
8430 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
8431 void CheckAddressOfNoDeref(const Expr *E);
8432
8433 ///@}
8434
8435 //
8436 //
8437 // -------------------------------------------------------------------------
8438 //
8439 //
8440
8441 /// \name C++ Expressions
8442 /// Implementations are in SemaExprCXX.cpp
8443 ///@{
8444
8445public:
8446 /// The C++ "std::bad_alloc" class, which is defined by the C++
8447 /// standard library.
8449
8450 /// The C++ "std::align_val_t" enum class, which is defined by the C++
8451 /// standard library.
8453
8454 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
8456
8457 /// A flag to remember whether the implicit forms of operator new and delete
8458 /// have been declared.
8460
8461 /// Delete-expressions to be analyzed at the end of translation unit
8462 ///
8463 /// This list contains class members, and locations of delete-expressions
8464 /// that could not be proven as to whether they mismatch with new-expression
8465 /// used in initializer of the field.
8466 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
8467
8468 /// Handle the result of the special case name lookup for inheriting
8469 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
8470 /// constructor names in member using declarations, even if 'X' is not the
8471 /// name of the corresponding type.
8473 SourceLocation NameLoc,
8474 const IdentifierInfo &Name);
8475
8477 SourceLocation NameLoc, Scope *S,
8478 CXXScopeSpec &SS, bool EnteringContext);
8480 Scope *S, CXXScopeSpec &SS,
8481 ParsedType ObjectType, bool EnteringContext);
8482
8484 ParsedType ObjectType);
8485
8486 /// Build a C++ typeid expression with a type operand.
8487 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8488 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8489
8490 /// Build a C++ typeid expression with an expression operand.
8491 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8492 Expr *Operand, SourceLocation RParenLoc);
8493
8494 /// ActOnCXXTypeid - Parse typeid( something ).
8496 bool isType, void *TyOrExpr,
8497 SourceLocation RParenLoc);
8498
8499 /// Build a Microsoft __uuidof expression with a type operand.
8500 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8501 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8502
8503 /// Build a Microsoft __uuidof expression with an expression operand.
8504 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8505 Expr *Operand, SourceLocation RParenLoc);
8506
8507 /// ActOnCXXUuidof - Parse __uuidof( something ).
8509 bool isType, void *TyOrExpr,
8510 SourceLocation RParenLoc);
8511
8512 //// ActOnCXXThis - Parse 'this' pointer.
8514
8515 /// Check whether the type of 'this' is valid in the current context.
8517
8518 /// Build a CXXThisExpr and mark it referenced in the current context.
8519 Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
8521
8522 /// Try to retrieve the type of the 'this' pointer.
8523 ///
8524 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8526
8527 /// When non-NULL, the C++ 'this' expression is allowed despite the
8528 /// current context not being a non-static member function. In such cases,
8529 /// this provides the type used for 'this'.
8531
8532 /// RAII object used to temporarily allow the C++ 'this' expression
8533 /// to be used, with the given qualifiers on the current class type.
8535 Sema &S;
8536 QualType OldCXXThisTypeOverride;
8537 bool Enabled;
8538
8539 public:
8540 /// Introduce a new scope where 'this' may be allowed (when enabled),
8541 /// using the given declaration (which is either a class template or a
8542 /// class) along with the given qualifiers.
8543 /// along with the qualifiers placed on '*this'.
8544 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8545 bool Enabled = true);
8546
8550 };
8551
8552 /// Make sure the value of 'this' is actually available in the current
8553 /// context, if it is a potentially evaluated context.
8554 ///
8555 /// \param Loc The location at which the capture of 'this' occurs.
8556 ///
8557 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8558 /// capture list.
8559 ///
8560 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8561 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8562 /// This is useful when enclosing lambdas must speculatively capture
8563 /// 'this' that may or may not be used in certain specializations of
8564 /// a nested generic lambda (depending on whether the name resolves to
8565 /// a non-static member function or a static function).
8566 /// \return returns 'true' if failed, 'false' if success.
8568 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8569 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8570 bool ByCopy = false);
8571
8572 /// Determine whether the given type is the type of *this that is used
8573 /// outside of the body of a member function for a type that is currently
8574 /// being defined.
8576
8577 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8579
8580 /// Build a boolean-typed literal expression.
8582
8583 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8585
8586 //// ActOnCXXThrow - Parse throw expressions.
8589 bool IsThrownVarInScope);
8590
8591 /// CheckCXXThrowOperand - Validate the operand of a throw.
8592 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8593
8594 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8595 /// Can be interpreted either as function-style casting ("int(x)")
8596 /// or class type construction ("ClassType(x,y,z)")
8597 /// or creation of a value-initialized type ("int()").
8599 SourceLocation LParenOrBraceLoc,
8600 MultiExprArg Exprs,
8601 SourceLocation RParenOrBraceLoc,
8602 bool ListInitialization);
8603
8605 SourceLocation LParenLoc,
8606 MultiExprArg Exprs,
8607 SourceLocation RParenLoc,
8608 bool ListInitialization);
8609
8610 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8611 ///
8612 /// E.g.:
8613 /// @code new (memory) int[size][4] @endcode
8614 /// or
8615 /// @code ::new Foo(23, "hello") @endcode
8616 ///
8617 /// \param StartLoc The first location of the expression.
8618 /// \param UseGlobal True if 'new' was prefixed with '::'.
8619 /// \param PlacementLParen Opening paren of the placement arguments.
8620 /// \param PlacementArgs Placement new arguments.
8621 /// \param PlacementRParen Closing paren of the placement arguments.
8622 /// \param TypeIdParens If the type is in parens, the source range.
8623 /// \param D The type to be allocated, as well as array dimensions.
8624 /// \param Initializer The initializing expression or initializer-list, or
8625 /// null if there is none.
8626 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8627 SourceLocation PlacementLParen,
8628 MultiExprArg PlacementArgs,
8629 SourceLocation PlacementRParen,
8630 SourceRange TypeIdParens, Declarator &D,
8631 Expr *Initializer);
8633 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8634 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8635 SourceRange TypeIdParens, QualType AllocType,
8636 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8637 SourceRange DirectInitRange, Expr *Initializer);
8638
8639 /// Determine whether \p FD is an aligned allocation or deallocation
8640 /// function that is unavailable.
8642
8643 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8644 /// function that is unavailable.
8646 SourceLocation Loc);
8647
8648 /// Checks that a type is suitable as the allocated type
8649 /// in a new-expression.
8650 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
8651 SourceRange R);
8652
8653 /// Finds the overloads of operator new and delete that are appropriate
8654 /// for the allocation.
8656 SourceLocation StartLoc, SourceRange Range,
8658 QualType AllocType, bool IsArray, ImplicitAllocationParameters &IAP,
8659 MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew,
8660 FunctionDecl *&OperatorDelete, bool Diagnose = true);
8661
8662 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8663 /// delete. These are:
8664 /// @code
8665 /// // C++03:
8666 /// void* operator new(std::size_t) throw(std::bad_alloc);
8667 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8668 /// void operator delete(void *) throw();
8669 /// void operator delete[](void *) throw();
8670 /// // C++11:
8671 /// void* operator new(std::size_t);
8672 /// void* operator new[](std::size_t);
8673 /// void operator delete(void *) noexcept;
8674 /// void operator delete[](void *) noexcept;
8675 /// // C++1y:
8676 /// void* operator new(std::size_t);
8677 /// void* operator new[](std::size_t);
8678 /// void operator delete(void *) noexcept;
8679 /// void operator delete[](void *) noexcept;
8680 /// void operator delete(void *, std::size_t) noexcept;
8681 /// void operator delete[](void *, std::size_t) noexcept;
8682 /// @endcode
8683 /// Note that the placement and nothrow forms of new are *not* implicitly
8684 /// declared. Their use requires including <new>.
8687 ArrayRef<QualType> Params);
8688
8690 DeclarationName Name, FunctionDecl *&Operator,
8692 bool Diagnose = true);
8695 DeclarationName Name,
8696 bool Diagnose = true);
8698 CXXRecordDecl *RD,
8699 bool Diagnose,
8700 bool LookForGlobal,
8701 DeclarationName Name);
8702
8703 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8704 /// @code ::delete ptr; @endcode
8705 /// or
8706 /// @code delete [] ptr; @endcode
8707 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8708 bool ArrayForm, Expr *Operand);
8710 bool IsDelete, bool CallCanBeVirtual,
8711 bool WarnOnNonAbstractTypes,
8712 SourceLocation DtorLoc);
8713
8715 Expr *Operand, SourceLocation RParen);
8717 SourceLocation RParen);
8718
8720 SourceLocation OpLoc,
8721 tok::TokenKind OpKind,
8722 ParsedType &ObjectType,
8723 bool &MayBePseudoDestructor);
8724
8726 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8727 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8728 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8729
8731 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8732 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8733 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8734
8736 SourceLocation OpLoc,
8737 tok::TokenKind OpKind,
8738 SourceLocation TildeLoc,
8739 const DeclSpec &DS);
8740
8741 /// MaybeCreateExprWithCleanups - If the current full-expression
8742 /// requires any cleanups, surround it with a ExprWithCleanups node.
8743 /// Otherwise, just returns the passed-in expression.
8747
8748 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8749 return ActOnFinishFullExpr(
8750 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8751 }
8753 bool DiscardedValue, bool IsConstexpr = false,
8754 bool IsTemplateArgument = false);
8756
8757 /// Process the expression contained within a decltype. For such expressions,
8758 /// certain semantic checks on temporaries are delayed until this point, and
8759 /// are omitted for the 'topmost' call in the decltype expression. If the
8760 /// topmost call bound a temporary, strip that temporary off the expression.
8762
8763 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8764 bool IsUDSuffix);
8765
8767
8768 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8769 SourceLocation StmtLoc,
8770 ConditionKind CK);
8771
8772 /// Check the use of the given variable as a C++ condition in an if,
8773 /// while, do-while, or switch statement.
8775 SourceLocation StmtLoc, ConditionKind CK);
8776
8777 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8778 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8779
8780 /// Helper function to determine whether this is the (deprecated) C++
8781 /// conversion from a string literal to a pointer to non-const char or
8782 /// non-const wchar_t (for narrow and wide string literals,
8783 /// respectively).
8785
8786 /// PerformImplicitConversion - Perform an implicit conversion of the
8787 /// expression From to the type ToType using the pre-computed implicit
8788 /// conversion sequence ICS. Returns the converted
8789 /// expression. Action is the kind of conversion we're performing,
8790 /// used in the error message.
8792 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8793 AssignmentAction Action,
8795
8796 /// PerformImplicitConversion - Perform an implicit conversion of the
8797 /// expression From to the type ToType by following the standard
8798 /// conversion sequence SCS. Returns the converted
8799 /// expression. Flavor is the context in which we're performing this
8800 /// conversion, for use in error messages.
8802 const StandardConversionSequence &SCS,
8803 AssignmentAction Action,
8805
8806 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8807
8808 /// Parsed one of the type trait support pseudo-functions.
8811 SourceLocation RParenLoc);
8814 SourceLocation RParenLoc);
8815
8816 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8817 /// pseudo-functions.
8819 ParsedType LhsTy, Expr *DimExpr,
8820 SourceLocation RParen);
8821
8823 TypeSourceInfo *TSInfo, Expr *DimExpr,
8824 SourceLocation RParen);
8825
8826 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8827 /// pseudo-functions.
8829 Expr *Queried, SourceLocation RParen);
8830
8832 Expr *Queried, SourceLocation RParen);
8833
8836 bool isIndirect);
8838 ExprResult &RHS,
8839 SourceLocation QuestionLoc);
8840
8841 //// Determines if a type is trivially relocatable
8842 /// according to the C++26 rules.
8843 // FIXME: This is in Sema because it requires
8844 // overload resolution, can we move to ASTContext?
8847
8848 /// Check the operands of ?: under C++ semantics.
8849 ///
8850 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8851 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8852 ///
8853 /// This function also implements GCC's vector extension and the
8854 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8855 /// permit the use of a?b:c where the type of a is that of a integer vector
8856 /// with the same number of elements and size as the vectors of b and c. If
8857 /// one of either b or c is a scalar it is implicitly converted to match the
8858 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8859 /// c are scalars, then b and c are checked and converted to the type of a if
8860 /// possible.
8861 ///
8862 /// The expressions are evaluated differently for GCC's and OpenCL's
8863 /// extensions. For the GCC extension, the ?: operator is evaluated as
8864 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8865 /// For the OpenCL extensions, the ?: operator is evaluated as
8866 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8867 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8869 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8870 ExprObjectKind &OK, SourceLocation questionLoc);
8871
8872 /// Find a merged pointer type and convert the two expressions to it.
8873 ///
8874 /// This finds the composite pointer type for \p E1 and \p E2 according to
8875 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8876 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8877 /// ConvertArgs is \c true).
8878 ///
8879 /// \param Loc The location of the operator requiring these two expressions to
8880 /// be converted to the composite pointer type.
8881 ///
8882 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8883 /// type.
8885 bool ConvertArgs = true);
8887 ExprResult &E2, bool ConvertArgs = true) {
8888 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8889 QualType Composite =
8890 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8891 E1 = E1Tmp;
8892 E2 = E2Tmp;
8893 return Composite;
8894 }
8895
8896 /// MaybeBindToTemporary - If the passed in expression has a record type with
8897 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8898 /// it simply returns the passed in expression.
8900
8901 /// IgnoredValueConversions - Given that an expression's result is
8902 /// syntactically ignored, perform any conversions that are
8903 /// required.
8905
8907
8910 const DeclarationNameInfo &TargetNameInfo);
8911
8913 SourceLocation KeywordLoc,
8914 bool IsIfExists, CXXScopeSpec &SS,
8915 UnqualifiedId &Name);
8916
8919 ArrayRef<ParmVarDecl *> LocalParameters,
8920 Scope *BodyScope);
8924 CXXScopeSpec &SS,
8925 SourceLocation NameLoc,
8926 const IdentifierInfo *TypeName,
8927 TemplateIdAnnotation *TemplateId);
8929 SourceLocation NoexceptLoc);
8931 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8932 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8935 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8939 bool IsSatisfied, SourceLocation NoexceptLoc,
8946 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8947 const ASTConstraintSatisfaction &Satisfaction);
8950 SourceLocation LParenLoc,
8951 ArrayRef<ParmVarDecl *> LocalParameters,
8952 SourceLocation RParenLoc,
8954 SourceLocation ClosingBraceLoc);
8955
8956private:
8957 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8958 bool IsDelete);
8959
8960 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8961 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8962 bool DeleteWasArrayForm);
8963
8964 ///@}
8965
8966 //
8967 //
8968 // -------------------------------------------------------------------------
8969 //
8970 //
8971
8972 /// \name Member Access Expressions
8973 /// Implementations are in SemaExprMember.cpp
8974 ///@{
8975
8976public:
8977 /// Check whether an expression might be an implicit class member access.
8979 bool IsAddressOfOperand);
8980
8981 /// Builds an expression which might be an implicit member expression.
8983 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
8984 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
8985
8986 /// Builds an implicit member access expression. The current context
8987 /// is known to be an instance method, and the given unqualified lookup
8988 /// set is known to contain only instance members, at least one of which
8989 /// is from an appropriate type.
8991 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8992 LookupResult &R,
8993 const TemplateArgumentListInfo *TemplateArgs,
8994 bool IsDefiniteInstance, const Scope *S);
8995
8997 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
8998 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8999 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
9000 const TemplateArgumentListInfo *TemplateArgs);
9001
9002 /// The main callback when the parser finds something like
9003 /// expression . [nested-name-specifier] identifier
9004 /// expression -> [nested-name-specifier] identifier
9005 /// where 'identifier' encompasses a fairly broad spectrum of
9006 /// possibilities, including destructor and operator references.
9007 ///
9008 /// \param OpKind either tok::arrow or tok::period
9009 /// \param ObjCImpDecl the current Objective-C \@implementation
9010 /// decl; this is an ugly hack around the fact that Objective-C
9011 /// \@implementations aren't properly put in the context chain
9013 tok::TokenKind OpKind, CXXScopeSpec &SS,
9014 SourceLocation TemplateKWLoc,
9015 UnqualifiedId &Member, Decl *ObjCImpDecl);
9016
9017 MemberExpr *
9018 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
9019 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
9020 ValueDecl *Member, DeclAccessPair FoundDecl,
9021 bool HadMultipleCandidates,
9022 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
9024 const TemplateArgumentListInfo *TemplateArgs = nullptr);
9025
9026 // Check whether the declarations we found through a nested-name
9027 // specifier in a member expression are actually members of the base
9028 // type. The restriction here is:
9029 //
9030 // C++ [expr.ref]p2:
9031 // ... In these cases, the id-expression shall name a
9032 // member of the class or of one of its base classes.
9033 //
9034 // So it's perfectly legitimate for the nested-name specifier to name
9035 // an unrelated class, and for us to find an overload set including
9036 // decls from classes which are not superclasses, as long as the decl
9037 // we actually pick through overload resolution is from a superclass.
9038 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
9039 const CXXScopeSpec &SS,
9040 const LookupResult &R);
9041
9042 // This struct is for use by ActOnMemberAccess to allow
9043 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
9044 // changing the access operator from a '.' to a '->' (to see if that is the
9045 // change needed to fix an error about an unknown member, e.g. when the class
9046 // defines a custom operator->).
9052
9054 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
9055 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9056 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
9057 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
9058 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
9059
9062 bool IsArrow, const CXXScopeSpec &SS,
9063 SourceLocation TemplateKWLoc,
9064 NamedDecl *FirstQualifierInScope, LookupResult &R,
9065 const TemplateArgumentListInfo *TemplateArgs,
9066 const Scope *S, bool SuppressQualifierCheck = false,
9067 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
9068
9069 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
9070 SourceLocation OpLoc,
9071 const CXXScopeSpec &SS, FieldDecl *Field,
9072 DeclAccessPair FoundDecl,
9073 const DeclarationNameInfo &MemberNameInfo);
9074
9075 /// Perform conversions on the LHS of a member access expression.
9077
9079 const CXXScopeSpec &SS, SourceLocation nameLoc,
9080 IndirectFieldDecl *indirectField,
9081 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
9082 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
9083
9084private:
9085 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
9086
9087 ///@}
9088
9089 //
9090 //
9091 // -------------------------------------------------------------------------
9092 //
9093 //
9094
9095 /// \name Initializers
9096 /// Implementations are in SemaInit.cpp
9097 ///@{
9098
9099public:
9100 /// Stack of types that correspond to the parameter entities that are
9101 /// currently being copy-initialized. Can be empty.
9103
9104 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
9106
9107 bool IsStringInit(Expr *Init, const ArrayType *AT);
9108
9109 /// Determine whether we can perform aggregate initialization for the purposes
9110 /// of overload resolution.
9112 const InitializedEntity &Entity, InitListExpr *From);
9113
9115 SourceLocation EqualOrColonLoc,
9116 bool GNUSyntax, ExprResult Init);
9117
9118 /// Check that the lifetime of the initializer (and its subobjects) is
9119 /// sufficient for initializing the entity, and perform lifetime extension
9120 /// (when permitted) if not.
9122
9125 bool BoundToLvalueReference);
9126
9127 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
9128 /// it as an xvalue. In C++98, the result will still be a prvalue, because
9129 /// we don't have xvalues there.
9131
9135
9139 SourceLocation EqualLoc, ExprResult Init,
9140 bool TopLevelOfInitList = false,
9141 bool AllowExplicit = false);
9142
9144 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
9145 const InitializationKind &Kind, MultiExprArg Init);
9146
9147 ///@}
9148
9149 //
9150 //
9151 // -------------------------------------------------------------------------
9152 //
9153 //
9154
9155 /// \name C++ Lambda Expressions
9156 /// Implementations are in SemaLambda.cpp
9157 ///@{
9158
9159public:
9160 /// Create a new lambda closure type.
9162 TypeSourceInfo *Info,
9163 unsigned LambdaDependencyKind,
9164 LambdaCaptureDefault CaptureDefault);
9165
9166 /// Number lambda for linkage purposes if necessary.
9168 std::optional<CXXRecordDecl::LambdaNumbering>
9169 NumberingOverride = std::nullopt);
9170
9171 /// Endow the lambda scope info with the relevant properties.
9172 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
9173 SourceRange IntroducerRange,
9174 LambdaCaptureDefault CaptureDefault,
9175 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
9176 bool Mutable);
9177
9180
9182 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
9183 TemplateParameterList *TemplateParams);
9184
9185 void
9187 SourceLocation CallOperatorLoc,
9188 const AssociatedConstraint &TrailingRequiresClause,
9189 TypeSourceInfo *MethodTyInfo,
9190 ConstexprSpecKind ConstexprKind, StorageClass SC,
9192 bool HasExplicitResultType);
9193
9194 /// Returns true if the explicit object parameter was invalid.
9196 SourceLocation CallLoc);
9197
9198 /// Perform initialization analysis of the init-capture and perform
9199 /// any implicit conversions such as an lvalue-to-rvalue conversion if
9200 /// not being used to initialize a reference.
9202 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
9203 IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init) {
9205 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
9207 }
9209 SourceLocation EllipsisLoc,
9210 UnsignedOrNone NumExpansions,
9211 IdentifierInfo *Id,
9212 bool DirectInit, Expr *&Init);
9213
9214 /// Create a dummy variable within the declcontext of the lambda's
9215 /// call operator, for name lookup purposes for a lambda init capture.
9216 ///
9217 /// CodeGen handles emission of lambda captures, ignoring these dummy
9218 /// variables appropriately.
9220 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
9221 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
9222
9223 /// Add an init-capture to a lambda scope.
9224 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
9225
9226 /// Note that we have finished the explicit captures for the
9227 /// given lambda.
9229
9230 /// Deduce a block or lambda's return type based on the return
9231 /// statements present in the body.
9233
9234 /// Once the Lambdas capture are known, we can start to create the closure,
9235 /// call operator method, and keep track of the captures.
9236 /// We do the capture lookup here, but they are not actually captured until
9237 /// after we know what the qualifiers of the call operator are.
9239 Scope *CurContext);
9240
9241 /// This is called after parsing the explicit template parameter list
9242 /// on a lambda (if it exists) in C++2a.
9244 SourceLocation LAngleLoc,
9245 ArrayRef<NamedDecl *> TParams,
9246 SourceLocation RAngleLoc,
9247 ExprResult RequiresClause);
9248
9250 SourceLocation MutableLoc);
9251
9253 Scope *LambdaScope,
9255
9256 /// ActOnStartOfLambdaDefinition - This is called just before we start
9257 /// parsing the body of a lambda; it analyzes the explicit captures and
9258 /// arguments, and sets up various data-structures for the body of the
9259 /// lambda.
9261 Declarator &ParamInfo, const DeclSpec &DS);
9262
9263 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
9264 /// is invoked to pop the information about the lambda.
9265 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
9266 bool IsInstantiation = false);
9267
9268 /// ActOnLambdaExpr - This is called when the body of a lambda expression
9269 /// was successfully completed.
9271
9272 /// Does copying/destroying the captured variable have side effects?
9273 bool CaptureHasSideEffects(const sema::Capture &From);
9274
9275 /// Diagnose if an explicit lambda capture is unused. Returns true if a
9276 /// diagnostic is emitted.
9277 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
9278 SourceRange FixItRange,
9279 const sema::Capture &From);
9280
9281 /// Build a FieldDecl suitable to hold the given capture.
9283
9284 /// Initialize the given capture with a suitable expression.
9286 SourceLocation ImplicitCaptureLoc,
9287 bool IsOpenMPMapping = false);
9288
9289 /// Complete a lambda-expression having processed and attached the
9290 /// lambda body.
9292
9293 /// Get the return type to use for a lambda's conversion function(s) to
9294 /// function pointer type, given the type of the call operator.
9295 QualType
9297 CallingConv CC);
9298
9300 SourceLocation ConvLocation,
9301 CXXConversionDecl *Conv, Expr *Src);
9302
9304 : private FunctionScopeRAII {
9305 public:
9307 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
9309 bool ShouldAddDeclsFromParentScope = true);
9310 };
9311
9312 /// Compute the mangling number context for a lambda expression or
9313 /// block literal. Also return the extra mangling decl if any.
9314 ///
9315 /// \param DC - The DeclContext containing the lambda expression or
9316 /// block literal.
9317 std::tuple<MangleNumberingContext *, Decl *>
9319
9320 ///@}
9321
9322 //
9323 //
9324 // -------------------------------------------------------------------------
9325 //
9326 //
9327
9328 /// \name Name Lookup
9329 ///
9330 /// These routines provide name lookup that is used during semantic
9331 /// analysis to resolve the various kinds of names (identifiers,
9332 /// overloaded operator names, constructor names, etc.) into zero or
9333 /// more declarations within a particular scope. The major entry
9334 /// points are LookupName, which performs unqualified name lookup,
9335 /// and LookupQualifiedName, which performs qualified name lookup.
9336 ///
9337 /// All name lookup is performed based on some specific criteria,
9338 /// which specify what names will be visible to name lookup and how
9339 /// far name lookup should work. These criteria are important both
9340 /// for capturing language semantics (certain lookups will ignore
9341 /// certain names, for example) and for performance, since name
9342 /// lookup is often a bottleneck in the compilation of C++. Name
9343 /// lookup criteria is specified via the LookupCriteria enumeration.
9344 ///
9345 /// The results of name lookup can vary based on the kind of name
9346 /// lookup performed, the current language, and the translation
9347 /// unit. In C, for example, name lookup will either return nothing
9348 /// (no entity found) or a single declaration. In C++, name lookup
9349 /// can additionally refer to a set of overloaded functions or
9350 /// result in an ambiguity. All of the possible results of name
9351 /// lookup are captured by the LookupResult class, which provides
9352 /// the ability to distinguish among them.
9353 ///
9354 /// Implementations are in SemaLookup.cpp
9355 ///@{
9356
9357public:
9358 /// Tracks whether we are in a context where typo correction is
9359 /// disabled.
9361
9362 /// The number of typos corrected by CorrectTypo.
9364
9365 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
9366 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
9367
9368 /// A cache containing identifiers for which typo correction failed and
9369 /// their locations, so that repeated attempts to correct an identifier in a
9370 /// given location are ignored if typo correction already failed for it.
9372
9373 /// SpecialMemberOverloadResult - The overloading result for a special member
9374 /// function.
9375 ///
9376 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
9377 /// integer are used to determine whether overload resolution succeeded.
9379 public:
9381
9382 private:
9383 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
9384
9385 public:
9388 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
9389
9390 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
9391 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
9392
9393 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
9394 void setKind(Kind K) { Pair.setInt(K); }
9395 };
9396
9397 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
9399 public:
9400 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
9401 : FastFoldingSetNode(ID) {}
9402 };
9403
9404 /// A cache of special member function overload resolution results
9405 /// for C++ records.
9406 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
9407
9409
9410 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
9411 // TODO: make this is a typesafe union.
9414
9415 /// Describes the kind of name lookup to perform.
9417 /// Ordinary name lookup, which finds ordinary names (functions,
9418 /// variables, typedefs, etc.) in C and most kinds of names
9419 /// (functions, variables, members, types, etc.) in C++.
9421 /// Tag name lookup, which finds the names of enums, classes,
9422 /// structs, and unions.
9424 /// Label name lookup.
9426 /// Member name lookup, which finds the names of
9427 /// class/struct/union members.
9429 /// Look up of an operator name (e.g., operator+) for use with
9430 /// operator overloading. This lookup is similar to ordinary name
9431 /// lookup, but will ignore any declarations that are class members.
9433 /// Look up a name following ~ in a destructor name. This is an ordinary
9434 /// lookup, but prefers tags to typedefs.
9436 /// Look up of a name that precedes the '::' scope resolution
9437 /// operator in C++. This lookup completely ignores operator, object,
9438 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9440 /// Look up a namespace name within a C++ using directive or
9441 /// namespace alias definition, ignoring non-namespace names (C++
9442 /// [basic.lookup.udir]p1).
9444 /// Look up all declarations in a scope with the given name,
9445 /// including resolved using declarations. This is appropriate
9446 /// for checking redeclarations for a using declaration.
9448 /// Look up an ordinary name that is going to be redeclared as a
9449 /// name with linkage. This lookup ignores any declarations that
9450 /// are outside of the current scope unless they have linkage. See
9451 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9453 /// Look up a friend of a local class. This lookup does not look
9454 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9456 /// Look up the name of an Objective-C protocol.
9458 /// Look up implicit 'self' parameter of an objective-c method.
9460 /// Look up the name of an OpenMP user-defined reduction operation.
9462 /// Look up the name of an OpenMP user-defined mapper.
9464 /// Look up any declaration with any name.
9466 };
9467
9468 /// The possible outcomes of name lookup for a literal operator.
9470 /// The lookup resulted in an error.
9472 /// The lookup found no match but no diagnostic was issued.
9474 /// The lookup found a single 'cooked' literal operator, which
9475 /// expects a normal literal to be built and passed to it.
9477 /// The lookup found a single 'raw' literal operator, which expects
9478 /// a string literal containing the spelling of the literal token.
9480 /// The lookup found an overload set of literal operator templates,
9481 /// which expect the characters of the spelling of the literal token to be
9482 /// passed as a non-type template argument pack.
9484 /// The lookup found an overload set of literal operator templates,
9485 /// which expect the character type and characters of the spelling of the
9486 /// string literal token to be passed as template arguments.
9488 };
9489
9490 SpecialMemberOverloadResult
9492 bool VolatileArg, bool RValueThis, bool ConstThis,
9493 bool VolatileThis);
9494
9496
9497 /// Look up a name, looking for a single declaration. Return
9498 /// null if the results were absent, ambiguous, or overloaded.
9499 ///
9500 /// It is preferable to use the elaborated form and explicitly handle
9501 /// ambiguity and overloaded.
9503 Scope *S, DeclarationName Name, SourceLocation Loc,
9504 LookupNameKind NameKind,
9506
9507 /// Lookup a builtin function, when name lookup would otherwise
9508 /// fail.
9509 bool LookupBuiltin(LookupResult &R);
9510 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9511
9512 /// Perform unqualified name lookup starting from a given
9513 /// scope.
9514 ///
9515 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9516 /// used to find names within the current scope. For example, 'x' in
9517 /// @code
9518 /// int x;
9519 /// int f() {
9520 /// return x; // unqualified name look finds 'x' in the global scope
9521 /// }
9522 /// @endcode
9523 ///
9524 /// Different lookup criteria can find different names. For example, a
9525 /// particular scope can have both a struct and a function of the same
9526 /// name, and each can be found by certain lookup criteria. For more
9527 /// information about lookup criteria, see the documentation for the
9528 /// class LookupCriteria.
9529 ///
9530 /// @param S The scope from which unqualified name lookup will
9531 /// begin. If the lookup criteria permits, name lookup may also search
9532 /// in the parent scopes.
9533 ///
9534 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9535 /// look up and the lookup kind), and is updated with the results of lookup
9536 /// including zero or more declarations and possibly additional information
9537 /// used to diagnose ambiguities.
9538 ///
9539 /// @returns \c true if lookup succeeded and false otherwise.
9540 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9541 bool ForceNoCPlusPlus = false);
9542
9543 /// Perform qualified name lookup into a given context.
9544 ///
9545 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9546 /// names when the context of those names is explicit specified, e.g.,
9547 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9548 ///
9549 /// Different lookup criteria can find different names. For example, a
9550 /// particular scope can have both a struct and a function of the same
9551 /// name, and each can be found by certain lookup criteria. For more
9552 /// information about lookup criteria, see the documentation for the
9553 /// class LookupCriteria.
9554 ///
9555 /// \param R captures both the lookup criteria and any lookup results found.
9556 ///
9557 /// \param LookupCtx The context in which qualified name lookup will
9558 /// search. If the lookup criteria permits, name lookup may also search
9559 /// in the parent contexts or (for C++ classes) base classes.
9560 ///
9561 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9562 /// occurs as part of unqualified name lookup.
9563 ///
9564 /// \returns true if lookup succeeded, false if it failed.
9565 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9566 bool InUnqualifiedLookup = false);
9567
9568 /// Performs qualified name lookup or special type of lookup for
9569 /// "__super::" scope specifier.
9570 ///
9571 /// This routine is a convenience overload meant to be called from contexts
9572 /// that need to perform a qualified name lookup with an optional C++ scope
9573 /// specifier that might require special kind of lookup.
9574 ///
9575 /// \param R captures both the lookup criteria and any lookup results found.
9576 ///
9577 /// \param LookupCtx The context in which qualified name lookup will
9578 /// search.
9579 ///
9580 /// \param SS An optional C++ scope-specifier.
9581 ///
9582 /// \returns true if lookup succeeded, false if it failed.
9583 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9584 CXXScopeSpec &SS);
9585
9586 /// Performs name lookup for a name that was parsed in the
9587 /// source code, and may contain a C++ scope specifier.
9588 ///
9589 /// This routine is a convenience routine meant to be called from
9590 /// contexts that receive a name and an optional C++ scope specifier
9591 /// (e.g., "N::M::x"). It will then perform either qualified or
9592 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9593 /// respectively) on the given name and return those results. It will
9594 /// perform a special type of lookup for "__super::" scope specifier.
9595 ///
9596 /// @param S The scope from which unqualified name lookup will
9597 /// begin.
9598 ///
9599 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9600 ///
9601 /// @param EnteringContext Indicates whether we are going to enter the
9602 /// context of the scope-specifier SS (if present).
9603 ///
9604 /// @returns True if any decls were found (but possibly ambiguous)
9606 QualType ObjectType, bool AllowBuiltinCreation = false,
9607 bool EnteringContext = false);
9608
9609 /// Perform qualified name lookup into all base classes of the given
9610 /// class.
9611 ///
9612 /// \param R captures both the lookup criteria and any lookup results found.
9613 ///
9614 /// \param Class The context in which qualified name lookup will
9615 /// search. Name lookup will search in all base classes merging the results.
9616 ///
9617 /// @returns True if any decls were found (but possibly ambiguous)
9619
9621 UnresolvedSetImpl &Functions);
9622
9623 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9624 /// If GnuLabelLoc is a valid source location, then this is a definition
9625 /// of an __label__ label name, otherwise it is a normal label definition
9626 /// or use.
9628 SourceLocation GnuLabelLoc = SourceLocation());
9629
9630 /// Perform a name lookup for a label with the specified name; this does not
9631 /// create a new label if the lookup fails.
9633
9634 /// Look up the constructors for the given class.
9636
9637 /// Look up the default constructor for the given class.
9639
9640 /// Look up the copying constructor for the given class.
9642 unsigned Quals);
9643
9644 /// Look up the copying assignment operator for the given class.
9646 bool RValueThis, unsigned ThisQuals);
9647
9648 /// Look up the moving constructor for the given class.
9650 unsigned Quals);
9651
9652 /// Look up the moving assignment operator for the given class.
9654 bool RValueThis, unsigned ThisQuals);
9655
9656 /// Look for the destructor of the given class.
9657 ///
9658 /// During semantic analysis, this routine should be used in lieu of
9659 /// CXXRecordDecl::getDestructor().
9660 ///
9661 /// \returns The destructor for this class.
9663
9664 /// Force the declaration of any implicitly-declared members of this
9665 /// class.
9667
9668 /// Make a merged definition of an existing hidden definition \p ND
9669 /// visible at the specified location.
9671
9672 /// Check ODR hashes for C/ObjC when merging types from modules.
9673 /// Differently from C++, actually parse the body and reject in case
9674 /// of a mismatch.
9675 template <typename T,
9676 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9678 if (Duplicate->getODRHash() != Previous->getODRHash())
9679 return false;
9680
9681 // Make the previous decl visible.
9683 return true;
9684 }
9685
9686 /// Get the set of additional modules that should be checked during
9687 /// name lookup. A module and its imports become visible when instanting a
9688 /// template defined within it.
9689 llvm::DenseSet<Module *> &getLookupModules();
9690
9691 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9693
9694 /// Determine if the template parameter \p D has a visible default argument.
9695 bool
9697 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9698 /// Determine if the template parameter \p D has a reachable default argument.
9700 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9701 /// Determine if the template parameter \p D has a reachable default argument.
9705
9706 /// Determine if there is a visible declaration of \p D that is an explicit
9707 /// specialization declaration for a specialization of a template. (For a
9708 /// member specialization, use hasVisibleMemberSpecialization.)
9710 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9711 /// Determine if there is a reachable declaration of \p D that is an explicit
9712 /// specialization declaration for a specialization of a template. (For a
9713 /// member specialization, use hasReachableMemberSpecialization.)
9715 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9716
9717 /// Determine if there is a visible declaration of \p D that is a member
9718 /// specialization declaration (as opposed to an instantiated declaration).
9720 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9721 /// Determine if there is a reachable declaration of \p D that is a member
9722 /// specialization declaration (as opposed to an instantiated declaration).
9724 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9725
9726 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9727
9728 /// Determine whether any declaration of an entity is visible.
9729 bool
9731 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9732 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9733 }
9734
9737 /// Determine whether any declaration of an entity is reachable.
9738 bool
9740 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9741 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9742 }
9744 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9745
9746 void diagnoseTypo(const TypoCorrection &Correction,
9747 const PartialDiagnostic &TypoDiag,
9748 bool ErrorRecovery = true);
9749
9750 /// Diagnose a successfully-corrected typo. Separated from the correction
9751 /// itself to allow external validation of the result, etc.
9752 ///
9753 /// \param Correction The result of performing typo correction.
9754 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9755 /// string added to it (and usually also a fixit).
9756 /// \param PrevNote A note to use when indicating the location of the entity
9757 /// to which we are correcting. Will have the correction string added
9758 /// to it.
9759 /// \param ErrorRecovery If \c true (the default), the caller is going to
9760 /// recover from the typo as if the corrected string had been typed.
9761 /// In this case, \c PDiag must be an error, and we will attach a fixit
9762 /// to it.
9763 void diagnoseTypo(const TypoCorrection &Correction,
9764 const PartialDiagnostic &TypoDiag,
9765 const PartialDiagnostic &PrevNote,
9766 bool ErrorRecovery = true);
9767
9768 /// Find the associated classes and namespaces for
9769 /// argument-dependent lookup for a call with the given set of
9770 /// arguments.
9771 ///
9772 /// This routine computes the sets of associated classes and associated
9773 /// namespaces searched by argument-dependent lookup
9774 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9776 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9777 AssociatedNamespaceSet &AssociatedNamespaces,
9778 AssociatedClassSet &AssociatedClasses);
9779
9780 /// Produce a diagnostic describing the ambiguity that resulted
9781 /// from name lookup.
9782 ///
9783 /// \param Result The result of the ambiguous lookup to be diagnosed.
9785
9786 /// LookupLiteralOperator - Determine which literal operator should be used
9787 /// for a user-defined literal, per C++11 [lex.ext].
9788 ///
9789 /// Normal overload resolution is not used to select which literal operator to
9790 /// call for a user-defined literal. Look up the provided literal operator
9791 /// name, and filter the results to the appropriate set for the given argument
9792 /// types.
9795 bool AllowRaw, bool AllowTemplate,
9796 bool AllowStringTemplate, bool DiagnoseMissing,
9797 StringLiteral *StringLit = nullptr);
9798
9800 ArrayRef<Expr *> Args, ADLResult &Functions);
9801
9802 void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
9804 bool IncludeGlobalScope = true,
9805 bool LoadExternal = true);
9806 void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
9808 bool IncludeGlobalScope = true,
9809 bool IncludeDependentBases = false,
9810 bool LoadExternal = true);
9811
9812 /// Try to "correct" a typo in the source code by finding
9813 /// visible declarations whose names are similar to the name that was
9814 /// present in the source code.
9815 ///
9816 /// \param TypoName the \c DeclarationNameInfo structure that contains
9817 /// the name that was present in the source code along with its location.
9818 ///
9819 /// \param LookupKind the name-lookup criteria used to search for the name.
9820 ///
9821 /// \param S the scope in which name lookup occurs.
9822 ///
9823 /// \param SS the nested-name-specifier that precedes the name we're
9824 /// looking for, if present.
9825 ///
9826 /// \param CCC A CorrectionCandidateCallback object that provides further
9827 /// validation of typo correction candidates. It also provides flags for
9828 /// determining the set of keywords permitted.
9829 ///
9830 /// \param MemberContext if non-NULL, the context in which to look for
9831 /// a member access expression.
9832 ///
9833 /// \param EnteringContext whether we're entering the context described by
9834 /// the nested-name-specifier SS.
9835 ///
9836 /// \param OPT when non-NULL, the search for visible declarations will
9837 /// also walk the protocols in the qualified interfaces of \p OPT.
9838 ///
9839 /// \returns a \c TypoCorrection containing the corrected name if the typo
9840 /// along with information such as the \c NamedDecl where the corrected name
9841 /// was declared, and any additional \c NestedNameSpecifier needed to access
9842 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9844 Sema::LookupNameKind LookupKind, Scope *S,
9846 CorrectTypoKind Mode,
9847 DeclContext *MemberContext = nullptr,
9848 bool EnteringContext = false,
9849 const ObjCObjectPointerType *OPT = nullptr,
9850 bool RecordFailure = true);
9851
9852 /// Kinds of missing import. Note, the values of these enumerators correspond
9853 /// to %select values in diagnostics.
9861
9862 /// Diagnose that the specified declaration needs to be visible but
9863 /// isn't, and suggest a module import that would resolve the problem.
9865 MissingImportKind MIK, bool Recover = true);
9867 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9868 MissingImportKind MIK, bool Recover);
9869
9870 /// Called on #pragma clang __debug dump II
9872
9873 /// Called on #pragma clang __debug dump E
9874 void ActOnPragmaDump(Expr *E);
9875
9876private:
9877 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9878 //
9879 // The boolean value will be true to indicate that the namespace was loaded
9880 // from an AST/PCH file, or false otherwise.
9881 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9882
9883 /// Whether we have already loaded known namespaces from an extenal
9884 /// source.
9885 bool LoadedExternalKnownNamespaces;
9886
9887 bool CppLookupName(LookupResult &R, Scope *S);
9888
9889 /// Determine if we could use all the declarations in the module.
9890 bool isUsableModule(const Module *M);
9891
9892 /// Helper for CorrectTypo used to create and populate a new
9893 /// TypoCorrectionConsumer. Returns nullptr if typo correction should be
9894 /// skipped entirely.
9895 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9896 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9898 DeclContext *MemberContext, bool EnteringContext,
9899 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9900
9901 /// Cache for module units which is usable for current module.
9902 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9903
9904 /// Record the typo correction failure and return an empty correction.
9905 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9906 bool RecordFailure = true) {
9907 if (RecordFailure)
9908 TypoCorrectionFailures[Typo].insert(TypoLoc);
9909 return TypoCorrection();
9910 }
9911
9912 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9913
9914 /// Determine whether two declarations should be linked together, given that
9915 /// the old declaration might not be visible and the new declaration might
9916 /// not have external linkage.
9917 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9918 const NamedDecl *New) {
9919 if (isVisible(Old))
9920 return true;
9921 // See comment in below overload for why it's safe to compute the linkage
9922 // of the new declaration here.
9923 if (New->isExternallyDeclarable()) {
9924 assert(Old->isExternallyDeclarable() &&
9925 "should not have found a non-externally-declarable previous decl");
9926 return true;
9927 }
9928 return false;
9929 }
9930 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9931
9932 ///@}
9933
9934 //
9935 //
9936 // -------------------------------------------------------------------------
9937 //
9938 //
9939
9940 /// \name Modules
9941 /// Implementations are in SemaModule.cpp
9942 ///@{
9943
9944public:
9945 /// Get the module unit whose scope we are currently within.
9947 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9948 }
9949
9950 /// Is the module scope we are an implementation unit?
9952 if (ModuleScopes.empty())
9953 return false;
9954 const Module *M = ModuleScopes.back().Module;
9956 }
9957
9958 // When loading a non-modular PCH files, this is used to restore module
9959 // visibility.
9961 VisibleModules.setVisible(Mod, ImportLoc);
9962 }
9963
9964 enum class ModuleDeclKind {
9965 Interface, ///< 'export module X;'
9966 Implementation, ///< 'module X;'
9967 PartitionInterface, ///< 'export module X:Y;'
9968 PartitionImplementation, ///< 'module X:Y;'
9969 };
9970
9971 /// An enumeration to represent the transition of states in parsing module
9972 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9973 /// an error in state transition, the state is set to NotACXX20Module.
9975 FirstDecl, ///< Parsing the first decl in a TU.
9976 GlobalFragment, ///< after 'module;' but before 'module X;'
9977 ImportAllowed, ///< after 'module X;' but before any non-import decl.
9978 ImportFinished, ///< after any non-import decl.
9979 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
9980 ///< non-import decl.
9981 PrivateFragmentImportFinished, ///< after 'module :private;' but a
9982 ///< non-import decl has already been seen.
9983 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
9984 };
9985
9986 /// The parser has processed a module-declaration that begins the definition
9987 /// of a module interface or implementation.
9989 SourceLocation ModuleLoc, ModuleDeclKind MDK,
9990 ModuleIdPath Path, ModuleIdPath Partition,
9991 ModuleImportState &ImportState,
9992 bool SeenNoTrivialPPDirective);
9993
9994 /// The parser has processed a global-module-fragment declaration that begins
9995 /// the definition of the global module fragment of the current module unit.
9996 /// \param ModuleLoc The location of the 'module' keyword.
9998
9999 /// The parser has processed a private-module-fragment declaration that begins
10000 /// the definition of the private module fragment of the current module unit.
10001 /// \param ModuleLoc The location of the 'module' keyword.
10002 /// \param PrivateLoc The location of the 'private' keyword.
10004 SourceLocation PrivateLoc);
10005
10006 /// The parser has processed a module import declaration.
10007 ///
10008 /// \param StartLoc The location of the first token in the declaration. This
10009 /// could be the location of an '@', 'export', or 'import'.
10010 /// \param ExportLoc The location of the 'export' keyword, if any.
10011 /// \param ImportLoc The location of the 'import' keyword.
10012 /// \param Path The module toplevel name as an access path.
10013 /// \param IsPartition If the name is for a partition.
10015 SourceLocation ExportLoc,
10016 SourceLocation ImportLoc, ModuleIdPath Path,
10017 bool IsPartition = false);
10019 SourceLocation ExportLoc,
10020 SourceLocation ImportLoc, Module *M,
10021 ModuleIdPath Path = {});
10022
10023 /// The parser has processed a module import translated from a
10024 /// #include or similar preprocessing directive.
10025 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
10026 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
10027
10028 /// The parsed has entered a submodule.
10029 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
10030 /// The parser has left a submodule.
10031 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
10032
10033 /// Create an implicit import of the given module at the given
10034 /// source location, for error recovery, if possible.
10035 ///
10036 /// This routine is typically used when an entity found by name lookup
10037 /// is actually hidden within a module that we know about but the user
10038 /// has forgotten to import.
10039 void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
10040 Module *Mod);
10041
10042 /// We have parsed the start of an export declaration, including the '{'
10043 /// (if present).
10044 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
10045 SourceLocation LBraceLoc);
10046
10047 /// Complete the definition of an export declaration.
10048 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
10049 SourceLocation RBraceLoc);
10050
10051private:
10052 /// The parser has begun a translation unit to be compiled as a C++20
10053 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
10054 void HandleStartOfHeaderUnit();
10055
10056 struct ModuleScope {
10057 SourceLocation BeginLoc;
10058 clang::Module *Module = nullptr;
10059 VisibleModuleSet OuterVisibleModules;
10060 };
10061 /// The modules we're currently parsing.
10062 llvm::SmallVector<ModuleScope, 16> ModuleScopes;
10063
10064 /// For an interface unit, this is the implicitly imported interface unit.
10065 clang::Module *ThePrimaryInterface = nullptr;
10066
10067 /// The explicit global module fragment of the current translation unit.
10068 /// The explicit Global Module Fragment, as specified in C++
10069 /// [module.global.frag].
10070 clang::Module *TheGlobalModuleFragment = nullptr;
10071
10072 /// The implicit global module fragments of the current translation unit.
10073 ///
10074 /// The contents in the implicit global module fragment can't be discarded.
10075 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
10076
10077 /// Namespace definitions that we will export when they finish.
10078 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
10079
10080 /// In a C++ standard module, inline declarations require a definition to be
10081 /// present at the end of a definition domain. This set holds the decls to
10082 /// be checked at the end of the TU.
10083 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
10084
10085 /// Helper function to judge if we are in module purview.
10086 /// Return false if we are not in a module.
10087 bool isCurrentModulePurview() const;
10088
10089 /// Enter the scope of the explicit global module fragment.
10090 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
10091 /// Leave the scope of the explicit global module fragment.
10092 void PopGlobalModuleFragment();
10093
10094 /// Enter the scope of an implicit global module fragment.
10095 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
10096 /// Leave the scope of an implicit global module fragment.
10097 void PopImplicitGlobalModuleFragment();
10098
10099 VisibleModuleSet VisibleModules;
10100
10101 /// Whether we had imported any named modules.
10102 bool HadImportedNamedModules = false;
10103 /// The set of instantiations we need to check if they references TU-local
10104 /// entity from TUs. This only makes sense if we imported any named modules.
10105 llvm::SmallVector<std::pair<FunctionDecl *, SourceLocation>>
10106 PendingCheckReferenceForTULocal;
10107 /// Implement [basic.link]p18, which requires that we can't use TU-local
10108 /// entities from other TUs (ignoring header units).
10109 void checkReferenceToTULocalFromOtherTU(FunctionDecl *FD,
10110 SourceLocation PointOfInstantiation);
10111 /// Implement [basic.link]p17, which diagnose for non TU local exposure in
10112 /// module interface or module partition.
10113 void checkExposure(const TranslationUnitDecl *TU);
10114
10115 ///@}
10116
10117 //
10118 //
10119 // -------------------------------------------------------------------------
10120 //
10121 //
10122
10123 /// \name C++ Overloading
10124 /// Implementations are in SemaOverload.cpp
10125 ///@{
10126
10127public:
10128 /// Whether deferrable diagnostics should be deferred.
10129 bool DeferDiags = false;
10130
10131 /// RAII class to control scope of DeferDiags.
10133 Sema &S;
10134 bool SavedDeferDiags = false;
10135
10136 public:
10138 : S(S), SavedDeferDiags(S.DeferDiags) {
10139 S.DeferDiags = SavedDeferDiags || DeferDiags;
10140 }
10141 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
10144 };
10145
10146 /// Flag indicating if Sema is building a recovery call expression.
10147 ///
10148 /// This flag is used to avoid building recovery call expressions
10149 /// if Sema is already doing so, which would cause infinite recursions.
10151
10152 /// Determine whether the given New declaration is an overload of the
10153 /// declarations in Old. This routine returns OverloadKind::Match or
10154 /// OverloadKind::NonFunction if New and Old cannot be overloaded, e.g., if
10155 /// New has the same signature as some function in Old (C++ 1.3.10) or if the
10156 /// Old declarations aren't functions (or function templates) at all. When it
10157 /// does return OverloadKind::Match or OverloadKind::NonFunction, MatchedDecl
10158 /// will point to the decl that New cannot be overloaded with. This decl may
10159 /// be a UsingShadowDecl on top of the underlying declaration.
10160 ///
10161 /// Example: Given the following input:
10162 ///
10163 /// void f(int, float); // #1
10164 /// void f(int, int); // #2
10165 /// int f(int, int); // #3
10166 ///
10167 /// When we process #1, there is no previous declaration of "f", so IsOverload
10168 /// will not be used.
10169 ///
10170 /// When we process #2, Old contains only the FunctionDecl for #1. By
10171 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
10172 /// they have different signatures), so this routine returns
10173 /// OverloadKind::Overload; MatchedDecl is unchanged.
10174 ///
10175 /// When we process #3, Old is an overload set containing #1 and #2. We
10176 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
10177 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
10178 /// types of functions are not part of the signature), IsOverload returns
10179 /// OverloadKind::Match and MatchedDecl will be set to point to the
10180 /// FunctionDecl for #2.
10181 ///
10182 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
10183 /// class by a using declaration. The rules for whether to hide shadow
10184 /// declarations ignore some properties which otherwise figure into a function
10185 /// template's signature.
10187 const LookupResult &OldDecls, NamedDecl *&OldDecl,
10188 bool UseMemberUsingDeclRules);
10190 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10191
10192 // Checks whether MD constitutes an override the base class method BaseMD.
10193 // When checking for overrides, the object object members are ignored.
10194 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
10195 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10196
10197 enum class AllowedExplicit {
10198 /// Allow no explicit functions to be used.
10200 /// Allow explicit conversion functions but not explicit constructors.
10202 /// Allow both explicit conversion functions and explicit constructors.
10204 };
10205
10207 Expr *From, QualType ToType, bool SuppressUserConversions,
10208 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
10209 bool AllowObjCWritebackConversion);
10210
10211 /// PerformImplicitConversion - Perform an implicit conversion of the
10212 /// expression From to the type ToType. Returns the
10213 /// converted expression. Flavor is the kind of conversion we're
10214 /// performing, used in the error message. If @p AllowExplicit,
10215 /// explicit user-defined conversions are permitted.
10217 AssignmentAction Action,
10218 bool AllowExplicit = false);
10219
10220 /// IsIntegralPromotion - Determines whether the conversion from the
10221 /// expression From (whose potentially-adjusted type is FromType) to
10222 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
10223 /// sets PromotedType to the promoted type.
10224 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
10225
10226 /// IsFloatingPointPromotion - Determines whether the conversion from
10227 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
10228 /// returns true and sets PromotedType to the promoted type.
10229 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
10230
10231 /// Determine if a conversion is a complex promotion.
10232 ///
10233 /// A complex promotion is defined as a complex -> complex conversion
10234 /// where the conversion between the underlying real types is a
10235 /// floating-point or integral promotion.
10236 bool IsComplexPromotion(QualType FromType, QualType ToType);
10237
10238 /// IsOverflowBehaviorTypePromotion - Determines whether the conversion from
10239 /// FromType to ToType involves an OverflowBehaviorType FromType being
10240 /// promoted to an OverflowBehaviorType ToType which has a larger bitwidth.
10241 /// If so, returns true and sets FromType to ToType.
10242 bool IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType);
10243
10244 /// IsOverflowBehaviorTypeConversion - Determines whether the conversion from
10245 /// FromType to ToType necessarily involves both an OverflowBehaviorType and
10246 /// a non-OverflowBehaviorType. If so, returns true and sets FromType to
10247 /// ToType.
10248 bool IsOverflowBehaviorTypeConversion(QualType FromType, QualType ToType);
10249
10250 /// IsPointerConversion - Determines whether the conversion of the
10251 /// expression From, which has the (possibly adjusted) type FromType,
10252 /// can be converted to the type ToType via a pointer conversion (C++
10253 /// 4.10). If so, returns true and places the converted type (that
10254 /// might differ from ToType in its cv-qualifiers at some level) into
10255 /// ConvertedType.
10256 ///
10257 /// This routine also supports conversions to and from block pointers
10258 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
10259 /// pointers to interfaces. FIXME: Once we've determined the
10260 /// appropriate overloading rules for Objective-C, we may want to
10261 /// split the Objective-C checks into a different routine; however,
10262 /// GCC seems to consider all of these conversions to be pointer
10263 /// conversions, so for now they live here. IncompatibleObjC will be
10264 /// set if the conversion is an allowed Objective-C conversion that
10265 /// should result in a warning.
10266 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
10267 bool InOverloadResolution, QualType &ConvertedType,
10268 bool &IncompatibleObjC);
10269
10270 /// isObjCPointerConversion - Determines whether this is an
10271 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
10272 /// with the same arguments and return values.
10273 bool isObjCPointerConversion(QualType FromType, QualType ToType,
10274 QualType &ConvertedType, bool &IncompatibleObjC);
10275 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
10276 QualType &ConvertedType);
10277
10278 /// FunctionParamTypesAreEqual - This routine checks two function proto types
10279 /// for equality of their parameter types. Caller has already checked that
10280 /// they have same number of parameters. If the parameters are different,
10281 /// ArgPos will have the parameter index of the first different parameter.
10282 /// If `Reversed` is true, the parameters of `NewType` will be compared in
10283 /// reverse order. That's useful if one of the functions is being used as a
10284 /// C++20 synthesized operator overload with a reversed parameter order.
10287 unsigned *ArgPos = nullptr,
10288 bool Reversed = false);
10289
10291 const FunctionProtoType *NewType,
10292 unsigned *ArgPos = nullptr,
10293 bool Reversed = false);
10294
10295 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
10296 const FunctionDecl *NewFunction,
10297 unsigned *ArgPos = nullptr,
10298 bool Reversed = false);
10299
10300 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
10301 /// function types. Catches different number of parameter, mismatch in
10302 /// parameter types, and different return types.
10304 QualType ToType);
10305
10306 /// CheckPointerConversion - Check the pointer conversion from the
10307 /// expression From to the type ToType. This routine checks for
10308 /// ambiguous or inaccessible derived-to-base pointer
10309 /// conversions for which IsPointerConversion has already returned
10310 /// true. It returns true and produces a diagnostic if there was an
10311 /// error, or returns false otherwise.
10312 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
10313 CXXCastPath &BasePath, bool IgnoreBaseAccess,
10314 bool Diagnose = true);
10315
10316 /// IsMemberPointerConversion - Determines whether the conversion of the
10317 /// expression From, which has the (possibly adjusted) type FromType, can be
10318 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
10319 /// If so, returns true and places the converted type (that might differ from
10320 /// ToType in its cv-qualifiers at some level) into ConvertedType.
10321 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
10322 bool InOverloadResolution,
10323 QualType &ConvertedType);
10324
10334 /// CheckMemberPointerConversion - Check the member pointer conversion from
10335 /// the expression From to the type ToType. This routine checks for ambiguous
10336 /// or virtual or inaccessible base-to-derived member pointer conversions for
10337 /// which IsMemberPointerConversion has already returned true. It produces a
10338 // diagnostic if there was an error.
10340 QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind,
10341 CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange,
10342 bool IgnoreBaseAccess, MemberPointerConversionDirection Direction);
10343
10344 /// IsQualificationConversion - Determines whether the conversion from
10345 /// an rvalue of type FromType to ToType is a qualification conversion
10346 /// (C++ 4.4).
10347 ///
10348 /// \param ObjCLifetimeConversion Output parameter that will be set to
10349 /// indicate when the qualification conversion involves a change in the
10350 /// Objective-C object lifetime.
10351 bool IsQualificationConversion(QualType FromType, QualType ToType,
10352 bool CStyle, bool &ObjCLifetimeConversion);
10353
10354 /// Determine whether the conversion from FromType to ToType is a valid
10355 /// conversion of ExtInfo/ExtProtoInfo on the nested function type.
10356 /// More precisely, this method checks whether FromType can be transformed
10357 /// into an exact match for ToType, by transforming its extended function
10358 /// type information in legal manner (e.g. by strictly stripping "noreturn"
10359 /// or "noexcept", or by stripping "noescape" for arguments).
10360 bool IsFunctionConversion(QualType FromType, QualType ToType) const;
10361
10362 /// Same as `IsFunctionConversion`, but if this would return true, it sets
10363 /// `ResultTy` to `ToType`.
10364 bool TryFunctionConversion(QualType FromType, QualType ToType,
10365 QualType &ResultTy) const;
10366
10369 DeclarationName Name,
10370 OverloadCandidateSet &CandidateSet,
10371 FunctionDecl *Fn, MultiExprArg Args,
10372 bool IsMember = false);
10373
10375 FunctionDecl *Fun);
10377 Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl,
10379
10380 /// PerformContextuallyConvertToBool - Perform a contextual conversion
10381 /// of the expression From to bool (C++0x [conv]p3).
10383
10384 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
10385 /// conversion of the expression From to an Objective-C pointer type.
10386 /// Returns a valid but null ExprResult if no conversion sequence exists.
10388
10390 CCEKind CCE,
10391 NamedDecl *Dest = nullptr);
10392
10394 llvm::APSInt &Value, CCEKind CCE);
10396 APValue &Value, CCEKind CCE,
10397 NamedDecl *Dest = nullptr);
10398
10399 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10400 /// That is a converted constant expression
10401 /// (which was built with BuildConvertedConstantExpression)
10404 CCEKind CCE, bool RequireInt,
10405 const APValue &PreNarrowingValue);
10406
10407 /// Abstract base class used to perform a contextual implicit
10408 /// conversion from an expression to any type passing a filter.
10410 public:
10413
10417
10418 /// Determine whether the specified type is a valid destination type
10419 /// for this conversion.
10420 virtual bool match(QualType T) = 0;
10421
10422 /// Emits a diagnostic complaining that the expression does not have
10423 /// integral or enumeration type.
10425 QualType T) = 0;
10426
10427 /// Emits a diagnostic when the expression has incomplete class type.
10428 virtual SemaDiagnosticBuilder
10430
10431 /// Emits a diagnostic when the only matching conversion function
10432 /// is explicit.
10434 SourceLocation Loc,
10435 QualType T,
10436 QualType ConvTy) = 0;
10437
10438 /// Emits a note for the explicit conversion function.
10439 virtual SemaDiagnosticBuilder
10441
10442 /// Emits a diagnostic when there are multiple possible conversion
10443 /// functions.
10445 QualType T) = 0;
10446
10447 /// Emits a note for one of the candidate conversions.
10448 virtual SemaDiagnosticBuilder
10450
10451 /// Emits a diagnostic when we picked a conversion function
10452 /// (for cases when we are not allowed to pick a conversion function).
10454 SourceLocation Loc,
10455 QualType T,
10456 QualType ConvTy) = 0;
10457
10459 };
10460
10462 bool AllowScopedEnumerations;
10463
10464 public:
10465 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10466 bool SuppressConversion)
10468 AllowScopedEnumerations(AllowScopedEnumerations) {}
10469
10470 /// Match an integral or (possibly scoped) enumeration type.
10471 bool match(QualType T) override;
10472
10474 QualType T) override {
10475 return diagnoseNotInt(S, Loc, T);
10476 }
10477
10478 /// Emits a diagnostic complaining that the expression does not have
10479 /// integral or enumeration type.
10481 QualType T) = 0;
10482 };
10483
10484 /// Perform a contextual implicit conversion.
10487 ContextualImplicitConverter &Converter);
10488
10489 /// ReferenceCompareResult - Expresses the result of comparing two
10490 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10491 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10493 /// Ref_Incompatible - The two types are incompatible, so direct
10494 /// reference binding is not possible.
10496 /// Ref_Related - The two types are reference-related, which means
10497 /// that their unqualified forms (T1 and T2) are either the same
10498 /// or T1 is a base class of T2.
10500 /// Ref_Compatible - The two types are reference-compatible.
10502 };
10503
10504 // Fake up a scoped enumeration that still contextually converts to bool.
10506 /// The conversions that would be performed on an lvalue of type T2 when
10507 /// binding a reference of type T1 to it, as determined when evaluating
10508 /// whether T1 is reference-compatible with T2.
10519 };
10521
10522 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10523 /// determine whether they are reference-compatible,
10524 /// reference-related, or incompatible, for use in C++ initialization by
10525 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10526 /// type, and the first type (T1) is the pointee type of the reference
10527 /// type being initialized.
10530 ReferenceConversions *Conv = nullptr);
10531
10532 /// AddOverloadCandidate - Adds the given function to the set of
10533 /// candidate functions, using the given function call arguments. If
10534 /// @p SuppressUserConversions, then don't allow user-defined
10535 /// conversions via constructors or conversion operators.
10536 ///
10537 /// \param PartialOverloading true if we are performing "partial" overloading
10538 /// based on an incomplete set of function arguments. This feature is used by
10539 /// code completion.
10542 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10543 bool PartialOverloading = false, bool AllowExplicit = true,
10544 bool AllowExplicitConversion = false,
10545 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10546 ConversionSequenceList EarlyConversions = {},
10548 bool AggregateCandidateDeduction = false, bool StrictPackMatch = false);
10549
10550 /// Add all of the function declarations in the given function set to
10551 /// the overload candidate set.
10553 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10554 OverloadCandidateSet &CandidateSet,
10555 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10556 bool SuppressUserConversions = false, bool PartialOverloading = false,
10557 bool FirstArgumentIsBase = false);
10558
10559 /// AddMethodCandidate - Adds a named decl (which is some kind of
10560 /// method) as a method candidate to the given overload set.
10561 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10562 Expr::Classification ObjectClassification,
10563 ArrayRef<Expr *> Args,
10564 OverloadCandidateSet &CandidateSet,
10565 bool SuppressUserConversion = false,
10566 OverloadCandidateParamOrder PO = {});
10567
10568 /// AddMethodCandidate - Adds the given C++ member function to the set
10569 /// of candidate functions, using the given function call arguments
10570 /// and the object argument (@c Object). For example, in a call
10571 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10572 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10573 /// allow user-defined conversions via constructors or conversion
10574 /// operators.
10575 void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10576 CXXRecordDecl *ActingContext, QualType ObjectType,
10577 Expr::Classification ObjectClassification,
10578 ArrayRef<Expr *> Args,
10579 OverloadCandidateSet &CandidateSet,
10580 bool SuppressUserConversions = false,
10581 bool PartialOverloading = false,
10582 ConversionSequenceList EarlyConversions = {},
10584 bool StrictPackMatch = false);
10585
10586 /// Add a C++ member function template as a candidate to the candidate
10587 /// set, using template argument deduction to produce an appropriate member
10588 /// function template specialization.
10590 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10591 CXXRecordDecl *ActingContext,
10592 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10593 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10594 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10595 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10596
10597 /// Add a C++ function template specialization as a candidate
10598 /// in the candidate set, using template argument deduction to produce
10599 /// an appropriate function template specialization.
10601 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10602 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10603 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10604 bool PartialOverloading = false, bool AllowExplicit = true,
10605 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10607 bool AggregateCandidateDeduction = false);
10608
10610 /// Do not consider any user-defined conversions when constructing the
10611 /// initializing sequence.
10613
10614 /// Before constructing the initializing sequence, we check whether the
10615 /// parameter type and argument type contain any user defined conversions.
10616 /// If so, do not initialize them. This effectively bypasses some undesired
10617 /// instantiation before checking constaints, which might otherwise result
10618 /// in non-SFINAE errors e.g. recursive constraints.
10620
10627 };
10628
10629 /// Check that implicit conversion sequences can be formed for each argument
10630 /// whose corresponding parameter has a non-dependent type, per DR1391's
10631 /// [temp.deduct.call]p10.
10634 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10636 CheckNonDependentConversionsFlag UserConversionFlag,
10637 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10638 Expr::Classification ObjectClassification = {},
10639 OverloadCandidateParamOrder PO = {});
10640
10641 /// AddConversionCandidate - Add a C++ conversion function as a
10642 /// candidate in the candidate set (C++ [over.match.conv],
10643 /// C++ [over.match.copy]). From is the expression we're converting from,
10644 /// and ToType is the type that we're eventually trying to convert to
10645 /// (which may or may not be the same type as the type that the
10646 /// conversion function produces).
10648 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10649 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10650 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10651 bool AllowExplicit, bool AllowResultConversion = true,
10652 bool StrictPackMatch = false);
10653
10654 /// Adds a conversion function template specialization
10655 /// candidate to the overload set, using template argument deduction
10656 /// to deduce the template arguments of the conversion function
10657 /// template from the type that we are converting to (C++
10658 /// [temp.deduct.conv]).
10660 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10661 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10662 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10663 bool AllowExplicit, bool AllowResultConversion = true);
10664
10665 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10666 /// converts the given @c Object to a function pointer via the
10667 /// conversion function @c Conversion, and then attempts to call it
10668 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10669 /// the type of function that we'll eventually be calling.
10670 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10671 DeclAccessPair FoundDecl,
10672 CXXRecordDecl *ActingContext,
10673 const FunctionProtoType *Proto, Expr *Object,
10674 ArrayRef<Expr *> Args,
10675 OverloadCandidateSet &CandidateSet);
10676
10677 /// Add all of the non-member operator function declarations in the given
10678 /// function set to the overload candidate set.
10680 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10681 OverloadCandidateSet &CandidateSet,
10682 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10683
10684 /// Add overload candidates for overloaded operators that are
10685 /// member functions.
10686 ///
10687 /// Add the overloaded operator candidates that are member functions
10688 /// for the operator Op that was used in an operator expression such
10689 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10690 /// CandidateSet will store the added overload candidates. (C++
10691 /// [over.match.oper]).
10693 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10694 OverloadCandidateSet &CandidateSet,
10696
10697 /// AddBuiltinCandidate - Add a candidate for a built-in
10698 /// operator. ResultTy and ParamTys are the result and parameter types
10699 /// of the built-in candidate, respectively. Args and NumArgs are the
10700 /// arguments being passed to the candidate. IsAssignmentOperator
10701 /// should be true when this built-in candidate is an assignment
10702 /// operator. NumContextualBoolArguments is the number of arguments
10703 /// (at the beginning of the argument list) that will be contextually
10704 /// converted to bool.
10705 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10706 OverloadCandidateSet &CandidateSet,
10707 bool IsAssignmentOperator = false,
10708 unsigned NumContextualBoolArguments = 0);
10709
10710 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10711 /// operator overloads to the candidate set (C++ [over.built]), based
10712 /// on the operator @p Op and the arguments given. For example, if the
10713 /// operator is a binary '+', this routine might add "int
10714 /// operator+(int, int)" to cover integer addition.
10716 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10717 OverloadCandidateSet &CandidateSet);
10718
10719 /// Add function candidates found via argument-dependent lookup
10720 /// to the set of overloading candidates.
10721 ///
10722 /// This routine performs argument-dependent name lookup based on the
10723 /// given function name (which may also be an operator name) and adds
10724 /// all of the overload candidates found by ADL to the overload
10725 /// candidate set (C++ [basic.lookup.argdep]).
10727 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10728 TemplateArgumentListInfo *ExplicitTemplateArgs,
10729 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10730
10731 /// Check the enable_if expressions on the given function. Returns the first
10732 /// failing attribute, or NULL if they were all successful.
10733 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10734 ArrayRef<Expr *> Args,
10735 bool MissingImplicitThis = false);
10736
10737 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10738 /// non-ArgDependent DiagnoseIfAttrs.
10739 ///
10740 /// Argument-dependent diagnose_if attributes should be checked each time a
10741 /// function is used as a direct callee of a function call.
10742 ///
10743 /// Returns true if any errors were emitted.
10744 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10745 const Expr *ThisArg,
10746 ArrayRef<const Expr *> Args,
10747 SourceLocation Loc);
10748
10749 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10750 /// ArgDependent DiagnoseIfAttrs.
10751 ///
10752 /// Argument-independent diagnose_if attributes should be checked on every use
10753 /// of a function.
10754 ///
10755 /// Returns true if any errors were emitted.
10756 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10757 SourceLocation Loc);
10758
10759 /// Determine if \p A and \p B are equivalent internal linkage declarations
10760 /// from different modules, and thus an ambiguity error can be downgraded to
10761 /// an extension warning.
10762 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10763 const NamedDecl *B);
10765 SourceLocation Loc, const NamedDecl *D,
10766 ArrayRef<const NamedDecl *> Equiv);
10767
10768 // Emit as a 'note' the specific overload candidate
10770 const NamedDecl *Found, const FunctionDecl *Fn,
10772 QualType DestType = QualType(), bool TakingAddress = false);
10773
10774 // Emit as a series of 'note's all template and non-templates identified by
10775 // the expression Expr
10776 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10777 bool TakingAddress = false);
10778
10779 /// Returns whether the given function's address can be taken or not,
10780 /// optionally emitting a diagnostic if the address can't be taken.
10781 ///
10782 /// Returns false if taking the address of the function is illegal.
10783 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10784 bool Complain = false,
10785 SourceLocation Loc = SourceLocation());
10786
10787 // [PossiblyAFunctionType] --> [Return]
10788 // NonFunctionType --> NonFunctionType
10789 // R (A) --> R(A)
10790 // R (*)(A) --> R (A)
10791 // R (&)(A) --> R (A)
10792 // R (S::*)(A) --> R (A)
10793 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10794
10795 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10796 /// an overloaded function (C++ [over.over]), where @p From is an
10797 /// expression with overloaded function type and @p ToType is the type
10798 /// we're trying to resolve to. For example:
10799 ///
10800 /// @code
10801 /// int f(double);
10802 /// int f(int);
10803 ///
10804 /// int (*pfd)(double) = f; // selects f(double)
10805 /// @endcode
10806 ///
10807 /// This routine returns the resulting FunctionDecl if it could be
10808 /// resolved, and NULL otherwise. When @p Complain is true, this
10809 /// routine will emit diagnostics if there is an error.
10810 FunctionDecl *
10811 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10812 bool Complain, DeclAccessPair &Found,
10813 bool *pHadMultipleCandidates = nullptr);
10814
10815 /// Given an expression that refers to an overloaded function, try to
10816 /// resolve that function to a single function that can have its address
10817 /// taken. This will modify `Pair` iff it returns non-null.
10818 ///
10819 /// This routine can only succeed if from all of the candidates in the
10820 /// overload set for SrcExpr that can have their addresses taken, there is one
10821 /// candidate that is more constrained than the rest.
10822 FunctionDecl *
10823 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10824
10825 /// Given an overloaded function, tries to turn it into a non-overloaded
10826 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10827 /// will perform access checks, diagnose the use of the resultant decl, and,
10828 /// if requested, potentially perform a function-to-pointer decay.
10829 ///
10830 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10831 /// Otherwise, returns true. This may emit diagnostics and return true.
10833 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10834
10835 /// Given an expression that refers to an overloaded function, try to
10836 /// resolve that overloaded function expression down to a single function.
10837 ///
10838 /// This routine can only resolve template-ids that refer to a single function
10839 /// template, where that template-id refers to a single template whose
10840 /// template arguments are either provided by the template-id or have
10841 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10842 ///
10843 /// If no template-ids are found, no diagnostics are emitted and NULL is
10844 /// returned.
10846 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10847 TemplateSpecCandidateSet *FailedTSC = nullptr,
10848 bool ForTypeDeduction = false);
10849
10850 // Resolve and fix an overloaded expression that can be resolved
10851 // because it identifies a single function template specialization.
10852 //
10853 // Last three arguments should only be supplied if Complain = true
10854 //
10855 // Return true if it was logically possible to so resolve the
10856 // expression, regardless of whether or not it succeeded. Always
10857 // returns true if 'complain' is set.
10859 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10860 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10861 QualType DestTypeForComplaining = QualType(),
10862 unsigned DiagIDForComplaining = 0);
10863
10864 /// Add the overload candidates named by callee and/or found by argument
10865 /// dependent lookup to the given overload set.
10866 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10867 ArrayRef<Expr *> Args,
10868 OverloadCandidateSet &CandidateSet,
10869 bool PartialOverloading = false);
10870
10871 /// Add the call candidates from the given set of lookup results to the given
10872 /// overload set. Non-function lookup results are ignored.
10874 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10875 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10876
10877 // An enum used to represent the different possible results of building a
10878 // range-based for loop.
10884
10885 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10886 /// given LookupResult is non-empty, it is assumed to describe a member which
10887 /// will be invoked. Otherwise, the function will be found via argument
10888 /// dependent lookup.
10889 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10890 /// otherwise CallExpr is set to ExprError() and some non-success value
10891 /// is returned.
10893 SourceLocation RangeLoc,
10894 const DeclarationNameInfo &NameInfo,
10895 LookupResult &MemberLookup,
10896 OverloadCandidateSet *CandidateSet,
10897 Expr *Range, ExprResult *CallExpr);
10898
10899 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10900 /// (which eventually refers to the declaration Func) and the call
10901 /// arguments Args/NumArgs, attempt to resolve the function call down
10902 /// to a specific function. If overload resolution succeeds, returns
10903 /// the call expression produced by overload resolution.
10904 /// Otherwise, emits diagnostics and returns ExprError.
10906 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10907 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10908 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10909
10910 /// Constructs and populates an OverloadedCandidateSet from
10911 /// the given function.
10912 /// \returns true when an the ExprResult output parameter has been set.
10914 MultiExprArg Args, SourceLocation RParenLoc,
10915 OverloadCandidateSet *CandidateSet,
10917
10921 const UnresolvedSetImpl &Fns,
10922 bool PerformADL = true);
10923
10924 /// Create a unary operation that may resolve to an overloaded
10925 /// operator.
10926 ///
10927 /// \param OpLoc The location of the operator itself (e.g., '*').
10928 ///
10929 /// \param Opc The UnaryOperatorKind that describes this operator.
10930 ///
10931 /// \param Fns The set of non-member functions that will be
10932 /// considered by overload resolution. The caller needs to build this
10933 /// set based on the context using, e.g.,
10934 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10935 /// set should not contain any member functions; those will be added
10936 /// by CreateOverloadedUnaryOp().
10937 ///
10938 /// \param Input The input argument.
10941 const UnresolvedSetImpl &Fns, Expr *input,
10942 bool RequiresADL = true);
10943
10944 /// Perform lookup for an overloaded binary operator.
10947 const UnresolvedSetImpl &Fns,
10948 ArrayRef<Expr *> Args, bool RequiresADL = true);
10949
10950 /// Create a binary operation that may resolve to an overloaded
10951 /// operator.
10952 ///
10953 /// \param OpLoc The location of the operator itself (e.g., '+').
10954 ///
10955 /// \param Opc The BinaryOperatorKind that describes this operator.
10956 ///
10957 /// \param Fns The set of non-member functions that will be
10958 /// considered by overload resolution. The caller needs to build this
10959 /// set based on the context using, e.g.,
10960 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10961 /// set should not contain any member functions; those will be added
10962 /// by CreateOverloadedBinOp().
10963 ///
10964 /// \param LHS Left-hand argument.
10965 /// \param RHS Right-hand argument.
10966 /// \param PerformADL Whether to consider operator candidates found by ADL.
10967 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10968 /// C++20 operator rewrites.
10969 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
10970 /// the function in question. Such a function is never a candidate in
10971 /// our overload resolution. This also enables synthesizing a three-way
10972 /// comparison from < and == as described in C++20 [class.spaceship]p1.
10974 const UnresolvedSetImpl &Fns, Expr *LHS,
10975 Expr *RHS, bool RequiresADL = true,
10976 bool AllowRewrittenCandidates = true,
10977 FunctionDecl *DefaultedFn = nullptr);
10979 const UnresolvedSetImpl &Fns,
10980 Expr *LHS, Expr *RHS,
10981 FunctionDecl *DefaultedFn);
10982
10984 SourceLocation RLoc, Expr *Base,
10985 MultiExprArg Args);
10986
10987 /// BuildCallToMemberFunction - Build a call to a member
10988 /// function. MemExpr is the expression that refers to the member
10989 /// function (and includes the object parameter), Args/NumArgs are the
10990 /// arguments to the function call (not including the object
10991 /// parameter). The caller needs to validate that the member
10992 /// expression refers to a non-static member function or an overloaded
10993 /// member function.
10995 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
10996 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
10997 bool IsExecConfig = false, bool AllowRecovery = false);
10998
10999 /// BuildCallToObjectOfClassType - Build a call to an object of class
11000 /// type (C++ [over.call.object]), which can end up invoking an
11001 /// overloaded function call operator (@c operator()) or performing a
11002 /// user-defined conversion on the object argument.
11004 SourceLocation LParenLoc,
11005 MultiExprArg Args,
11006 SourceLocation RParenLoc);
11007
11008 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
11009 /// (if one exists), where @c Base is an expression of class type and
11010 /// @c Member is the name of the member we're trying to find.
11012 SourceLocation OpLoc,
11013 bool *NoArrowOperatorFound = nullptr);
11014
11017 bool HadMultipleCandidates);
11018
11019 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
11020 /// to a literal operator described by the provided lookup results.
11023 SourceLocation LitEndLoc,
11024 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
11025
11026 /// FixOverloadedFunctionReference - E is an expression that refers to
11027 /// a C++ overloaded function (possibly with some parentheses and
11028 /// perhaps a '&' around it). We have resolved the overloaded function
11029 /// to the function declaration Fn, so patch up the expression E to
11030 /// refer (possibly indirectly) to Fn. Returns the new expr.
11032 FunctionDecl *Fn);
11034 DeclAccessPair FoundDecl,
11035 FunctionDecl *Fn);
11036
11037 /// - Returns a selector which best matches given argument list or
11038 /// nullptr if none could be found
11040 bool IsInstance,
11042
11043 ///@}
11044
11045 //
11046 //
11047 // -------------------------------------------------------------------------
11048 //
11049 //
11050
11051 /// \name Statements
11052 /// Implementations are in SemaStmt.cpp
11053 ///@{
11054
11055public:
11056 /// Stack of active SEH __finally scopes. Can be empty.
11058
11059 /// Stack of '_Defer' statements that are currently being parsed, as well
11060 /// as the locations of their '_Defer' keywords. Can be empty.
11062
11063 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
11065
11067 bool HasLeadingEmptyMacro = false);
11068
11070 SourceLocation EndLoc);
11072
11073 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
11074 /// whose result is unused, warn.
11075 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
11076
11077 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
11081 ArrayRef<Stmt *> Elts, bool isStmtExpr);
11082
11084
11087 SourceLocation DotDotDotLoc, ExprResult RHS,
11088 SourceLocation ColonLoc);
11089
11090 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
11091 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
11092
11094 SourceLocation ColonLoc, Stmt *SubStmt,
11095 Scope *CurScope);
11097 SourceLocation ColonLoc, Stmt *SubStmt);
11098
11100 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
11102 Stmt *SubStmt);
11103
11104 /// Check whether the given statement can have musttail applied to it,
11105 /// issuing a diagnostic and returning false if not. In the success case,
11106 /// the statement is rewritten to remove implicit nodes from the return
11107 /// value.
11108 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
11109
11111 SourceLocation LParenLoc, Stmt *InitStmt,
11113 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
11115 SourceLocation LParenLoc, Stmt *InitStmt,
11117 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
11118
11120
11122 SourceLocation LParenLoc, Stmt *InitStmt,
11124 SourceLocation RParenLoc);
11126 Stmt *Body);
11127
11128 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
11129 /// integer not in the range of enum values.
11130 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
11131 Expr *SrcExpr);
11132
11135 Stmt *Body);
11137 SourceLocation WhileLoc, SourceLocation CondLParen,
11138 Expr *Cond, SourceLocation CondRParen);
11139
11141 Stmt *First, ConditionResult Second,
11142 FullExprArg Third, SourceLocation RParenLoc,
11143 Stmt *Body);
11144
11145 /// In an Objective C collection iteration statement:
11146 /// for (x in y)
11147 /// x can be an arbitrary l-value expression. Bind it up as a
11148 /// full-expression.
11150
11152 /// Initial building of a for-range statement.
11154 /// Instantiation or recovery rebuild of a for-range statement. Don't
11155 /// attempt any typo-correction.
11157 /// Determining whether a for-range statement could be built. Avoid any
11158 /// unnecessary or irreversible actions.
11160 };
11161
11162 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
11163 ///
11164 /// C++11 [stmt.ranged]:
11165 /// A range-based for statement is equivalent to
11166 ///
11167 /// {
11168 /// auto && __range = range-init;
11169 /// for ( auto __begin = begin-expr,
11170 /// __end = end-expr;
11171 /// __begin != __end;
11172 /// ++__begin ) {
11173 /// for-range-declaration = *__begin;
11174 /// statement
11175 /// }
11176 /// }
11177 ///
11178 /// The body of the loop is not available yet, since it cannot be analysed
11179 /// until we have determined the type of the for-range-declaration.
11181 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
11182 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
11183 SourceLocation RParenLoc, BuildForRangeKind Kind,
11184 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11185
11186 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
11187 StmtResult BuildCXXForRangeStmt(
11188 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
11189 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
11190 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
11191 BuildForRangeKind Kind,
11192 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11193
11194 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
11195 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
11196 /// body cannot be performed until after the type of the range variable is
11197 /// determined.
11198 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
11199
11200 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
11201 LabelDecl *TheDecl);
11202 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
11203 SourceLocation StarLoc, Expr *DestExp);
11204 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope,
11205 LabelDecl *Label, SourceLocation LabelLoc);
11206 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope,
11207 LabelDecl *Label, SourceLocation LabelLoc);
11208
11209 void ActOnStartOfDeferStmt(SourceLocation DeferLoc, Scope *CurScope);
11210 void ActOnDeferStmtError(Scope *CurScope);
11211 StmtResult ActOnEndOfDeferStmt(Stmt *Body, Scope *CurScope);
11212
11215
11218
11219 bool isMoveEligible() const { return S != None; };
11221 };
11223
11224 /// Determine whether the given expression might be move-eligible or
11225 /// copy-elidable in either a (co_)return statement or throw expression,
11226 /// without considering function return type, if applicable.
11227 ///
11228 /// \param E The expression being returned from the function or block,
11229 /// being thrown, or being co_returned from a coroutine. This expression
11230 /// might be modified by the implementation.
11231 ///
11232 /// \param Mode Overrides detection of current language mode
11233 /// and uses the rules for C++23.
11234 ///
11235 /// \returns An aggregate which contains the Candidate and isMoveEligible
11236 /// and isCopyElidable methods. If Candidate is non-null, it means
11237 /// isMoveEligible() would be true under the most permissive language
11238 /// standard.
11239 NamedReturnInfo getNamedReturnInfo(
11241
11242 /// Determine whether the given NRVO candidate variable is move-eligible or
11243 /// copy-elidable, without considering function return type.
11244 ///
11245 /// \param VD The NRVO candidate variable.
11246 ///
11247 /// \returns An aggregate which contains the Candidate and isMoveEligible
11248 /// and isCopyElidable methods. If Candidate is non-null, it means
11249 /// isMoveEligible() would be true under the most permissive language
11250 /// standard.
11251 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
11252
11253 /// Updates given NamedReturnInfo's move-eligible and
11254 /// copy-elidable statuses, considering the function
11255 /// return type criteria as applicable to return statements.
11256 ///
11257 /// \param Info The NamedReturnInfo object to update.
11258 ///
11259 /// \param ReturnType This is the return type of the function.
11260 /// \returns The copy elision candidate, in case the initial return expression
11261 /// was copy elidable, or nullptr otherwise.
11262 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
11263 QualType ReturnType);
11264
11265 /// Perform the initialization of a potentially-movable value, which
11266 /// is the result of return value.
11267 ///
11268 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
11269 /// treat returned lvalues as rvalues in certain cases (to prefer move
11270 /// construction), then falls back to treating them as lvalues if that failed.
11273 const NamedReturnInfo &NRInfo, Expr *Value,
11274 bool SupressSimplerImplicitMoves = false);
11275
11277
11278 /// Deduce the return type for a function from a returned expression, per
11279 /// C++1y [dcl.spec.auto]p6.
11281 SourceLocation ReturnLoc, Expr *RetExpr,
11282 const AutoType *AT);
11283
11284 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11285 Scope *CurScope);
11286 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11287 bool AllowRecovery = false);
11288
11289 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
11290 /// for capturing scopes.
11292 NamedReturnInfo &NRInfo,
11293 bool SupressSimplerImplicitMoves);
11294
11295 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
11296 /// and creates a proper catch handler from them.
11298 Stmt *HandlerBlock);
11299
11300 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
11301 /// handlers and creates a try statement from them.
11303 ArrayRef<Stmt *> Handlers);
11304
11305 void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry);
11306
11307 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
11308 SourceLocation TryLoc, Stmt *TryBlock,
11309 Stmt *Handler);
11311 Stmt *Block);
11316
11318 bool IsIfExists,
11319 NestedNameSpecifierLoc QualifierLoc,
11320 DeclarationNameInfo NameInfo,
11321 Stmt *Nested);
11323 bool IsIfExists, CXXScopeSpec &SS,
11324 UnqualifiedId &Name, Stmt *Nested);
11325
11326 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11327 CapturedRegionKind Kind, unsigned NumParams);
11328 typedef std::pair<StringRef, QualType> CapturedParamNameType;
11329 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11330 CapturedRegionKind Kind,
11332 unsigned OpenMPCaptureLevel = 0);
11336 SourceLocation Loc,
11337 unsigned NumParams);
11338
11339private:
11340 /// Check whether the given statement can have musttail applied to it,
11341 /// issuing a diagnostic and returning false if not.
11342 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
11343
11344 ///@}
11345
11346 //
11347 //
11348 // -------------------------------------------------------------------------
11349 //
11350 //
11351
11352 /// \name `inline asm` Statement
11353 /// Implementations are in SemaStmtAsm.cpp
11354 ///@{
11355
11356public:
11357 ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel);
11358 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
11359 bool IsVolatile, unsigned NumOutputs,
11360 unsigned NumInputs, IdentifierInfo **Names,
11361 MultiExprArg Constraints, MultiExprArg Exprs,
11362 Expr *AsmString, MultiExprArg Clobbers,
11363 unsigned NumLabels, SourceLocation RParenLoc);
11364
11366 llvm::InlineAsmIdentifierInfo &Info);
11368 SourceLocation TemplateKWLoc,
11369 UnqualifiedId &Id,
11370 bool IsUnevaluatedContext);
11371 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
11372 SourceLocation AsmLoc);
11374 SourceLocation AsmLoc);
11376 ArrayRef<Token> AsmToks, StringRef AsmString,
11377 unsigned NumOutputs, unsigned NumInputs,
11378 ArrayRef<StringRef> Constraints,
11379 ArrayRef<StringRef> Clobbers,
11380 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
11381 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
11382 SourceLocation Location, bool AlwaysCreate);
11383
11384 ///@}
11385
11386 //
11387 //
11388 // -------------------------------------------------------------------------
11389 //
11390 //
11391
11392 /// \name Statement Attribute Handling
11393 /// Implementations are in SemaStmtAttr.cpp
11394 ///@{
11395
11396public:
11397 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11398 const AttributeCommonInfo &A);
11399 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11400 const AttributeCommonInfo &A);
11401
11402 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11404
11405 /// Process the attributes before creating an attributed statement. Returns
11406 /// the semantic attributes that have been processed.
11407 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11409
11411 SourceRange Range);
11413 const IdentifierInfo *AttrName,
11414 SourceRange Range);
11415
11416 ///@}
11417
11418 //
11419 //
11420 // -------------------------------------------------------------------------
11421 //
11422 //
11423
11424 /// \name C++ Templates
11425 /// Implementations are in SemaTemplate.cpp
11426 ///@{
11427
11428public:
11429 // Saves the current floating-point pragma stack and clear it in this Sema.
11431 public:
11433 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11434 S.FpPragmaStack.Stack.clear();
11435 }
11436 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11439
11440 private:
11441 Sema &S;
11443 };
11444
11446 CurFPFeatures = FPO;
11447 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11448 }
11449
11455
11460
11461 typedef llvm::MapVector<const FunctionDecl *,
11462 std::unique_ptr<LateParsedTemplate>>
11465
11466 /// Determine the number of levels of enclosing template parameters. This is
11467 /// only usable while parsing. Note that this does not include dependent
11468 /// contexts in which no template parameters have yet been declared, such as
11469 /// in a terse function template or generic lambda before the first 'auto' is
11470 /// encountered.
11471 unsigned getTemplateDepth(Scope *S) const;
11472
11474 bool AllowFunctionTemplates = true,
11475 bool AllowDependent = true);
11477 bool AllowFunctionTemplates = true,
11478 bool AllowDependent = true,
11479 bool AllowNonTemplateFunctions = false);
11480 /// Try to interpret the lookup result D as a template-name.
11481 ///
11482 /// \param D A declaration found by name lookup.
11483 /// \param AllowFunctionTemplates Whether function templates should be
11484 /// considered valid results.
11485 /// \param AllowDependent Whether unresolved using declarations (that might
11486 /// name templates) should be considered valid results.
11488 bool AllowFunctionTemplates = true,
11489 bool AllowDependent = true);
11490
11492 /// Whether and why a template name is required in this lookup.
11494 public:
11495 /// Template name is required if TemplateKWLoc is valid.
11497 : TemplateKW(TemplateKWLoc) {}
11498 /// Template name is unconditionally required.
11500
11502 return TemplateKW.value_or(SourceLocation());
11503 }
11504 bool hasTemplateKeyword() const {
11505 return getTemplateKeywordLoc().isValid();
11506 }
11507 bool isRequired() const { return TemplateKW != SourceLocation(); }
11508 explicit operator bool() const { return isRequired(); }
11509
11510 private:
11511 std::optional<SourceLocation> TemplateKW;
11512 };
11513
11515 /// This is not assumed to be a template name.
11517 /// This is assumed to be a template name because lookup found nothing.
11519 /// This is assumed to be a template name because lookup found one or more
11520 /// functions (but no function templates).
11522 };
11523
11524 bool
11526 QualType ObjectType, bool EnteringContext,
11527 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11528 AssumedTemplateKind *ATK = nullptr,
11529 bool AllowTypoCorrection = true);
11530
11532 bool hasTemplateKeyword,
11533 const UnqualifiedId &Name,
11534 ParsedType ObjectType, bool EnteringContext,
11536 bool &MemberOfUnknownSpecialization,
11537 bool Disambiguation = false);
11538
11539 /// Try to resolve an undeclared template name as a type template.
11540 ///
11541 /// Sets II to the identifier corresponding to the template name, and updates
11542 /// Name to a corresponding (typo-corrected) type template name and TNK to
11543 /// the corresponding kind, if possible.
11545 TemplateNameKind &TNK,
11546 SourceLocation NameLoc,
11547 IdentifierInfo *&II);
11548
11549 /// Determine whether a particular identifier might be the name in a C++1z
11550 /// deduction-guide declaration.
11551 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11552 SourceLocation NameLoc, CXXScopeSpec &SS,
11553 ParsedTemplateTy *Template = nullptr);
11554
11556 SourceLocation IILoc, Scope *S,
11557 const CXXScopeSpec *SS,
11558 TemplateTy &SuggestedTemplate,
11559 TemplateNameKind &SuggestedKind);
11560
11561 /// Determine whether we would be unable to instantiate this template (because
11562 /// it either has no definition, or is in the process of being instantiated).
11564 SourceLocation PointOfInstantiation, NamedDecl *Instantiation,
11565 bool InstantiatedFromMember, const NamedDecl *Pattern,
11566 const NamedDecl *PatternDef, TemplateSpecializationKind TSK,
11567 bool Complain = true, bool *Unreachable = nullptr);
11568
11569 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11570 /// that the template parameter 'PrevDecl' is being shadowed by a new
11571 /// declaration at location Loc. Returns true to indicate that this is
11572 /// an error, and false otherwise.
11573 ///
11574 /// \param Loc The location of the declaration that shadows a template
11575 /// parameter.
11576 ///
11577 /// \param PrevDecl The template parameter that the declaration shadows.
11578 ///
11579 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11580 /// a warning for compatibility with older versions of clang.
11581 /// Ignored when MSVC compatibility is enabled.
11583 bool SupportedForCompatibility = false);
11584
11585 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11586 /// the parameter D to reference the templated declaration and return a
11587 /// pointer to the template declaration. Otherwise, do nothing to D and return
11588 /// null.
11590
11591 /// ActOnTypeParameter - Called when a C++ template type parameter
11592 /// (e.g., "typename T") has been parsed. Typename specifies whether
11593 /// the keyword "typename" was used to declare the type parameter
11594 /// (otherwise, "class" was used), and KeyLoc is the location of the
11595 /// "class" or "typename" keyword. ParamName is the name of the
11596 /// parameter (NULL indicates an unnamed template parameter) and
11597 /// ParamNameLoc is the location of the parameter name (if any).
11598 /// If the type parameter has a default argument, it will be added
11599 /// later via ActOnTypeParameterDefault.
11601 SourceLocation EllipsisLoc,
11602 SourceLocation KeyLoc,
11603 IdentifierInfo *ParamName,
11604 SourceLocation ParamNameLoc, unsigned Depth,
11605 unsigned Position, SourceLocation EqualLoc,
11606 ParsedType DefaultArg, bool HasTypeConstraint);
11607
11609
11610 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11612 TemplateTypeParmDecl *ConstrainedParameter,
11613 SourceLocation EllipsisLoc);
11614 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11616 TemplateTypeParmDecl *ConstrainedParameter,
11617 SourceLocation EllipsisLoc,
11618 bool AllowUnexpandedPack);
11619
11620 /// Attach a type-constraint to a template parameter.
11621 /// \returns true if an error occurred. This can happen if the
11622 /// immediately-declared constraint could not be formed (e.g. incorrect number
11623 /// of arguments for the named concept).
11625 DeclarationNameInfo NameInfo,
11626 TemplateDecl *NamedConcept, NamedDecl *FoundDecl,
11627 const TemplateArgumentListInfo *TemplateArgs,
11628 TemplateTypeParmDecl *ConstrainedParameter,
11629 SourceLocation EllipsisLoc);
11630
11632 NonTypeTemplateParmDecl *NewConstrainedParm,
11633 NonTypeTemplateParmDecl *OrigConstrainedParm,
11634 SourceLocation EllipsisLoc);
11635
11636 /// Require the given type to be a structural type, and diagnose if it is not.
11637 ///
11638 /// \return \c true if an error was produced.
11640
11641 /// Check that the type of a non-type template parameter is
11642 /// well-formed.
11643 ///
11644 /// \returns the (possibly-promoted) parameter type if valid;
11645 /// otherwise, produces a diagnostic and returns a NULL type.
11647 SourceLocation Loc);
11649
11651 unsigned Depth, unsigned Position,
11652 SourceLocation EqualLoc,
11653 Expr *DefaultArg);
11654
11655 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11656 /// parameter (e.g. T in template <template <typename> class T> class array)
11657 /// has been parsed. S is the current scope.
11659 Scope *S, SourceLocation TmpLoc, TemplateNameKind Kind,
11660 bool TypenameKeyword, TemplateParameterList *Params,
11661 SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11662 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11663 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11664
11665 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11666 /// constrained by RequiresClause, that contains the template parameters in
11667 /// Params.
11669 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11670 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11671 SourceLocation RAngleLoc, Expr *RequiresClause);
11672
11673 /// The context in which we are checking a template parameter list.
11675 // For this context, Class, Variable, TypeAlias, and non-pack Template
11676 // Template Parameters are treated uniformly.
11678
11685 };
11686
11687 /// Checks the validity of a template parameter list, possibly
11688 /// considering the template parameter list from a previous
11689 /// declaration.
11690 ///
11691 /// If an "old" template parameter list is provided, it must be
11692 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11693 /// template parameter list.
11694 ///
11695 /// \param NewParams Template parameter list for a new template
11696 /// declaration. This template parameter list will be updated with any
11697 /// default arguments that are carried through from the previous
11698 /// template parameter list.
11699 ///
11700 /// \param OldParams If provided, template parameter list from a
11701 /// previous declaration of the same template. Default template
11702 /// arguments will be merged from the old template parameter list to
11703 /// the new template parameter list.
11704 ///
11705 /// \param TPC Describes the context in which we are checking the given
11706 /// template parameter list.
11707 ///
11708 /// \param SkipBody If we might have already made a prior merged definition
11709 /// of this template visible, the corresponding body-skipping information.
11710 /// Default argument redefinition is not an error when skipping such a body,
11711 /// because (under the ODR) we can assume the default arguments are the same
11712 /// as the prior merged definition.
11713 ///
11714 /// \returns true if an error occurred, false otherwise.
11716 TemplateParameterList *OldParams,
11718 SkipBodyInfo *SkipBody = nullptr);
11719
11720 /// Match the given template parameter lists to the given scope
11721 /// specifier, returning the template parameter list that applies to the
11722 /// name.
11723 ///
11724 /// \param DeclStartLoc the start of the declaration that has a scope
11725 /// specifier or a template parameter list.
11726 ///
11727 /// \param DeclLoc The location of the declaration itself.
11728 ///
11729 /// \param SS the scope specifier that will be matched to the given template
11730 /// parameter lists. This scope specifier precedes a qualified name that is
11731 /// being declared.
11732 ///
11733 /// \param TemplateId The template-id following the scope specifier, if there
11734 /// is one. Used to check for a missing 'template<>'.
11735 ///
11736 /// \param ParamLists the template parameter lists, from the outermost to the
11737 /// innermost template parameter lists.
11738 ///
11739 /// \param IsFriend Whether to apply the slightly different rules for
11740 /// matching template parameters to scope specifiers in friend
11741 /// declarations.
11742 ///
11743 /// \param IsMemberSpecialization will be set true if the scope specifier
11744 /// denotes a fully-specialized type, and therefore this is a declaration of
11745 /// a member specialization.
11746 ///
11747 /// \returns the template parameter list, if any, that corresponds to the
11748 /// name that is preceded by the scope specifier @p SS. This template
11749 /// parameter list may have template parameters (if we're declaring a
11750 /// template) or may have no template parameters (if we're declaring a
11751 /// template specialization), or may be NULL (if what we're declaring isn't
11752 /// itself a template).
11754 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11755 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11756 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11757 bool &IsMemberSpecialization, bool &Invalid,
11758 bool SuppressDiagnostic = false);
11759
11760 /// Returns the template parameter list with all default template argument
11761 /// information.
11763
11765 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11766 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11767 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11768 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11769 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11770 TemplateParameterList **OuterTemplateParamLists,
11771 bool IsMemberSpecialization, SkipBodyInfo *SkipBody = nullptr);
11772
11773 /// Translates template arguments as provided by the parser
11774 /// into template arguments used by semantic analysis.
11777
11778 /// Convert a parsed type into a parsed template argument. This is mostly
11779 /// trivial, except that we may have parsed a C++17 deduced class template
11780 /// specialization type, in which case we should form a template template
11781 /// argument instead of a type template argument.
11783
11785
11788 SourceLocation TemplateLoc,
11789 TemplateArgumentListInfo &TemplateArgs,
11790 Scope *Scope, bool ForNestedNameSpecifier);
11791
11793 ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword,
11794 SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS,
11795 SourceLocation TemplateKWLoc, TemplateTy Template,
11796 const IdentifierInfo *TemplateII,
11797 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11798 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11799 bool IsCtorOrDtorName = false, bool IsClassName = false,
11800 ImplicitTypenameContext AllowImplicitTypename =
11802
11803 /// Parsed an elaborated-type-specifier that refers to a template-id,
11804 /// such as \c class T::template apply<U>.
11806 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11807 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11808 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11809 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11810
11813 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11815
11816 /// Get the specialization of the given variable template corresponding to
11817 /// the specified argument list, or a null-but-valid result if the arguments
11818 /// are dependent.
11820 SourceLocation TemplateLoc,
11821 SourceLocation TemplateNameLoc,
11822 const TemplateArgumentListInfo &TemplateArgs,
11823 bool SetWrittenArgs);
11824
11825 /// Form a reference to the specialization of the given variable template
11826 /// corresponding to the specified argument list, or a null-but-valid result
11827 /// if the arguments are dependent.
11829 const DeclarationNameInfo &NameInfo,
11831 SourceLocation TemplateLoc,
11832 const TemplateArgumentListInfo *TemplateArgs);
11833
11835 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
11837 const TemplateArgumentListInfo *TemplateArgs);
11838
11840 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11841 const DeclarationNameInfo &ConceptNameInfo,
11842 NamedDecl *FoundDecl, TemplateDecl *NamedConcept,
11843 const TemplateArgumentListInfo *TemplateArgs,
11844 bool DoCheckConstraintSatisfaction = true);
11845
11848 bool TemplateKeyword, TemplateDecl *TD,
11849 SourceLocation Loc);
11850
11852 SourceLocation TemplateKWLoc, LookupResult &R,
11853 bool RequiresADL,
11854 const TemplateArgumentListInfo *TemplateArgs);
11855
11856 // We actually only call this from template instantiation.
11859 const DeclarationNameInfo &NameInfo,
11860 const TemplateArgumentListInfo *TemplateArgs,
11861 bool IsAddressOfOperand);
11862
11864 return Pack.pack_size() - 1 - *ArgPackSubstIndex;
11865 }
11866
11869 Arg = Arg.pack_elements()[*ArgPackSubstIndex];
11870 if (Arg.isPackExpansion())
11871 Arg = Arg.getPackExpansionPattern();
11872 return Arg;
11873 }
11874
11876 Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP,
11877 SourceLocation loc, TemplateArgument Replacement,
11878 UnsignedOrNone PackIndex, bool Final);
11879
11880 /// Form a template name from a name that is syntactically required to name a
11881 /// template, either due to use of the 'template' keyword or because a name in
11882 /// this syntactic context is assumed to name a template (C++
11883 /// [temp.names]p2-4).
11884 ///
11885 /// This action forms a template name given the name of the template and its
11886 /// optional scope specifier. This is used when the 'template' keyword is used
11887 /// or when the parsing context unambiguously treats a following '<' as
11888 /// introducing a template argument list. Note that this may produce a
11889 /// non-dependent template name if we can perform the lookup now and identify
11890 /// the named template.
11891 ///
11892 /// For example, given "x.MetaFun::template apply", the scope specifier
11893 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11894 /// of the "template" keyword, and "apply" is the \p Name.
11896 SourceLocation TemplateKWLoc,
11897 const UnqualifiedId &Name,
11898 ParsedType ObjectType,
11899 bool EnteringContext, TemplateTy &Template,
11900 bool AllowInjectedClassName = false);
11901
11903 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11904 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11906 MultiTemplateParamsArg TemplateParameterLists,
11907 SkipBodyInfo *SkipBody = nullptr);
11908
11909 /// Check the non-type template arguments of a class template
11910 /// partial specialization according to C++ [temp.class.spec]p9.
11911 ///
11912 /// \param TemplateNameLoc the location of the template name.
11913 /// \param PrimaryTemplate the template parameters of the primary class
11914 /// template.
11915 /// \param NumExplicit the number of explicitly-specified template arguments.
11916 /// \param TemplateArgs the template arguments of the class template
11917 /// partial specialization.
11918 ///
11919 /// \returns \c true if there was an error, \c false otherwise.
11921 TemplateDecl *PrimaryTemplate,
11922 unsigned NumExplicitArgs,
11928
11930 MultiTemplateParamsArg TemplateParameterLists,
11931 Declarator &D);
11932
11933 /// Diagnose cases where we have an explicit template specialization
11934 /// before/after an explicit template instantiation, producing diagnostics
11935 /// for those cases where they are required and determining whether the
11936 /// new specialization/instantiation will have any effect.
11937 ///
11938 /// \param NewLoc the location of the new explicit specialization or
11939 /// instantiation.
11940 ///
11941 /// \param NewTSK the kind of the new explicit specialization or
11942 /// instantiation.
11943 ///
11944 /// \param PrevDecl the previous declaration of the entity.
11945 ///
11946 /// \param PrevTSK the kind of the old explicit specialization or
11947 /// instantiatin.
11948 ///
11949 /// \param PrevPointOfInstantiation if valid, indicates where the previous
11950 /// declaration was instantiated (either implicitly or explicitly).
11951 ///
11952 /// \param HasNoEffect will be set to true to indicate that the new
11953 /// specialization or instantiation has no effect and should be ignored.
11954 ///
11955 /// \returns true if there was an error that should prevent the introduction
11956 /// of the new declaration into the AST, false otherwise.
11958 SourceLocation NewLoc,
11959 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
11960 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
11961 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
11962
11963 /// Perform semantic analysis for the given dependent function
11964 /// template specialization.
11965 ///
11966 /// The only possible way to get a dependent function template specialization
11967 /// is with a friend declaration, like so:
11968 ///
11969 /// \code
11970 /// template <class T> void foo(T);
11971 /// template <class T> class A {
11972 /// friend void foo<>(T);
11973 /// };
11974 /// \endcode
11975 ///
11976 /// There really isn't any useful analysis we can do here, so we
11977 /// just store the information.
11979 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
11981
11982 /// Perform semantic analysis for the given function template
11983 /// specialization.
11984 ///
11985 /// This routine performs all of the semantic analysis required for an
11986 /// explicit function template specialization. On successful completion,
11987 /// the function declaration \p FD will become a function template
11988 /// specialization.
11989 ///
11990 /// \param FD the function declaration, which will be updated to become a
11991 /// function template specialization.
11992 ///
11993 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
11994 /// if any. Note that this may be valid info even when 0 arguments are
11995 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
11996 /// as it anyway contains info on the angle brackets locations.
11997 ///
11998 /// \param Previous the set of declarations that may be specialized by
11999 /// this function specialization.
12000 ///
12001 /// \param QualifiedFriend whether this is a lookup for a qualified friend
12002 /// declaration with no explicit template argument list that might be
12003 /// befriending a function template specialization.
12005 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
12006 LookupResult &Previous, bool QualifiedFriend = false);
12007
12008 /// Perform semantic analysis for the given non-template member
12009 /// specialization.
12010 ///
12011 /// This routine performs all of the semantic analysis required for an
12012 /// explicit member function specialization. On successful completion,
12013 /// the function declaration \p FD will become a member function
12014 /// specialization.
12015 ///
12016 /// \param Member the member declaration, which will be updated to become a
12017 /// specialization.
12018 ///
12019 /// \param Previous the set of declarations, one of which may be specialized
12020 /// by this function specialization; the set will be modified to contain the
12021 /// redeclared member.
12024
12025 // Explicit instantiation of a class template specialization
12027 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
12028 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
12029 TemplateTy Template, SourceLocation TemplateNameLoc,
12030 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
12031 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
12032
12033 // Explicit instantiation of a member class of a class template.
12035 SourceLocation TemplateLoc,
12036 unsigned TagSpec, SourceLocation KWLoc,
12037 CXXScopeSpec &SS, IdentifierInfo *Name,
12038 SourceLocation NameLoc,
12039 const ParsedAttributesView &Attr);
12040
12042 SourceLocation TemplateLoc,
12043 Declarator &D);
12044
12045 /// If the given template parameter has a default template
12046 /// argument, substitute into that default template argument and
12047 /// return the corresponding template argument.
12049 TemplateDecl *Template, SourceLocation TemplateKWLoc,
12050 SourceLocation TemplateNameLoc, SourceLocation RAngleLoc, Decl *Param,
12051 ArrayRef<TemplateArgument> SugaredConverted,
12052 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
12053
12054 /// Returns the top most location responsible for the definition of \p N.
12055 /// If \p N is a a template specialization, this is the location
12056 /// of the top of the instantiation stack.
12057 /// Otherwise, the location of \p N is returned.
12059
12060 /// Specifies the context in which a particular template
12061 /// argument is being checked.
12063 /// The template argument was specified in the code or was
12064 /// instantiated with some deduced template arguments.
12066
12067 /// The template argument was deduced via template argument
12068 /// deduction.
12070
12071 /// The template argument was deduced from an array bound
12072 /// via template argument deduction.
12074 };
12075
12083
12084 /// The checked, converted argument will be added to the
12085 /// end of these vectors.
12087
12088 /// The check is being performed in the context of partial ordering.
12090
12091 /// If true, assume these template arguments are
12092 /// the injected template arguments for a template template parameter.
12093 /// This will relax the requirement that all its possible uses are valid:
12094 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
12095 /// during instantiation.
12097
12098 /// Is set to true when, in the context of TTP matching, a pack parameter
12099 /// matches non-pack arguments.
12100 bool StrictPackMatch = false;
12101 };
12102
12103 /// Check that the given template argument corresponds to the given
12104 /// template parameter.
12105 ///
12106 /// \param Param The template parameter against which the argument will be
12107 /// checked.
12108 ///
12109 /// \param Arg The template argument, which may be updated due to conversions.
12110 ///
12111 /// \param Template The template in which the template argument resides.
12112 ///
12113 /// \param TemplateLoc The location of the template name for the template
12114 /// whose argument list we're matching.
12115 ///
12116 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
12117 /// the template argument list.
12118 ///
12119 /// \param ArgumentPackIndex The index into the argument pack where this
12120 /// argument will be placed. Only valid if the parameter is a parameter pack.
12121 ///
12122 /// \param CTAK Describes how we arrived at this particular template argument:
12123 /// explicitly written, deduced, etc.
12124 ///
12125 /// \returns true on error, false otherwise.
12127 NamedDecl *Template, SourceLocation TemplateLoc,
12128 SourceLocation RAngleLoc,
12129 unsigned ArgumentPackIndex,
12132
12133 /// Check that the given template arguments can be provided to
12134 /// the given template, converting the arguments along the way.
12135 ///
12136 /// \param Template The template to which the template arguments are being
12137 /// provided.
12138 ///
12139 /// \param TemplateLoc The location of the template name in the source.
12140 ///
12141 /// \param TemplateArgs The list of template arguments. If the template is
12142 /// a template template parameter, this function may extend the set of
12143 /// template arguments to also include substituted, defaulted template
12144 /// arguments.
12145 ///
12146 /// \param PartialTemplateArgs True if the list of template arguments is
12147 /// intentionally partial, e.g., because we're checking just the initial
12148 /// set of template arguments.
12149 ///
12150 /// \param Converted Will receive the converted, canonicalized template
12151 /// arguments.
12152 ///
12153 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
12154 /// contain the converted forms of the template arguments as written.
12155 /// Otherwise, \p TemplateArgs will not be modified.
12156 ///
12157 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
12158 /// receive true if the cause for the error is the associated constraints of
12159 /// the template not being satisfied by the template arguments.
12160 ///
12161 /// \param DefaultArgs any default arguments from template specialization
12162 /// deduction.
12163 ///
12164 /// \returns true if an error occurred, false otherwise.
12166 SourceLocation TemplateLoc,
12167 TemplateArgumentListInfo &TemplateArgs,
12168 const DefaultArguments &DefaultArgs,
12169 bool PartialTemplateArgs,
12171 bool UpdateArgsWithConversions = true,
12172 bool *ConstraintsNotSatisfied = nullptr);
12173
12176 SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs,
12177 const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
12178 CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions = true,
12179 bool *ConstraintsNotSatisfied = nullptr);
12180
12183 SmallVectorImpl<TemplateArgument> &SugaredConverted,
12184 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
12185
12186 /// Check a template argument against its corresponding
12187 /// template type parameter.
12188 ///
12189 /// This routine implements the semantics of C++ [temp.arg.type]. It
12190 /// returns true if an error occurred, and false otherwise.
12192
12193 /// Check a template argument against its corresponding
12194 /// non-type template parameter.
12195 ///
12196 /// This routine implements the semantics of C++ [temp.arg.nontype].
12197 /// If an error occurred, it returns ExprError(); otherwise, it
12198 /// returns the converted template argument. \p ParamType is the
12199 /// type of the non-type template parameter after it has been instantiated.
12201 QualType InstantiatedParamType, Expr *Arg,
12202 TemplateArgument &SugaredConverted,
12203 TemplateArgument &CanonicalConverted,
12204 bool StrictCheck,
12206
12207 /// Check a template argument against its corresponding
12208 /// template template parameter.
12209 ///
12210 /// This routine implements the semantics of C++ [temp.arg.template].
12211 /// It returns true if an error occurred, and false otherwise.
12213 TemplateParameterList *Params,
12215 bool PartialOrdering,
12216 bool *StrictPackMatch);
12217
12220 const TemplateArgumentLoc &Arg);
12221
12223 std::optional<SourceRange> ParamRange = {});
12225
12226 /// Given a non-type template argument that refers to a
12227 /// declaration and the type of its corresponding non-type template
12228 /// parameter, produce an expression that properly refers to that
12229 /// declaration.
12230 /// FIXME: This is used in some contexts where the resulting expression
12231 /// doesn't need to live too long. It would be useful if this function
12232 /// could return a temporary expression.
12234 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
12235 NamedDecl *TemplateParam = nullptr);
12238 SourceLocation Loc);
12239
12240 /// Enumeration describing how template parameter lists are compared
12241 /// for equality.
12243 /// We are matching the template parameter lists of two templates
12244 /// that might be redeclarations.
12245 ///
12246 /// \code
12247 /// template<typename T> struct X;
12248 /// template<typename T> struct X;
12249 /// \endcode
12251
12252 /// We are matching the template parameter lists of two template
12253 /// template parameters as part of matching the template parameter lists
12254 /// of two templates that might be redeclarations.
12255 ///
12256 /// \code
12257 /// template<template<int I> class TT> struct X;
12258 /// template<template<int Value> class Other> struct X;
12259 /// \endcode
12261
12262 /// We are determining whether the template-parameters are equivalent
12263 /// according to C++ [temp.over.link]/6. This comparison does not consider
12264 /// constraints.
12265 ///
12266 /// \code
12267 /// template<C1 T> void f(T);
12268 /// template<C2 T> void f(T);
12269 /// \endcode
12271 };
12272
12273 // A struct to represent the 'new' declaration, which is either itself just
12274 // the named decl, or the important information we need about it in order to
12275 // do constraint comparisons.
12277 const NamedDecl *ND = nullptr;
12278 const DeclContext *DC = nullptr;
12279 const DeclContext *LexicalDC = nullptr;
12280 SourceLocation Loc;
12281
12282 public:
12285 const DeclContext *LexicalDeclCtx,
12286 SourceLocation Loc)
12287
12288 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
12289 assert(DC && LexicalDC &&
12290 "Constructor only for cases where we have the information to put "
12291 "in here");
12292 }
12293
12294 // If this was constructed with no information, we cannot do substitution
12295 // for constraint comparison, so make sure we can check that.
12296 bool isInvalid() const { return !ND && !DC; }
12297
12298 const NamedDecl *getDecl() const { return ND; }
12299
12300 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
12301
12303 return ND ? ND->getLexicalDeclContext() : LexicalDC;
12304 }
12305
12307 return ND ? ND->getDeclContext() : DC;
12308 }
12309
12310 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
12311 };
12312
12313 /// Determine whether the given template parameter lists are
12314 /// equivalent.
12315 ///
12316 /// \param New The new template parameter list, typically written in the
12317 /// source code as part of a new template declaration.
12318 ///
12319 /// \param Old The old template parameter list, typically found via
12320 /// name lookup of the template declared with this template parameter
12321 /// list.
12322 ///
12323 /// \param Complain If true, this routine will produce a diagnostic if
12324 /// the template parameter lists are not equivalent.
12325 ///
12326 /// \param Kind describes how we are to match the template parameter lists.
12327 ///
12328 /// \param TemplateArgLoc If this source location is valid, then we
12329 /// are actually checking the template parameter list of a template
12330 /// argument (New) against the template parameter list of its
12331 /// corresponding template template parameter (Old). We produce
12332 /// slightly different diagnostics in this scenario.
12333 ///
12334 /// \returns True if the template parameter lists are equal, false
12335 /// otherwise.
12337 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
12338 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
12340 SourceLocation TemplateArgLoc = SourceLocation());
12341
12343 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
12345 SourceLocation TemplateArgLoc = SourceLocation()) {
12346 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
12347 Kind, TemplateArgLoc);
12348 }
12349
12350 /// Check whether a template can be declared within this scope.
12351 ///
12352 /// If the template declaration is valid in this scope, returns
12353 /// false. Otherwise, issues a diagnostic and returns true.
12354 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
12355
12356 /// Called when the parser has parsed a C++ typename
12357 /// specifier, e.g., "typename T::type".
12358 ///
12359 /// \param S The scope in which this typename type occurs.
12360 /// \param TypenameLoc the location of the 'typename' keyword
12361 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12362 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
12363 /// \param IdLoc the location of the identifier.
12364 /// \param IsImplicitTypename context where T::type refers to a type.
12366 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
12367 const IdentifierInfo &II, SourceLocation IdLoc,
12369
12370 /// Called when the parser has parsed a C++ typename
12371 /// specifier that ends in a template-id, e.g.,
12372 /// "typename MetaFun::template apply<T1, T2>".
12373 ///
12374 /// \param S The scope in which this typename type occurs.
12375 /// \param TypenameLoc the location of the 'typename' keyword
12376 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12377 /// \param TemplateLoc the location of the 'template' keyword, if any.
12378 /// \param TemplateName The template name.
12379 /// \param TemplateII The identifier used to name the template.
12380 /// \param TemplateIILoc The location of the template name.
12381 /// \param LAngleLoc The location of the opening angle bracket ('<').
12382 /// \param TemplateArgs The template arguments.
12383 /// \param RAngleLoc The location of the closing angle bracket ('>').
12385 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
12386 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
12387 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
12388 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
12389 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
12390
12392 SourceLocation KeywordLoc,
12393 NestedNameSpecifierLoc QualifierLoc,
12394 const IdentifierInfo &II, SourceLocation IILoc,
12395 TypeSourceInfo **TSI, bool DeducedTSTContext);
12396
12398 SourceLocation KeywordLoc,
12399 NestedNameSpecifierLoc QualifierLoc,
12400 const IdentifierInfo &II, SourceLocation IILoc,
12401 bool DeducedTSTContext = true);
12402
12403 /// Rebuilds a type within the context of the current instantiation.
12404 ///
12405 /// The type \p T is part of the type of an out-of-line member definition of
12406 /// a class template (or class template partial specialization) that was
12407 /// parsed and constructed before we entered the scope of the class template
12408 /// (or partial specialization thereof). This routine will rebuild that type
12409 /// now that we have entered the declarator's scope, which may produce
12410 /// different canonical types, e.g.,
12411 ///
12412 /// \code
12413 /// template<typename T>
12414 /// struct X {
12415 /// typedef T* pointer;
12416 /// pointer data();
12417 /// };
12418 ///
12419 /// template<typename T>
12420 /// typename X<T>::pointer X<T>::data() { ... }
12421 /// \endcode
12422 ///
12423 /// Here, the type "typename X<T>::pointer" will be created as a
12424 /// DependentNameType, since we do not know that we can look into X<T> when we
12425 /// parsed the type. This function will rebuild the type, performing the
12426 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
12427 /// canonical type is the same as the canonical type of T*, allowing the
12428 /// return types of the out-of-line definition and the declaration to match.
12430 SourceLocation Loc,
12431 DeclarationName Name);
12433
12435
12436 /// Rebuild the template parameters now that we know we're in a current
12437 /// instantiation.
12438 bool
12440
12441 /// Produces a formatted string that describes the binding of
12442 /// template parameters to template arguments.
12443 std::string
12445 const TemplateArgumentList &Args);
12446
12447 std::string
12449 const TemplateArgument *Args,
12450 unsigned NumArgs);
12451
12455
12456 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12457 /// was just parsed. This is only possible with an explicit scope
12458 /// specifier naming a dependent type.
12460 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12461 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12462 const TemplateArgumentListInfo *TemplateArgs);
12463
12466 SourceLocation TemplateKWLoc,
12467 const DeclarationNameInfo &NameInfo,
12468 const TemplateArgumentListInfo *TemplateArgs);
12469
12470 // Calculates whether the expression Constraint depends on an enclosing
12471 // template, for the purposes of [temp.friend] p9.
12472 // TemplateDepth is the 'depth' of the friend function, which is used to
12473 // compare whether a declaration reference is referring to a containing
12474 // template, or just the current friend function. A 'lower' TemplateDepth in
12475 // the AST refers to a 'containing' template. As the constraint is
12476 // uninstantiated, this is relative to the 'top' of the TU.
12477 bool
12479 unsigned TemplateDepth,
12480 const Expr *Constraint);
12481
12482 /// Find the failed Boolean condition within a given Boolean
12483 /// constant expression, and describe it with a string.
12484 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12485
12487
12489 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12490 const IdentifierInfo *Name, SourceLocation NameLoc);
12491
12493 Expr *ConstraintExpr,
12494 const ParsedAttributesView &Attrs);
12495
12497 bool &AddToScope);
12499
12500 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12501 const CXXScopeSpec &SS,
12502 const IdentifierInfo *Name,
12503 SourceLocation TagLoc, SourceLocation NameLoc);
12504
12506 CachedTokens &Toks);
12509
12510 /// We've found a use of a templated declaration that would trigger an
12511 /// implicit instantiation. Check that any relevant explicit specializations
12512 /// and partial specializations are visible/reachable, and diagnose if not.
12515
12516 ///@}
12517
12518 //
12519 //
12520 // -------------------------------------------------------------------------
12521 //
12522 //
12523
12524 /// \name C++ Template Argument Deduction
12525 /// Implementations are in SemaTemplateDeduction.cpp
12526 ///@{
12527
12528public:
12529 class SFINAETrap;
12530
12533 : S(S), Prev(std::exchange(S.CurrentSFINAEContext, Cur)) {}
12534
12535 protected:
12537 ~SFINAEContextBase() { S.CurrentSFINAEContext = Prev; }
12540
12541 private:
12542 SFINAETrap *Prev;
12543 };
12544
12548
12549 /// RAII class used to determine whether SFINAE has
12550 /// trapped any errors that occur during template argument
12551 /// deduction.
12552 class SFINAETrap : SFINAEContextBase {
12553 bool HasErrorOcurred = false;
12554 bool WithAccessChecking = false;
12555 bool PrevLastDiagnosticIgnored =
12556 S.getDiagnostics().isLastDiagnosticIgnored();
12557 sema::TemplateDeductionInfo *DeductionInfo = nullptr;
12558
12559 SFINAETrap(Sema &S, sema::TemplateDeductionInfo *Info,
12560 bool WithAccessChecking)
12561 : SFINAEContextBase(S, this), WithAccessChecking(WithAccessChecking),
12562 DeductionInfo(Info) {}
12563
12564 public:
12565 /// \param WithAccessChecking If true, discard all diagnostics (from the
12566 /// immediate context) instead of adding them to the currently active
12567 /// \ref TemplateDeductionInfo.
12568 explicit SFINAETrap(Sema &S, bool WithAccessChecking = false)
12569 : SFINAETrap(S, /*Info=*/nullptr, WithAccessChecking) {}
12570
12572 : SFINAETrap(S, &Info, /*WithAccessChecking=*/false) {}
12573
12575 S.getDiagnostics().setLastDiagnosticIgnored(PrevLastDiagnosticIgnored);
12576 }
12577
12578 SFINAETrap(const SFINAETrap &) = delete;
12579 SFINAETrap &operator=(const SFINAETrap &) = delete;
12580
12582 return DeductionInfo;
12583 }
12584
12585 /// Determine whether any SFINAE errors have been trapped.
12586 bool hasErrorOccurred() const { return HasErrorOcurred; }
12587 void setErrorOccurred() { HasErrorOcurred = true; }
12588
12589 bool withAccessChecking() const { return WithAccessChecking; }
12590 };
12591
12592 /// RAII class used to indicate that we are performing provisional
12593 /// semantic analysis to determine the validity of a construct, so
12594 /// typo-correction and diagnostics in the immediate context (not within
12595 /// implicitly-instantiated templates) should be suppressed.
12597 Sema &SemaRef;
12598 // FIXME: Using a SFINAETrap for this is a hack.
12599 SFINAETrap Trap;
12600 bool PrevDisableTypoCorrection;
12601
12602 public:
12603 explicit TentativeAnalysisScope(Sema &SemaRef)
12604 : SemaRef(SemaRef), Trap(SemaRef, /*ForValidityCheck=*/true),
12605 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12606 SemaRef.DisableTypoCorrection = true;
12607 }
12609 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12610 }
12611
12614 };
12615
12616 /// For each declaration that involved template argument deduction, the
12617 /// set of diagnostics that were suppressed during that template argument
12618 /// deduction.
12619 ///
12620 /// FIXME: Serialize this structure to the AST file.
12621 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12624
12625 /// Compare types for equality with respect to possibly compatible
12626 /// function types (noreturn adjustment, implicit calling conventions). If any
12627 /// of parameter and argument is not a function, just perform type comparison.
12628 ///
12629 /// \param P the template parameter type.
12630 ///
12631 /// \param A the argument type.
12633
12634 /// Allocate a TemplateArgumentLoc where all locations have
12635 /// been initialized to the given location.
12636 ///
12637 /// \param Arg The template argument we are producing template argument
12638 /// location information for.
12639 ///
12640 /// \param NTTPType For a declaration template argument, the type of
12641 /// the non-type template parameter that corresponds to this template
12642 /// argument. Can be null if no type sugar is available to add to the
12643 /// type from the template argument.
12644 ///
12645 /// \param Loc The source location to use for the resulting template
12646 /// argument.
12649 SourceLocation Loc,
12650 NamedDecl *TemplateParam = nullptr);
12651
12652 /// Get a template argument mapping the given template parameter to itself,
12653 /// e.g. for X in \c template<int X>, this would return an expression template
12654 /// argument referencing X.
12656 SourceLocation Location);
12657
12658 /// Adjust the type \p ArgFunctionType to match the calling convention,
12659 /// noreturn, and optionally the exception specification of \p FunctionType.
12660 /// Deduction often wants to ignore these properties when matching function
12661 /// types.
12663 bool AdjustExceptionSpec = false);
12664
12667 ArrayRef<TemplateArgument> TemplateArgs,
12669
12672 ArrayRef<TemplateArgument> TemplateArgs,
12674
12675 /// Deduce the template arguments of the given template from \p FromType.
12676 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12677 /// [over.match.class.deduct]p4.
12678 ///
12679 /// It only supports class or type alias templates.
12683
12688 bool NumberOfArgumentsMustMatch);
12689
12690 /// Substitute the explicitly-provided template arguments into the
12691 /// given function template according to C++ [temp.arg.explicit].
12692 ///
12693 /// \param FunctionTemplate the function template into which the explicit
12694 /// template arguments will be substituted.
12695 ///
12696 /// \param ExplicitTemplateArgs the explicitly-specified template
12697 /// arguments.
12698 ///
12699 /// \param Deduced the deduced template arguments, which will be populated
12700 /// with the converted and checked explicit template arguments.
12701 ///
12702 /// \param ParamTypes will be populated with the instantiated function
12703 /// parameters.
12704 ///
12705 /// \param FunctionType if non-NULL, the result type of the function template
12706 /// will also be instantiated and the pointed-to value will be updated with
12707 /// the instantiated function type.
12708 ///
12709 /// \param Info if substitution fails for any reason, this object will be
12710 /// populated with more information about the failure.
12711 ///
12712 /// \returns TemplateDeductionResult::Success if substitution was successful,
12713 /// or some failure condition.
12716 TemplateArgumentListInfo &ExplicitTemplateArgs,
12720
12721 /// brief A function argument from which we performed template argument
12722 // deduction for a call.
12735
12736 /// Finish template argument deduction for a function template,
12737 /// checking the deduced template arguments for completeness and forming
12738 /// the function template specialization.
12739 ///
12740 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12741 /// which the deduced argument types should be compared.
12742 /// \param CheckNonDependent Callback before substituting into the declaration
12743 /// with the deduced template arguments.
12744 /// \param OnlyInitializeNonUserDefinedConversions is used as a workaround for
12745 /// some breakages introduced by CWG2369, where non-user-defined conversions
12746 /// are checked first before the constraints.
12750 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12752 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12753 bool PartialOverloading, bool PartialOrdering,
12754 bool ForOverloadSetAddressResolution,
12755 llvm::function_ref<bool(bool)> CheckNonDependent =
12756 [](bool /*OnlyInitializeNonUserDefinedConversions*/) {
12757 return false;
12758 });
12759
12760 /// Perform template argument deduction from a function call
12761 /// (C++ [temp.deduct.call]).
12762 ///
12763 /// \param FunctionTemplate the function template for which we are performing
12764 /// template argument deduction.
12765 ///
12766 /// \param ExplicitTemplateArgs the explicit template arguments provided
12767 /// for this call.
12768 ///
12769 /// \param Args the function call arguments
12770 ///
12771 /// \param Specialization if template argument deduction was successful,
12772 /// this will be set to the function template specialization produced by
12773 /// template argument deduction.
12774 ///
12775 /// \param Info the argument will be updated to provide additional information
12776 /// about template argument deduction.
12777 ///
12778 /// \param CheckNonDependent A callback to invoke to check conversions for
12779 /// non-dependent parameters, between deduction and substitution, per DR1391.
12780 /// If this returns true, substitution will be skipped and we return
12781 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12782 /// passed the parameter types (after substituting explicit template
12783 /// arguments).
12784 ///
12785 /// \returns the result of template argument deduction.
12788 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12790 bool PartialOverloading, bool AggregateDeductionCandidate,
12791 bool PartialOrdering, QualType ObjectType,
12792 Expr::Classification ObjectClassification,
12793 bool ForOverloadSetAddressResolution,
12794 llvm::function_ref<bool(ArrayRef<QualType>, bool)> CheckNonDependent);
12795
12796 /// Deduce template arguments when taking the address of a function
12797 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12798 /// a template.
12799 ///
12800 /// \param FunctionTemplate the function template for which we are performing
12801 /// template argument deduction.
12802 ///
12803 /// \param ExplicitTemplateArgs the explicitly-specified template
12804 /// arguments.
12805 ///
12806 /// \param ArgFunctionType the function type that will be used as the
12807 /// "argument" type (A) when performing template argument deduction from the
12808 /// function template's function type. This type may be NULL, if there is no
12809 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12810 ///
12811 /// \param Specialization if template argument deduction was successful,
12812 /// this will be set to the function template specialization produced by
12813 /// template argument deduction.
12814 ///
12815 /// \param Info the argument will be updated to provide additional information
12816 /// about template argument deduction.
12817 ///
12818 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12819 /// the address of a function template per [temp.deduct.funcaddr] and
12820 /// [over.over]. If \c false, we are looking up a function template
12821 /// specialization based on its signature, per [temp.deduct.decl].
12822 ///
12823 /// \returns the result of template argument deduction.
12826 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12828 bool IsAddressOfFunction = false);
12829
12830 /// Deduce template arguments for a templated conversion
12831 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12832 /// conversion function template specialization.
12835 Expr::Classification ObjectClassification, QualType ToType,
12837
12838 /// Deduce template arguments for a function template when there is
12839 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12840 ///
12841 /// \param FunctionTemplate the function template for which we are performing
12842 /// template argument deduction.
12843 ///
12844 /// \param ExplicitTemplateArgs the explicitly-specified template
12845 /// arguments.
12846 ///
12847 /// \param Specialization if template argument deduction was successful,
12848 /// this will be set to the function template specialization produced by
12849 /// template argument deduction.
12850 ///
12851 /// \param Info the argument will be updated to provide additional information
12852 /// about template argument deduction.
12853 ///
12854 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12855 /// the address of a function template in a context where we do not have a
12856 /// target type, per [over.over]. If \c false, we are looking up a function
12857 /// template specialization based on its signature, which only happens when
12858 /// deducing a function parameter type from an argument that is a template-id
12859 /// naming a function template specialization.
12860 ///
12861 /// \returns the result of template argument deduction.
12864 TemplateArgumentListInfo *ExplicitTemplateArgs,
12867 bool IsAddressOfFunction = false);
12868
12869 /// Substitute Replacement for \p auto in \p TypeWithAuto
12870 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12871 /// Substitute Replacement for auto in TypeWithAuto
12873 QualType Replacement);
12874
12875 // Substitute auto in TypeWithAuto for a Dependent auto type
12877
12878 // Substitute auto in TypeWithAuto for a Dependent auto type
12881
12882 /// Completely replace the \c auto in \p TypeWithAuto by
12883 /// \p Replacement. This does not retain any \c auto type sugar.
12884 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12886 QualType Replacement);
12887
12888 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12889 ///
12890 /// Note that this is done even if the initializer is dependent. (This is
12891 /// necessary to support partial ordering of templates using 'auto'.)
12892 /// A dependent type will be produced when deducing from a dependent type.
12893 ///
12894 /// \param Type the type pattern using the auto type-specifier.
12895 /// \param Init the initializer for the variable whose type is to be deduced.
12896 /// \param Result if type deduction was successful, this will be set to the
12897 /// deduced type.
12898 /// \param Info the argument will be updated to provide additional information
12899 /// about template argument deduction.
12900 /// \param DependentDeduction Set if we should permit deduction in
12901 /// dependent cases. This is necessary for template partial ordering
12902 /// with 'auto' template parameters. The template parameter depth to be
12903 /// used should be specified in the 'Info' parameter.
12904 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12905 /// does not satisfy the type-constraint in the auto
12906 /// type.
12910 bool DependentDeduction = false,
12911 bool IgnoreConstraints = false,
12912 TemplateSpecCandidateSet *FailedTSC = nullptr);
12913 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12915 bool Diagnose = true);
12916
12918 SourceLocation Loc);
12919
12920 /// Returns the more specialized class template partial specialization
12921 /// according to the rules of partial ordering of class template partial
12922 /// specializations (C++ [temp.class.order]).
12923 ///
12924 /// \param PS1 the first class template partial specialization
12925 ///
12926 /// \param PS2 the second class template partial specialization
12927 ///
12928 /// \returns the more specialized class template partial specialization. If
12929 /// neither partial specialization is more specialized, returns NULL.
12934
12937
12941
12944
12946 TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
12947 const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
12948 bool PartialOrdering, bool *StrictPackMatch);
12949
12950 /// Mark which template parameters are used in a given expression.
12951 ///
12952 /// \param E the expression from which template parameters will be deduced.
12953 ///
12954 /// \param Used a bit vector whose elements will be set to \c true
12955 /// to indicate when the corresponding template parameter will be
12956 /// deduced.
12957 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12958 unsigned Depth, llvm::SmallBitVector &Used);
12959
12960 /// Mark which template parameters are named in a given expression.
12961 ///
12962 /// Unlike MarkUsedTemplateParameters, this excludes parameter that
12963 /// are used but not directly named by an expression - i.e. it excludes
12964 /// any template parameter that denotes the type of a referenced NTTP.
12965 ///
12966 /// \param Used a bit vector whose elements will be set to \c true
12967 /// to indicate when the corresponding template parameter will be
12968 /// deduced.
12970 const Expr *E, unsigned Depth, llvm::SmallBitVector &Used);
12971
12972 /// Mark which template parameters can be deduced from a given
12973 /// template argument list.
12974 ///
12975 /// \param TemplateArgs the template argument list from which template
12976 /// parameters will be deduced.
12977 ///
12978 /// \param Used a bit vector whose elements will be set to \c true
12979 /// to indicate when the corresponding template parameter will be
12980 /// deduced.
12981 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
12982 bool OnlyDeduced, unsigned Depth,
12983 llvm::SmallBitVector &Used);
12984
12986 unsigned Depth, llvm::SmallBitVector &Used);
12987
12989 unsigned Depth, llvm::SmallBitVector &Used);
12990
12991 void
12996
12997 /// Marks all of the template parameters that will be deduced by a
12998 /// call to the given function template.
12999 static void
13002 llvm::SmallBitVector &Deduced);
13003
13004 /// Returns the more specialized function template according
13005 /// to the rules of function template partial ordering (C++
13006 /// [temp.func.order]).
13007 ///
13008 /// \param FT1 the first function template
13009 ///
13010 /// \param FT2 the second function template
13011 ///
13012 /// \param TPOC the context in which we are performing partial ordering of
13013 /// function templates.
13014 ///
13015 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
13016 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
13017 /// when calling a member function.
13018 ///
13019 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
13020 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
13021 /// template from a member function
13022 ///
13023 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
13024 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
13025 /// template from a member function
13026 ///
13027 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
13028 /// candidate with a reversed parameter order. In this case, the corresponding
13029 /// P/A pairs between FT1 and FT2 are reversed.
13030 ///
13031 /// \returns the more specialized function template. If neither
13032 /// template is more specialized, returns NULL.
13035 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
13036 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false,
13037 bool PartialOverloading = false);
13038
13039 /// Retrieve the most specialized of the given function template
13040 /// specializations.
13041 ///
13042 /// \param SpecBegin the start iterator of the function template
13043 /// specializations that we will be comparing.
13044 ///
13045 /// \param SpecEnd the end iterator of the function template
13046 /// specializations, paired with \p SpecBegin.
13047 ///
13048 /// \param Loc the location where the ambiguity or no-specializations
13049 /// diagnostic should occur.
13050 ///
13051 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
13052 /// no matching candidates.
13053 ///
13054 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
13055 /// occurs.
13056 ///
13057 /// \param CandidateDiag partial diagnostic used for each function template
13058 /// specialization that is a candidate in the ambiguous ordering. One
13059 /// parameter in this diagnostic should be unbound, which will correspond to
13060 /// the string describing the template arguments for the function template
13061 /// specialization.
13062 ///
13063 /// \returns the most specialized function template specialization, if
13064 /// found. Otherwise, returns SpecEnd.
13065 UnresolvedSetIterator
13066 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
13067 TemplateSpecCandidateSet &FailedCandidates,
13068 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
13069 const PartialDiagnostic &AmbigDiag,
13070 const PartialDiagnostic &CandidateDiag,
13071 bool Complain = true, QualType TargetType = QualType());
13072
13073 /// Returns the more constrained function according to the rules of
13074 /// partial ordering by constraints (C++ [temp.constr.order]).
13075 ///
13076 /// \param FD1 the first function
13077 ///
13078 /// \param FD2 the second function
13079 ///
13080 /// \returns the more constrained function. If neither function is
13081 /// more constrained, returns NULL.
13082 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
13083 FunctionDecl *FD2);
13084
13085 ///@}
13086
13087 //
13088 //
13089 // -------------------------------------------------------------------------
13090 //
13091 //
13092
13093 /// \name C++ Template Deduction Guide
13094 /// Implementations are in SemaTemplateDeductionGuide.cpp
13095 ///@{
13096
13097 /// Declare implicit deduction guides for a class template if we've
13098 /// not already done so.
13099 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
13100 SourceLocation Loc);
13101
13102 CXXDeductionGuideDecl *DeclareAggregateDeductionGuideFromInitList(
13103 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
13104 SourceLocation Loc);
13105
13106 ///@}
13107
13108 //
13109 //
13110 // -------------------------------------------------------------------------
13111 //
13112 //
13113
13114 /// \name C++ Template Instantiation
13115 /// Implementations are in SemaTemplateInstantiate.cpp
13116 ///@{
13117
13118public:
13119 /// A helper class for building up ExtParameterInfos.
13122 bool HasInteresting = false;
13123
13124 public:
13125 /// Set the ExtParameterInfo for the parameter at the given index,
13126 ///
13128 assert(Infos.size() <= index);
13129 Infos.resize(index);
13130 Infos.push_back(info);
13131
13132 if (!HasInteresting)
13133 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
13134 }
13135
13136 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
13137 /// ExtParameterInfo array we've built up.
13139 getPointerOrNull(unsigned numParams) {
13140 if (!HasInteresting)
13141 return nullptr;
13142 Infos.resize(numParams);
13143 return Infos.data();
13144 }
13145 };
13146
13147 /// The current instantiation scope used to store local
13148 /// variables.
13150
13151 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
13153
13154 /// A mapping from parameters with unparsed default arguments to the
13155 /// set of instantiations of each parameter.
13156 ///
13157 /// This mapping is a temporary data structure used when parsing
13158 /// nested class templates or nested classes of class templates,
13159 /// where we might end up instantiating an inner class before the
13160 /// default arguments of its methods have been parsed.
13162
13163 using InstantiatingSpecializationsKey = llvm::PointerIntPair<Decl *, 2>;
13164
13171
13173 : S(S), Key(D->getCanonicalDecl(), unsigned(Kind)) {
13174 auto [_, Created] = S.InstantiatingSpecializations.insert(Key);
13175 if (!Created)
13176 Key = {};
13177 }
13178
13180 if (Key.getOpaqueValue()) {
13181 [[maybe_unused]] bool Erased =
13182 S.InstantiatingSpecializations.erase(Key);
13183 assert(Erased);
13184 }
13185 }
13186
13189
13190 operator bool() const { return Key.getOpaqueValue() == nullptr; }
13191
13192 private:
13193 Sema &S;
13195 };
13196
13197 /// A context in which code is being synthesized (where a source location
13198 /// alone is not sufficient to identify the context). This covers template
13199 /// instantiation and various forms of implicitly-generated functions.
13201 /// The kind of template instantiation we are performing
13203 /// We are instantiating a template declaration. The entity is
13204 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
13206
13207 /// We are instantiating a default argument for a template
13208 /// parameter. The Entity is the template parameter whose argument is
13209 /// being instantiated, the Template is the template, and the
13210 /// TemplateArgs/NumTemplateArguments provide the template arguments as
13211 /// specified.
13213
13214 /// We are instantiating a default argument for a function.
13215 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
13216 /// provides the template arguments as specified.
13218
13219 /// We are substituting explicit template arguments provided for
13220 /// a function template. The entity is a FunctionTemplateDecl.
13222
13223 /// We are substituting template argument determined as part of
13224 /// template argument deduction for either a class template
13225 /// partial specialization or a function template. The
13226 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
13227 /// a TemplateDecl.
13229
13230 /// We are substituting into a lambda expression.
13232
13233 /// We are substituting prior template arguments into a new
13234 /// template parameter. The template parameter itself is either a
13235 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
13237
13238 /// We are checking the validity of a default template argument that
13239 /// has been used when naming a template-id.
13241
13242 /// We are computing the exception specification for a defaulted special
13243 /// member function.
13245
13246 /// We are instantiating the exception specification for a function
13247 /// template which was deferred until it was needed.
13249
13250 /// We are instantiating a requirement of a requires expression.
13252
13253 /// We are checking the satisfaction of a nested requirement of a requires
13254 /// expression.
13256
13257 /// We are declaring an implicit special member function.
13259
13260 /// We are declaring an implicit 'operator==' for a defaulted
13261 /// 'operator<=>'.
13263
13264 /// We are defining a synthesized function (such as a defaulted special
13265 /// member).
13267
13268 // We are checking the constraints associated with a constrained entity or
13269 // the constraint expression of a concept. This includes the checks that
13270 // atomic constraints have the type 'bool' and that they can be constant
13271 // evaluated.
13273
13274 // We are substituting template arguments into a constraint expression.
13276
13277 // Instantiating a Requires Expression parameter clause.
13279
13280 // We are substituting into the parameter mapping of an atomic constraint
13281 // during normalization.
13283
13284 /// We are rewriting a comparison operator in terms of an operator<=>.
13286
13287 /// We are initializing a structured binding.
13289
13290 /// We are marking a class as __dllexport.
13292
13293 /// We are building an implied call from __builtin_dump_struct. The
13294 /// arguments are in CallArgs.
13296
13297 /// Added for Template instantiation observation.
13298 /// Memoization means we are _not_ instantiating a template because
13299 /// it is already instantiated (but we entered a context where we
13300 /// would have had to if it was not already instantiated).
13302
13303 /// We are building deduction guides for a class.
13305
13306 /// We are instantiating a type alias template declaration.
13308
13309 /// We are performing partial ordering for template template parameters.
13311
13312 /// We are performing name lookup for a function template or variable
13313 /// template named 'sycl_kernel_launch'.
13315
13316 /// We are performing overload resolution for a call to a function
13317 /// template or variable template named 'sycl_kernel_launch'.
13319 } Kind;
13320
13321 /// Whether we're substituting into constraints.
13323
13324 /// Whether we're substituting into the parameter mapping of a constraint.
13326
13327 /// The point of instantiation or synthesis within the source code.
13329
13330 /// The entity that is being synthesized.
13332
13333 /// The template (or partial specialization) in which we are
13334 /// performing the instantiation, for substitutions of prior template
13335 /// arguments.
13337
13338 union {
13339 /// The list of template arguments we are substituting, if they
13340 /// are not part of the entity.
13342
13343 /// The list of argument expressions in a synthesized call.
13344 const Expr *const *CallArgs;
13345 };
13346
13347 // FIXME: Wrap this union around more members, or perhaps store the
13348 // kind-specific members in the RAII object owning the context.
13349 union {
13350 /// The number of template arguments in TemplateArgs.
13352
13353 /// The number of expressions in CallArgs.
13354 unsigned NumCallArgs;
13355
13356 /// The special member being declared or defined.
13358 };
13359
13364
13365 /// The source range that covers the construct that cause
13366 /// the instantiation, e.g., the template-id that causes a class
13367 /// template instantiation.
13369
13374
13375 /// Determines whether this template is an actual instantiation
13376 /// that should be counted toward the maximum instantiation depth.
13377 bool isInstantiationRecord() const;
13378 };
13379
13380 /// A stack object to be created when performing template
13381 /// instantiation.
13382 ///
13383 /// Construction of an object of type \c InstantiatingTemplate
13384 /// pushes the current instantiation onto the stack of active
13385 /// instantiations. If the size of this stack exceeds the maximum
13386 /// number of recursive template instantiations, construction
13387 /// produces an error and evaluates true.
13388 ///
13389 /// Destruction of this object will pop the named instantiation off
13390 /// the stack.
13392 /// Note that we are instantiating a class template,
13393 /// function template, variable template, alias template,
13394 /// or a member thereof.
13395 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13396 Decl *Entity,
13397 SourceRange InstantiationRange = SourceRange());
13398
13400 /// Note that we are instantiating an exception specification
13401 /// of a function template.
13402 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13404 SourceRange InstantiationRange = SourceRange());
13405
13406 /// Note that we are instantiating a type alias template declaration.
13407 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13408 TypeAliasTemplateDecl *Entity,
13409 ArrayRef<TemplateArgument> TemplateArgs,
13410 SourceRange InstantiationRange = SourceRange());
13411
13412 /// Note that we are instantiating a default argument in a
13413 /// template-id.
13414 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13416 ArrayRef<TemplateArgument> TemplateArgs,
13417 SourceRange InstantiationRange = SourceRange());
13418
13419 /// Note that we are substituting either explicitly-specified or
13420 /// deduced template arguments during function template argument deduction.
13421 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13423 ArrayRef<TemplateArgument> TemplateArgs,
13425 SourceRange InstantiationRange = SourceRange());
13426
13427 /// Note that we are instantiating as part of template
13428 /// argument deduction for a class template declaration.
13429 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13431 ArrayRef<TemplateArgument> TemplateArgs,
13432 SourceRange InstantiationRange = SourceRange());
13433
13434 /// Note that we are instantiating as part of template
13435 /// argument deduction for a class template partial
13436 /// specialization.
13437 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13439 ArrayRef<TemplateArgument> TemplateArgs,
13440 SourceRange InstantiationRange = SourceRange());
13441
13442 /// Note that we are instantiating as part of template
13443 /// argument deduction for a variable template partial
13444 /// specialization.
13445 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13447 ArrayRef<TemplateArgument> TemplateArgs,
13448 SourceRange InstantiationRange = SourceRange());
13449
13450 /// Note that we are instantiating a default argument for a function
13451 /// parameter.
13452 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13453 ParmVarDecl *Param,
13454 ArrayRef<TemplateArgument> TemplateArgs,
13455 SourceRange InstantiationRange = SourceRange());
13456
13457 /// Note that we are substituting prior template arguments into a
13458 /// non-type parameter.
13459 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13461 ArrayRef<TemplateArgument> TemplateArgs,
13462 SourceRange InstantiationRange);
13463
13464 /// Note that we are substituting prior template arguments into a
13465 /// template template parameter.
13466 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13468 ArrayRef<TemplateArgument> TemplateArgs,
13469 SourceRange InstantiationRange);
13470
13471 /// Note that we are checking the default template argument
13472 /// against the template parameter for a given template-id.
13473 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13475 ArrayRef<TemplateArgument> TemplateArgs,
13476 SourceRange InstantiationRange);
13477
13479 /// \brief Note that we are checking the constraints associated with some
13480 /// constrained entity (a concept declaration or a template with associated
13481 /// constraints).
13482 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13484 ArrayRef<TemplateArgument> TemplateArgs,
13485 SourceRange InstantiationRange);
13486
13488 /// \brief Note that we are checking a constraint expression associated
13489 /// with a template declaration or as part of the satisfaction check of a
13490 /// concept.
13491 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13493 SourceRange InstantiationRange);
13494
13496 /// \brief Note that we are subtituting into the parameter mapping of an
13497 /// atomic constraint during constraint normalization.
13498 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13500 SourceRange InstantiationRange);
13501
13502 /// \brief Note that we are substituting template arguments into a part of
13503 /// a requirement of a requires expression.
13504 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13506 SourceRange InstantiationRange = SourceRange());
13507
13508 /// \brief Note that we are checking the satisfaction of the constraint
13509 /// expression inside of a nested requirement.
13510 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13512 SourceRange InstantiationRange = SourceRange());
13513
13514 /// \brief Note that we are checking a requires clause.
13515 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13516 const RequiresExpr *E,
13517 SourceRange InstantiationRange);
13518
13520 /// \brief Note that we are building deduction guides.
13521 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13523 SourceRange InstantiationRange = SourceRange());
13524
13526 /// \brief Note that we are partial ordering template template parameters.
13527 InstantiatingTemplate(Sema &SemaRef, SourceLocation ArgLoc,
13529 SourceRange InstantiationRange = SourceRange());
13530
13531 /// Note that we have finished instantiating this template.
13532 void Clear();
13533
13535
13536 /// Determines whether we have exceeded the maximum
13537 /// recursive template instantiations.
13538 bool isInvalid() const { return Invalid; }
13539
13540 private:
13541 Sema &SemaRef;
13542 bool Invalid;
13543
13546 SourceLocation PointOfInstantiation,
13547 SourceRange InstantiationRange, Decl *Entity,
13548 NamedDecl *Template = nullptr,
13549 ArrayRef<TemplateArgument> TemplateArgs = {});
13550
13552
13553 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13554 };
13555
13556 bool SubstTemplateArgument(const TemplateArgumentLoc &Input,
13557 const MultiLevelTemplateArgumentList &TemplateArgs,
13558 TemplateArgumentLoc &Output,
13559 SourceLocation Loc = {},
13560 const DeclarationName &Entity = {});
13561 bool
13562 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13563 const MultiLevelTemplateArgumentList &TemplateArgs,
13564 TemplateArgumentListInfo &Outputs);
13565
13566 /// Substitute concept template arguments in the constraint expression
13567 /// of a concept-id. This is used to implement [temp.constr.normal].
13569 SubstConceptTemplateArguments(const ConceptSpecializationExpr *CSE,
13570 const Expr *ConstraintExpr,
13571 const MultiLevelTemplateArgumentList &MLTAL);
13572
13574 ArrayRef<TemplateArgumentLoc> Args, SourceLocation BaseLoc,
13575 const MultiLevelTemplateArgumentList &TemplateArgs,
13576 TemplateArgumentListInfo &Out);
13577
13578 /// Retrieve the template argument list(s) that should be used to
13579 /// instantiate the definition of the given declaration.
13580 ///
13581 /// \param ND the declaration for which we are computing template
13582 /// instantiation arguments.
13583 ///
13584 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13585 /// the decl context where it will be created. In this case, the `Innermost`
13586 /// should likely be provided. If ND is non-null, this is ignored.
13587 ///
13588 /// \param Innermost if non-NULL, specifies a template argument list for the
13589 /// template declaration passed as ND.
13590 ///
13591 /// \param RelativeToPrimary true if we should get the template
13592 /// arguments relative to the primary template, even when we're
13593 /// dealing with a specialization. This is only relevant for function
13594 /// template specializations.
13595 ///
13596 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13597 /// instantiating the definition of the given declaration, \p ND. This is
13598 /// used to determine the proper set of template instantiation arguments for
13599 /// friend function template specializations.
13600 ///
13601 /// \param ForConstraintInstantiation when collecting arguments,
13602 /// ForConstraintInstantiation indicates we should continue looking when
13603 /// encountering a lambda generic call operator, and continue looking for
13604 /// arguments on an enclosing class template.
13605 ///
13606 /// \param SkipForSpecialization when specified, any template specializations
13607 /// in a traversal would be ignored.
13608 ///
13609 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13610 /// when encountering a specialized member function template, rather than
13611 /// returning immediately.
13612 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13613 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13614 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13615 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13616 bool ForConstraintInstantiation = false,
13617 bool SkipForSpecialization = false,
13618 bool ForDefaultArgumentSubstitution = false);
13619
13620 /// RAII object to handle the state changes required to synthesize
13621 /// a function body.
13623 Sema &S;
13624 Sema::ContextRAII SavedContext;
13625 bool PushedCodeSynthesisContext = false;
13626
13627 public:
13629 : S(S), SavedContext(S, DC) {
13630 auto *FD = dyn_cast<FunctionDecl>(DC);
13631 S.PushFunctionScope();
13632 S.PushExpressionEvaluationContextForFunction(
13634 if (FD)
13635 FD->setWillHaveBody(true);
13636 else
13637 assert(isa<ObjCMethodDecl>(DC));
13638 }
13639
13641 assert(!PushedCodeSynthesisContext);
13642
13645 Ctx.PointOfInstantiation = UseLoc;
13646 Ctx.Entity = cast<Decl>(S.CurContext);
13647 S.pushCodeSynthesisContext(Ctx);
13648
13649 PushedCodeSynthesisContext = true;
13650 }
13651
13653 if (PushedCodeSynthesisContext)
13654 S.popCodeSynthesisContext();
13655 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13656 FD->setWillHaveBody(false);
13657 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13658 }
13659 S.PopExpressionEvaluationContext();
13660 S.PopFunctionScopeInfo();
13661 }
13662
13666 };
13667
13668 /// RAII object to ensure that a code synthesis context is popped on scope
13669 /// exit.
13671 Sema &S;
13672
13673 public:
13675 : S(S) {
13676 S.pushCodeSynthesisContext(Ctx);
13677 }
13678
13679 ~ScopedCodeSynthesisContext() { S.popCodeSynthesisContext(); }
13683 };
13684
13685 /// List of active code synthesis contexts.
13686 ///
13687 /// This vector is treated as a stack. As synthesis of one entity requires
13688 /// synthesis of another, additional contexts are pushed onto the stack.
13690
13691 /// Specializations whose definitions are currently being instantiated.
13692 llvm::DenseSet<InstantiatingSpecializationsKey> InstantiatingSpecializations;
13693
13694 /// Non-dependent types used in templates that have already been instantiated
13695 /// by some template instantiation.
13696 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13697
13698 /// Extra modules inspected when performing a lookup during a template
13699 /// instantiation. Computed lazily.
13701
13702 /// Cache of additional modules that should be used for name lookup
13703 /// within the current template instantiation. Computed lazily; use
13704 /// getLookupModules() to get a complete set.
13705 llvm::DenseSet<Module *> LookupModulesCache;
13706
13707 /// Map from the most recent declaration of a namespace to the most
13708 /// recent visible declaration of that namespace.
13709 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13710
13712
13713 /// The number of \p CodeSynthesisContexts that are not template
13714 /// instantiations and, therefore, should not be counted as part of the
13715 /// instantiation depth.
13716 ///
13717 /// When the instantiation depth reaches the user-configurable limit
13718 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13719 // FIXME: Should we have a similar limit for other forms of synthesis?
13721
13722 /// The depth of the context stack at the point when the most recent
13723 /// error or warning was produced.
13724 ///
13725 /// This value is used to suppress printing of redundant context stacks
13726 /// when there are multiple errors or warnings in the same instantiation.
13727 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13729
13730 /// The template instantiation callbacks to trace or track
13731 /// instantiations (objects can be chained).
13732 ///
13733 /// This callbacks is used to print, trace or track template
13734 /// instantiations as they are being constructed.
13735 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
13737
13738 /// The current index into pack expansion arguments that will be
13739 /// used for substitution of parameter packs.
13740 ///
13741 /// The pack expansion index will be none to indicate that parameter packs
13742 /// should be instantiated as themselves. Otherwise, the index specifies
13743 /// which argument within the parameter pack will be used for substitution.
13745
13746 /// RAII object used to change the argument pack substitution index
13747 /// within a \c Sema object.
13748 ///
13749 /// See \c ArgPackSubstIndex for more information.
13751 Sema &Self;
13752 UnsignedOrNone OldSubstIndex;
13753
13754 public:
13756 : Self(Self),
13757 OldSubstIndex(std::exchange(Self.ArgPackSubstIndex, NewSubstIndex)) {}
13758
13759 ~ArgPackSubstIndexRAII() { Self.ArgPackSubstIndex = OldSubstIndex; }
13762 };
13763
13766
13777 /// Prints the current instantiation stack through a series of
13778 /// notes.
13783
13784 /// Returns a pointer to the current SFINAE context, if any.
13785 [[nodiscard]] SFINAETrap *getSFINAEContext() const {
13786 return CurrentSFINAEContext;
13787 }
13788 [[nodiscard]] bool isSFINAEContext() const {
13789 return CurrentSFINAEContext != nullptr;
13790 }
13791
13792 /// Perform substitution on the type T with a given set of template
13793 /// arguments.
13794 ///
13795 /// This routine substitutes the given template arguments into the
13796 /// type T and produces the instantiated type.
13797 ///
13798 /// \param T the type into which the template arguments will be
13799 /// substituted. If this type is not dependent, it will be returned
13800 /// immediately.
13801 ///
13802 /// \param Args the template arguments that will be
13803 /// substituted for the top-level template parameters within T.
13804 ///
13805 /// \param Loc the location in the source code where this substitution
13806 /// is being performed. It will typically be the location of the
13807 /// declarator (if we're instantiating the type of some declaration)
13808 /// or the location of the type in the source code (if, e.g., we're
13809 /// instantiating the type of a cast expression).
13810 ///
13811 /// \param Entity the name of the entity associated with a declaration
13812 /// being instantiated (if any). May be empty to indicate that there
13813 /// is no such entity (if, e.g., this is a type that occurs as part of
13814 /// a cast expression) or that the entity has no name (e.g., an
13815 /// unnamed function parameter).
13816 ///
13817 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13818 /// acceptable as the top level type of the result.
13819 ///
13820 /// \param IsIncompleteSubstitution If provided, the pointee will be set
13821 /// whenever substitution would perform a replacement with a null or
13822 /// non-existent template argument.
13823 ///
13824 /// \returns If the instantiation succeeds, the instantiated
13825 /// type. Otherwise, produces diagnostics and returns a NULL type.
13827 const MultiLevelTemplateArgumentList &TemplateArgs,
13828 SourceLocation Loc, DeclarationName Entity,
13829 bool AllowDeducedTST = false);
13830
13832 const MultiLevelTemplateArgumentList &TemplateArgs,
13833 SourceLocation Loc, DeclarationName Entity,
13834 bool *IsIncompleteSubstitution = nullptr);
13835
13837 const MultiLevelTemplateArgumentList &TemplateArgs,
13838 SourceLocation Loc, DeclarationName Entity);
13839
13840 /// A form of SubstType intended specifically for instantiating the
13841 /// type of a FunctionDecl. Its purpose is solely to force the
13842 /// instantiation of default-argument expressions and to avoid
13843 /// instantiating an exception-specification.
13845 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13846 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13847 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13849 const MultiLevelTemplateArgumentList &Args);
13852 SmallVectorImpl<QualType> &ExceptionStorage,
13853 const MultiLevelTemplateArgumentList &Args);
13854 ParmVarDecl *
13856 const MultiLevelTemplateArgumentList &TemplateArgs,
13857 int indexAdjustment, UnsignedOrNone NumExpansions,
13858 bool ExpectParameterPack, bool EvaluateConstraints = true);
13859
13860 /// Substitute the given template arguments into the given set of
13861 /// parameters, producing the set of parameter types that would be generated
13862 /// from such a substitution.
13864 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13865 const MultiLevelTemplateArgumentList &TemplateArgs,
13866 SmallVectorImpl<QualType> &ParamTypes,
13868 ExtParameterInfoBuilder &ParamInfos);
13869
13870 /// Substitute the given template arguments into the default argument.
13872 const MultiLevelTemplateArgumentList &TemplateArgs,
13873 bool ForCallExpr = false);
13875 const MultiLevelTemplateArgumentList &TemplateArgs);
13876 /// Substitute an expression as if it is a address-of-operand, which makes it
13877 /// act like a CXXIdExpression rather than an attempt to call.
13879 const MultiLevelTemplateArgumentList &TemplateArgs);
13880
13881 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
13882 // to disable constraint evaluation, then restore the state.
13883 template <typename InstTy> struct ConstraintEvalRAII {
13884 InstTy &TI;
13886
13888 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
13889 TI.setEvaluateConstraints(false);
13890 }
13891 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
13894 };
13895
13896 // Must be used instead of SubstExpr at 'constraint checking' time.
13899 const MultiLevelTemplateArgumentList &TemplateArgs);
13900 // Unlike the above, this does not evaluate constraints.
13902 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13903
13904 /// Substitute the given template arguments into a list of
13905 /// expressions, expanding pack expansions if required.
13906 ///
13907 /// \param Exprs The list of expressions to substitute into.
13908 ///
13909 /// \param IsCall Whether this is some form of call, in which case
13910 /// default arguments will be dropped.
13911 ///
13912 /// \param TemplateArgs The set of template arguments to substitute.
13913 ///
13914 /// \param Outputs Will receive all of the substituted arguments.
13915 ///
13916 /// \returns true if an error occurred, false otherwise.
13917 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13918 const MultiLevelTemplateArgumentList &TemplateArgs,
13919 SmallVectorImpl<Expr *> &Outputs);
13920
13922 const MultiLevelTemplateArgumentList &TemplateArgs);
13923
13926 bool CXXDirectInit);
13927
13928 /// Perform substitution on the base class specifiers of the
13929 /// given class template specialization.
13930 ///
13931 /// Produces a diagnostic and returns true on error, returns false and
13932 /// attaches the instantiated base classes to the class template
13933 /// specialization if successful.
13934 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13935 const MultiLevelTemplateArgumentList &TemplateArgs);
13936
13937 /// Instantiate the definition of a class from a given pattern.
13938 ///
13939 /// \param PointOfInstantiation The point of instantiation within the
13940 /// source code.
13941 ///
13942 /// \param Instantiation is the declaration whose definition is being
13943 /// instantiated. This will be either a class template specialization
13944 /// or a member class of a class template specialization.
13945 ///
13946 /// \param Pattern is the pattern from which the instantiation
13947 /// occurs. This will be either the declaration of a class template or
13948 /// the declaration of a member class of a class template.
13949 ///
13950 /// \param TemplateArgs The template arguments to be substituted into
13951 /// the pattern.
13952 ///
13953 /// \param TSK the kind of implicit or explicit instantiation to perform.
13954 ///
13955 /// \param Complain whether to complain if the class cannot be instantiated
13956 /// due to the lack of a definition.
13957 ///
13958 /// \returns true if an error occurred, false otherwise.
13959 bool InstantiateClass(SourceLocation PointOfInstantiation,
13960 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13961 const MultiLevelTemplateArgumentList &TemplateArgs,
13962 TemplateSpecializationKind TSK, bool Complain = true);
13963
13964private:
13965 bool InstantiateClassImpl(SourceLocation PointOfInstantiation,
13966 CXXRecordDecl *Instantiation,
13967 CXXRecordDecl *Pattern,
13968 const MultiLevelTemplateArgumentList &TemplateArgs,
13969 TemplateSpecializationKind TSK, bool Complain);
13970
13971public:
13972 /// Instantiate the definition of an enum from a given pattern.
13973 ///
13974 /// \param PointOfInstantiation The point of instantiation within the
13975 /// source code.
13976 /// \param Instantiation is the declaration whose definition is being
13977 /// instantiated. This will be a member enumeration of a class
13978 /// temploid specialization, or a local enumeration within a
13979 /// function temploid specialization.
13980 /// \param Pattern The templated declaration from which the instantiation
13981 /// occurs.
13982 /// \param TemplateArgs The template arguments to be substituted into
13983 /// the pattern.
13984 /// \param TSK The kind of implicit or explicit instantiation to perform.
13985 ///
13986 /// \return \c true if an error occurred, \c false otherwise.
13987 bool InstantiateEnum(SourceLocation PointOfInstantiation,
13988 EnumDecl *Instantiation, EnumDecl *Pattern,
13989 const MultiLevelTemplateArgumentList &TemplateArgs,
13991
13992 /// Instantiate the definition of a field from the given pattern.
13993 ///
13994 /// \param PointOfInstantiation The point of instantiation within the
13995 /// source code.
13996 /// \param Instantiation is the declaration whose definition is being
13997 /// instantiated. This will be a class of a class temploid
13998 /// specialization, or a local enumeration within a function temploid
13999 /// specialization.
14000 /// \param Pattern The templated declaration from which the instantiation
14001 /// occurs.
14002 /// \param TemplateArgs The template arguments to be substituted into
14003 /// the pattern.
14004 ///
14005 /// \return \c true if an error occurred, \c false otherwise.
14007 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
14008 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
14009
14011 SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
14012
14014 SourceLocation PointOfInstantiation,
14015 ClassTemplateSpecializationDecl *ClassTemplateSpec,
14016 TemplateSpecializationKind TSK, bool Complain,
14017 bool PrimaryStrictPackMatch);
14018
14019 /// Instantiates the definitions of all of the member
14020 /// of the given class, which is an instantiation of a class template
14021 /// or a member class of a template.
14022 void
14023 InstantiateClassMembers(SourceLocation PointOfInstantiation,
14024 CXXRecordDecl *Instantiation,
14025 const MultiLevelTemplateArgumentList &TemplateArgs,
14027
14028 /// Instantiate the definitions of all of the members of the
14029 /// given class template specialization, which was named as part of an
14030 /// explicit instantiation.
14032 SourceLocation PointOfInstantiation,
14033 ClassTemplateSpecializationDecl *ClassTemplateSpec,
14035
14038 const MultiLevelTemplateArgumentList &TemplateArgs);
14039
14040 /// Do template substitution on declaration name info.
14043 const MultiLevelTemplateArgumentList &TemplateArgs);
14045 SubstTemplateName(SourceLocation TemplateKWLoc,
14046 NestedNameSpecifierLoc &QualifierLoc, TemplateName Name,
14047 SourceLocation NameLoc,
14048 const MultiLevelTemplateArgumentList &TemplateArgs);
14049
14051 const MultiLevelTemplateArgumentList &TemplateArgs,
14052 bool EvaluateConstraint);
14053
14054 /// Determine whether we are currently performing template instantiation.
14057 }
14058
14059 /// Determine whether we are currently performing constraint substitution.
14061 return !CodeSynthesisContexts.empty() &&
14062 CodeSynthesisContexts.back().InConstraintSubstitution;
14063 }
14064
14066 return !CodeSynthesisContexts.empty() &&
14067 CodeSynthesisContexts.back().InParameterMappingSubstitution &&
14069 }
14070
14071 using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
14072
14073 /// \brief create a Requirement::SubstitutionDiagnostic with only a
14074 /// SubstitutedEntity and DiagLoc using ASTContext's allocator.
14077
14078 ///@}
14079
14080 //
14081 //
14082 // -------------------------------------------------------------------------
14083 //
14084 //
14085
14086 /// \name C++ Template Declaration Instantiation
14087 /// Implementations are in SemaTemplateInstantiateDecl.cpp
14088 ///@{
14089
14090public:
14091 /// An entity for which implicit template instantiation is required.
14092 ///
14093 /// The source location associated with the declaration is the first place in
14094 /// the source code where the declaration was "used". It is not necessarily
14095 /// the point of instantiation (which will be either before or after the
14096 /// namespace-scope declaration that triggered this implicit instantiation),
14097 /// However, it is the location that diagnostics should generally refer to,
14098 /// because users will need to know what code triggered the instantiation.
14099 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
14100
14101 /// The queue of implicit template instantiations that are required
14102 /// but have not yet been performed.
14103 std::deque<PendingImplicitInstantiation> PendingInstantiations;
14104
14105 /// Queue of implicit template instantiations that cannot be performed
14106 /// eagerly.
14108
14112
14113 /// The queue of implicit template instantiations that are required
14114 /// and must be performed within the current local scope.
14115 ///
14116 /// This queue is only used for member functions of local classes in
14117 /// templates, which must be instantiated in the same scope as their
14118 /// enclosing function, so that they can reference function-local
14119 /// types, static variables, enumerators, etc.
14120 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
14121
14123 public:
14125 : S(S), AtEndOfTU(AtEndOfTU) {
14126 SavedPendingLocalImplicitInstantiations.swap(
14127 S.PendingLocalImplicitInstantiations);
14128 }
14129
14130 void perform() {
14131 S.PerformPendingInstantiations(/*LocalOnly=*/true,
14132 /*AtEndOfTU=*/AtEndOfTU);
14133 }
14134
14136 assert(S.PendingLocalImplicitInstantiations.empty() &&
14137 "there shouldn't be any pending local implicit instantiations");
14138 SavedPendingLocalImplicitInstantiations.swap(
14139 S.PendingLocalImplicitInstantiations);
14140 }
14141
14145
14146 private:
14147 Sema &S;
14148 bool AtEndOfTU;
14149 std::deque<PendingImplicitInstantiation>
14150 SavedPendingLocalImplicitInstantiations;
14151 };
14152
14153 /// Records and restores the CurFPFeatures state on entry/exit of compound
14154 /// statements.
14156 public:
14161 FPOptionsOverride getOverrides() { return OldOverrides; }
14162
14163 private:
14164 Sema &S;
14165 FPOptions OldFPFeaturesState;
14166 FPOptionsOverride OldOverrides;
14167 LangOptions::FPEvalMethodKind OldEvalMethod;
14168 SourceLocation OldFPPragmaLocation;
14169 };
14170
14172 public:
14173 GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
14174 : S(S), Enabled(Enabled), AtEndOfTU(AtEndOfTU) {
14175 if (!Enabled)
14176 return;
14177
14178 S.SavedPendingInstantiations.emplace_back();
14179 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
14180
14181 S.SavedVTableUses.emplace_back();
14182 S.SavedVTableUses.back().swap(S.VTableUses);
14183 }
14184
14185 void perform() {
14186 if (Enabled) {
14187 S.DefineUsedVTables();
14188 S.PerformPendingInstantiations(/*LocalOnly=*/false,
14189 /*AtEndOfTU=*/AtEndOfTU);
14190 }
14191 }
14192
14194 if (!Enabled)
14195 return;
14196
14197 // Restore the set of pending vtables.
14198 assert(S.VTableUses.empty() &&
14199 "VTableUses should be empty before it is discarded.");
14200 S.VTableUses.swap(S.SavedVTableUses.back());
14201 S.SavedVTableUses.pop_back();
14202
14203 // Restore the set of pending implicit instantiations.
14204 if ((S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) &&
14205 AtEndOfTU) {
14206 assert(S.PendingInstantiations.empty() &&
14207 "PendingInstantiations should be empty before it is discarded.");
14208 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
14209 S.SavedPendingInstantiations.pop_back();
14210 } else {
14211 // Template instantiations in the PCH may be delayed until the TU.
14212 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
14213 S.PendingInstantiations.insert(
14214 S.PendingInstantiations.end(),
14215 S.SavedPendingInstantiations.back().begin(),
14216 S.SavedPendingInstantiations.back().end());
14217 S.SavedPendingInstantiations.pop_back();
14218 }
14219 }
14220
14222 delete;
14225
14226 private:
14227 Sema &S;
14228 bool Enabled;
14229 bool AtEndOfTU;
14230 };
14231
14233 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
14234
14245
14246 /// Recheck instantiated thread-safety attributes that could not be validated
14247 /// on the dependent pattern declaration.
14248 bool checkInstantiatedThreadSafetyAttrs(const Decl *D, const Attr *A);
14249
14250 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
14251 const Decl *Pattern, Decl *Inst,
14252 LateInstantiatedAttrVec *LateAttrs = nullptr,
14253 LocalInstantiationScope *OuterMostScope = nullptr);
14254
14255 /// Update instantiation attributes after template was late parsed.
14256 ///
14257 /// Some attributes are evaluated based on the body of template. If it is
14258 /// late parsed, such attributes cannot be evaluated when declaration is
14259 /// instantiated. This function is used to update instantiation attributes
14260 /// when template definition is ready.
14261 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
14262
14263 void
14265 const Decl *Pattern, Decl *Inst,
14266 LateInstantiatedAttrVec *LateAttrs = nullptr,
14267 LocalInstantiationScope *OuterMostScope = nullptr);
14268
14269 /// In the MS ABI, we need to instantiate default arguments of dllexported
14270 /// default constructors along with the constructor definition. This allows IR
14271 /// gen to emit a constructor closure which calls the default constructor with
14272 /// its default arguments.
14274
14276 ParmVarDecl *Param);
14277 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
14279
14280 /// Instantiate (or find existing instantiation of) a function template with a
14281 /// given set of template arguments.
14282 ///
14283 /// Usually this should not be used, and template argument deduction should be
14284 /// used in its place.
14287 SourceLocation Loc,
14290
14291 /// Instantiate the definition of the given function from its
14292 /// template.
14293 ///
14294 /// \param PointOfInstantiation the point at which the instantiation was
14295 /// required. Note that this is not precisely a "point of instantiation"
14296 /// for the function, but it's close.
14297 ///
14298 /// \param Function the already-instantiated declaration of a
14299 /// function template specialization or member function of a class template
14300 /// specialization.
14301 ///
14302 /// \param Recursive if true, recursively instantiates any functions that
14303 /// are required by this instantiation.
14304 ///
14305 /// \param DefinitionRequired if true, then we are performing an explicit
14306 /// instantiation where the body of the function is required. Complain if
14307 /// there is no such body.
14308 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
14310 bool Recursive = false,
14311 bool DefinitionRequired = false,
14312 bool AtEndOfTU = false);
14315 const TemplateArgumentList *PartialSpecArgs,
14317 SourceLocation PointOfInstantiation,
14318 LateInstantiatedAttrVec *LateAttrs = nullptr,
14319 LocalInstantiationScope *StartingScope = nullptr);
14320
14321 /// Instantiates a variable template specialization by completing it
14322 /// with appropriate type information and initializer.
14324 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
14325 const MultiLevelTemplateArgumentList &TemplateArgs);
14326
14327 /// BuildVariableInstantiation - Used after a new variable has been created.
14328 /// Sets basic variable data and decides whether to postpone the
14329 /// variable instantiation.
14330 void
14332 const MultiLevelTemplateArgumentList &TemplateArgs,
14333 LateInstantiatedAttrVec *LateAttrs,
14334 DeclContext *Owner,
14335 LocalInstantiationScope *StartingScope,
14336 bool InstantiatingVarTemplate = false,
14337 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
14338
14339 /// Instantiate the initializer of a variable.
14341 VarDecl *Var, VarDecl *OldVar,
14342 const MultiLevelTemplateArgumentList &TemplateArgs);
14343
14344 /// Instantiate the definition of the given variable from its
14345 /// template.
14346 ///
14347 /// \param PointOfInstantiation the point at which the instantiation was
14348 /// required. Note that this is not precisely a "point of instantiation"
14349 /// for the variable, but it's close.
14350 ///
14351 /// \param Var the already-instantiated declaration of a templated variable.
14352 ///
14353 /// \param Recursive if true, recursively instantiates any functions that
14354 /// are required by this instantiation.
14355 ///
14356 /// \param DefinitionRequired if true, then we are performing an explicit
14357 /// instantiation where a definition of the variable is required. Complain
14358 /// if there is no such definition.
14359 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
14360 VarDecl *Var, bool Recursive = false,
14361 bool DefinitionRequired = false,
14362 bool AtEndOfTU = false);
14363
14366 const MultiLevelTemplateArgumentList &TemplateArgs);
14367
14368 /// Find the instantiation of the given declaration within the
14369 /// current instantiation.
14370 ///
14371 /// This routine is intended to be used when \p D is a declaration
14372 /// referenced from within a template, that needs to mapped into the
14373 /// corresponding declaration within an instantiation. For example,
14374 /// given:
14375 ///
14376 /// \code
14377 /// template<typename T>
14378 /// struct X {
14379 /// enum Kind {
14380 /// KnownValue = sizeof(T)
14381 /// };
14382 ///
14383 /// bool getKind() const { return KnownValue; }
14384 /// };
14385 ///
14386 /// template struct X<int>;
14387 /// \endcode
14388 ///
14389 /// In the instantiation of X<int>::getKind(), we need to map the \p
14390 /// EnumConstantDecl for \p KnownValue (which refers to
14391 /// X<T>::<Kind>::KnownValue) to its instantiation
14392 /// (X<int>::<Kind>::KnownValue).
14393 /// \p FindInstantiatedDecl performs this mapping from within the
14394 /// instantiation of X<int>.
14395 NamedDecl *
14397 const MultiLevelTemplateArgumentList &TemplateArgs,
14398 bool FindingInstantiatedContext = false);
14399
14400 /// Finds the instantiation of the given declaration context
14401 /// within the current instantiation.
14402 ///
14403 /// \returns NULL if there was an error
14404 DeclContext *
14406 const MultiLevelTemplateArgumentList &TemplateArgs);
14407
14408 Decl *SubstDecl(Decl *D, DeclContext *Owner,
14409 const MultiLevelTemplateArgumentList &TemplateArgs);
14410
14411 /// Substitute the name and return type of a defaulted 'operator<=>' to form
14412 /// an implicit 'operator=='.
14414 FunctionDecl *Spaceship);
14415
14416 /// Performs template instantiation for all implicit template
14417 /// instantiations we have seen until this point.
14418 void PerformPendingInstantiations(bool LocalOnly = false,
14419 bool AtEndOfTU = true);
14420
14423 const MultiLevelTemplateArgumentList &TemplateArgs,
14424 bool EvaluateConstraints = true);
14425
14427 const DeclContext *Pattern,
14428 const MultiLevelTemplateArgumentList &TemplateArgs);
14429
14430private:
14431 /// Introduce the instantiated local variables into the local
14432 /// instantiation scope.
14433 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
14434 const FunctionDecl *PatternDecl,
14436 /// Introduce the instantiated function parameters into the local
14437 /// instantiation scope, and set the parameter names to those used
14438 /// in the template.
14439 bool addInstantiatedParametersToScope(
14440 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14442 const MultiLevelTemplateArgumentList &TemplateArgs);
14443
14444 /// Introduce the instantiated captures of the lambda into the local
14445 /// instantiation scope.
14446 bool addInstantiatedCapturesToScope(
14447 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14449 const MultiLevelTemplateArgumentList &TemplateArgs);
14450
14451 int ParsingClassDepth = 0;
14452
14453 class SavePendingParsedClassStateRAII {
14454 public:
14455 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
14456
14457 ~SavePendingParsedClassStateRAII() {
14458 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
14459 "there shouldn't be any pending delayed exception spec checks");
14460 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
14461 "there shouldn't be any pending delayed exception spec checks");
14462 swapSavedState();
14463 }
14464
14465 SavePendingParsedClassStateRAII(const SavePendingParsedClassStateRAII &) =
14466 delete;
14467 SavePendingParsedClassStateRAII &
14468 operator=(const SavePendingParsedClassStateRAII &) = delete;
14469
14470 private:
14471 Sema &S;
14473 SavedOverridingExceptionSpecChecks;
14475 SavedEquivalentExceptionSpecChecks;
14476
14477 void swapSavedState() {
14478 SavedOverridingExceptionSpecChecks.swap(
14479 S.DelayedOverridingExceptionSpecChecks);
14480 SavedEquivalentExceptionSpecChecks.swap(
14481 S.DelayedEquivalentExceptionSpecChecks);
14482 }
14483 };
14484
14485 ///@}
14486
14487 //
14488 //
14489 // -------------------------------------------------------------------------
14490 //
14491 //
14492
14493 /// \name C++ Variadic Templates
14494 /// Implementations are in SemaTemplateVariadic.cpp
14495 ///@{
14496
14497public:
14498 /// Determine whether an unexpanded parameter pack might be permitted in this
14499 /// location. Useful for error recovery.
14501
14502 /// The context in which an unexpanded parameter pack is
14503 /// being diagnosed.
14504 ///
14505 /// Note that the values of this enumeration line up with the first
14506 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
14508 /// An arbitrary expression.
14510
14511 /// The base type of a class type.
14513
14514 /// The type of an arbitrary declaration.
14516
14517 /// The type of a data member.
14519
14520 /// The size of a bit-field.
14522
14523 /// The expression in a static assertion.
14525
14526 /// The fixed underlying type of an enumeration.
14528
14529 /// The enumerator value.
14531
14532 /// A using declaration.
14534
14535 /// A friend declaration.
14537
14538 /// A declaration qualifier.
14540
14541 /// An initializer.
14543
14544 /// A default argument.
14546
14547 /// The type of a non-type template parameter.
14549
14550 /// The type of an exception.
14552
14553 /// Explicit specialization.
14555
14556 /// Partial specialization.
14558
14559 /// Microsoft __if_exists.
14561
14562 /// Microsoft __if_not_exists.
14564
14565 /// Lambda expression.
14567
14568 /// Block expression.
14570
14571 /// A type constraint.
14573
14574 // A requirement in a requires-expression.
14576
14577 // A requires-clause.
14579 };
14580
14581 /// Diagnose unexpanded parameter packs.
14582 ///
14583 /// \param Loc The location at which we should emit the diagnostic.
14584 ///
14585 /// \param UPPC The context in which we are diagnosing unexpanded
14586 /// parameter packs.
14587 ///
14588 /// \param Unexpanded the set of unexpanded parameter packs.
14589 ///
14590 /// \returns true if an error occurred, false otherwise.
14594
14595 /// If the given type contains an unexpanded parameter pack,
14596 /// diagnose the error.
14597 ///
14598 /// \param Loc The source location where a diagnostc should be emitted.
14599 ///
14600 /// \param T The type that is being checked for unexpanded parameter
14601 /// packs.
14602 ///
14603 /// \returns true if an error occurred, false otherwise.
14606
14607 /// If the given expression contains an unexpanded parameter
14608 /// pack, diagnose the error.
14609 ///
14610 /// \param E The expression that is being checked for unexpanded
14611 /// parameter packs.
14612 ///
14613 /// \returns true if an error occurred, false otherwise.
14616
14617 /// If the given requirees-expression contains an unexpanded reference to one
14618 /// of its own parameter packs, diagnose the error.
14619 ///
14620 /// \param RE The requiress-expression that is being checked for unexpanded
14621 /// parameter packs.
14622 ///
14623 /// \returns true if an error occurred, false otherwise.
14625
14626 /// If the given nested-name-specifier contains an unexpanded
14627 /// parameter pack, diagnose the error.
14628 ///
14629 /// \param SS The nested-name-specifier that is being checked for
14630 /// unexpanded parameter packs.
14631 ///
14632 /// \returns true if an error occurred, false otherwise.
14635
14636 /// If the given name contains an unexpanded parameter pack,
14637 /// diagnose the error.
14638 ///
14639 /// \param NameInfo The name (with source location information) that
14640 /// is being checked for unexpanded parameter packs.
14641 ///
14642 /// \returns true if an error occurred, false otherwise.
14645
14646 /// If the given template name contains an unexpanded parameter pack,
14647 /// diagnose the error.
14648 ///
14649 /// \param Loc The location of the template name.
14650 ///
14651 /// \param Template The template name that is being checked for unexpanded
14652 /// parameter packs.
14653 ///
14654 /// \returns true if an error occurred, false otherwise.
14658
14659 /// If the given template argument contains an unexpanded parameter
14660 /// pack, diagnose the error.
14661 ///
14662 /// \param Arg The template argument that is being checked for unexpanded
14663 /// parameter packs.
14664 ///
14665 /// \returns true if an error occurred, false otherwise.
14668
14669 /// Collect the set of unexpanded parameter packs within the given
14670 /// template argument.
14671 ///
14672 /// \param Arg The template argument that will be traversed to find
14673 /// unexpanded parameter packs.
14675 TemplateArgument Arg,
14677
14678 /// Collect the set of unexpanded parameter packs within the given
14679 /// template argument.
14680 ///
14681 /// \param Arg The template argument that will be traversed to find
14682 /// unexpanded parameter packs.
14686
14687 /// Collect the set of unexpanded parameter packs within the given
14688 /// type.
14689 ///
14690 /// \param T The type that will be traversed to find
14691 /// unexpanded parameter packs.
14694
14695 /// Collect the set of unexpanded parameter packs within the given
14696 /// type.
14697 ///
14698 /// \param TL The type that will be traversed to find
14699 /// unexpanded parameter packs.
14702
14703 /// Collect the set of unexpanded parameter packs within the given
14704 /// nested-name-specifier.
14705 ///
14706 /// \param NNS The nested-name-specifier that will be traversed to find
14707 /// unexpanded parameter packs.
14711
14712 /// Collect the set of unexpanded parameter packs within the given
14713 /// name.
14714 ///
14715 /// \param NameInfo The name that will be traversed to find
14716 /// unexpanded parameter packs.
14718 const DeclarationNameInfo &NameInfo,
14720
14721 /// Collect the set of unexpanded parameter packs within the given
14722 /// expression.
14725
14726 /// Invoked when parsing a template argument.
14727 ///
14728 /// \param Arg the template argument, which may already be invalid.
14729 ///
14730 /// If it is followed by ellipsis, this function is called before
14731 /// `ActOnPackExpansion`.
14734
14735 /// Invoked when parsing a template argument followed by an
14736 /// ellipsis, which creates a pack expansion.
14737 ///
14738 /// \param Arg The template argument preceding the ellipsis, which
14739 /// may already be invalid.
14740 ///
14741 /// \param EllipsisLoc The location of the ellipsis.
14743 SourceLocation EllipsisLoc);
14744
14745 /// Invoked when parsing a type followed by an ellipsis, which
14746 /// creates a pack expansion.
14747 ///
14748 /// \param Type The type preceding the ellipsis, which will become
14749 /// the pattern of the pack expansion.
14750 ///
14751 /// \param EllipsisLoc The location of the ellipsis.
14753
14754 /// Construct a pack expansion type from the pattern of the pack
14755 /// expansion.
14757 SourceLocation EllipsisLoc,
14758 UnsignedOrNone NumExpansions);
14759
14760 /// Construct a pack expansion type from the pattern of the pack
14761 /// expansion.
14762 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14763 SourceLocation EllipsisLoc,
14764 UnsignedOrNone NumExpansions);
14765
14766 /// Invoked when parsing an expression followed by an ellipsis, which
14767 /// creates a pack expansion.
14768 ///
14769 /// \param Pattern The expression preceding the ellipsis, which will become
14770 /// the pattern of the pack expansion.
14771 ///
14772 /// \param EllipsisLoc The location of the ellipsis.
14773 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14774
14775 /// Invoked when parsing an expression followed by an ellipsis, which
14776 /// creates a pack expansion.
14777 ///
14778 /// \param Pattern The expression preceding the ellipsis, which will become
14779 /// the pattern of the pack expansion.
14780 ///
14781 /// \param EllipsisLoc The location of the ellipsis.
14782 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14783 UnsignedOrNone NumExpansions);
14784
14785 /// Determine whether we could expand a pack expansion with the
14786 /// given set of parameter packs into separate arguments by repeatedly
14787 /// transforming the pattern.
14788 ///
14789 /// \param EllipsisLoc The location of the ellipsis that identifies the
14790 /// pack expansion.
14791 ///
14792 /// \param PatternRange The source range that covers the entire pattern of
14793 /// the pack expansion.
14794 ///
14795 /// \param Unexpanded The set of unexpanded parameter packs within the
14796 /// pattern.
14797 ///
14798 /// \param ShouldExpand Will be set to \c true if the transformer should
14799 /// expand the corresponding pack expansions into separate arguments. When
14800 /// set, \c NumExpansions must also be set.
14801 ///
14802 /// \param RetainExpansion Whether the caller should add an unexpanded
14803 /// pack expansion after all of the expanded arguments. This is used
14804 /// when extending explicitly-specified template argument packs per
14805 /// C++0x [temp.arg.explicit]p9.
14806 ///
14807 /// \param NumExpansions The number of separate arguments that will be in
14808 /// the expanded form of the corresponding pack expansion. This is both an
14809 /// input and an output parameter, which can be set by the caller if the
14810 /// number of expansions is known a priori (e.g., due to a prior substitution)
14811 /// and will be set by the callee when the number of expansions is known.
14812 /// The callee must set this value when \c ShouldExpand is \c true; it may
14813 /// set this value in other cases.
14814 ///
14815 /// \returns true if an error occurred (e.g., because the parameter packs
14816 /// are to be instantiated with arguments of different lengths), false
14817 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14818 /// must be set.
14820 SourceLocation EllipsisLoc, SourceRange PatternRange,
14822 const MultiLevelTemplateArgumentList &TemplateArgs,
14823 bool FailOnPackProducingTemplates, bool &ShouldExpand,
14824 bool &RetainExpansion, UnsignedOrNone &NumExpansions,
14825 bool Diagnose = true);
14826
14827 /// Determine the number of arguments in the given pack expansion
14828 /// type.
14829 ///
14830 /// This routine assumes that the number of arguments in the expansion is
14831 /// consistent across all of the unexpanded parameter packs in its pattern.
14832 ///
14833 /// Returns an empty Optional if the type can't be expanded.
14835 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14836
14839 const MultiLevelTemplateArgumentList &TemplateArgs);
14840
14841 /// Determine whether the given declarator contains any unexpanded
14842 /// parameter packs.
14843 ///
14844 /// This routine is used by the parser to disambiguate function declarators
14845 /// with an ellipsis prior to the ')', e.g.,
14846 ///
14847 /// \code
14848 /// void f(T...);
14849 /// \endcode
14850 ///
14851 /// To determine whether we have an (unnamed) function parameter pack or
14852 /// a variadic function.
14853 ///
14854 /// \returns true if the declarator contains any unexpanded parameter packs,
14855 /// false otherwise.
14857
14858 /// Returns the pattern of the pack expansion for a template argument.
14859 ///
14860 /// \param OrigLoc The template argument to expand.
14861 ///
14862 /// \param Ellipsis Will be set to the location of the ellipsis.
14863 ///
14864 /// \param NumExpansions Will be set to the number of expansions that will
14865 /// be generated from this pack expansion, if known a priori.
14868 SourceLocation &Ellipsis,
14869 UnsignedOrNone &NumExpansions) const;
14870
14871 /// Given a template argument that contains an unexpanded parameter pack, but
14872 /// which has already been substituted, attempt to determine the number of
14873 /// elements that will be produced once this argument is fully-expanded.
14874 ///
14875 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14876 /// avoid actually expanding the pack where possible.
14878
14879 /// Called when an expression computing the size of a parameter pack
14880 /// is parsed.
14881 ///
14882 /// \code
14883 /// template<typename ...Types> struct count {
14884 /// static const unsigned value = sizeof...(Types);
14885 /// };
14886 /// \endcode
14887 ///
14888 //
14889 /// \param OpLoc The location of the "sizeof" keyword.
14890 /// \param Name The name of the parameter pack whose size will be determined.
14891 /// \param NameLoc The source location of the name of the parameter pack.
14892 /// \param RParenLoc The location of the closing parentheses.
14894 IdentifierInfo &Name,
14895 SourceLocation NameLoc,
14896 SourceLocation RParenLoc);
14897
14898 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14899 SourceLocation EllipsisLoc,
14900 SourceLocation LSquareLoc, Expr *IndexExpr,
14901 SourceLocation RSquareLoc);
14902
14903 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14904 SourceLocation EllipsisLoc, Expr *IndexExpr,
14905 SourceLocation RSquareLoc,
14906 ArrayRef<Expr *> ExpandedExprs = {},
14907 bool FullySubstituted = false);
14908
14909 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
14910 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14911 tok::TokenKind Operator,
14912 SourceLocation EllipsisLoc, Expr *RHS,
14913 SourceLocation RParenLoc);
14914 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
14915 SourceLocation LParenLoc, Expr *LHS,
14916 BinaryOperatorKind Operator,
14917 SourceLocation EllipsisLoc, Expr *RHS,
14918 SourceLocation RParenLoc,
14919 UnsignedOrNone NumExpansions);
14920 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
14921 BinaryOperatorKind Operator);
14922
14923 ///@}
14924
14925 //
14926 //
14927 // -------------------------------------------------------------------------
14928 //
14929 //
14930
14931 /// \name Constraints and Concepts
14932 /// Implementations are in SemaConcept.cpp
14933 ///@{
14934
14935public:
14936 ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, TypeSourceInfo *TSI);
14937
14938 ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc,
14939 TypeSourceInfo *TSI);
14940
14941public:
14943 const llvm::FoldingSetNodeID &ID) {
14944 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14945 SatisfactionStack.emplace_back(Can, ID);
14946 }
14947
14948 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
14949
14951 const llvm::FoldingSetNodeID &ID) const {
14952 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14953 return llvm::is_contained(SatisfactionStack,
14954 SatisfactionStackEntryTy{Can, ID});
14955 }
14956
14958 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
14959
14960 // Resets the current SatisfactionStack for cases where we are instantiating
14961 // constraints as a 'side effect' of normal instantiation in a way that is not
14962 // indicative of recursive definition.
14965 Sema &SemaRef;
14966
14967 public:
14969 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14970 }
14971
14973 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14974 }
14975
14979 };
14980
14983 SatisfactionStack.swap(NewSS);
14984 }
14985
14987 llvm::PointerUnion<const NamedDecl *,
14989
14990 /// Check whether the given expression is a valid constraint expression.
14991 /// A diagnostic is emitted if it is not, false is returned, and
14992 /// PossibleNonPrimary will be set to true if the failure might be due to a
14993 /// non-primary expression being used as an atomic constraint.
14994 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
14995 bool *PossibleNonPrimary = nullptr,
14996 bool IsTrailingRequiresClause = false);
14997
14998 /// \brief Check whether the given list of constraint expressions are
14999 /// satisfied (as if in a 'conjunction') given template arguments.
15000 /// \param Template the template-like entity that triggered the constraints
15001 /// check (either a concept or a constrained entity).
15002 /// \param ConstraintExprs a list of constraint expressions, treated as if
15003 /// they were 'AND'ed together.
15004 /// \param TemplateArgLists the list of template arguments to substitute into
15005 /// the constraint expression.
15006 /// \param TemplateIDRange The source range of the template id that
15007 /// caused the constraints check.
15008 /// \param Satisfaction if true is returned, will contain details of the
15009 /// satisfaction, with enough information to diagnose an unsatisfied
15010 /// expression.
15011 /// \returns true if an error occurred and satisfaction could not be checked,
15012 /// false otherwise.
15015 ArrayRef<AssociatedConstraint> AssociatedConstraints,
15016 const MultiLevelTemplateArgumentList &TemplateArgLists,
15017 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction,
15018 const ConceptReference *TopLevelConceptId = nullptr,
15019 Expr **ConvertedExpr = nullptr);
15020
15021 /// Check whether the given function decl's trailing requires clause is
15022 /// satisfied, if any. Returns false and updates Satisfaction with the
15023 /// satisfaction verdict if successful, emits a diagnostic and returns true if
15024 /// an error occurred and satisfaction could not be determined.
15025 ///
15026 /// \returns true if an error occurred, false otherwise.
15028 ConstraintSatisfaction &Satisfaction,
15029 SourceLocation UsageLoc = SourceLocation(),
15030 bool ForOverloadResolution = false);
15031
15032 // Calculates whether two constraint expressions are equal irrespective of a
15033 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
15034 // 'New', which are the "source" of the constraint, since this is necessary
15035 // for figuring out the relative 'depth' of the constraint. The depth of the
15036 // 'primary template' and the 'instantiated from' templates aren't necessarily
15037 // the same, such as a case when one is a 'friend' defined in a class.
15039 const Expr *OldConstr,
15041 const Expr *NewConstr);
15042
15043 // Calculates whether the friend function depends on an enclosing template for
15044 // the purposes of [temp.friend] p9.
15046
15047 /// \brief Ensure that the given template arguments satisfy the constraints
15048 /// associated with the given template, emitting a diagnostic if they do not.
15049 ///
15050 /// \param Template The template to which the template arguments are being
15051 /// provided.
15052 ///
15053 /// \param TemplateArgs The converted, canonicalized template arguments.
15054 ///
15055 /// \param TemplateIDRange The source range of the template id that
15056 /// caused the constraints check.
15057 ///
15058 /// \returns true if the constrains are not satisfied or could not be checked
15059 /// for satisfaction, false if the constraints are satisfied.
15062 const MultiLevelTemplateArgumentList &TemplateArgs,
15063 SourceRange TemplateIDRange);
15064
15065 bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation,
15067 ArrayRef<TemplateArgument> TemplateArgs,
15068 ConstraintSatisfaction &Satisfaction);
15069
15070 /// \brief Emit diagnostics explaining why a constraint expression was deemed
15071 /// unsatisfied.
15072 /// \param First whether this is the first time an unsatisfied constraint is
15073 /// diagnosed for this error.
15075 SourceLocation Loc = {},
15076 bool First = true);
15077
15078 /// \brief Emit diagnostics explaining why a constraint expression was deemed
15079 /// unsatisfied.
15080 void
15082 bool First = true);
15083
15086 ArrayRef<AssociatedConstraint> AssociatedConstraints);
15087
15088 /// \brief Check whether the given declaration's associated constraints are
15089 /// at least as constrained than another declaration's according to the
15090 /// partial ordering of constraints.
15091 ///
15092 /// \param Result If no error occurred, receives the result of true if D1 is
15093 /// at least constrained than D2, and false otherwise.
15094 ///
15095 /// \returns true if an error occurred, false otherwise.
15096 bool IsAtLeastAsConstrained(const NamedDecl *D1,
15098 const NamedDecl *D2,
15100 bool &Result);
15101
15102 /// If D1 was not at least as constrained as D2, but would've been if a pair
15103 /// of atomic constraints involved had been declared in a concept and not
15104 /// repeated in two separate places in code.
15105 /// \returns true if such a diagnostic was emitted, false otherwise.
15109
15110 /// Cache the satisfaction of an atomic constraint.
15111 /// The key is based on the unsubstituted expression and the parameter
15112 /// mapping. This lets us not substituting the mapping more than once,
15113 /// which is (very!) expensive.
15114 /// FIXME: this should be private.
15115 llvm::DenseMap<llvm::FoldingSetNodeID,
15118
15119 /// Cache the instantiation results of template parameter mappings within
15120 /// concepts. Substituting into normalized concepts can be extremely expensive
15121 /// due to the redundancy of template parameters. This cache is intended for
15122 /// use by TemplateInstantiator to avoid redundant semantic checking.
15123 llvm::DenseMap<llvm::FoldingSetNodeID, TemplateArgumentLoc>
15125
15126private:
15127 /// Caches pairs of template-like decls whose associated constraints were
15128 /// checked for subsumption and whether or not the first's constraints did in
15129 /// fact subsume the second's.
15130 llvm::DenseMap<std::pair<const NamedDecl *, const NamedDecl *>, bool>
15131 SubsumptionCache;
15132 /// Caches the normalized associated constraints of declarations (concepts or
15133 /// constrained declarations). If an error occurred while normalizing the
15134 /// associated constraints of the template or concept, nullptr will be cached
15135 /// here.
15136 llvm::DenseMap<ConstrainedDeclOrNestedRequirement, NormalizedConstraint *>
15137 NormalizationCache;
15138
15139 /// Cache whether the associated constraint of a declaration
15140 /// is satisfied.
15141 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
15142 SatisfactionCache;
15143
15144 // The current stack of constraint satisfactions, so we can exit-early.
15146
15147 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to set up the
15148 /// LocalInstantiationScope of the current non-lambda function. For lambdas,
15149 /// use LambdaScopeForCallOperatorInstantiationRAII.
15150 bool
15151 SetupConstraintScope(FunctionDecl *FD,
15152 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
15153 const MultiLevelTemplateArgumentList &MLTAL,
15155
15156 /// Used during constraint checking, sets up the constraint template argument
15157 /// lists, and calls SetupConstraintScope to set up the
15158 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
15159 std::optional<MultiLevelTemplateArgumentList>
15160 SetupConstraintCheckingTemplateArgumentsAndScope(
15161 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
15163
15164 ///@}
15165
15166 //
15167 //
15168 // -------------------------------------------------------------------------
15169 //
15170 //
15171
15172 /// \name Types
15173 /// Implementations are in SemaType.cpp
15174 ///@{
15175
15176public:
15177 /// A mapping that describes the nullability we've seen in each header file.
15179
15180 static int getPrintable(int I) { return I; }
15181 static unsigned getPrintable(unsigned I) { return I; }
15182 static bool getPrintable(bool B) { return B; }
15183 static const char *getPrintable(const char *S) { return S; }
15184 static StringRef getPrintable(StringRef S) { return S; }
15185 static const std::string &getPrintable(const std::string &S) { return S; }
15186 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
15187 return II;
15188 }
15190 static QualType getPrintable(QualType T) { return T; }
15191 static SourceRange getPrintable(SourceRange R) { return R; }
15193 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
15195
15196 enum class CompleteTypeKind {
15197 /// Apply the normal rules for complete types. In particular,
15198 /// treat all sizeless types as incomplete.
15200
15201 /// Relax the normal rules for complete types so that they include
15202 /// sizeless built-in types.
15204
15205 // FIXME: Eventually we should flip the default to Normal and opt in
15206 // to AcceptSizeless rather than opt out of it.
15208 };
15209
15211 const DeclSpec *DS = nullptr);
15212 QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVRA,
15213 const DeclSpec *DS = nullptr);
15214
15215 /// Build a pointer type.
15216 ///
15217 /// \param T The type to which we'll be building a pointer.
15218 ///
15219 /// \param Loc The location of the entity whose type involves this
15220 /// pointer type or, if there is no such entity, the location of the
15221 /// type that will have pointer type.
15222 ///
15223 /// \param Entity The name of the entity that involves the pointer
15224 /// type, if known.
15225 ///
15226 /// \returns A suitable pointer type, if there are no
15227 /// errors. Otherwise, returns a NULL type.
15229 DeclarationName Entity);
15230
15231 /// Build a reference type.
15232 ///
15233 /// \param T The type to which we'll be building a reference.
15234 ///
15235 /// \param Loc The location of the entity whose type involves this
15236 /// reference type or, if there is no such entity, the location of the
15237 /// type that will have reference type.
15238 ///
15239 /// \param Entity The name of the entity that involves the reference
15240 /// type, if known.
15241 ///
15242 /// \returns A suitable reference type, if there are no
15243 /// errors. Otherwise, returns a NULL type.
15244 QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc,
15245 DeclarationName Entity);
15246
15247 /// Build an array type.
15248 ///
15249 /// \param T The type of each element in the array.
15250 ///
15251 /// \param ASM C99 array size modifier (e.g., '*', 'static').
15252 ///
15253 /// \param ArraySize Expression describing the size of the array.
15254 ///
15255 /// \param Brackets The range from the opening '[' to the closing ']'.
15256 ///
15257 /// \param Entity The name of the entity that involves the array
15258 /// type, if known.
15259 ///
15260 /// \returns A suitable array type, if there are no errors. Otherwise,
15261 /// returns a NULL type.
15263 unsigned Quals, SourceRange Brackets,
15264 DeclarationName Entity);
15265 QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc);
15266
15267 /// Build an ext-vector type.
15268 ///
15269 /// Run the required checks for the extended vector type.
15271 SourceLocation AttrLoc);
15272 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
15273 SourceLocation AttrLoc);
15274
15276 Expr *CountExpr,
15277 bool CountInBytes,
15278 bool OrNull);
15279
15280 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
15281 /// expression is uninstantiated. If instantiated it will apply the
15282 /// appropriate address space to the type. This function allows dependent
15283 /// template variables to be used in conjunction with the address_space
15284 /// attribute
15285 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
15286 SourceLocation AttrLoc);
15287
15288 /// Same as above, but constructs the AddressSpace index if not provided.
15290 SourceLocation AttrLoc);
15291
15293
15295
15296 /// Build a function type.
15297 ///
15298 /// This routine checks the function type according to C++ rules and
15299 /// under the assumption that the result type and parameter types have
15300 /// just been instantiated from a template. It therefore duplicates
15301 /// some of the behavior of GetTypeForDeclarator, but in a much
15302 /// simpler form that is only suitable for this narrow use case.
15303 ///
15304 /// \param T The return type of the function.
15305 ///
15306 /// \param ParamTypes The parameter types of the function. This array
15307 /// will be modified to account for adjustments to the types of the
15308 /// function parameters.
15309 ///
15310 /// \param Loc The location of the entity whose type involves this
15311 /// function type or, if there is no such entity, the location of the
15312 /// type that will have function type.
15313 ///
15314 /// \param Entity The name of the entity that involves the function
15315 /// type, if known.
15316 ///
15317 /// \param EPI Extra information about the function type. Usually this will
15318 /// be taken from an existing function with the same prototype.
15319 ///
15320 /// \returns A suitable function type, if there are no errors. The
15321 /// unqualified type will always be a FunctionProtoType.
15322 /// Otherwise, returns a NULL type.
15324 SourceLocation Loc, DeclarationName Entity,
15326
15327 /// Build a member pointer type \c T Class::*.
15328 ///
15329 /// \param T the type to which the member pointer refers.
15330 /// \param Class the class type into which the member pointer points.
15331 /// \param Loc the location where this type begins
15332 /// \param Entity the name of the entity that will have this member pointer
15333 /// type
15334 ///
15335 /// \returns a member pointer type, if successful, or a NULL type if there was
15336 /// an error.
15338 CXXRecordDecl *Cls, SourceLocation Loc,
15339 DeclarationName Entity);
15340
15341 /// Build a block pointer type.
15342 ///
15343 /// \param T The type to which we'll be building a block pointer.
15344 ///
15345 /// \param Loc The source location, used for diagnostics.
15346 ///
15347 /// \param Entity The name of the entity that involves the block pointer
15348 /// type, if known.
15349 ///
15350 /// \returns A suitable block pointer type, if there are no
15351 /// errors. Otherwise, returns a NULL type.
15353 DeclarationName Entity);
15354
15355 /// Build a paren type including \p T.
15358
15359 /// Build a Read-only Pipe type.
15360 ///
15361 /// \param T The type to which we'll be building a Pipe.
15362 ///
15363 /// \param Loc We do not use it for now.
15364 ///
15365 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15366 /// a NULL type.
15368
15369 /// Build a Write-only Pipe type.
15370 ///
15371 /// \param T The type to which we'll be building a Pipe.
15372 ///
15373 /// \param Loc We do not use it for now.
15374 ///
15375 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15376 /// a NULL type.
15378
15379 /// Build a bit-precise integer type.
15380 ///
15381 /// \param IsUnsigned Boolean representing the signedness of the type.
15382 ///
15383 /// \param BitWidth Size of this int type in bits, or an expression
15384 /// representing that.
15385 ///
15386 /// \param Loc Location of the keyword.
15387 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
15388
15389 /// GetTypeForDeclarator - Convert the type for the specified
15390 /// declarator to Type instances.
15391 ///
15392 /// The result of this call will never be null, but the associated
15393 /// type may be a null type if there's an unrecoverable error.
15396
15397 /// Package the given type and TSI into a ParsedType.
15400 TypeSourceInfo **TInfo = nullptr);
15401
15403
15404 // Check whether the size of array element of type \p EltTy is a multiple of
15405 // its alignment and return false if it isn't.
15407
15408 void
15409 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
15410 SourceLocation FallbackLoc,
15411 SourceLocation ConstQualLoc = SourceLocation(),
15412 SourceLocation VolatileQualLoc = SourceLocation(),
15413 SourceLocation RestrictQualLoc = SourceLocation(),
15414 SourceLocation AtomicQualLoc = SourceLocation(),
15415 SourceLocation UnalignedQualLoc = SourceLocation());
15416
15417 /// Retrieve the keyword associated
15419
15420 /// Adjust the calling convention of a method to be the ABI default if it
15421 /// wasn't specified explicitly. This handles method types formed from
15422 /// function type typedefs and typename template arguments.
15423 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
15424 bool IsCtorOrDtor, SourceLocation Loc);
15425
15426 // Check if there is an explicit attribute, but only look through parens.
15427 // The intent is to look for an attribute on the current declarator, but not
15428 // one that came from a typedef.
15430
15431 /// Check whether a nullability type specifier can be added to the given
15432 /// type through some means not written in source (e.g. API notes).
15433 ///
15434 /// \param Type The type to which the nullability specifier will be
15435 /// added. On success, this type will be updated appropriately.
15436 ///
15437 /// \param Nullability The nullability specifier to add.
15438 ///
15439 /// \param DiagLoc The location to use for diagnostics.
15440 ///
15441 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
15442 /// array type (e.g., because it will decay to a pointer).
15443 ///
15444 /// \param OverrideExisting Whether to override an existing, locally-specified
15445 /// nullability specifier rather than complaining about the conflict.
15446 ///
15447 /// \returns true if nullability cannot be applied, false otherwise.
15449 NullabilityKind Nullability,
15450 SourceLocation DiagLoc,
15451 bool AllowArrayTypes,
15452 bool OverrideExisting);
15453
15454 /// Check whether the given variable declaration has a size that fits within
15455 /// the address space it is declared in. This issues a diagnostic if not.
15456 ///
15457 /// \param VD The variable declaration to check the size of.
15458 ///
15459 /// \param AS The address space to check the size of \p VD against.
15460 ///
15461 /// \returns true if the variable's size fits within the address space, false
15462 /// otherwise.
15463 bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS);
15464
15465 /// Get the type of expression E, triggering instantiation to complete the
15466 /// type if necessary -- that is, if the expression refers to a templated
15467 /// static data member of incomplete array type.
15468 ///
15469 /// May still return an incomplete type if instantiation was not possible or
15470 /// if the type is incomplete for a different reason. Use
15471 /// RequireCompleteExprType instead if a diagnostic is expected for an
15472 /// incomplete expression type.
15474
15476
15477 /// Ensure that the type of the given expression is complete.
15478 ///
15479 /// This routine checks whether the expression \p E has a complete type. If
15480 /// the expression refers to an instantiable construct, that instantiation is
15481 /// performed as needed to complete its type. Furthermore
15482 /// Sema::RequireCompleteType is called for the expression's type (or in the
15483 /// case of a reference type, the referred-to type).
15484 ///
15485 /// \param E The expression whose type is required to be complete.
15486 /// \param Kind Selects which completeness rules should be applied.
15487 /// \param Diagnoser The object that will emit a diagnostic if the type is
15488 /// incomplete.
15489 ///
15490 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
15491 /// otherwise.
15493 TypeDiagnoser &Diagnoser);
15494 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
15495
15496 template <typename... Ts>
15497 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
15498 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15500 }
15501
15502 // Returns the underlying type of a decltype with the given expression.
15504
15506 /// If AsUnevaluated is false, E is treated as though it were an evaluated
15507 /// context, such as when building a type for decltype(auto).
15508 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
15509
15510 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
15511 SourceLocation Loc,
15512 SourceLocation EllipsisLoc);
15513 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
15514 SourceLocation Loc, SourceLocation EllipsisLoc,
15515 bool FullySubstituted = false,
15516 ArrayRef<QualType> Expansions = {});
15517
15518 using UTTKind = UnaryTransformType::UTTKind;
15520 SourceLocation Loc);
15526 SourceLocation Loc);
15528 SourceLocation Loc);
15530 SourceLocation Loc);
15531
15533 return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc);
15534 }
15535
15537 SourceLocation Loc);
15539 SourceLocation Loc);
15540
15541 bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);
15542
15543 /// Ensure that the type T is a literal type.
15544 ///
15545 /// This routine checks whether the type @p T is a literal type. If @p T is an
15546 /// incomplete type, an attempt is made to complete it. If @p T is a literal
15547 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
15548 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
15549 /// it the type @p T), along with notes explaining why the type is not a
15550 /// literal type, and returns true.
15551 ///
15552 /// @param Loc The location in the source that the non-literal type
15553 /// diagnostic should refer to.
15554 ///
15555 /// @param T The type that this routine is examining for literalness.
15556 ///
15557 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
15558 ///
15559 /// @returns @c true if @p T is not a literal type and a diagnostic was
15560 /// emitted, @c false otherwise.
15562 TypeDiagnoser &Diagnoser);
15563 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
15564
15565 template <typename... Ts>
15566 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
15567 const Ts &...Args) {
15568 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15569 return RequireLiteralType(Loc, T, Diagnoser);
15570 }
15571
15574 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
15575 }
15576
15577 /// Ensure that the type T is a complete type.
15578 ///
15579 /// This routine checks whether the type @p T is complete in any
15580 /// context where a complete type is required. If @p T is a complete
15581 /// type, returns false. If @p T is a class template specialization,
15582 /// this routine then attempts to perform class template
15583 /// instantiation. If instantiation fails, or if @p T is incomplete
15584 /// and cannot be completed, issues the diagnostic @p diag (giving it
15585 /// the type @p T) and returns true.
15586 ///
15587 /// @param Loc The location in the source that the incomplete type
15588 /// diagnostic should refer to.
15589 ///
15590 /// @param T The type that this routine is examining for completeness.
15591 ///
15592 /// @param Kind Selects which completeness rules should be applied.
15593 ///
15594 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
15595 /// @c false otherwise.
15597 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
15599 CompleteTypeKind Kind, unsigned DiagID);
15600
15602 TypeDiagnoser &Diagnoser) {
15603 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, Diagnoser);
15604 }
15605 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID) {
15606 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, DiagID);
15607 }
15608
15609 template <typename... Ts>
15610 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
15611 const Ts &...Args) {
15612 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15613 return RequireCompleteType(Loc, T, Diagnoser);
15614 }
15615
15616 /// Determine whether a declaration is visible to name lookup.
15617 bool isVisible(const NamedDecl *D) {
15618 return D->isUnconditionallyVisible() ||
15619 isAcceptableSlow(D, AcceptableKind::Visible);
15620 }
15621
15622 /// Determine whether a declaration is reachable.
15623 bool isReachable(const NamedDecl *D) {
15624 // All visible declarations are reachable.
15625 return D->isUnconditionallyVisible() ||
15626 isAcceptableSlow(D, AcceptableKind::Reachable);
15627 }
15628
15629 /// Determine whether a declaration is acceptable (visible/reachable).
15631 return Kind == AcceptableKind::Visible ? isVisible(D) : isReachable(D);
15632 }
15633
15634 /// Determine if \p D and \p Suggested have a structurally compatible
15635 /// layout as described in C11 6.2.7/1.
15636 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15637
15638 /// Determine if \p D has a visible definition. If not, suggest a declaration
15639 /// that should be made visible to expose the definition.
15640 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15641 bool OnlyNeedComplete = false);
15643 NamedDecl *Hidden;
15644 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15645 }
15646 /// Determine if \p D has a definition which allows we redefine it in current
15647 /// TU. \p Suggested is the definition that should be made visible to expose
15648 /// the definition.
15649 bool isRedefinitionAllowedFor(NamedDecl *D, NamedDecl **Suggested,
15650 bool &Visible);
15652 NamedDecl *Hidden;
15653 return isRedefinitionAllowedFor(const_cast<NamedDecl *>(D), &Hidden,
15654 Visible);
15655 }
15656
15657 /// Determine if \p D has a reachable definition. If not, suggest a
15658 /// declaration that should be made reachable to expose the definition.
15659 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15660 bool OnlyNeedComplete = false);
15662 NamedDecl *Hidden;
15663 return hasReachableDefinition(D, &Hidden);
15664 }
15665
15666 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15667 AcceptableKind Kind,
15668 bool OnlyNeedComplete = false);
15670 NamedDecl *Hidden;
15671 return hasAcceptableDefinition(D, &Hidden, Kind);
15672 }
15673
15674 /// Try to parse the conditional expression attached to an effect attribute
15675 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
15676 /// optional on error.
15677 std::optional<FunctionEffectMode>
15678 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
15679
15680 void ActOnCleanupAttr(Decl *D, const Attr *A);
15681 void ActOnInitPriorityAttr(Decl *D, const Attr *A);
15682
15683private:
15684 /// The implementation of RequireCompleteType
15685 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15686 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15687
15688 /// Nullability type specifiers.
15689 IdentifierInfo *Ident__Nonnull = nullptr;
15690 IdentifierInfo *Ident__Nullable = nullptr;
15691 IdentifierInfo *Ident__Nullable_result = nullptr;
15692 IdentifierInfo *Ident__Null_unspecified = nullptr;
15693
15694 ///@}
15695
15696 //
15697 //
15698 // -------------------------------------------------------------------------
15699 //
15700 //
15701
15702 /// \name FixIt Helpers
15703 /// Implementations are in SemaFixItUtils.cpp
15704 ///@{
15705
15706public:
15707 /// Get a string to suggest for zero-initialization of a type.
15709 SourceLocation Loc) const;
15710 std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
15711
15712 ///@}
15713
15714 //
15715 //
15716 // -------------------------------------------------------------------------
15717 //
15718 //
15719
15720 /// \name Function Effects
15721 /// Implementations are in SemaFunctionEffects.cpp
15722 ///@{
15723public:
15726
15729 std::optional<FunctionEffectWithCondition>
15730 Old; // Invalid when 'Kind' is 'Added'.
15731 std::optional<FunctionEffectWithCondition>
15732 New; // Invalid when 'Kind' is 'Removed'.
15733
15734 StringRef effectName() const {
15735 if (Old)
15736 return Old.value().Effect.name();
15737 return New.value().Effect.name();
15738 }
15739
15740 /// Describes the result of effects differing between a base class's virtual
15741 /// method and an overriding method in a subclass.
15742 enum class OverrideResult {
15745 Merge // Merge missing effect from base to derived.
15746 };
15747
15748 /// Return true if adding or removing the effect as part of a type
15749 /// conversion should generate a diagnostic.
15751 const FunctionEffectsRef &SrcFX,
15752 QualType DstType,
15753 const FunctionEffectsRef &DstFX) const;
15754
15755 /// Return true if adding or removing the effect in a redeclaration should
15756 /// generate a diagnostic.
15757 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
15758 const FunctionEffectsRef &OldFX,
15759 const FunctionDecl &NewFunction,
15760 const FunctionEffectsRef &NewFX) const;
15761
15762 /// Return true if adding or removing the effect in a C++ virtual method
15763 /// override should generate a diagnostic.
15765 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
15766 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
15767 };
15768
15769 struct FunctionEffectDiffVector : public SmallVector<FunctionEffectDiff> {
15770 /// Caller should short-circuit by checking for equality first.
15772 const FunctionEffectsRef &New);
15773 };
15774
15775 /// All functions/lambdas/blocks which have bodies and which have a non-empty
15776 /// FunctionEffectsRef to be verified.
15778
15779 /// The union of all effects present on DeclsWithEffectsToVerify. Conditions
15780 /// are all null.
15782
15783public:
15784 /// Warn and return true if adding a function effect to a set would create a
15785 /// conflict.
15788 SourceLocation NewAttrLoc);
15789
15790 // Report a failure to merge function effects between declarations due to a
15791 // conflict.
15792 void
15794 SourceLocation NewLoc,
15795 SourceLocation OldLoc);
15796
15797 /// Inline checks from the start of maybeAddDeclWithEffects, to
15798 /// minimize performance impact on code not using effects.
15799 template <class FuncOrBlockDecl>
15800 void maybeAddDeclWithEffects(FuncOrBlockDecl *D) {
15801 if (Context.hasAnyFunctionEffects())
15802 if (FunctionEffectsRef FX = D->getFunctionEffects(); !FX.empty())
15804 }
15805
15806 /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify.
15807 void maybeAddDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15808
15809 /// Unconditionally add a Decl to DeclsWithEfffectsToVerify.
15810 void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15811
15813
15814 ///@}
15815};
15816
15817DeductionFailureInfo
15819 sema::TemplateDeductionInfo &Info);
15820
15821/// Contains a late templated function.
15822/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15825 /// The template function declaration to be late parsed.
15827 /// Floating-point options in the point of definition.
15829};
15830
15831template <>
15833 PragmaMsStackAction Action,
15834 llvm::StringRef StackSlotLabel,
15836
15837} // end namespace clang
15838
15839#endif
#define V(N, I)
Forward declaration of all AST node types.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines enum values for all the target-independent builtin functions.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
Defines enumerations for expression traits intrinsics.
Token Tok
The Token.
FormatToken * Previous
The previous token in the unwrapped line.
static const Decl * getCanonicalDecl(const Decl *D)
Result
Implement __builtin_bit_cast and related operations.
#define X(type, name)
Definition Value.h:97
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
Definition MachO.h:31
Defines the clang::Module class, which describes a module in the source code.
#define SM(sm)
Defines the clang::OpenCLOptions class.
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
llvm::json::Object Object
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
AccessResult
A copy of Sema's enum without AR_delayed.
CastType
Definition SemaCast.cpp:50
static void CheckFormatString(Sema &S, const FormatStringLiteral *FExpr, const StringLiteral *ReferenceFormatString, const Expr *OrigFormatExpr, ArrayRef< const Expr * > Args, Sema::FormatArgumentPassingKind APK, unsigned format_idx, unsigned firstDataArg, FormatStringType Type, bool inFunctionCall, VariadicCallType CallType, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg, bool IgnoreStringsWithoutSpecifiers)
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
Sema::AllowedExplicit AllowedExplicit
This file declares semantic analysis functions specific to RISC-V.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Defines a utilitiy for warning once when close to out of stack space.
Defines the clang::TemplateNameKind enum.
Defines the clang::TokenKind enum and support functions.
Defines the clang::TypeLoc interface and its subclasses.
Defines enumerations for the type traits support.
TypePropertyCache< Private > Cache
Definition Type.cpp:4914
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:229
Represents a member of a struct/union/class.
Definition Decl.h:3182
a trap message and trap category.
A class for storing results from argument-dependent lookup.
Definition Lookup.h:871
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:35
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:229
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:427
Writes an AST file containing the contents of a translation unit.
Definition ASTWriter.h:97
Represents an access specifier followed by colon ':'.
Definition DeclCXX.h:86
PtrTy get() const
Definition Ownership.h:171
bool isInvalid() const
Definition Ownership.h:167
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2724
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3784
Attr - This represents one attribute.
Definition Attr.h:46
Represents a C++ declaration that introduces decls from somewhere else.
Definition DeclCXX.h:3501
A binding in a decomposition declaration.
Definition DeclCXX.h:4190
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4694
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:2620
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2952
Represents a C++ base or member initializer.
Definition DeclCXX.h:2385
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2630
Represents a C++ destructor within a class.
Definition DeclCXX.h:2882
CXXFieldCollector - Used to keep track of CXXFieldDecls during parsing of C++ classes.
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2132
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:76
Represents the this expression in C++.
Definition ExprCXX.h:1158
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:2946
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4966
CaseStmt - Represent a case statement.
Definition Stmt.h:1930
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3679
CharUnits - This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
Abstract interface for a consumer of code-completion information.
Declaration of a C++20 concept.
A reference to a concept and its template args, as it appears in the code.
Definition ASTConcept.h:130
Represents the specialization of a concept - evaluates to a prvalue of type bool.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:47
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition DeclCXX.h:3682
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.
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:1395
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1462
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1273
Captures information about "declaration specifiers".
Definition DeclSpec.h:220
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:867
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition DeclBase.h:850
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:991
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:780
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1948
A decomposition declaration.
Definition DeclCXX.h:4254
Captures a template argument whose value has been deduced via c++ template argument deduction.
Definition Template.h:333
A dependently-generated diagnostic.
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:233
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3445
Represents an enum.
Definition Decl.h:4033
Store information needed for an explicit specifier.
Definition DeclCXX.h:1931
The return type of classify().
Definition Expr.h:339
This represents one expression.
Definition Expr.h:112
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
Definition Expr.h:805
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition Expr.cpp:282
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.
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
Represents a member of a struct/union/class.
Definition Decl.h:3182
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:260
FileNullability & operator[](FileID file)
Definition Sema.h:271
FileNullability Nullability
Definition Sema.h:267
Represents a function declaration or definition.
Definition Decl.h:2018
A mutable set of FunctionEffect::Kind.
Definition TypeBase.h:5223
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5337
Kind
Identifies the particular effect.
Definition TypeBase.h:4985
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition TypeBase.h:5169
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4841
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5369
Declaration of a template function.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4591
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4565
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:622
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3489
Describes an C or C++ initializer list.
Definition Expr.h:5302
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:524
FPEvalMethodKind
Possible float expression evaluation method choices.
ComplexRangeKind
Controls the various implementations for complex multiplication and.
FPExceptionModeKind
Possible floating point exception behavior.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents a lazily-loaded vector of data.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
Definition Template.h:371
Represents the results of name lookup.
Definition Lookup.h:147
A global _GUID constant.
Definition DeclCXX.h:4403
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4349
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4920
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3367
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3715
Abstract interface for a module loader.
Describes a module or submodule.
Definition Module.h:340
bool isModulePartitionImplementation() const
Is this a module partition implementation unit.
Definition Module.h:877
Module(ModuleConstructorTag, StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit, unsigned VisibilityID)
Construct a new module or submodule.
Definition Module.cpp:36
bool isModuleImplementation() const
Is this a module implementation.
Definition Module.h:882
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:274
Represent a C++ namespace.
Definition Decl.h:592
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents an ObjC class declaration.
Definition DeclObjC.h:1154
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition TypeBase.h:8063
Wrapper for void* pointer.
Definition Ownership.h:51
static OpaquePtr make(QualType P)
Definition Ownership.h:61
OpenCL supported extensions and optional core features.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
Definition Overload.h:1160
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Definition Attr.h:277
static constexpr unsigned IdxBitWidth
Definition Attr.h:279
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2185
Represents a parameter to a function.
Definition Decl.h:1808
ParsedAttr - Represents a syntactic attribute.
Definition ParsedAttr.h:119
ParsedAttributes - A collection of parsed attributes.
Definition ParsedAttr.h:937
Represents the parsed form of a C++ template argument.
void Emit(const DiagnosticBuilder &DB) const
PreferredTypeBuilder(ASTContext *Ctx, bool Enabled)
Definition Sema.h:294
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)
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
Definition Sema.h:330
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Stores the type being destroyed by a pseudo-destructor expression.
Definition ExprCXX.h:2698
A (possibly-)qualified type.
Definition TypeBase.h:937
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
Represents a struct/union/class.
Definition Decl.h:4347
Represents the body of a requires-expression.
Definition DeclCXX.h:2101
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:41
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:111
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition SemaBase.cpp:33
SemaBase(Sema &S)
Definition SemaBase.cpp:7
Sema & SemaRef
Definition SemaBase.h:40
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
Definition Sema.h:1873
bool operator==(const AlignPackInfo &Info) const
Definition Sema.h:1933
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition Sema.h:1905
unsigned getPackNumber() const
Definition Sema.h:1923
bool IsXLStack() const
Definition Sema.h:1931
bool IsPackSet() const
Definition Sema.h:1925
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition Sema.h:1879
bool IsAlignAttr() const
Definition Sema.h:1919
bool IsPackAttr() const
Definition Sema.h:1917
bool operator!=(const AlignPackInfo &Info) const
Definition Sema.h:1939
AlignPackInfo(bool IsXL)
Definition Sema.h:1883
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition Sema.h:1890
Mode getAlignMode() const
Definition Sema.h:1921
ArgPackSubstIndexRAII(Sema &Self, UnsignedOrNone NewSubstIndex)
Definition Sema.h:13755
ArgPackSubstIndexRAII & operator=(const ArgPackSubstIndexRAII &)=delete
ArgPackSubstIndexRAII(const ArgPackSubstIndexRAII &)=delete
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8365
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8370
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition Sema.h:8357
std::tuple< const Ts &... > Args
Definition Sema.h:8354
CXXThisScopeRAII(const CXXThisScopeRAII &)=delete
CXXThisScopeRAII & operator=(const CXXThisScopeRAII &)=delete
CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals, bool Enabled=true)
Introduce a new scope where 'this' may be allowed (when enabled), using the given declaration (which ...
CompoundScopeRAII & operator=(const CompoundScopeRAII &)=delete
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition Sema.h:1317
CompoundScopeRAII(const CompoundScopeRAII &)=delete
std::pair< VarDecl *, Expr * > get() const
Definition Sema.h:7904
std::optional< bool > getKnownValue() const
Definition Sema.h:7908
A RAII object to temporarily push a declaration context.
Definition Sema.h:3526
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition Sema.h:3536
ContextRAII & operator=(const ContextRAII &)=delete
ContextRAII(const ContextRAII &)=delete
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition Sema.h:10409
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:10414
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.
DefaultedComparisonKind asComparison() const
Definition Sema.h:6470
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition Sema.h:6447
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition Sema.h:6475
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition Sema.h:6450
CXXSpecialMemberKind asSpecialMember() const
Definition Sema.h:6467
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition Sema.h:10137
DeferDiagsRAII & operator=(const DeferDiagsRAII &)=delete
DeferDiagsRAII(const DeferDiagsRAII &)=delete
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition Sema.h:1386
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition Sema.h:1405
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition Sema.h:1429
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition Sema.h:1398
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition Sema.h:1401
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:1415
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition Sema.h:1421
A helper class for building up ExtParameterInfos.
Definition Sema.h:13120
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:13139
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13127
FPFeaturesStateRAII(const FPFeaturesStateRAII &)=delete
FPOptionsOverride getOverrides()
Definition Sema.h:14161
FPFeaturesStateRAII & operator=(const FPFeaturesStateRAII &)=delete
FpPragmaStackSaveRAII(const FpPragmaStackSaveRAII &)=delete
FpPragmaStackSaveRAII & operator=(const FpPragmaStackSaveRAII &)=delete
FullExprArg(Sema &actions)
Definition Sema.h:7848
ExprResult release()
Definition Sema.h:7850
friend class Sema
Definition Sema.h:7859
Expr * get() const
Definition Sema.h:7852
GlobalEagerInstantiationScope(const GlobalEagerInstantiationScope &)=delete
GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
Definition Sema.h:14173
GlobalEagerInstantiationScope & operator=(const GlobalEagerInstantiationScope &)=delete
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:10473
virtual SemaDiagnosticBuilder diagnoseNotInt(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress, bool SuppressConversion)
Definition Sema.h:10465
unsigned size() const
The number of exceptions in the exception specification.
Definition Sema.h:5569
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition Sema.h:5562
const QualType * data() const
The set of exceptions in the exception specification.
Definition Sema.h:5572
void CalledStmt(Stmt *S)
Integrate an invoked statement into the collected data.
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
Definition Sema.h:5578
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition Sema.h:5585
LambdaScopeForCallOperatorInstantiationRAII(Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope, bool ShouldAddDeclsFromParentScope=true)
LocalEagerInstantiationScope & operator=(const LocalEagerInstantiationScope &)=delete
LocalEagerInstantiationScope(Sema &S, bool AtEndOfTU)
Definition Sema.h:14124
LocalEagerInstantiationScope(const LocalEagerInstantiationScope &)=delete
static NameClassification DependentNonType()
Definition Sema.h:3747
static NameClassification VarTemplate(TemplateName Name)
Definition Sema.h:3757
ExprResult getExpression() const
Definition Sema.h:3783
NameClassification(const IdentifierInfo *Keyword)
Definition Sema.h:3720
static NameClassification Unknown()
Definition Sema.h:3727
static NameClassification OverloadSet(ExprResult E)
Definition Sema.h:3731
NameClassificationKind getKind() const
Definition Sema.h:3781
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition Sema.h:3775
static NameClassification FunctionTemplate(TemplateName Name)
Definition Sema.h:3763
NamedDecl * getNonTypeDecl() const
Definition Sema.h:3793
NameClassification(ParsedType Type)
Definition Sema.h:3717
TemplateName getTemplateName() const
Definition Sema.h:3798
ParsedType getType() const
Definition Sema.h:3788
TemplateNameKind getTemplateNameKind() const
Definition Sema.h:3807
static NameClassification NonType(NamedDecl *D)
Definition Sema.h:3737
static NameClassification Concept(TemplateName Name)
Definition Sema.h:3769
static NameClassification UndeclaredNonType()
Definition Sema.h:3743
static NameClassification TypeTemplate(TemplateName Name)
Definition Sema.h:3751
static NameClassification Error()
Definition Sema.h:3723
void operator()(sema::FunctionScopeInfo *Scope) const
Definition Sema.cpp:2582
PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct)
Definition SemaAttr.cpp:29
PragmaStackSentinelRAII(const PragmaStackSentinelRAII &)=delete
PragmaStackSentinelRAII & operator=(const PragmaStackSentinelRAII &)=delete
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition Sema.h:11499
SourceLocation getTemplateKeywordLoc() const
Definition Sema.h:11501
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition Sema.h:11496
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition Sema.h:12552
SFINAETrap & operator=(const SFINAETrap &)=delete
SFINAETrap(const SFINAETrap &)=delete
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition Sema.h:12586
SFINAETrap(Sema &S, bool WithAccessChecking=false)
Definition Sema.h:12568
bool withAccessChecking() const
Definition Sema.h:12589
sema::TemplateDeductionInfo * getDeductionInfo() const
Definition Sema.h:12581
SFINAETrap(Sema &S, sema::TemplateDeductionInfo &Info)
Definition Sema.h:12571
SatisfactionStackResetRAII(const SatisfactionStackResetRAII &)=delete
SatisfactionStackResetRAII & operator=(const SatisfactionStackResetRAII &)=delete
ScopedCodeSynthesisContext(Sema &S, const CodeSynthesisContext &Ctx)
Definition Sema.h:13674
ScopedCodeSynthesisContext & operator=(const ScopedCodeSynthesisContext &)=delete
ScopedCodeSynthesisContext(const ScopedCodeSynthesisContext &)=delete
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition Sema.h:8382
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8387
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8384
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition Sema.h:9400
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition Sema.h:9387
CXXMethodDecl * getMethod() const
Definition Sema.h:9390
void setMethod(CXXMethodDecl *MD)
Definition Sema.h:9391
void addContextNote(SourceLocation UseLoc)
Definition Sema.h:13640
SynthesizedFunctionScope(const SynthesizedFunctionScope &)=delete
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition Sema.h:13628
SynthesizedFunctionScope & operator=(const SynthesizedFunctionScope &)=delete
SourceLocation getLocation() const
Definition Sema.h:12310
bool ContainsDecl(const NamedDecl *ND) const
Definition Sema.h:12300
const DeclContext * getDeclContext() const
Definition Sema.h:12306
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition Sema.h:12284
const NamedDecl * getDecl() const
Definition Sema.h:12298
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition Sema.h:12283
const DeclContext * getLexicalDeclContext() const
Definition Sema.h:12302
TentativeAnalysisScope(Sema &SemaRef)
Definition Sema.h:12603
TentativeAnalysisScope & operator=(const TentativeAnalysisScope &)=delete
TentativeAnalysisScope(const TentativeAnalysisScope &)=delete
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition Sema.h:7807
virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc)
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:868
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...
void DeclareGlobalNewDelete()
DeclareGlobalNewDelete - Declare the global forms of operator new and delete.
bool TryFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy) const
Same as IsFunctionConversion, but if this would return true, it sets ResultTy to ToType.
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs)
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
IfExistsResult CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo)
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
bool DiscardingCFIUncheckedCallee(QualType From, QualType To) const
Returns true if From is a function or pointer to a function with the cfi_unchecked_callee attribute b...
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.
QualType BuildParenType(QualType T)
Build a paren type including T.
SemaAMDGPU & AMDGPU()
Definition Sema.h:1448
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
SmallVector< DeclaratorDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
Definition Sema.h:3625
FunctionDecl * FindUsualDeallocationFunction(SourceLocation StartLoc, ImplicitDeallocationParameters, DeclarationName Name, bool Diagnose=true)
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXTypeid - Parse typeid( something ).
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
Definition Sema.h:13705
ExprResult ActOnCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn)
pragma optimize("[optimization-list]", on | off).
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 BuiltinConstantArgShiftedByte(CallExpr *TheCall, unsigned ArgNum, unsigned ArgBits)
BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is a constant expression represen...
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
ExprResult BuildOperatorCoawaitCall(SourceLocation Loc, Expr *E, UnresolvedLookupExpr *Lookup)
Build a call to 'operator co_await' if there is a suitable operator for the given expression.
ConceptDecl * ActOnStartConceptDefinition(Scope *S, MultiTemplateParamsArg TemplateParameterLists, const IdentifierInfo *Name, SourceLocation NameLoc)
std::optional< ExpressionEvaluationContextRecord::InitializationContext > InnermostDeclarationWithDelayedImmediateInvocations() const
Definition Sema.h:8287
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
Definition SemaAttr.cpp:546
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition Sema.h:13689
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...
bool BuiltinConstantArgMultiple(CallExpr *TheCall, unsigned ArgNum, unsigned Multiple)
BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr TheCall is a constant expr...
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:11057
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition Sema.h:13149
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
Definition Sema.cpp:2655
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition Sema.h:1141
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...
TemplateDeductionResult DeduceTemplateArgumentsFromType(TemplateDecl *TD, QualType FromType, sema::TemplateDeductionInfo &Info)
Deduce the template arguments of the given template from FromType.
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
friend class ASTWriter
Definition Sema.h:1591
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope, LabelDecl *Label, SourceLocation LabelLoc)
SmallVector< SmallVector< VTableUse, 16 >, 8 > SavedVTableUses
Definition Sema.h:14109
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
void PopParsingClass(ParsingClassState state)
Definition Sema.h:6638
void DiagnoseAbstractType(const CXXRecordDecl *RD)
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc, const LookupResult *R=nullptr, const UsingDecl *UD=nullptr)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
Definition Sema.h:10150
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition Sema.cpp:1087
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
std::optional< QualType > BuiltinVectorMath(CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr=EltwiseBuiltinArgTyRestriction::None)
bool CheckExplicitObjectOverride(CXXMethodDecl *New, const CXXMethodDecl *Old)
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
Definition Sema.h:6627
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
QualType CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
void ActOnPragmaExport(IdentifierInfo *IdentId, SourceLocation ExportNameLoc, Scope *curScope)
ActonPragmaExport - called on well-formed '#pragma export'.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs, SmallVectorImpl< const Attr * > &OutAttrs)
Process the attributes before creating an attributed statement.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
Unary Operators. 'Tok' is the token for the operator.
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition Sema.h:8337
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',...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
llvm::DenseSet< Module * > & getLookupModules()
Get the set of additional modules that should be checked during name lookup.
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
bool isAlwaysConstantEvaluatedContext() const
Definition Sema.h:8255
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:955
bool isAttrContext() const
Definition Sema.h:7034
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
ExprResult BuildBoolLiteral(SourceLocation Loc, bool Value)
Build a boolean-typed literal expression.
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.
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:8330
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition Sema.cpp:2755
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition Sema.h:6389
LookupNameKind
Describes the kind of name lookup to perform.
Definition Sema.h:9416
@ LookupLabel
Label name lookup.
Definition Sema.h:9425
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition Sema.h:9420
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition Sema.h:9447
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition Sema.h:9439
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition Sema.h:9461
@ LookupLocalFriendName
Look up a friend of a local class.
Definition Sema.h:9455
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition Sema.h:9457
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition Sema.h:9452
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition Sema.h:9432
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition Sema.h:9459
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition Sema.h:9443
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9428
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition Sema.h:9435
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9423
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition Sema.h:9463
@ LookupAnyName
Look up any declaration with any name.
Definition Sema.h:9465
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:416
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition Sema.h:9366
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition Sema.h:4950
UnaryTransformType::UTTKind UTTKind
Definition Sema.h:15518
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.
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
void ActOnPopScope(SourceLocation Loc, Scope *S)
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
ExprResult CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBLoc)
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
ActOnPragmaDetectMismatch - Call on well-formed #pragma detect_mismatch.
Definition SemaAttr.cpp:671
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:6326
SemaM68k & M68k()
Definition Sema.h:1498
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
void EvaluateImplicitExceptionSpec(SourceLocation Loc, FunctionDecl *FD)
Evaluate the implicit exception specification for a defaulted special member function.
bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount)
Checks that a call expression's argument count is at most the desired number.
void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
bool checkPointerAuthDiscriminatorArg(Expr *Arg, PointerAuthDiscArgKind Kind, unsigned &IntVal)
void PrintContextStack(InstantiationContextDiagFuncRef DiagFunc)
Definition Sema.h:13767
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)
ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E)
ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression found in an explicit(bool)...
bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum)
Returns true if the argument consists of one contiguous run of 1s with any number of 0s on either sid...
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
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...
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.
ExprResult SubstConceptTemplateArguments(const ConceptSpecializationExpr *CSE, const Expr *ConstraintExpr, const MultiLevelTemplateArgumentList &MLTAL)
Substitute concept template arguments in the constraint expression of a concept-id.
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
DelayedDiagnosticsState ParsingDeclState
Definition Sema.h:1381
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
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)
void deduceOpenCLAddressSpace(VarDecl *decl)
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:2141
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...
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.
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...
bool hasReachableDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
MissingImportKind
Kinds of missing import.
Definition Sema.h:9854
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, ImplicitDeallocationParameters, bool Diagnose=true)
ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E)
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc, Expr *DefaultArg)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
bool areVectorTypesSameSize(QualType srcType, QualType destType)
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.
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val, SkipBodyInfo *SkipBody=nullptr)
bool hasVisibleDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
static std::enable_if_t< std::is_base_of_v< Attr, AttrInfo >, SourceLocation > getAttrLoc(const AttrInfo &AL)
A helper function to provide Attribute Location for the Attr types AND the ParsedAttr.
Definition Sema.h:4895
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID)
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 directive...
RetainOwnershipKind
Definition Sema.h:5124
OpaquePtr< QualType > TypeTy
Definition Sema.h:1301
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
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:170
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
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:366
void PrintContextStack()
Definition Sema.h:13776
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...
bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc, StringRef Keyword)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition SemaStmt.cpp:631
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings={})
SemaOpenMP & OpenMP()
Definition Sema.h:1533
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition Sema.h:9365
void ActOnStartStmtExpr()
bool ActOnTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, MultiExprArg Args)
llvm::function_ref< void(SourceLocation, PartialDiagnostic)> InstantiationContextDiagFuncRef
Definition Sema.h:2316
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition Sema.h:6364
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition Sema.h:9730
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt={})
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition Sema.h:1369
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
bool BoundsSafetyCheckAssignmentToCountAttrPtr(QualType LHSTy, Expr *RHSExpr, AssignmentAction Action, SourceLocation Loc, const ValueDecl *Assignee, bool ShowFullyQualifiedAssigneeName)
Perform Bounds Safety Semantic checks for assigning to a __counted_by or __counted_by_or_null pointer...
void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
llvm::DenseMap< const EnumDecl *, llvm::SmallVector< llvm::APSInt > > AssignEnumCache
A cache of enumerator values for enums checked by -Wassign-enum.
Definition Sema.h:3581
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
void CheckExplicitObjectMemberFunction(Declarator &D, DeclarationName Name, QualType R, bool IsLambda, DeclContext *DC=nullptr)
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
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....
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition Sema.h:15186
StmtResult ActOnForEachLValueExpr(Expr *E)
In an Objective C collection iteration statement: for (x in y) x can be an arbitrary l-value expressi...
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:1262
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
Definition Sema.h:4797
void CheckFloatComparison(SourceLocation Loc, const Expr *LHS, const Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition Sema.h:3607
PragmaClangSection PragmaClangRodataSection
Definition Sema.h:1845
QualType tryBuildStdTypeIdentity(QualType Type, SourceLocation Loc)
Looks for the std::type_identity template and instantiates it with Type, or returns a null type if ty...
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
std::optional< FunctionEffectMode > ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName)
Try to parse the conditional expression attached to an effect attribute (e.g.
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
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.
bool hasVisibleDefinition(const NamedDecl *D)
Definition Sema.h:15642
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, const IdentifierInfo *IIEnvironment, const IdentifierInfo *InferredPlatformII=nullptr)
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:6600
bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis=false, bool CanIndexVariadicArguments=false)
Check if IdxExpr is a valid parameter index for a function or instance method D.
Definition Sema.h:5223
void emitAndClearUnusedLocalTypedefWarnings()
Definition Sema.cpp:1187
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...
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Definition Sema.h:6581
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
Definition SemaStmt.cpp:85
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
TemplateName SubstTemplateName(SourceLocation TemplateKWLoc, NestedNameSpecifierLoc &QualifierLoc, TemplateName Name, SourceLocation NameLoc, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
VarDecl * buildCoroutinePromise(SourceLocation Loc)
unsigned CapturingFunctionScopes
Track the number of currently active capturing scopes.
Definition Sema.h:1251
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true)
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:1473
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)
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 ...
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...
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:372
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
Definition Sema.h:7924
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7926
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7925
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition Sema.h:1350
void AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc)
Adds the 'optnone' attribute to the function declaration if there are no conflicts; Loc represents th...
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Definition Sema.h:15601
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition Sema.h:15192
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
bool needsRebuildOfDefaultArgOrInit() const
Definition Sema.h:8275
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicCallType::DoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
@ PartitionImplementation
'module X:Y;'
Definition Sema.h:9968
@ Interface
'export module X;'
Definition Sema.h:9965
@ Implementation
'module X;'
Definition Sema.h:9966
@ PartitionInterface
'export module X:Y;'
Definition Sema.h:9967
SourceLocation LocationOfExcessPrecisionNotSatisfied
Definition Sema.h:8417
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition Sema.h:1244
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()
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
Definition Sema.h:9677
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition Sema.h:10492
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition Sema.h:10495
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition Sema.h:10501
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition Sema.h:10499
void inferLifetimeCaptureByAttribute(FunctionDecl *FD)
Add [[clang:lifetime_capture_by(this)]] to STL container methods.
Definition SemaAttr.cpp:318
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:1803
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
@ AR_dependent
Definition Sema.h:1688
@ AR_accessible
Definition Sema.h:1686
@ AR_inaccessible
Definition Sema.h:1687
@ AR_delayed
Definition Sema.h:1689
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
@ Normal
Apply the normal rules for complete types.
Definition Sema.h:15199
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
Definition Sema.h:15203
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:660
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, SourceLocation EllipsisLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
Preprocessor & getPreprocessor() const
Definition Sema.h:938
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition Sema.h:7012
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition Sema.cpp:2427
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope, LabelDecl *Label, SourceLocation LabelLoc)
QualType GetSignedSizelessVectorType(QualType V)
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,...
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:439
void AddTemplateParametersToLambdaCallOperator(CXXMethodDecl *CallOperator, CXXRecordDecl *Class, TemplateParameterList *TemplateParams)
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
Annotation attributes are the only attributes allowed after an access specifier.
FunctionDecl * getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2)
Returns the more constrained function according to the rules of partial ordering by constraints (C++ ...
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
llvm::SmallPtrSet< ConstantExpr *, 4 > FailedImmediateInvocations
Definition Sema.h:8406
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition Sema.h:2076
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:8318
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition Sema.h:15193
PragmaStack< StringLiteral * > CodeSegStack
Definition Sema.h:2070
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)
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
void referenceDLLExportedClassMethods()
StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit=false)
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
void MarkCaptureUsedInEnclosingContext(ValueDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member function overrides a virtual...
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates.
void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX)
Unconditionally add a Decl to DeclsWithEfffectsToVerify.
FunctionEffectKindSet AllEffectsToVerify
The union of all effects present on DeclsWithEffectsToVerify.
Definition Sema.h:15781
void setFunctionHasBranchIntoScope()
Definition Sema.cpp:2608
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:4955
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition SemaStmt.cpp:485
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimizeoff". If this location is invalid,...
Definition Sema.h:2150
llvm::SmallSetVector< Expr *, 4 > MaybeODRUseExprSet
Store a set of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) t...
Definition Sema.h:6841
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool CheckOverridingFunctionAttributes(CXXMethodDecl *New, const CXXMethodDecl *Old)
void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind, StringRef Arg)
ActOnPragmaMSComment - Called on well formed #pragma comment(kind, "arg").
Definition SemaAttr.cpp:663
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...
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition Sema.h:2065
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:11222
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
Definition SemaAttr.cpp:54
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...
bool CheckFormatStringsCompatible(FormatStringType FST, const StringLiteral *AuthoritativeFormatString, const StringLiteral *TestedFormatString, const Expr *FunctionCallArg=nullptr)
Verify that two format strings (as understood by attribute(format) and attribute(format_matches) are ...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver)
If VD is set but not otherwise used, diagnose, for a parameter or a variable.
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.
void ActOnComment(SourceRange Comment)
Definition Sema.cpp:2707
bool IsCXXTriviallyRelocatableType(QualType T)
Determines if a type is trivially relocatable according to the C++26 rules.
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
@ Other
C++26 [dcl.fct.def.general]p1 function-body: ctor-initializer[opt] compound-statement function-try-bl...
Definition Sema.h:4198
@ Default
= default ;
Definition Sema.h:4200
@ Delete
deleted-function-body
Definition Sema.h:4206
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
bool RequireStructuralType(QualType T, SourceLocation Loc)
Require the given type to be a structural type, and diagnose if it is not.
ExprResult VerifyBitField(SourceLocation FieldLoc, const IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width,...
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
bool CheckOverflowBehaviorTypeConversion(Expr *E, QualType T, SourceLocation CC)
Check for overflow behavior type related implicit conversion diagnostics.
llvm::function_ref< void(llvm::raw_ostream &)> EntityPrinter
Definition Sema.h:14071
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
Definition SemaStmt.cpp:48
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.
bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS)
Check whether the given variable declaration has a size that fits within the address space it is decl...
TemplateDeductionResult FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, SmallVectorImpl< OriginalCallArg > const *OriginalCallArgs, bool PartialOverloading, bool PartialOrdering, bool ForOverloadSetAddressResolution, llvm::function_ref< bool(bool)> CheckNonDependent=[](bool) { return false;})
Finish template argument deduction for a function template, checking the deduced template arguments f...
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition Sema.cpp:1266
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
ExprResult EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, const APValue &PreNarrowingValue)
EvaluateConvertedConstantExpression - Evaluate an Expression That is a converted constant expression ...
ConceptDecl * ActOnFinishConceptDefinition(Scope *S, ConceptDecl *C, Expr *ConstraintExpr, const ParsedAttributesView &Attrs)
FPOptionsOverride CurFPFeatureOverrides()
Definition Sema.h:2077
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
Given a set of delayed diagnostics, re-emit them as if they had been delayed in the current context i...
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any.
SemaHexagon & Hexagon()
Definition Sema.h:1488
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation=false, bool RetainFunctionScopeInfo=false)
Performs semantic analysis at the end of a function body.
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types?
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef)
Add an init-capture to a lambda scope.
FieldDecl * BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture)
Build a FieldDecl suitable to hold the given capture.
concepts::Requirement * ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc)
void ActOnPragmaMSSeg(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, StringLiteral *SegmentName, llvm::StringRef PragmaName)
Called on well formed #pragma bss_seg/data_seg/const_seg/code_seg.
Definition SemaAttr.cpp:890
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
void CheckThreadLocalForLargeAlignment(VarDecl *VD)
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
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...
PersonalityAttr * mergePersonalityAttr(Decl *D, FunctionDecl *Routine, const AttributeCommonInfo &CI)
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.
llvm::DenseMap< llvm::FoldingSetNodeID, UnsubstitutedConstraintSatisfactionCacheResult > UnsubstitutedConstraintSatisfactionCache
Cache the satisfaction of an atomic constraint.
Definition Sema.h:15117
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
void ActOnTranslationUnitScope(Scope *S)
Scope actions.
Definition Sema.cpp:173
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD, bool Diagnose, bool LookForGlobal, DeclarationName Name)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
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.
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.
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition Sema.h:1558
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...
concepts::Requirement::SubstitutionDiagnostic * createSubstDiagAt(SourceLocation Location, EntityPrinter Printer)
create a Requirement::SubstitutionDiagnostic with only a SubstitutedEntity and DiagLoc using ASTConte...
sema::LambdaScopeInfo * RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator)
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
IdentifierInfo * getSuperIdentifier() const
Definition Sema.cpp:2982
StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
ExpressionEvaluationContextRecord & parentEvaluationContext()
Definition Sema.h:7024
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:1725
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
bool CheckConceptUseInDefinition(NamedDecl *Concept, SourceLocation Loc)
void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action, PragmaFloatControlKind Value)
ActOnPragmaFloatControl - Call on well-formed #pragma float_control.
Definition SemaAttr.cpp:706
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
Definition SemaExpr.cpp:838
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition Sema.h:11464
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT)
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition Sema.h:12062
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition Sema.h:12073
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition Sema.h:12065
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition Sema.h:12069
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:689
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:760
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old)
[module.interface]p6: A redeclaration of an entity X is implicitly exported if X was introduced by an...
void DiagnosePrecisionLossInComplexDivision()
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:9360
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
AvailabilityAttr * mergeAndInferAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, const IdentifierInfo *IIEnvironment, const IdentifierInfo *InferredPlatformII)
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
SemaX86 & X86()
Definition Sema.h:1578
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Look for instances where it is likely the comma operator is confused with another operator.
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:13709
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
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.
void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry)
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
ASTContext & Context
Definition Sema.h:1308
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain, bool PrimaryStrictPackMatch)
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:8242
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:686
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
bool DiagIfReachable(SourceLocation Loc, ArrayRef< const Stmt * > Stmts, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the statements's reachability analysis.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E)
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION()
This virtual key function only exists to limit the emission of debug info describing the Sema class.
bool ConstraintExpressionDependsOnEnclosingTemplate(const FunctionDecl *Friend, unsigned TemplateDepth, const Expr *Constraint)
bool BoundsSafetyCheckUseOfCountAttrPtr(const Expr *E)
Perform Bounds Safety semantic checks for uses of invalid uses counted_by or counted_by_or_null point...
void LazyProcessLifetimeCaptureByParams(FunctionDecl *FD)
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()
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
void MarkUsedTemplateParametersForSubsumptionParameterMapping(const Expr *E, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters are named in a given expression.
IdentifierSourceLocations TypoCorrectionFailures
A cache containing identifiers for which typo correction failed and their locations,...
Definition Sema.h:9371
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition Sema.h:7869
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
Definition SemaExpr.cpp:226
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc)
ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Definition SemaAttr.cpp:978
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
llvm::DenseMap< IdentifierInfo *, PendingPragmaInfo > PendingExportedNames
Definition Sema.h:2358
DiagnosticsEngine & getDiagnostics() const
Definition Sema.h:936
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...
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void DiagnoseTypeTraitDetails(const Expr *E)
If E represents a built-in type trait, or a known standard type trait, try to print more information ...
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
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.
void CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC, bool *ICContext=nullptr, bool IsListInit=false)
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, CheckNonDependentConversionsFlag UserConversionFlag, 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 * SkippedDefinitionContext
Definition Sema.h:4424
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15566
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
void resetFPOptions(FPOptions FPO)
Definition Sema.h:11445
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition Sema.h:15669
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions, bool Diagnose=true)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
bool isStdTypeIdentity(QualType Ty, QualType *TypeArgument, const Decl **MalformedDecl=nullptr)
Tests whether Ty is an instance of std::type_identity and, if it is and TypeArgument is not NULL,...
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:9951
DeclResult ActOnModuleImport(SourceLocation StartLoc, SourceLocation ExportLoc, SourceLocation ImportLoc, ModuleIdPath Path, bool IsPartition=false)
The parser has processed a module import declaration.
static bool getPrintable(bool B)
Definition Sema.h:15182
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
SemaObjC & ObjC()
Definition Sema.h:1518
bool InOverflowBehaviorAssignmentContext
Track if we're currently analyzing overflow behavior types in assignment context.
Definition Sema.h:1373
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...
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TrivialABIHandling::IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
void DiagPlaceholderFieldDeclDefinitions(RecordDecl *Record)
Emit diagnostic warnings for placeholder members.
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
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:2937
bool isRedefinitionAllowedFor(NamedDecl *D, NamedDecl **Suggested, bool &Visible)
Determine if D has a definition which allows we redefine it in current TU.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
bool FunctionParamTypesAreEqual(ArrayRef< QualType > Old, ArrayRef< QualType > New, unsigned *ArgPos=nullptr, bool Reversed=false)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their param...
SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags
Diagnostics that are emitted only if we discover that the given function must be codegen'ed.
Definition Sema.h:1443
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition SemaDecl.cpp:81
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool FullySubstituted=false)
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.
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:942
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition Sema.h:3199
bool captureSwiftVersionIndependentAPINotes()
Whether APINotes should be gathered for all applicable Swift language versions, without being applied...
Definition Sema.h:1669
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
PragmaStack< bool > StrictGuardStackCheckStack
Definition Sema.h:2073
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void PrintInstantiationStack()
Definition Sema.h:13780
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:3615
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
void CleanupVarDeclMarking()
bool CheckConstraintExpression(const Expr *CE, Token NextToken=Token(), bool *PossibleNonPrimary=nullptr, bool IsTrailingRequiresClause=false)
Check whether the given expression is a valid constraint expression.
ExprResult PerformImplicitObjectArgumentInitialization(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
Definition SemaExpr.cpp:759
bool isImmediateFunctionContext() const
Definition Sema.h:8267
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
ASTContext & getASTContext() const
Definition Sema.h:939
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Definition Sema.h:1081
void addExternalSource(IntrusiveRefCntPtr< ExternalSemaSource > E)
Registers an external source.
Definition Sema.cpp:661
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition SemaExpr.cpp:769
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...
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)
bool IsFloatingPointPromotion(QualType FromType, QualType ToType)
IsFloatingPointPromotion - Determines whether the conversion from FromType to ToType is a floating po...
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>.
Definition Sema.h:6607
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)
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition Sema.h:1435
void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules)
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.
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Check the redefinition in C++20 Modules.
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
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:6691
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
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()
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:2069
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
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:762
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
Definition SemaAttr.cpp:377
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:888
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
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:713
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition Sema.h:2637
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, bool DoCheckConstraintSatisfaction=true)
ParsingClassState PushParsingClass()
Definition Sema.h:6634
@ FRS_Success
Definition Sema.h:10880
@ FRS_DiagnosticIssued
Definition Sema.h:10882
@ FRS_NoViableFunction
Definition Sema.h:10881
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
void ActOnPragmaCXLimitedRange(SourceLocation Loc, LangOptions::ComplexRangeKind Range)
ActOnPragmaCXLimitedRange - Called on well formed #pragma STDC CX_LIMITED_RANGE.
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
TemplateParameterList * GetTemplateParameterList(TemplateDecl *TD)
Returns the template parameter list with all default template argument information.
void ActOnPragmaFPExceptions(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called on well formed '#pragma clang fp' that has option 'exceptions'.
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:112
SmallVector< LateInstantiatedAttribute, 1 > LateInstantiatedAttrVec
Definition Sema.h:14244
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition Sema.h:989
void mergeVisibilityType(Decl *D, SourceLocation Loc, VisibilityAttr::VisibilityType Type)
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition Sema.h:9413
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, SourceRange PlacementRange, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose=true)
Checks access to an overloaded operator new or delete.
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg, const DefaultArguments &DefaultArgs, SourceLocation ArgLoc, bool PartialOrdering, bool *StrictPackMatch)
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:9363
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.
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition Sema.h:6159
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
Definition Sema.h:6173
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
Definition Sema.h:6170
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
Definition Sema.h:6167
@ None
This is not a defaultable comparison operator.
Definition Sema.h:6161
@ Equal
This is an operator== that should be implemented as a series of subobject comparisons.
Definition Sema.h:6164
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)
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.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
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:9102
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.
SmallVector< const Decl * > DeclsWithEffectsToVerify
All functions/lambdas/blocks which have bodies and which have a non-empty FunctionEffectsRef to be ve...
Definition Sema.h:15777
@ Conversions
Allow explicit conversion functions but not explicit constructors.
Definition Sema.h:10201
@ All
Allow both explicit conversion functions and explicit constructors.
Definition Sema.h:10203
void ActOnFinishRequiresExpr()
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
Definition Sema.h:1234
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition Sema.h:6622
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
void * SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS)
Given a C++ nested-name-specifier, produce an annotation value that the parser can use later to recon...
ValueDecl * tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl, CXXScopeSpec &SS, ParsedType TemplateTypeTy, IdentifierInfo *MemberOrBase)
void ProcessPragmaWeak(Scope *S, Decl *D)
void DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range, DeclarationName Name, OverloadCandidateSet &CandidateSet, FunctionDecl *Fn, MultiExprArg Args, bool IsMember=false)
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
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.
bool BuiltinConstantArg(CallExpr *TheCall, unsigned ArgNum, llvm::APSInt &Result)
BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr TheCall is a constant expression.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition Sema.h:1212
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.
llvm::PointerUnion< const NamedDecl *, const concepts::NestedRequirement * > ConstrainedDeclOrNestedRequirement
Definition Sema.h:14986
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union.
bool CheckDeclCompatibleWithTemplateTemplate(TemplateDecl *Template, TemplateTemplateParmDecl *Param, const TemplateArgumentLoc &Arg)
bool pushCodeSynthesisContext(CodeSynthesisContext Ctx)
void ActOnPragmaFPEvalMethod(SourceLocation Loc, LangOptions::FPEvalMethodKind Value)
Definition SemaAttr.cpp:679
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
Definition Sema.h:3638
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:1730
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...
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition Sema.cpp:2698
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition Sema.h:3523
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
void CheckAttributesOnDeducedType(Decl *D)
CheckAttributesOnDeducedType - Calls Sema functions for attributes that requires the type to be deduc...
void handleLambdaNumbering(CXXRecordDecl *Class, CXXMethodDecl *Method, std::optional< CXXRecordDecl::LambdaNumbering > NumberingOverride=std::nullopt)
Number lambda for linkage purposes if necessary.
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, UnsignedOrNone NumExpansions)
void setFunctionHasIndirectGoto()
Definition Sema.cpp:2618
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 CheckConstraintSatisfaction(ConstrainedDeclOrNestedRequirement Entity, ArrayRef< AssociatedConstraint > AssociatedConstraints, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction, const ConceptReference *TopLevelConceptId=nullptr, Expr **ConvertedExpr=nullptr)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc)
Build a bit-precise integer type.
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition Sema.h:12242
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition Sema.h:12260
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition Sema.h:12250
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition Sema.h:12270
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
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:4946
EnumDecl * getStdAlignValT() const
const NormalizedConstraint * getNormalizedAssociatedConstraints(ConstrainedDeclOrNestedRequirement Entity, ArrayRef< AssociatedConstraint > AssociatedConstraints)
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
Definition Sema.cpp:1744
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
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 *.
ExprResult BuildCaptureInit(const sema::Capture &Capture, SourceLocation ImplicitCaptureLoc, bool IsOpenMPMapping=false)
Initialize the given capture with a suitable expression.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true, bool StrictPackMatch=false)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
Definition Sema.h:8448
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
Definition SemaAttr.cpp:432
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr * > Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
AssumedTemplateKind
Definition Sema.h:11514
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
Definition Sema.h:11521
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
Definition Sema.h:11518
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:838
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
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...
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfMove - Emits a warning if a value is moved to itself.
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)
AtomicArgumentOrder
Definition Sema.h:2744
void PushFunctionScope()
Enter a new function scope.
Definition Sema.cpp:2446
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.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:427
SourceRange getExprRange(Expr *E) const
Definition SemaExpr.cpp:511
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...
void setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called to set exception behavior for floating point operations.
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 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)
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
Definition Sema.h:11450
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
Definition SemaAttr.cpp:170
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:3611
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition Sema.h:8302
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateNameKind Kind, bool TypenameKeyword, TemplateParameterList *Params, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e....
static DeclarationName getPrintable(DeclarationName N)
Definition Sema.h:15189
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition Sema.h:4635
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id, bool IsUDSuffix)
friend class ASTReader
Definition Sema.h:1589
bool FriendConstraintsDependOnEnclosingTemplate(const FunctionDecl *FD)
void addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI)
Add a no_cluster attribute to a particular declaration.
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
Definition SemaStmt.cpp:405
FPOptions & getCurFPFeatures()
Definition Sema.h:934
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition Sema.h:8400
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
Definition Sema.cpp:273
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:84
sema::LambdaScopeInfo * PushLambdaScope()
Definition Sema.cpp:2464
StmtResult ActOnCoreturnStmt(Scope *S, SourceLocation KwLoc, Expr *E)
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
void PopCompoundScope()
Definition Sema.cpp:2597
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15610
bool EnsureTemplateArgumentListConstraints(TemplateDecl *Template, const MultiLevelTemplateArgumentList &TemplateArgs, SourceRange TemplateIDRange)
Ensure that the given template arguments satisfy the constraints associated with the given template,...
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition Sema.h:14507
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition Sema.h:14527
@ UPPC_RequiresClause
Definition Sema.h:14578
@ UPPC_UsingDeclaration
A using declaration.
Definition Sema.h:14533
@ UPPC_IfExists
Microsoft __if_exists.
Definition Sema.h:14560
@ UPPC_Requirement
Definition Sema.h:14575
@ UPPC_ExceptionType
The type of an exception.
Definition Sema.h:14551
@ UPPC_EnumeratorValue
The enumerator value.
Definition Sema.h:14530
@ UPPC_Lambda
Lambda expression.
Definition Sema.h:14566
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition Sema.h:14563
@ UPPC_PartialSpecialization
Partial specialization.
Definition Sema.h:14557
@ UPPC_Initializer
An initializer.
Definition Sema.h:14542
@ UPPC_BaseType
The base type of a class type.
Definition Sema.h:14512
@ UPPC_FriendDeclaration
A friend declaration.
Definition Sema.h:14536
@ UPPC_DefaultArgument
A default argument.
Definition Sema.h:14545
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition Sema.h:14515
@ UPPC_Expression
An arbitrary expression.
Definition Sema.h:14509
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition Sema.h:14554
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition Sema.h:14539
@ UPPC_DataMemberType
The type of a data member.
Definition Sema.h:14518
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition Sema.h:14524
@ UPPC_Block
Block expression.
Definition Sema.h:14569
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition Sema.h:14521
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition Sema.h:14548
@ UPPC_TypeConstraint
A type constraint.
Definition Sema.h:14572
api_notes::APINotesManager APINotes
Definition Sema.h:1312
bool BuiltinConstantArgRange(CallExpr *TheCall, unsigned ArgNum, int Low, int High, bool RangeIsError=true)
BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr TheCall is a constant express...
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:12622
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.
const LangOptions & getLangOpts() const
Definition Sema.h:932
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl, bool SupportedForCompatibility=false)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
bool RequireCompleteExprType(Expr *E, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
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?
llvm::PointerIntPair< Decl *, 2 > InstantiatingSpecializationsKey
Definition Sema.h:13163
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
StmtResult ActOnFinishFullStmt(Stmt *Stmt)
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
Definition Sema.h:5938
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Definition Sema.cpp:2558
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)
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
SourceLocation CurInitSegLoc
Definition Sema.h:2112
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition SemaAttr.cpp:767
SemaCodeCompletion & CodeCompletion()
Definition Sema.h:1468
void inferLifetimeBoundAttribute(FunctionDecl *FD)
Add [[clang:lifetimebound]] attr for std:: functions and methods.
Definition SemaAttr.cpp:238
ModularFormatAttr * mergeModularFormatAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *ModularImplFn, StringRef ImplName, MutableArrayRef< StringRef > Aspects)
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition Sema.h:3632
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:1523
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition Sema.h:14981
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
ReuseLambdaContextDecl_t
Definition Sema.h:7103
@ ReuseLambdaContextDecl
Definition Sema.h:7103
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.
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)
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.
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
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:940
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
bool isUnexpandedParameterPackPermitted()
Determine whether an unexpanded parameter pack might be permitted in this location.
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules,...
void diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD, SourceLocation Loc)
Produce diagnostics if FD is an aligned allocation or deallocation function that is unavailable.
SemaBPF & BPF()
Definition Sema.h:1463
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E)
Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
void * OpaqueParser
Definition Sema.h:1352
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false)
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr)
Diagnose an empty lookup.
Preprocessor & PP
Definition Sema.h:1307
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
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)
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
Definition Sema.h:2159
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
bool SubstTemplateArgumentsInParameterMapping(ArrayRef< TemplateArgumentLoc > Args, SourceLocation BaseLoc, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Out)
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition Sema.h:1347
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition Sema.h:2137
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, CXXRecordDecl *Base, CXXRecordDecl *Derived, const CXXBasePath &Path, unsigned DiagID, llvm::function_ref< void(PartialDiagnostic &PD)> SetupPDiag, bool ForceCheck=false, bool ForceUnprivileged=false)
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 ...
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:2236
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy)
Are the two types matrix types and do they have the same dimensions i.e.
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:3619
SemaDirectX & DirectX()
Definition Sema.h:1478
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition Sema.h:6583
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
SemaMSP430 & MSP430()
Definition Sema.h:1508
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
friend class ASTDeclReader
Definition Sema.h:1590
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
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={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool StrictPackMatch=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
const LangOptions & LangOpts
Definition Sema.h:1306
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 ...
NamedDecl * FindFirstQualifierInScope(Scope *S, NestedNameSpecifier NNS)
If the given nested-name-specifier begins with a bare identifier (e.g., Base::), perform name lookup ...
bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
ExprResult PerformQualificationConversion(Expr *E, QualType Ty, ExprValueKind VK=VK_PRValue, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
void PushExpressionEvaluationContextForFunction(ExpressionEvaluationContext NewContext, FunctionDecl *FD)
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)
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition Sema.h:1240
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition Sema.cpp:2673
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.
static const uint64_t MaximumAlignment
Definition Sema.h:1235
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition Sema.h:9105
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.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Definition SemaExpr.cpp:957
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition SemaStmt.cpp:416
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition Sema.h:15623
CUDAClusterDimsAttr * createClusterDimsAttr(const AttributeCommonInfo &CI, Expr *X, Expr *Y, Expr *Z)
Add a cluster_dims attribute to a particular declaration.
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition Sema.h:6585
SemaHLSL & HLSL()
Definition Sema.h:1483
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:11463
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition Sema.h:1238
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition Sema.h:9412
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
ExprResult ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ConvertVectorExpr - Handle __builtin_convertvector.
void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind)
Definition Sema.cpp:1206
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
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.
ExpressionEvaluationContextRecord & currentEvaluationContext()
Definition Sema.h:7018
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
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:1846
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
static StringRef GetFormatStringTypeName(FormatStringType FST)
SemaMIPS & MIPS()
Definition Sema.h:1503
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition Sema.cpp:140
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
void CompleteLambdaCallOperator(CXXMethodDecl *Method, SourceLocation LambdaLoc, SourceLocation CallOperatorLoc, const AssociatedConstraint &TrailingRequiresClause, TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind, StorageClass SC, ArrayRef< ParmVarDecl * > Params, bool HasExplicitResultType)
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
SemaRISCV & RISCV()
Definition Sema.h:1548
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)
void maybeAddDeclWithEffects(FuncOrBlockDecl *D)
Inline checks from the start of maybeAddDeclWithEffects, to minimize performance impact on code not u...
Definition Sema.h:15800
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition Sema.h:1835
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:5944
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....
ExprResult prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr)
Prepare SplattedExpr for a matrix splat operation, adding implicit casts if necessary.
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
Definition SemaExpr.cpp:215
void CheckCXXDefaultArguments(FunctionDecl *FD)
Helpers for dealing with blocks and functions.
bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes, bool OrNull)
Check if applying the specified attribute variant from the "counted by" family of attributes to Field...
ComparisonCategoryUsage
Definition Sema.h:5318
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
Definition Sema.h:5321
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
Definition Sema.h:5325
MemberPointerConversionDirection
Definition Sema.h:10333
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition Sema.h:14107
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition Sema.h:6578
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, TypeSourceInfo *TSI)
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
Definition SemaExpr.cpp:77
ConditionResult ActOnConditionVariable(Decl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type.
void performFunctionEffectAnalysis(TranslationUnitDecl *TU)
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
EltwiseBuiltinArgTyRestriction
Definition Sema.h:2810
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, SourceRange R)
Checks that a type is suitable as the allocated type in a new-expression.
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Diagnose cases where a scalar was implicitly converted to a vector and diagnose the underlying types.
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:15184
SemaSwift & Swift()
Definition Sema.h:1563
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...
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
PragmaStack< AlignPackInfo > AlignPackStack
Definition Sema.h:2058
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used,...
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:6683
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition Sema.h:7048
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition Sema.h:13736
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition Sema.h:6615
StmtResult ActOnExprStmtError()
Definition SemaStmt.cpp:65
PragmaStack< StringLiteral * > BSSSegStack
Definition Sema.h:2068
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...
CXXRecordDecl * getCurrentInstantiationOf(NestedNameSpecifier NNS)
If the given nested name specifier refers to the current instantiation, return the declaration that c...
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed.
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
void completeExprArrayBound(Expr *E)
DeclContext * getCurLexicalContext() const
Definition Sema.h:1145
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition Sema.h:1361
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:2115
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:1737
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)
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)
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:912
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
Definition SemaStmt.cpp:70
OpenCLOptions OpenCLFeatures
Definition Sema.h:1303
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
TemplateArgument getPackSubstitutedTemplateArgument(TemplateArgument Arg) const
Definition Sema.h:11868
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
Definition Sema.h:14111
void MarkVirtualBaseDestructorsReferenced(SourceLocation Location, CXXRecordDecl *ClassDecl, llvm::SmallPtrSetImpl< const CXXRecordDecl * > *DirectVirtualBases=nullptr)
Mark destructors of virtual bases of this class referenced.
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
Definition Sema.h:2162
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
void ExitDeclaratorContext(Scope *S)
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
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...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition Sema.cpp:869
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D)
Determine if we're in a case where we need to (incorrectly) eagerly parse an exception specification ...
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
bool buildCoroutineParameterMoves(SourceLocation Loc)
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMemberKind CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
llvm::SmallSetVector< Decl *, 4 > DeclsToCheckForDeferredDiags
Function or variable declarations to be checked for whether the deferred diagnostics should be emitte...
Definition Sema.h:4812
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, const CXXScopeSpec &SS)
DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc)
The parser has processed a global-module-fragment declaration that begins the definition of the globa...
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted)
void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams)
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
UnsignedOrNone getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
ReferenceConversionsScope::ReferenceConversions ReferenceConversions
Definition Sema.h:10520
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition Sema.h:15178
ProcessingContextState ParsingClassState
Definition Sema.h:6633
void DiagnoseMisalignedMembers()
Diagnoses the current set of gathered accesses.
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a Microsoft __uuidof expression with a type operand.
sema::FunctionScopeInfo * getCurFunction() const
Definition Sema.h:1341
NamedDecl * lookupExternCFunctionOrVariable(IdentifierInfo *IdentId, SourceLocation NameLoc, Scope *curScope)
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:2592
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
MemberPointerConversionResult CheckMemberPointerConversion(QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind, CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange, bool IgnoreBaseAccess, MemberPointerConversionDirection Direction)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx, StringEvaluationContext EvalContext, bool ErrorOnInvalidMessage)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData, StringRef FileName)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
bool isDeclaratorFunctionLike(Declarator &D)
Determine whether.
Definition Sema.cpp:3026
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it's plausible that E was intended to be a template-name.
Definition Sema.h:3884
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition Sema.h:2717
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
QualType BuiltinRemoveCVRef(QualType BaseType, SourceLocation Loc)
Definition Sema.h:15532
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
llvm::DenseMap< llvm::FoldingSetNodeID, TemplateArgumentLoc > * CurrentCachedTemplateArgs
Cache the instantiation results of template parameter mappings within concepts.
Definition Sema.h:15124
bool CheckNontrivialField(FieldDecl *FD)
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
Helper for delayed processing TransparentUnion or BPFPreserveAccessIndexAttr attribute.
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...
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition Sema.h:7045
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
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...
bool IsOverflowBehaviorTypeConversion(QualType FromType, QualType ToType)
IsOverflowBehaviorTypeConversion - Determines whether the conversion from FromType to ToType necessar...
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
StmtResult ActOnEndOfDeferStmt(Stmt *Body, Scope *CurScope)
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...
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
TemplateDeductionResult SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate, TemplateArgumentListInfo &ExplicitTemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< QualType > &ParamTypes, QualType *FunctionType, sema::TemplateDeductionInfo &Info)
Substitute the explicitly-provided template arguments into the given function template according to C...
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
Check the validity of a C++ base class specifier.
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
Definition Sema.cpp:2410
QualType BuildMemberPointerType(QualType T, const CXXScopeSpec &SS, CXXRecordDecl *Cls, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
UnsignedOrNone getPackIndex(TemplateArgument Pack) const
Definition Sema.h:11863
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:13161
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx=UINT_MAX, bool StrictlyUnsigned=false)
If Expr is a valid integer constant, get the value of the integer expression and return success or fa...
Definition Sema.h:4906
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.
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:5934
DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, ModuleDeclKind MDK, ModuleIdPath Path, ModuleIdPath Partition, ModuleImportState &ImportState, bool SeenNoTrivialPPDirective)
The parser has processed a module-declaration that begins the definition of a module interface or imp...
void MarkThisReferenced(CXXThisExpr *This)
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:644
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)
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:15617
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition Sema.h:8271
llvm::MapVector< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition Sema.h:3603
StringLiteral * CurInitSeg
Last section used with pragma init_seg.
Definition Sema.h:2111
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition Sema.h:9946
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
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,...
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
static bool isCast(CheckedConversionKind CCK)
Definition Sema.h:2572
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 *.
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...
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
bool IsAssignConvertCompatible(AssignConvertType ConvTy)
Definition Sema.h:8138
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:2628
ParsedTemplateArgument ActOnTemplateTemplateArgument(const ParsedTemplateArgument &Arg)
Invoked when parsing a template argument.
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
Definition Sema.h:7060
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
void DiagnoseUniqueObjectDuplication(const VarDecl *Dcl)
std::unique_ptr< RecordDeclSetTy > PureVirtualClassDiagSet
PureVirtualClassDiagSet - a set of class declarations which we have emitted a list of pure virtual fu...
Definition Sema.h:6592
void CheckTCBEnforcement(const SourceLocation CallExprLoc, const NamedDecl *Callee)
Enforce the bounds of a TCB CheckTCBEnforcement - Enforces that every function in a named TCB only di...
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
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:1446
auto getDefaultDiagFunc()
Definition Sema.h:2318
void ActOnInitPriorityAttr(Decl *D, const Attr *A)
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount)
Checks that a call expression's argument count is at least the desired number.
bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, AllocationFunctionScope NewScope, AllocationFunctionScope DeleteScope, QualType AllocType, bool IsArray, ImplicitAllocationParameters &IAP, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete, bool Diagnose=true)
Finds the overloads of operator new and delete that are appropriate for the allocation.
bool IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType)
IsOverflowBehaviorTypePromotion - Determines whether the conversion from FromType to ToType involves ...
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc)
ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const,addrspace}_cast's.
Definition SemaCast.cpp:315
DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc, SourceLocation PrivateLoc)
The parser has processed a private-module-fragment declaration that begins the definition of the priv...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition Sema.h:12623
ClassTemplateDecl * StdTypeIdentity
The C++ "std::type_identity" template, which is defined in <type_traits>.
Definition Sema.h:6611
SemaOpenCL & OpenCL()
Definition Sema.h:1528
void ActOnPragmaMSFunction(SourceLocation Loc, const llvm::SmallVectorImpl< StringRef > &NoBuiltins)
Call on well formed #pragma function.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition Sema.h:14120
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, SourceLocation Loc={}, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams, SourceLocation EllipsisLoc)
Handle a friend type declaration.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
Definition SemaAttr.cpp:659
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition Sema.h:2242
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
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:933
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:15194
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...
void ActOnStartOfDeferStmt(SourceLocation DeferLoc, Scope *CurScope)
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, ParsedType ObjectType)
FormatArgumentPassingKind
Definition Sema.h:2647
@ FAPK_Elsewhere
Definition Sema.h:2651
@ FAPK_Fixed
Definition Sema.h:2648
@ FAPK_Variadic
Definition Sema.h:2649
@ FAPK_VAList
Definition Sema.h:2650
void FillInlineAsmIdentifierInfo(Expr *Res, llvm::InlineAsmIdentifierInfo &Info)
bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived, CXXRecordDecl *Base, CXXBasePaths &Paths)
Determine whether the type Derived is a C++ class that is derived from the type Base.
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.
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:8263
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition Sema.h:13152
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition Sema.cpp:1705
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, NamedReturnInfo &NRInfo, bool SupressSimplerImplicitMoves)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes.
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr, bool ForTypeDeduction=false)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
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...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
Parsed a C++ 'new' expression (C++ 5.3.4).
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
StmtResult ActOnCapturedRegionEnd(Stmt *S)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
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:15630
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...
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, SourceLocation Loc)
DeclClonePragmaWeak - clone existing decl (maybe definition), #pragma weak needs a non-definition dec...
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
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)
std::pair< const NamedDecl *, llvm::FoldingSetNodeID > SatisfactionStackEntryTy
Definition Sema.h:14957
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
void CleanupMergedEnum(Scope *S, Decl *New)
CleanupMergedEnum - We have just merged the decl 'New' by making another definition visible.
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
Definition Sema.h:8459
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)
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition Sema.h:3629
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition Sema.h:6844
bool MSStructPragmaOn
Definition Sema.h:1832
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
ExprResult TransformToPotentiallyEvaluated(Expr *E)
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
void deduceHLSLAddressSpace(VarDecl *decl)
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:13720
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
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.
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:14055
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition Sema.h:15605
SourceManager & getSourceManager() const
Definition Sema.h:937
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
void ActOnCleanupAttr(Decl *D, const Attr *A)
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition Sema.h:8530
FunctionDecl * SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD, FunctionDecl *Spaceship)
Substitute the name and return type of a defaulted 'operator<=>' to form an implicit 'operator=='.
static FormatStringType GetFormatStringType(StringRef FormatFlavor)
CallingConventionIgnoredReason
Describes the reason a calling convention specification was ignored, used for diagnostics.
Definition Sema.h:4884
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.
bool CheckVecStepExpr(Expr *E)
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
Definition Sema.cpp:636
bool isModuleVisible(const Module *M, bool ModulePrivate=false)
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false, OverloadCandidateParamOrder PO={})
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
Definition Sema.h:3577
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
bool CheckRebuiltStmtAttributes(ArrayRef< const Attr * > Attrs)
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible.
bool hasVisibleMergedDefinition(const NamedDecl *Def)
void diagnoseFunctionEffectMergeConflicts(const FunctionEffectSet::Conflicts &Errs, SourceLocation NewLoc, SourceLocation OldLoc)
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
Definition Sema.cpp:972
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
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 ...
void diagnoseFunctionEffectConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn when implicitly changing function effects.
Definition Sema.cpp:702
ClassTemplateDecl * lookupCoroutineTraits(SourceLocation KwLoc, SourceLocation FuncLoc)
Lookup 'coroutine_traits' in std namespace and std::experimental namespace.
bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Definition Sema.h:12342
void PerformPendingInstantiations(bool LocalOnly=false, bool AtEndOfTU=true)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
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.
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.
bool CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *MD, DefaultedComparisonKind DCK)
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, ExprResult Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
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...
void PrintPragmaAttributeInstantiationPoint()
Definition Sema.h:2330
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Definition Sema.h:9406
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition SemaAttr.cpp:593
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....
bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount, unsigned MaxArgCount)
Checks that a call expression's argument count is in the desired range.
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
bool inConstraintSubstitution() const
Determine whether we are currently performing constraint substitution.
Definition Sema.h:14060
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 ValidateFormatString(FormatStringType FST, const StringLiteral *Str)
Verify that one format string (as understood by attribute(format)) is self-consistent; for instance,...
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...
StringEvaluationContext
Definition Sema.h:6054
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc)
PragmaClangSection PragmaClangTextSection
Definition Sema.h:1847
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks, ObjCInterfaceDecl *ClassReceiver)
CallExpr::ADLCallKind ADLCallKind
Definition Sema.h:7557
bool BoundsSafetyCheckInitialization(const InitializedEntity &Entity, const InitializationKind &Kind, AssignmentAction Action, QualType LHSType, Expr *RHSExpr)
Perform Bounds Safety Semantic checks for initializing a Bounds Safety pointer.
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
NonTrivialCUnionKind
Definition Sema.h:4137
@ NTCUK_Destruct
Definition Sema.h:4139
@ NTCUK_Init
Definition Sema.h:4138
@ NTCUK_Copy
Definition Sema.h:4140
FormatMatchesAttr * mergeFormatMatchesAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Format, int FormatIdx, StringLiteral *FormatStr)
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr=EltwiseBuiltinArgTyRestriction::None)
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
DelayedDiagnosticsState ProcessingContextState
Definition Sema.h:1382
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.
QualType BuildAtomicType(QualType T, SourceLocation Loc)
std::vector< std::pair< QualType, unsigned > > ExcessPrecisionNotSatisfied
Definition Sema.h:8416
PragmaClangSection PragmaClangDataSection
Definition Sema.h:1844
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
llvm::Error isValidSectionSpecifier(StringRef Str)
Used to implement to perform semantic checking on attribute((section("foo"))) specifiers.
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
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:9201
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, 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...
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
bool anyAltivecTypes(QualType srcType, QualType destType)
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?
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute.
ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc)
std::pair< AvailabilityResult, const NamedDecl * > ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message, ObjCInterfaceDecl *ClassReceiver)
The diagnostic we should emit for D, and the declaration that originated it, or AR_Available.
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
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.
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition Sema.cpp:2458
bool diagnoseConflictingFunctionEffect(const FunctionEffectsRef &FX, const FunctionEffectWithCondition &EC, SourceLocation NewAttrLoc)
Warn and return true if adding a function effect to a set would create a conflict.
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.
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:2057
TypeSourceInfo * ReplaceAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
Definition SemaAttr.cpp:90
QualType CXXCheckConditionalOperands(ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc)
Check the operands of ?
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)
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
MaybeODRUseExprSet MaybeODRUseExprs
Definition Sema.h:6842
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition Sema.h:942
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:1248
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition Sema.h:2118
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool isSFINAEContext() const
Definition Sema.h:13788
FunctionDecl * BuildTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl, QualType AllocType, SourceLocation)
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition Sema.h:8886
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...
static SourceRange getPrintable(SourceRange R)
Definition Sema.h:15191
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)
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.
UnsignedOrNone ArgPackSubstIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition Sema.h:13744
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.
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....
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
void DiagnoseUnknownAttribute(const ParsedAttr &AL)
void PushSatisfactionStackEntry(const NamedDecl *D, const llvm::FoldingSetNodeID &ID)
Definition Sema.h:14942
ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, TypeSourceInfo *TSI)
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)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition Sema.h:15572
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition Sema.h:1151
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
Binary Operators. 'Tok' is the token for the operator.
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
Definition Sema.cpp:2988
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)
void ProcessPragmaExport(DeclaratorDecl *newDecl)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void emitDeferredDiags()
Definition Sema.cpp:2101
void setFunctionHasMustTail()
Definition Sema.cpp:2623
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 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)
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition Sema.h:8455
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange, SourceRange FixItRange, const sema::Capture &From)
Diagnose if an explicit lambda capture is unused.
void CheckCompleteVariableDeclaration(VarDecl *VD)
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
QualType CheckTemplateIdType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, Scope *Scope, bool ForNestedNameSpecifier)
void PopSatisfactionStackEntry()
Definition Sema.h:14948
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
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)
void setFunctionHasBranchProtectedScope()
Definition Sema.cpp:2613
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition Sema.h:15661
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
bool isConstantEvaluatedContext() const
Definition Sema.h:2639
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition Sema.h:6603
QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions, IdentifierInfo *Id, bool DirectInit, Expr *&Init)
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output, SourceLocation Loc={}, const DeclarationName &Entity={})
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
Definition SemaDecl.cpp:641
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.
bool SubstDefaultArgument(SourceLocation Loc, ParmVarDecl *Param, const MultiLevelTemplateArgumentList &TemplateArgs, bool ForCallExpr=false)
Substitute the given template arguments into the default argument.
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
bool BuiltinElementwiseTernaryMath(CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr=EltwiseBuiltinArgTyRestriction::FloatTy)
void ActOnStartOfTranslationUnit()
This is called before the very first declaration in the translation unit is parsed.
Definition Sema.cpp:1200
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.
friend class Parser
Definition Sema.h:1587
ExprResult ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, SourceRange Range)
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
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.
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
std::pair< StringRef, QualType > CapturedParamNameType
Definition Sema.h:11328
void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
void ApplyNullability(Decl *D, NullabilityKind Nullability)
Apply the 'Nullability:' annotation to the specified declaration.
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
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:276
ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
Definition Sema.h:1584
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *TSI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
ASTConsumer & Consumer
Definition Sema.h:1309
bool handlerCanCatch(QualType HandlerType, QualType ExceptionType)
RequiresExprBodyDecl * ActOnStartRequiresExpr(SourceLocation RequiresKWLoc, ArrayRef< ParmVarDecl * > LocalParameters, Scope *BodyScope)
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false, bool FirstArgumentIsBase=false)
Add all of the function declarations in the given function set to the overload candidate set.
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand)
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
Definition Sema.h:4698
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
PragmaAlignPackDiagnoseKind
Definition Sema.h:2220
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:7052
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition SemaExpr.cpp:125
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition Sema.h:1346
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg, bool PartialOrdering, bool *StrictPackMatch)
Check a template argument against its corresponding template template parameter.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
Definition Sema.cpp:1851
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition Sema.h:14103
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
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...
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:9974
@ PrivateFragmentImportFinished
after 'module :private;' but a non-import decl has already been seen.
Definition Sema.h:9981
@ ImportFinished
after any non-import decl.
Definition Sema.h:9978
@ PrivateFragmentImportAllowed
after 'module :private;' but before any non-import decl.
Definition Sema.h:9979
@ FirstDecl
Parsing the first decl in a TU.
Definition Sema.h:9975
@ GlobalFragment
after 'module;' but before 'module X;'
Definition Sema.h:9976
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
Definition Sema.h:9983
@ ImportAllowed
after 'module X;' but before any non-import decl.
Definition Sema.h:9977
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters are used in a given expression.
static QualType getPrintable(QualType T)
Definition Sema.h:15190
bool checkInstantiatedThreadSafetyAttrs(const Decl *D, const Attr *A)
Recheck instantiated thread-safety attributes that could not be validated on the dependent pattern de...
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks, bool IgnoreArch=false)
Create a CUDALaunchBoundsAttr attribute.
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition Sema.cpp:110
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition Sema.h:1269
void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc)
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, const ParsedAttributesView &Attr)
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
void AddNonMemberOperatorCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
Add all of the non-member operator function declarations in the given function set to the overload ca...
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X, Expr *Y, Expr *Z)
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition Sema.h:6786
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
Definition Sema.h:6808
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
Definition Sema.h:6798
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
Definition Sema.h:6813
@ DiscardedStatement
The current expression occurs within a discarded statement.
Definition Sema.h:6803
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6823
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6792
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6818
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
Definition Sema.h:6833
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
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...
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
Definition Sema.h:13728
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition Sema.h:4860
@ AP_InferredFromAnyAppleOS
The availability attribute was inferred from an 'anyAppleOS' availability attribute.
Definition Sema.h:4874
@ AP_PragmaClangAttribute
The availability attribute was applied using 'pragma clang attribute'.
Definition Sema.h:4866
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition Sema.h:4870
@ AP_PragmaClangAttribute_InferredFromAnyAppleOS
The availability attribute was inferred from an 'anyAppleOS' availability attribute that was applied ...
Definition Sema.h:4879
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition Sema.h:4863
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Parse a __builtin_astype expression.
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
ExprResult BuildOperatorCoawaitLookupExpr(Scope *S, SourceLocation Loc)
std::pair< SourceLocation, bool > DeleteExprLoc
Definition Sema.h:988
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.
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
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 {'.
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....
bool inParameterMappingSubstitution() const
Definition Sema.h:14065
SemaPPC & PPC()
Definition Sema.h:1538
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
Definition Sema.cpp:2471
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
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:420
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition Sema.h:4943
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
void actOnDelayedExceptionSpecification(Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member or friend function (or function template).
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Definition Sema.h:1267
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)
void DiagnoseUnterminatedPragmaAttribute()
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
bool SatisfactionStackContains(const NamedDecl *D, const llvm::FoldingSetNodeID &ID) const
Definition Sema.h:14950
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
UnsignedOrNone getFullyPackExpandedSize(TemplateArgument Arg)
Given a template argument that contains an unexpanded parameter pack, but which has already been subs...
ASTContext::CXXRecordDeclRelocationInfo CheckCXX2CRelocatable(const clang::CXXRecordDecl *D)
LateTemplateParserCB * LateTemplateParser
Definition Sema.h:1351
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)
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.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC pragma optimize in scope, consider changing t...
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Delete-expressions to be analyzed at the end of translation unit.
Definition Sema.h:8466
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition Sema.h:3622
static bool getFormatStringInfo(const Decl *Function, unsigned FormatIdx, unsigned FirstArg, FormatStringInfo *FSI)
Given a function and its FormatAttr or FormatMatchesAttr info, attempts to populate the FormatStringI...
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition Sema.h:10129
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
QualType getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType, CallingConv CC)
Get the return type to use for a lambda's conversion function(s) to function pointer type,...
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
Definition Sema.h:8253
SemaSystemZ & SystemZ()
Definition Sema.h:1568
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition Sema.cpp:124
bool isRedefinitionAllowedFor(const NamedDecl *D, bool &Visible)
Definition Sema.h:15651
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:3010
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8403
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
void warnOnCTypeHiddenInCPlusPlus(const NamedDecl *D)
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
MemberPointerConversionResult
Definition Sema.h:10325
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
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:9960
bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, unsigned ArgNum, unsigned ArgBits)
BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of TheCall is a constant expression re...
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AvailabilityMergeKind::Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
Definition SemaStmt.cpp:648
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true, bool *Unreachable=nullptr)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition Sema.h:1311
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs, bool SetWrittenArgs)
Get the specialization of the given variable template corresponding to the specified argument list,...
TemplateNameIsRequiredTag
Definition Sema.h:11491
@ TemplateNameIsRequired
Definition Sema.h:11491
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
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.
ExprResult UsualUnaryFPConversions(Expr *E)
UsualUnaryFPConversions - Promotes floating-point types according to the current language semantics.
Definition SemaExpr.cpp:788
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.
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, CXXScopeSpec &SS, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration.
TypeSourceInfo * SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, StringRef SlotLabel, Expr *Alignment)
ActOnPragmaPack - Called on well formed #pragma pack(...).
Definition SemaAttr.cpp:481
static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD)
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:6596
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.
DiagnosticsEngine & Diags
Definition Sema.h:1310
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
void DiagnoseUnterminatedPragmaAlignPack()
Definition SemaAttr.cpp:632
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition Sema.h:7873
OpenCLOptions & getOpenCLOptions()
Definition Sema.h:933
FPOptions CurFPFeatures
Definition Sema.h:1304
void ActOnStartSEHFinallyBlock()
TypeAwareAllocationMode ShouldUseTypeAwareOperatorNewOrDelete() const
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
static bool CanBeGetReturnObject(const FunctionDecl *FD)
NamespaceDecl * getStdNamespace() const
void SetLateTemplateParser(LateTemplateParserCB *LTP, void *P)
Definition Sema.h:1354
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition Sema.h:6587
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
bool IsAtLeastAsConstrained(const NamedDecl *D1, MutableArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, MutableArrayRef< AssociatedConstraint > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
void addLifetimeBoundToImplicitThis(CXXMethodDecl *MD)
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)
void LoadExternalExtnameUndeclaredIdentifiers()
Load pragma redefine_extname'd undeclared identifiers from the external source.
Definition Sema.cpp:1097
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Definition SemaExpr.cpp:520
PragmaStack< StringLiteral * > DataSegStack
Definition Sema.h:2067
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types?
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
Attr * CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
Definition Sema.cpp:3049
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc, bool IsExplicit)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
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:11674
@ TPC_TemplateTemplateParameterPack
Definition Sema.h:11684
@ TPC_FriendFunctionTemplate
Definition Sema.h:11682
@ TPC_ClassTemplateMember
Definition Sema.h:11680
@ TPC_FunctionTemplate
Definition Sema.h:11679
@ TPC_FriendClassTemplate
Definition Sema.h:11681
@ TPC_FriendFunctionTemplateDefinition
Definition Sema.h:11683
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
void ActOnAbortSEHFinallyBlock()
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,...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val)
SemaAVR & AVR()
Definition Sema.h:1458
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
friend class InitializationSequence
Definition Sema.h:1588
bool GloballyUniqueObjectMightBeAccidentallyDuplicated(const VarDecl *Dcl)
Certain globally-unique variables might be accidentally duplicated if built into multiple shared libr...
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition,...
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition Sema.h:2146
bool isMainFileLoc(SourceLocation Loc) const
Determines whether the given source location is in the main file and we're in a context where we shou...
Definition Sema.cpp:964
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)
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
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.
void PopDeclContext()
ExprResult VerifyIntegerConstantExpression(Expr *E, AllowFoldKind CanFold=AllowFoldKind::No)
Definition Sema.h:7832
void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init)
CXXDeductionGuideDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param, SourceLocation Location)
Get a template argument mapping the given template parameter to itself, e.g.
bool CheckIfFunctionSpecializationIsImmediate(FunctionDecl *FD, SourceLocation Loc)
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc)
Complete a lambda-expression having processed and attached the lambda body.
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
void ActOnDeferStmtError(Scope *CurScope)
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
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:6619
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition Sema.h:13700
void PrintStats() const
Print out statistics about the semantic analysis.
Definition Sema.cpp:676
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
static unsigned getPrintable(unsigned I)
Definition Sema.h:15181
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...
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,...
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition Sema.h:1830
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.
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)
llvm::BumpPtrAllocator BumpAlloc
Definition Sema.h:1253
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
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...
SourceRange getRangeForNextToken(SourceLocation Loc, bool IncludeMacros, bool IncludeComments, std::optional< tok::TokenKind > ExpectedToken=std::nullopt)
Calls Lexer::findNextToken() to find the next token, and if the locations of both ends of the token c...
Definition Sema.cpp:89
MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
BuildForRangeKind
Definition Sema.h:11151
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition Sema.h:11159
@ BFRK_Build
Initial building of a for-range statement.
Definition Sema.h:11153
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition Sema.h:11156
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
SemaNVPTX & NVPTX()
Definition Sema.h:1513
void checkIncorrectVTablePointerAuthenticationAttribute(CXXRecordDecl &RD)
Check that VTable Pointer authentication is only being set on the first first instantiation of the vt...
StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl, Stmt *HandlerBlock)
ActOnCXXCatchBlock - Takes an exception declaration and a handler block and creates a proper catch ha...
void ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation, PragmaMsStackAction Action, bool Value)
ActOnPragmaMSStrictGuardStackCheck - Called on well formed #pragma strict_gs_check.
Definition SemaAttr.cpp:917
void ActOnUninitializedDecl(Decl *dcl)
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
void ApplyAPINotesType(Decl *D, StringRef TypeString)
Apply the 'Type:' annotation to the specified declaration.
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation, FunctionDecl *Decl, ArrayRef< TemplateArgument > TemplateArgs, ConstraintSatisfaction &Satisfaction)
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc)
void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction, const Expr *ThisArg, ArrayRef< const Expr * > Args)
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:563
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
PragmaSectionKind
Definition Sema.h:2087
@ PSK_ConstSeg
Definition Sema.h:2090
@ PSK_DataSeg
Definition Sema.h:2088
@ PSK_CodeSeg
Definition Sema.h:2091
@ PSK_BSSSeg
Definition Sema.h:2089
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)
TypeResult ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword, SourceLocation ElaboratedKeywordLoc, 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 runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
Definition Sema.cpp:631
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
bool CheckSpanLikeType(const AttributeCommonInfo &CI, const QualType &Ty)
Check that the type is a plain record with one field being a pointer type and the other field being a...
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition SemaCast.cpp:338
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...
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:6363
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...
bool BuiltinConstantArgPower2(CallExpr *TheCall, unsigned ArgNum)
BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a constant expression representing ...
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,...
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
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)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void ActOnCXXForRangeDecl(Decl *D)
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
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:3596
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition Sema.cpp:2219
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
UnsignedOrNone GetDecompositionElementCount(QualType DecompType, SourceLocation Loc)
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, bool IsMemberSpecialization, SkipBodyInfo *SkipBody=nullptr)
PragmaClangSection PragmaClangBSSSection
Definition Sema.h:1843
Decl * ActOnDeclarator(Scope *S, Declarator &D)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition Sema.h:1365
QualType CheckMatrixLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel)
AbstractDiagSelID
Definition Sema.h:6309
@ AbstractSynthesizedIvarType
Definition Sema.h:6316
@ AbstractVariableType
Definition Sema.h:6313
@ AbstractReturnType
Definition Sema.h:6311
@ AbstractNone
Definition Sema.h:6310
@ AbstractFieldType
Definition Sema.h:6314
@ AbstractArrayType
Definition Sema.h:6317
@ AbstractParamType
Definition Sema.h:6312
@ AbstractIvarType
Definition Sema.h:6315
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition SemaStmt.cpp:950
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 CheckVarOrConceptTemplateTemplateId(const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, TemplateTemplateParmDecl *Template, SourceLocation TemplateLoc, const TemplateArgumentListInfo *TemplateArgs)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
ExprResult SubstCXXIdExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
Substitute an expression as if it is a address-of-operand, which makes it act like a CXXIdExpression ...
bool IsFunctionConversion(QualType FromType, QualType ToType) const
Determine whether the conversion from FromType to ToType is a valid conversion of ExtInfo/ExtProtoInf...
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
void CheckAlignasUnderalignment(Decl *D)
SemaSPIRV & SPIRV()
Definition Sema.h:1553
ParsedType getConstructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext)
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old)
A wrapper function for checking the semantic restrictions of a redeclaration within a module.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition Sema.h:8452
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.
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(const NamedDecl *D1, ArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, ArrayRef< AssociatedConstraint > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
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.
void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI)
Note that we have finished the explicit captures for the given lambda.
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, const DefaultArguments &DefaultArgs, bool PartialTemplateArgs, CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
void ActOnPragmaFPContract(SourceLocation Loc, LangOptions::FPModeKind FPC)
ActOnPragmaFPContract - Called on well formed #pragma {STDC,OPENCL} FP_CONTRACT and #pragma clang fp ...
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.
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc)
Called on well formed #pragma clang optimize.
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.
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...
QualType PreferredConditionType(ConditionKind K) const
Definition Sema.h:8061
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.
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
Definition Sema.h:9469
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition Sema.h:9473
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition Sema.h:9479
@ LOLR_Error
The lookup resulted in an error.
Definition Sema.h:9471
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition Sema.h:9476
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition Sema.h:9487
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition Sema.h:9483
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition Sema.cpp:2643
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition Sema.h:7030
SemaLoongArch & LoongArch()
Definition Sema.h:1493
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
CheckConstexprKind
Definition Sema.h:6498
@ CheckValid
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
Definition Sema.h:6503
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
Definition Sema.h:6500
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:14099
void CheckVariableDeclarationType(VarDecl *NewVD)
sema::CompoundScopeInfo & getCurCompoundScope() const
Definition SemaStmt.cpp:432
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:3002
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1300
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
bool DiagnoseInvalidExplicitObjectParameterInLambda(CXXMethodDecl *Method, SourceLocation CallLoc)
Returns true if the explicit object parameter was invalid.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
Definition Sema.cpp:714
bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E)
CheckCXXThrowOperand - Validate the operand of a throw.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
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.
bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New)
void checkEnumArithmeticConversions(Expr *LHS, Expr *RHS, SourceLocation Loc, ArithConvKind ACK)
Check that the usual arithmetic conversions can be performed on this pair of expressions that might b...
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)
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:3573
void ActOnFinishOfCompoundStmt()
Definition SemaStmt.cpp:428
concepts::Requirement * ActOnNestedRequirement(Expr *Constraint)
void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB)
Cause the built diagnostic to be emitted on the DiagosticsEngine.
Definition Sema.cpp:1750
QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType, bool AdjustExceptionSpec=false)
Adjust the type ArgFunctionType to match the calling convention, noreturn, and optionally the excepti...
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
void AddSectionMSAllocText(FunctionDecl *FD)
Only called on function definitions; if there is a #pragma alloc_text that decides which code section...
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15497
void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
UnsignedOrNone getNumArgumentsInExpansionFromUnexpanded(llvm::ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs)
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...
static ConditionResult ConditionError()
Definition Sema.h:7910
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
void NoteTemplateParameterLocation(const NamedDecl &Decl)
SemaWasm & Wasm()
Definition Sema.h:1573
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Format, int FormatIdx, int FirstArg)
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:3519
bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo, bool EnteringContext)
IsInvalidUnlessNestedName - This method is used for error recovery purposes to determine whether the ...
llvm::DenseSet< QualType > InstantiatedNonDependentTypes
Non-dependent types used in templates that have already been instantiated by some template instantiat...
Definition Sema.h:13696
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
LifetimeCaptureByAttr * ParseLifetimeCaptureByAttr(const ParsedAttr &AL, StringRef ParamName)
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.
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 ...
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
SemaPseudoObject & PseudoObject()
Definition Sema.h:1543
LabelDecl * LookupExistingLabel(IdentifierInfo *II, SourceLocation IdentLoc)
Perform a name lookup for a label with the specified name; this does not create a new label if the lo...
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition Sema.cpp:2604
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition SemaStmt.cpp:588
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition Sema.h:11456
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...
FullExprArg MakeFullExpr(Expr *Arg)
Definition Sema.h:7866
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:732
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...
void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD, SourceLocation NameLoc)
Returns the TypeDeclType for the given type declaration, as ASTContext::getTypeDeclType would,...
Definition SemaDecl.cpp:149
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
FunctionTemplateDecl * getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1, QualType RawObj1Ty={}, QualType RawObj2Ty={}, bool Reversed=false, bool PartialOverloading=false)
Returns the more specialized function template according to the rules of function template partial or...
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
Definition Sema.h:8411
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition Sema.h:1299
static int getPrintable(int I)
Definition Sema.h:15180
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply.
void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags, StringLiteral *SegmentName)
Called on well formed #pragma section().
Definition SemaAttr.cpp:928
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
Definition Sema.h:9739
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition Sema.h:12992
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:568
ExprResult ActOnCXXThis(SourceLocation Loc)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
Definition Sema.h:3870
bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, QualType SrcTy)
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)
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:15185
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
void warnOnReservedIdentifier(const NamedDecl *D)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition SemaStmt.cpp:532
TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, UnsignedOrNone &NumExpansions) const
Returns the pattern of the pack expansion for a template argument.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
bool isCheckingDefaultArgumentOrInitializer() const
Definition Sema.h:8279
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
SFINAETrap * CurrentSFINAEContext
Definition Sema.h:13711
SemaARM & ARM()
Definition Sema.h:1453
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.
llvm::DenseSet< InstantiatingSpecializationsKey > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition Sema.h:13692
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
Definition SemaAttr.cpp:365
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
static const char * getPrintable(const char *S)
Definition Sema.h:15183
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto)
CheckFunctionCall - Check a direct function call for various correctness and safety properties not st...
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO={})
Add overload candidates for overloaded operators that are member functions.
ExprResult ActOnDecltypeExpression(Expr *E)
Process the expression contained within a decltype.
SmallVector< std::pair< Scope *, SourceLocation >, 2 > CurrentDefer
Stack of '_Defer' statements that are currently being parsed, as well as the locations of their '_Def...
Definition Sema.h:11061
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.
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
ASTMutationListener * getASTMutationListener() const
Definition Sema.cpp:657
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
PragmaMsStackAction
Definition Sema.h:1849
@ PSK_Push_Set
Definition Sema.h:1855
@ PSK_Reset
Definition Sema.h:1850
@ PSK_Pop_Set
Definition Sema.h:1856
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
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.
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer * > Initializers={})
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:8748
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)
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
SFINAETrap * getSFINAEContext() const
Returns a pointer to the current SFINAE context, if any.
Definition Sema.h:13785
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,...
void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, const Expr *ThisArg, ArrayRef< const Expr * > Args, bool IsMemberFunction, SourceLocation Loc, SourceRange Range, VariadicCallType CallType)
Handles the checks for format strings, non-POD arguments to vararg functions, NULL arguments passed t...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
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:298
Stmt - This represents one statement.
Definition Stmt.h:86
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:343
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1802
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3739
Exposes information about the current target.
Definition TargetInfo.h:227
A convenient class for passing around template argument information.
A template argument list.
Location wrapper for a TemplateArgument.
Represents a template argument.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
The base class of all kinds of template declarations (e.g., class, function, etc.).
This is a base class for callbacks that will be notified at every template instantiation.
Represents a C++ template name within the type system.
Stores a list of template parameters for a TemplateDecl and its derived classes.
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:4657
The top declaration context.
Definition Decl.h:105
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:227
Represents a declaration of a type.
Definition Decl.h:3535
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:154
A container of type source information.
Definition TypeBase.h:8416
The base class of the type hierarchy.
Definition TypeBase.h:1875
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3689
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3584
Simple class containing the result of Sema::CorrectTypo.
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1035
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3390
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4126
A set of unresolved declarations.
The iterator over UnresolvedSets.
Represents a C++ using-declaration.
Definition DeclCXX.h:3596
Represents C++ using-directive.
Definition DeclCXX.h:3101
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3404
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
Represents a variable declaration or definition.
Definition Decl.h:924
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 TypeBase.h:4237
Represents a C++11 virt-specifier-seq.
Definition DeclSpec.h:2828
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Definition Lookup.h:838
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...
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
Retains information about a block that is currently being parsed.
Definition ScopeInfo.h:794
Retains information about a captured region.
Definition ScopeInfo.h:820
Contains information about the compound statement currently being parsed.
Definition ScopeInfo.h:67
A collection of diagnostics which were delayed.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
Retains information about a function, method, or block that is currently being parsed.
Definition ScopeInfo.h:104
Provides information about an attempted template argument deduction, whose success or failure was des...
#define UINT_MAX
Definition limits.h:64
Definition SPIR.cpp:47
Enums for the diagnostics of target, target_version and target_clones.
Definition Sema.h:854
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
bool operator==(const ValueType &a, const ValueType &b)
void threadSafetyCleanup(BeforeSet *Cache)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition TokenKinds.h:25
The JSON file list parser is used to communicate input to InstallAPI.
PragmaClangSectionAction
Definition Sema.h:476
TypeSpecifierType
Specifies the kind of type.
Definition Specifiers.h:56
ImplicitTypenameContext
Definition DeclSpec.h:1931
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
OverloadKind
Definition Sema.h:823
@ NonFunction
This is not an overload because the lookup results contain a non-function.
Definition Sema.h:834
@ Match
This is not an overload because the signature exactly matches an existing declaration.
Definition Sema.h:830
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition Sema.h:826
bool isa(CodeGen::Address addr)
Definition Address.h:330
OpaquePtr< TemplateName > ParsedTemplateTy
Definition Ownership.h:256
ArrayTypeTrait
Names for the array type traits.
Definition TypeTraits.h:42
@ CPlusPlus
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
Definition Ownership.h:263
VariadicCallType
Definition Sema.h:513
FunctionEffectMode
Used with attributes/effects with a boolean condition, e.g. nonblocking.
Definition Sema.h:459
CUDAFunctionTarget
Definition Cuda.h:63
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...
Definition Template.h:50
AllocationFunctionScope
The scope in which to find allocation functions.
Definition Sema.h:791
@ Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition Sema.h:799
PragmaMSCommentKind
Definition PragmaKinds.h:14
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition Specifiers.h:36
ArrayRef< IdentifierLoc > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
TryCaptureKind
Definition Sema.h:653
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition Specifiers.h:40
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition Sema.h:661
@ BitwiseOp
A bitwise operation.
Definition Sema.h:665
@ Arithmetic
An arithmetic operation.
Definition Sema.h:663
@ Conditional
A conditional (?:) operator.
Definition Sema.h:669
@ CompAssign
A compound assignment expression.
Definition Sema.h:671
@ Comparison
A comparison.
Definition Sema.h:667
NullabilityKind
Describes the nullability of a particular type.
Definition Specifiers.h:349
InClassInitStyle
In-class initialization styles for non-static data members.
Definition Specifiers.h:272
@ Success
Annotation was successful.
Definition Parser.h:65
CXXConstructionKind
Definition ExprCXX.h:1544
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition Specifiers.h:150
PointerAuthDiscArgKind
Definition Sema.h:594
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h:604
@ TemplateTemplateArgument
Definition Sema.h:613
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
Definition Overload.h:84
NonTrivialCUnionContext
Definition Sema.h:532
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition Sema.h:628
@ Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition Sema.h:636
@ OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition Sema.h:642
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition Sema.h:633
@ ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition Sema.h:639
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:238
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:918
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition Specifiers.h:124
@ AS_none
Definition Specifiers.h:128
LazyOffsetPtr< Decl, GlobalDeclID, &ExternalASTSource::GetExternalDecl > LazyDeclPtr
A lazy pointer to a declaration.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
ActionResult< Decl * > DeclResult
Definition Ownership.h:255
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
CapturedRegionKind
The different kinds of captured statement.
StorageClass
Storage classes.
Definition Specifiers.h:249
void inferNoReturnAttr(Sema &S, Decl *D)
Expr * Cond
};
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition Overload.h:929
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
Definition Parser.h:142
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition TypeTraits.h:51
bool isFunctionOrMethodOrBlockForAttrSubject(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
Definition Attr.h:40
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
Definition Overload.h:89
MutableArrayRef< Expr * > MultiExprArg
Definition Ownership.h:259
LambdaCaptureInitKind
Definition DeclSpec.h:2872
@ CopyInit
[a = b], [a = {b}]
Definition DeclSpec.h:2874
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Definition Linkage.h:54
@ AANT_ArgumentIntegerConstant
PragmaOptionsAlignKind
Definition Sema.h:478
@ Result
The result type of a method or function.
Definition TypeBase.h:905
ActionResult< ParsedType > TypeResult
Definition Ownership.h:251
OffsetOfKind
Definition Sema.h:616
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3781
CorrectTypoKind
Definition Sema.h:818
ActionResult< CXXCtorInitializer * > MemInitResult
Definition Ownership.h:253
OptionalUnsigned< unsigned > UnsignedOrNone
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isFunctionOrMethodVariadic(const Decl *D)
Definition Attr.h:112
@ Template
We are parsing a template declaration.
Definition Parser.h:81
ActionResult< CXXBaseSpecifier * > BaseResult
Definition Ownership.h:252
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition Sema.h:689
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition Sema.h:712
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition Sema.h:787
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition Sema.h:704
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition Sema.h:759
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition Sema.h:749
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition Sema.h:776
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition Sema.h:763
@ CompatibleOBTDiscards
CompatibleOBTDiscards - Assignment discards overflow behavior.
Definition Sema.h:783
@ IncompatibleOBTKinds
IncompatibleOBTKinds - Assigning between incompatible OverflowBehaviorType kinds, e....
Definition Sema.h:780
@ CompatibleVoidPtrToNonVoidPtr
CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because a void * can implicitly convert...
Definition Sema.h:696
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition Sema.h:738
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition Sema.h:733
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition Sema.h:772
@ Compatible
Compatible - the types are compatible according to the standard.
Definition Sema.h:691
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition Sema.h:723
@ IncompatiblePointerDiscardsOverflowBehavior
IncompatiblePointerDiscardsOverflowBehavior - The assignment discards overflow behavior annotations b...
Definition Sema.h:743
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition Sema.h:700
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition Sema.h:708
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition Sema.h:755
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition Sema.h:717
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition Sema.h:729
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition Sema.h:767
TagUseKind
Definition Sema.h:451
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
Definition LangOptions.h:38
PragmaClangSectionKind
pragma clang section kind
Definition Sema.h:467
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:5993
TUFragmentKind
Definition Sema.h:487
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...
NameClassificationKind
Describes the result of the name lookup and resolution performed by Sema::ClassifyName().
Definition Sema.h:555
@ FunctionTemplate
The name was classified as a function template name.
Definition Sema.h:587
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:562
@ DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition Sema.h:576
@ UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition Sema.h:589
@ NonType
The name was classified as a specific non-type, non-template declaration.
Definition Sema.h:568
@ Unknown
This name is not a type or template in this context, but might be something else.
Definition Sema.h:558
@ Error
Classification failed; an error has been produced.
Definition Sema.h:560
@ Type
The name was classified as a type.
Definition Sema.h:564
@ TypeTemplate
The name was classified as a template whose specializations are types.
Definition Sema.h:583
@ Concept
The name was classified as a concept name.
Definition Sema.h:591
@ OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition Sema.h:581
@ UndeclaredNonType
The name was classified as an ADL-only function name.
Definition Sema.h:572
@ VarTemplate
The name was classified as a variable template name.
Definition Sema.h:585
LangAS
Defines the address space values used by the address space qualifier of QualType.
FormatStringType
Definition Sema.h:499
CastKind
CastKind - The kind of operation required for a conversion.
AllowFoldKind
Definition Sema.h:655
TranslationUnitKind
Describes the kind of translation unit being processed.
@ TU_Complete
The translation unit is a complete translation unit.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
Definition Ownership.h:261
VarArgKind
Definition Sema.h:676
PragmaMSStructKind
Definition PragmaKinds.h:23
AssignmentAction
Definition Sema.h:216
@ Deduced
The normal deduced case.
Definition TypeBase.h:1814
CXXSpecialMemberKind
Kinds of C++ special members.
Definition Sema.h:427
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
@ TNK_Var_template
The name refers to a variable template whose specialization produces a variable.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
@ TNK_Function_template
The name refers to a function template or a set of overloaded functions that includes at least one fu...
@ TNK_Concept_template
The name refers to a concept.
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
BuiltinCountedByRefKind
Definition Sema.h:521
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
bool hasImplicitObjectParameter(const Decl *D)
Definition Attr.h:126
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:133
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:136
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition ASTContext.h:153
TypeAwareAllocationMode
Definition ExprCXX.h:2255
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition Sema.h:803
@ Exists
The symbol exists.
Definition Sema.h:805
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:808
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition Specifiers.h:413
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
Definition Attr.h:55
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
Definition Attr.h:64
TPOC
The context in which partial ordering of function templates occurs.
Definition Template.h:304
TrivialABIHandling
Definition Sema.h:645
@ ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition Sema.h:650
@ IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition Sema.h:647
TemplateDeductionResult
Describes the result of template argument deduction.
Definition Sema.h:369
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
Definition Sema.h:419
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
Definition Sema.h:414
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
Definition Sema.h:417
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
Definition Sema.h:390
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
Definition Sema.h:376
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
Definition Sema.h:412
@ CUDATargetMismatch
CUDA Target attributes do not match.
Definition Sema.h:421
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
Definition Sema.h:409
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
Definition Sema.h:379
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
Definition Sema.h:393
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
Definition Sema.h:382
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Definition Sema.h:396
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
Definition Sema.h:385
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
Definition Sema.h:406
@ AlreadyDiagnosed
Some error which was already diagnosed.
Definition Sema.h:423
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
Definition Sema.h:400
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
Definition Sema.h:403
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition Specifiers.h:189
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:279
U cast(CodeGen::Address addr)
Definition Address.h:327
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
Definition DeclSpec.h:1252
@ None
The alignment was not explicit in code.
Definition ASTContext.h:182
CCEKind
Contexts in which a converted constant expression is required.
Definition Sema.h:838
@ CaseValue
Expression in a case label.
Definition Sema.h:839
@ StaticAssertMessageData
Call to data() in a static assert message.
Definition Sema.h:849
@ Enumerator
Enumerator value with fixed underlying type.
Definition Sema.h:840
@ StaticAssertMessageSize
Call to size() in a static assert message.
Definition Sema.h:847
@ Noexcept
Condition in a noexcept(bool) specifier.
Definition Sema.h:846
@ ArrayBound
Array bound in array declarator or new-expression.
Definition Sema.h:844
@ TempArgStrict
As above, but applies strict template checking rules.
Definition Sema.h:842
@ ExplicitBool
Condition in an explicit(bool) specifier.
Definition Sema.h:845
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:5007
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5968
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5979
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5982
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5986
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
TypeTrait
Names for traits that operate specifically on types.
Definition TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h:2249
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition Expr.h:1992
CheckedConversionKind
The kind of conversion being performed.
Definition Sema.h:438
@ Implicit
An implicit conversion.
Definition Sema.h:440
@ CStyleCast
A C-style cast.
Definition Sema.h:442
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
Definition Sema.h:448
@ OtherCast
A cast other than a C-style cast.
Definition Sema.h:446
@ FunctionalCast
A functional-style cast.
Definition Sema.h:444
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition Specifiers.h:174
unsigned int uint32_t
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
int const char * function
Definition c++config.h:31
#define false
Definition stdbool.h:26
#define true
Definition stdbool.h:25
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:91
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A structure used to record information about a failed template argument deduction,...
Describes whether we've seen any nullability information for the given file.
Definition Sema.h:242
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition Sema.h:249
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition Sema.h:245
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition Sema.h:255
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition Sema.h:252
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h:5106
Holds information about the various types of exception specification.
Definition TypeBase.h:5426
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5428
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5431
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5434
Extra information about a function prototype.
Definition TypeBase.h:5454
Represents a complete lambda introducer.
Definition DeclSpec.h:2880
Contains a late templated function.
Definition Sema.h:15823
FPOptions FPO
Floating-point options in the point of definition.
Definition Sema.h:15828
Decl * D
The template function declaration to be late parsed.
Definition Sema.h:15826
A normalized constraint, as defined in C++ [temp.constr.normal], is either an atomic constraint,...
Definition SemaConcept.h:36
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Definition Overload.h:933
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation CurrentPragmaLocation
Definition Sema.h:2062
bool SuppressUserConversions
Do not consider any user-defined conversions when constructing the initializing sequence.
Definition Sema.h:10612
bool OnlyInitializeNonUserDefinedConversions
Before constructing the initializing sequence, we check whether the parameter type and argument type ...
Definition Sema.h:10619
CheckNonDependentConversionsFlag(bool SuppressUserConversions, bool OnlyInitializeNonUserDefinedConversions)
Definition Sema.h:10621
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
Definition Sema.h:12100
bool MatchingTTP
If true, assume these template arguments are the injected template arguments for a template template ...
Definition Sema.h:12096
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &)=delete
CheckTemplateArgumentInfo(bool PartialOrdering=false, bool MatchingTTP=false)
Definition Sema.h:12077
bool PartialOrdering
The check is being performed in the context of partial ordering.
Definition Sema.h:12089
SmallVector< TemplateArgument, 4 > SugaredConverted
The checked, converted argument will be added to the end of these vectors.
Definition Sema.h:12086
SmallVector< TemplateArgument, 4 > CanonicalConverted
Definition Sema.h:12086
CheckTemplateArgumentInfo & operator=(const CheckTemplateArgumentInfo &)=delete
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition Sema.h:13200
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition Sema.h:13368
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool InParameterMappingSubstitution
Whether we're substituting into the parameter mapping of a constraint.
Definition Sema.h:13325
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition Sema.h:13341
ArrayRef< TemplateArgument > template_arguments() const
Definition Sema.h:13360
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition Sema.h:13336
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition Sema.h:13328
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition Sema.h:13354
bool InConstraintSubstitution
Whether we're substituting into constraints.
Definition Sema.h:13322
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition Sema.h:13344
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition Sema.h:13351
SynthesisKind
The kind of template instantiation we are performing.
Definition Sema.h:13202
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition Sema.h:13291
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition Sema.h:13212
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition Sema.h:13221
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition Sema.h:13240
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition Sema.h:13288
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition Sema.h:13248
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition Sema.h:13255
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition Sema.h:13295
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition Sema.h:13266
@ Memoization
Added for Template instantiation observation.
Definition Sema.h:13301
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13231
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition Sema.h:13307
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition Sema.h:13304
@ PartialOrderingTTP
We are performing partial ordering for template template parameters.
Definition Sema.h:13310
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition Sema.h:13228
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition Sema.h:13236
@ SYCLKernelLaunchOverloadResolution
We are performing overload resolution for a call to a function template or variable template named 's...
Definition Sema.h:13318
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition Sema.h:13244
@ TemplateInstantiation
We are instantiating a template declaration.
Definition Sema.h:13205
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition Sema.h:13258
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition Sema.h:13262
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition Sema.h:13217
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition Sema.h:13285
@ SYCLKernelLaunchLookup
We are performing name lookup for a function template or variable template named 'sycl_kernel_launch'...
Definition Sema.h:13314
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition Sema.h:13251
Decl * Entity
The entity that is being synthesized.
Definition Sema.h:13331
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition Sema.h:13357
bool isInstantiationRecord() const
Determines whether this template is an actual instantiation that should be counted toward the maximum...
ConstraintEvalRAII & operator=(const ConstraintEvalRAII &)=delete
ConstraintEvalRAII(const ConstraintEvalRAII &)=delete
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition Sema.h:6947
Data structure used to record current or nested expression evaluation contexts.
Definition Sema.h:6848
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:6881
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition Sema.h:6883
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition Sema.h:6934
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition Sema.h:6868
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:6877
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition Sema.h:6888
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:6896
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition Sema.h:6892
bool IsCaseExpr
Whether evaluating an expression for a switch case label.
Definition Sema.h:6937
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition Sema.h:6902
enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition Sema.h:6863
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition Sema.h:6910
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition Sema.h:6940
SmallVector< MisalignedMember, 4 > MisalignedMembers
Small set of gathered accesses to potentially misaligned members due to the packed attribute.
Definition Sema.h:6906
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition Sema.h:6853
VarDecl * DeclForInitializer
Declaration for initializer if one is currently being parsed.
Definition Sema.h:6873
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition Sema.h:6957
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition Sema.h:6959
ExpressionEvaluationContext Context
The expression evaluation context.
Definition Sema.h:6850
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition Sema.h:6857
FormatArgumentPassingKind ArgPassingKind
Definition Sema.h:2659
FunctionEffectDiffVector(const FunctionEffectsRef &Old, const FunctionEffectsRef &New)
Caller should short-circuit by checking for equality first.
std::optional< FunctionEffectWithCondition > Old
Definition Sema.h:15730
bool shouldDiagnoseConversion(QualType SrcType, const FunctionEffectsRef &SrcFX, QualType DstType, const FunctionEffectsRef &DstFX) const
Return true if adding or removing the effect as part of a type conversion should generate a diagnosti...
bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction, const FunctionEffectsRef &OldFX, const FunctionDecl &NewFunction, const FunctionEffectsRef &NewFX) const
Return true if adding or removing the effect in a redeclaration should generate a diagnostic.
StringRef effectName() const
Definition Sema.h:15734
OverrideResult shouldDiagnoseMethodOverride(const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX, const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const
Return true if adding or removing the effect in a C++ virtual method override should generate a diagn...
OverrideResult
Describes the result of effects differing between a base class's virtual method and an overriding met...
Definition Sema.h:15742
std::optional< FunctionEffectWithCondition > New
Definition Sema.h:15732
FunctionEffect::Kind EffectKind
Definition Sema.h:15727
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition Sema.h:13538
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Decl *Entity, SourceRange InstantiationRange=SourceRange())
Note that we are instantiating a class template, function template, variable template,...
void Clear()
Note that we have finished instantiating this template.
LocalInstantiationScope * Scope
Definition Sema.h:14237
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition Sema.h:14240
bool isMoveEligible() const
Definition Sema.h:11219
bool isCopyElidable() const
Definition Sema.h:11220
const VarDecl * Candidate
Definition Sema.h:11214
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition Sema.h:3332
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition Sema.h:3341
SourceLocation IdentifierLoc
The location of the identifier.
Definition Sema.h:3335
SourceLocation CCLoc
The location of the '::'.
Definition Sema.h:3338
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition Sema.h:3329
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition Sema.h:3347
SourceLocation LocStart
Definition Sema.h:7644
IdentifierInfo * IdentInfo
Definition Sema.h:7647
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition Sema.h:12724
Information from a C++ pragma export, for a symbol that we haven't seen the declaration for yet.
Definition Sema.h:2353
This an attribute introduced by #pragma clang attribute.
Definition Sema.h:2121
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition Sema.h:2124
A push'd group of PragmaAttributeEntries.
Definition Sema.h:2129
SourceLocation Loc
The location of the push attribute.
Definition Sema.h:2131
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition Sema.h:2134
const IdentifierInfo * Namespace
The namespace of this push group.
Definition Sema.h:2133
SourceLocation PragmaLocation
Definition Sema.h:1840
PragmaMsStackAction Action
Definition Sema.h:1860
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition Sema.h:1973
llvm::StringRef StackSlotLabel
Definition Sema.h:1969
SourceLocation PragmaLocation
Definition Sema.h:1971
SourceLocation PragmaPushLocation
Definition Sema.h:1972
ValueType CurrentValue
Definition Sema.h:2043
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition Sema.h:2029
bool hasValue() const
Definition Sema.h:2039
SmallVector< Slot, 2 > Stack
Definition Sema.h:2041
ValueType DefaultValue
Definition Sema.h:2042
SourceLocation CurrentPragmaLocation
Definition Sema.h:2044
PragmaStack(const ValueType &Default)
Definition Sema.h:2036
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition Sema.h:1980
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition Sema.h:5158
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition Sema.h:5152
RecursiveInstGuard(Sema &S, Decl *D, Kind Kind)
Definition Sema.h:13172
RecursiveInstGuard(const RecursiveInstGuard &)=delete
RecursiveInstGuard & operator=(const RecursiveInstGuard &)=delete
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition Sema.h:10509
SFINAEContextBase & operator=(const SFINAEContextBase &)=delete
SFINAEContextBase(Sema &S, SFINAETrap *Cur)
Definition Sema.h:12532
SFINAEContextBase(const SFINAEContextBase &)=delete
Abstract class used to diagnose incomplete types.
Definition Sema.h:8344
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition Sema.h:2701
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition Sema.h:2710
bool CheckSameAsPrevious
Definition Sema.h:355
NamedDecl * Previous
Definition Sema.h:356
SkipBodyInfo()=default
NamedDecl * New
Definition Sema.h:357
Information about a template-id annotation token.