clang 22.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"
39#include "clang/Basic/Cuda.h"
43#include "clang/Basic/LLVM.h"
44#include "clang/Basic/Lambda.h"
46#include "clang/Basic/Module.h"
58#include "clang/Sema/Attr.h"
60#include "clang/Sema/DeclSpec.h"
66#include "clang/Sema/Scope.h"
67#include "clang/Sema/SemaBase.h"
71#include "clang/Sema/Weak.h"
72#include "llvm/ADT/APInt.h"
73#include "llvm/ADT/ArrayRef.h"
74#include "llvm/ADT/BitmaskEnum.h"
75#include "llvm/ADT/DenseMap.h"
76#include "llvm/ADT/DenseSet.h"
77#include "llvm/ADT/FloatingPointMode.h"
78#include "llvm/ADT/FoldingSet.h"
79#include "llvm/ADT/MapVector.h"
80#include "llvm/ADT/PointerIntPair.h"
81#include "llvm/ADT/PointerUnion.h"
82#include "llvm/ADT/STLExtras.h"
83#include "llvm/ADT/STLForwardCompat.h"
84#include "llvm/ADT/STLFunctionalExtras.h"
85#include "llvm/ADT/SetVector.h"
86#include "llvm/ADT/SmallBitVector.h"
87#include "llvm/ADT/SmallPtrSet.h"
88#include "llvm/ADT/SmallSet.h"
89#include "llvm/ADT/SmallVector.h"
90#include "llvm/ADT/StringExtras.h"
91#include "llvm/ADT/StringMap.h"
92#include "llvm/ADT/TinyPtrVector.h"
93#include "llvm/Support/Allocator.h"
94#include "llvm/Support/Compiler.h"
95#include "llvm/Support/Error.h"
96#include "llvm/Support/ErrorHandling.h"
97#include <cassert>
98#include <climits>
99#include <cstddef>
100#include <cstdint>
101#include <deque>
102#include <functional>
103#include <iterator>
104#include <memory>
105#include <optional>
106#include <string>
107#include <tuple>
108#include <type_traits>
109#include <utility>
110#include <vector>
111
112namespace llvm {
113struct InlineAsmIdentifierInfo;
114} // namespace llvm
115
116namespace clang {
117class ADLResult;
118class APValue;
120class ASTConsumer;
121class ASTContext;
122class ASTDeclReader;
124class ASTReader;
125class ASTWriter;
126class CXXBasePath;
127class CXXBasePaths;
130enum class ComparisonCategoryType : unsigned char;
132class DarwinSDKInfo;
133class DeclGroupRef;
137class Designation;
138class IdentifierInfo;
144enum class LangAS : unsigned int;
146class LookupResult;
149class ModuleLoader;
153class ObjCMethodDecl;
154struct OverloadCandidate;
155enum class OverloadCandidateParamOrder : char;
156enum OverloadCandidateRewriteKind : unsigned;
158class Preprocessor;
159class SemaAMDGPU;
160class SemaARM;
161class SemaAVR;
162class SemaBPF;
164class SemaCUDA;
165class SemaDirectX;
166class SemaHLSL;
167class SemaHexagon;
168class SemaLoongArch;
169class SemaM68k;
170class SemaMIPS;
171class SemaMSP430;
172class SemaNVPTX;
173class SemaObjC;
174class SemaOpenACC;
175class SemaOpenCL;
176class SemaOpenMP;
177class SemaPPC;
178class SemaPseudoObject;
179class SemaRISCV;
180class SemaSPIRV;
181class SemaSYCL;
182class SemaSwift;
183class SemaSystemZ;
184class SemaWasm;
185class SemaX86;
187class TemplateArgument;
192class Token;
193class TypeConstraint;
198
199namespace sema {
200class BlockScopeInfo;
201class Capture;
208class LambdaScopeInfo;
209class SemaPPCallbacks;
211} // namespace sema
212
213// AssignmentAction - This is used by all the assignment diagnostic functions
214// to represent what is actually causing the operation
225
226namespace threadSafety {
227class BeforeSet;
228void threadSafetyCleanup(BeforeSet *Cache);
229} // namespace threadSafety
230
231// FIXME: No way to easily map from TemplateTypeParmTypes to
232// TemplateTypeParmDecls, so we have this horrible PointerUnion.
233typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *,
234 const TemplateSpecializationType *,
235 const SubstBuiltinTemplatePackType *>,
238
239/// Describes whether we've seen any nullability information for the given
240/// file.
242 /// The first pointer declarator (of any pointer kind) in the file that does
243 /// not have a corresponding nullability annotation.
245
246 /// The end location for the first pointer declarator in the file. Used for
247 /// placing fix-its.
249
250 /// Which kind of pointer declarator we saw.
251 uint8_t PointerKind;
252
253 /// Whether we saw any type nullability annotations in the given file.
254 bool SawTypeNullability = false;
255};
256
257/// A mapping from file IDs to a record of whether we've seen nullability
258/// information in that file.
260 /// A mapping from file IDs to the nullability information for each file ID.
261 llvm::DenseMap<FileID, FileNullability> Map;
262
263 /// A single-element cache based on the file ID.
264 struct {
267 } Cache;
268
269public:
271 // Check the single-element cache.
272 if (file == Cache.File)
273 return Cache.Nullability;
274
275 // It's not in the single-element cache; flush the cache if we have one.
276 if (!Cache.File.isInvalid()) {
277 Map[Cache.File] = Cache.Nullability;
278 }
279
280 // Pull this entry into the cache.
281 Cache.File = file;
282 Cache.Nullability = Map[file];
283 return Cache.Nullability;
284 }
285};
286
287/// Tracks expected type during expression parsing, for use in code completion.
288/// The type is tied to a particular token, all functions that update or consume
289/// the type take a start location of the token they are looking at as a
290/// parameter. This avoids updating the type on hot paths in the parser.
292public:
294 : Ctx(Ctx), Enabled(Enabled) {}
295
299 /// Handles e.g. BaseType{ .D = Tok...
301 const Designation &D);
302 /// Computing a type for the function argument may require running
303 /// overloading, so we postpone its computation until it is actually needed.
304 ///
305 /// Clients should be very careful when using this function, as it stores a
306 /// function_ref, clients should make sure all calls to get() with the same
307 /// location happen while function_ref is alive.
308 ///
309 /// The callback should also emit signature help as a side-effect, but only
310 /// if the completion point has been reached.
312 llvm::function_ref<QualType()> ComputeType);
313
316 SourceLocation OpLoc);
319 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
320 /// Handles all type casts, including C-style cast, C++ casts, etc.
322
323 /// Get the expected type associated with this location, if any.
324 ///
325 /// If the location is a function argument, determining the expected type
326 /// involves considering all function overloads and the arguments so far.
327 /// In this case, signature help for these function overloads will be reported
328 /// as a side-effect (only if the completion point has been reached).
330 if (!Enabled || Tok != ExpectedLoc)
331 return QualType();
332 if (!Type.isNull())
333 return Type;
334 if (ComputeType)
335 return ComputeType();
336 return QualType();
337 }
338
339private:
340 ASTContext *Ctx;
341 bool Enabled;
342 /// Start position of a token for which we store expected type.
343 SourceLocation ExpectedLoc;
344 /// Expected type for a token starting at ExpectedLoc.
346 /// A function to compute expected type at ExpectedLoc. It is only considered
347 /// if Type is null.
348 llvm::function_ref<QualType()> ComputeType;
349};
350
352 SkipBodyInfo() = default;
353 bool ShouldSkip = false;
355 NamedDecl *Previous = nullptr;
356 NamedDecl *New = nullptr;
357};
358
359/// Describes the result of template argument deduction.
360///
361/// The TemplateDeductionResult enumeration describes the result of
362/// template argument deduction, as returned from
363/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
364/// structure provides additional information about the results of
365/// template argument deduction, e.g., the deduced template argument
366/// list (if successful) or the specific template parameters or
367/// deduced arguments that were involved in the failure.
369 /// Template argument deduction was successful.
371 /// The declaration was invalid; do nothing.
373 /// Template argument deduction exceeded the maximum template
374 /// instantiation depth (which has already been diagnosed).
376 /// Template argument deduction did not deduce a value
377 /// for every template parameter.
379 /// Template argument deduction did not deduce a value for every
380 /// expansion of an expanded template parameter pack.
382 /// Template argument deduction produced inconsistent
383 /// deduced values for the given template parameter.
385 /// Template argument deduction failed due to inconsistent
386 /// cv-qualifiers on a template parameter type that would
387 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
388 /// but were given a non-const "X".
390 /// Substitution of the deduced template argument values
391 /// resulted in an error.
393 /// After substituting deduced template arguments, a dependent
394 /// parameter type did not match the corresponding argument.
396 /// After substituting deduced template arguments, an element of
397 /// a dependent parameter type did not match the corresponding element
398 /// of the corresponding argument (when deducing from an initializer list).
400 /// A non-depnedent component of the parameter did not match the
401 /// corresponding component of the argument.
403 /// When performing template argument deduction for a function
404 /// template, there were too many call arguments.
406 /// When performing template argument deduction for a function
407 /// template, there were too few call arguments.
409 /// The explicitly-specified template arguments were not valid
410 /// template arguments for the given template.
412 /// Checking non-dependent argument conversions failed.
414 /// The deduced arguments did not satisfy the constraints associated
415 /// with the template.
417 /// Deduction failed; that's all we know.
419 /// CUDA Target attributes do not match.
421 /// Some error which was already diagnosed.
423};
424
425/// Kinds of C++ special members.
435
436/// The kind of conversion being performed.
438 /// An implicit conversion.
440 /// A C-style cast.
442 /// A functional-style cast.
444 /// A cast other than a C-style cast.
446 /// A conversion for an operand of a builtin overloaded operator.
448};
449
450enum class TagUseKind {
451 Reference, // Reference to a tag: 'struct foo *X;'
452 Declaration, // Fwd decl of a tag: 'struct foo;'
453 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
454 Friend // Friend declaration: 'friend struct foo;'
455};
456
457/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
458enum class FunctionEffectMode : uint8_t {
459 None, // effect is not present.
460 False, // effect(false).
461 True, // effect(true).
462 Dependent // effect(expr) where expr is dependent.
463};
464
465/// pragma clang section kind
468 BSS = 1,
469 Data = 2,
471 Text = 4,
473};
474
475enum class PragmaClangSectionAction { Set = 0, Clear = 1 };
476
478 Native, // #pragma options align=native
479 Natural, // #pragma options align=natural
480 Packed, // #pragma options align=packed
481 Power, // #pragma options align=power
482 Mac68k, // #pragma options align=mac68k
483 Reset // #pragma options align=reset
484};
485
486enum class TUFragmentKind {
487 /// The global module fragment, between 'module;' and a module-declaration.
489 /// A normal translation unit fragment. For a non-module unit, this is the
490 /// entire translation unit. Otherwise, it runs from the module-declaration
491 /// to the private-module-fragment (if any) or the end of the TU (if not).
493 /// The private module fragment, between 'module :private;' and the end of
494 /// the translation unit.
496};
497
510
511// Used for emitting the right warning by DefaultVariadicArgumentPromotion
519
528
529// Contexts where using non-trivial C union types can be disallowed. This is
530// passed to err_non_trivial_c_union_in_invalid_context.
532 // Function parameter.
534 // Function return.
536 // Default-initialized object.
538 // Variable with automatic storage duration.
540 // Initializer expression that might copy from another object.
542 // Assignment.
544 // Compound literal.
546 // Block capture.
548 // lvalue-to-rvalue conversion of volatile type.
550};
551
552/// Describes the result of the name lookup and resolution performed
553/// by \c Sema::ClassifyName().
555 /// This name is not a type or template in this context, but might be
556 /// something else.
558 /// Classification failed; an error has been produced.
560 /// The name has been typo-corrected to a keyword.
562 /// The name was classified as a type.
564 /// The name was classified as a specific non-type, non-template
565 /// declaration. ActOnNameClassifiedAsNonType should be called to
566 /// convert the declaration to an expression.
568 /// The name was classified as an ADL-only function name.
569 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
570 /// result to an expression.
572 /// The name denotes a member of a dependent type that could not be
573 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
574 /// convert the result to an expression.
576 /// The name was classified as an overload set, and an expression
577 /// representing that overload set has been formed.
578 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
579 /// expression referencing the overload set.
581 /// The name was classified as a template whose specializations are types.
583 /// The name was classified as a variable template name.
585 /// The name was classified as a function template name.
587 /// The name was classified as an ADL-only function template name.
589 /// The name was classified as a concept name.
591};
592
594 // Address discrimination argument of __ptrauth.
596
597 // Extra discriminator argument of __ptrauth.
599};
600
601/// Common ways to introduce type names without a tag for use in diagnostics.
602/// Keep in sync with err_tag_reference_non_tag.
614
615enum class OffsetOfKind {
616 // Not parsing a type within __builtin_offsetof.
618 // Parsing a type within __builtin_offsetof.
620 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
621 // To improve our diagnostic message.
623};
624
625/// Describes the kind of merge to perform for availability
626/// attributes (including "deprecated", "unavailable", and "availability").
628 /// Don't merge availability attributes at all.
630 /// Merge availability attributes for a redeclaration, which requires
631 /// an exact match.
633 /// Merge availability attributes for an override, which requires
634 /// an exact match or a weakening of constraints.
636 /// Merge availability attributes for an implementation of
637 /// a protocol requirement.
639 /// Merge availability attributes for an implementation of
640 /// an optional protocol requirement.
642};
643
645 /// The triviality of a method unaffected by "trivial_abi".
647
648 /// The triviality of a method affected by "trivial_abi".
650};
651
653
654enum class AllowFoldKind {
657};
658
659/// Context in which we're performing a usual arithmetic conversion.
660enum class ArithConvKind {
661 /// An arithmetic operation.
663 /// A bitwise operation.
665 /// A comparison.
667 /// A conditional (?:) operator.
669 /// A compound assignment expression.
671};
672
673// Used for determining in which context a type is allowed to be passed to a
674// vararg function.
682
683/// AssignConvertType - All of the 'assignment' semantic checks return this
684/// enum to indicate whether the assignment was allowed. These checks are
685/// done for simple assignments, as well as initialization, return from
686/// function, argument passing, etc. The query is phrased in terms of a
687/// source and destination type.
689 /// Compatible - the types are compatible according to the standard.
691
692 /// CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because
693 /// a void * can implicitly convert to another pointer type, which we
694 /// differentiate for better diagnostic behavior.
696
697 /// PointerToInt - The assignment converts a pointer to an int, which we
698 /// accept as an extension.
700
701 /// IntToPointer - The assignment converts an int to a pointer, which we
702 /// accept as an extension.
704
705 /// FunctionVoidPointer - The assignment is between a function pointer and
706 /// void*, which the standard doesn't allow, but we accept as an extension.
708
709 /// IncompatiblePointer - The assignment is between two pointers types that
710 /// are not compatible, but we accept them as an extension.
712
713 /// IncompatibleFunctionPointer - The assignment is between two function
714 /// pointers types that are not compatible, but we accept them as an
715 /// extension.
717
718 /// IncompatibleFunctionPointerStrict - The assignment is between two
719 /// function pointer types that are not identical, but are compatible,
720 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
721 /// may trip an indirect call runtime check.
723
724 /// IncompatiblePointerSign - The assignment is between two pointers types
725 /// which point to integers which have a different sign, but are otherwise
726 /// identical. This is a subset of the above, but broken out because it's by
727 /// far the most common case of incompatible pointers.
729
730 /// CompatiblePointerDiscardsQualifiers - The assignment discards
731 /// c/v/r qualifiers, which we accept as an extension.
733
734 /// IncompatiblePointerDiscardsQualifiers - The assignment
735 /// discards qualifiers that we don't permit to be discarded,
736 /// like address spaces.
738
739 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
740 /// changes address spaces in nested pointer types which is not allowed.
741 /// For instance, converting __private int ** to __generic int ** is
742 /// illegal even though __private could be converted to __generic.
744
745 /// IncompatibleNestedPointerQualifiers - The assignment is between two
746 /// nested pointer types, and the qualifiers other than the first two
747 /// levels differ e.g. char ** -> const char **, but we accept them as an
748 /// extension.
750
751 /// IncompatibleVectors - The assignment is between two vector types that
752 /// have the same size, which we accept as an extension.
754
755 /// IntToBlockPointer - The assignment converts an int to a block
756 /// pointer. We disallow this.
758
759 /// IncompatibleBlockPointer - The assignment is between two block
760 /// pointers types that are not compatible.
762
763 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
764 /// id type and something else (that is incompatible with it). For example,
765 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
767
768 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
769 /// object with __weak qualifier.
771
772 /// Incompatible - We reject this conversion outright, it is invalid to
773 /// represent it in the AST.
775};
776
777/// The scope in which to find allocation functions.
779 /// Only look for allocation functions in the global scope.
781 /// Only look for allocation functions in the scope of the
782 /// allocated class.
784 /// Look for allocation functions in both the global scope
785 /// and in the scope of the allocated class.
787};
788
789/// Describes the result of an "if-exists" condition check.
790enum class IfExistsResult {
791 /// The symbol exists.
793
794 /// The symbol does not exist.
796
797 /// The name is a dependent name, so the results will differ
798 /// from one instantiation to the next.
800
801 /// An error occurred.
803};
804
805enum class CorrectTypoKind {
806 NonError, // CorrectTypo used in a non error recovery situation.
807 ErrorRecovery // CorrectTypo used in normal error recovery.
808};
809
810enum class OverloadKind {
811 /// This is a legitimate overload: the existing declarations are
812 /// functions or function templates with different signatures.
814
815 /// This is not an overload because the signature exactly matches
816 /// an existing declaration.
818
819 /// This is not an overload because the lookup results contain a
820 /// non-function.
822};
823
824/// Contexts in which a converted constant expression is required.
825enum class CCEKind {
826 CaseValue, ///< Expression in a case label.
827 Enumerator, ///< Enumerator value with fixed underlying type.
828 TemplateArg, ///< Value of a non-type template parameter.
829 TempArgStrict, ///< As above, but applies strict template checking
830 ///< rules.
831 ArrayBound, ///< Array bound in array declarator or new-expression.
832 ExplicitBool, ///< Condition in an explicit(bool) specifier.
833 Noexcept, ///< Condition in a noexcept(bool) specifier.
834 StaticAssertMessageSize, ///< Call to size() in a static assert
835 ///< message.
836 StaticAssertMessageData, ///< Call to data() in a static assert
837 ///< message.
838};
839
840/// Enums for the diagnostics of target, target_version and target_clones.
841namespace DiagAttrParams {
845} // end namespace DiagAttrParams
846
847void inferNoReturnAttr(Sema &S, const Decl *D);
848
849#ifdef __GNUC__
850#pragma GCC diagnostic push
851#pragma GCC diagnostic ignored "-Wattributes"
852#endif
853/// Sema - This implements semantic analysis and AST building for C.
854/// \nosubgrouping
855class Sema final : public SemaBase {
856#ifdef __GNUC__
857#pragma GCC diagnostic pop
858#endif
859 // Table of Contents
860 // -----------------
861 // 1. Semantic Analysis (Sema.cpp)
862 // 2. API Notes (SemaAPINotes.cpp)
863 // 3. C++ Access Control (SemaAccess.cpp)
864 // 4. Attributes (SemaAttr.cpp)
865 // 5. Availability Attribute Handling (SemaAvailability.cpp)
866 // 6. Bounds Safety (SemaBoundsSafety.cpp)
867 // 7. Casts (SemaCast.cpp)
868 // 8. Extra Semantic Checking (SemaChecking.cpp)
869 // 9. C++ Coroutines (SemaCoroutine.cpp)
870 // 10. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
871 // 11. Declarations (SemaDecl.cpp)
872 // 12. Declaration Attribute Handling (SemaDeclAttr.cpp)
873 // 13. C++ Declarations (SemaDeclCXX.cpp)
874 // 14. C++ Exception Specifications (SemaExceptionSpec.cpp)
875 // 15. Expressions (SemaExpr.cpp)
876 // 16. C++ Expressions (SemaExprCXX.cpp)
877 // 17. Member Access Expressions (SemaExprMember.cpp)
878 // 18. Initializers (SemaInit.cpp)
879 // 19. C++ Lambda Expressions (SemaLambda.cpp)
880 // 20. Name Lookup (SemaLookup.cpp)
881 // 21. Modules (SemaModule.cpp)
882 // 22. C++ Overloading (SemaOverload.cpp)
883 // 23. Statements (SemaStmt.cpp)
884 // 24. `inline asm` Statement (SemaStmtAsm.cpp)
885 // 25. Statement Attribute Handling (SemaStmtAttr.cpp)
886 // 26. C++ Templates (SemaTemplate.cpp)
887 // 27. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
888 // 28. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
889 // 29. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
890 // 30. C++ Template Declaration Instantiation
891 // (SemaTemplateInstantiateDecl.cpp)
892 // 31. C++ Variadic Templates (SemaTemplateVariadic.cpp)
893 // 32. Constraints and Concepts (SemaConcept.cpp)
894 // 33. Types (SemaType.cpp)
895 // 34. FixIt Helpers (SemaFixItUtils.cpp)
896 // 35. Function Effects (SemaFunctionEffects.cpp)
897
898 /// \name Semantic Analysis
899 /// Implementations are in Sema.cpp
900 ///@{
901
902public:
903 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
905 CodeCompleteConsumer *CompletionConsumer = nullptr);
906 ~Sema();
907
908 /// Perform initialization that occurs after the parser has been
909 /// initialized but before it parses anything.
910 void Initialize();
911
912 /// This virtual key function only exists to limit the emission of debug info
913 /// describing the Sema class. GCC and Clang only emit debug info for a class
914 /// with a vtable when the vtable is emitted. Sema is final and not
915 /// polymorphic, but the debug info size savings are so significant that it is
916 /// worth adding a vtable just to take advantage of this optimization.
918
919 const LangOptions &getLangOpts() const { return LangOpts; }
922
925 Preprocessor &getPreprocessor() const { return PP; }
926 ASTContext &getASTContext() const { return Context; }
930
932 StringRef Platform);
934
935 /// Registers an external source. If an external source already exists,
936 /// creates a multiplex external source and appends to it.
937 ///
938 ///\param[in] E - A non-null external sema source.
939 ///
941
942 /// Print out statistics about the semantic analysis.
943 void PrintStats() const;
944
945 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
946 /// guaranteed). Produces a warning if we're low on stack space and allocates
947 /// more in that case. Use this in code that may recurse deeply (for example,
948 /// in template instantiation) to avoid stack overflow.
950 llvm::function_ref<void()> Fn);
951
952 /// Returns default addr space for method qualifiers.
954
955 /// Load weak undeclared identifiers from the external source.
957
958 /// Determine if VD, which must be a variable or function, is an external
959 /// symbol that nonetheless can't be referenced from outside this translation
960 /// unit because its type has no linkage and it's not extern "C".
961 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
962
963 /// Obtain a sorted list of functions that are undefined but ODR-used.
965 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
966
967 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
969 /// Retrieves list of suspicious delete-expressions that will be checked at
970 /// the end of translation unit.
971 const llvm::MapVector<FieldDecl *, DeleteLocs> &
973
974 /// Cause the built diagnostic to be emitted on the DiagosticsEngine.
975 /// This is closely coupled to the SemaDiagnosticBuilder class and
976 /// should not be used elsewhere.
977 void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB);
978
979 void addImplicitTypedef(StringRef Name, QualType T);
980
981 /// Whether uncompilable error has occurred. This includes error happens
982 /// in deferred diagnostics.
983 bool hasUncompilableErrorOccurred() const;
984
985 /// Looks through the macro-expansion chain for the given
986 /// location, looking for a macro expansion with the given name.
987 /// If one is found, returns true and sets the location to that
988 /// expansion loc.
989 bool findMacroSpelling(SourceLocation &loc, StringRef name);
990
991 /// Calls \c Lexer::getLocForEndOfToken()
992 SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
993
994 /// Calls \c Lexer::findNextToken() to find the next token, and if the
995 /// locations of both ends of the token can be resolved it return that
996 /// range; Otherwise it returns an invalid SourceRange.
998 SourceLocation Loc, bool IncludeMacros, bool IncludeComments,
999 std::optional<tok::TokenKind> ExpectedToken = std::nullopt);
1000
1001 /// Retrieve the module loader associated with the preprocessor.
1003
1004 /// Invent a new identifier for parameters of abbreviated templates.
1007 unsigned Index);
1008
1010
1011 // Emit all deferred diagnostics.
1012 void emitDeferredDiags();
1013
1014 /// This is called before the very first declaration in the translation unit
1015 /// is parsed. Note that the ASTContext may have already injected some
1016 /// declarations.
1018 /// ActOnEndOfTranslationUnit - This is called at the very end of the
1019 /// translation unit when EOF is reached and all but the top-level scope is
1020 /// popped.
1023
1024 /// Determines the active Scope associated with the given declaration
1025 /// context.
1026 ///
1027 /// This routine maps a declaration context to the active Scope object that
1028 /// represents that declaration context in the parser. It is typically used
1029 /// from "scope-less" code (e.g., template instantiation, lazy creation of
1030 /// declarations) that injects a name for name-lookup purposes and, therefore,
1031 /// must update the Scope.
1032 ///
1033 /// \returns The scope corresponding to the given declaraion context, or NULL
1034 /// if no such scope is open.
1036
1037 void PushFunctionScope();
1038 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
1040
1041 /// This is used to inform Sema what the current TemplateParameterDepth
1042 /// is during Parsing. Currently it is used to pass on the depth
1043 /// when parsing generic lambda 'auto' parameters.
1044 void RecordParsingTemplateParameterDepth(unsigned Depth);
1045
1046 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
1048 unsigned OpenMPCaptureLevel = 0);
1049
1050 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
1051 /// time after they've been popped.
1053 Sema *Self;
1054
1055 public:
1056 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
1058 };
1059
1061 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
1062
1063 /// Pop a function (or block or lambda or captured region) scope from the
1064 /// stack.
1065 ///
1066 /// \param WP The warning policy to use for CFG-based warnings, or null if
1067 /// such warnings should not be produced.
1068 /// \param D The declaration corresponding to this function scope, if
1069 /// producing CFG-based warnings.
1070 /// \param BlockType The type of the block expression, if D is a BlockDecl.
1073 const Decl *D = nullptr,
1074 QualType BlockType = QualType());
1075
1077
1082
1083 void PushCompoundScope(bool IsStmtExpr);
1084 void PopCompoundScope();
1085
1086 /// Determine whether any errors occurred within this function/method/
1087 /// block.
1089
1090 /// Retrieve the current block, if any.
1092
1093 /// Get the innermost lambda or block enclosing the current location, if any.
1094 /// This looks through intervening non-lambda, non-block scopes such as local
1095 /// functions.
1097
1098 /// Retrieve the current lambda scope info, if any.
1099 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
1100 /// lambda scope info ignoring all inner capturing scopes that are not
1101 /// lambda scopes.
1103 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
1104
1105 /// Retrieve the current generic lambda info, if any.
1107
1108 /// Retrieve the current captured region, if any.
1110
1111 void ActOnComment(SourceRange Comment);
1112
1113 /// Retrieve the parser's current scope.
1114 ///
1115 /// This routine must only be used when it is certain that semantic analysis
1116 /// and the parser are in precisely the same context, which is not the case
1117 /// when, e.g., we are performing any kind of template instantiation.
1118 /// Therefore, the only safe places to use this scope are in the parser
1119 /// itself and in routines directly invoked from the parser and *never* from
1120 /// template substitution or instantiation.
1121 Scope *getCurScope() const { return CurScope; }
1122
1124
1128
1129 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
1130 const FunctionDecl *FD = nullptr);
1132 const PartialDiagnostic &PD,
1133 const FunctionDecl *FD = nullptr) {
1134 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
1135 }
1136
1137 /// Check if the type is allowed to be used for the current target.
1139 ValueDecl *D = nullptr);
1140
1141 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
1142 /// cast. If there is already an implicit cast, merge into the existing one.
1143 /// If isLvalue, the result of the cast is an lvalue.
1146 const CXXCastPath *BasePath = nullptr,
1148
1149 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
1150 /// to the conversion from scalar type ScalarTy to the Boolean type.
1152
1153 /// If \p AllowLambda is true, treat lambda as function.
1154 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
1155
1156 /// Returns a pointer to the innermost enclosing function, or nullptr if the
1157 /// current context is not inside a function. If \p AllowLambda is true,
1158 /// this can return the call operator of an enclosing lambda, otherwise
1159 /// lambdas are skipped when looking for an enclosing function.
1160 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
1161
1162 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
1163 /// the method decl for the method being parsed. If we're currently
1164 /// in a 'block', this returns the containing context.
1166
1167 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
1168 /// or C function we're in, otherwise return null. If we're currently
1169 /// in a 'block', this returns the containing context.
1171
1172 /// Warn if we're implicitly casting from a _Nullable pointer type to a
1173 /// _Nonnull one.
1175 SourceLocation Loc);
1176
1177 /// Warn when implicitly casting 0 to nullptr.
1178 void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
1179
1180 /// Warn when implicitly changing function effects.
1182 SourceLocation Loc);
1183
1184 /// makeUnavailableInSystemHeader - There is an error in the current
1185 /// context. If we're still in a system header, and we can plausibly
1186 /// make the relevant declaration unavailable instead of erroring, do
1187 /// so and return true.
1189 UnavailableAttr::ImplicitReason reason);
1190
1191 /// Retrieve a suitable printing policy for diagnostics.
1195
1196 /// Retrieve a suitable printing policy for diagnostics.
1198 const Preprocessor &PP);
1199
1200 /// Scope actions.
1202
1203 /// Determine whether \param D is function like (function or function
1204 /// template) for parsing.
1206
1207 /// The maximum alignment, same as in llvm::Value. We duplicate them here
1208 /// because that allows us not to duplicate the constants in clang code,
1209 /// which we must to since we can't directly use the llvm constants.
1210 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
1211 ///
1212 /// This is the greatest alignment value supported by load, store, and alloca
1213 /// instructions, and global values.
1214 static const unsigned MaxAlignmentExponent = 32;
1215 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
1216
1217 /// Flag indicating whether or not to collect detailed statistics.
1219
1220 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
1221
1222 /// Stack containing information about each of the nested
1223 /// function, block, and method scopes that are currently active.
1225
1226 /// The index of the first FunctionScope that corresponds to the current
1227 /// context.
1229
1230 /// Track the number of currently active capturing scopes.
1232
1233 llvm::BumpPtrAllocator BumpAlloc;
1234
1235 /// The kind of translation unit we are processing.
1236 ///
1237 /// When we're processing a complete translation unit, Sema will perform
1238 /// end-of-translation-unit semantic tasks (such as creating
1239 /// initializers for tentative definitions in C) once parsing has
1240 /// completed. Modules and precompiled headers perform different kinds of
1241 /// checks.
1243
1244 /// Translation Unit Scope - useful to Objective-C actions that need
1245 /// to lookup file scope declarations in the "ordinary" C decl namespace.
1246 /// For example, user-defined classes, built-in "id" type, etc.
1248
1250 return CurScope->incrementMSManglingNumber();
1251 }
1252
1253 /// Try to recover by turning the given expression into a
1254 /// call. Returns true if recovery was attempted or an error was
1255 /// emitted; this may also leave the ExprResult invalid.
1257 bool ForceComplain = false,
1258 bool (*IsPlausibleResult)(QualType) = nullptr);
1259
1260 /// Figure out if an expression could be turned into a call.
1261 ///
1262 /// Use this when trying to recover from an error where the programmer may
1263 /// have written just the name of a function instead of actually calling it.
1264 ///
1265 /// \param E - The expression to examine.
1266 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
1267 /// with no arguments, this parameter is set to the type returned by such a
1268 /// call; otherwise, it is set to an empty QualType.
1269 /// \param OverloadSet - If the expression is an overloaded function
1270 /// name, this parameter is populated with the decls of the various
1271 /// overloads.
1272 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
1273 UnresolvedSetImpl &NonTemplateOverloads);
1274
1278
1281
1289
1290 /// A RAII object to enter scope of a compound statement.
1292 public:
1293 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
1294 S.ActOnStartOfCompoundStmt(IsStmtExpr);
1295 }
1296
1297 ~CompoundScopeRAII() { S.ActOnFinishOfCompoundStmt(); }
1298
1299 private:
1300 Sema &S;
1301 };
1302
1303 /// An RAII helper that pops function a function scope on exit.
1309 if (Active)
1310 S.PopFunctionScopeInfo();
1311 }
1312 void disable() { Active = false; }
1313 };
1314
1316 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
1317 }
1318
1319 /// Worker object for performing CFG-based warnings.
1322
1323 /// Callback to the parser to parse templated functions when needed.
1324 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
1327
1329 LateTemplateParser = LTP;
1330 OpaqueParser = P;
1331 }
1332
1333 /// Callback to the parser to parse a type expressed as a string.
1334 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
1336
1337 /// VAListTagName - The declaration name corresponding to __va_list_tag.
1338 /// This is used as part of a hack to omit that class from ADL results.
1340
1341 /// Is the last error level diagnostic immediate. This is used to determined
1342 /// whether the next info diagnostic should be immediate.
1344
1345 class DelayedDiagnostics;
1346
1348 sema::DelayedDiagnosticPool *SavedPool = nullptr;
1350 };
1353
1354 /// A class which encapsulates the logic for delaying diagnostics
1355 /// during parsing and other processing.
1357 /// The current pool of diagnostics into which delayed
1358 /// diagnostics should go.
1359 sema::DelayedDiagnosticPool *CurPool = nullptr;
1360
1361 public:
1363
1364 /// Adds a delayed diagnostic.
1365 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
1366
1367 /// Determines whether diagnostics should be delayed.
1368 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
1369
1370 /// Returns the current delayed-diagnostics pool.
1371 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1372
1373 /// Enter a new scope. Access and deprecation diagnostics will be
1374 /// collected in this pool.
1377 state.SavedPool = CurPool;
1378 CurPool = &pool;
1379 return state;
1380 }
1381
1382 /// Leave a delayed-diagnostic state that was previously pushed.
1383 /// Do not emit any of the diagnostics. This is performed as part
1384 /// of the bookkeeping of popping a pool "properly".
1386 CurPool = state.SavedPool;
1387 }
1388
1389 /// Enter a new scope where access and deprecation diagnostics are
1390 /// not delayed.
1393 state.SavedPool = CurPool;
1394 CurPool = nullptr;
1395 return state;
1396 }
1397
1398 /// Undo a previous pushUndelayed().
1400 assert(CurPool == nullptr);
1401 CurPool = state.SavedPool;
1402 }
1404
1408
1409 /// Diagnostics that are emitted only if we discover that the given function
1410 /// must be codegen'ed. Because handling these correctly adds overhead to
1411 /// compilation, this is currently only enabled for CUDA compilations.
1412 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1413
1414 /// CurContext - This is the current declaration context of parsing.
1416
1418 assert(AMDGPUPtr);
1419 return *AMDGPUPtr;
1420 }
1421
1423 assert(ARMPtr);
1424 return *ARMPtr;
1425 }
1426
1428 assert(AVRPtr);
1429 return *AVRPtr;
1430 }
1431
1433 assert(BPFPtr);
1434 return *BPFPtr;
1435 }
1436
1438 assert(CodeCompletionPtr);
1439 return *CodeCompletionPtr;
1440 }
1441
1443 assert(CUDAPtr);
1444 return *CUDAPtr;
1445 }
1446
1448 assert(DirectXPtr);
1449 return *DirectXPtr;
1450 }
1451
1453 assert(HLSLPtr);
1454 return *HLSLPtr;
1455 }
1456
1458 assert(HexagonPtr);
1459 return *HexagonPtr;
1460 }
1461
1463 assert(LoongArchPtr);
1464 return *LoongArchPtr;
1465 }
1466
1468 assert(M68kPtr);
1469 return *M68kPtr;
1470 }
1471
1473 assert(MIPSPtr);
1474 return *MIPSPtr;
1475 }
1476
1478 assert(MSP430Ptr);
1479 return *MSP430Ptr;
1480 }
1481
1483 assert(NVPTXPtr);
1484 return *NVPTXPtr;
1485 }
1486
1488 assert(ObjCPtr);
1489 return *ObjCPtr;
1490 }
1491
1493 assert(OpenACCPtr);
1494 return *OpenACCPtr;
1495 }
1496
1498 assert(OpenCLPtr);
1499 return *OpenCLPtr;
1500 }
1501
1503 assert(OpenMPPtr && "SemaOpenMP is dead");
1504 return *OpenMPPtr;
1505 }
1506
1508 assert(PPCPtr);
1509 return *PPCPtr;
1510 }
1511
1513 assert(PseudoObjectPtr);
1514 return *PseudoObjectPtr;
1515 }
1516
1518 assert(RISCVPtr);
1519 return *RISCVPtr;
1520 }
1521
1523 assert(SPIRVPtr);
1524 return *SPIRVPtr;
1525 }
1526
1528 assert(SYCLPtr);
1529 return *SYCLPtr;
1530 }
1531
1533 assert(SwiftPtr);
1534 return *SwiftPtr;
1535 }
1536
1538 assert(SystemZPtr);
1539 return *SystemZPtr;
1540 }
1541
1543 assert(WasmPtr);
1544 return *WasmPtr;
1545 }
1546
1548 assert(X86Ptr);
1549 return *X86Ptr;
1550 }
1551
1552 /// Source of additional semantic information.
1554
1555protected:
1556 friend class Parser;
1558 friend class ASTReader;
1559 friend class ASTDeclReader;
1560 friend class ASTWriter;
1561
1562private:
1563 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1564 bool WarnedDarwinSDKInfoMissing = false;
1565
1566 StackExhaustionHandler StackHandler;
1567
1568 Sema(const Sema &) = delete;
1569 void operator=(const Sema &) = delete;
1570
1571 /// The handler for the FileChanged preprocessor events.
1572 ///
1573 /// Used for diagnostics that implement custom semantic analysis for #include
1574 /// directives, like -Wpragma-pack.
1575 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1576
1577 /// The parser's current scope.
1578 ///
1579 /// The parser maintains this state here.
1580 Scope *CurScope;
1581
1582 mutable IdentifierInfo *Ident_super;
1583
1584 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1585 std::unique_ptr<SemaARM> ARMPtr;
1586 std::unique_ptr<SemaAVR> AVRPtr;
1587 std::unique_ptr<SemaBPF> BPFPtr;
1588 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1589 std::unique_ptr<SemaCUDA> CUDAPtr;
1590 std::unique_ptr<SemaDirectX> DirectXPtr;
1591 std::unique_ptr<SemaHLSL> HLSLPtr;
1592 std::unique_ptr<SemaHexagon> HexagonPtr;
1593 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1594 std::unique_ptr<SemaM68k> M68kPtr;
1595 std::unique_ptr<SemaMIPS> MIPSPtr;
1596 std::unique_ptr<SemaMSP430> MSP430Ptr;
1597 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1598 std::unique_ptr<SemaObjC> ObjCPtr;
1599 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1600 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1601 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1602 std::unique_ptr<SemaPPC> PPCPtr;
1603 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1604 std::unique_ptr<SemaRISCV> RISCVPtr;
1605 std::unique_ptr<SemaSPIRV> SPIRVPtr;
1606 std::unique_ptr<SemaSYCL> SYCLPtr;
1607 std::unique_ptr<SemaSwift> SwiftPtr;
1608 std::unique_ptr<SemaSystemZ> SystemZPtr;
1609 std::unique_ptr<SemaWasm> WasmPtr;
1610 std::unique_ptr<SemaX86> X86Ptr;
1611
1612 ///@}
1613
1614 //
1615 //
1616 // -------------------------------------------------------------------------
1617 //
1618 //
1619
1620 /// \name API Notes
1621 /// Implementations are in SemaAPINotes.cpp
1622 ///@{
1623
1624public:
1625 /// Map any API notes provided for this declaration to attributes on the
1626 /// declaration.
1627 ///
1628 /// Triggered by declaration-attribute processing.
1629 void ProcessAPINotes(Decl *D);
1630 /// Apply the 'Nullability:' annotation to the specified declaration
1631 void ApplyNullability(Decl *D, NullabilityKind Nullability);
1632 /// Apply the 'Type:' annotation to the specified declaration
1633 void ApplyAPINotesType(Decl *D, StringRef TypeString);
1634
1635 /// Whether APINotes should be gathered for all applicable Swift language
1636 /// versions, without being applied. Leaving clients of the current module
1637 /// to select and apply the correct version.
1639 return APINotes.captureVersionIndependentSwift();
1640 }
1641 ///@}
1642
1643 //
1644 //
1645 // -------------------------------------------------------------------------
1646 //
1647 //
1648
1649 /// \name C++ Access Control
1650 /// Implementations are in SemaAccess.cpp
1651 ///@{
1652
1653public:
1660
1661 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1662 /// Returns true on error (when the previous member decl access specifier
1663 /// is different from the new member decl access specifier).
1664 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1665 NamedDecl *PrevMemberDecl,
1666 AccessSpecifier LexicalAS);
1667
1668 /// Perform access-control checking on a previously-unresolved member
1669 /// access which has now been resolved to a member.
1671 DeclAccessPair FoundDecl);
1673 DeclAccessPair FoundDecl);
1674
1675 /// Checks access to an overloaded operator new or delete.
1677 SourceRange PlacementRange,
1678 CXXRecordDecl *NamingClass,
1679 DeclAccessPair FoundDecl,
1680 bool Diagnose = true);
1681
1682 /// Checks access to a constructor.
1684 DeclAccessPair FoundDecl,
1685 const InitializedEntity &Entity,
1686 bool IsCopyBindingRefToTemp = false);
1687
1688 /// Checks access to a constructor.
1690 DeclAccessPair FoundDecl,
1691 const InitializedEntity &Entity,
1692 const PartialDiagnostic &PDiag);
1694 CXXDestructorDecl *Dtor,
1695 const PartialDiagnostic &PDiag,
1696 QualType objectType = QualType());
1697
1698 /// Checks access to the target of a friend declaration.
1700
1701 /// Checks access to a member.
1703 CXXRecordDecl *NamingClass,
1705
1706 /// Checks implicit access to a member in a structured binding.
1709 CXXRecordDecl *DecomposedClass,
1710 DeclAccessPair Field);
1712 const SourceRange &,
1713 DeclAccessPair FoundDecl);
1714
1715 /// Checks access to an overloaded member operator, including
1716 /// conversion operators.
1718 Expr *ArgExpr,
1719 DeclAccessPair FoundDecl);
1721 ArrayRef<Expr *> ArgExprs,
1722 DeclAccessPair FoundDecl);
1724 DeclAccessPair FoundDecl);
1725
1726 /// Checks access for a hierarchy conversion.
1727 ///
1728 /// \param ForceCheck true if this check should be performed even if access
1729 /// control is disabled; some things rely on this for semantics
1730 /// \param ForceUnprivileged true if this check should proceed as if the
1731 /// context had no special privileges
1733 QualType Derived, const CXXBasePath &Path,
1734 unsigned DiagID, bool ForceCheck = false,
1735 bool ForceUnprivileged = false);
1736
1738 SourceLocation AccessLoc, CXXRecordDecl *Base, CXXRecordDecl *Derived,
1739 const CXXBasePath &Path, unsigned DiagID,
1740 llvm::function_ref<void(PartialDiagnostic &PD)> SetupPDiag,
1741 bool ForceCheck = false, bool ForceUnprivileged = false);
1742
1743 /// Checks access to all the declarations in the given result set.
1744 void CheckLookupAccess(const LookupResult &R);
1745
1746 /// Checks access to Target from the given class. The check will take access
1747 /// specifiers into account, but no member access expressions and such.
1748 ///
1749 /// \param Target the declaration to check if it can be accessed
1750 /// \param NamingClass the class in which the lookup was started.
1751 /// \param BaseType type of the left side of member access expression.
1752 /// \p BaseType and \p NamingClass are used for C++ access control.
1753 /// Depending on the lookup case, they should be set to the following:
1754 /// - lhs.target (member access without a qualifier):
1755 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1756 /// - lhs.X::target (member access with a qualifier):
1757 /// BaseType is the type of 'lhs', NamingClass is 'X'
1758 /// - X::target (qualified lookup without member access):
1759 /// BaseType is null, NamingClass is 'X'.
1760 /// - target (unqualified lookup).
1761 /// BaseType is null, NamingClass is the parent class of 'target'.
1762 /// \return true if the Target is accessible from the Class, false otherwise.
1763 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1764 QualType BaseType);
1765
1766 /// Is the given member accessible for the purposes of deciding whether to
1767 /// define a special member function as deleted?
1769 DeclAccessPair Found, QualType ObjectType,
1770 SourceLocation Loc,
1771 const PartialDiagnostic &Diag);
1774 QualType ObjectType) {
1775 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1776 SourceLocation(), PDiag());
1777 }
1778
1780 const DependentDiagnostic &DD,
1781 const MultiLevelTemplateArgumentList &TemplateArgs);
1783
1784 ///@}
1785
1786 //
1787 //
1788 // -------------------------------------------------------------------------
1789 //
1790 //
1791
1792 /// \name Attributes
1793 /// Implementations are in SemaAttr.cpp
1794 ///@{
1795
1796public:
1797 /// Controls member pointer representation format under the MS ABI.
1800
1801 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1802
1803 /// Source location for newly created implicit MSInheritanceAttrs
1805
1811
1817
1819 PSK_Reset = 0x0, // #pragma ()
1820 PSK_Set = 0x1, // #pragma (value)
1821 PSK_Push = 0x2, // #pragma (push[, id])
1822 PSK_Pop = 0x4, // #pragma (pop[, id])
1823 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1824 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1825 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1826 };
1827
1833
1834 // #pragma pack and align.
1836 public:
1837 // `Native` represents default align mode, which may vary based on the
1838 // platform.
1839 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1840
1841 // #pragma pack info constructor
1842 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1843 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1844 assert(Num == PackNumber && "The pack number has been truncated.");
1845 }
1846
1847 // #pragma align info constructor
1849 : PackAttr(false), AlignMode(M),
1850 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1851
1852 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1853
1855
1856 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1857 // integer encoding for it. This should only be passed to
1858 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1859 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1860 std::uint32_t Encoding{};
1861 if (Info.IsXLStack())
1862 Encoding |= IsXLMask;
1863
1864 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1865
1866 if (Info.IsPackAttr())
1867 Encoding |= PackAttrMask;
1868
1869 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1870
1871 return Encoding;
1872 }
1873
1874 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1875 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1877 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1878 int PackNumber = (Encoding & PackNumMask) >> 4;
1879
1880 if (Encoding & PackAttrMask)
1881 return AlignPackInfo(M, PackNumber, IsXL);
1882
1883 return AlignPackInfo(M, IsXL);
1884 }
1885
1886 bool IsPackAttr() const { return PackAttr; }
1887
1888 bool IsAlignAttr() const { return !PackAttr; }
1889
1890 Mode getAlignMode() const { return AlignMode; }
1891
1892 unsigned getPackNumber() const { return PackNumber; }
1893
1894 bool IsPackSet() const {
1895 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1896 // attriute on a decl.
1897 return PackNumber != UninitPackVal && PackNumber != 0;
1898 }
1899
1900 bool IsXLStack() const { return XLStack; }
1901
1902 bool operator==(const AlignPackInfo &Info) const {
1903 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1904 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1905 Info.XLStack);
1906 }
1907
1908 bool operator!=(const AlignPackInfo &Info) const {
1909 return !(*this == Info);
1910 }
1911
1912 private:
1913 /// \brief True if this is a pragma pack attribute,
1914 /// not a pragma align attribute.
1915 bool PackAttr;
1916
1917 /// \brief The alignment mode that is in effect.
1918 Mode AlignMode;
1919
1920 /// \brief The pack number of the stack.
1921 unsigned char PackNumber;
1922
1923 /// \brief True if it is a XL #pragma align/pack stack.
1924 bool XLStack;
1925
1926 /// \brief Uninitialized pack value.
1927 static constexpr unsigned char UninitPackVal = -1;
1928
1929 // Masks to encode and decode an AlignPackInfo.
1930 static constexpr uint32_t IsXLMask{0x0000'0001};
1931 static constexpr uint32_t AlignModeMask{0x0000'0006};
1932 static constexpr uint32_t PackAttrMask{0x00000'0008};
1933 static constexpr uint32_t PackNumMask{0x0000'01F0};
1934 };
1935
1936 template <typename ValueType> struct PragmaStack {
1948
1949 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1950 llvm::StringRef StackSlotLabel, ValueType Value) {
1951 if (Action == PSK_Reset) {
1953 CurrentPragmaLocation = PragmaLocation;
1954 return;
1955 }
1956 if (Action & PSK_Push)
1957 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1958 PragmaLocation);
1959 else if (Action & PSK_Pop) {
1960 if (!StackSlotLabel.empty()) {
1961 // If we've got a label, try to find it and jump there.
1962 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1963 return x.StackSlotLabel == StackSlotLabel;
1964 });
1965 // If we found the label so pop from there.
1966 if (I != Stack.rend()) {
1967 CurrentValue = I->Value;
1968 CurrentPragmaLocation = I->PragmaLocation;
1969 Stack.erase(std::prev(I.base()), Stack.end());
1970 }
1971 } else if (!Stack.empty()) {
1972 // We do not have a label, just pop the last entry.
1973 CurrentValue = Stack.back().Value;
1974 CurrentPragmaLocation = Stack.back().PragmaLocation;
1975 Stack.pop_back();
1976 }
1977 }
1978 if (Action & PSK_Set) {
1980 CurrentPragmaLocation = PragmaLocation;
1981 }
1982 }
1983
1984 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1985 // method body to restore the stacks on exit, so it works like this:
1986 //
1987 // struct S {
1988 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1989 // void Method {}
1990 // #pragma <name>(pop, InternalPragmaSlot)
1991 // };
1992 //
1993 // It works even with #pragma vtordisp, although MSVC doesn't support
1994 // #pragma vtordisp(push [, id], n)
1995 // syntax.
1996 //
1997 // Push / pop a named sentinel slot.
1998 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
1999 assert((Action == PSK_Push || Action == PSK_Pop) &&
2000 "Can only push / pop #pragma stack sentinels!");
2001 Act(CurrentPragmaLocation, Action, Label, CurrentValue);
2002 }
2003
2004 // Constructors.
2005 explicit PragmaStack(const ValueType &Default)
2007
2008 bool hasValue() const { return CurrentValue != DefaultValue; }
2009
2011 ValueType DefaultValue; // Value used for PSK_Reset action.
2012 ValueType CurrentValue;
2014 };
2015 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
2016 // we shouldn't do so if they're in a module).
2017
2018 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
2019 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
2020 ///
2021 /// 0: Suppress all vtordisps
2022 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
2023 /// structors
2024 /// 2: Always insert vtordisps to support RTTI on partially constructed
2025 /// objects
2028 // The current #pragma align/pack values and locations at each #include.
2035 // Segment #pragmas.
2040
2041 // #pragma strict_gs_check.
2043
2044 // This stack tracks the current state of Sema.CurFPFeatures.
2047 FPOptionsOverride result;
2048 if (!FpPragmaStack.hasValue()) {
2049 result = FPOptionsOverride();
2050 } else {
2051 result = FpPragmaStack.CurrentValue;
2052 }
2053 return result;
2054 }
2055
2062
2063 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
2064 // Actions should be performed only if we enter / exit a C++ method body.
2066 public:
2067 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
2069
2070 private:
2071 Sema &S;
2072 StringRef SlotLabel;
2073 bool ShouldAct;
2074 };
2075
2076 /// Last section used with #pragma init_seg.
2079
2080 /// Sections used with #pragma alloc_text.
2081 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
2082
2083 /// VisContext - Manages the stack for \#pragma GCC visibility.
2084 void *VisContext; // Really a "PragmaVisStack*"
2085
2086 /// This an attribute introduced by \#pragma clang attribute.
2093
2094 /// A push'd group of PragmaAttributeEntries.
2096 /// The location of the push attribute.
2098 /// The namespace of this push group.
2101 };
2102
2104
2105 /// The declaration that is currently receiving an attribute from the
2106 /// #pragma attribute stack.
2108
2109 /// This represents the last location of a "#pragma clang optimize off"
2110 /// directive if such a directive has not been closed by an "on" yet. If
2111 /// optimizations are currently "on", this is set to an invalid location.
2113
2114 /// Get the location for the currently active "\#pragma clang optimize
2115 /// off". If this location is invalid, then the state of the pragma is "on".
2119
2120 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
2121 /// whether the optimizations in the list passed to the pragma should be
2122 /// turned off or on. This boolean is true by default because command line
2123 /// options are honored when `#pragma optimize("", on)`.
2124 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
2126
2127 /// Set of no-builtin functions listed by \#pragma function.
2129
2130 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
2131 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
2133
2134 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
2136
2137 /// Add gsl::Pointer attribute to std::container::iterator
2138 /// \param ND The declaration that introduces the name
2139 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
2140 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
2141
2142 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
2144
2145 /// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
2147
2148 /// Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
2150
2151 /// Add [[gsl::Pointer]] attributes for std:: types.
2153
2154 LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
2155 StringRef ParamName);
2156 // Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'
2157 // can be the name of a function parameter, we need to parse the function
2158 // declaration and rest of the parameters before processesing 'X'. Therefore
2159 // do this lazily instead of processing while parsing the annotation itself.
2161
2162 /// Add _Nullable attributes for std:: types.
2164
2165 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
2168 PragmaClangSectionKind SecKind,
2169 StringRef SecName);
2170
2171 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
2173 SourceLocation PragmaLoc);
2174
2175 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
2176 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
2177 StringRef SlotLabel, Expr *Alignment);
2178
2179 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
2180 /// (unless they are value dependent or type dependent). Returns false
2181 /// and emits a diagnostic if one or more of the arguments could not be
2182 /// folded into a constant.
2185
2190
2192 SourceLocation IncludeLoc);
2194
2195 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
2197
2198 /// ActOnPragmaMSComment - Called on well formed
2199 /// \#pragma comment(kind, "arg").
2201 StringRef Arg);
2202
2203 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
2204 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
2205 StringRef Value);
2206
2207 /// Are precise floating point semantics currently enabled?
2209 return !CurFPFeatures.getAllowFPReassociate() &&
2210 !CurFPFeatures.getNoSignedZero() &&
2211 !CurFPFeatures.getAllowReciprocal() &&
2212 !CurFPFeatures.getAllowApproxFunc();
2213 }
2214
2217
2218 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
2219 void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action,
2221
2222 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
2223 /// pointers_to_members(representation method[, general purpose
2224 /// representation]).
2227 SourceLocation PragmaLoc);
2228
2229 /// Called on well formed \#pragma vtordisp().
2230 void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
2232
2233 bool UnifySection(StringRef SectionName, int SectionFlags,
2234 NamedDecl *TheDecl);
2235 bool UnifySection(StringRef SectionName, int SectionFlags,
2236 SourceLocation PragmaSectionLocation);
2237
2238 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
2239 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
2240 PragmaMsStackAction Action,
2241 llvm::StringRef StackSlotLabel,
2242 StringLiteral *SegmentName, llvm::StringRef PragmaName);
2243
2244 /// Called on well formed \#pragma section().
2245 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
2246 StringLiteral *SegmentName);
2247
2248 /// Called on well-formed \#pragma init_seg().
2249 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
2250 StringLiteral *SegmentName);
2251
2252 /// Called on well-formed \#pragma alloc_text().
2254 SourceLocation PragmaLocation, StringRef Section,
2255 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
2256 &Functions);
2257
2258 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
2259 /// strict_gs_check.
2261 PragmaMsStackAction Action,
2262 bool Value);
2263
2264 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
2265 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
2266 SourceLocation PragmaLoc);
2267
2269 SourceLocation PragmaLoc,
2272 const IdentifierInfo *Namespace);
2273
2274 /// Called on well-formed '\#pragma clang attribute pop'.
2276 const IdentifierInfo *Namespace);
2277
2278 /// Adds the attributes that have been specified using the
2279 /// '\#pragma clang attribute push' directives to the given declaration.
2280 void AddPragmaAttributes(Scope *S, Decl *D);
2281
2283 llvm::function_ref<void(SourceLocation, PartialDiagnostic)>;
2285 return [this](SourceLocation Loc, PartialDiagnostic PD) {
2286 // This bypasses a lot of the filters in the diag engine, as it's
2287 // to be used to attach notes to diagnostics which have already
2288 // been filtered through.
2289 DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
2290 PD.Emit(Builder);
2291 };
2292 }
2293
2299
2301
2302 /// Called on well formed \#pragma clang optimize.
2303 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
2304
2305 /// #pragma optimize("[optimization-list]", on | off).
2306 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
2307
2308 /// Call on well formed \#pragma function.
2309 void
2311 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
2312
2313 /// Only called on function definitions; if there is a pragma in scope
2314 /// with the effect of a range-based optnone, consider marking the function
2315 /// with attribute optnone.
2317
2318 /// Only called on function definitions; if there is a `#pragma alloc_text`
2319 /// that decides which code section the function should be in, add
2320 /// attribute section to the function.
2322
2323 /// Adds the 'optnone' attribute to the function declaration if there
2324 /// are no conflicts; Loc represents the location causing the 'optnone'
2325 /// attribute to be added (usually because of a pragma).
2327
2328 /// Only called on function definitions; if there is a MSVC #pragma optimize
2329 /// in scope, consider changing the function's attributes based on the
2330 /// optimization list passed to the pragma.
2332
2333 /// Only called on function definitions; if there is a pragma in scope
2334 /// with the effect of a range-based no_builtin, consider marking the function
2335 /// with attribute no_builtin.
2337
2338 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
2339 /// add an appropriate visibility attribute.
2341
2342 /// FreeVisContext - Deallocate and null out VisContext.
2343 void FreeVisContext();
2344
2345 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
2346 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
2347 SourceLocation PragmaLoc);
2348
2349 /// ActOnPragmaFPContract - Called on well formed
2350 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
2351 /// \#pragma clang fp contract
2353
2354 /// Called on well formed
2355 /// \#pragma clang fp reassociate
2356 /// or
2357 /// \#pragma clang fp reciprocal
2359 bool IsEnabled);
2360
2361 /// ActOnPragmaFenvAccess - Called on well formed
2362 /// \#pragma STDC FENV_ACCESS
2363 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
2364
2365 /// ActOnPragmaCXLimitedRange - Called on well formed
2366 /// \#pragma STDC CX_LIMITED_RANGE
2369
2370 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
2373
2374 /// Called to set constant rounding mode for floating point operations.
2375 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
2376
2377 /// Called to set exception behavior for floating point operations.
2379
2380 /// PushNamespaceVisibilityAttr - Note that we've entered a
2381 /// namespace with a visibility attribute.
2382 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
2383 SourceLocation Loc);
2384
2385 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
2386 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2387 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2388
2389 /// Handles semantic checking for features that are common to all attributes,
2390 /// such as checking whether a parameter was properly specified, or the
2391 /// correct number of arguments were passed, etc. Returns true if the
2392 /// attribute has been diagnosed.
2393 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2394 bool SkipArgCountCheck = false);
2395 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2396 bool SkipArgCountCheck = false);
2397
2398 ///@}
2399
2400 //
2401 //
2402 // -------------------------------------------------------------------------
2403 //
2404 //
2405
2406 /// \name Availability Attribute Handling
2407 /// Implementations are in SemaAvailability.cpp
2408 ///@{
2409
2410public:
2411 /// Issue any -Wunguarded-availability warnings in \c FD
2413
2415
2416 /// Retrieve the current function, if any, that should be analyzed for
2417 /// potential availability violations.
2419
2421 const ObjCInterfaceDecl *UnknownObjCClass,
2422 bool ObjCPropertyAccess,
2423 bool AvoidPartialAvailabilityChecks,
2424 ObjCInterfaceDecl *ClassReceiver);
2425
2427
2428 std::pair<AvailabilityResult, const NamedDecl *>
2429 ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message,
2430 ObjCInterfaceDecl *ClassReceiver);
2431 ///@}
2432
2433 //
2434 //
2435 // -------------------------------------------------------------------------
2436 //
2437 //
2438
2439 /// \name Bounds Safety
2440 /// Implementations are in SemaBoundsSafety.cpp
2441 ///@{
2442public:
2443 /// Check if applying the specified attribute variant from the "counted by"
2444 /// family of attributes to FieldDecl \p FD is semantically valid. If
2445 /// semantically invalid diagnostics will be emitted explaining the problems.
2446 ///
2447 /// \param FD The FieldDecl to apply the attribute to
2448 /// \param E The count expression on the attribute
2449 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2450 /// attributes. If the false the attribute is from
2451 /// "counted_by" family of attributes.
2452 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2453 /// of attributes. If false the attribute does not have the
2454 /// suffix.
2455 ///
2456 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2457 /// \p CountInBytes and \p OrNull both being true indicates the
2458 /// `counted_by_or_null` attribute.
2459 ///
2460 /// \returns false iff semantically valid.
2461 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2462 bool OrNull);
2463
2464 /// Perform Bounds Safety Semantic checks for assigning to a `__counted_by` or
2465 /// `__counted_by_or_null` pointer type \param LHSTy.
2466 ///
2467 /// \param LHSTy The type being assigned to. Checks will only be performed if
2468 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2469 /// \param RHSExpr The expression being assigned from.
2470 /// \param Action The type assignment being performed
2471 /// \param Loc The SourceLocation to use for error diagnostics
2472 /// \param Assignee The ValueDecl being assigned. This is used to compute
2473 /// the name of the assignee. If the assignee isn't known this can
2474 /// be set to nullptr.
2475 /// \param ShowFullyQualifiedAssigneeName If set to true when using \p
2476 /// Assignee to compute the name of the assignee use the fully
2477 /// qualified name, otherwise use the unqualified name.
2478 ///
2479 /// \returns True iff no diagnostic where emitted, false otherwise.
2481 QualType LHSTy, Expr *RHSExpr, AssignmentAction Action,
2482 SourceLocation Loc, const ValueDecl *Assignee,
2483 bool ShowFullyQualifiedAssigneeName);
2484
2485 /// Perform Bounds Safety Semantic checks for initializing a Bounds Safety
2486 /// pointer.
2487 ///
2488 /// \param Entity The entity being initialized
2489 /// \param Kind The kind of initialization being performed
2490 /// \param Action The type assignment being performed
2491 /// \param LHSTy The type being assigned to. Checks will only be performed if
2492 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2493 /// \param RHSExpr The expression being used for initialization.
2494 ///
2495 /// \returns True iff no diagnostic where emitted, false otherwise.
2497 const InitializationKind &Kind,
2498 AssignmentAction Action,
2499 QualType LHSType, Expr *RHSExpr);
2500
2501 /// Perform Bounds Safety semantic checks for uses of invalid uses counted_by
2502 /// or counted_by_or_null pointers in \param E.
2503 ///
2504 /// \param E the expression to check
2505 ///
2506 /// \returns True iff no diagnostic where emitted, false otherwise.
2508 ///@}
2509
2510 //
2511 //
2512 // -------------------------------------------------------------------------
2513 //
2514 //
2515
2516 /// \name Casts
2517 /// Implementations are in SemaCast.cpp
2518 ///@{
2519
2520public:
2526
2527 /// ActOnCXXNamedCast - Parse
2528 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2530 SourceLocation LAngleBracketLoc, Declarator &D,
2531 SourceLocation RAngleBracketLoc,
2532 SourceLocation LParenLoc, Expr *E,
2533 SourceLocation RParenLoc);
2534
2536 TypeSourceInfo *Ty, Expr *E,
2537 SourceRange AngleBrackets, SourceRange Parens);
2538
2540 ExprResult Operand,
2541 SourceLocation RParenLoc);
2542
2544 Expr *Operand, SourceLocation RParenLoc);
2545
2546 // Checks that reinterpret casts don't have undefined behavior.
2547 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2548 bool IsDereference, SourceRange Range);
2549
2550 // Checks that the vector type should be initialized from a scalar
2551 // by splatting the value rather than populating a single element.
2552 // This is the case for AltiVecVector types as well as with
2553 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2554 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2555
2556 // Checks if the -faltivec-src-compat=gcc option is specified.
2557 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2558 // treated the same way as they are when trying to initialize
2559 // these vectors on gcc (an error is emitted).
2561 QualType SrcTy);
2562
2564 SourceLocation RParenLoc, Expr *Op);
2565
2567 SourceLocation LParenLoc,
2568 Expr *CastExpr,
2569 SourceLocation RParenLoc);
2570
2571 ///@}
2572
2573 //
2574 //
2575 // -------------------------------------------------------------------------
2576 //
2577 //
2578
2579 /// \name Extra Semantic Checking
2580 /// Implementations are in SemaChecking.cpp
2581 ///@{
2582
2583public:
2584 /// Used to change context to isConstantEvaluated without pushing a heavy
2585 /// ExpressionEvaluationContextRecord object.
2587
2592
2594 unsigned ByteNo) const;
2595
2597 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2598 FAPK_Variadic, // values to format are passed as variadic arguments
2599 FAPK_VAList, // values to format are passed in a va_list
2600 FAPK_Elsewhere, // values to format are not passed to this function
2601 };
2602
2603 // Used to grab the relevant information from a FormatAttr and a
2604 // FunctionDeclaration.
2610
2611 /// Given a function and its FormatAttr or FormatMatchesAttr info, attempts to
2612 /// populate the FormatStringInfo parameter with the attribute's correct
2613 /// format_idx and firstDataArg. Returns true when the format fits the
2614 /// function and the FormatStringInfo has been populated.
2615 static bool getFormatStringInfo(const Decl *Function, unsigned FormatIdx,
2616 unsigned FirstArg, FormatStringInfo *FSI);
2617 static bool getFormatStringInfo(unsigned FormatIdx, unsigned FirstArg,
2618 bool HasImplicitThisParam, bool IsVariadic,
2619 FormatStringInfo *FSI);
2620
2621 // Used by C++ template instantiation.
2623
2624 /// ConvertVectorExpr - Handle __builtin_convertvector
2626 SourceLocation BuiltinLoc,
2627 SourceLocation RParenLoc);
2628
2629 static StringRef GetFormatStringTypeName(FormatStringType FST);
2630 static FormatStringType GetFormatStringType(StringRef FormatFlavor);
2631 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2632 static FormatStringType GetFormatStringType(const FormatMatchesAttr *Format);
2633
2634 bool FormatStringHasSArg(const StringLiteral *FExpr);
2635
2636 /// Check for comparisons of floating-point values using == and !=. Issue a
2637 /// warning if the comparison is not likely to do what the programmer
2638 /// intended.
2639 void CheckFloatComparison(SourceLocation Loc, const Expr *LHS,
2640 const Expr *RHS, BinaryOperatorKind Opcode);
2641
2642 /// Register a magic integral constant to be used as a type tag.
2643 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2644 uint64_t MagicValue, QualType Type,
2645 bool LayoutCompatible, bool MustBeNull);
2646
2649
2653
2655
2656 /// If true, \c Type should be compared with other expression's types for
2657 /// layout-compatibility.
2658 LLVM_PREFERRED_TYPE(bool)
2660 LLVM_PREFERRED_TYPE(bool)
2661 unsigned MustBeNull : 1;
2662 };
2663
2664 /// A pair of ArgumentKind identifier and magic value. This uniquely
2665 /// identifies the magic value.
2666 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2667
2668 /// Diagnoses the current set of gathered accesses. This happens at the end of
2669 /// each expression evaluation context. Diagnostics are emitted only for
2670 /// accesses gathered in the current evaluation context.
2672
2673 /// This function checks if the expression is in the sef of potentially
2674 /// misaligned members and it is converted to some pointer type T with lower
2675 /// or equal alignment requirements. If so it removes it. This is used when
2676 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2677 /// void*).
2678 void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
2679
2680 /// Returns true if `From` is a function or pointer to a function with the
2681 /// `cfi_unchecked_callee` attribute but `To` is a function or pointer to
2682 /// function without this attribute.
2683 bool DiscardingCFIUncheckedCallee(QualType From, QualType To) const;
2684
2685 /// This function calls Action when it determines that E designates a
2686 /// misaligned member due to the packed attribute. This is used to emit
2687 /// local diagnostics like in reference binding.
2689 Expr *E,
2690 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2691 Action);
2692
2693 enum class AtomicArgumentOrder { API, AST };
2695 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2696 SourceLocation RParenLoc, MultiExprArg Args,
2699
2700 /// Check to see if a given expression could have '.c_str()' called on it.
2701 bool hasCStrMethod(const Expr *E);
2702
2703 /// Diagnose pointers that are always non-null.
2704 /// \param E the expression containing the pointer
2705 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2706 /// compared to a null pointer
2707 /// \param IsEqual True when the comparison is equal to a null pointer
2708 /// \param Range Extra SourceRange to highlight in the diagnostic
2711 bool IsEqual, SourceRange Range);
2712
2713 /// CheckParmsForFunctionDef - Check that the parameters of the given
2714 /// function are appropriate for the definition of a function. This
2715 /// takes care of any checks that cannot be performed on the
2716 /// declaration itself, e.g., that the types of each of the function
2717 /// parameters are complete.
2719 bool CheckParameterNames);
2720
2721 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2722 /// pointer cast increases the alignment requirements.
2723 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2724
2725 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2726 /// to weak/__unsafe_unretained type.
2727 bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
2728
2729 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2730 /// to weak/__unsafe_unretained expression.
2731 void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
2732
2733 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2734 /// statement as a \p Body, and it is located on the same line.
2735 ///
2736 /// This helps prevent bugs due to typos, such as:
2737 /// if (condition);
2738 /// do_stuff();
2739 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2740 unsigned DiagID);
2741
2742 /// Warn if a for/while loop statement \p S, which is followed by
2743 /// \p PossibleBody, has a suspicious null statement as a body.
2744 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2745
2746 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2747 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2748 SourceLocation OpLoc);
2749
2750 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2752 const TypeSourceInfo *Derived);
2753
2754 /// CheckFunctionCall - Check a direct function call for various correctness
2755 /// and safety properties not strictly enforced by the C type system.
2756 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2757 const FunctionProtoType *Proto);
2758
2765
2766 /// \param FPOnly restricts the arguments to floating-point types.
2767 std::optional<QualType>
2768 BuiltinVectorMath(CallExpr *TheCall,
2771 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2772
2773 void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
2774 const Expr *ThisArg, ArrayRef<const Expr *> Args);
2775
2776 /// Handles the checks for format strings, non-POD arguments to vararg
2777 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2778 /// attributes and AArch64 SME attributes.
2779 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2780 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2781 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2782 VariadicCallType CallType);
2783
2784 /// Verify that two format strings (as understood by attribute(format) and
2785 /// attribute(format_matches) are compatible. If they are incompatible,
2786 /// diagnostics are emitted with the assumption that \c
2787 /// AuthoritativeFormatString is correct and
2788 /// \c TestedFormatString is wrong. If \c FunctionCallArg is provided,
2789 /// diagnostics will point to it and a note will refer to \c
2790 /// TestedFormatString or \c AuthoritativeFormatString as appropriate.
2791 bool
2793 const StringLiteral *AuthoritativeFormatString,
2794 const StringLiteral *TestedFormatString,
2795 const Expr *FunctionCallArg = nullptr);
2796
2797 /// Verify that one format string (as understood by attribute(format)) is
2798 /// self-consistent; for instance, that it doesn't have multiple positional
2799 /// arguments referring to the same argument in incompatible ways. Diagnose
2800 /// if it isn't.
2802
2803 /// \brief Enforce the bounds of a TCB
2804 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2805 /// directly calls other functions in the same TCB as marked by the
2806 /// enforce_tcb and enforce_tcb_leaf attributes.
2807 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2808 const NamedDecl *Callee);
2809
2810 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2811
2812 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2813 /// TheCall is a constant expression.
2814 bool BuiltinConstantArg(CallExpr *TheCall, unsigned ArgNum,
2815 llvm::APSInt &Result);
2816
2817 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2818 /// TheCall is a constant expression in the range [Low, High].
2819 bool BuiltinConstantArgRange(CallExpr *TheCall, unsigned ArgNum, int Low,
2820 int High, bool RangeIsError = true);
2821
2822 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2823 /// TheCall is a constant expression is a multiple of Num..
2824 bool BuiltinConstantArgMultiple(CallExpr *TheCall, unsigned ArgNum,
2825 unsigned Multiple);
2826
2827 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2828 /// constant expression representing a power of 2.
2829 bool BuiltinConstantArgPower2(CallExpr *TheCall, unsigned ArgNum);
2830
2831 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2832 /// a constant expression representing an arbitrary byte value shifted left by
2833 /// a multiple of 8 bits.
2834 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, unsigned ArgNum,
2835 unsigned ArgBits);
2836
2837 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2838 /// TheCall is a constant expression representing either a shifted byte value,
2839 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2840 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2841 /// Arm MVE intrinsics.
2842 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, unsigned ArgNum,
2843 unsigned ArgBits);
2844
2845 /// Checks that a call expression's argument count is at least the desired
2846 /// number. This is useful when doing custom type-checking on a variadic
2847 /// function. Returns true on error.
2848 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2849
2850 /// Checks that a call expression's argument count is at most the desired
2851 /// number. This is useful when doing custom type-checking on a variadic
2852 /// function. Returns true on error.
2853 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2854
2855 /// Checks that a call expression's argument count is in the desired range.
2856 /// This is useful when doing custom type-checking on a variadic function.
2857 /// Returns true on error.
2858 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2859 unsigned MaxArgCount);
2860
2861 /// Checks that a call expression's argument count is the desired number.
2862 /// This is useful when doing custom type-checking. Returns true on error.
2863 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2864
2865 /// Returns true if the argument consists of one contiguous run of 1s with any
2866 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2867 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2868 /// since all 1s are not contiguous.
2869 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2870
2872 bool *ICContext = nullptr,
2873 bool IsListInit = false);
2874
2875 bool
2880 CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr =
2882
2883private:
2884 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2885 const ArraySubscriptExpr *ASE = nullptr,
2886 bool AllowOnePastEnd = true, bool IndexNegated = false);
2887 void CheckArrayAccess(const Expr *E);
2888
2889 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2890 const FunctionProtoType *Proto);
2891
2892 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
2893 /// such as function pointers returned from functions.
2894 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2895
2896 /// CheckConstructorCall - Check a constructor call for correctness and safety
2897 /// properties not enforced by the C type system.
2898 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2900 const FunctionProtoType *Proto, SourceLocation Loc);
2901
2902 /// Warn if a pointer or reference argument passed to a function points to an
2903 /// object that is less aligned than the parameter. This can happen when
2904 /// creating a typedef with a lower alignment than the original type and then
2905 /// calling functions defined in terms of the original type.
2906 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2907 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2908
2909 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2910
2911 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2912 CallExpr *TheCall);
2913
2914 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2915 CallExpr *TheCall);
2916
2917 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2918
2919 /// Check the arguments to '__builtin_va_start', '__builtin_ms_va_start',
2920 /// or '__builtin_c23_va_start' for validity. Emit an error and return true
2921 /// on failure; return false on success.
2922 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2923 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2924
2925 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
2926 /// friends. This is declared to take (...), so we have to check everything.
2927 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2928
2929 /// BuiltinSemaBuiltinFPClassification - Handle functions like
2930 /// __builtin_isnan and friends. This is declared to take (...), so we have
2931 /// to check everything.
2932 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2933 unsigned BuiltinID);
2934
2935 /// Perform semantic analysis for a call to __builtin_complex.
2936 bool BuiltinComplex(CallExpr *TheCall);
2937 bool BuiltinOSLogFormat(CallExpr *TheCall);
2938
2939 /// BuiltinPrefetch - Handle __builtin_prefetch.
2940 /// This is declared to take (const void*, ...) and can take two
2941 /// optional constant int args.
2942 bool BuiltinPrefetch(CallExpr *TheCall);
2943
2944 /// Handle __builtin_alloca_with_align. This is declared
2945 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
2946 /// than 8.
2947 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2948
2949 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
2950 bool BuiltinArithmeticFence(CallExpr *TheCall);
2951
2952 /// BuiltinAssume - Handle __assume (MS Extension).
2953 /// __assume does not evaluate its arguments, and should warn if its argument
2954 /// has side effects.
2955 bool BuiltinAssume(CallExpr *TheCall);
2956
2957 /// Handle __builtin_assume_aligned. This is declared
2958 /// as (const void*, size_t, ...) and can take one optional constant int arg.
2959 bool BuiltinAssumeAligned(CallExpr *TheCall);
2960
2961 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
2962 /// This checks that the target supports __builtin_longjmp and
2963 /// that val is a constant 1.
2964 bool BuiltinLongjmp(CallExpr *TheCall);
2965
2966 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
2967 /// This checks that the target supports __builtin_setjmp.
2968 bool BuiltinSetjmp(CallExpr *TheCall);
2969
2970 /// We have a call to a function like __sync_fetch_and_add, which is an
2971 /// overloaded function based on the pointer type of its first argument.
2972 /// The main BuildCallExpr routines have already promoted the types of
2973 /// arguments because all of these calls are prototyped as void(...).
2974 ///
2975 /// This function goes through and does final semantic checking for these
2976 /// builtins, as well as generating any warnings.
2977 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2978
2979 /// BuiltinNontemporalOverloaded - We have a call to
2980 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
2981 /// overloaded function based on the pointer type of its last argument.
2982 ///
2983 /// This function goes through and does final semantic checking for these
2984 /// builtins.
2985 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2986 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2988
2989 /// \param FPOnly restricts the arguments to floating-point types.
2990 bool BuiltinElementwiseMath(CallExpr *TheCall,
2993 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
2994
2995 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
2996
2997 bool CheckInvalidBuiltinCountedByRef(const Expr *E,
2999 bool BuiltinCountedByRef(CallExpr *TheCall);
3000
3001 // Matrix builtin handling.
3002 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
3003 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
3004 ExprResult CallResult);
3005 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
3006 ExprResult CallResult);
3007
3008 /// CheckFormatArguments - Check calls to printf and scanf (and similar
3009 /// functions) for correct use of format strings.
3010 /// Returns true if a format string has been fully checked.
3011 bool CheckFormatArguments(const FormatAttr *Format,
3012 ArrayRef<const Expr *> Args, bool IsCXXMember,
3013 VariadicCallType CallType, SourceLocation Loc,
3014 SourceRange Range,
3015 llvm::SmallBitVector &CheckedVarArgs);
3016 bool CheckFormatString(const FormatMatchesAttr *Format,
3017 ArrayRef<const Expr *> Args, bool IsCXXMember,
3018 VariadicCallType CallType, SourceLocation Loc,
3019 SourceRange Range,
3020 llvm::SmallBitVector &CheckedVarArgs);
3021 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
3022 FormatArgumentPassingKind FAPK,
3023 StringLiteral *ReferenceFormatString,
3024 unsigned format_idx, unsigned firstDataArg,
3026 SourceLocation Loc, SourceRange range,
3027 llvm::SmallBitVector &CheckedVarArgs);
3028
3029 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
3030
3031 /// Warn when using the wrong abs() function.
3032 void CheckAbsoluteValueFunction(const CallExpr *Call,
3033 const FunctionDecl *FDecl);
3034
3035 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
3036
3037 /// Check for dangerous or invalid arguments to memset().
3038 ///
3039 /// This issues warnings on known problematic, dangerous or unspecified
3040 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
3041 /// function calls.
3042 ///
3043 /// \param Call The call expression to diagnose.
3044 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
3045 IdentifierInfo *FnName);
3046
3047 // Warn if the user has made the 'size' argument to strlcpy or strlcat
3048 // be the size of the source, instead of the destination.
3049 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
3050
3051 // Warn on anti-patterns as the 'size' argument to strncat.
3052 // The correct size argument should look like following:
3053 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
3054 void CheckStrncatArguments(const CallExpr *Call,
3055 const IdentifierInfo *FnName);
3056
3057 /// Alerts the user that they are attempting to free a non-malloc'd object.
3058 void CheckFreeArguments(const CallExpr *E);
3059
3060 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
3061 SourceLocation ReturnLoc, bool isObjCMethod = false,
3062 const AttrVec *Attrs = nullptr,
3063 const FunctionDecl *FD = nullptr);
3064
3065 /// Diagnoses "dangerous" implicit conversions within the given
3066 /// expression (which is a full expression). Implements -Wconversion
3067 /// and -Wsign-compare.
3068 ///
3069 /// \param CC the "context" location of the implicit conversion, i.e.
3070 /// the most location of the syntactic entity requiring the implicit
3071 /// conversion
3072 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
3073
3074 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
3075 /// Input argument E is a logical expression.
3077
3078 /// Diagnose when expression is an integer constant expression and its
3079 /// evaluation results in integer overflow
3080 void CheckForIntOverflow(const Expr *E);
3081 void CheckUnsequencedOperations(const Expr *E);
3082
3083 /// Perform semantic checks on a completed expression. This will either
3084 /// be a full-expression or a default argument expression.
3085 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
3086 bool IsConstexpr = false);
3087
3088 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
3089 Expr *Init);
3090
3091 /// A map from magic value to type information.
3092 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
3093 TypeTagForDatatypeMagicValues;
3094
3095 /// Peform checks on a call of a function with argument_with_type_tag
3096 /// or pointer_with_type_tag attributes.
3097 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
3098 const ArrayRef<const Expr *> ExprArgs,
3099 SourceLocation CallSiteLoc);
3100
3101 /// Check if we are taking the address of a packed field
3102 /// as this may be a problem if the pointer value is dereferenced.
3103 void CheckAddressOfPackedMember(Expr *rhs);
3104
3105 /// Helper class that collects misaligned member designations and
3106 /// their location info for delayed diagnostics.
3107 struct MisalignedMember {
3108 Expr *E;
3109 RecordDecl *RD;
3110 ValueDecl *MD;
3111 CharUnits Alignment;
3112
3113 MisalignedMember() : E(), RD(), MD() {}
3114 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
3115 CharUnits Alignment)
3116 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
3117 explicit MisalignedMember(Expr *E)
3118 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
3119
3120 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
3121 };
3122
3123 /// Adds an expression to the set of gathered misaligned members.
3124 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
3125 CharUnits Alignment);
3126 ///@}
3127
3128 //
3129 //
3130 // -------------------------------------------------------------------------
3131 //
3132 //
3133
3134 /// \name C++ Coroutines
3135 /// Implementations are in SemaCoroutine.cpp
3136 ///@{
3137
3138public:
3139 /// The C++ "std::coroutine_traits" template, which is defined in
3140 /// <coroutine_traits>
3142
3144 StringRef Keyword);
3148
3151 UnresolvedLookupExpr *Lookup);
3153 Expr *Awaiter, bool IsImplicit = false);
3155 UnresolvedLookupExpr *Lookup);
3158 bool IsImplicit = false);
3163
3164 // As a clang extension, enforces that a non-coroutine function must be marked
3165 // with [[clang::coro_wrapper]] if it returns a type marked with
3166 // [[clang::coro_return_type]].
3167 // Expects that FD is not a coroutine.
3169 /// Lookup 'coroutine_traits' in std namespace and std::experimental
3170 /// namespace. The namespace found is recorded in Namespace.
3172 SourceLocation FuncLoc);
3173 /// Check that the expression co_await promise.final_suspend() shall not be
3174 /// potentially-throwing.
3175 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
3176
3177 ///@}
3178
3179 //
3180 //
3181 // -------------------------------------------------------------------------
3182 //
3183 //
3184
3185 /// \name C++ Scope Specifiers
3186 /// Implementations are in SemaCXXScopeSpec.cpp
3187 ///@{
3188
3189public:
3190 // Marks SS invalid if it represents an incomplete type.
3192 // Complete an enum decl, maybe without a scope spec.
3194 CXXScopeSpec *SS = nullptr);
3195
3196 /// Compute the DeclContext that is associated with the given type.
3197 ///
3198 /// \param T the type for which we are attempting to find a DeclContext.
3199 ///
3200 /// \returns the declaration context represented by the type T,
3201 /// or NULL if the declaration context cannot be computed (e.g., because it is
3202 /// dependent and not the current instantiation).
3204
3205 /// Compute the DeclContext that is associated with the given
3206 /// scope specifier.
3207 ///
3208 /// \param SS the C++ scope specifier as it appears in the source
3209 ///
3210 /// \param EnteringContext when true, we will be entering the context of
3211 /// this scope specifier, so we can retrieve the declaration context of a
3212 /// class template or class template partial specialization even if it is
3213 /// not the current instantiation.
3214 ///
3215 /// \returns the declaration context represented by the scope specifier @p SS,
3216 /// or NULL if the declaration context cannot be computed (e.g., because it is
3217 /// dependent and not the current instantiation).
3219 bool EnteringContext = false);
3221
3222 /// If the given nested name specifier refers to the current
3223 /// instantiation, return the declaration that corresponds to that
3224 /// current instantiation (C++0x [temp.dep.type]p1).
3225 ///
3226 /// \param NNS a dependent nested name specifier.
3228
3229 /// The parser has parsed a global nested-name-specifier '::'.
3230 ///
3231 /// \param CCLoc The location of the '::'.
3232 ///
3233 /// \param SS The nested-name-specifier, which will be updated in-place
3234 /// to reflect the parsed nested-name-specifier.
3235 ///
3236 /// \returns true if an error occurred, false otherwise.
3238
3239 /// The parser has parsed a '__super' nested-name-specifier.
3240 ///
3241 /// \param SuperLoc The location of the '__super' keyword.
3242 ///
3243 /// \param ColonColonLoc The location of the '::'.
3244 ///
3245 /// \param SS The nested-name-specifier, which will be updated in-place
3246 /// to reflect the parsed nested-name-specifier.
3247 ///
3248 /// \returns true if an error occurred, false otherwise.
3250 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
3251
3252 /// Determines whether the given declaration is an valid acceptable
3253 /// result for name lookup of a nested-name-specifier.
3254 /// \param SD Declaration checked for nested-name-specifier.
3255 /// \param IsExtension If not null and the declaration is accepted as an
3256 /// extension, the pointed variable is assigned true.
3258 bool *CanCorrect = nullptr);
3259
3260 /// If the given nested-name-specifier begins with a bare identifier
3261 /// (e.g., Base::), perform name lookup for that identifier as a
3262 /// nested-name-specifier within the given scope, and return the result of
3263 /// that name lookup.
3265
3266 /// Keeps information about an identifier in a nested-name-spec.
3267 ///
3269 /// The type of the object, if we're parsing nested-name-specifier in
3270 /// a member access expression.
3272
3273 /// The identifier preceding the '::'.
3275
3276 /// The location of the identifier.
3278
3279 /// The location of the '::'.
3281
3282 /// Creates info object for the most typical case.
3284 SourceLocation ColonColonLoc,
3287 CCLoc(ColonColonLoc) {}
3288
3290 SourceLocation ColonColonLoc, QualType ObjectType)
3292 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
3293 };
3294
3295 /// Build a new nested-name-specifier for "identifier::", as described
3296 /// by ActOnCXXNestedNameSpecifier.
3297 ///
3298 /// \param S Scope in which the nested-name-specifier occurs.
3299 /// \param IdInfo Parser information about an identifier in the
3300 /// nested-name-spec.
3301 /// \param EnteringContext If true, enter the context specified by the
3302 /// nested-name-specifier.
3303 /// \param SS Optional nested name specifier preceding the identifier.
3304 /// \param ScopeLookupResult Provides the result of name lookup within the
3305 /// scope of the nested-name-specifier that was computed at template
3306 /// definition time.
3307 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
3308 /// error recovery and what kind of recovery is performed.
3309 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
3310 /// are allowed. The bool value pointed by this parameter is set to
3311 /// 'true' if the identifier is treated as if it was followed by ':',
3312 /// not '::'.
3313 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3314 ///
3315 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
3316 /// that it contains an extra parameter \p ScopeLookupResult, which provides
3317 /// the result of name lookup within the scope of the nested-name-specifier
3318 /// that was computed at template definition time.
3319 ///
3320 /// If ErrorRecoveryLookup is true, then this call is used to improve error
3321 /// recovery. This means that it should not emit diagnostics, it should
3322 /// just return true on failure. It also means it should only return a valid
3323 /// scope if it *knows* that the result is correct. It should not return in a
3324 /// dependent context, for example. Nor will it extend \p SS with the scope
3325 /// specifier.
3326 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3327 bool EnteringContext, CXXScopeSpec &SS,
3328 NamedDecl *ScopeLookupResult,
3329 bool ErrorRecoveryLookup,
3330 bool *IsCorrectedToColon = nullptr,
3331 bool OnlyNamespace = false);
3332
3333 /// The parser has parsed a nested-name-specifier 'identifier::'.
3334 ///
3335 /// \param S The scope in which this nested-name-specifier occurs.
3336 ///
3337 /// \param IdInfo Parser information about an identifier in the
3338 /// nested-name-spec.
3339 ///
3340 /// \param EnteringContext Whether we're entering the context nominated by
3341 /// this nested-name-specifier.
3342 ///
3343 /// \param SS The nested-name-specifier, which is both an input
3344 /// parameter (the nested-name-specifier before this type) and an
3345 /// output parameter (containing the full nested-name-specifier,
3346 /// including this new type).
3347 ///
3348 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
3349 /// are allowed. The bool value pointed by this parameter is set to 'true'
3350 /// if the identifier is treated as if it was followed by ':', not '::'.
3351 ///
3352 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3353 ///
3354 /// \returns true if an error occurred, false otherwise.
3355 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3356 bool EnteringContext, CXXScopeSpec &SS,
3357 bool *IsCorrectedToColon = nullptr,
3358 bool OnlyNamespace = false);
3359
3360 /// The parser has parsed a nested-name-specifier
3361 /// 'template[opt] template-name < template-args >::'.
3362 ///
3363 /// \param S The scope in which this nested-name-specifier occurs.
3364 ///
3365 /// \param SS The nested-name-specifier, which is both an input
3366 /// parameter (the nested-name-specifier before this type) and an
3367 /// output parameter (containing the full nested-name-specifier,
3368 /// including this new type).
3369 ///
3370 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
3371 /// \param TemplateName the template name.
3372 /// \param TemplateNameLoc The location of the template name.
3373 /// \param LAngleLoc The location of the opening angle bracket ('<').
3374 /// \param TemplateArgs The template arguments.
3375 /// \param RAngleLoc The location of the closing angle bracket ('>').
3376 /// \param CCLoc The location of the '::'.
3377 ///
3378 /// \param EnteringContext Whether we're entering the context of the
3379 /// nested-name-specifier.
3380 ///
3381 ///
3382 /// \returns true if an error occurred, false otherwise.
3384 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
3385 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
3386 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
3387 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
3388
3390 SourceLocation ColonColonLoc);
3391
3393 const DeclSpec &DS,
3394 SourceLocation ColonColonLoc,
3395 QualType Type);
3396
3397 /// IsInvalidUnlessNestedName - This method is used for error recovery
3398 /// purposes to determine whether the specified identifier is only valid as
3399 /// a nested name specifier, for example a namespace name. It is
3400 /// conservatively correct to always return false from this method.
3401 ///
3402 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
3404 NestedNameSpecInfo &IdInfo,
3405 bool EnteringContext);
3406
3407 /// Given a C++ nested-name-specifier, produce an annotation value
3408 /// that the parser can use later to reconstruct the given
3409 /// nested-name-specifier.
3410 ///
3411 /// \param SS A nested-name-specifier.
3412 ///
3413 /// \returns A pointer containing all of the information in the
3414 /// nested-name-specifier \p SS.
3416
3417 /// Given an annotation pointer for a nested-name-specifier, restore
3418 /// the nested-name-specifier structure.
3419 ///
3420 /// \param Annotation The annotation pointer, produced by
3421 /// \c SaveNestedNameSpecifierAnnotation().
3422 ///
3423 /// \param AnnotationRange The source range corresponding to the annotation.
3424 ///
3425 /// \param SS The nested-name-specifier that will be updated with the contents
3426 /// of the annotation pointer.
3427 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
3428 SourceRange AnnotationRange,
3429 CXXScopeSpec &SS);
3430
3431 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
3432
3433 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
3434 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
3435 /// After this method is called, according to [C++ 3.4.3p3], names should be
3436 /// looked up in the declarator-id's scope, until the declarator is parsed and
3437 /// ActOnCXXExitDeclaratorScope is called.
3438 /// The 'SS' should be a non-empty valid CXXScopeSpec.
3440
3441 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
3442 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
3443 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
3444 /// Used to indicate that names should revert to being looked up in the
3445 /// defining scope.
3447
3448 ///@}
3449
3450 //
3451 //
3452 // -------------------------------------------------------------------------
3453 //
3454 //
3455
3456 /// \name Declarations
3457 /// Implementations are in SemaDecl.cpp
3458 ///@{
3459
3460public:
3462
3463 /// The index of the first InventedParameterInfo that refers to the current
3464 /// context.
3466
3467 /// A RAII object to temporarily push a declaration context.
3469 private:
3470 Sema &S;
3471 DeclContext *SavedContext;
3472 ProcessingContextState SavedContextState;
3473 QualType SavedCXXThisTypeOverride;
3474 unsigned SavedFunctionScopesStart;
3475 unsigned SavedInventedParameterInfosStart;
3476
3477 public:
3478 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3479 : S(S), SavedContext(S.CurContext),
3480 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3481 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3482 SavedFunctionScopesStart(S.FunctionScopesStart),
3483 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3484 assert(ContextToPush && "pushing null context");
3485 S.CurContext = ContextToPush;
3486 if (NewThisContext)
3487 S.CXXThisTypeOverride = QualType();
3488 // Any saved FunctionScopes do not refer to this context.
3489 S.FunctionScopesStart = S.FunctionScopes.size();
3490 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3491 }
3492
3493 void pop() {
3494 if (!SavedContext)
3495 return;
3496 S.CurContext = SavedContext;
3497 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3498 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3499 S.FunctionScopesStart = SavedFunctionScopesStart;
3500 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3501 SavedContext = nullptr;
3502 }
3503
3505 };
3506
3507 void DiagnoseInvalidJumps(Stmt *Body);
3508
3509 /// The function definitions which were renamed as part of typo-correction
3510 /// to match their respective declarations. We want to keep track of them
3511 /// to ensure that we don't emit a "redefinition" error if we encounter a
3512 /// correctly named definition after the renamed definition.
3514
3515 /// A cache of the flags available in enumerations with the flag_bits
3516 /// attribute.
3517 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3518
3519 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3520 /// declared. Rare. May alias another identifier, declared or undeclared.
3521 ///
3522 /// For aliases, the target identifier is used as a key for eventual
3523 /// processing when the target is declared. For the single-identifier form,
3524 /// the sole identifier is used as the key. Each entry is a `SetVector`
3525 /// (ordered by parse order) of aliases (identified by the alias name) in case
3526 /// of multiple aliases to the same undeclared identifier.
3527 llvm::MapVector<
3529 llvm::SetVector<
3531 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3533
3534 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3535 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3536 /// to define functions that occur in multiple standards to call the version
3537 /// in the currently selected standard.
3538 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
3539
3540 /// Set containing all typedefs that are likely unused.
3543
3547
3548 /// The set of file scoped decls seen so far that have not been used
3549 /// and must warn if not used. Only contains the first declaration.
3551
3555
3556 /// All the tentative definitions encountered in the TU.
3558
3559 /// All the external declarations encoutered and used in the TU.
3561
3562 /// Generally null except when we temporarily switch decl contexts,
3563 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3565
3566 /// Is the module scope we are in a C++ Header Unit?
3568 return ModuleScopes.empty() ? false
3569 : ModuleScopes.back().Module->isHeaderUnit();
3570 }
3571
3572 /// Get the module owning an entity.
3573 Module *getOwningModule(const Decl *Entity) {
3574 return Entity->getOwningModule();
3575 }
3576
3577 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3578
3580 /// Returns the TypeDeclType for the given type declaration,
3581 /// as ASTContext::getTypeDeclType would, but
3582 /// performs the required semantic checks for name lookup of said entity.
3583 void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD,
3584 SourceLocation NameLoc);
3585
3586 /// If the identifier refers to a type name within this scope,
3587 /// return the declaration of that type.
3588 ///
3589 /// This routine performs ordinary name lookup of the identifier II
3590 /// within the given scope, with optional C++ scope specifier SS, to
3591 /// determine whether the name refers to a type. If so, returns an
3592 /// opaque pointer (actually a QualType) corresponding to that
3593 /// type. Otherwise, returns NULL.
3595 Scope *S, CXXScopeSpec *SS = nullptr,
3596 bool isClassName = false, bool HasTrailingDot = false,
3597 ParsedType ObjectType = nullptr,
3598 bool IsCtorOrDtorName = false,
3599 bool WantNontrivialTypeSourceInfo = false,
3600 bool IsClassTemplateDeductionContext = true,
3601 ImplicitTypenameContext AllowImplicitTypename =
3603 IdentifierInfo **CorrectedII = nullptr);
3604
3605 /// isTagName() - This method is called *for error recovery purposes only*
3606 /// to determine if the specified name is a valid tag name ("struct foo"). If
3607 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3608 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3609 /// diagnose cases in C where the user forgot to specify the tag.
3611
3612 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3613 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3614 /// then downgrade the missing typename error to a warning.
3615 /// This is needed for MSVC compatibility; Example:
3616 /// @code
3617 /// template<class T> class A {
3618 /// public:
3619 /// typedef int TYPE;
3620 /// };
3621 /// template<class T> class B : public A<T> {
3622 /// public:
3623 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3624 /// };
3625 /// @endcode
3626 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3628 Scope *S, CXXScopeSpec *SS,
3629 ParsedType &SuggestedType,
3630 bool IsTemplateName = false);
3631
3632 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3633 /// type name has failed in a dependent context. In these situations, we
3634 /// automatically form a DependentTypeName that will retry lookup in a related
3635 /// scope during instantiation.
3637 SourceLocation NameLoc,
3638 bool IsTemplateTypeArg);
3639
3640 class NameClassification {
3642 union {
3647 };
3648
3649 explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
3650
3651 public:
3654
3657
3658 static NameClassification Error() {
3659 return NameClassification(NameClassificationKind::Error);
3660 }
3661
3662 static NameClassification Unknown() {
3663 return NameClassification(NameClassificationKind::Unknown);
3664 }
3665
3666 static NameClassification OverloadSet(ExprResult E) {
3667 NameClassification Result(NameClassificationKind::OverloadSet);
3668 Result.Expr = E;
3669 return Result;
3670 }
3671
3672 static NameClassification NonType(NamedDecl *D) {
3673 NameClassification Result(NameClassificationKind::NonType);
3674 Result.NonTypeDecl = D;
3675 return Result;
3676 }
3677
3678 static NameClassification UndeclaredNonType() {
3679 return NameClassification(NameClassificationKind::UndeclaredNonType);
3680 }
3681
3682 static NameClassification DependentNonType() {
3683 return NameClassification(NameClassificationKind::DependentNonType);
3684 }
3685
3686 static NameClassification TypeTemplate(TemplateName Name) {
3687 NameClassification Result(NameClassificationKind::TypeTemplate);
3688 Result.Template = Name;
3689 return Result;
3690 }
3691
3692 static NameClassification VarTemplate(TemplateName Name) {
3693 NameClassification Result(NameClassificationKind::VarTemplate);
3694 Result.Template = Name;
3695 return Result;
3696 }
3697
3698 static NameClassification FunctionTemplate(TemplateName Name) {
3700 Result.Template = Name;
3701 return Result;
3702 }
3703
3704 static NameClassification Concept(TemplateName Name) {
3705 NameClassification Result(NameClassificationKind::Concept);
3706 Result.Template = Name;
3707 return Result;
3708 }
3709
3710 static NameClassification UndeclaredTemplate(TemplateName Name) {
3712 Result.Template = Name;
3713 return Result;
3714 }
3715
3716 NameClassificationKind getKind() const { return Kind; }
3717
3720 return Expr;
3721 }
3722
3724 assert(Kind == NameClassificationKind::Type);
3725 return Type;
3726 }
3727
3729 assert(Kind == NameClassificationKind::NonType);
3730 return NonTypeDecl;
3731 }
3732
3741
3743 switch (Kind) {
3745 return TNK_Type_template;
3747 return TNK_Function_template;
3749 return TNK_Var_template;
3751 return TNK_Concept_template;
3754 default:
3755 llvm_unreachable("unsupported name classification.");
3756 }
3757 }
3758 };
3759
3760 /// Perform name lookup on the given name, classifying it based on
3761 /// the results of name lookup and the following token.
3762 ///
3763 /// This routine is used by the parser to resolve identifiers and help direct
3764 /// parsing. When the identifier cannot be found, this routine will attempt
3765 /// to correct the typo and classify based on the resulting name.
3766 ///
3767 /// \param S The scope in which we're performing name lookup.
3768 ///
3769 /// \param SS The nested-name-specifier that precedes the name.
3770 ///
3771 /// \param Name The identifier. If typo correction finds an alternative name,
3772 /// this pointer parameter will be updated accordingly.
3773 ///
3774 /// \param NameLoc The location of the identifier.
3775 ///
3776 /// \param NextToken The token following the identifier. Used to help
3777 /// disambiguate the name.
3778 ///
3779 /// \param CCC The correction callback, if typo correction is desired.
3780 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3781 IdentifierInfo *&Name, SourceLocation NameLoc,
3782 const Token &NextToken,
3783 CorrectionCandidateCallback *CCC = nullptr);
3784
3785 /// Act on the result of classifying a name as an undeclared (ADL-only)
3786 /// non-type declaration.
3788 SourceLocation NameLoc);
3789 /// Act on the result of classifying a name as an undeclared member of a
3790 /// dependent base class.
3792 IdentifierInfo *Name,
3793 SourceLocation NameLoc,
3794 bool IsAddressOfOperand);
3795 /// Act on the result of classifying a name as a specific non-type
3796 /// declaration.
3799 SourceLocation NameLoc,
3800 const Token &NextToken);
3801 /// Act on the result of classifying a name as an overload set.
3803
3804 /// Describes the detailed kind of a template name. Used in diagnostics.
3816
3817 /// Determine whether it's plausible that E was intended to be a
3818 /// template-name.
3820 if (!getLangOpts().CPlusPlus || E.isInvalid())
3821 return false;
3822 Dependent = false;
3823 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3824 return !DRE->hasExplicitTemplateArgs();
3825 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3826 return !ME->hasExplicitTemplateArgs();
3827 Dependent = true;
3828 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3829 return !DSDRE->hasExplicitTemplateArgs();
3830 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3831 return !DSME->hasExplicitTemplateArgs();
3832 // Any additional cases recognized here should also be handled by
3833 // diagnoseExprIntendedAsTemplateName.
3834 return false;
3835 }
3836
3837 void warnOnReservedIdentifier(const NamedDecl *D);
3839
3841
3843 MultiTemplateParamsArg TemplateParameterLists);
3844
3845 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3846 /// true if we were successful.
3848 SourceLocation Loc,
3849 unsigned FailedFoldDiagID);
3850
3851 /// Register the given locally-scoped extern "C" declaration so
3852 /// that it can be found later for redeclarations. We include any extern "C"
3853 /// declaration that is not visible in the translation unit here, not just
3854 /// function-scope declarations.
3856
3857 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3858 /// If T is the name of a class, then each of the following shall have a
3859 /// name different from T:
3860 /// - every static data member of class T;
3861 /// - every member function of class T
3862 /// - every member of class T that is itself a type;
3863 /// \returns true if the declaration name violates these rules.
3865
3866 /// Diagnose a declaration whose declarator-id has the given
3867 /// nested-name-specifier.
3868 ///
3869 /// \param SS The nested-name-specifier of the declarator-id.
3870 ///
3871 /// \param DC The declaration context to which the nested-name-specifier
3872 /// resolves.
3873 ///
3874 /// \param Name The name of the entity being declared.
3875 ///
3876 /// \param Loc The location of the name of the entity being declared.
3877 ///
3878 /// \param IsMemberSpecialization Whether we are declaring a member
3879 /// specialization.
3880 ///
3881 /// \param TemplateId The template-id, if any.
3882 ///
3883 /// \returns true if we cannot safely recover from this error, false
3884 /// otherwise.
3887 TemplateIdAnnotation *TemplateId,
3888 bool IsMemberSpecialization);
3889
3891
3892 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
3893
3895 unsigned &IntVal);
3896
3897 /// Diagnose function specifiers on a declaration of an identifier that
3898 /// does not identify a function.
3899 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
3900
3901 /// Return the declaration shadowed by the given typedef \p D, or null
3902 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3904 const LookupResult &R);
3905
3906 /// Return the declaration shadowed by the given variable \p D, or null
3907 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3909
3910 /// Return the declaration shadowed by the given variable \p D, or null
3911 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3913 const LookupResult &R);
3914 /// Diagnose variable or built-in function shadowing. Implements
3915 /// -Wshadow.
3916 ///
3917 /// This method is called whenever a VarDecl is added to a "useful"
3918 /// scope.
3919 ///
3920 /// \param ShadowedDecl the declaration that is shadowed by the given variable
3921 /// \param R the lookup of the name
3922 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
3923 const LookupResult &R);
3924
3925 /// Check -Wshadow without the advantage of a previous lookup.
3926 void CheckShadow(Scope *S, VarDecl *D);
3927
3928 /// Warn if 'E', which is an expression that is about to be modified, refers
3929 /// to a shadowing declaration.
3931
3932 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
3933 /// when these variables are captured by the lambda.
3935
3936 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
3937 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
3938 TypedefNameDecl *NewTD);
3941 TypeSourceInfo *TInfo,
3943
3944 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
3945 /// declares a typedef-name, either using the 'typedef' type specifier or via
3946 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
3950 TypeSourceInfo *TInfo,
3952 MultiTemplateParamsArg TemplateParamLists,
3953 bool &AddToScope,
3955
3956private:
3957 // Perform a check on an AsmLabel to verify its consistency and emit
3958 // diagnostics in case of an error.
3959 void CheckAsmLabel(Scope *S, Expr *AsmLabelExpr, StorageClass SC,
3960 TypeSourceInfo *TInfo, VarDecl *);
3961
3962public:
3963 /// Perform semantic checking on a newly-created variable
3964 /// declaration.
3965 ///
3966 /// This routine performs all of the type-checking required for a
3967 /// variable declaration once it has been built. It is used both to
3968 /// check variables after they have been parsed and their declarators
3969 /// have been translated into a declaration, and to check variables
3970 /// that have been instantiated from a template.
3971 ///
3972 /// Sets NewVD->isInvalidDecl() if an error was encountered.
3973 ///
3974 /// Returns true if the variable declaration is a redeclaration.
3975 bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
3976 void CheckVariableDeclarationType(VarDecl *NewVD);
3977 void CheckCompleteVariableDeclaration(VarDecl *VD);
3978
3979 NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
3980 TypeSourceInfo *TInfo,
3981 LookupResult &Previous,
3982 MultiTemplateParamsArg TemplateParamLists,
3983 bool &AddToScope);
3984
3985 /// AddOverriddenMethods - See if a method overrides any in the base classes,
3986 /// and if so, check that it's a valid override and remember it.
3987 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
3988
3989 /// Perform semantic checking of a new function declaration.
3990 ///
3991 /// Performs semantic analysis of the new function declaration
3992 /// NewFD. This routine performs all semantic checking that does not
3993 /// require the actual declarator involved in the declaration, and is
3994 /// used both for the declaration of functions as they are parsed
3995 /// (called via ActOnDeclarator) and for the declaration of functions
3996 /// that have been instantiated via C++ template instantiation (called
3997 /// via InstantiateDecl).
3998 ///
3999 /// \param IsMemberSpecialization whether this new function declaration is
4000 /// a member specialization (that replaces any definition provided by the
4001 /// previous declaration).
4002 ///
4003 /// This sets NewFD->isInvalidDecl() to true if there was an error.
4004 ///
4005 /// \returns true if the function declaration is a redeclaration.
4006 bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
4007 LookupResult &Previous,
4008 bool IsMemberSpecialization, bool DeclIsDefn);
4009
4010 /// Checks if the new declaration declared in dependent context must be
4011 /// put in the same redeclaration chain as the specified declaration.
4012 ///
4013 /// \param D Declaration that is checked.
4014 /// \param PrevDecl Previous declaration found with proper lookup method for
4015 /// the same declaration name.
4016 /// \returns True if D must be added to the redeclaration chain which PrevDecl
4017 /// belongs to.
4018 bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
4019
4020 /// Determines if we can perform a correct type check for \p D as a
4021 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
4022 /// best-effort check.
4023 ///
4024 /// \param NewD The new declaration.
4025 /// \param OldD The old declaration.
4026 /// \param NewT The portion of the type of the new declaration to check.
4027 /// \param OldT The portion of the type of the old declaration to check.
4028 bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
4029 QualType NewT, QualType OldT);
4030 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
4031 void CheckMSVCRTEntryPoint(FunctionDecl *FD);
4032
4033 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
4034 /// containing class. Otherwise it will return implicit SectionAttr if the
4035 /// function is a definition and there is an active value on CodeSegStack
4036 /// (from the current #pragma code-seg value).
4037 ///
4038 /// \param FD Function being declared.
4039 /// \param IsDefinition Whether it is a definition or just a declaration.
4040 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
4041 /// nullptr if no attribute should be added.
4042 Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
4043 bool IsDefinition);
4044
4045 /// Common checks for a parameter-declaration that should apply to both
4046 /// function parameters and non-type template parameters.
4047 void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
4048
4049 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
4050 /// to introduce parameters into function prototype scope.
4051 Decl *ActOnParamDeclarator(Scope *S, Declarator &D,
4052 SourceLocation ExplicitThisLoc = {});
4053
4054 /// Synthesizes a variable for a parameter arising from a
4055 /// typedef.
4056 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
4057 QualType T);
4058 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
4059 SourceLocation NameLoc,
4060 const IdentifierInfo *Name, QualType T,
4061 TypeSourceInfo *TSInfo, StorageClass SC);
4062
4063 /// Emit diagnostics if the initializer or any of its explicit or
4064 /// implicitly-generated subexpressions require copying or
4065 /// default-initializing a type that is or contains a C union type that is
4066 /// non-trivial to copy or default-initialize.
4067 void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc);
4068
4069 // These flags are passed to checkNonTrivialCUnion.
4075
4076 /// Emit diagnostics if a non-trivial C union type or a struct that contains
4077 /// a non-trivial C union is used in an invalid context.
4079 NonTrivialCUnionContext UseContext,
4080 unsigned NonTrivialKind);
4081
4082 /// Certain globally-unique variables might be accidentally duplicated if
4083 /// built into multiple shared libraries with hidden visibility. This can
4084 /// cause problems if the variable is mutable, its initialization is
4085 /// effectful, or its address is taken.
4088
4089 /// AddInitializerToDecl - Adds the initializer Init to the
4090 /// declaration dcl. If DirectInit is true, this is C++ direct
4091 /// initialization rather than copy initialization.
4092 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
4093 void ActOnUninitializedDecl(Decl *dcl);
4094
4095 /// ActOnInitializerError - Given that there was an error parsing an
4096 /// initializer for the given declaration, try to at least re-establish
4097 /// invariants such as whether a variable's type is either dependent or
4098 /// complete.
4099 void ActOnInitializerError(Decl *Dcl);
4100
4101 void ActOnCXXForRangeDecl(Decl *D);
4103 IdentifierInfo *Ident,
4104 ParsedAttributes &Attrs);
4105
4106 /// Check if VD needs to be dllexport/dllimport due to being in a
4107 /// dllexport/import function.
4110
4111 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
4112 /// any semantic actions necessary after any initializer has been attached.
4113 void FinalizeDeclaration(Decl *D);
4115 ArrayRef<Decl *> Group);
4116
4117 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
4118 /// group, performing any necessary semantic checking.
4120
4121 /// Should be called on all declarations that might have attached
4122 /// documentation comments.
4123 void ActOnDocumentableDecl(Decl *D);
4125
4126 enum class FnBodyKind {
4127 /// C++26 [dcl.fct.def.general]p1
4128 /// function-body:
4129 /// ctor-initializer[opt] compound-statement
4130 /// function-try-block
4132 /// = default ;
4134 /// deleted-function-body
4135 ///
4136 /// deleted-function-body:
4137 /// = delete ;
4138 /// = delete ( unevaluated-string ) ;
4140 };
4141
4143 SourceLocation LocAfterDecls);
4145 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
4146 SkipBodyInfo *SkipBody = nullptr);
4148 MultiTemplateParamsArg TemplateParamLists,
4149 SkipBodyInfo *SkipBody = nullptr,
4150 FnBodyKind BodyKind = FnBodyKind::Other);
4152 SkipBodyInfo *SkipBody = nullptr,
4153 FnBodyKind BodyKind = FnBodyKind::Other);
4155
4156 /// Determine whether we can delay parsing the body of a function or
4157 /// function template until it is used, assuming we don't care about emitting
4158 /// code for that function.
4159 ///
4160 /// This will be \c false if we may need the body of the function in the
4161 /// middle of parsing an expression (where it's impractical to switch to
4162 /// parsing a different function), for instance, if it's constexpr in C++11
4163 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
4164 bool canDelayFunctionBody(const Declarator &D);
4165
4166 /// Determine whether we can skip parsing the body of a function
4167 /// definition, assuming we don't care about analyzing its body or emitting
4168 /// code for that function.
4169 ///
4170 /// This will be \c false only if we may need the body of the function in
4171 /// order to parse the rest of the program (for instance, if it is
4172 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
4173 bool canSkipFunctionBody(Decl *D);
4174
4175 /// Given the set of return statements within a function body,
4176 /// compute the variables that are subject to the named return value
4177 /// optimization.
4178 ///
4179 /// Each of the variables that is subject to the named return value
4180 /// optimization will be marked as NRVO variables in the AST, and any
4181 /// return statement that has a marked NRVO variable as its NRVO candidate can
4182 /// use the named return value optimization.
4183 ///
4184 /// This function applies a very simplistic algorithm for NRVO: if every
4185 /// return statement in the scope of a variable has the same NRVO candidate,
4186 /// that candidate is an NRVO variable.
4188
4189 /// Performs semantic analysis at the end of a function body.
4190 ///
4191 /// \param RetainFunctionScopeInfo If \c true, the client is responsible for
4192 /// releasing the associated \p FunctionScopeInfo. This is useful when
4193 /// building e.g. LambdaExprs.
4195 bool IsInstantiation = false,
4196 bool RetainFunctionScopeInfo = false);
4199
4200 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
4201 /// attribute for which parsing is delayed.
4203
4204 /// Diagnose any unused parameters in the given sequence of
4205 /// ParmVarDecl pointers.
4207
4208 /// Diagnose whether the size of parameters or return value of a
4209 /// function or obj-c method definition is pass-by-value and larger than a
4210 /// specified threshold.
4211 void
4213 QualType ReturnTy, NamedDecl *D);
4214
4216 SourceLocation RParenLoc);
4217
4220
4221 void ActOnPopScope(SourceLocation Loc, Scope *S);
4222
4223 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4224 /// no declarator (e.g. "struct foo;") is parsed.
4226 const ParsedAttributesView &DeclAttrs,
4227 RecordDecl *&AnonRecord);
4228
4229 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4230 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
4231 /// parameters to cope with template friend declarations.
4233 const ParsedAttributesView &DeclAttrs,
4234 MultiTemplateParamsArg TemplateParams,
4235 bool IsExplicitInstantiation,
4236 RecordDecl *&AnonRecord,
4237 SourceLocation EllipsisLoc = {});
4238
4239 /// BuildAnonymousStructOrUnion - Handle the declaration of an
4240 /// anonymous structure or union. Anonymous unions are a C++ feature
4241 /// (C++ [class.union]) and a C11 feature; anonymous structures
4242 /// are a C11 feature and GNU C++ extension.
4243 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
4244 RecordDecl *Record,
4245 const PrintingPolicy &Policy);
4246
4247 /// Called once it is known whether
4248 /// a tag declaration is an anonymous union or struct.
4250
4251 /// Emit diagnostic warnings for placeholder members.
4252 /// We can only do that after the class is fully constructed,
4253 /// as anonymous union/structs can insert placeholders
4254 /// in their parent scope (which might be a Record).
4256
4257 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
4258 /// Microsoft C anonymous structure.
4259 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
4260 /// Example:
4261 ///
4262 /// struct A { int a; };
4263 /// struct B { struct A; int b; };
4264 ///
4265 /// void foo() {
4266 /// B var;
4267 /// var.a = 3;
4268 /// }
4269 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
4270 RecordDecl *Record);
4271
4272 /// Given a non-tag type declaration, returns an enum useful for indicating
4273 /// what kind of non-tag type this is.
4274 NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
4275
4276 /// Determine whether a tag with a given kind is acceptable
4277 /// as a redeclaration of the given tag declaration.
4278 ///
4279 /// \returns true if the new tag kind is acceptable, false otherwise.
4281 bool isDefinition, SourceLocation NewTagLoc,
4282 const IdentifierInfo *Name);
4283
4284 /// This is invoked when we see 'struct foo' or 'struct {'. In the
4285 /// former case, Name will be non-null. In the later case, Name will be null.
4286 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
4287 /// a reference/declaration/definition of a tag.
4288 ///
4289 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
4290 /// trailing-type-specifier) other than one in an alias-declaration.
4291 ///
4292 /// \param SkipBody If non-null, will be set to indicate if the caller should
4293 /// skip the definition of this tag and treat it as if it were a declaration.
4294 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
4295 SourceLocation KWLoc, CXXScopeSpec &SS,
4296 IdentifierInfo *Name, SourceLocation NameLoc,
4297 const ParsedAttributesView &Attr, AccessSpecifier AS,
4298 SourceLocation ModulePrivateLoc,
4299 MultiTemplateParamsArg TemplateParameterLists,
4300 bool &OwnedDecl, bool &IsDependent,
4301 SourceLocation ScopedEnumKWLoc,
4302 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
4303 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
4304 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
4305
4306 /// ActOnField - Each field of a C struct/union is passed into this in order
4307 /// to create a FieldDecl object for it.
4308 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
4309 Declarator &D, Expr *BitfieldWidth);
4310
4311 /// HandleField - Analyze a field of a C struct or a C++ data member.
4312 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
4313 Declarator &D, Expr *BitfieldWidth,
4314 InClassInitStyle InitStyle, AccessSpecifier AS);
4315
4316 /// Build a new FieldDecl and check its well-formedness.
4317 ///
4318 /// This routine builds a new FieldDecl given the fields name, type,
4319 /// record, etc. \p PrevDecl should refer to any previous declaration
4320 /// with the same name and in the same scope as the field to be
4321 /// created.
4322 ///
4323 /// \returns a new FieldDecl.
4324 ///
4325 /// \todo The Declarator argument is a hack. It will be removed once
4326 FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
4327 TypeSourceInfo *TInfo, RecordDecl *Record,
4328 SourceLocation Loc, bool Mutable,
4329 Expr *BitfieldWidth, InClassInitStyle InitStyle,
4330 SourceLocation TSSL, AccessSpecifier AS,
4331 NamedDecl *PrevDecl, Declarator *D = nullptr);
4332
4334
4335 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
4336 /// class and class extensions. For every class \@interface and class
4337 /// extension \@interface, if the last ivar is a bitfield of any type,
4338 /// then add an implicit `char :0` ivar to the end of that interface.
4339 void ActOnLastBitfield(SourceLocation DeclStart,
4340 SmallVectorImpl<Decl *> &AllIvarDecls);
4341
4342 // This is used for both record definitions and ObjC interface declarations.
4343 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
4344 ArrayRef<Decl *> Fields, SourceLocation LBrac,
4345 SourceLocation RBrac, const ParsedAttributesView &AttrList);
4346
4347 /// ActOnTagStartDefinition - Invoked when we have entered the
4348 /// scope of a tag's definition (e.g., for an enumeration, class,
4349 /// struct, or union).
4350 void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
4351
4352 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
4353 /// Differently from C++, actually parse the body and reject / error out
4354 /// in case of a structural mismatch.
4355 bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody);
4356
4358
4359 /// Invoked when we enter a tag definition that we're skipping.
4361
4362 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
4363 /// C++ record definition's base-specifiers clause and are starting its
4364 /// member declarations.
4366 SourceLocation FinalLoc,
4367 bool IsFinalSpelledSealed,
4368 bool IsAbstract,
4369 SourceLocation TriviallyRelocatable,
4370 SourceLocation LBraceLoc);
4371
4372 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
4373 /// the definition of a tag (enumeration, class, struct, or union).
4375 SourceRange BraceRange);
4376
4379
4381
4382 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
4383 /// error parsing the definition of a tag.
4385
4387 EnumConstantDecl *LastEnumConst,
4388 SourceLocation IdLoc, IdentifierInfo *Id,
4389 Expr *val);
4390
4391 /// Check that this is a valid underlying type for an enum declaration.
4393
4394 /// Check whether this is a valid redeclaration of a previous enumeration.
4395 /// \return true if the redeclaration was invalid.
4396 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
4397 QualType EnumUnderlyingTy, bool IsFixed,
4398 const EnumDecl *Prev);
4399
4400 /// Determine whether the body of an anonymous enumeration should be skipped.
4401 /// \param II The name of the first enumerator.
4403 SourceLocation IILoc);
4404
4405 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
4406 SourceLocation IdLoc, IdentifierInfo *Id,
4407 const ParsedAttributesView &Attrs,
4408 SourceLocation EqualLoc, Expr *Val,
4409 SkipBodyInfo *SkipBody = nullptr);
4410 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
4411 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
4412 const ParsedAttributesView &Attr);
4413
4414 /// Set the current declaration context until it gets popped.
4415 void PushDeclContext(Scope *S, DeclContext *DC);
4416 void PopDeclContext();
4417
4418 /// EnterDeclaratorContext - Used when we must lookup names in the context
4419 /// of a declarator's nested name specifier.
4422
4423 /// Enter a template parameter scope, after it's been associated with a
4424 /// particular DeclContext. Causes lookup within the scope to chain through
4425 /// enclosing contexts in the correct order.
4427
4428 /// Push the parameters of D, which must be a function, into scope.
4431
4432 /// Add this decl to the scope shadowed decl chains.
4433 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4434
4435 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4436 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4437 /// true if 'D' belongs to the given declaration context.
4438 ///
4439 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4440 /// enclosing namespace set of the context, rather than contained
4441 /// directly within it.
4442 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4443 bool AllowInlineNamespace = false) const;
4444
4445 /// Finds the scope corresponding to the given decl context, if it
4446 /// happens to be an enclosing scope. Otherwise return NULL.
4448
4449 /// Subroutines of ActOnDeclarator().
4451 TypeSourceInfo *TInfo);
4453
4454 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4456 NamedDecl *New, Decl *Old,
4458
4459 /// CheckAttributesOnDeducedType - Calls Sema functions for attributes that
4460 /// requires the type to be deduced.
4462
4463 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4464 /// same name and scope as a previous declaration 'Old'. Figure out
4465 /// how to resolve this situation, merging decls or emitting
4466 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4468 LookupResult &OldDecls);
4469
4470 /// CleanupMergedEnum - We have just merged the decl 'New' by making another
4471 /// definition visible.
4472 /// This method performs any necessary cleanup on the parser state to discard
4473 /// child nodes from newly parsed decl we are retiring.
4474 void CleanupMergedEnum(Scope *S, Decl *New);
4475
4476 /// MergeFunctionDecl - We just parsed a function 'New' from
4477 /// declarator D which has the same name and scope as a previous
4478 /// declaration 'Old'. Figure out how to resolve this situation,
4479 /// merging decls or emitting diagnostics as appropriate.
4480 ///
4481 /// In C++, New and Old must be declarations that are not
4482 /// overloaded. Use IsOverload to determine whether New and Old are
4483 /// overloaded, and to select the Old declaration that New should be
4484 /// merged with.
4485 ///
4486 /// Returns true if there was an error, false otherwise.
4488 bool MergeTypeWithOld, bool NewDeclIsDefn);
4489
4490 /// Completes the merge of two function declarations that are
4491 /// known to be compatible.
4492 ///
4493 /// This routine handles the merging of attributes and other
4494 /// properties of function declarations from the old declaration to
4495 /// the new declaration, once we know that New is in fact a
4496 /// redeclaration of Old.
4497 ///
4498 /// \returns false
4500 Scope *S, bool MergeTypeWithOld);
4502
4503 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4504 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4505 /// situation, merging decls or emitting diagnostics as appropriate.
4506 ///
4507 /// Tentative definition rules (C99 6.9.2p2) are checked by
4508 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4509 /// definitions here, since the initializer hasn't been attached.
4511
4512 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4513 /// scope as a previous declaration 'Old'. Figure out how to merge their
4514 /// types, emitting diagnostics as appropriate.
4515 ///
4516 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4517 /// back to here in AddInitializerToDecl. We can't check them before the
4518 /// initializer is attached.
4519 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4520
4521 /// We've just determined that \p Old and \p New both appear to be definitions
4522 /// of the same variable. Either diagnose or fix the problem.
4523 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4525
4526 /// Filters out lookup results that don't fall within the given scope
4527 /// as determined by isDeclInScope.
4529 bool ConsiderLinkage, bool AllowInlineNamespace);
4530
4531 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4532 /// have compatible owning modules.
4534
4535 /// [module.interface]p6:
4536 /// A redeclaration of an entity X is implicitly exported if X was introduced
4537 /// by an exported declaration; otherwise it shall not be exported.
4539
4540 /// A wrapper function for checking the semantic restrictions of
4541 /// a redeclaration within a module.
4543
4544 /// Check the redefinition in C++20 Modules.
4545 ///
4546 /// [basic.def.odr]p14:
4547 /// For any definable item D with definitions in multiple translation units,
4548 /// - if D is a non-inline non-templated function or variable, or
4549 /// - if the definitions in different translation units do not satisfy the
4550 /// following requirements,
4551 /// the program is ill-formed; a diagnostic is required only if the
4552 /// definable item is attached to a named module and a prior definition is
4553 /// reachable at the point where a later definition occurs.
4554 /// - Each such definition shall not be attached to a named module
4555 /// ([module.unit]).
4556 /// - Each such definition shall consist of the same sequence of tokens, ...
4557 /// ...
4558 ///
4559 /// Return true if the redefinition is not allowed. Return false otherwise.
4560 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4561
4563
4564 /// If it's a file scoped decl that must warn if not used, keep track
4565 /// of it.
4567
4568 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4570
4573 DiagReceiverTy DiagReceiver);
4574 void DiagnoseUnusedDecl(const NamedDecl *ND);
4575
4576 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4577 /// unless they are marked attr(unused).
4578 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4579
4580 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4581 /// variable.
4582 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4583
4584 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4585 /// from S, where a non-field would be declared. This routine copes
4586 /// with the difference between C and C++ scoping rules in structs and
4587 /// unions. For example, the following code is well-formed in C but
4588 /// ill-formed in C++:
4589 /// @code
4590 /// struct S6 {
4591 /// enum { BAR } e;
4592 /// };
4593 ///
4594 /// void test_S6() {
4595 /// struct S6 a;
4596 /// a.e = BAR;
4597 /// }
4598 /// @endcode
4599 /// For the declaration of BAR, this routine will return a different
4600 /// scope. The scope S will be the scope of the unnamed enumeration
4601 /// within S6. In C++, this routine will return the scope associated
4602 /// with S6, because the enumeration's scope is a transparent
4603 /// context but structures can contain non-field names. In C, this
4604 /// routine will return the translation unit scope, since the
4605 /// enumeration's scope is a transparent context and structures cannot
4606 /// contain non-field names.
4608
4610 SourceLocation Loc);
4611
4612 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4613 /// file scope. lazily create a decl for it. ForRedeclaration is true
4614 /// if we're creating this built-in in anticipation of redeclaring the
4615 /// built-in.
4616 NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S,
4617 bool ForRedeclaration, SourceLocation Loc);
4618
4619 /// Get the outermost AttributedType node that sets a calling convention.
4620 /// Valid types should not have multiple attributes with different CCs.
4621 const AttributedType *getCallingConvAttributedType(QualType T) const;
4622
4623 /// GetNameForDeclarator - Determine the full declaration name for the
4624 /// given Declarator.
4626
4627 /// Retrieves the declaration name from a parsed unqualified-id.
4629
4630 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4631 /// we are currently parsing the initializer.
4633
4634 /// Look for a locally scoped extern "C" declaration by the given name.
4636
4639
4640 /// Adjust the \c DeclContext for a function or variable that might be a
4641 /// function-local external declaration.
4643
4645
4646 /// Checks if the variant/multiversion functions are compatible.
4648 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4649 const PartialDiagnostic &NoProtoDiagID,
4650 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4651 const PartialDiagnosticAt &NoSupportDiagIDAt,
4652 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4653 bool ConstexprSupported, bool CLinkageMayDiffer);
4654
4655 /// type checking declaration initializers (C99 6.7.8)
4657 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4658
4661 SourceRange Range, bool DirectInit,
4662 Expr *Init);
4663
4665 Expr *Init);
4666
4668
4669 // Heuristically tells if the function is `get_return_object` member of a
4670 // coroutine promise_type by matching the function name.
4671 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4672 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4673
4674 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4675 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4677 Scope *S);
4678
4679 /// If this function is a C++ replaceable global allocation function
4680 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4681 /// adds any function attributes that we know a priori based on the standard.
4682 ///
4683 /// We need to check for duplicate attributes both here and where user-written
4684 /// attributes are applied to declarations.
4686 FunctionDecl *FD);
4687
4688 /// Adds any function attributes that we know a priori based on
4689 /// the declaration of this function.
4690 ///
4691 /// These attributes can apply both to implicitly-declared builtins
4692 /// (like __builtin___printf_chk) or to library-declared functions
4693 /// like NSLog or printf.
4694 ///
4695 /// We need to check for duplicate attributes both here and where user-written
4696 /// attributes are applied to declarations.
4698
4699 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4700 /// the correct width, and that the field type is valid.
4701 /// Returns false on success.
4703 const IdentifierInfo *FieldName, QualType FieldTy,
4704 bool IsMsStruct, Expr *BitWidth);
4705
4706 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4707 /// enum. If AllowMask is true, then we also allow the complement of a valid
4708 /// value, to be used as a mask.
4709 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4710 bool AllowMask) const;
4711
4712 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4713 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4714 SourceLocation WeakNameLoc);
4715
4716 /// ActOnPragmaRedefineExtname - Called on well formed
4717 /// \#pragma redefine_extname oldname newname.
4719 IdentifierInfo *AliasName,
4720 SourceLocation PragmaLoc,
4721 SourceLocation WeakNameLoc,
4722 SourceLocation AliasNameLoc);
4723
4724 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4725 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4726 SourceLocation PragmaLoc,
4727 SourceLocation WeakNameLoc,
4728 SourceLocation AliasNameLoc);
4729
4730 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4733 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4734 OMPDiscarded, // Discarded due to OpenMP hostness
4735 TemplateDiscarded, // Discarded due to uninstantiated templates
4737 };
4738 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4739 bool Final = false);
4740
4741 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4743
4744 /// Function or variable declarations to be checked for whether the deferred
4745 /// diagnostics should be emitted.
4747
4748private:
4749 /// Map of current shadowing declarations to shadowed declarations. Warn if
4750 /// it looks like the user is trying to modify the shadowing declaration.
4751 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4752
4753 // We need this to handle
4754 //
4755 // typedef struct {
4756 // void *foo() { return 0; }
4757 // } A;
4758 //
4759 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4760 // for example. If 'A', foo will have external linkage. If we have '*A',
4761 // foo will have no linkage. Since we can't know until we get to the end
4762 // of the typedef, this function finds out if D might have non-external
4763 // linkage. Callers should verify at the end of the TU if it D has external
4764 // linkage or not.
4765 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4766
4767#include "clang/Sema/AttrIsTypeDependent.inc"
4768
4769 ///@}
4770
4771 //
4772 //
4773 // -------------------------------------------------------------------------
4774 //
4775 //
4776
4777 /// \name Declaration Attribute Handling
4778 /// Implementations are in SemaDeclAttr.cpp
4779 ///@{
4780
4781public:
4782 /// Describes the kind of priority given to an availability attribute.
4783 ///
4784 /// The sum of priorities deteremines the final priority of the attribute.
4785 /// The final priority determines how the attribute will be merged.
4786 /// An attribute with a lower priority will always remove higher priority
4787 /// attributes for the specified platform when it is being applied. An
4788 /// attribute with a higher priority will not be applied if the declaration
4789 /// already has an availability attribute with a lower priority for the
4790 /// specified platform. The final prirority values are not expected to match
4791 /// the values in this enumeration, but instead should be treated as a plain
4792 /// integer value. This enumeration just names the priority weights that are
4793 /// used to calculate that final vaue.
4795 /// The availability attribute was specified explicitly next to the
4796 /// declaration.
4798
4799 /// The availability attribute was applied using '#pragma clang attribute'.
4801
4802 /// The availability attribute for a specific platform was inferred from
4803 /// an availability attribute for another platform.
4805 };
4806
4807 /// Describes the reason a calling convention specification was ignored, used
4808 /// for diagnostics.
4815
4816 /// A helper function to provide Attribute Location for the Attr types
4817 /// AND the ParsedAttr.
4818 template <typename AttrInfo>
4819 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4820 getAttrLoc(const AttrInfo &AL) {
4821 return AL.getLocation();
4822 }
4824
4825 /// If Expr is a valid integer constant, get the value of the integer
4826 /// expression and return success or failure. May output an error.
4827 ///
4828 /// Negative argument is implicitly converted to unsigned, unless
4829 /// \p StrictlyUnsigned is true.
4830 template <typename AttrInfo>
4831 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4832 unsigned Idx = UINT_MAX,
4833 bool StrictlyUnsigned = false) {
4834 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4835 if (Expr->isTypeDependent() ||
4837 if (Idx != UINT_MAX)
4838 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4839 << &AI << Idx << AANT_ArgumentIntegerConstant
4840 << Expr->getSourceRange();
4841 else
4842 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4844 return false;
4845 }
4846
4847 if (!I->isIntN(32)) {
4848 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4849 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4850 return false;
4851 }
4852
4853 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
4854 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
4855 << &AI << /*non-negative*/ 1;
4856 return false;
4857 }
4858
4859 Val = (uint32_t)I->getZExtValue();
4860 return true;
4861 }
4862
4863 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
4864 /// \#pragma weak during processing of other Decls.
4865 /// I couldn't figure out a clean way to generate these in-line, so
4866 /// we store them here and handle separately -- which is a hack.
4867 /// It would be best to refactor this.
4869
4870 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
4872
4876
4877 /// ExtVectorDecls - This is a list all the extended vector types. This allows
4878 /// us to associate a raw vector type with one of the ext_vector type names.
4879 /// This is only necessary for issuing pretty diagnostics.
4881
4882 /// Check if the argument \p E is a ASCII string literal. If not emit an error
4883 /// and return false, otherwise set \p Str to the value of the string literal
4884 /// and return true.
4886 const Expr *E, StringRef &Str,
4887 SourceLocation *ArgLocation = nullptr);
4888
4889 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
4890 /// If not emit an error and return false. If the argument is an identifier it
4891 /// will emit an error with a fixit hint and treat it as if it was a string
4892 /// literal.
4893 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
4894 StringRef &Str,
4895 SourceLocation *ArgLocation = nullptr);
4896
4897 /// Determine if type T is a valid subject for a nonnull and similar
4898 /// attributes. Dependent types are considered valid so they can be checked
4899 /// during instantiation time. By default, we look through references (the
4900 /// behavior used by nonnull), but if the second parameter is true, then we
4901 /// treat a reference type as valid.
4902 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
4903
4904 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
4905 /// declaration.
4906 void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4907 Expr *OE);
4908
4909 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
4910 /// declaration.
4911 void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
4912 Expr *ParamExpr);
4913
4914 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
4915 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
4916
4917 AvailabilityAttr *mergeAvailabilityAttr(
4918 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform,
4919 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
4920 VersionTuple Obsoleted, bool IsUnavailable, StringRef Message,
4921 bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK,
4922 int Priority, IdentifierInfo *IIEnvironment);
4923
4924 TypeVisibilityAttr *
4926 TypeVisibilityAttr::VisibilityType Vis);
4927 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
4928 VisibilityAttr::VisibilityType Vis);
4929 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
4930 StringRef Name);
4931
4932 /// Used to implement to perform semantic checking on
4933 /// attribute((section("foo"))) specifiers.
4934 ///
4935 /// In this case, "foo" is passed in to be checked. If the section
4936 /// specifier is invalid, return an Error that indicates the problem.
4937 ///
4938 /// This is a simple quality of implementation feature to catch errors
4939 /// and give good diagnostics in cases when the assembler or code generator
4940 /// would otherwise reject the section specifier.
4941 llvm::Error isValidSectionSpecifier(StringRef Str);
4942 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
4943 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
4944 StringRef Name);
4945
4946 // Check for things we'd like to warn about. Multiversioning issues are
4947 // handled later in the process, once we know how many exist.
4948 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
4949
4950 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
4951 StringRef NewUserDiagnostic);
4952 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
4953 IdentifierInfo *Format, int FormatIdx,
4954 int FirstArg);
4955 FormatMatchesAttr *mergeFormatMatchesAttr(Decl *D,
4956 const AttributeCommonInfo &CI,
4957 IdentifierInfo *Format,
4958 int FormatIdx,
4959 StringLiteral *FormatStr);
4960 ModularFormatAttr *mergeModularFormatAttr(Decl *D,
4961 const AttributeCommonInfo &CI,
4962 IdentifierInfo *ModularImplFn,
4963 StringRef ImplName,
4965
4966 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4967 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4968 bool IsPackExpansion);
4970 bool IsPackExpansion);
4971
4972 /// AddAlignValueAttr - Adds an align_value attribute to a particular
4973 /// declaration.
4974 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
4975
4976 /// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
4977 Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
4980
4982 bool BestCase,
4983 MSInheritanceModel SemanticSpelling);
4984
4986
4987 /// AddModeAttr - Adds a mode attribute to a particular declaration.
4988 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
4989 bool InInstantiation = false);
4990 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
4991 const AttributeCommonInfo &CI,
4992 const IdentifierInfo *Ident);
4993 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
4994 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
4995 const AttributeCommonInfo &CI);
4996 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
4997 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
4998 const InternalLinkageAttr &AL);
4999
5000 /// Check validaty of calling convention attribute \p attr. If \p FD
5001 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
5002 /// target. Otherwise, it is specified by \p CFT.
5004 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
5006
5007 /// Checks a regparm attribute, returning true if it is ill-formed and
5008 /// otherwise setting numParams to the appropriate value.
5009 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
5010
5011 /// Create an CUDALaunchBoundsAttr attribute.
5012 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
5013 Expr *MaxThreads,
5014 Expr *MinBlocks,
5015 Expr *MaxBlocks);
5016
5017 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
5018 /// declaration.
5019 void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
5020 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
5021
5022 /// Add a cluster_dims attribute to a particular declaration.
5023 CUDAClusterDimsAttr *createClusterDimsAttr(const AttributeCommonInfo &CI,
5024 Expr *X, Expr *Y, Expr *Z);
5025 void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X,
5026 Expr *Y, Expr *Z);
5027 /// Add a no_cluster attribute to a particular declaration.
5028 void addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI);
5029
5030 enum class RetainOwnershipKind { NS, CF, OS };
5031
5032 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
5033 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
5034
5035 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
5036
5037 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
5038 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
5039 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
5040 const AttributeCommonInfo &CI,
5041 bool BestCase,
5042 MSInheritanceModel Model);
5043
5044 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
5045 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
5046 const EnforceTCBLeafAttr &AL);
5047
5048 /// Helper for delayed processing TransparentUnion or
5049 /// BPFPreserveAccessIndexAttr attribute.
5051 const ParsedAttributesView &AttrList);
5052
5053 // Options for ProcessDeclAttributeList().
5057
5060 Result.IncludeCXX11Attributes = Val;
5061 return Result;
5062 }
5063
5066 Result.IgnoreTypeAttributes = Val;
5067 return Result;
5068 }
5069
5070 // Should C++11 attributes be processed?
5072
5073 // Should any type attributes encountered be ignored?
5074 // If this option is false, a diagnostic will be emitted for any type
5075 // attributes of a kind that does not "slide" from the declaration to
5076 // the decl-specifier-seq.
5078 };
5079
5080 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
5081 /// attribute list to the specified decl, ignoring any type attributes.
5083 const ParsedAttributesView &AttrList,
5084 const ProcessDeclAttributeOptions &Options =
5086
5087 /// Annotation attributes are the only attributes allowed after an access
5088 /// specifier.
5090 const ParsedAttributesView &AttrList);
5091
5092 /// checkUnusedDeclAttributes - Given a declarator which is not being
5093 /// used to build a declaration, complain about any decl attributes
5094 /// which might be lying around on it.
5096
5097 void DiagnoseUnknownAttribute(const ParsedAttr &AL);
5098
5099 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
5100 /// \#pragma weak needs a non-definition decl and source may not have one.
5102 SourceLocation Loc);
5103
5104 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
5105 /// applied to it, possibly with an alias.
5106 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
5107
5108 void ProcessPragmaWeak(Scope *S, Decl *D);
5109 // Decl attributes - this routine is the top level dispatcher.
5110 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
5111
5113
5114 /// Given a set of delayed diagnostics, re-emit them as if they had
5115 /// been delayed in the current context instead of in the given pool.
5116 /// Essentially, this just moves them to the current pool.
5118
5119 /// Check that the type is a plain record with one field being a pointer
5120 /// type and the other field being an integer. This matches the common
5121 /// implementation of std::span or sized_allocation_t in P0901R11.
5122 bool CheckSpanLikeType(const AttributeCommonInfo &CI, const QualType &Ty);
5123
5124 /// Check if IdxExpr is a valid parameter index for a function or
5125 /// instance method D. May output an error.
5126 ///
5127 /// \returns true if IdxExpr is a valid index.
5128 template <typename AttrInfo>
5130 const Decl *D, const AttrInfo &AI, unsigned AttrArgNum,
5131 const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis = false,
5132 bool CanIndexVariadicArguments = false) {
5134
5135 // In C++ the implicit 'this' function parameter also counts.
5136 // Parameters are counted from one.
5137 bool HP = hasFunctionProto(D);
5138 bool HasImplicitThisParam = hasImplicitObjectParameter(D);
5139 bool IV = HP && isFunctionOrMethodVariadic(D);
5140 unsigned NumParams =
5141 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
5142
5143 std::optional<llvm::APSInt> IdxInt;
5144 if (IdxExpr->isTypeDependent() ||
5145 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
5146 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
5147 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
5148 << IdxExpr->getSourceRange();
5149 return false;
5150 }
5151
5152 unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX);
5153 if (IdxSource < 1 ||
5154 ((!IV || !CanIndexVariadicArguments) && IdxSource > NumParams)) {
5155 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
5156 << &AI << AttrArgNum << IdxExpr->getSourceRange();
5157 return false;
5158 }
5159 if (HasImplicitThisParam && !CanIndexImplicitThis) {
5160 if (IdxSource == 1) {
5161 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
5162 << &AI << IdxExpr->getSourceRange();
5163 return false;
5164 }
5165 }
5166
5167 Idx = ParamIdx(IdxSource, D);
5168 return true;
5169 }
5170
5171 ///@}
5172
5173 //
5174 //
5175 // -------------------------------------------------------------------------
5176 //
5177 //
5178
5179 /// \name C++ Declarations
5180 /// Implementations are in SemaDeclCXX.cpp
5181 ///@{
5182
5183public:
5185
5186 /// Called before parsing a function declarator belonging to a function
5187 /// declaration.
5189 unsigned TemplateParameterDepth);
5190
5191 /// Called after parsing a function declarator belonging to a function
5192 /// declaration.
5194
5195 // Act on C++ namespaces
5197 SourceLocation NamespaceLoc,
5198 SourceLocation IdentLoc, IdentifierInfo *Ident,
5199 SourceLocation LBrace,
5200 const ParsedAttributesView &AttrList,
5201 UsingDirectiveDecl *&UsingDecl, bool IsNested);
5202
5203 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
5204 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
5205 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
5206
5208
5209 /// Retrieve the special "std" namespace, which may require us to
5210 /// implicitly define the namespace.
5212
5214 EnumDecl *getStdAlignValT() const;
5215
5218 QualType AllocType, SourceLocation);
5219
5221 const IdentifierInfo *MemberOrBase);
5222
5224 /// The '<=>' operator was used in an expression and a builtin operator
5225 /// was selected.
5227 /// A defaulted 'operator<=>' needed the comparison category. This
5228 /// typically only applies to 'std::strong_ordering', due to the implicit
5229 /// fallback return value.
5231 };
5232
5233 /// Lookup the specified comparison category types in the standard
5234 /// library, an check the VarDecls possibly returned by the operator<=>
5235 /// builtins for that type.
5236 ///
5237 /// \return The type of the comparison category type corresponding to the
5238 /// specified Kind, or a null type if an error occurs
5240 SourceLocation Loc,
5242
5243 /// Tests whether Ty is an instance of std::initializer_list and, if
5244 /// it is and Element is not NULL, assigns the element type to Element.
5245 bool isStdInitializerList(QualType Ty, QualType *Element);
5246
5247 /// Tests whether Ty is an instance of std::type_identity and, if
5248 /// it is and TypeArgument is not NULL, assigns the element type to Element.
5249 /// If MalformedDecl is not null, and type_identity was ruled out due to being
5250 /// incorrectly structured despite having the correct name, the faulty Decl
5251 /// will be assigned to MalformedDecl.
5252 bool isStdTypeIdentity(QualType Ty, QualType *TypeArgument,
5253 const Decl **MalformedDecl = nullptr);
5254
5255 /// Looks for the std::initializer_list template and instantiates it
5256 /// with Element, or emits an error if it's not found.
5257 ///
5258 /// \returns The instantiated template, or null on error.
5260
5261 /// Looks for the std::type_identity template and instantiates it
5262 /// with Type, or returns a null type if type_identity has not been declared
5263 ///
5264 /// \returns The instantiated template, or null if std::type_identity is not
5265 /// declared
5267
5268 /// Determine whether Ctor is an initializer-list constructor, as
5269 /// defined in [dcl.init.list]p2.
5270 bool isInitListConstructor(const FunctionDecl *Ctor);
5271
5272 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
5273 SourceLocation NamespcLoc, CXXScopeSpec &SS,
5274 SourceLocation IdentLoc,
5275 IdentifierInfo *NamespcName,
5276 const ParsedAttributesView &AttrList);
5277
5279
5280 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
5281 SourceLocation AliasLoc, IdentifierInfo *Alias,
5282 CXXScopeSpec &SS, SourceLocation IdentLoc,
5283 IdentifierInfo *Ident);
5284
5285 /// Remove decls we can't actually see from a lookup being used to declare
5286 /// shadow using decls.
5287 ///
5288 /// \param S - The scope of the potential shadow decl
5289 /// \param Previous - The lookup of a potential shadow decl's name.
5290 void FilterUsingLookup(Scope *S, LookupResult &lookup);
5291
5292 /// Hides a using shadow declaration. This is required by the current
5293 /// using-decl implementation when a resolvable using declaration in a
5294 /// class is followed by a declaration which would hide or override
5295 /// one or more of the using decl's targets; for example:
5296 ///
5297 /// struct Base { void foo(int); };
5298 /// struct Derived : Base {
5299 /// using Base::foo;
5300 /// void foo(int);
5301 /// };
5302 ///
5303 /// The governing language is C++03 [namespace.udecl]p12:
5304 ///
5305 /// When a using-declaration brings names from a base class into a
5306 /// derived class scope, member functions in the derived class
5307 /// override and/or hide member functions with the same name and
5308 /// parameter types in a base class (rather than conflicting).
5309 ///
5310 /// There are two ways to implement this:
5311 /// (1) optimistically create shadow decls when they're not hidden
5312 /// by existing declarations, or
5313 /// (2) don't create any shadow decls (or at least don't make them
5314 /// visible) until we've fully parsed/instantiated the class.
5315 /// The problem with (1) is that we might have to retroactively remove
5316 /// a shadow decl, which requires several O(n) operations because the
5317 /// decl structures are (very reasonably) not designed for removal.
5318 /// (2) avoids this but is very fiddly and phase-dependent.
5319 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
5320
5321 /// Determines whether to create a using shadow decl for a particular
5322 /// decl, given the set of decls existing prior to this using lookup.
5324 const LookupResult &PreviousDecls,
5325 UsingShadowDecl *&PrevShadow);
5326
5327 /// Builds a shadow declaration corresponding to a 'using' declaration.
5330 UsingShadowDecl *PrevDecl);
5331
5332 /// Checks that the given using declaration is not an invalid
5333 /// redeclaration. Note that this is checking only for the using decl
5334 /// itself, not for any ill-formedness among the UsingShadowDecls.
5336 bool HasTypenameKeyword,
5337 const CXXScopeSpec &SS,
5338 SourceLocation NameLoc,
5339 const LookupResult &Previous);
5340
5341 /// Checks that the given nested-name qualifier used in a using decl
5342 /// in the current context is appropriately related to the current
5343 /// scope. If an error is found, diagnoses it and returns true.
5344 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
5345 /// the result of that lookup. UD is likewise nullptr, except when we have an
5346 /// already-populated UsingDecl whose shadow decls contain the same
5347 /// information (i.e. we're instantiating a UsingDecl with non-dependent
5348 /// scope).
5349 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
5350 const CXXScopeSpec &SS,
5351 const DeclarationNameInfo &NameInfo,
5352 SourceLocation NameLoc,
5353 const LookupResult *R = nullptr,
5354 const UsingDecl *UD = nullptr);
5355
5356 /// Builds a using declaration.
5357 ///
5358 /// \param IsInstantiation - Whether this call arises from an
5359 /// instantiation of an unresolved using declaration. We treat
5360 /// the lookup differently for these declarations.
5362 SourceLocation UsingLoc,
5363 bool HasTypenameKeyword,
5364 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5365 DeclarationNameInfo NameInfo,
5366 SourceLocation EllipsisLoc,
5367 const ParsedAttributesView &AttrList,
5368 bool IsInstantiation, bool IsUsingIfExists);
5370 SourceLocation UsingLoc,
5371 SourceLocation EnumLoc,
5372 SourceLocation NameLoc,
5373 TypeSourceInfo *EnumType, EnumDecl *ED);
5374 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
5375 ArrayRef<NamedDecl *> Expansions);
5376
5377 /// Additional checks for a using declaration referring to a constructor name.
5379
5380 /// Given a derived-class using shadow declaration for a constructor and the
5381 /// correspnding base class constructor, find or create the implicit
5382 /// synthesized derived class constructor to use for this initialization.
5385 ConstructorUsingShadowDecl *DerivedShadow);
5386
5388 SourceLocation UsingLoc,
5389 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5390 UnqualifiedId &Name, SourceLocation EllipsisLoc,
5391 const ParsedAttributesView &AttrList);
5393 SourceLocation UsingLoc,
5394 SourceLocation EnumLoc, SourceRange TyLoc,
5395 const IdentifierInfo &II, ParsedType Ty,
5396 const CXXScopeSpec &SS);
5398 MultiTemplateParamsArg TemplateParams,
5399 SourceLocation UsingLoc, UnqualifiedId &Name,
5400 const ParsedAttributesView &AttrList,
5401 TypeResult Type, Decl *DeclFromDeclSpec);
5402
5403 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
5404 /// including handling of its default argument expressions.
5405 ///
5406 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
5408 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5410 bool HadMultipleCandidates, bool IsListInitialization,
5411 bool IsStdInitListInitialization, bool RequiresZeroInit,
5412 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5413
5414 /// Build a CXXConstructExpr whose constructor has already been resolved if
5415 /// it denotes an inherited constructor.
5417 SourceLocation ConstructLoc, QualType DeclInitType,
5418 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5419 bool HadMultipleCandidates, bool IsListInitialization,
5420 bool IsStdInitListInitialization, bool RequiresZeroInit,
5421 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5422
5423 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
5424 // the constructor can be elidable?
5426 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5427 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5428 bool HadMultipleCandidates, bool IsListInitialization,
5429 bool IsStdInitListInitialization, bool RequiresZeroInit,
5430 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5431
5433 SourceLocation InitLoc);
5434
5435 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
5436 /// constructed variable.
5437 void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit);
5438
5439 /// Helper class that collects exception specifications for
5440 /// implicitly-declared special member functions.
5442 // Pointer to allow copying
5443 Sema *Self;
5444 // We order exception specifications thus:
5445 // noexcept is the most restrictive, but is only used in C++11.
5446 // throw() comes next.
5447 // Then a throw(collected exceptions)
5448 // Finally no specification, which is expressed as noexcept(false).
5449 // throw(...) is used instead if any called function uses it.
5450 ExceptionSpecificationType ComputedEST;
5451 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5452 SmallVector<QualType, 4> Exceptions;
5453
5454 void ClearExceptions() {
5455 ExceptionsSeen.clear();
5456 Exceptions.clear();
5457 }
5458
5459 public:
5461 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5462 if (!Self.getLangOpts().CPlusPlus11)
5463 ComputedEST = EST_DynamicNone;
5464 }
5465
5466 /// Get the computed exception specification type.
5468 assert(!isComputedNoexcept(ComputedEST) &&
5469 "noexcept(expr) should not be a possible result");
5470 return ComputedEST;
5471 }
5472
5473 /// The number of exceptions in the exception specification.
5474 unsigned size() const { return Exceptions.size(); }
5475
5476 /// The set of exceptions in the exception specification.
5477 const QualType *data() const { return Exceptions.data(); }
5478
5479 /// Integrate another called method into the collected data.
5480 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5481
5482 /// Integrate an invoked expression into the collected data.
5483 void CalledExpr(Expr *E) { CalledStmt(E); }
5484
5485 /// Integrate an invoked statement into the collected data.
5486 void CalledStmt(Stmt *S);
5487
5488 /// Overwrite an EPI's exception specification with this
5489 /// computed exception specification.
5492 ESI.Type = getExceptionSpecType();
5493 if (ESI.Type == EST_Dynamic) {
5494 ESI.Exceptions = Exceptions;
5495 } else if (ESI.Type == EST_None) {
5496 /// C++11 [except.spec]p14:
5497 /// The exception-specification is noexcept(false) if the set of
5498 /// potential exceptions of the special member function contains "any"
5499 ESI.Type = EST_NoexceptFalse;
5500 ESI.NoexceptExpr =
5501 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5502 }
5503 return ESI;
5504 }
5505 };
5506
5507 /// Evaluate the implicit exception specification for a defaulted
5508 /// special member function.
5510
5511 /// Check the given exception-specification and update the
5512 /// exception specification information with the results.
5513 void checkExceptionSpecification(bool IsTopLevel,
5515 ArrayRef<ParsedType> DynamicExceptions,
5516 ArrayRef<SourceRange> DynamicExceptionRanges,
5517 Expr *NoexceptExpr,
5518 SmallVectorImpl<QualType> &Exceptions,
5520
5521 /// Add an exception-specification to the given member or friend function
5522 /// (or function template). The exception-specification was parsed
5523 /// after the function itself was declared.
5525 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5526 ArrayRef<ParsedType> DynamicExceptions,
5527 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5528
5529 class InheritedConstructorInfo;
5530
5531 /// Determine if a special member function should have a deleted
5532 /// definition when it is defaulted.
5534 InheritedConstructorInfo *ICI = nullptr,
5535 bool Diagnose = false);
5536
5537 /// Produce notes explaining why a defaulted function was defined as deleted.
5539
5540 /// Declare the implicit default constructor for the given class.
5541 ///
5542 /// \param ClassDecl The class declaration into which the implicit
5543 /// default constructor will be added.
5544 ///
5545 /// \returns The implicitly-declared default constructor.
5548
5549 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5550 /// defining this constructor as the default constructor.
5553
5554 /// Declare the implicit destructor for the given class.
5555 ///
5556 /// \param ClassDecl The class declaration into which the implicit
5557 /// destructor will be added.
5558 ///
5559 /// \returns The implicitly-declared destructor.
5561
5562 /// DefineImplicitDestructor - Checks for feasibility of
5563 /// defining this destructor as the default destructor.
5564 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5566
5567 /// Build an exception spec for destructors that don't have one.
5568 ///
5569 /// C++11 says that user-defined destructors with no exception spec get one
5570 /// that looks as if the destructor was implicitly declared.
5572
5573 /// Define the specified inheriting constructor.
5576
5577 /// Declare the implicit copy constructor for the given class.
5578 ///
5579 /// \param ClassDecl The class declaration into which the implicit
5580 /// copy constructor will be added.
5581 ///
5582 /// \returns The implicitly-declared copy constructor.
5584
5585 /// DefineImplicitCopyConstructor - Checks for feasibility of
5586 /// defining this constructor as the copy constructor.
5587 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5589
5590 /// Declare the implicit move constructor for the given class.
5591 ///
5592 /// \param ClassDecl The Class declaration into which the implicit
5593 /// move constructor will be added.
5594 ///
5595 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5596 /// declared.
5598
5599 /// DefineImplicitMoveConstructor - Checks for feasibility of
5600 /// defining this constructor as the move constructor.
5601 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5603
5604 /// Declare the implicit copy assignment operator for the given class.
5605 ///
5606 /// \param ClassDecl The class declaration into which the implicit
5607 /// copy assignment operator will be added.
5608 ///
5609 /// \returns The implicitly-declared copy assignment operator.
5611
5612 /// Defines an implicitly-declared copy assignment operator.
5613 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5614 CXXMethodDecl *MethodDecl);
5615
5616 /// Declare the implicit move assignment operator for the given class.
5617 ///
5618 /// \param ClassDecl The Class declaration into which the implicit
5619 /// move assignment operator will be added.
5620 ///
5621 /// \returns The implicitly-declared move assignment operator, or NULL if it
5622 /// wasn't declared.
5624
5625 /// Defines an implicitly-declared move assignment operator.
5626 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5627 CXXMethodDecl *MethodDecl);
5628
5629 /// Check a completed declaration of an implicit special member.
5631
5632 /// Determine whether the given function is an implicitly-deleted
5633 /// special member function.
5635
5636 /// Check whether 'this' shows up in the type of a static member
5637 /// function after the (naturally empty) cv-qualifier-seq would be.
5638 ///
5639 /// \returns true if an error occurred.
5641
5642 /// Whether this' shows up in the exception specification of a static
5643 /// member function.
5645
5646 /// Check whether 'this' shows up in the attributes of the given
5647 /// static member function.
5648 ///
5649 /// \returns true if an error occurred.
5651
5653 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5654
5656
5657 /// Given a constructor and the set of arguments provided for the
5658 /// constructor, convert the arguments and add any required default arguments
5659 /// to form a proper call to this constructor.
5660 ///
5661 /// \returns true if an error occurred, false otherwise.
5663 QualType DeclInitType, MultiExprArg ArgsPtr,
5664 SourceLocation Loc,
5665 SmallVectorImpl<Expr *> &ConvertedArgs,
5666 bool AllowExplicit = false,
5667 bool IsListInitialization = false);
5668
5669 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5670 /// initializer for the declaration 'Dcl'.
5671 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5672 /// static data member of class X, names should be looked up in the scope of
5673 /// class X.
5675
5676 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5677 /// initializer for the declaration 'Dcl'.
5678 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5679
5680 /// Define the "body" of the conversion from a lambda object to a
5681 /// function pointer.
5682 ///
5683 /// This routine doesn't actually define a sensible body; rather, it fills
5684 /// in the initialization expression needed to copy the lambda object into
5685 /// the block, and IR generation actually generates the real body of the
5686 /// block pointer conversion.
5687 void
5689 CXXConversionDecl *Conv);
5690
5691 /// Define the "body" of the conversion from a lambda object to a
5692 /// block pointer.
5693 ///
5694 /// This routine doesn't actually define a sensible body; rather, it fills
5695 /// in the initialization expression needed to copy the lambda object into
5696 /// the block, and IR generation actually generates the real body of the
5697 /// block pointer conversion.
5699 CXXConversionDecl *Conv);
5700
5701 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5702 /// linkage specification, including the language and (if present)
5703 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5704 /// language string literal. LBraceLoc, if valid, provides the location of
5705 /// the '{' brace. Otherwise, this linkage specification does not
5706 /// have any braces.
5708 Expr *LangStr, SourceLocation LBraceLoc);
5709
5710 /// ActOnFinishLinkageSpecification - Complete the definition of
5711 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5712 /// valid, it's the position of the closing '}' brace in a linkage
5713 /// specification that uses braces.
5715 SourceLocation RBraceLoc);
5716
5717 //===--------------------------------------------------------------------===//
5718 // C++ Classes
5719 //
5720
5721 /// Get the class that is directly named by the current context. This is the
5722 /// class for which an unqualified-id in this scope could name a constructor
5723 /// or destructor.
5724 ///
5725 /// If the scope specifier denotes a class, this will be that class.
5726 /// If the scope specifier is empty, this will be the class whose
5727 /// member-specification we are currently within. Otherwise, there
5728 /// is no such class.
5730
5731 /// isCurrentClassName - Determine whether the identifier II is the
5732 /// name of the class type currently being defined. In the case of
5733 /// nested classes, this will only return true if II is the name of
5734 /// the innermost class.
5735 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5736 const CXXScopeSpec *SS = nullptr);
5737
5738 /// Determine whether the identifier II is a typo for the name of
5739 /// the class type currently being defined. If so, update it to the identifier
5740 /// that should have been used.
5742
5743 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5745 SourceLocation ColonLoc,
5746 const ParsedAttributesView &Attrs);
5747
5748 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5749 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5750 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5751 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5752 /// present (but parsing it has been deferred).
5753 NamedDecl *
5755 MultiTemplateParamsArg TemplateParameterLists,
5756 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5757 InClassInitStyle InitStyle);
5758
5759 /// Enter a new C++ default initializer scope. After calling this, the
5760 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5761 /// parsing or instantiating the initializer failed.
5763
5764 /// This is invoked after parsing an in-class initializer for a
5765 /// non-static C++ class member, and after instantiating an in-class
5766 /// initializer in a class template. Such actions are deferred until the class
5767 /// is complete.
5769 SourceLocation EqualLoc,
5771
5772 /// Handle a C++ member initializer using parentheses syntax.
5774 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5775 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5776 const DeclSpec &DS, SourceLocation IdLoc,
5777 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5778 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5779
5780 /// Handle a C++ member initializer using braced-init-list syntax.
5781 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5782 CXXScopeSpec &SS,
5783 IdentifierInfo *MemberOrBase,
5784 ParsedType TemplateTypeTy,
5785 const DeclSpec &DS, SourceLocation IdLoc,
5786 Expr *InitList, SourceLocation EllipsisLoc);
5787
5788 /// Handle a C++ member initializer.
5789 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5790 CXXScopeSpec &SS,
5791 IdentifierInfo *MemberOrBase,
5792 ParsedType TemplateTypeTy,
5793 const DeclSpec &DS, SourceLocation IdLoc,
5794 Expr *Init, SourceLocation EllipsisLoc);
5795
5797 SourceLocation IdLoc);
5798
5800 TypeSourceInfo *BaseTInfo, Expr *Init,
5801 CXXRecordDecl *ClassDecl,
5802 SourceLocation EllipsisLoc);
5803
5805 CXXRecordDecl *ClassDecl);
5806
5809
5811 ArrayRef<CXXCtorInitializer *> Initializers = {});
5812
5813 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5814 /// mark all the non-trivial destructors of its members and bases as
5815 /// referenced.
5816 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
5817 CXXRecordDecl *Record);
5818
5819 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5820 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5821 /// class. In the Microsoft C++ ABI, this is done any time a class's
5822 /// destructor is referenced.
5824 SourceLocation Location, CXXRecordDecl *ClassDecl,
5825 llvm::SmallPtrSetImpl<const CXXRecordDecl *> *DirectVirtualBases =
5826 nullptr);
5827
5828 /// Do semantic checks to allow the complete destructor variant to be emitted
5829 /// when the destructor is defined in another translation unit. In the Itanium
5830 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
5831 /// can be emitted in separate TUs. To emit the complete variant, run a subset
5832 /// of the checks performed when emitting a regular destructor.
5833 void CheckCompleteDestructorVariant(SourceLocation CurrentLocation,
5834 CXXDestructorDecl *Dtor);
5835
5836 /// The list of classes whose vtables have been used within
5837 /// this translation unit, and the source locations at which the
5838 /// first use occurred.
5839 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
5840
5841 /// The list of vtables that are required but have not yet been
5842 /// materialized.
5844
5845 /// The set of classes whose vtables have been used within
5846 /// this translation unit, and a bit that will be true if the vtable is
5847 /// required to be emitted (otherwise, it should be emitted only if needed
5848 /// by code generation).
5849 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5850
5851 /// Load any externally-stored vtable uses.
5853
5854 /// Note that the vtable for the given class was used at the
5855 /// given location.
5857 bool DefinitionRequired = false);
5858
5859 /// Mark the exception specifications of all virtual member functions
5860 /// in the given class as needed.
5862 const CXXRecordDecl *RD);
5863
5864 /// MarkVirtualMembersReferenced - Will mark all members of the given
5865 /// CXXRecordDecl referenced.
5867 bool ConstexprOnly = false);
5868
5869 /// Define all of the vtables that have been used in this
5870 /// translation unit and reference any virtual members used by those
5871 /// vtables.
5872 ///
5873 /// \returns true if any work was done, false otherwise.
5874 bool DefineUsedVTables();
5875
5876 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
5877 /// special functions, such as the default constructor, copy
5878 /// constructor, or destructor, to the given C++ class (C++
5879 /// [special]p1). This routine can only be executed just before the
5880 /// definition of the class is complete.
5882
5883 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5884 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
5886 bool AnyErrors);
5887
5888 /// Check class-level dllimport/dllexport attribute. The caller must
5889 /// ensure that referenceDLLExportedClassMethods is called some point later
5890 /// when all outer classes of Class are complete.
5893
5895
5896 /// Perform propagation of DLL attributes from a derived class to a
5897 /// templated base class for MS compatibility.
5899 CXXRecordDecl *Class, Attr *ClassAttr,
5900 ClassTemplateSpecializationDecl *BaseTemplateSpec,
5901 SourceLocation BaseLoc);
5902
5903 /// Perform semantic checks on a class definition that has been
5904 /// completing, introducing implicitly-declared members, checking for
5905 /// abstract types, etc.
5906 ///
5907 /// \param S The scope in which the class was parsed. Null if we didn't just
5908 /// parse a class definition.
5909 /// \param Record The completed class.
5911
5912 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
5913 /// conditions that are needed for the attribute to have an effect.
5915
5916 /// Check that VTable Pointer authentication is only being set on the first
5917 /// first instantiation of the vtable
5919
5921 Decl *TagDecl, SourceLocation LBrac,
5922 SourceLocation RBrac,
5923 const ParsedAttributesView &AttrList);
5924
5925 /// Perform any semantic analysis which needs to be delayed until all
5926 /// pending class member declarations have been parsed.
5929
5930 /// This is used to implement the constant expression evaluation part of the
5931 /// attribute enable_if extension. There is nothing in standard C++ which
5932 /// would require reentering parameters.
5935 llvm::function_ref<Scope *()> EnterScope);
5937
5938 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
5939 /// parsing a top-level (non-nested) C++ class, and we are now
5940 /// parsing those parts of the given Method declaration that could
5941 /// not be parsed earlier (C++ [class.mem]p2), such as default
5942 /// arguments. This action should enter the scope of the given
5943 /// Method declaration as if we had just parsed the qualified method
5944 /// name. However, it should not bring the parameters into scope;
5945 /// that will be performed by ActOnDelayedCXXMethodParameter.
5947 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
5949
5950 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
5951 /// processing the delayed method declaration for Method. The method
5952 /// declaration is now considered finished. There may be a separate
5953 /// ActOnStartOfFunctionDef action later (not necessarily
5954 /// immediately!) for this method, if it was also defined inside the
5955 /// class body.
5958
5960
5961 bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx,
5962 StringEvaluationContext EvalContext,
5963 bool ErrorOnInvalidMessage);
5964 bool EvaluateAsString(Expr *Message, std::string &Result, ASTContext &Ctx,
5965 StringEvaluationContext EvalContext,
5966 bool ErrorOnInvalidMessage);
5967
5969 Expr *AssertExpr, Expr *AssertMessageExpr,
5970 SourceLocation RParenLoc);
5972 Expr *AssertExpr, Expr *AssertMessageExpr,
5973 SourceLocation RParenLoc, bool Failed);
5974
5975 /// Try to print more useful information about a failed static_assert
5976 /// with expression \E
5977 void DiagnoseStaticAssertDetails(const Expr *E);
5978
5979 /// If E represents a built-in type trait, or a known standard type trait,
5980 /// try to print more information about why the type type-trait failed.
5981 /// This assumes we already evaluated the expression to a false boolean value.
5982 void DiagnoseTypeTraitDetails(const Expr *E);
5983
5984 /// Handle a friend type declaration. This works in tandem with
5985 /// ActOnTag.
5986 ///
5987 /// Notes on friend class templates:
5988 ///
5989 /// We generally treat friend class declarations as if they were
5990 /// declaring a class. So, for example, the elaborated type specifier
5991 /// in a friend declaration is required to obey the restrictions of a
5992 /// class-head (i.e. no typedefs in the scope chain), template
5993 /// parameters are required to match up with simple template-ids, &c.
5994 /// However, unlike when declaring a template specialization, it's
5995 /// okay to refer to a template specialization without an empty
5996 /// template parameter declaration, e.g.
5997 /// friend class A<T>::B<unsigned>;
5998 /// We permit this as a special case; if there are any template
5999 /// parameters present at all, require proper matching, i.e.
6000 /// template <> template <class T> friend class A<int>::B;
6001 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
6002 MultiTemplateParamsArg TemplateParams,
6003 SourceLocation EllipsisLoc);
6005 MultiTemplateParamsArg TemplateParams);
6006
6007 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
6008 /// the well-formedness of the constructor declarator @p D with type @p
6009 /// R. If there are any errors in the declarator, this routine will
6010 /// emit diagnostics and set the invalid bit to true. In any case, the type
6011 /// will be updated to reflect a well-formed type for the constructor and
6012 /// returned.
6014 StorageClass &SC);
6015
6016 /// CheckConstructor - Checks a fully-formed constructor for
6017 /// well-formedness, issuing any diagnostics required. Returns true if
6018 /// the constructor declarator is invalid.
6020
6021 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
6022 /// the well-formednes of the destructor declarator @p D with type @p
6023 /// R. If there are any errors in the declarator, this routine will
6024 /// emit diagnostics and set the declarator to invalid. Even if this happens,
6025 /// will be updated to reflect a well-formed type for the destructor and
6026 /// returned.
6028 StorageClass &SC);
6029
6030 /// CheckDestructor - Checks a fully-formed destructor definition for
6031 /// well-formedness, issuing any diagnostics required. Returns true
6032 /// on error.
6034
6035 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
6036 /// well-formednes of the conversion function declarator @p D with
6037 /// type @p R. If there are any errors in the declarator, this routine
6038 /// will emit diagnostics and return true. Otherwise, it will return
6039 /// false. Either way, the type @p R will be updated to reflect a
6040 /// well-formed type for the conversion operator.
6042
6043 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
6044 /// the declaration of the given C++ conversion function. This routine
6045 /// is responsible for recording the conversion function in the C++
6046 /// class, if possible.
6048
6049 /// Check the validity of a declarator that we parsed for a deduction-guide.
6050 /// These aren't actually declarators in the grammar, so we need to check that
6051 /// the user didn't specify any pieces that are not part of the
6052 /// deduction-guide grammar. Return true on invalid deduction-guide.
6054 StorageClass &SC);
6055
6057
6060 SourceLocation DefaultLoc);
6062
6063 /// Kinds of defaulted comparison operator functions.
6064 enum class DefaultedComparisonKind : unsigned char {
6065 /// This is not a defaultable comparison operator.
6067 /// This is an operator== that should be implemented as a series of
6068 /// subobject comparisons.
6070 /// This is an operator<=> that should be implemented as a series of
6071 /// subobject comparisons.
6073 /// This is an operator!= that should be implemented as a rewrite in terms
6074 /// of a == comparison.
6076 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
6077 /// terms of a <=> comparison.
6079 };
6080
6084 FunctionDecl *Spaceship);
6087
6089 QualType R, bool IsLambda,
6090 DeclContext *DC = nullptr);
6092 DeclarationName Name, QualType R);
6094
6095 //===--------------------------------------------------------------------===//
6096 // C++ Derived Classes
6097 //
6098
6099 /// Check the validity of a C++ base class specifier.
6100 ///
6101 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
6102 /// and returns NULL otherwise.
6104 SourceRange SpecifierRange, bool Virtual,
6105 AccessSpecifier Access,
6106 TypeSourceInfo *TInfo,
6107 SourceLocation EllipsisLoc);
6108
6109 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
6110 /// one entry in the base class list of a class specifier, for
6111 /// example:
6112 /// class foo : public bar, virtual private baz {
6113 /// 'public bar' and 'virtual private baz' are each base-specifiers.
6114 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
6115 const ParsedAttributesView &Attrs, bool Virtual,
6116 AccessSpecifier Access, ParsedType basetype,
6117 SourceLocation BaseLoc,
6118 SourceLocation EllipsisLoc);
6119
6120 /// Performs the actual work of attaching the given base class
6121 /// specifiers to a C++ class.
6124
6125 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
6126 /// class, after checking whether there are any duplicate base
6127 /// classes.
6128 void ActOnBaseSpecifiers(Decl *ClassDecl,
6130
6131 /// Determine whether the type \p Derived is a C++ class that is
6132 /// derived from the type \p Base.
6133 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6135 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6139 CXXBasePaths &Paths);
6140
6141 // FIXME: I don't like this name.
6142 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
6143
6145 SourceLocation Loc, SourceRange Range,
6146 CXXCastPath *BasePath = nullptr,
6147 bool IgnoreAccess = false);
6148
6149 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
6150 /// conversion (where Derived and Base are class types) is
6151 /// well-formed, meaning that the conversion is unambiguous (and
6152 /// that all of the base classes are accessible). Returns true
6153 /// and emits a diagnostic if the code is ill-formed, returns false
6154 /// otherwise. Loc is the location where this routine should point to
6155 /// if there is an error, and Range is the source range to highlight
6156 /// if there is an error.
6157 ///
6158 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
6159 /// diagnostic for the respective type of error will be suppressed, but the
6160 /// check for ill-formed code will still be performed.
6162 unsigned InaccessibleBaseID,
6163 unsigned AmbiguousBaseConvID,
6164 SourceLocation Loc, SourceRange Range,
6165 DeclarationName Name, CXXCastPath *BasePath,
6166 bool IgnoreAccess = false);
6167
6168 /// Builds a string representing ambiguous paths from a
6169 /// specific derived class to different subobjects of the same base
6170 /// class.
6171 ///
6172 /// This function builds a string that can be used in error messages
6173 /// to show the different paths that one can take through the
6174 /// inheritance hierarchy to go from the derived class to different
6175 /// subobjects of a base class. The result looks something like this:
6176 /// @code
6177 /// struct D -> struct B -> struct A
6178 /// struct D -> struct C -> struct A
6179 /// @endcode
6180 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
6181
6183 const CXXMethodDecl *Old);
6184
6185 /// CheckOverridingFunctionReturnType - Checks whether the return types are
6186 /// covariant, according to C++ [class.virtual]p5.
6188 const CXXMethodDecl *Old);
6189
6190 // Check that the overriding method has no explicit object parameter.
6192 const CXXMethodDecl *Old);
6193
6194 /// Mark the given method pure.
6195 ///
6196 /// \param Method the method to be marked pure.
6197 ///
6198 /// \param InitRange the source range that covers the "0" initializer.
6200
6201 /// CheckOverrideControl - Check C++11 override control semantics.
6203
6204 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
6205 /// not used in the declaration of an overriding method.
6207
6208 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
6209 /// function overrides a virtual member function marked 'final', according to
6210 /// C++11 [class.virtual]p4.
6212 const CXXMethodDecl *Old);
6213
6224
6225 struct TypeDiagnoser;
6226
6229 TypeDiagnoser &Diagnoser);
6230 template <typename... Ts>
6232 const Ts &...Args) {
6233 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6234 return RequireNonAbstractType(Loc, T, Diagnoser);
6235 }
6236
6237 void DiagnoseAbstractType(const CXXRecordDecl *RD);
6238
6239 //===--------------------------------------------------------------------===//
6240 // C++ Overloaded Operators [C++ 13.5]
6241 //
6242
6243 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
6244 /// of this overloaded operator is well-formed. If so, returns false;
6245 /// otherwise, emits appropriate diagnostics and returns true.
6247
6248 /// CheckLiteralOperatorDeclaration - Check whether the declaration
6249 /// of this literal operator function is well-formed. If so, returns
6250 /// false; otherwise, emits appropriate diagnostics and returns true.
6252
6253 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
6254 /// found in an explicit(bool) specifier.
6256
6257 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
6258 /// Returns true if the explicit specifier is now resolved.
6260
6261 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
6262 /// C++ if/switch/while/for statement.
6263 /// e.g: "if (int x = f()) {...}"
6265
6266 // Emitting members of dllexported classes is delayed until the class
6267 // (including field initializers) is fully parsed.
6270
6271 /// Merge the exception specifications of two variable declarations.
6272 ///
6273 /// This is called when there's a redeclaration of a VarDecl. The function
6274 /// checks if the redeclaration might have an exception specification and
6275 /// validates compatibility and merges the specs if necessary.
6277
6278 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
6279 /// function, once we already know that they have the same
6280 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
6281 /// error, false otherwise.
6283
6284 /// Helpers for dealing with blocks and functions.
6286
6287 /// CheckExtraCXXDefaultArguments - Check for any extra default
6288 /// arguments in the declarator, which is not a function declaration
6289 /// or definition and therefore is not permitted to have default
6290 /// arguments. This routine should be invoked for every declarator
6291 /// that is not a function declaration or definition.
6293
6297
6298 /// Perform semantic analysis for the variable declaration that
6299 /// occurs within a C++ catch clause, returning the newly-created
6300 /// variable.
6302 SourceLocation StartLoc,
6303 SourceLocation IdLoc,
6304 const IdentifierInfo *Id);
6305
6306 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
6307 /// handler.
6309
6311
6312 /// Handle a friend tag declaration where the scope specifier was
6313 /// templated.
6315 unsigned TagSpec, SourceLocation TagLoc,
6316 CXXScopeSpec &SS, IdentifierInfo *Name,
6317 SourceLocation NameLoc,
6318 SourceLocation EllipsisLoc,
6320 MultiTemplateParamsArg TempParamLists);
6321
6323 SourceLocation DeclStart, Declarator &D,
6324 Expr *BitfieldWidth,
6325 InClassInitStyle InitStyle,
6326 AccessSpecifier AS,
6327 const ParsedAttr &MSPropertyAttr);
6328
6329 /// Diagnose why the specified class does not have a trivial special member of
6330 /// the given kind.
6333
6334 /// Determine whether a defaulted or deleted special member function is
6335 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
6336 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
6340 bool Diagnose = false);
6341
6342 /// For a defaulted function, the kind of defaulted function that it is.
6344 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
6345 unsigned SpecialMember : 8;
6346 unsigned Comparison : 8;
6347
6348 public:
6350 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
6351 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
6353 : SpecialMember(llvm::to_underlying(CSM)),
6354 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
6356 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
6357 Comparison(llvm::to_underlying(Comp)) {}
6358
6359 bool isSpecialMember() const {
6360 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
6362 }
6363 bool isComparison() const {
6364 return static_cast<DefaultedComparisonKind>(Comparison) !=
6366 }
6367
6368 explicit operator bool() const {
6369 return isSpecialMember() || isComparison();
6370 }
6371
6373 return static_cast<CXXSpecialMemberKind>(SpecialMember);
6374 }
6376 return static_cast<DefaultedComparisonKind>(Comparison);
6377 }
6378
6379 /// Get the index of this function kind for use in diagnostics.
6380 unsigned getDiagnosticIndex() const {
6381 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
6382 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
6383 "invalid should have highest index");
6384 static_assert((unsigned)DefaultedComparisonKind::None == 0,
6385 "none should be equal to zero");
6386 return SpecialMember + Comparison;
6387 }
6388 };
6389
6390 /// Determine the kind of defaulting that would be done for a given function.
6391 ///
6392 /// If the function is both a default constructor and a copy / move
6393 /// constructor (due to having a default argument for the first parameter),
6394 /// this picks CXXSpecialMemberKind::DefaultConstructor.
6395 ///
6396 /// FIXME: Check that case is properly handled by all callers.
6397 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
6398
6399 /// Handle a C++11 empty-declaration and attribute-declaration.
6401 SourceLocation SemiLoc);
6402
6404 /// Diagnose issues that are non-constant or that are extensions.
6406 /// Identify whether this function satisfies the formal rules for constexpr
6407 /// functions in the current lanugage mode (with no extensions).
6409 };
6410
6411 // Check whether a function declaration satisfies the requirements of a
6412 // constexpr function definition or a constexpr constructor definition. If so,
6413 // return true. If not, produce appropriate diagnostics (unless asked not to
6414 // by Kind) and return false.
6415 //
6416 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
6418 CheckConstexprKind Kind);
6419
6420 /// Diagnose methods which overload virtual methods in a base class
6421 /// without overriding any.
6423
6424 /// Check if a method overloads virtual methods in a base class without
6425 /// overriding any.
6426 void
6428 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6429 void
6431 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6432
6433 /// ActOnParamDefaultArgument - Check whether the default argument
6434 /// provided for a function parameter is well-formed. If so, attach it
6435 /// to the parameter declaration.
6436 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
6437 Expr *defarg);
6438
6439 /// ActOnParamUnparsedDefaultArgument - We've seen a default
6440 /// argument for a function parameter, but we can't parse it yet
6441 /// because we're inside a class definition. Note that this default
6442 /// argument will be parsed later.
6444 SourceLocation ArgLoc);
6445
6446 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
6447 /// the default argument for the parameter param failed.
6449 Expr *DefaultArg);
6451 SourceLocation EqualLoc);
6452 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
6453 SourceLocation EqualLoc);
6454
6455 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
6456 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
6457 StringLiteral *Message = nullptr);
6458 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6459
6460 void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
6461 StringLiteral *DeletedMessage = nullptr);
6465
6466 NamedDecl *
6468 MultiTemplateParamsArg TemplateParamLists);
6471 RecordDecl *ClassDecl,
6472 const IdentifierInfo *Name);
6473
6475 SourceLocation Loc);
6477
6478 /// Stack containing information needed when in C++2a an 'auto' is encountered
6479 /// in a function declaration parameter type specifier in order to invent a
6480 /// corresponding template parameter in the enclosing abbreviated function
6481 /// template. This information is also present in LambdaScopeInfo, stored in
6482 /// the FunctionScopes stack.
6484
6485 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6486 std::unique_ptr<CXXFieldCollector> FieldCollector;
6487
6489 /// Set containing all declared private fields that are not used.
6491
6493
6494 /// PureVirtualClassDiagSet - a set of class declarations which we have
6495 /// emitted a list of pure virtual functions. Used to prevent emitting the
6496 /// same list more than once.
6497 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6498
6502
6503 /// All the delegating constructors seen so far in the file, used for
6504 /// cycle detection at the end of the TU.
6506
6507 /// The C++ "std" namespace, where the standard library resides.
6509
6510 /// The C++ "std::initializer_list" template, which is defined in
6511 /// <initializer_list>.
6513
6514 /// The C++ "std::type_identity" template, which is defined in
6515 /// <type_traits>.
6517
6518 // Contains the locations of the beginning of unparsed default
6519 // argument locations.
6520 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6521
6522 /// UndefinedInternals - all the used, undefined objects which require a
6523 /// definition in this translation unit.
6524 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6525
6526 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6528
6529 /// The C++ special members which we are currently in the process of
6530 /// declaring. If this process recursively triggers the declaration of the
6531 /// same special member, we should act as if it is not yet declared.
6533
6535
6536 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6537
6540 ParsingClassDepth++;
6542 }
6544 ParsingClassDepth--;
6546 }
6547
6549 CXXScopeSpec &SS,
6550 ParsedType TemplateTypeTy,
6551 IdentifierInfo *MemberOrBase);
6552
6553private:
6554 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6555 QualType ResultTy,
6556 ArrayRef<QualType> Args);
6557 // Helper for ActOnFields to check for all function pointer members.
6558 bool EntirelyFunctionPointers(const RecordDecl *Record);
6559
6560 // A cache representing if we've fully checked the various comparison category
6561 // types stored in ASTContext. The bit-index corresponds to the integer value
6562 // of a ComparisonCategoryType enumerator.
6563 llvm::SmallBitVector FullyCheckedComparisonCategories;
6564
6565 /// Check if there is a field shadowing.
6566 void CheckShadowInheritedFields(const SourceLocation &Loc,
6567 DeclarationName FieldName,
6568 const CXXRecordDecl *RD,
6569 bool DeclIsField = true);
6570
6571 ///@}
6572
6573 //
6574 //
6575 // -------------------------------------------------------------------------
6576 //
6577 //
6578
6579 /// \name C++ Exception Specifications
6580 /// Implementations are in SemaExceptionSpec.cpp
6581 ///@{
6582
6583public:
6584 /// All the overriding functions seen during a class definition
6585 /// that had their exception spec checks delayed, plus the overridden
6586 /// function.
6589
6590 /// All the function redeclarations seen during a class definition that had
6591 /// their exception spec checks delayed, plus the prior declaration they
6592 /// should be checked against. Except during error recovery, the new decl
6593 /// should always be a friend declaration, as that's the only valid way to
6594 /// redeclare a special member before its class is complete.
6597
6598 /// Determine if we're in a case where we need to (incorrectly) eagerly
6599 /// parse an exception specification to work around a libstdc++ bug.
6601
6602 /// Check the given noexcept-specifier, convert its expression, and compute
6603 /// the appropriate ExceptionSpecificationType.
6604 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6606
6607 CanThrowResult canThrow(const Stmt *E);
6608 /// Determine whether the callee of a particular function call can throw.
6609 /// E, D and Loc are all optional.
6610 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6613 const FunctionProtoType *FPT);
6616
6617 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6618 /// exception specification. Incomplete types, or pointers to incomplete types
6619 /// other than void are not allowed.
6620 ///
6621 /// \param[in,out] T The exception type. This will be decayed to a pointer
6622 /// type
6623 /// when the input is an array or a function type.
6625
6626 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6627 /// pointer to member to a function with an exception specification. This
6628 /// means that it is invalid to add another level of indirection.
6631
6632 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6633 /// exception specifications. Exception specifications are equivalent if
6634 /// they allow exactly the same set of exception types. It does not matter how
6635 /// that is achieved. See C++ [except.spec]p2.
6637 SourceLocation OldLoc,
6638 const FunctionProtoType *New,
6639 SourceLocation NewLoc);
6641 const PartialDiagnostic &NoteID,
6642 const FunctionProtoType *Old,
6643 SourceLocation OldLoc,
6644 const FunctionProtoType *New,
6645 SourceLocation NewLoc);
6646 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6647
6648 /// CheckExceptionSpecSubset - Check whether the second function type's
6649 /// exception specification is a subset (or equivalent) of the first function
6650 /// type. This is used by override and pointer assignment checks.
6652 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6653 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6654 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6655 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6656 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6657
6658 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6659 /// two functions have equivalent exception specs. This is part of the
6660 /// assignment and override compatibility check. We do not check the
6661 /// parameters of parameter function pointers recursively, as no sane
6662 /// programmer would even be able to write such a function type.
6664 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6665 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6666 SourceLocation TargetLoc, const FunctionProtoType *Source,
6667 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6668
6669 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6670
6671 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6672 /// spec is a subset of base spec.
6674 const CXXMethodDecl *Old);
6675
6676 ///@}
6677
6678 //
6679 //
6680 // -------------------------------------------------------------------------
6681 //
6682 //
6683
6684 /// \name Expressions
6685 /// Implementations are in SemaExpr.cpp
6686 ///@{
6687
6688public:
6689 /// Describes how the expressions currently being parsed are
6690 /// evaluated at run-time, if at all.
6692 /// The current expression and its subexpressions occur within an
6693 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6694 /// \c sizeof, where the type of the expression may be significant but
6695 /// no code will be generated to evaluate the value of the expression at
6696 /// run time.
6698
6699 /// The current expression occurs within a braced-init-list within
6700 /// an unevaluated operand. This is mostly like a regular unevaluated
6701 /// context, except that we still instantiate constexpr functions that are
6702 /// referenced here so that we can perform narrowing checks correctly.
6704
6705 /// The current expression occurs within a discarded statement.
6706 /// This behaves largely similarly to an unevaluated operand in preventing
6707 /// definitions from being required, but not in other ways.
6709
6710 /// The current expression occurs within an unevaluated
6711 /// operand that unconditionally permits abstract references to
6712 /// fields, such as a SIZE operator in MS-style inline assembly.
6714
6715 /// The current context is "potentially evaluated" in C++11 terms,
6716 /// but the expression is evaluated at compile-time (like the values of
6717 /// cases in a switch statement).
6719
6720 /// In addition of being constant evaluated, the current expression
6721 /// occurs in an immediate function context - either a consteval function
6722 /// or a consteval if statement.
6724
6725 /// The current expression is potentially evaluated at run time,
6726 /// which means that code may be generated to evaluate the value of the
6727 /// expression at run time.
6729
6730 /// The current expression is potentially evaluated, but any
6731 /// declarations referenced inside that expression are only used if
6732 /// in fact the current expression is used.
6733 ///
6734 /// This value is used when parsing default function arguments, for which
6735 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6736 /// through varargs) but do not want to mark declarations as "referenced"
6737 /// until the default argument is used.
6739 };
6740
6741 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6742 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6743 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6744 /// have been applied to all subexpressions of the enclosing full expression.
6745 /// This is cleared at the end of each full expression.
6748
6749 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6750
6751 /// Data structure used to record current or nested
6752 /// expression evaluation contexts.
6754 /// The expression evaluation context.
6756
6757 /// Whether the enclosing context needed a cleanup.
6759
6760 /// The number of active cleanup objects when we entered
6761 /// this expression evaluation context.
6763
6765
6766 /// The lambdas that are present within this context, if it
6767 /// is indeed an unevaluated context.
6769
6770 /// The declaration that provides context for lambda expressions
6771 /// and block literals if the normal declaration context does not
6772 /// suffice, e.g., in a default function argument.
6774
6775 /// Declaration for initializer if one is currently being
6776 /// parsed. Used when an expression has a possibly unreachable
6777 /// diagnostic to reference the declaration as a whole.
6779
6780 /// If we are processing a decltype type, a set of call expressions
6781 /// for which we have deferred checking the completeness of the return type.
6783
6784 /// If we are processing a decltype type, a set of temporary binding
6785 /// expressions for which we have deferred checking the destructor.
6787
6789
6790 /// Expressions appearing as the LHS of a volatile assignment in this
6791 /// context. We produce a warning for these when popping the context if
6792 /// they are not discarded-value expressions nor unevaluated operands.
6794
6795 /// Set of candidates for starting an immediate invocation.
6798
6799 /// Set of DeclRefExprs referencing a consteval function when used in a
6800 /// context not already known to be immediately invoked.
6802
6803 /// P2718R0 - Lifetime extension in range-based for loops.
6804 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6805 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6806 /// InLifetimeExtendingContext is true.
6808
6809 /// Small set of gathered accesses to potentially misaligned members
6810 /// due to the packed attribute.
6812
6813 /// \brief Describes whether we are in an expression constext which we have
6814 /// to handle differently.
6822
6823 // A context can be nested in both a discarded statement context and
6824 // an immediate function context, so they need to be tracked independently.
6828
6830
6831 // We are in a constant context, but we also allow
6832 // non constant expressions, for example for array bounds (which may be
6833 // VLAs).
6835
6836 /// Whether we are currently in a context in which all temporaries must be
6837 /// lifetime-extended, even if they're not bound to a reference (for
6838 /// example, in a for-range initializer).
6840
6841 /// Whether evaluating an expression for a switch case label.
6842 bool IsCaseExpr = false;
6843
6844 /// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
6846
6847 // When evaluating immediate functions in the initializer of a default
6848 // argument or default member initializer, this is the declaration whose
6849 // default initializer is being evaluated and the location of the call
6850 // or constructor definition.
6854 : Loc(Loc), Decl(Decl), Context(Context) {
6855 assert(Decl && Context && "invalid initialization context");
6856 }
6857
6859 ValueDecl *Decl = nullptr;
6861 };
6862 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6863
6874
6880
6887
6892
6897 // C++23 [expr.const]p14:
6898 // An expression or conversion is in an immediate function
6899 // context if it is potentially evaluated and either:
6900 // * its innermost enclosing non-block scope is a function
6901 // parameter scope of an immediate function, or
6902 // * its enclosing statement is enclosed by the compound-
6903 // statement of a consteval if statement.
6906 }
6907
6915 };
6916
6918 assert(!ExprEvalContexts.empty() &&
6919 "Must be in an expression evaluation context");
6920 return ExprEvalContexts.back();
6921 }
6922
6924 assert(!ExprEvalContexts.empty() &&
6925 "Must be in an expression evaluation context");
6926 return ExprEvalContexts.back();
6927 }
6928
6930 assert(ExprEvalContexts.size() >= 2 &&
6931 "Must be in an expression evaluation context");
6932 return ExprEvalContexts[ExprEvalContexts.size() - 2];
6933 }
6934
6936 return const_cast<Sema *>(this)->parentEvaluationContext();
6937 }
6938
6943
6944 /// Increment when we find a reference; decrement when we find an ignored
6945 /// assignment. Ultimately the value is 0 if every reference is an ignored
6946 /// assignment.
6947 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
6948
6949 /// Used to control the generation of ExprWithCleanups.
6951
6952 /// ExprCleanupObjects - This is the stack of objects requiring
6953 /// cleanup that are created by the current full expression.
6955
6956 /// Determine whether the use of this declaration is valid, without
6957 /// emitting diagnostics.
6958 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
6959 // A version of DiagnoseUseOfDecl that should be used if overload resolution
6960 // has been used to find this declaration, which means we don't have to bother
6961 // checking the trailing requires clause.
6963 return DiagnoseUseOfDecl(
6964 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
6965 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
6966 /*SkipTrailingRequiresClause=*/true);
6967 }
6968
6969 /// Determine whether the use of this declaration is valid, and
6970 /// emit any corresponding diagnostics.
6971 ///
6972 /// This routine diagnoses various problems with referencing
6973 /// declarations that can occur when using a declaration. For example,
6974 /// it might warn if a deprecated or unavailable declaration is being
6975 /// used, or produce an error (and return true) if a C++0x deleted
6976 /// function is being used.
6977 ///
6978 /// \returns true if there was an error (this declaration cannot be
6979 /// referenced), false otherwise.
6981 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
6982 bool ObjCPropertyAccess = false,
6983 bool AvoidPartialAvailabilityChecks = false,
6984 ObjCInterfaceDecl *ClassReciever = nullptr,
6985 bool SkipTrailingRequiresClause = false);
6986
6987 /// Emit a note explaining that this function is deleted.
6989
6990 /// DiagnoseSentinelCalls - This routine checks whether a call or
6991 /// message-send is to a declaration with the sentinel attribute, and
6992 /// if so, it checks that the requirements of the sentinel are
6993 /// satisfied.
6995 ArrayRef<Expr *> Args);
6996
6998 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
7001
7003 ExpressionEvaluationContext NewContext, FunctionDecl *FD);
7004
7007 ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
7011
7013
7017
7018 /// Check whether E, which is either a discarded-value expression or an
7019 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
7020 /// lvalue, and if so, remove it from the list of volatile-qualified
7021 /// assignments that we are going to warn are deprecated.
7023
7025
7026 // Functions for marking a declaration referenced. These functions also
7027 // contain the relevant logic for marking if a reference to a function or
7028 // variable is an odr-use (in the C++11 sense). There are separate variants
7029 // for expressions referring to a decl; these exist because odr-use marking
7030 // needs to be delayed for some constant variables when we build one of the
7031 // named expressions.
7032 //
7033 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
7034 // should usually be true. This only needs to be set to false if the lack of
7035 // odr-use cannot be determined from the current context (for instance,
7036 // because the name denotes a virtual function and was written without an
7037 // explicit nested-name-specifier).
7038 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
7039
7040 /// Mark a function referenced, and check whether it is odr-used
7041 /// (C++ [basic.def.odr]p2, C99 6.9p3)
7043 bool MightBeOdrUse = true);
7044
7045 /// Mark a variable referenced, and check whether it is odr-used
7046 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
7047 /// used directly for normal expressions referring to VarDecl.
7049
7050 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
7051 ///
7052 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
7053 /// be handled with care if the DeclRefExpr is not newly-created.
7054 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
7055
7056 /// Perform reference-marking and odr-use handling for a MemberExpr.
7058
7059 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
7062 unsigned CapturingScopeIndex);
7063
7065 void CleanupVarDeclMarking();
7066
7067 /// Try to capture the given variable.
7068 ///
7069 /// \param Var The variable to capture.
7070 ///
7071 /// \param Loc The location at which the capture occurs.
7072 ///
7073 /// \param Kind The kind of capture, which may be implicit (for either a
7074 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
7075 ///
7076 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
7077 /// an explicit lambda capture.
7078 ///
7079 /// \param BuildAndDiagnose Whether we are actually supposed to add the
7080 /// captures or diagnose errors. If false, this routine merely check whether
7081 /// the capture can occur without performing the capture itself or complaining
7082 /// if the variable cannot be captured.
7083 ///
7084 /// \param CaptureType Will be set to the type of the field used to capture
7085 /// this variable in the innermost block or lambda. Only valid when the
7086 /// variable can be captured.
7087 ///
7088 /// \param DeclRefType Will be set to the type of a reference to the capture
7089 /// from within the current scope. Only valid when the variable can be
7090 /// captured.
7091 ///
7092 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
7093 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
7094 /// This is useful when enclosing lambdas must speculatively capture
7095 /// variables that may or may not be used in certain specializations of
7096 /// a nested generic lambda.
7097 ///
7098 /// \returns true if an error occurred (i.e., the variable cannot be
7099 /// captured) and false if the capture succeeded.
7101 TryCaptureKind Kind, SourceLocation EllipsisLoc,
7102 bool BuildAndDiagnose, QualType &CaptureType,
7103 QualType &DeclRefType,
7104 const unsigned *const FunctionScopeIndexToStopAt);
7105
7106 /// Try to capture the given variable.
7109 SourceLocation EllipsisLoc = SourceLocation());
7110
7111 /// Checks if the variable must be captured.
7113
7114 /// Given a variable, determine the type that a reference to that
7115 /// variable will have in the given scope.
7117
7118 /// Mark all of the declarations referenced within a particular AST node as
7119 /// referenced. Used when template instantiation instantiates a non-dependent
7120 /// type -- entities referenced by the type are now referenced.
7122
7123 /// Mark any declarations that appear within this expression or any
7124 /// potentially-evaluated subexpressions as "referenced".
7125 ///
7126 /// \param SkipLocalVariables If true, don't mark local variables as
7127 /// 'referenced'.
7128 /// \param StopAt Subexpressions that we shouldn't recurse into.
7130 bool SkipLocalVariables = false,
7131 ArrayRef<const Expr *> StopAt = {});
7132
7133 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
7134 /// conversion.
7135 ExprResult tryConvertExprToType(Expr *E, QualType Ty);
7136
7137 /// Conditionally issue a diagnostic based on the statements's reachability
7138 /// analysis.
7139 ///
7140 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
7141 /// the function body is parsed, and then do a basic reachability analysis to
7142 /// determine if the statement is reachable. If it is unreachable, the
7143 /// diagnostic will not be emitted.
7144 bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7145 const PartialDiagnostic &PD);
7146
7147 /// Conditionally issue a diagnostic based on the current
7148 /// evaluation context.
7149 ///
7150 /// \param Statement If Statement is non-null, delay reporting the
7151 /// diagnostic until the function body is parsed, and then do a basic
7152 /// reachability analysis to determine if the statement is reachable.
7153 /// If it is unreachable, the diagnostic will not be emitted.
7154 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
7155 const PartialDiagnostic &PD);
7156 /// Similar, but diagnostic is only produced if all the specified statements
7157 /// are reachable.
7158 bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7159 const PartialDiagnostic &PD);
7160
7161 // Primary Expressions.
7162 SourceRange getExprRange(Expr *E) const;
7163
7164 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
7165 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
7166 bool HasTrailingLParen, bool IsAddressOfOperand,
7167 CorrectionCandidateCallback *CCC = nullptr,
7168 bool IsInlineAsmIdentifier = false,
7169 Token *KeywordReplacement = nullptr);
7170
7171 /// Decomposes the given name into a DeclarationNameInfo, its location, and
7172 /// possibly a list of template arguments.
7173 ///
7174 /// If this produces template arguments, it is permitted to call
7175 /// DecomposeTemplateName.
7176 ///
7177 /// This actually loses a lot of source location information for
7178 /// non-standard name kinds; we should consider preserving that in
7179 /// some way.
7180 void DecomposeUnqualifiedId(const UnqualifiedId &Id,
7181 TemplateArgumentListInfo &Buffer,
7182 DeclarationNameInfo &NameInfo,
7183 const TemplateArgumentListInfo *&TemplateArgs);
7184
7185 /// Diagnose a lookup that found results in an enclosing class during error
7186 /// recovery. This usually indicates that the results were found in a
7187 /// dependent base class that could not be searched as part of a template
7188 /// definition. Always issues a diagnostic (though this may be only a warning
7189 /// in MS compatibility mode).
7190 ///
7191 /// Return \c true if the error is unrecoverable, or \c false if the caller
7192 /// should attempt to recover using these lookup results.
7193 bool DiagnoseDependentMemberLookup(const LookupResult &R);
7194
7195 /// Diagnose an empty lookup.
7196 ///
7197 /// \return false if new lookup candidates were found
7198 bool
7199 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
7200 CorrectionCandidateCallback &CCC,
7201 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
7202 ArrayRef<Expr *> Args = {},
7203 DeclContext *LookupCtx = nullptr);
7204
7205 /// If \p D cannot be odr-used in the current expression evaluation context,
7206 /// return a reason explaining why. Otherwise, return NOUR_None.
7208
7209 DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7210 SourceLocation Loc,
7211 const CXXScopeSpec *SS = nullptr);
7212 DeclRefExpr *
7213 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7214 const DeclarationNameInfo &NameInfo,
7215 const CXXScopeSpec *SS = nullptr,
7216 NamedDecl *FoundD = nullptr,
7217 SourceLocation TemplateKWLoc = SourceLocation(),
7218 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7219
7220 /// BuildDeclRefExpr - Build an expression that references a
7221 /// declaration that does not require a closure capture.
7222 DeclRefExpr *
7223 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7224 const DeclarationNameInfo &NameInfo,
7225 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
7226 SourceLocation TemplateKWLoc = SourceLocation(),
7227 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7228
7229 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
7230 bool HasTrailingLParen);
7231
7232 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
7233 /// declaration name, generally during template instantiation.
7234 /// There's a large number of things which don't need to be done along
7235 /// this path.
7237 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
7238 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
7239
7240 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
7241 bool NeedsADL,
7242 bool AcceptInvalidDecl = false);
7243
7244 /// Complete semantic analysis for a reference to the given declaration.
7246 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
7247 NamedDecl *FoundD = nullptr,
7248 const TemplateArgumentListInfo *TemplateArgs = nullptr,
7249 bool AcceptInvalidDecl = false);
7250
7251 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
7252 // where Tokens representing function local predefined macros (such as
7253 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
7254 std::vector<Token> ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks);
7255
7256 ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK);
7257 ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
7258 ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
7259
7260 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
7261
7262 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
7264 Scope *UDLScope = nullptr);
7265 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
7266 ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
7267 MultiExprArg Val);
7268 ExprResult ActOnCXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
7269 unsigned NumUserSpecifiedExprs,
7270 SourceLocation InitLoc,
7271 SourceLocation LParenLoc,
7272 SourceLocation RParenLoc);
7273
7274 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
7275 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
7276 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
7277 /// from multiple tokens. However, the common case is that StringToks points
7278 /// to one string.
7279 ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
7280 Scope *UDLScope = nullptr);
7281
7282 ExprResult ActOnUnevaluatedStringLiteral(ArrayRef<Token> StringToks);
7283
7284 /// ControllingExprOrType is either an opaque pointer coming out of a
7285 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
7286 /// into two so we don't take a void *, but that's awkward because one of
7287 /// the operands is either a ParsedType or an Expr *, which doesn't lend
7288 /// itself to generic code very well.
7289 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
7290 SourceLocation DefaultLoc,
7291 SourceLocation RParenLoc,
7292 bool PredicateIsExpr,
7293 void *ControllingExprOrType,
7294 ArrayRef<ParsedType> ArgTypes,
7295 ArrayRef<Expr *> ArgExprs);
7296 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
7297 /// it'd be better to split this interface into two so we don't take a
7298 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
7299 /// isn't a trivial change.
7300 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
7301 SourceLocation DefaultLoc,
7302 SourceLocation RParenLoc,
7303 bool PredicateIsExpr,
7304 void *ControllingExprOrType,
7305 ArrayRef<TypeSourceInfo *> Types,
7306 ArrayRef<Expr *> Exprs);
7307
7308 // Binary/Unary Operators. 'Tok' is the token for the operator.
7309 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
7310 Expr *InputExpr, bool IsAfterAmp = false);
7311 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc,
7312 Expr *Input, bool IsAfterAmp = false);
7313
7314 /// Unary Operators. 'Tok' is the token for the operator.
7315 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op,
7316 Expr *Input, bool IsAfterAmp = false);
7317
7318 /// Determine whether the given expression is a qualified member
7319 /// access expression, of a form that could be turned into a pointer to member
7320 /// with the address-of operator.
7321 bool isQualifiedMemberAccess(Expr *E);
7322 bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
7323 const Expr *Op,
7324 const CXXMethodDecl *MD);
7325
7326 /// CheckAddressOfOperand - The operand of & must be either a function
7327 /// designator or an lvalue designating an object. If it is an lvalue, the
7328 /// object cannot be declared with storage class register or be a bit field.
7329 /// Note: The usual conversions are *not* applied to the operand of the &
7330 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
7331 /// In C++, the operand might be an overloaded function name, in which case
7332 /// we allow the '&' but retain the overloaded-function type.
7333 QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
7334
7335 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
7336 /// _Alignas(type-name) .
7337 /// [dcl.align] An alignment-specifier of the form
7338 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
7339 ///
7340 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
7341 /// _Alignas(_Alignof(type-name)).
7342 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
7343 SourceLocation OpLoc, SourceRange R);
7344 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
7345 SourceLocation OpLoc, SourceRange R);
7346
7347 /// Build a sizeof or alignof expression given a type operand.
7348 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
7349 SourceLocation OpLoc,
7350 UnaryExprOrTypeTrait ExprKind,
7351 SourceRange R);
7352
7353 /// Build a sizeof or alignof expression given an expression
7354 /// operand.
7355 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
7356 UnaryExprOrTypeTrait ExprKind);
7357
7358 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
7359 /// expr and the same for @c alignof and @c __alignof
7360 /// Note that the ArgRange is invalid if isType is false.
7361 ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
7362 UnaryExprOrTypeTrait ExprKind,
7363 bool IsType, void *TyOrEx,
7364 SourceRange ArgRange);
7365
7366 /// Check for operands with placeholder types and complain if found.
7367 /// Returns ExprError() if there was an error and no recovery was possible.
7369 bool CheckVecStepExpr(Expr *E);
7370
7371 /// Check the constraints on expression operands to unary type expression
7372 /// and type traits.
7373 ///
7374 /// Completes any types necessary and validates the constraints on the operand
7375 /// expression. The logic mostly mirrors the type-based overload, but may
7376 /// modify the expression as it completes the type for that expression through
7377 /// template instantiation, etc.
7379
7380 /// Check the constraints on operands to unary expression and type
7381 /// traits.
7382 ///
7383 /// This will complete any types necessary, and validate the various
7384 /// constraints on those operands.
7385 ///
7386 /// The UsualUnaryConversions() function is *not* called by this routine.
7387 /// C99 6.3.2.1p[2-4] all state:
7388 /// Except when it is the operand of the sizeof operator ...
7389 ///
7390 /// C++ [expr.sizeof]p4
7391 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
7392 /// standard conversions are not applied to the operand of sizeof.
7393 ///
7394 /// This policy is followed for all of the unary trait expressions.
7395 bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
7396 SourceRange ExprRange,
7397 UnaryExprOrTypeTrait ExprKind,
7398 StringRef KWName);
7399
7400 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
7401 tok::TokenKind Kind, Expr *Input);
7402
7403 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
7404 MultiExprArg ArgExprs,
7405 SourceLocation RLoc);
7406 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
7407 Expr *Idx, SourceLocation RLoc);
7408
7409 ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx,
7410 Expr *ColumnIdx,
7411 SourceLocation RBLoc);
7412
7413 /// ConvertArgumentsForCall - Converts the arguments specified in
7414 /// Args/NumArgs to the parameter types of the function FDecl with
7415 /// function prototype Proto. Call is the call expression itself, and
7416 /// Fn is the function expression. For a C++ member function, this
7417 /// routine does not attempt to convert the object argument. Returns
7418 /// true if the call is ill-formed.
7419 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl,
7420 const FunctionProtoType *Proto,
7421 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
7422 bool ExecConfig = false);
7423
7424 /// CheckStaticArrayArgument - If the given argument corresponds to a static
7425 /// array parameter, check that it is non-null, and that if it is formed by
7426 /// array-to-pointer decay, the underlying array is sufficiently large.
7427 ///
7428 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
7429 /// the array type derivation, then for each call to the function, the value
7430 /// of the corresponding actual argument shall provide access to the first
7431 /// element of an array with at least as many elements as specified by the
7432 /// size expression.
7433 void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
7434 const Expr *ArgExpr);
7435
7436 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
7437 /// This provides the location of the left/right parens and a list of comma
7438 /// locations.
7439 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7440 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7441 Expr *ExecConfig = nullptr);
7442
7443 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
7444 /// This provides the location of the left/right parens and a list of comma
7445 /// locations.
7446 ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7447 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7448 Expr *ExecConfig = nullptr,
7449 bool IsExecConfig = false,
7450 bool AllowRecovery = false);
7451
7452 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
7453 // with the specified CallArgs
7454 Expr *BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id,
7455 MultiExprArg CallArgs);
7456
7458
7459 /// BuildResolvedCallExpr - Build a call to a resolved expression,
7460 /// i.e. an expression not of \p OverloadTy. The expression should
7461 /// unary-convert to an expression of function-pointer or
7462 /// block-pointer type.
7463 ///
7464 /// \param NDecl the declaration being called, if available
7466 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
7467 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
7468 Expr *Config = nullptr, bool IsExecConfig = false,
7469 ADLCallKind UsesADL = ADLCallKind::NotADL);
7470
7472 ParsedType &Ty, SourceLocation RParenLoc,
7473 Expr *CastExpr);
7474
7475 /// Prepares for a scalar cast, performing all the necessary stages
7476 /// except the final cast and returning the kind required.
7478
7479 /// Build an altivec or OpenCL literal.
7481 SourceLocation RParenLoc, Expr *E,
7482 TypeSourceInfo *TInfo);
7483
7484 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7485 /// the ParenListExpr into a sequence of comma binary operators.
7487
7489 SourceLocation RParenLoc, Expr *InitExpr);
7490
7492 TypeSourceInfo *TInfo,
7493 SourceLocation RParenLoc,
7494 Expr *LiteralExpr);
7495
7496 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7497 SourceLocation RBraceLoc);
7498
7499 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7500 SourceLocation RBraceLoc);
7501
7502 /// Binary Operators. 'Tok' is the token for the operator.
7504 Expr *LHSExpr, Expr *RHSExpr);
7506 Expr *LHSExpr, Expr *RHSExpr,
7507 bool ForFoldExpression = false);
7508
7509 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7510 /// operator @p Opc at location @c TokLoc. This routine only supports
7511 /// built-in operations; ActOnBinOp handles overloaded operators.
7513 Expr *LHSExpr, Expr *RHSExpr,
7514 bool ForFoldExpression = false);
7516 UnresolvedSetImpl &Functions);
7517
7518 /// Look for instances where it is likely the comma operator is confused with
7519 /// another operator. There is an explicit list of acceptable expressions for
7520 /// the left hand side of the comma operator, otherwise emit a warning.
7521 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7522
7523 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7524 /// in the case of a the GNU conditional expr extension.
7526 SourceLocation ColonLoc, Expr *CondExpr,
7527 Expr *LHSExpr, Expr *RHSExpr);
7528
7529 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7531 LabelDecl *TheDecl);
7532
7533 void ActOnStartStmtExpr();
7534 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7535 SourceLocation RPLoc);
7537 SourceLocation RPLoc, unsigned TemplateDepth);
7538 // Handle the final expression in a statement expression.
7540 void ActOnStmtExprError();
7541
7542 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
7545 bool isBrackets; // true if [expr], false if .ident
7546 union {
7549 } U;
7550 };
7551
7552 /// __builtin_offsetof(type, a.b[123][456].c)
7554 TypeSourceInfo *TInfo,
7555 ArrayRef<OffsetOfComponent> Components,
7556 SourceLocation RParenLoc);
7559 ParsedType ParsedArgTy,
7560 ArrayRef<OffsetOfComponent> Components,
7561 SourceLocation RParenLoc);
7562
7563 // __builtin_choose_expr(constExpr, expr1, expr2)
7564 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7565 Expr *LHSExpr, Expr *RHSExpr,
7566 SourceLocation RPLoc);
7567
7568 // __builtin_va_arg(expr, type)
7570 SourceLocation RPLoc);
7572 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7573
7574 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7575 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7577 SourceLocation BuiltinLoc,
7578 SourceLocation RPLoc);
7579
7580 // #embed
7582 StringLiteral *BinaryData, StringRef FileName);
7583
7584 // Build a potentially resolved SourceLocExpr.
7586 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7587 DeclContext *ParentContext);
7588
7589 // __null
7591
7592 bool CheckCaseExpression(Expr *E);
7593
7594 //===------------------------- "Block" Extension ------------------------===//
7595
7596 /// ActOnBlockStart - This callback is invoked when a block literal is
7597 /// started.
7598 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7599
7600 /// ActOnBlockArguments - This callback allows processing of block arguments.
7601 /// If there are no arguments, this is still invoked.
7602 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7603 Scope *CurScope);
7604
7605 /// ActOnBlockError - If there is an error parsing a block, this callback
7606 /// is invoked to pop the information about the block from the action impl.
7607 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7608
7609 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7610 /// literal was successfully completed. ^(int x){...}
7612 Scope *CurScope);
7613
7614 //===---------------------------- Clang Extensions ----------------------===//
7615
7616 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7617 /// provided arguments.
7618 ///
7619 /// __builtin_convertvector( value, dst type )
7620 ///
7622 SourceLocation BuiltinLoc,
7623 SourceLocation RParenLoc);
7624
7625 //===---------------------------- OpenCL Features -----------------------===//
7626
7627 /// Parse a __builtin_astype expression.
7628 ///
7629 /// __builtin_astype( value, dst type )
7630 ///
7631 ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
7632 SourceLocation BuiltinLoc,
7633 SourceLocation RParenLoc);
7634
7635 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7637 SourceLocation BuiltinLoc,
7638 SourceLocation RParenLoc);
7639
7640 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7642 ArrayRef<Expr *> SubExprs,
7643 QualType T = QualType());
7644
7645 /// Cast a base object to a member's actual type.
7646 ///
7647 /// There are two relevant checks:
7648 ///
7649 /// C++ [class.access.base]p7:
7650 ///
7651 /// If a class member access operator [...] is used to access a non-static
7652 /// data member or non-static member function, the reference is ill-formed
7653 /// if the left operand [...] cannot be implicitly converted to a pointer to
7654 /// the naming class of the right operand.
7655 ///
7656 /// C++ [expr.ref]p7:
7657 ///
7658 /// If E2 is a non-static data member or a non-static member function, the
7659 /// program is ill-formed if the class of which E2 is directly a member is
7660 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7661 ///
7662 /// Note that the latter check does not consider access; the access of the
7663 /// "real" base class is checked as appropriate when checking the access of
7664 /// the member name.
7666 NestedNameSpecifier Qualifier,
7667 NamedDecl *FoundDecl,
7668 NamedDecl *Member);
7669
7670 /// CheckCallReturnType - Checks that a call expression's return type is
7671 /// complete. Returns true on failure. The location passed in is the location
7672 /// that best represents the call.
7673 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
7674 CallExpr *CE, FunctionDecl *FD);
7675
7676 /// Emit a warning for all pending noderef expressions that we recorded.
7677 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
7678
7680
7681 /// Instantiate or parse a C++ default argument expression as necessary.
7682 /// Return true on error.
7684 ParmVarDecl *Param, Expr *Init = nullptr,
7685 bool SkipImmediateInvocations = true);
7686
7687 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7688 /// the default expr if needed.
7690 ParmVarDecl *Param, Expr *Init = nullptr);
7691
7692 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7693 /// invocation.
7695
7697
7698 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7699 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7700
7701 /// Abstract base class used for diagnosing integer constant
7702 /// expression violations.
7704 public:
7706
7708
7709 virtual SemaDiagnosticBuilder
7710 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7712 SourceLocation Loc) = 0;
7715 };
7716
7717 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7718 /// and reports the appropriate diagnostics. Returns false on success.
7719 /// Can optionally return the value of the expression.
7722 VerifyICEDiagnoser &Diagnoser,
7726 unsigned DiagID,
7729 VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result = nullptr,
7733 AllowFoldKind CanFold = AllowFoldKind::No) {
7734 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7735 }
7736
7737 /// DiagnoseAssignmentAsCondition - Given that an expression is
7738 /// being used as a boolean condition, warn if it's an assignment.
7740
7741 /// Redundant parentheses over an equality comparison can indicate
7742 /// that the user intended an assignment used as condition.
7744
7746 public:
7748 FullExprArg(Sema &actions) : E(nullptr) {}
7749
7750 ExprResult release() { return E; }
7751
7752 Expr *get() const { return E; }
7753
7754 Expr *operator->() { return E; }
7755
7756 private:
7757 // FIXME: No need to make the entire Sema class a friend when it's just
7758 // Sema::MakeFullExpr that needs access to the constructor below.
7759 friend class Sema;
7760
7761 explicit FullExprArg(Expr *expr) : E(expr) {}
7762
7763 Expr *E;
7764 };
7765
7767 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7768 }
7770 return FullExprArg(
7771 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7772 }
7774 ExprResult FE =
7775 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7776 /*DiscardedValue*/ true);
7777 return FullExprArg(FE.get());
7778 }
7779
7780 class ConditionResult {
7781 Decl *ConditionVar;
7782 ExprResult Condition;
7783 bool Invalid;
7784 std::optional<bool> KnownValue;
7785
7786 friend class Sema;
7787 ConditionResult(Sema &S, Decl *ConditionVar, ExprResult Condition,
7788 bool IsConstexpr)
7789 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7790 if (IsConstexpr && Condition.get()) {
7791 if (std::optional<llvm::APSInt> Val =
7792 Condition.get()->getIntegerConstantExpr(S.Context)) {
7793 KnownValue = !!(*Val);
7794 }
7795 }
7796 }
7797 explicit ConditionResult(bool Invalid)
7798 : ConditionVar(nullptr), Condition(Invalid), Invalid(Invalid),
7799 KnownValue(std::nullopt) {}
7800
7801 public:
7802 ConditionResult() : ConditionResult(false) {}
7803 bool isInvalid() const { return Invalid; }
7804 std::pair<VarDecl *, Expr *> get() const {
7805 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7806 Condition.get());
7807 }
7808 std::optional<bool> getKnownValue() const { return KnownValue; }
7809 };
7811
7812 /// CheckBooleanCondition - Diagnose problems involving the use of
7813 /// the given expression as a boolean condition (e.g. in an if
7814 /// statement). Also performs the standard function and array
7815 /// decays, possibly changing the input variable.
7816 ///
7817 /// \param Loc - A location associated with the condition, e.g. the
7818 /// 'if' keyword.
7819 /// \return true iff there were any errors
7821 bool IsConstexpr = false);
7822
7823 enum class ConditionKind {
7824 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7825 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7826 Switch ///< An integral condition for a 'switch' statement.
7827 };
7828
7829 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7830 ConditionKind CK, bool MissingOK = false);
7831
7832 QualType CheckConditionalOperands( // C99 6.5.15
7834 ExprObjectKind &OK, SourceLocation QuestionLoc);
7835
7836 /// Emit a specialized diagnostic when one expression is a null pointer
7837 /// constant and the other is not a pointer. Returns true if a diagnostic is
7838 /// emitted.
7839 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7840 SourceLocation QuestionLoc);
7841
7842 /// type checking for vector binary operators.
7844 SourceLocation Loc, bool IsCompAssign,
7845 bool AllowBothBool, bool AllowBoolConversion,
7846 bool AllowBoolOperation, bool ReportInvalid);
7847
7848 /// Return a signed ext_vector_type that is of identical size and number of
7849 /// elements. For floating point vectors, return an integer type of identical
7850 /// size and number of elements. In the non ext_vector_type case, search from
7851 /// the largest type to the smallest type to avoid cases where long long ==
7852 /// long, where long gets picked over long long.
7855
7856 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7857 /// operates on extended vector types. Instead of producing an IntTy result,
7858 /// like a scalar comparison, a vector comparison produces a vector of integer
7859 /// types.
7861 SourceLocation Loc,
7862 BinaryOperatorKind Opc);
7864 SourceLocation Loc,
7865 BinaryOperatorKind Opc);
7867 SourceLocation Loc,
7868 BinaryOperatorKind Opc);
7869
7870 // type checking for sizeless vector binary operators.
7872 SourceLocation Loc, bool IsCompAssign,
7873 ArithConvKind OperationKind);
7874
7875 /// Type checking for matrix binary operators.
7877 SourceLocation Loc,
7878 bool IsCompAssign);
7880 SourceLocation Loc, bool IsCompAssign);
7881
7882 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
7883 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
7884 /// VLST) allowed?
7885 ///
7886 /// This will also return false if the two given types do not make sense from
7887 /// the perspective of SVE bitcasts.
7888 bool isValidSveBitcast(QualType srcType, QualType destType);
7889
7890 /// Are the two types matrix types and do they have the same dimensions i.e.
7891 /// do they have the same number of rows and the same number of columns?
7893
7894 bool areVectorTypesSameSize(QualType srcType, QualType destType);
7895
7896 /// Are the two types lax-compatible vector types? That is, given
7897 /// that one of them is a vector, do they have equal storage sizes,
7898 /// where the storage size is the number of elements times the element
7899 /// size?
7900 ///
7901 /// This will also return false if either of the types is neither a
7902 /// vector nor a real type.
7903 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
7904
7905 /// Is this a legal conversion between two types, one of which is
7906 /// known to be a vector type?
7907 bool isLaxVectorConversion(QualType srcType, QualType destType);
7908
7909 // This returns true if at least one of the types is an altivec vector.
7910 bool anyAltivecTypes(QualType srcType, QualType destType);
7911
7912 // type checking C++ declaration initializers (C++ [dcl.init]).
7913
7914 /// Check a cast of an unknown-any type. We intentionally only
7915 /// trigger this for C-style casts.
7918 ExprValueKind &VK, CXXCastPath &Path);
7919
7920 /// Force an expression with unknown-type to an expression of the
7921 /// given type.
7923
7924 /// Type-check an expression that's being passed to an
7925 /// __unknown_anytype parameter.
7927 QualType &paramType);
7928
7929 // CheckMatrixCast - Check type constraints for matrix casts.
7930 // We allow casting between matrixes of the same dimensions i.e. when they
7931 // have the same number of rows and column. Returns true if the cast is
7932 // invalid.
7933 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
7934 CastKind &Kind);
7935
7936 // CheckVectorCast - check type constraints for vectors.
7937 // Since vectors are an extension, there are no C standard reference for this.
7938 // We allow casting between vectors and integer datatypes of the same size.
7939 // returns true if the cast is invalid
7940 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
7941 CastKind &Kind);
7942
7943 /// Prepare `SplattedExpr` for a vector splat operation, adding
7944 /// implicit casts if necessary.
7945 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
7946
7947 /// Prepare `SplattedExpr` for a matrix splat operation, adding
7948 /// implicit casts if necessary.
7949 ExprResult prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr);
7950
7951 // CheckExtVectorCast - check type constraints for extended vectors.
7952 // Since vectors are an extension, there are no C standard reference for this.
7953 // We allow casting between vectors and integer datatypes of the same size,
7954 // or vectors and the element type of that vector.
7955 // returns the cast expr
7957 CastKind &Kind);
7958
7960 return K == ConditionKind::Switch ? Context.IntTy : Context.BoolTy;
7961 }
7962
7963 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2), converts
7964 // functions and arrays to their respective pointers (C99 6.3.2.1), and
7965 // promotes floating-piont types according to the language semantics.
7967
7968 // UsualUnaryFPConversions - promotes floating-point types according to the
7969 // current language semantics.
7971
7972 /// CallExprUnaryConversions - a special case of an unary conversion
7973 /// performed on a function designator of a call expression.
7975
7976 // DefaultFunctionArrayConversion - converts functions and arrays
7977 // to their respective pointers (C99 6.3.2.1).
7979
7980 // DefaultFunctionArrayLvalueConversion - converts functions and
7981 // arrays to their respective pointers and performs the
7982 // lvalue-to-rvalue conversion.
7984 bool Diagnose = true);
7985
7986 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
7987 // the operand. This function is a no-op if the operand has a function type
7988 // or an array type.
7990
7991 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
7992 // do not have a prototype. Integer promotions are performed on each
7993 // argument, and arguments that have type float are promoted to double.
7995
7997 const FunctionProtoType *Proto,
7998 Expr *Fn);
7999
8000 /// Determine the degree of POD-ness for an expression.
8001 /// Incomplete types are considered POD, since this check can be performed
8002 /// when we're in an unevaluated context.
8004
8005 /// Check to see if the given expression is a valid argument to a variadic
8006 /// function, issuing a diagnostic if not.
8007 void checkVariadicArgument(const Expr *E, VariadicCallType CT);
8008
8009 /// GatherArgumentsForCall - Collector argument expressions for various
8010 /// form of call prototypes.
8012 SourceLocation CallLoc, FunctionDecl *FDecl,
8013 const FunctionProtoType *Proto, unsigned FirstParam,
8016 bool AllowExplicit = false, bool IsListInitialization = false);
8017
8018 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
8019 // will create a runtime trap if the resulting type is not a POD type.
8021 FunctionDecl *FDecl);
8022
8023 // Check that the usual arithmetic conversions can be performed on this pair
8024 // of expressions that might be of enumeration type.
8026 ArithConvKind ACK);
8027
8028 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
8029 // operands and then handles various conversions that are common to binary
8030 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
8031 // routine returns the first non-arithmetic type found. The client is
8032 // responsible for emitting appropriate error diagnostics.
8034 SourceLocation Loc, ArithConvKind ACK);
8035
8037 switch (ConvTy) {
8038 default:
8039 return false;
8043 return true;
8044 }
8045 llvm_unreachable("impossible");
8046 }
8047
8048 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
8049 /// assignment conversion type specified by ConvTy. This returns true if the
8050 /// conversion was invalid or false if the conversion was accepted.
8052 QualType DstType, QualType SrcType,
8053 Expr *SrcExpr, AssignmentAction Action,
8054 bool *Complained = nullptr);
8055
8056 /// CheckAssignmentConstraints - Perform type checking for assignment,
8057 /// argument passing, variable initialization, and function return values.
8058 /// C99 6.5.16.
8060 QualType LHSType,
8061 QualType RHSType);
8062
8063 /// Check assignment constraints and optionally prepare for a conversion of
8064 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
8065 /// is true.
8067 ExprResult &RHS, CastKind &Kind,
8068 bool ConvertRHS = true);
8069
8070 /// Check assignment constraints for an assignment of RHS to LHSType.
8071 ///
8072 /// \param LHSType The destination type for the assignment.
8073 /// \param RHS The source expression for the assignment.
8074 /// \param Diagnose If \c true, diagnostics may be produced when checking
8075 /// for assignability. If a diagnostic is produced, \p RHS will be
8076 /// set to ExprError(). Note that this function may still return
8077 /// without producing a diagnostic, even for an invalid assignment.
8078 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
8079 /// in an audited Core Foundation API and does not need to be checked
8080 /// for ARC retain issues.
8081 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
8082 /// conversions necessary to perform the assignment. If \c false,
8083 /// \p Diagnose must also be \c false.
8085 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
8086 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
8087
8088 // If the lhs type is a transparent union, check whether we
8089 // can initialize the transparent union with the given expression.
8091 ExprResult &RHS);
8092
8093 /// the following "Check" methods will return a valid/converted QualType
8094 /// or a null QualType (indicating an error diagnostic was issued).
8095
8096 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
8098 ExprResult &RHS);
8099
8100 /// Diagnose cases where a scalar was implicitly converted to a vector and
8101 /// diagnose the underlying types. Otherwise, diagnose the error
8102 /// as invalid vector logical operands for non-C++ cases.
8104 ExprResult &RHS);
8105
8107 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8108 BinaryOperatorKind Opc);
8109 QualType CheckRemainderOperands( // C99 6.5.5
8110 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8111 bool IsCompAssign = false);
8112 QualType CheckAdditionOperands( // C99 6.5.6
8113 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8114 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8116 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8117 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8118 QualType CheckShiftOperands( // C99 6.5.7
8119 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8120 BinaryOperatorKind Opc, bool IsCompAssign = false);
8122 QualType CheckCompareOperands( // C99 6.5.8/9
8123 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8124 BinaryOperatorKind Opc);
8125 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
8126 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8127 BinaryOperatorKind Opc);
8128 QualType CheckLogicalOperands( // C99 6.5.[13,14]
8129 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8130 BinaryOperatorKind Opc);
8131 // CheckAssignmentOperands is used for both simple and compound assignment.
8132 // For simple assignment, pass both expressions and a null converted type.
8133 // For compound assignment, pass both expressions and the converted type.
8134 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
8135 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
8136 BinaryOperatorKind Opc);
8137
8138 /// To be used for checking whether the arguments being passed to
8139 /// function exceeds the number of parameters expected for it.
8140 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
8141 bool PartialOverloading = false) {
8142 // We check whether we're just after a comma in code-completion.
8143 if (NumArgs > 0 && PartialOverloading)
8144 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
8145 return NumArgs > NumParams;
8146 }
8147
8148 /// Whether the AST is currently being rebuilt to correct immediate
8149 /// invocations. Immediate invocation candidates and references to consteval
8150 /// functions aren't tracked when this is set.
8152
8158
8159 /// Determines whether we are currently in a context that
8160 /// is not evaluated as per C++ [expr] p5.
8163 }
8164
8168
8172
8176
8183
8184 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8186 assert(!ExprEvalContexts.empty() &&
8187 "Must be in an expression evaluation context");
8188 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8190 Ctx.DelayedDefaultInitializationContext)
8191 return Ctx.DelayedDefaultInitializationContext;
8192 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8193 Ctx.isUnevaluated())
8194 break;
8195 }
8196 return std::nullopt;
8197 }
8198
8199 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8201 assert(!ExprEvalContexts.empty() &&
8202 "Must be in an expression evaluation context");
8203 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
8204 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8206 !Ctx.DelayedDefaultInitializationContext && Res)
8207 break;
8208 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8209 Ctx.isUnevaluated())
8210 break;
8211 Res = Ctx.DelayedDefaultInitializationContext;
8212 }
8213 return Res;
8214 }
8215
8219
8220 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
8221 /// SelfAssigned when inside a CXXMethodDecl.
8222 const FieldDecl *
8224
8226
8227 template <typename... Ts>
8229 const Ts &...Args) {
8230 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8231 return RequireCompleteType(Loc, T, CompleteTypeKind::Normal, Diagnoser);
8232 }
8233
8234 template <typename... Ts>
8235 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
8236 const Ts &...Args) {
8237 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8239 }
8240
8241 /// Abstract class used to diagnose incomplete types.
8244
8245 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
8246 virtual ~TypeDiagnoser() {}
8247 };
8248
8249 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
8250 protected:
8251 unsigned DiagID;
8252 std::tuple<const Ts &...> Args;
8253
8254 template <std::size_t... Is>
8256 std::index_sequence<Is...>) const {
8257 // Apply all tuple elements to the builder in order.
8258 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
8259 (void)Dummy;
8260 }
8261
8262 public:
8263 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8264 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
8265 assert(DiagID != 0 && "no diagnostic for type diagnoser");
8266 }
8267
8268 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8269 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
8270 emit(DB, std::index_sequence_for<Ts...>());
8271 DB << T;
8272 }
8273 };
8274
8275 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
8276 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
8277 /// For example, a diagnostic with no other parameters would generally have
8278 /// the form "...%select{incomplete|sizeless}0 type %1...".
8279 template <typename... Ts>
8281 public:
8282 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8283 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
8284
8285 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8286 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
8287 this->emit(DB, std::index_sequence_for<Ts...>());
8288 DB << T->isSizelessType() << T;
8289 }
8290 };
8291
8292 /// Check an argument list for placeholders that we won't try to
8293 /// handle later.
8295
8296 /// The C++ "std::source_location::__impl" struct, defined in
8297 /// <source_location>.
8299
8300 /// A stack of expression evaluation contexts.
8302
8303 // Set of failed immediate invocations to avoid double diagnosing.
8305
8306 /// List of SourceLocations where 'self' is implicitly retained inside a
8307 /// block.
8310
8311 /// Do an explicit extend of the given block pointer if we're in ARC.
8313
8314 std::vector<std::pair<QualType, unsigned>> ExcessPrecisionNotSatisfied;
8317
8318private:
8319 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
8320
8321 /// Methods for marking which expressions involve dereferencing a pointer
8322 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
8323 /// they are parsed, meaning that a noderef pointer may not be accessed. For
8324 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
8325 /// `*p`, but need to check that `address of` is called on it. This requires
8326 /// keeping a container of all pending expressions and checking if the address
8327 /// of them are eventually taken.
8328 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
8329 void CheckAddressOfNoDeref(const Expr *E);
8330
8331 ///@}
8332
8333 //
8334 //
8335 // -------------------------------------------------------------------------
8336 //
8337 //
8338
8339 /// \name C++ Expressions
8340 /// Implementations are in SemaExprCXX.cpp
8341 ///@{
8342
8343public:
8344 /// The C++ "std::bad_alloc" class, which is defined by the C++
8345 /// standard library.
8347
8348 /// The C++ "std::align_val_t" enum class, which is defined by the C++
8349 /// standard library.
8351
8352 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
8354
8355 /// A flag to remember whether the implicit forms of operator new and delete
8356 /// have been declared.
8358
8359 /// Delete-expressions to be analyzed at the end of translation unit
8360 ///
8361 /// This list contains class members, and locations of delete-expressions
8362 /// that could not be proven as to whether they mismatch with new-expression
8363 /// used in initializer of the field.
8364 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
8365
8366 /// Handle the result of the special case name lookup for inheriting
8367 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
8368 /// constructor names in member using declarations, even if 'X' is not the
8369 /// name of the corresponding type.
8371 SourceLocation NameLoc,
8372 const IdentifierInfo &Name);
8373
8375 SourceLocation NameLoc, Scope *S,
8376 CXXScopeSpec &SS, bool EnteringContext);
8378 Scope *S, CXXScopeSpec &SS,
8379 ParsedType ObjectType, bool EnteringContext);
8380
8382 ParsedType ObjectType);
8383
8384 /// Build a C++ typeid expression with a type operand.
8385 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8386 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8387
8388 /// Build a C++ typeid expression with an expression operand.
8389 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8390 Expr *Operand, SourceLocation RParenLoc);
8391
8392 /// ActOnCXXTypeid - Parse typeid( something ).
8394 bool isType, void *TyOrExpr,
8395 SourceLocation RParenLoc);
8396
8397 /// Build a Microsoft __uuidof expression with a type operand.
8398 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8399 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8400
8401 /// Build a Microsoft __uuidof expression with an expression operand.
8402 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8403 Expr *Operand, SourceLocation RParenLoc);
8404
8405 /// ActOnCXXUuidof - Parse __uuidof( something ).
8407 bool isType, void *TyOrExpr,
8408 SourceLocation RParenLoc);
8409
8410 //// ActOnCXXThis - Parse 'this' pointer.
8412
8413 /// Check whether the type of 'this' is valid in the current context.
8415
8416 /// Build a CXXThisExpr and mark it referenced in the current context.
8417 Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
8419
8420 /// Try to retrieve the type of the 'this' pointer.
8421 ///
8422 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8424
8425 /// When non-NULL, the C++ 'this' expression is allowed despite the
8426 /// current context not being a non-static member function. In such cases,
8427 /// this provides the type used for 'this'.
8429
8430 /// RAII object used to temporarily allow the C++ 'this' expression
8431 /// to be used, with the given qualifiers on the current class type.
8433 Sema &S;
8434 QualType OldCXXThisTypeOverride;
8435 bool Enabled;
8436
8437 public:
8438 /// Introduce a new scope where 'this' may be allowed (when enabled),
8439 /// using the given declaration (which is either a class template or a
8440 /// class) along with the given qualifiers.
8441 /// along with the qualifiers placed on '*this'.
8442 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8443 bool Enabled = true);
8444
8446 };
8447
8448 /// Make sure the value of 'this' is actually available in the current
8449 /// context, if it is a potentially evaluated context.
8450 ///
8451 /// \param Loc The location at which the capture of 'this' occurs.
8452 ///
8453 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8454 /// capture list.
8455 ///
8456 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8457 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8458 /// This is useful when enclosing lambdas must speculatively capture
8459 /// 'this' that may or may not be used in certain specializations of
8460 /// a nested generic lambda (depending on whether the name resolves to
8461 /// a non-static member function or a static function).
8462 /// \return returns 'true' if failed, 'false' if success.
8464 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8465 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8466 bool ByCopy = false);
8467
8468 /// Determine whether the given type is the type of *this that is used
8469 /// outside of the body of a member function for a type that is currently
8470 /// being defined.
8472
8473 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8475
8476 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8478
8479 //// ActOnCXXThrow - Parse throw expressions.
8482 bool IsThrownVarInScope);
8483
8484 /// CheckCXXThrowOperand - Validate the operand of a throw.
8485 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8486
8487 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8488 /// Can be interpreted either as function-style casting ("int(x)")
8489 /// or class type construction ("ClassType(x,y,z)")
8490 /// or creation of a value-initialized type ("int()").
8492 SourceLocation LParenOrBraceLoc,
8493 MultiExprArg Exprs,
8494 SourceLocation RParenOrBraceLoc,
8495 bool ListInitialization);
8496
8498 SourceLocation LParenLoc,
8499 MultiExprArg Exprs,
8500 SourceLocation RParenLoc,
8501 bool ListInitialization);
8502
8503 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8504 ///
8505 /// E.g.:
8506 /// @code new (memory) int[size][4] @endcode
8507 /// or
8508 /// @code ::new Foo(23, "hello") @endcode
8509 ///
8510 /// \param StartLoc The first location of the expression.
8511 /// \param UseGlobal True if 'new' was prefixed with '::'.
8512 /// \param PlacementLParen Opening paren of the placement arguments.
8513 /// \param PlacementArgs Placement new arguments.
8514 /// \param PlacementRParen Closing paren of the placement arguments.
8515 /// \param TypeIdParens If the type is in parens, the source range.
8516 /// \param D The type to be allocated, as well as array dimensions.
8517 /// \param Initializer The initializing expression or initializer-list, or
8518 /// null if there is none.
8519 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8520 SourceLocation PlacementLParen,
8521 MultiExprArg PlacementArgs,
8522 SourceLocation PlacementRParen,
8523 SourceRange TypeIdParens, Declarator &D,
8524 Expr *Initializer);
8526 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8527 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8528 SourceRange TypeIdParens, QualType AllocType,
8529 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8530 SourceRange DirectInitRange, Expr *Initializer);
8531
8532 /// Determine whether \p FD is an aligned allocation or deallocation
8533 /// function that is unavailable.
8535
8536 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8537 /// function that is unavailable.
8539 SourceLocation Loc);
8540
8541 /// Checks that a type is suitable as the allocated type
8542 /// in a new-expression.
8543 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
8544 SourceRange R);
8545
8546 /// Finds the overloads of operator new and delete that are appropriate
8547 /// for the allocation.
8549 SourceLocation StartLoc, SourceRange Range,
8551 QualType AllocType, bool IsArray, ImplicitAllocationParameters &IAP,
8552 MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew,
8553 FunctionDecl *&OperatorDelete, bool Diagnose = true);
8554
8555 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8556 /// delete. These are:
8557 /// @code
8558 /// // C++03:
8559 /// void* operator new(std::size_t) throw(std::bad_alloc);
8560 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8561 /// void operator delete(void *) throw();
8562 /// void operator delete[](void *) throw();
8563 /// // C++11:
8564 /// void* operator new(std::size_t);
8565 /// void* operator new[](std::size_t);
8566 /// void operator delete(void *) noexcept;
8567 /// void operator delete[](void *) noexcept;
8568 /// // C++1y:
8569 /// void* operator new(std::size_t);
8570 /// void* operator new[](std::size_t);
8571 /// void operator delete(void *) noexcept;
8572 /// void operator delete[](void *) noexcept;
8573 /// void operator delete(void *, std::size_t) noexcept;
8574 /// void operator delete[](void *, std::size_t) noexcept;
8575 /// @endcode
8576 /// Note that the placement and nothrow forms of new are *not* implicitly
8577 /// declared. Their use requires including <new>.
8580 ArrayRef<QualType> Params);
8581
8583 DeclarationName Name, FunctionDecl *&Operator,
8585 bool Diagnose = true);
8588 DeclarationName Name,
8589 bool Diagnose = true);
8591 CXXRecordDecl *RD,
8592 bool Diagnose,
8593 bool LookForGlobal,
8594 DeclarationName Name);
8595
8596 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8597 /// @code ::delete ptr; @endcode
8598 /// or
8599 /// @code delete [] ptr; @endcode
8600 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8601 bool ArrayForm, Expr *Operand);
8603 bool IsDelete, bool CallCanBeVirtual,
8604 bool WarnOnNonAbstractTypes,
8605 SourceLocation DtorLoc);
8606
8608 Expr *Operand, SourceLocation RParen);
8610 SourceLocation RParen);
8611
8613 SourceLocation OpLoc,
8614 tok::TokenKind OpKind,
8615 ParsedType &ObjectType,
8616 bool &MayBePseudoDestructor);
8617
8619 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8620 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8621 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8622
8624 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8625 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8626 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8627
8629 SourceLocation OpLoc,
8630 tok::TokenKind OpKind,
8631 SourceLocation TildeLoc,
8632 const DeclSpec &DS);
8633
8634 /// MaybeCreateExprWithCleanups - If the current full-expression
8635 /// requires any cleanups, surround it with a ExprWithCleanups node.
8636 /// Otherwise, just returns the passed-in expression.
8640
8641 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8642 return ActOnFinishFullExpr(
8643 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8644 }
8646 bool DiscardedValue, bool IsConstexpr = false,
8647 bool IsTemplateArgument = false);
8649
8650 /// Process the expression contained within a decltype. For such expressions,
8651 /// certain semantic checks on temporaries are delayed until this point, and
8652 /// are omitted for the 'topmost' call in the decltype expression. If the
8653 /// topmost call bound a temporary, strip that temporary off the expression.
8655
8656 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8657 bool IsUDSuffix);
8658
8660
8661 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8662 SourceLocation StmtLoc,
8663 ConditionKind CK);
8664
8665 /// Check the use of the given variable as a C++ condition in an if,
8666 /// while, do-while, or switch statement.
8668 SourceLocation StmtLoc, ConditionKind CK);
8669
8670 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8671 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8672
8673 /// Helper function to determine whether this is the (deprecated) C++
8674 /// conversion from a string literal to a pointer to non-const char or
8675 /// non-const wchar_t (for narrow and wide string literals,
8676 /// respectively).
8678
8679 /// PerformImplicitConversion - Perform an implicit conversion of the
8680 /// expression From to the type ToType using the pre-computed implicit
8681 /// conversion sequence ICS. Returns the converted
8682 /// expression. Action is the kind of conversion we're performing,
8683 /// used in the error message.
8685 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8686 AssignmentAction Action,
8688
8689 /// PerformImplicitConversion - Perform an implicit conversion of the
8690 /// expression From to the type ToType by following the standard
8691 /// conversion sequence SCS. Returns the converted
8692 /// expression. Flavor is the context in which we're performing this
8693 /// conversion, for use in error messages.
8695 const StandardConversionSequence &SCS,
8696 AssignmentAction Action,
8698
8699 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8700
8701 /// Parsed one of the type trait support pseudo-functions.
8704 SourceLocation RParenLoc);
8707 SourceLocation RParenLoc);
8708
8709 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8710 /// pseudo-functions.
8712 ParsedType LhsTy, Expr *DimExpr,
8713 SourceLocation RParen);
8714
8716 TypeSourceInfo *TSInfo, Expr *DimExpr,
8717 SourceLocation RParen);
8718
8719 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8720 /// pseudo-functions.
8722 Expr *Queried, SourceLocation RParen);
8723
8725 Expr *Queried, SourceLocation RParen);
8726
8729 bool isIndirect);
8731 ExprResult &RHS,
8732 SourceLocation QuestionLoc);
8733
8734 //// Determines if a type is trivially relocatable
8735 /// according to the C++26 rules.
8736 // FIXME: This is in Sema because it requires
8737 // overload resolution, can we move to ASTContext?
8740
8741 /// Check the operands of ?: under C++ semantics.
8742 ///
8743 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8744 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8745 ///
8746 /// This function also implements GCC's vector extension and the
8747 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8748 /// permit the use of a?b:c where the type of a is that of a integer vector
8749 /// with the same number of elements and size as the vectors of b and c. If
8750 /// one of either b or c is a scalar it is implicitly converted to match the
8751 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8752 /// c are scalars, then b and c are checked and converted to the type of a if
8753 /// possible.
8754 ///
8755 /// The expressions are evaluated differently for GCC's and OpenCL's
8756 /// extensions. For the GCC extension, the ?: operator is evaluated as
8757 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8758 /// For the OpenCL extensions, the ?: operator is evaluated as
8759 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8760 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8762 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8763 ExprObjectKind &OK, SourceLocation questionLoc);
8764
8765 /// Find a merged pointer type and convert the two expressions to it.
8766 ///
8767 /// This finds the composite pointer type for \p E1 and \p E2 according to
8768 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8769 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8770 /// ConvertArgs is \c true).
8771 ///
8772 /// \param Loc The location of the operator requiring these two expressions to
8773 /// be converted to the composite pointer type.
8774 ///
8775 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8776 /// type.
8778 bool ConvertArgs = true);
8780 ExprResult &E2, bool ConvertArgs = true) {
8781 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8782 QualType Composite =
8783 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8784 E1 = E1Tmp;
8785 E2 = E2Tmp;
8786 return Composite;
8787 }
8788
8789 /// MaybeBindToTemporary - If the passed in expression has a record type with
8790 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8791 /// it simply returns the passed in expression.
8793
8794 /// IgnoredValueConversions - Given that an expression's result is
8795 /// syntactically ignored, perform any conversions that are
8796 /// required.
8798
8800
8803 const DeclarationNameInfo &TargetNameInfo);
8804
8806 SourceLocation KeywordLoc,
8807 bool IsIfExists, CXXScopeSpec &SS,
8808 UnqualifiedId &Name);
8809
8812 ArrayRef<ParmVarDecl *> LocalParameters,
8813 Scope *BodyScope);
8817 CXXScopeSpec &SS,
8818 SourceLocation NameLoc,
8819 const IdentifierInfo *TypeName,
8820 TemplateIdAnnotation *TemplateId);
8822 SourceLocation NoexceptLoc);
8824 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8825 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8828 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8832 bool IsSatisfied, SourceLocation NoexceptLoc,
8839 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8840 const ASTConstraintSatisfaction &Satisfaction);
8843 SourceLocation LParenLoc,
8844 ArrayRef<ParmVarDecl *> LocalParameters,
8845 SourceLocation RParenLoc,
8847 SourceLocation ClosingBraceLoc);
8848
8849private:
8850 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8851 bool IsDelete);
8852
8853 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8854 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8855 bool DeleteWasArrayForm);
8856
8857 ///@}
8858
8859 //
8860 //
8861 // -------------------------------------------------------------------------
8862 //
8863 //
8864
8865 /// \name Member Access Expressions
8866 /// Implementations are in SemaExprMember.cpp
8867 ///@{
8868
8869public:
8870 /// Check whether an expression might be an implicit class member access.
8872 bool IsAddressOfOperand);
8873
8874 /// Builds an expression which might be an implicit member expression.
8876 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
8877 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
8878
8879 /// Builds an implicit member access expression. The current context
8880 /// is known to be an instance method, and the given unqualified lookup
8881 /// set is known to contain only instance members, at least one of which
8882 /// is from an appropriate type.
8884 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8885 LookupResult &R,
8886 const TemplateArgumentListInfo *TemplateArgs,
8887 bool IsDefiniteInstance, const Scope *S);
8888
8890 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
8891 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8892 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8893 const TemplateArgumentListInfo *TemplateArgs);
8894
8895 /// The main callback when the parser finds something like
8896 /// expression . [nested-name-specifier] identifier
8897 /// expression -> [nested-name-specifier] identifier
8898 /// where 'identifier' encompasses a fairly broad spectrum of
8899 /// possibilities, including destructor and operator references.
8900 ///
8901 /// \param OpKind either tok::arrow or tok::period
8902 /// \param ObjCImpDecl the current Objective-C \@implementation
8903 /// decl; this is an ugly hack around the fact that Objective-C
8904 /// \@implementations aren't properly put in the context chain
8906 tok::TokenKind OpKind, CXXScopeSpec &SS,
8907 SourceLocation TemplateKWLoc,
8908 UnqualifiedId &Member, Decl *ObjCImpDecl);
8909
8910 MemberExpr *
8911 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
8912 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
8913 ValueDecl *Member, DeclAccessPair FoundDecl,
8914 bool HadMultipleCandidates,
8915 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
8917 const TemplateArgumentListInfo *TemplateArgs = nullptr);
8918
8919 // Check whether the declarations we found through a nested-name
8920 // specifier in a member expression are actually members of the base
8921 // type. The restriction here is:
8922 //
8923 // C++ [expr.ref]p2:
8924 // ... In these cases, the id-expression shall name a
8925 // member of the class or of one of its base classes.
8926 //
8927 // So it's perfectly legitimate for the nested-name specifier to name
8928 // an unrelated class, and for us to find an overload set including
8929 // decls from classes which are not superclasses, as long as the decl
8930 // we actually pick through overload resolution is from a superclass.
8931 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
8932 const CXXScopeSpec &SS,
8933 const LookupResult &R);
8934
8935 // This struct is for use by ActOnMemberAccess to allow
8936 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
8937 // changing the access operator from a '.' to a '->' (to see if that is the
8938 // change needed to fix an error about an unknown member, e.g. when the class
8939 // defines a custom operator->).
8945
8947 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
8948 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8949 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8950 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
8951 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8952
8955 bool IsArrow, const CXXScopeSpec &SS,
8956 SourceLocation TemplateKWLoc,
8957 NamedDecl *FirstQualifierInScope, LookupResult &R,
8958 const TemplateArgumentListInfo *TemplateArgs,
8959 const Scope *S, bool SuppressQualifierCheck = false,
8960 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8961
8962 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
8963 SourceLocation OpLoc,
8964 const CXXScopeSpec &SS, FieldDecl *Field,
8965 DeclAccessPair FoundDecl,
8966 const DeclarationNameInfo &MemberNameInfo);
8967
8968 /// Perform conversions on the LHS of a member access expression.
8970
8972 const CXXScopeSpec &SS, SourceLocation nameLoc,
8973 IndirectFieldDecl *indirectField,
8974 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
8975 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
8976
8977private:
8978 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
8979
8980 ///@}
8981
8982 //
8983 //
8984 // -------------------------------------------------------------------------
8985 //
8986 //
8987
8988 /// \name Initializers
8989 /// Implementations are in SemaInit.cpp
8990 ///@{
8991
8992public:
8993 /// Stack of types that correspond to the parameter entities that are
8994 /// currently being copy-initialized. Can be empty.
8996
8997 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
8999
9000 bool IsStringInit(Expr *Init, const ArrayType *AT);
9001
9002 /// Determine whether we can perform aggregate initialization for the purposes
9003 /// of overload resolution.
9005 const InitializedEntity &Entity, InitListExpr *From);
9006
9008 SourceLocation EqualOrColonLoc,
9009 bool GNUSyntax, ExprResult Init);
9010
9011 /// Check that the lifetime of the initializer (and its subobjects) is
9012 /// sufficient for initializing the entity, and perform lifetime extension
9013 /// (when permitted) if not.
9015
9018 bool BoundToLvalueReference);
9019
9020 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
9021 /// it as an xvalue. In C++98, the result will still be a prvalue, because
9022 /// we don't have xvalues there.
9024
9028
9032 SourceLocation EqualLoc, ExprResult Init,
9033 bool TopLevelOfInitList = false,
9034 bool AllowExplicit = false);
9035
9037 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
9038 const InitializationKind &Kind, MultiExprArg Init);
9039
9040 ///@}
9041
9042 //
9043 //
9044 // -------------------------------------------------------------------------
9045 //
9046 //
9047
9048 /// \name C++ Lambda Expressions
9049 /// Implementations are in SemaLambda.cpp
9050 ///@{
9051
9052public:
9053 /// Create a new lambda closure type.
9055 TypeSourceInfo *Info,
9056 unsigned LambdaDependencyKind,
9057 LambdaCaptureDefault CaptureDefault);
9058
9059 /// Number lambda for linkage purposes if necessary.
9061 std::optional<CXXRecordDecl::LambdaNumbering>
9062 NumberingOverride = std::nullopt);
9063
9064 /// Endow the lambda scope info with the relevant properties.
9065 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
9066 SourceRange IntroducerRange,
9067 LambdaCaptureDefault CaptureDefault,
9068 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
9069 bool Mutable);
9070
9073
9075 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
9076 TemplateParameterList *TemplateParams);
9077
9078 void
9080 SourceLocation CallOperatorLoc,
9081 const AssociatedConstraint &TrailingRequiresClause,
9082 TypeSourceInfo *MethodTyInfo,
9083 ConstexprSpecKind ConstexprKind, StorageClass SC,
9085 bool HasExplicitResultType);
9086
9087 /// Returns true if the explicit object parameter was invalid.
9089 SourceLocation CallLoc);
9090
9091 /// Perform initialization analysis of the init-capture and perform
9092 /// any implicit conversions such as an lvalue-to-rvalue conversion if
9093 /// not being used to initialize a reference.
9095 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
9096 IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init) {
9098 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
9100 }
9102 SourceLocation EllipsisLoc,
9103 UnsignedOrNone NumExpansions,
9104 IdentifierInfo *Id,
9105 bool DirectInit, Expr *&Init);
9106
9107 /// Create a dummy variable within the declcontext of the lambda's
9108 /// call operator, for name lookup purposes for a lambda init capture.
9109 ///
9110 /// CodeGen handles emission of lambda captures, ignoring these dummy
9111 /// variables appropriately.
9113 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
9114 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
9115
9116 /// Add an init-capture to a lambda scope.
9117 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
9118
9119 /// Note that we have finished the explicit captures for the
9120 /// given lambda.
9122
9123 /// Deduce a block or lambda's return type based on the return
9124 /// statements present in the body.
9126
9127 /// Once the Lambdas capture are known, we can start to create the closure,
9128 /// call operator method, and keep track of the captures.
9129 /// We do the capture lookup here, but they are not actually captured until
9130 /// after we know what the qualifiers of the call operator are.
9132 Scope *CurContext);
9133
9134 /// This is called after parsing the explicit template parameter list
9135 /// on a lambda (if it exists) in C++2a.
9137 SourceLocation LAngleLoc,
9138 ArrayRef<NamedDecl *> TParams,
9139 SourceLocation RAngleLoc,
9140 ExprResult RequiresClause);
9141
9143 SourceLocation MutableLoc);
9144
9146 Scope *LambdaScope,
9148
9149 /// ActOnStartOfLambdaDefinition - This is called just before we start
9150 /// parsing the body of a lambda; it analyzes the explicit captures and
9151 /// arguments, and sets up various data-structures for the body of the
9152 /// lambda.
9154 Declarator &ParamInfo, const DeclSpec &DS);
9155
9156 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
9157 /// is invoked to pop the information about the lambda.
9158 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
9159 bool IsInstantiation = false);
9160
9161 /// ActOnLambdaExpr - This is called when the body of a lambda expression
9162 /// was successfully completed.
9164
9165 /// Does copying/destroying the captured variable have side effects?
9166 bool CaptureHasSideEffects(const sema::Capture &From);
9167
9168 /// Diagnose if an explicit lambda capture is unused. Returns true if a
9169 /// diagnostic is emitted.
9170 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
9171 SourceRange FixItRange,
9172 const sema::Capture &From);
9173
9174 /// Build a FieldDecl suitable to hold the given capture.
9176
9177 /// Initialize the given capture with a suitable expression.
9179 SourceLocation ImplicitCaptureLoc,
9180 bool IsOpenMPMapping = false);
9181
9182 /// Complete a lambda-expression having processed and attached the
9183 /// lambda body.
9185
9186 /// Get the return type to use for a lambda's conversion function(s) to
9187 /// function pointer type, given the type of the call operator.
9188 QualType
9190 CallingConv CC);
9191
9193 SourceLocation ConvLocation,
9194 CXXConversionDecl *Conv, Expr *Src);
9195
9197 : private FunctionScopeRAII {
9198 public:
9200 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
9202 bool ShouldAddDeclsFromParentScope = true);
9203 };
9204
9205 /// Compute the mangling number context for a lambda expression or
9206 /// block literal. Also return the extra mangling decl if any.
9207 ///
9208 /// \param DC - The DeclContext containing the lambda expression or
9209 /// block literal.
9210 std::tuple<MangleNumberingContext *, Decl *>
9212
9213 ///@}
9214
9215 //
9216 //
9217 // -------------------------------------------------------------------------
9218 //
9219 //
9220
9221 /// \name Name Lookup
9222 ///
9223 /// These routines provide name lookup that is used during semantic
9224 /// analysis to resolve the various kinds of names (identifiers,
9225 /// overloaded operator names, constructor names, etc.) into zero or
9226 /// more declarations within a particular scope. The major entry
9227 /// points are LookupName, which performs unqualified name lookup,
9228 /// and LookupQualifiedName, which performs qualified name lookup.
9229 ///
9230 /// All name lookup is performed based on some specific criteria,
9231 /// which specify what names will be visible to name lookup and how
9232 /// far name lookup should work. These criteria are important both
9233 /// for capturing language semantics (certain lookups will ignore
9234 /// certain names, for example) and for performance, since name
9235 /// lookup is often a bottleneck in the compilation of C++. Name
9236 /// lookup criteria is specified via the LookupCriteria enumeration.
9237 ///
9238 /// The results of name lookup can vary based on the kind of name
9239 /// lookup performed, the current language, and the translation
9240 /// unit. In C, for example, name lookup will either return nothing
9241 /// (no entity found) or a single declaration. In C++, name lookup
9242 /// can additionally refer to a set of overloaded functions or
9243 /// result in an ambiguity. All of the possible results of name
9244 /// lookup are captured by the LookupResult class, which provides
9245 /// the ability to distinguish among them.
9246 ///
9247 /// Implementations are in SemaLookup.cpp
9248 ///@{
9249
9250public:
9251 /// Tracks whether we are in a context where typo correction is
9252 /// disabled.
9254
9255 /// The number of typos corrected by CorrectTypo.
9257
9258 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
9259 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
9260
9261 /// A cache containing identifiers for which typo correction failed and
9262 /// their locations, so that repeated attempts to correct an identifier in a
9263 /// given location are ignored if typo correction already failed for it.
9265
9266 /// SpecialMemberOverloadResult - The overloading result for a special member
9267 /// function.
9268 ///
9269 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
9270 /// integer are used to determine whether overload resolution succeeded.
9272 public:
9274
9275 private:
9276 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
9277
9278 public:
9281 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
9282
9283 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
9284 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
9285
9286 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
9287 void setKind(Kind K) { Pair.setInt(K); }
9288 };
9289
9290 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
9292 public:
9293 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
9294 : FastFoldingSetNode(ID) {}
9295 };
9296
9297 /// A cache of special member function overload resolution results
9298 /// for C++ records.
9299 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
9300
9302
9303 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
9304 // TODO: make this is a typesafe union.
9307
9308 /// Describes the kind of name lookup to perform.
9310 /// Ordinary name lookup, which finds ordinary names (functions,
9311 /// variables, typedefs, etc.) in C and most kinds of names
9312 /// (functions, variables, members, types, etc.) in C++.
9314 /// Tag name lookup, which finds the names of enums, classes,
9315 /// structs, and unions.
9317 /// Label name lookup.
9319 /// Member name lookup, which finds the names of
9320 /// class/struct/union members.
9322 /// Look up of an operator name (e.g., operator+) for use with
9323 /// operator overloading. This lookup is similar to ordinary name
9324 /// lookup, but will ignore any declarations that are class members.
9326 /// Look up a name following ~ in a destructor name. This is an ordinary
9327 /// lookup, but prefers tags to typedefs.
9329 /// Look up of a name that precedes the '::' scope resolution
9330 /// operator in C++. This lookup completely ignores operator, object,
9331 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9333 /// Look up a namespace name within a C++ using directive or
9334 /// namespace alias definition, ignoring non-namespace names (C++
9335 /// [basic.lookup.udir]p1).
9337 /// Look up all declarations in a scope with the given name,
9338 /// including resolved using declarations. This is appropriate
9339 /// for checking redeclarations for a using declaration.
9341 /// Look up an ordinary name that is going to be redeclared as a
9342 /// name with linkage. This lookup ignores any declarations that
9343 /// are outside of the current scope unless they have linkage. See
9344 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9346 /// Look up a friend of a local class. This lookup does not look
9347 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9349 /// Look up the name of an Objective-C protocol.
9351 /// Look up implicit 'self' parameter of an objective-c method.
9353 /// Look up the name of an OpenMP user-defined reduction operation.
9355 /// Look up the name of an OpenMP user-defined mapper.
9357 /// Look up any declaration with any name.
9359 };
9360
9361 /// The possible outcomes of name lookup for a literal operator.
9363 /// The lookup resulted in an error.
9365 /// The lookup found no match but no diagnostic was issued.
9367 /// The lookup found a single 'cooked' literal operator, which
9368 /// expects a normal literal to be built and passed to it.
9370 /// The lookup found a single 'raw' literal operator, which expects
9371 /// a string literal containing the spelling of the literal token.
9373 /// The lookup found an overload set of literal operator templates,
9374 /// which expect the characters of the spelling of the literal token to be
9375 /// passed as a non-type template argument pack.
9377 /// The lookup found an overload set of literal operator templates,
9378 /// which expect the character type and characters of the spelling of the
9379 /// string literal token to be passed as template arguments.
9381 };
9382
9383 SpecialMemberOverloadResult
9385 bool VolatileArg, bool RValueThis, bool ConstThis,
9386 bool VolatileThis);
9387
9389
9390 /// Look up a name, looking for a single declaration. Return
9391 /// null if the results were absent, ambiguous, or overloaded.
9392 ///
9393 /// It is preferable to use the elaborated form and explicitly handle
9394 /// ambiguity and overloaded.
9396 Scope *S, DeclarationName Name, SourceLocation Loc,
9397 LookupNameKind NameKind,
9399
9400 /// Lookup a builtin function, when name lookup would otherwise
9401 /// fail.
9402 bool LookupBuiltin(LookupResult &R);
9403 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9404
9405 /// Perform unqualified name lookup starting from a given
9406 /// scope.
9407 ///
9408 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9409 /// used to find names within the current scope. For example, 'x' in
9410 /// @code
9411 /// int x;
9412 /// int f() {
9413 /// return x; // unqualified name look finds 'x' in the global scope
9414 /// }
9415 /// @endcode
9416 ///
9417 /// Different lookup criteria can find different names. For example, a
9418 /// particular scope can have both a struct and a function of the same
9419 /// name, and each can be found by certain lookup criteria. For more
9420 /// information about lookup criteria, see the documentation for the
9421 /// class LookupCriteria.
9422 ///
9423 /// @param S The scope from which unqualified name lookup will
9424 /// begin. If the lookup criteria permits, name lookup may also search
9425 /// in the parent scopes.
9426 ///
9427 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9428 /// look up and the lookup kind), and is updated with the results of lookup
9429 /// including zero or more declarations and possibly additional information
9430 /// used to diagnose ambiguities.
9431 ///
9432 /// @returns \c true if lookup succeeded and false otherwise.
9433 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9434 bool ForceNoCPlusPlus = false);
9435
9436 /// Perform qualified name lookup into a given context.
9437 ///
9438 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9439 /// names when the context of those names is explicit specified, e.g.,
9440 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9441 ///
9442 /// Different lookup criteria can find different names. For example, a
9443 /// particular scope can have both a struct and a function of the same
9444 /// name, and each can be found by certain lookup criteria. For more
9445 /// information about lookup criteria, see the documentation for the
9446 /// class LookupCriteria.
9447 ///
9448 /// \param R captures both the lookup criteria and any lookup results found.
9449 ///
9450 /// \param LookupCtx The context in which qualified name lookup will
9451 /// search. If the lookup criteria permits, name lookup may also search
9452 /// in the parent contexts or (for C++ classes) base classes.
9453 ///
9454 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9455 /// occurs as part of unqualified name lookup.
9456 ///
9457 /// \returns true if lookup succeeded, false if it failed.
9458 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9459 bool InUnqualifiedLookup = false);
9460
9461 /// Performs qualified name lookup or special type of lookup for
9462 /// "__super::" scope specifier.
9463 ///
9464 /// This routine is a convenience overload meant to be called from contexts
9465 /// that need to perform a qualified name lookup with an optional C++ scope
9466 /// specifier that might require special kind of lookup.
9467 ///
9468 /// \param R captures both the lookup criteria and any lookup results found.
9469 ///
9470 /// \param LookupCtx The context in which qualified name lookup will
9471 /// search.
9472 ///
9473 /// \param SS An optional C++ scope-specifier.
9474 ///
9475 /// \returns true if lookup succeeded, false if it failed.
9476 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9477 CXXScopeSpec &SS);
9478
9479 /// Performs name lookup for a name that was parsed in the
9480 /// source code, and may contain a C++ scope specifier.
9481 ///
9482 /// This routine is a convenience routine meant to be called from
9483 /// contexts that receive a name and an optional C++ scope specifier
9484 /// (e.g., "N::M::x"). It will then perform either qualified or
9485 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9486 /// respectively) on the given name and return those results. It will
9487 /// perform a special type of lookup for "__super::" scope specifier.
9488 ///
9489 /// @param S The scope from which unqualified name lookup will
9490 /// begin.
9491 ///
9492 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9493 ///
9494 /// @param EnteringContext Indicates whether we are going to enter the
9495 /// context of the scope-specifier SS (if present).
9496 ///
9497 /// @returns True if any decls were found (but possibly ambiguous)
9499 QualType ObjectType, bool AllowBuiltinCreation = false,
9500 bool EnteringContext = false);
9501
9502 /// Perform qualified name lookup into all base classes of the given
9503 /// class.
9504 ///
9505 /// \param R captures both the lookup criteria and any lookup results found.
9506 ///
9507 /// \param Class The context in which qualified name lookup will
9508 /// search. Name lookup will search in all base classes merging the results.
9509 ///
9510 /// @returns True if any decls were found (but possibly ambiguous)
9512
9514 UnresolvedSetImpl &Functions);
9515
9516 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9517 /// If GnuLabelLoc is a valid source location, then this is a definition
9518 /// of an __label__ label name, otherwise it is a normal label definition
9519 /// or use.
9521 SourceLocation GnuLabelLoc = SourceLocation());
9522
9523 /// Perform a name lookup for a label with the specified name; this does not
9524 /// create a new label if the lookup fails.
9526
9527 /// Look up the constructors for the given class.
9529
9530 /// Look up the default constructor for the given class.
9532
9533 /// Look up the copying constructor for the given class.
9535 unsigned Quals);
9536
9537 /// Look up the copying assignment operator for the given class.
9539 bool RValueThis, unsigned ThisQuals);
9540
9541 /// Look up the moving constructor for the given class.
9543 unsigned Quals);
9544
9545 /// Look up the moving assignment operator for the given class.
9547 bool RValueThis, unsigned ThisQuals);
9548
9549 /// Look for the destructor of the given class.
9550 ///
9551 /// During semantic analysis, this routine should be used in lieu of
9552 /// CXXRecordDecl::getDestructor().
9553 ///
9554 /// \returns The destructor for this class.
9556
9557 /// Force the declaration of any implicitly-declared members of this
9558 /// class.
9560
9561 /// Make a merged definition of an existing hidden definition \p ND
9562 /// visible at the specified location.
9564
9565 /// Check ODR hashes for C/ObjC when merging types from modules.
9566 /// Differently from C++, actually parse the body and reject in case
9567 /// of a mismatch.
9568 template <typename T,
9569 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9571 if (Duplicate->getODRHash() != Previous->getODRHash())
9572 return false;
9573
9574 // Make the previous decl visible.
9576 return true;
9577 }
9578
9579 /// Get the set of additional modules that should be checked during
9580 /// name lookup. A module and its imports become visible when instanting a
9581 /// template defined within it.
9582 llvm::DenseSet<Module *> &getLookupModules();
9583
9584 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9586
9587 /// Determine if the template parameter \p D has a visible default argument.
9588 bool
9590 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9591 /// Determine if the template parameter \p D has a reachable default argument.
9593 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9594 /// Determine if the template parameter \p D has a reachable default argument.
9598
9599 /// Determine if there is a visible declaration of \p D that is an explicit
9600 /// specialization declaration for a specialization of a template. (For a
9601 /// member specialization, use hasVisibleMemberSpecialization.)
9603 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9604 /// Determine if there is a reachable declaration of \p D that is an explicit
9605 /// specialization declaration for a specialization of a template. (For a
9606 /// member specialization, use hasReachableMemberSpecialization.)
9608 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9609
9610 /// Determine if there is a visible declaration of \p D that is a member
9611 /// specialization declaration (as opposed to an instantiated declaration).
9613 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9614 /// Determine if there is a reachable declaration of \p D that is a member
9615 /// specialization declaration (as opposed to an instantiated declaration).
9617 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9618
9619 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9620
9621 /// Determine whether any declaration of an entity is visible.
9622 bool
9624 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9625 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9626 }
9627
9630 /// Determine whether any declaration of an entity is reachable.
9631 bool
9633 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9634 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9635 }
9637 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9638
9639 void diagnoseTypo(const TypoCorrection &Correction,
9640 const PartialDiagnostic &TypoDiag,
9641 bool ErrorRecovery = true);
9642
9643 /// Diagnose a successfully-corrected typo. Separated from the correction
9644 /// itself to allow external validation of the result, etc.
9645 ///
9646 /// \param Correction The result of performing typo correction.
9647 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9648 /// string added to it (and usually also a fixit).
9649 /// \param PrevNote A note to use when indicating the location of the entity
9650 /// to which we are correcting. Will have the correction string added
9651 /// to it.
9652 /// \param ErrorRecovery If \c true (the default), the caller is going to
9653 /// recover from the typo as if the corrected string had been typed.
9654 /// In this case, \c PDiag must be an error, and we will attach a fixit
9655 /// to it.
9656 void diagnoseTypo(const TypoCorrection &Correction,
9657 const PartialDiagnostic &TypoDiag,
9658 const PartialDiagnostic &PrevNote,
9659 bool ErrorRecovery = true);
9660
9661 /// Find the associated classes and namespaces for
9662 /// argument-dependent lookup for a call with the given set of
9663 /// arguments.
9664 ///
9665 /// This routine computes the sets of associated classes and associated
9666 /// namespaces searched by argument-dependent lookup
9667 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9669 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9670 AssociatedNamespaceSet &AssociatedNamespaces,
9671 AssociatedClassSet &AssociatedClasses);
9672
9673 /// Produce a diagnostic describing the ambiguity that resulted
9674 /// from name lookup.
9675 ///
9676 /// \param Result The result of the ambiguous lookup to be diagnosed.
9678
9679 /// LookupLiteralOperator - Determine which literal operator should be used
9680 /// for a user-defined literal, per C++11 [lex.ext].
9681 ///
9682 /// Normal overload resolution is not used to select which literal operator to
9683 /// call for a user-defined literal. Look up the provided literal operator
9684 /// name, and filter the results to the appropriate set for the given argument
9685 /// types.
9688 bool AllowRaw, bool AllowTemplate,
9689 bool AllowStringTemplate, bool DiagnoseMissing,
9690 StringLiteral *StringLit = nullptr);
9691
9693 ArrayRef<Expr *> Args, ADLResult &Functions);
9694
9695 void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
9697 bool IncludeGlobalScope = true,
9698 bool LoadExternal = true);
9699 void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
9701 bool IncludeGlobalScope = true,
9702 bool IncludeDependentBases = false,
9703 bool LoadExternal = true);
9704
9705 /// Try to "correct" a typo in the source code by finding
9706 /// visible declarations whose names are similar to the name that was
9707 /// present in the source code.
9708 ///
9709 /// \param TypoName the \c DeclarationNameInfo structure that contains
9710 /// the name that was present in the source code along with its location.
9711 ///
9712 /// \param LookupKind the name-lookup criteria used to search for the name.
9713 ///
9714 /// \param S the scope in which name lookup occurs.
9715 ///
9716 /// \param SS the nested-name-specifier that precedes the name we're
9717 /// looking for, if present.
9718 ///
9719 /// \param CCC A CorrectionCandidateCallback object that provides further
9720 /// validation of typo correction candidates. It also provides flags for
9721 /// determining the set of keywords permitted.
9722 ///
9723 /// \param MemberContext if non-NULL, the context in which to look for
9724 /// a member access expression.
9725 ///
9726 /// \param EnteringContext whether we're entering the context described by
9727 /// the nested-name-specifier SS.
9728 ///
9729 /// \param OPT when non-NULL, the search for visible declarations will
9730 /// also walk the protocols in the qualified interfaces of \p OPT.
9731 ///
9732 /// \returns a \c TypoCorrection containing the corrected name if the typo
9733 /// along with information such as the \c NamedDecl where the corrected name
9734 /// was declared, and any additional \c NestedNameSpecifier needed to access
9735 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9737 Sema::LookupNameKind LookupKind, Scope *S,
9739 CorrectTypoKind Mode,
9740 DeclContext *MemberContext = nullptr,
9741 bool EnteringContext = false,
9742 const ObjCObjectPointerType *OPT = nullptr,
9743 bool RecordFailure = true);
9744
9745 /// Kinds of missing import. Note, the values of these enumerators correspond
9746 /// to %select values in diagnostics.
9754
9755 /// Diagnose that the specified declaration needs to be visible but
9756 /// isn't, and suggest a module import that would resolve the problem.
9758 MissingImportKind MIK, bool Recover = true);
9760 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9761 MissingImportKind MIK, bool Recover);
9762
9763 /// Called on #pragma clang __debug dump II
9765
9766 /// Called on #pragma clang __debug dump E
9767 void ActOnPragmaDump(Expr *E);
9768
9769private:
9770 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9771 //
9772 // The boolean value will be true to indicate that the namespace was loaded
9773 // from an AST/PCH file, or false otherwise.
9774 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9775
9776 /// Whether we have already loaded known namespaces from an extenal
9777 /// source.
9778 bool LoadedExternalKnownNamespaces;
9779
9780 bool CppLookupName(LookupResult &R, Scope *S);
9781
9782 /// Determine if we could use all the declarations in the module.
9783 bool isUsableModule(const Module *M);
9784
9785 /// Helper for CorrectTypo used to create and populate a new
9786 /// TypoCorrectionConsumer. Returns nullptr if typo correction should be
9787 /// skipped entirely.
9788 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9789 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9791 DeclContext *MemberContext, bool EnteringContext,
9792 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9793
9794 /// Cache for module units which is usable for current module.
9795 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9796
9797 /// Record the typo correction failure and return an empty correction.
9798 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9799 bool RecordFailure = true) {
9800 if (RecordFailure)
9801 TypoCorrectionFailures[Typo].insert(TypoLoc);
9802 return TypoCorrection();
9803 }
9804
9805 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9806
9807 /// Determine whether two declarations should be linked together, given that
9808 /// the old declaration might not be visible and the new declaration might
9809 /// not have external linkage.
9810 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9811 const NamedDecl *New) {
9812 if (isVisible(Old))
9813 return true;
9814 // See comment in below overload for why it's safe to compute the linkage
9815 // of the new declaration here.
9816 if (New->isExternallyDeclarable()) {
9817 assert(Old->isExternallyDeclarable() &&
9818 "should not have found a non-externally-declarable previous decl");
9819 return true;
9820 }
9821 return false;
9822 }
9823 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9824
9825 ///@}
9826
9827 //
9828 //
9829 // -------------------------------------------------------------------------
9830 //
9831 //
9832
9833 /// \name Modules
9834 /// Implementations are in SemaModule.cpp
9835 ///@{
9836
9837public:
9838 /// Get the module unit whose scope we are currently within.
9840 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9841 }
9842
9843 /// Is the module scope we are an implementation unit?
9845 return ModuleScopes.empty()
9846 ? false
9847 : ModuleScopes.back().Module->isModuleImplementation();
9848 }
9849
9850 // When loading a non-modular PCH files, this is used to restore module
9851 // visibility.
9853 VisibleModules.setVisible(Mod, ImportLoc);
9854 }
9855
9856 enum class ModuleDeclKind {
9857 Interface, ///< 'export module X;'
9858 Implementation, ///< 'module X;'
9859 PartitionInterface, ///< 'export module X:Y;'
9860 PartitionImplementation, ///< 'module X:Y;'
9861 };
9862
9863 /// An enumeration to represent the transition of states in parsing module
9864 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9865 /// an error in state transition, the state is set to NotACXX20Module.
9867 FirstDecl, ///< Parsing the first decl in a TU.
9868 GlobalFragment, ///< after 'module;' but before 'module X;'
9869 ImportAllowed, ///< after 'module X;' but before any non-import decl.
9870 ImportFinished, ///< after any non-import decl.
9871 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
9872 ///< non-import decl.
9873 PrivateFragmentImportFinished, ///< after 'module :private;' but a
9874 ///< non-import decl has already been seen.
9875 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
9876 };
9877
9878 /// The parser has processed a module-declaration that begins the definition
9879 /// of a module interface or implementation.
9881 SourceLocation ModuleLoc, ModuleDeclKind MDK,
9882 ModuleIdPath Path, ModuleIdPath Partition,
9883 ModuleImportState &ImportState,
9884 bool SeenNoTrivialPPDirective);
9885
9886 /// The parser has processed a global-module-fragment declaration that begins
9887 /// the definition of the global module fragment of the current module unit.
9888 /// \param ModuleLoc The location of the 'module' keyword.
9890
9891 /// The parser has processed a private-module-fragment declaration that begins
9892 /// the definition of the private module fragment of the current module unit.
9893 /// \param ModuleLoc The location of the 'module' keyword.
9894 /// \param PrivateLoc The location of the 'private' keyword.
9896 SourceLocation PrivateLoc);
9897
9898 /// The parser has processed a module import declaration.
9899 ///
9900 /// \param StartLoc The location of the first token in the declaration. This
9901 /// could be the location of an '@', 'export', or 'import'.
9902 /// \param ExportLoc The location of the 'export' keyword, if any.
9903 /// \param ImportLoc The location of the 'import' keyword.
9904 /// \param Path The module toplevel name as an access path.
9905 /// \param IsPartition If the name is for a partition.
9907 SourceLocation ExportLoc,
9908 SourceLocation ImportLoc, ModuleIdPath Path,
9909 bool IsPartition = false);
9911 SourceLocation ExportLoc,
9912 SourceLocation ImportLoc, Module *M,
9913 ModuleIdPath Path = {});
9914
9915 /// The parser has processed a module import translated from a
9916 /// #include or similar preprocessing directive.
9917 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9918 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9919
9920 /// The parsed has entered a submodule.
9921 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
9922 /// The parser has left a submodule.
9923 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
9924
9925 /// Create an implicit import of the given module at the given
9926 /// source location, for error recovery, if possible.
9927 ///
9928 /// This routine is typically used when an entity found by name lookup
9929 /// is actually hidden within a module that we know about but the user
9930 /// has forgotten to import.
9931 void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
9932 Module *Mod);
9933
9934 /// We have parsed the start of an export declaration, including the '{'
9935 /// (if present).
9936 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
9937 SourceLocation LBraceLoc);
9938
9939 /// Complete the definition of an export declaration.
9940 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
9941 SourceLocation RBraceLoc);
9942
9943private:
9944 /// The parser has begun a translation unit to be compiled as a C++20
9945 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
9946 void HandleStartOfHeaderUnit();
9947
9948 struct ModuleScope {
9949 SourceLocation BeginLoc;
9950 clang::Module *Module = nullptr;
9951 VisibleModuleSet OuterVisibleModules;
9952 };
9953 /// The modules we're currently parsing.
9954 llvm::SmallVector<ModuleScope, 16> ModuleScopes;
9955
9956 /// For an interface unit, this is the implicitly imported interface unit.
9957 clang::Module *ThePrimaryInterface = nullptr;
9958
9959 /// The explicit global module fragment of the current translation unit.
9960 /// The explicit Global Module Fragment, as specified in C++
9961 /// [module.global.frag].
9962 clang::Module *TheGlobalModuleFragment = nullptr;
9963
9964 /// The implicit global module fragments of the current translation unit.
9965 ///
9966 /// The contents in the implicit global module fragment can't be discarded.
9967 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
9968
9969 /// Namespace definitions that we will export when they finish.
9970 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
9971
9972 /// In a C++ standard module, inline declarations require a definition to be
9973 /// present at the end of a definition domain. This set holds the decls to
9974 /// be checked at the end of the TU.
9975 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
9976
9977 /// Helper function to judge if we are in module purview.
9978 /// Return false if we are not in a module.
9979 bool isCurrentModulePurview() const;
9980
9981 /// Enter the scope of the explicit global module fragment.
9982 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
9983 /// Leave the scope of the explicit global module fragment.
9984 void PopGlobalModuleFragment();
9985
9986 /// Enter the scope of an implicit global module fragment.
9987 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
9988 /// Leave the scope of an implicit global module fragment.
9989 void PopImplicitGlobalModuleFragment();
9990
9991 VisibleModuleSet VisibleModules;
9992
9993 /// Whether we had imported any named modules.
9994 bool HadImportedNamedModules = false;
9995 /// The set of instantiations we need to check if they references TU-local
9996 /// entity from TUs. This only makes sense if we imported any named modules.
9997 llvm::SmallVector<std::pair<FunctionDecl *, SourceLocation>>
9998 PendingCheckReferenceForTULocal;
9999 /// Implement [basic.link]p18, which requires that we can't use TU-local
10000 /// entities from other TUs (ignoring header units).
10001 void checkReferenceToTULocalFromOtherTU(FunctionDecl *FD,
10002 SourceLocation PointOfInstantiation);
10003 /// Implement [basic.link]p17, which diagnose for non TU local exposure in
10004 /// module interface or module partition.
10005 void checkExposure(const TranslationUnitDecl *TU);
10006
10007 ///@}
10008
10009 //
10010 //
10011 // -------------------------------------------------------------------------
10012 //
10013 //
10014
10015 /// \name C++ Overloading
10016 /// Implementations are in SemaOverload.cpp
10017 ///@{
10018
10019public:
10020 /// Whether deferrable diagnostics should be deferred.
10021 bool DeferDiags = false;
10022
10023 /// RAII class to control scope of DeferDiags.
10025 Sema &S;
10026 bool SavedDeferDiags = false;
10027
10028 public:
10030 : S(S), SavedDeferDiags(S.DeferDiags) {
10031 S.DeferDiags = SavedDeferDiags || DeferDiags;
10032 }
10033 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
10034 };
10035
10036 /// Flag indicating if Sema is building a recovery call expression.
10037 ///
10038 /// This flag is used to avoid building recovery call expressions
10039 /// if Sema is already doing so, which would cause infinite recursions.
10041
10042 /// Determine whether the given New declaration is an overload of the
10043 /// declarations in Old. This routine returns OverloadKind::Match or
10044 /// OverloadKind::NonFunction if New and Old cannot be overloaded, e.g., if
10045 /// New has the same signature as some function in Old (C++ 1.3.10) or if the
10046 /// Old declarations aren't functions (or function templates) at all. When it
10047 /// does return OverloadKind::Match or OverloadKind::NonFunction, MatchedDecl
10048 /// will point to the decl that New cannot be overloaded with. This decl may
10049 /// be a UsingShadowDecl on top of the underlying declaration.
10050 ///
10051 /// Example: Given the following input:
10052 ///
10053 /// void f(int, float); // #1
10054 /// void f(int, int); // #2
10055 /// int f(int, int); // #3
10056 ///
10057 /// When we process #1, there is no previous declaration of "f", so IsOverload
10058 /// will not be used.
10059 ///
10060 /// When we process #2, Old contains only the FunctionDecl for #1. By
10061 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
10062 /// they have different signatures), so this routine returns
10063 /// OverloadKind::Overload; MatchedDecl is unchanged.
10064 ///
10065 /// When we process #3, Old is an overload set containing #1 and #2. We
10066 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
10067 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
10068 /// types of functions are not part of the signature), IsOverload returns
10069 /// OverloadKind::Match and MatchedDecl will be set to point to the
10070 /// FunctionDecl for #2.
10071 ///
10072 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
10073 /// class by a using declaration. The rules for whether to hide shadow
10074 /// declarations ignore some properties which otherwise figure into a function
10075 /// template's signature.
10077 const LookupResult &OldDecls, NamedDecl *&OldDecl,
10078 bool UseMemberUsingDeclRules);
10080 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10081
10082 // Checks whether MD constitutes an override the base class method BaseMD.
10083 // When checking for overrides, the object object members are ignored.
10084 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
10085 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10086
10087 enum class AllowedExplicit {
10088 /// Allow no explicit functions to be used.
10090 /// Allow explicit conversion functions but not explicit constructors.
10092 /// Allow both explicit conversion functions and explicit constructors.
10094 };
10095
10097 Expr *From, QualType ToType, bool SuppressUserConversions,
10098 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
10099 bool AllowObjCWritebackConversion);
10100
10101 /// PerformImplicitConversion - Perform an implicit conversion of the
10102 /// expression From to the type ToType. Returns the
10103 /// converted expression. Flavor is the kind of conversion we're
10104 /// performing, used in the error message. If @p AllowExplicit,
10105 /// explicit user-defined conversions are permitted.
10107 AssignmentAction Action,
10108 bool AllowExplicit = false);
10109
10110 /// IsIntegralPromotion - Determines whether the conversion from the
10111 /// expression From (whose potentially-adjusted type is FromType) to
10112 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
10113 /// sets PromotedType to the promoted type.
10114 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
10115
10116 /// IsFloatingPointPromotion - Determines whether the conversion from
10117 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
10118 /// returns true and sets PromotedType to the promoted type.
10119 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
10120
10121 /// Determine if a conversion is a complex promotion.
10122 ///
10123 /// A complex promotion is defined as a complex -> complex conversion
10124 /// where the conversion between the underlying real types is a
10125 /// floating-point or integral promotion.
10126 bool IsComplexPromotion(QualType FromType, QualType ToType);
10127
10128 /// IsPointerConversion - Determines whether the conversion of the
10129 /// expression From, which has the (possibly adjusted) type FromType,
10130 /// can be converted to the type ToType via a pointer conversion (C++
10131 /// 4.10). If so, returns true and places the converted type (that
10132 /// might differ from ToType in its cv-qualifiers at some level) into
10133 /// ConvertedType.
10134 ///
10135 /// This routine also supports conversions to and from block pointers
10136 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
10137 /// pointers to interfaces. FIXME: Once we've determined the
10138 /// appropriate overloading rules for Objective-C, we may want to
10139 /// split the Objective-C checks into a different routine; however,
10140 /// GCC seems to consider all of these conversions to be pointer
10141 /// conversions, so for now they live here. IncompatibleObjC will be
10142 /// set if the conversion is an allowed Objective-C conversion that
10143 /// should result in a warning.
10144 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
10145 bool InOverloadResolution, QualType &ConvertedType,
10146 bool &IncompatibleObjC);
10147
10148 /// isObjCPointerConversion - Determines whether this is an
10149 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
10150 /// with the same arguments and return values.
10151 bool isObjCPointerConversion(QualType FromType, QualType ToType,
10152 QualType &ConvertedType, bool &IncompatibleObjC);
10153 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
10154 QualType &ConvertedType);
10155
10156 /// FunctionParamTypesAreEqual - This routine checks two function proto types
10157 /// for equality of their parameter types. Caller has already checked that
10158 /// they have same number of parameters. If the parameters are different,
10159 /// ArgPos will have the parameter index of the first different parameter.
10160 /// If `Reversed` is true, the parameters of `NewType` will be compared in
10161 /// reverse order. That's useful if one of the functions is being used as a
10162 /// C++20 synthesized operator overload with a reversed parameter order.
10165 unsigned *ArgPos = nullptr,
10166 bool Reversed = false);
10167
10169 const FunctionProtoType *NewType,
10170 unsigned *ArgPos = nullptr,
10171 bool Reversed = false);
10172
10173 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
10174 const FunctionDecl *NewFunction,
10175 unsigned *ArgPos = nullptr,
10176 bool Reversed = false);
10177
10178 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
10179 /// function types. Catches different number of parameter, mismatch in
10180 /// parameter types, and different return types.
10182 QualType ToType);
10183
10184 /// CheckPointerConversion - Check the pointer conversion from the
10185 /// expression From to the type ToType. This routine checks for
10186 /// ambiguous or inaccessible derived-to-base pointer
10187 /// conversions for which IsPointerConversion has already returned
10188 /// true. It returns true and produces a diagnostic if there was an
10189 /// error, or returns false otherwise.
10190 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
10191 CXXCastPath &BasePath, bool IgnoreBaseAccess,
10192 bool Diagnose = true);
10193
10194 /// IsMemberPointerConversion - Determines whether the conversion of the
10195 /// expression From, which has the (possibly adjusted) type FromType, can be
10196 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
10197 /// If so, returns true and places the converted type (that might differ from
10198 /// ToType in its cv-qualifiers at some level) into ConvertedType.
10199 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
10200 bool InOverloadResolution,
10201 QualType &ConvertedType);
10202
10212 /// CheckMemberPointerConversion - Check the member pointer conversion from
10213 /// the expression From to the type ToType. This routine checks for ambiguous
10214 /// or virtual or inaccessible base-to-derived member pointer conversions for
10215 /// which IsMemberPointerConversion has already returned true. It produces a
10216 // diagnostic if there was an error.
10218 QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind,
10219 CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange,
10220 bool IgnoreBaseAccess, MemberPointerConversionDirection Direction);
10221
10222 /// IsQualificationConversion - Determines whether the conversion from
10223 /// an rvalue of type FromType to ToType is a qualification conversion
10224 /// (C++ 4.4).
10225 ///
10226 /// \param ObjCLifetimeConversion Output parameter that will be set to
10227 /// indicate when the qualification conversion involves a change in the
10228 /// Objective-C object lifetime.
10229 bool IsQualificationConversion(QualType FromType, QualType ToType,
10230 bool CStyle, bool &ObjCLifetimeConversion);
10231
10232 /// Determine whether the conversion from FromType to ToType is a valid
10233 /// conversion of ExtInfo/ExtProtoInfo on the nested function type.
10234 /// More precisely, this method checks whether FromType can be transformed
10235 /// into an exact match for ToType, by transforming its extended function
10236 /// type information in legal manner (e.g. by strictly stripping "noreturn"
10237 /// or "noexcept", or by stripping "noescape" for arguments).
10238 bool IsFunctionConversion(QualType FromType, QualType ToType) const;
10239
10240 /// Same as `IsFunctionConversion`, but if this would return true, it sets
10241 /// `ResultTy` to `ToType`.
10242 bool TryFunctionConversion(QualType FromType, QualType ToType,
10243 QualType &ResultTy) const;
10244
10247 DeclarationName Name,
10248 OverloadCandidateSet &CandidateSet,
10249 FunctionDecl *Fn, MultiExprArg Args,
10250 bool IsMember = false);
10251
10253 FunctionDecl *Fun);
10255 Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl,
10257
10258 /// PerformContextuallyConvertToBool - Perform a contextual conversion
10259 /// of the expression From to bool (C++0x [conv]p3).
10261
10262 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
10263 /// conversion of the expression From to an Objective-C pointer type.
10264 /// Returns a valid but null ExprResult if no conversion sequence exists.
10266
10268 CCEKind CCE,
10269 NamedDecl *Dest = nullptr);
10270
10272 llvm::APSInt &Value, CCEKind CCE);
10274 APValue &Value, CCEKind CCE,
10275 NamedDecl *Dest = nullptr);
10276
10277 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10278 /// That is a converted constant expression
10279 /// (which was built with BuildConvertedConstantExpression)
10282 CCEKind CCE, bool RequireInt,
10283 const APValue &PreNarrowingValue);
10284
10285 /// Abstract base class used to perform a contextual implicit
10286 /// conversion from an expression to any type passing a filter.
10288 public:
10291
10295
10296 /// Determine whether the specified type is a valid destination type
10297 /// for this conversion.
10298 virtual bool match(QualType T) = 0;
10299
10300 /// Emits a diagnostic complaining that the expression does not have
10301 /// integral or enumeration type.
10303 QualType T) = 0;
10304
10305 /// Emits a diagnostic when the expression has incomplete class type.
10306 virtual SemaDiagnosticBuilder
10308
10309 /// Emits a diagnostic when the only matching conversion function
10310 /// is explicit.
10312 SourceLocation Loc,
10313 QualType T,
10314 QualType ConvTy) = 0;
10315
10316 /// Emits a note for the explicit conversion function.
10317 virtual SemaDiagnosticBuilder
10319
10320 /// Emits a diagnostic when there are multiple possible conversion
10321 /// functions.
10323 QualType T) = 0;
10324
10325 /// Emits a note for one of the candidate conversions.
10326 virtual SemaDiagnosticBuilder
10328
10329 /// Emits a diagnostic when we picked a conversion function
10330 /// (for cases when we are not allowed to pick a conversion function).
10332 SourceLocation Loc,
10333 QualType T,
10334 QualType ConvTy) = 0;
10335
10337 };
10338
10340 bool AllowScopedEnumerations;
10341
10342 public:
10343 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10344 bool SuppressConversion)
10346 AllowScopedEnumerations(AllowScopedEnumerations) {}
10347
10348 /// Match an integral or (possibly scoped) enumeration type.
10349 bool match(QualType T) override;
10350
10352 QualType T) override {
10353 return diagnoseNotInt(S, Loc, T);
10354 }
10355
10356 /// Emits a diagnostic complaining that the expression does not have
10357 /// integral or enumeration type.
10359 QualType T) = 0;
10360 };
10361
10362 /// Perform a contextual implicit conversion.
10365 ContextualImplicitConverter &Converter);
10366
10367 /// ReferenceCompareResult - Expresses the result of comparing two
10368 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10369 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10371 /// Ref_Incompatible - The two types are incompatible, so direct
10372 /// reference binding is not possible.
10374 /// Ref_Related - The two types are reference-related, which means
10375 /// that their unqualified forms (T1 and T2) are either the same
10376 /// or T1 is a base class of T2.
10378 /// Ref_Compatible - The two types are reference-compatible.
10380 };
10381
10382 // Fake up a scoped enumeration that still contextually converts to bool.
10384 /// The conversions that would be performed on an lvalue of type T2 when
10385 /// binding a reference of type T1 to it, as determined when evaluating
10386 /// whether T1 is reference-compatible with T2.
10397 };
10399
10400 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10401 /// determine whether they are reference-compatible,
10402 /// reference-related, or incompatible, for use in C++ initialization by
10403 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10404 /// type, and the first type (T1) is the pointee type of the reference
10405 /// type being initialized.
10408 ReferenceConversions *Conv = nullptr);
10409
10410 /// AddOverloadCandidate - Adds the given function to the set of
10411 /// candidate functions, using the given function call arguments. If
10412 /// @p SuppressUserConversions, then don't allow user-defined
10413 /// conversions via constructors or conversion operators.
10414 ///
10415 /// \param PartialOverloading true if we are performing "partial" overloading
10416 /// based on an incomplete set of function arguments. This feature is used by
10417 /// code completion.
10420 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10421 bool PartialOverloading = false, bool AllowExplicit = true,
10422 bool AllowExplicitConversion = false,
10423 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10424 ConversionSequenceList EarlyConversions = {},
10426 bool AggregateCandidateDeduction = false, bool StrictPackMatch = false);
10427
10428 /// Add all of the function declarations in the given function set to
10429 /// the overload candidate set.
10431 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10432 OverloadCandidateSet &CandidateSet,
10433 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10434 bool SuppressUserConversions = false, bool PartialOverloading = false,
10435 bool FirstArgumentIsBase = false);
10436
10437 /// AddMethodCandidate - Adds a named decl (which is some kind of
10438 /// method) as a method candidate to the given overload set.
10439 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10440 Expr::Classification ObjectClassification,
10441 ArrayRef<Expr *> Args,
10442 OverloadCandidateSet &CandidateSet,
10443 bool SuppressUserConversion = false,
10444 OverloadCandidateParamOrder PO = {});
10445
10446 /// AddMethodCandidate - Adds the given C++ member function to the set
10447 /// of candidate functions, using the given function call arguments
10448 /// and the object argument (@c Object). For example, in a call
10449 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10450 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10451 /// allow user-defined conversions via constructors or conversion
10452 /// operators.
10453 void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10454 CXXRecordDecl *ActingContext, QualType ObjectType,
10455 Expr::Classification ObjectClassification,
10456 ArrayRef<Expr *> Args,
10457 OverloadCandidateSet &CandidateSet,
10458 bool SuppressUserConversions = false,
10459 bool PartialOverloading = false,
10460 ConversionSequenceList EarlyConversions = {},
10462 bool StrictPackMatch = false);
10463
10464 /// Add a C++ member function template as a candidate to the candidate
10465 /// set, using template argument deduction to produce an appropriate member
10466 /// function template specialization.
10468 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10469 CXXRecordDecl *ActingContext,
10470 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10471 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10472 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10473 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10474
10475 /// Add a C++ function template specialization as a candidate
10476 /// in the candidate set, using template argument deduction to produce
10477 /// an appropriate function template specialization.
10479 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10480 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10481 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10482 bool PartialOverloading = false, bool AllowExplicit = true,
10483 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10485 bool AggregateCandidateDeduction = false);
10486
10488 /// Do not consider any user-defined conversions when constructing the
10489 /// initializing sequence.
10491
10492 /// Before constructing the initializing sequence, we check whether the
10493 /// parameter type and argument type contain any user defined conversions.
10494 /// If so, do not initialize them. This effectively bypasses some undesired
10495 /// instantiation before checking constaints, which might otherwise result
10496 /// in non-SFINAE errors e.g. recursive constraints.
10498
10505 };
10506
10507 /// Check that implicit conversion sequences can be formed for each argument
10508 /// whose corresponding parameter has a non-dependent type, per DR1391's
10509 /// [temp.deduct.call]p10.
10512 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10514 CheckNonDependentConversionsFlag UserConversionFlag,
10515 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10516 Expr::Classification ObjectClassification = {},
10517 OverloadCandidateParamOrder PO = {});
10518
10519 /// AddConversionCandidate - Add a C++ conversion function as a
10520 /// candidate in the candidate set (C++ [over.match.conv],
10521 /// C++ [over.match.copy]). From is the expression we're converting from,
10522 /// and ToType is the type that we're eventually trying to convert to
10523 /// (which may or may not be the same type as the type that the
10524 /// conversion function produces).
10526 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10527 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10528 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10529 bool AllowExplicit, bool AllowResultConversion = true,
10530 bool StrictPackMatch = false);
10531
10532 /// Adds a conversion function template specialization
10533 /// candidate to the overload set, using template argument deduction
10534 /// to deduce the template arguments of the conversion function
10535 /// template from the type that we are converting to (C++
10536 /// [temp.deduct.conv]).
10538 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10539 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10540 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10541 bool AllowExplicit, bool AllowResultConversion = true);
10542
10543 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10544 /// converts the given @c Object to a function pointer via the
10545 /// conversion function @c Conversion, and then attempts to call it
10546 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10547 /// the type of function that we'll eventually be calling.
10548 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10549 DeclAccessPair FoundDecl,
10550 CXXRecordDecl *ActingContext,
10551 const FunctionProtoType *Proto, Expr *Object,
10552 ArrayRef<Expr *> Args,
10553 OverloadCandidateSet &CandidateSet);
10554
10555 /// Add all of the non-member operator function declarations in the given
10556 /// function set to the overload candidate set.
10558 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10559 OverloadCandidateSet &CandidateSet,
10560 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10561
10562 /// Add overload candidates for overloaded operators that are
10563 /// member functions.
10564 ///
10565 /// Add the overloaded operator candidates that are member functions
10566 /// for the operator Op that was used in an operator expression such
10567 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10568 /// CandidateSet will store the added overload candidates. (C++
10569 /// [over.match.oper]).
10571 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10572 OverloadCandidateSet &CandidateSet,
10574
10575 /// AddBuiltinCandidate - Add a candidate for a built-in
10576 /// operator. ResultTy and ParamTys are the result and parameter types
10577 /// of the built-in candidate, respectively. Args and NumArgs are the
10578 /// arguments being passed to the candidate. IsAssignmentOperator
10579 /// should be true when this built-in candidate is an assignment
10580 /// operator. NumContextualBoolArguments is the number of arguments
10581 /// (at the beginning of the argument list) that will be contextually
10582 /// converted to bool.
10583 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10584 OverloadCandidateSet &CandidateSet,
10585 bool IsAssignmentOperator = false,
10586 unsigned NumContextualBoolArguments = 0);
10587
10588 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10589 /// operator overloads to the candidate set (C++ [over.built]), based
10590 /// on the operator @p Op and the arguments given. For example, if the
10591 /// operator is a binary '+', this routine might add "int
10592 /// operator+(int, int)" to cover integer addition.
10594 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10595 OverloadCandidateSet &CandidateSet);
10596
10597 /// Add function candidates found via argument-dependent lookup
10598 /// to the set of overloading candidates.
10599 ///
10600 /// This routine performs argument-dependent name lookup based on the
10601 /// given function name (which may also be an operator name) and adds
10602 /// all of the overload candidates found by ADL to the overload
10603 /// candidate set (C++ [basic.lookup.argdep]).
10605 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10606 TemplateArgumentListInfo *ExplicitTemplateArgs,
10607 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10608
10609 /// Check the enable_if expressions on the given function. Returns the first
10610 /// failing attribute, or NULL if they were all successful.
10611 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10612 ArrayRef<Expr *> Args,
10613 bool MissingImplicitThis = false);
10614
10615 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10616 /// non-ArgDependent DiagnoseIfAttrs.
10617 ///
10618 /// Argument-dependent diagnose_if attributes should be checked each time a
10619 /// function is used as a direct callee of a function call.
10620 ///
10621 /// Returns true if any errors were emitted.
10622 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10623 const Expr *ThisArg,
10624 ArrayRef<const Expr *> Args,
10625 SourceLocation Loc);
10626
10627 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10628 /// ArgDependent DiagnoseIfAttrs.
10629 ///
10630 /// Argument-independent diagnose_if attributes should be checked on every use
10631 /// of a function.
10632 ///
10633 /// Returns true if any errors were emitted.
10634 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10635 SourceLocation Loc);
10636
10637 /// Determine if \p A and \p B are equivalent internal linkage declarations
10638 /// from different modules, and thus an ambiguity error can be downgraded to
10639 /// an extension warning.
10640 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10641 const NamedDecl *B);
10643 SourceLocation Loc, const NamedDecl *D,
10644 ArrayRef<const NamedDecl *> Equiv);
10645
10646 // Emit as a 'note' the specific overload candidate
10648 const NamedDecl *Found, const FunctionDecl *Fn,
10650 QualType DestType = QualType(), bool TakingAddress = false);
10651
10652 // Emit as a series of 'note's all template and non-templates identified by
10653 // the expression Expr
10654 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10655 bool TakingAddress = false);
10656
10657 /// Returns whether the given function's address can be taken or not,
10658 /// optionally emitting a diagnostic if the address can't be taken.
10659 ///
10660 /// Returns false if taking the address of the function is illegal.
10661 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10662 bool Complain = false,
10663 SourceLocation Loc = SourceLocation());
10664
10665 // [PossiblyAFunctionType] --> [Return]
10666 // NonFunctionType --> NonFunctionType
10667 // R (A) --> R(A)
10668 // R (*)(A) --> R (A)
10669 // R (&)(A) --> R (A)
10670 // R (S::*)(A) --> R (A)
10671 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10672
10673 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10674 /// an overloaded function (C++ [over.over]), where @p From is an
10675 /// expression with overloaded function type and @p ToType is the type
10676 /// we're trying to resolve to. For example:
10677 ///
10678 /// @code
10679 /// int f(double);
10680 /// int f(int);
10681 ///
10682 /// int (*pfd)(double) = f; // selects f(double)
10683 /// @endcode
10684 ///
10685 /// This routine returns the resulting FunctionDecl if it could be
10686 /// resolved, and NULL otherwise. When @p Complain is true, this
10687 /// routine will emit diagnostics if there is an error.
10688 FunctionDecl *
10689 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10690 bool Complain, DeclAccessPair &Found,
10691 bool *pHadMultipleCandidates = nullptr);
10692
10693 /// Given an expression that refers to an overloaded function, try to
10694 /// resolve that function to a single function that can have its address
10695 /// taken. This will modify `Pair` iff it returns non-null.
10696 ///
10697 /// This routine can only succeed if from all of the candidates in the
10698 /// overload set for SrcExpr that can have their addresses taken, there is one
10699 /// candidate that is more constrained than the rest.
10700 FunctionDecl *
10701 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10702
10703 /// Given an overloaded function, tries to turn it into a non-overloaded
10704 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10705 /// will perform access checks, diagnose the use of the resultant decl, and,
10706 /// if requested, potentially perform a function-to-pointer decay.
10707 ///
10708 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10709 /// Otherwise, returns true. This may emit diagnostics and return true.
10711 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10712
10713 /// Given an expression that refers to an overloaded function, try to
10714 /// resolve that overloaded function expression down to a single function.
10715 ///
10716 /// This routine can only resolve template-ids that refer to a single function
10717 /// template, where that template-id refers to a single template whose
10718 /// template arguments are either provided by the template-id or have
10719 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10720 ///
10721 /// If no template-ids are found, no diagnostics are emitted and NULL is
10722 /// returned.
10724 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10725 TemplateSpecCandidateSet *FailedTSC = nullptr,
10726 bool ForTypeDeduction = false);
10727
10728 // Resolve and fix an overloaded expression that can be resolved
10729 // because it identifies a single function template specialization.
10730 //
10731 // Last three arguments should only be supplied if Complain = true
10732 //
10733 // Return true if it was logically possible to so resolve the
10734 // expression, regardless of whether or not it succeeded. Always
10735 // returns true if 'complain' is set.
10737 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10738 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10739 QualType DestTypeForComplaining = QualType(),
10740 unsigned DiagIDForComplaining = 0);
10741
10742 /// Add the overload candidates named by callee and/or found by argument
10743 /// dependent lookup to the given overload set.
10744 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10745 ArrayRef<Expr *> Args,
10746 OverloadCandidateSet &CandidateSet,
10747 bool PartialOverloading = false);
10748
10749 /// Add the call candidates from the given set of lookup results to the given
10750 /// overload set. Non-function lookup results are ignored.
10752 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10753 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10754
10755 // An enum used to represent the different possible results of building a
10756 // range-based for loop.
10762
10763 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10764 /// given LookupResult is non-empty, it is assumed to describe a member which
10765 /// will be invoked. Otherwise, the function will be found via argument
10766 /// dependent lookup.
10767 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10768 /// otherwise CallExpr is set to ExprError() and some non-success value
10769 /// is returned.
10771 SourceLocation RangeLoc,
10772 const DeclarationNameInfo &NameInfo,
10773 LookupResult &MemberLookup,
10774 OverloadCandidateSet *CandidateSet,
10775 Expr *Range, ExprResult *CallExpr);
10776
10777 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10778 /// (which eventually refers to the declaration Func) and the call
10779 /// arguments Args/NumArgs, attempt to resolve the function call down
10780 /// to a specific function. If overload resolution succeeds, returns
10781 /// the call expression produced by overload resolution.
10782 /// Otherwise, emits diagnostics and returns ExprError.
10784 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10785 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10786 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10787
10788 /// Constructs and populates an OverloadedCandidateSet from
10789 /// the given function.
10790 /// \returns true when an the ExprResult output parameter has been set.
10792 MultiExprArg Args, SourceLocation RParenLoc,
10793 OverloadCandidateSet *CandidateSet,
10795
10799 const UnresolvedSetImpl &Fns,
10800 bool PerformADL = true);
10801
10802 /// Create a unary operation that may resolve to an overloaded
10803 /// operator.
10804 ///
10805 /// \param OpLoc The location of the operator itself (e.g., '*').
10806 ///
10807 /// \param Opc The UnaryOperatorKind that describes this operator.
10808 ///
10809 /// \param Fns The set of non-member functions that will be
10810 /// considered by overload resolution. The caller needs to build this
10811 /// set based on the context using, e.g.,
10812 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10813 /// set should not contain any member functions; those will be added
10814 /// by CreateOverloadedUnaryOp().
10815 ///
10816 /// \param Input The input argument.
10819 const UnresolvedSetImpl &Fns, Expr *input,
10820 bool RequiresADL = true);
10821
10822 /// Perform lookup for an overloaded binary operator.
10825 const UnresolvedSetImpl &Fns,
10826 ArrayRef<Expr *> Args, bool RequiresADL = true);
10827
10828 /// Create a binary operation that may resolve to an overloaded
10829 /// operator.
10830 ///
10831 /// \param OpLoc The location of the operator itself (e.g., '+').
10832 ///
10833 /// \param Opc The BinaryOperatorKind that describes this operator.
10834 ///
10835 /// \param Fns The set of non-member functions that will be
10836 /// considered by overload resolution. The caller needs to build this
10837 /// set based on the context using, e.g.,
10838 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10839 /// set should not contain any member functions; those will be added
10840 /// by CreateOverloadedBinOp().
10841 ///
10842 /// \param LHS Left-hand argument.
10843 /// \param RHS Right-hand argument.
10844 /// \param PerformADL Whether to consider operator candidates found by ADL.
10845 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10846 /// C++20 operator rewrites.
10847 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
10848 /// the function in question. Such a function is never a candidate in
10849 /// our overload resolution. This also enables synthesizing a three-way
10850 /// comparison from < and == as described in C++20 [class.spaceship]p1.
10852 const UnresolvedSetImpl &Fns, Expr *LHS,
10853 Expr *RHS, bool RequiresADL = true,
10854 bool AllowRewrittenCandidates = true,
10855 FunctionDecl *DefaultedFn = nullptr);
10857 const UnresolvedSetImpl &Fns,
10858 Expr *LHS, Expr *RHS,
10859 FunctionDecl *DefaultedFn);
10860
10862 SourceLocation RLoc, Expr *Base,
10863 MultiExprArg Args);
10864
10865 /// BuildCallToMemberFunction - Build a call to a member
10866 /// function. MemExpr is the expression that refers to the member
10867 /// function (and includes the object parameter), Args/NumArgs are the
10868 /// arguments to the function call (not including the object
10869 /// parameter). The caller needs to validate that the member
10870 /// expression refers to a non-static member function or an overloaded
10871 /// member function.
10873 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
10874 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
10875 bool IsExecConfig = false, bool AllowRecovery = false);
10876
10877 /// BuildCallToObjectOfClassType - Build a call to an object of class
10878 /// type (C++ [over.call.object]), which can end up invoking an
10879 /// overloaded function call operator (@c operator()) or performing a
10880 /// user-defined conversion on the object argument.
10882 SourceLocation LParenLoc,
10883 MultiExprArg Args,
10884 SourceLocation RParenLoc);
10885
10886 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
10887 /// (if one exists), where @c Base is an expression of class type and
10888 /// @c Member is the name of the member we're trying to find.
10890 SourceLocation OpLoc,
10891 bool *NoArrowOperatorFound = nullptr);
10892
10895 bool HadMultipleCandidates);
10896
10897 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
10898 /// to a literal operator described by the provided lookup results.
10901 SourceLocation LitEndLoc,
10902 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10903
10904 /// FixOverloadedFunctionReference - E is an expression that refers to
10905 /// a C++ overloaded function (possibly with some parentheses and
10906 /// perhaps a '&' around it). We have resolved the overloaded function
10907 /// to the function declaration Fn, so patch up the expression E to
10908 /// refer (possibly indirectly) to Fn. Returns the new expr.
10910 FunctionDecl *Fn);
10912 DeclAccessPair FoundDecl,
10913 FunctionDecl *Fn);
10914
10915 /// - Returns a selector which best matches given argument list or
10916 /// nullptr if none could be found
10918 bool IsInstance,
10920
10921 ///@}
10922
10923 //
10924 //
10925 // -------------------------------------------------------------------------
10926 //
10927 //
10928
10929 /// \name Statements
10930 /// Implementations are in SemaStmt.cpp
10931 ///@{
10932
10933public:
10934 /// Stack of active SEH __finally scopes. Can be empty.
10936
10937 /// Stack of '_Defer' statements that are currently being parsed, as well
10938 /// as the locations of their '_Defer' keywords. Can be empty.
10940
10941 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
10943
10945 bool HasLeadingEmptyMacro = false);
10946
10948 SourceLocation EndLoc);
10950
10951 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
10952 /// whose result is unused, warn.
10953 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
10954
10955 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
10959 ArrayRef<Stmt *> Elts, bool isStmtExpr);
10960
10962
10965 SourceLocation DotDotDotLoc, ExprResult RHS,
10966 SourceLocation ColonLoc);
10967
10968 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
10969 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
10970
10972 SourceLocation ColonLoc, Stmt *SubStmt,
10973 Scope *CurScope);
10975 SourceLocation ColonLoc, Stmt *SubStmt);
10976
10978 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
10980 Stmt *SubStmt);
10981
10982 /// Check whether the given statement can have musttail applied to it,
10983 /// issuing a diagnostic and returning false if not. In the success case,
10984 /// the statement is rewritten to remove implicit nodes from the return
10985 /// value.
10986 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
10987
10989 SourceLocation LParenLoc, Stmt *InitStmt,
10991 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10993 SourceLocation LParenLoc, Stmt *InitStmt,
10995 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10996
10998
11000 SourceLocation LParenLoc, Stmt *InitStmt,
11002 SourceLocation RParenLoc);
11004 Stmt *Body);
11005
11006 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
11007 /// integer not in the range of enum values.
11008 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
11009 Expr *SrcExpr);
11010
11013 Stmt *Body);
11015 SourceLocation WhileLoc, SourceLocation CondLParen,
11016 Expr *Cond, SourceLocation CondRParen);
11017
11019 Stmt *First, ConditionResult Second,
11020 FullExprArg Third, SourceLocation RParenLoc,
11021 Stmt *Body);
11022
11023 /// In an Objective C collection iteration statement:
11024 /// for (x in y)
11025 /// x can be an arbitrary l-value expression. Bind it up as a
11026 /// full-expression.
11028
11030 /// Initial building of a for-range statement.
11032 /// Instantiation or recovery rebuild of a for-range statement. Don't
11033 /// attempt any typo-correction.
11035 /// Determining whether a for-range statement could be built. Avoid any
11036 /// unnecessary or irreversible actions.
11038 };
11039
11040 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
11041 ///
11042 /// C++11 [stmt.ranged]:
11043 /// A range-based for statement is equivalent to
11044 ///
11045 /// {
11046 /// auto && __range = range-init;
11047 /// for ( auto __begin = begin-expr,
11048 /// __end = end-expr;
11049 /// __begin != __end;
11050 /// ++__begin ) {
11051 /// for-range-declaration = *__begin;
11052 /// statement
11053 /// }
11054 /// }
11055 ///
11056 /// The body of the loop is not available yet, since it cannot be analysed
11057 /// until we have determined the type of the for-range-declaration.
11059 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
11060 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
11061 SourceLocation RParenLoc, BuildForRangeKind Kind,
11062 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11063
11064 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
11065 StmtResult BuildCXXForRangeStmt(
11066 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
11067 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
11068 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
11069 BuildForRangeKind Kind,
11070 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11071
11072 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
11073 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
11074 /// body cannot be performed until after the type of the range variable is
11075 /// determined.
11076 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
11077
11078 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
11079 LabelDecl *TheDecl);
11080 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
11081 SourceLocation StarLoc, Expr *DestExp);
11082 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope,
11083 LabelDecl *Label, SourceLocation LabelLoc);
11084 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope,
11085 LabelDecl *Label, SourceLocation LabelLoc);
11086
11087 void ActOnStartOfDeferStmt(SourceLocation DeferLoc, Scope *CurScope);
11088 void ActOnDeferStmtError(Scope *CurScope);
11089 StmtResult ActOnEndOfDeferStmt(Stmt *Body, Scope *CurScope);
11090
11093
11096
11097 bool isMoveEligible() const { return S != None; };
11099 };
11101
11102 /// Determine whether the given expression might be move-eligible or
11103 /// copy-elidable in either a (co_)return statement or throw expression,
11104 /// without considering function return type, if applicable.
11105 ///
11106 /// \param E The expression being returned from the function or block,
11107 /// being thrown, or being co_returned from a coroutine. This expression
11108 /// might be modified by the implementation.
11109 ///
11110 /// \param Mode Overrides detection of current language mode
11111 /// and uses the rules for C++23.
11112 ///
11113 /// \returns An aggregate which contains the Candidate and isMoveEligible
11114 /// and isCopyElidable methods. If Candidate is non-null, it means
11115 /// isMoveEligible() would be true under the most permissive language
11116 /// standard.
11117 NamedReturnInfo getNamedReturnInfo(
11119
11120 /// Determine whether the given NRVO candidate variable is move-eligible or
11121 /// copy-elidable, without considering function return type.
11122 ///
11123 /// \param VD The NRVO candidate variable.
11124 ///
11125 /// \returns An aggregate which contains the Candidate and isMoveEligible
11126 /// and isCopyElidable methods. If Candidate is non-null, it means
11127 /// isMoveEligible() would be true under the most permissive language
11128 /// standard.
11129 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
11130
11131 /// Updates given NamedReturnInfo's move-eligible and
11132 /// copy-elidable statuses, considering the function
11133 /// return type criteria as applicable to return statements.
11134 ///
11135 /// \param Info The NamedReturnInfo object to update.
11136 ///
11137 /// \param ReturnType This is the return type of the function.
11138 /// \returns The copy elision candidate, in case the initial return expression
11139 /// was copy elidable, or nullptr otherwise.
11140 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
11141 QualType ReturnType);
11142
11143 /// Perform the initialization of a potentially-movable value, which
11144 /// is the result of return value.
11145 ///
11146 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
11147 /// treat returned lvalues as rvalues in certain cases (to prefer move
11148 /// construction), then falls back to treating them as lvalues if that failed.
11151 const NamedReturnInfo &NRInfo, Expr *Value,
11152 bool SupressSimplerImplicitMoves = false);
11153
11155
11156 /// Deduce the return type for a function from a returned expression, per
11157 /// C++1y [dcl.spec.auto]p6.
11159 SourceLocation ReturnLoc, Expr *RetExpr,
11160 const AutoType *AT);
11161
11162 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11163 Scope *CurScope);
11164 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11165 bool AllowRecovery = false);
11166
11167 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
11168 /// for capturing scopes.
11170 NamedReturnInfo &NRInfo,
11171 bool SupressSimplerImplicitMoves);
11172
11173 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
11174 /// and creates a proper catch handler from them.
11176 Stmt *HandlerBlock);
11177
11178 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
11179 /// handlers and creates a try statement from them.
11181 ArrayRef<Stmt *> Handlers);
11182
11183 void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry);
11184
11185 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
11186 SourceLocation TryLoc, Stmt *TryBlock,
11187 Stmt *Handler);
11189 Stmt *Block);
11194
11196 bool IsIfExists,
11197 NestedNameSpecifierLoc QualifierLoc,
11198 DeclarationNameInfo NameInfo,
11199 Stmt *Nested);
11201 bool IsIfExists, CXXScopeSpec &SS,
11202 UnqualifiedId &Name, Stmt *Nested);
11203
11204 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11205 CapturedRegionKind Kind, unsigned NumParams);
11206 typedef std::pair<StringRef, QualType> CapturedParamNameType;
11207 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11208 CapturedRegionKind Kind,
11210 unsigned OpenMPCaptureLevel = 0);
11214 SourceLocation Loc,
11215 unsigned NumParams);
11216
11217private:
11218 /// Check whether the given statement can have musttail applied to it,
11219 /// issuing a diagnostic and returning false if not.
11220 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
11221
11222 /// Check if the given expression contains 'break' or 'continue'
11223 /// statement that produces control flow different from GCC.
11224 void CheckBreakContinueBinding(Expr *E);
11225
11226 ///@}
11227
11228 //
11229 //
11230 // -------------------------------------------------------------------------
11231 //
11232 //
11233
11234 /// \name `inline asm` Statement
11235 /// Implementations are in SemaStmtAsm.cpp
11236 ///@{
11237
11238public:
11239 ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel);
11240 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
11241 bool IsVolatile, unsigned NumOutputs,
11242 unsigned NumInputs, IdentifierInfo **Names,
11243 MultiExprArg Constraints, MultiExprArg Exprs,
11244 Expr *AsmString, MultiExprArg Clobbers,
11245 unsigned NumLabels, SourceLocation RParenLoc);
11246
11248 llvm::InlineAsmIdentifierInfo &Info);
11250 SourceLocation TemplateKWLoc,
11251 UnqualifiedId &Id,
11252 bool IsUnevaluatedContext);
11253 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
11254 SourceLocation AsmLoc);
11256 SourceLocation AsmLoc);
11258 ArrayRef<Token> AsmToks, StringRef AsmString,
11259 unsigned NumOutputs, unsigned NumInputs,
11260 ArrayRef<StringRef> Constraints,
11261 ArrayRef<StringRef> Clobbers,
11262 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
11263 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
11264 SourceLocation Location, bool AlwaysCreate);
11265
11266 ///@}
11267
11268 //
11269 //
11270 // -------------------------------------------------------------------------
11271 //
11272 //
11273
11274 /// \name Statement Attribute Handling
11275 /// Implementations are in SemaStmtAttr.cpp
11276 ///@{
11277
11278public:
11279 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11280 const AttributeCommonInfo &A);
11281 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11282 const AttributeCommonInfo &A);
11283
11284 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11286
11287 /// Process the attributes before creating an attributed statement. Returns
11288 /// the semantic attributes that have been processed.
11289 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11291
11293 SourceRange Range);
11295 const IdentifierInfo *AttrName,
11296 SourceRange Range);
11297
11298 ///@}
11299
11300 //
11301 //
11302 // -------------------------------------------------------------------------
11303 //
11304 //
11305
11306 /// \name C++ Templates
11307 /// Implementations are in SemaTemplate.cpp
11308 ///@{
11309
11310public:
11311 // Saves the current floating-point pragma stack and clear it in this Sema.
11313 public:
11315 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11316 S.FpPragmaStack.Stack.clear();
11317 }
11318 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11319
11320 private:
11321 Sema &S;
11323 };
11324
11326 CurFPFeatures = FPO;
11327 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11328 }
11329
11335
11340
11341 typedef llvm::MapVector<const FunctionDecl *,
11342 std::unique_ptr<LateParsedTemplate>>
11345
11346 /// Determine the number of levels of enclosing template parameters. This is
11347 /// only usable while parsing. Note that this does not include dependent
11348 /// contexts in which no template parameters have yet been declared, such as
11349 /// in a terse function template or generic lambda before the first 'auto' is
11350 /// encountered.
11351 unsigned getTemplateDepth(Scope *S) const;
11352
11354 bool AllowFunctionTemplates = true,
11355 bool AllowDependent = true);
11357 bool AllowFunctionTemplates = true,
11358 bool AllowDependent = true,
11359 bool AllowNonTemplateFunctions = false);
11360 /// Try to interpret the lookup result D as a template-name.
11361 ///
11362 /// \param D A declaration found by name lookup.
11363 /// \param AllowFunctionTemplates Whether function templates should be
11364 /// considered valid results.
11365 /// \param AllowDependent Whether unresolved using declarations (that might
11366 /// name templates) should be considered valid results.
11368 bool AllowFunctionTemplates = true,
11369 bool AllowDependent = true);
11370
11372 /// Whether and why a template name is required in this lookup.
11374 public:
11375 /// Template name is required if TemplateKWLoc is valid.
11377 : TemplateKW(TemplateKWLoc) {}
11378 /// Template name is unconditionally required.
11380
11382 return TemplateKW.value_or(SourceLocation());
11383 }
11384 bool hasTemplateKeyword() const {
11385 return getTemplateKeywordLoc().isValid();
11386 }
11387 bool isRequired() const { return TemplateKW != SourceLocation(); }
11388 explicit operator bool() const { return isRequired(); }
11389
11390 private:
11391 std::optional<SourceLocation> TemplateKW;
11392 };
11393
11395 /// This is not assumed to be a template name.
11397 /// This is assumed to be a template name because lookup found nothing.
11399 /// This is assumed to be a template name because lookup found one or more
11400 /// functions (but no function templates).
11402 };
11403
11404 bool
11406 QualType ObjectType, bool EnteringContext,
11407 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11408 AssumedTemplateKind *ATK = nullptr,
11409 bool AllowTypoCorrection = true);
11410
11412 bool hasTemplateKeyword,
11413 const UnqualifiedId &Name,
11414 ParsedType ObjectType, bool EnteringContext,
11416 bool &MemberOfUnknownSpecialization,
11417 bool Disambiguation = false);
11418
11419 /// Try to resolve an undeclared template name as a type template.
11420 ///
11421 /// Sets II to the identifier corresponding to the template name, and updates
11422 /// Name to a corresponding (typo-corrected) type template name and TNK to
11423 /// the corresponding kind, if possible.
11425 TemplateNameKind &TNK,
11426 SourceLocation NameLoc,
11427 IdentifierInfo *&II);
11428
11429 /// Determine whether a particular identifier might be the name in a C++1z
11430 /// deduction-guide declaration.
11431 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11432 SourceLocation NameLoc, CXXScopeSpec &SS,
11433 ParsedTemplateTy *Template = nullptr);
11434
11436 SourceLocation IILoc, Scope *S,
11437 const CXXScopeSpec *SS,
11438 TemplateTy &SuggestedTemplate,
11439 TemplateNameKind &SuggestedKind);
11440
11441 /// Determine whether we would be unable to instantiate this template (because
11442 /// it either has no definition, or is in the process of being instantiated).
11444 SourceLocation PointOfInstantiation, NamedDecl *Instantiation,
11445 bool InstantiatedFromMember, const NamedDecl *Pattern,
11446 const NamedDecl *PatternDef, TemplateSpecializationKind TSK,
11447 bool Complain = true, bool *Unreachable = nullptr);
11448
11449 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11450 /// that the template parameter 'PrevDecl' is being shadowed by a new
11451 /// declaration at location Loc. Returns true to indicate that this is
11452 /// an error, and false otherwise.
11453 ///
11454 /// \param Loc The location of the declaration that shadows a template
11455 /// parameter.
11456 ///
11457 /// \param PrevDecl The template parameter that the declaration shadows.
11458 ///
11459 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11460 /// a warning for compatibility with older versions of clang.
11461 /// Ignored when MSVC compatibility is enabled.
11463 bool SupportedForCompatibility = false);
11464
11465 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11466 /// the parameter D to reference the templated declaration and return a
11467 /// pointer to the template declaration. Otherwise, do nothing to D and return
11468 /// null.
11470
11471 /// ActOnTypeParameter - Called when a C++ template type parameter
11472 /// (e.g., "typename T") has been parsed. Typename specifies whether
11473 /// the keyword "typename" was used to declare the type parameter
11474 /// (otherwise, "class" was used), and KeyLoc is the location of the
11475 /// "class" or "typename" keyword. ParamName is the name of the
11476 /// parameter (NULL indicates an unnamed template parameter) and
11477 /// ParamNameLoc is the location of the parameter name (if any).
11478 /// If the type parameter has a default argument, it will be added
11479 /// later via ActOnTypeParameterDefault.
11481 SourceLocation EllipsisLoc,
11482 SourceLocation KeyLoc,
11483 IdentifierInfo *ParamName,
11484 SourceLocation ParamNameLoc, unsigned Depth,
11485 unsigned Position, SourceLocation EqualLoc,
11486 ParsedType DefaultArg, bool HasTypeConstraint);
11487
11489
11490 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11492 TemplateTypeParmDecl *ConstrainedParameter,
11493 SourceLocation EllipsisLoc);
11494 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11496 TemplateTypeParmDecl *ConstrainedParameter,
11497 SourceLocation EllipsisLoc,
11498 bool AllowUnexpandedPack);
11499
11500 /// Attach a type-constraint to a template parameter.
11501 /// \returns true if an error occurred. This can happen if the
11502 /// immediately-declared constraint could not be formed (e.g. incorrect number
11503 /// of arguments for the named concept).
11505 DeclarationNameInfo NameInfo,
11506 TemplateDecl *NamedConcept, NamedDecl *FoundDecl,
11507 const TemplateArgumentListInfo *TemplateArgs,
11508 TemplateTypeParmDecl *ConstrainedParameter,
11509 SourceLocation EllipsisLoc);
11510
11512 NonTypeTemplateParmDecl *NewConstrainedParm,
11513 NonTypeTemplateParmDecl *OrigConstrainedParm,
11514 SourceLocation EllipsisLoc);
11515
11516 /// Require the given type to be a structural type, and diagnose if it is not.
11517 ///
11518 /// \return \c true if an error was produced.
11520
11521 /// Check that the type of a non-type template parameter is
11522 /// well-formed.
11523 ///
11524 /// \returns the (possibly-promoted) parameter type if valid;
11525 /// otherwise, produces a diagnostic and returns a NULL type.
11527 SourceLocation Loc);
11529
11531 unsigned Depth, unsigned Position,
11532 SourceLocation EqualLoc,
11533 Expr *DefaultArg);
11534
11535 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11536 /// parameter (e.g. T in template <template <typename> class T> class array)
11537 /// has been parsed. S is the current scope.
11539 Scope *S, SourceLocation TmpLoc, TemplateNameKind Kind,
11540 bool TypenameKeyword, TemplateParameterList *Params,
11541 SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11542 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11543 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11544
11545 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11546 /// constrained by RequiresClause, that contains the template parameters in
11547 /// Params.
11549 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11550 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11551 SourceLocation RAngleLoc, Expr *RequiresClause);
11552
11553 /// The context in which we are checking a template parameter list.
11555 // For this context, Class, Variable, TypeAlias, and non-pack Template
11556 // Template Parameters are treated uniformly.
11558
11565 };
11566
11567 /// Checks the validity of a template parameter list, possibly
11568 /// considering the template parameter list from a previous
11569 /// declaration.
11570 ///
11571 /// If an "old" template parameter list is provided, it must be
11572 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11573 /// template parameter list.
11574 ///
11575 /// \param NewParams Template parameter list for a new template
11576 /// declaration. This template parameter list will be updated with any
11577 /// default arguments that are carried through from the previous
11578 /// template parameter list.
11579 ///
11580 /// \param OldParams If provided, template parameter list from a
11581 /// previous declaration of the same template. Default template
11582 /// arguments will be merged from the old template parameter list to
11583 /// the new template parameter list.
11584 ///
11585 /// \param TPC Describes the context in which we are checking the given
11586 /// template parameter list.
11587 ///
11588 /// \param SkipBody If we might have already made a prior merged definition
11589 /// of this template visible, the corresponding body-skipping information.
11590 /// Default argument redefinition is not an error when skipping such a body,
11591 /// because (under the ODR) we can assume the default arguments are the same
11592 /// as the prior merged definition.
11593 ///
11594 /// \returns true if an error occurred, false otherwise.
11596 TemplateParameterList *OldParams,
11598 SkipBodyInfo *SkipBody = nullptr);
11599
11600 /// Match the given template parameter lists to the given scope
11601 /// specifier, returning the template parameter list that applies to the
11602 /// name.
11603 ///
11604 /// \param DeclStartLoc the start of the declaration that has a scope
11605 /// specifier or a template parameter list.
11606 ///
11607 /// \param DeclLoc The location of the declaration itself.
11608 ///
11609 /// \param SS the scope specifier that will be matched to the given template
11610 /// parameter lists. This scope specifier precedes a qualified name that is
11611 /// being declared.
11612 ///
11613 /// \param TemplateId The template-id following the scope specifier, if there
11614 /// is one. Used to check for a missing 'template<>'.
11615 ///
11616 /// \param ParamLists the template parameter lists, from the outermost to the
11617 /// innermost template parameter lists.
11618 ///
11619 /// \param IsFriend Whether to apply the slightly different rules for
11620 /// matching template parameters to scope specifiers in friend
11621 /// declarations.
11622 ///
11623 /// \param IsMemberSpecialization will be set true if the scope specifier
11624 /// denotes a fully-specialized type, and therefore this is a declaration of
11625 /// a member specialization.
11626 ///
11627 /// \returns the template parameter list, if any, that corresponds to the
11628 /// name that is preceded by the scope specifier @p SS. This template
11629 /// parameter list may have template parameters (if we're declaring a
11630 /// template) or may have no template parameters (if we're declaring a
11631 /// template specialization), or may be NULL (if what we're declaring isn't
11632 /// itself a template).
11634 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11635 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11636 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11637 bool &IsMemberSpecialization, bool &Invalid,
11638 bool SuppressDiagnostic = false);
11639
11640 /// Returns the template parameter list with all default template argument
11641 /// information.
11643
11645 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11646 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11647 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11648 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11649 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11650 TemplateParameterList **OuterTemplateParamLists,
11651 SkipBodyInfo *SkipBody = nullptr);
11652
11653 /// Translates template arguments as provided by the parser
11654 /// into template arguments used by semantic analysis.
11657
11658 /// Convert a parsed type into a parsed template argument. This is mostly
11659 /// trivial, except that we may have parsed a C++17 deduced class template
11660 /// specialization type, in which case we should form a template template
11661 /// argument instead of a type template argument.
11663
11665
11668 SourceLocation TemplateLoc,
11669 TemplateArgumentListInfo &TemplateArgs,
11670 Scope *Scope, bool ForNestedNameSpecifier);
11671
11673 ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword,
11674 SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS,
11675 SourceLocation TemplateKWLoc, TemplateTy Template,
11676 const IdentifierInfo *TemplateII,
11677 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11678 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11679 bool IsCtorOrDtorName = false, bool IsClassName = false,
11680 ImplicitTypenameContext AllowImplicitTypename =
11682
11683 /// Parsed an elaborated-type-specifier that refers to a template-id,
11684 /// such as \c class T::template apply<U>.
11686 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11687 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11688 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11689 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11690
11693 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11695
11696 /// Get the specialization of the given variable template corresponding to
11697 /// the specified argument list, or a null-but-valid result if the arguments
11698 /// are dependent.
11700 SourceLocation TemplateLoc,
11701 SourceLocation TemplateNameLoc,
11702 const TemplateArgumentListInfo &TemplateArgs,
11703 bool SetWrittenArgs);
11704
11705 /// Form a reference to the specialization of the given variable template
11706 /// corresponding to the specified argument list, or a null-but-valid result
11707 /// if the arguments are dependent.
11709 const DeclarationNameInfo &NameInfo,
11711 SourceLocation TemplateLoc,
11712 const TemplateArgumentListInfo *TemplateArgs);
11713
11715 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
11717 const TemplateArgumentListInfo *TemplateArgs);
11718
11720 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11721 const DeclarationNameInfo &ConceptNameInfo,
11722 NamedDecl *FoundDecl, TemplateDecl *NamedConcept,
11723 const TemplateArgumentListInfo *TemplateArgs,
11724 bool DoCheckConstraintSatisfaction = true);
11725
11728 bool TemplateKeyword, TemplateDecl *TD,
11729 SourceLocation Loc);
11730
11732 SourceLocation TemplateKWLoc, LookupResult &R,
11733 bool RequiresADL,
11734 const TemplateArgumentListInfo *TemplateArgs);
11735
11736 // We actually only call this from template instantiation.
11739 const DeclarationNameInfo &NameInfo,
11740 const TemplateArgumentListInfo *TemplateArgs,
11741 bool IsAddressOfOperand);
11742
11744 return Pack.pack_size() - 1 - *ArgPackSubstIndex;
11745 }
11746
11749 Arg = Arg.pack_elements()[*ArgPackSubstIndex];
11750 if (Arg.isPackExpansion())
11751 Arg = Arg.getPackExpansionPattern();
11752 return Arg;
11753 }
11754
11756 Decl *AssociatedDecl, const NonTypeTemplateParmDecl *NTTP,
11757 SourceLocation loc, TemplateArgument Replacement,
11758 UnsignedOrNone PackIndex, bool Final);
11759
11760 /// Form a template name from a name that is syntactically required to name a
11761 /// template, either due to use of the 'template' keyword or because a name in
11762 /// this syntactic context is assumed to name a template (C++
11763 /// [temp.names]p2-4).
11764 ///
11765 /// This action forms a template name given the name of the template and its
11766 /// optional scope specifier. This is used when the 'template' keyword is used
11767 /// or when the parsing context unambiguously treats a following '<' as
11768 /// introducing a template argument list. Note that this may produce a
11769 /// non-dependent template name if we can perform the lookup now and identify
11770 /// the named template.
11771 ///
11772 /// For example, given "x.MetaFun::template apply", the scope specifier
11773 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11774 /// of the "template" keyword, and "apply" is the \p Name.
11776 SourceLocation TemplateKWLoc,
11777 const UnqualifiedId &Name,
11778 ParsedType ObjectType,
11779 bool EnteringContext, TemplateTy &Template,
11780 bool AllowInjectedClassName = false);
11781
11783 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11784 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11786 MultiTemplateParamsArg TemplateParameterLists,
11787 SkipBodyInfo *SkipBody = nullptr);
11788
11789 /// Check the non-type template arguments of a class template
11790 /// partial specialization according to C++ [temp.class.spec]p9.
11791 ///
11792 /// \param TemplateNameLoc the location of the template name.
11793 /// \param PrimaryTemplate the template parameters of the primary class
11794 /// template.
11795 /// \param NumExplicit the number of explicitly-specified template arguments.
11796 /// \param TemplateArgs the template arguments of the class template
11797 /// partial specialization.
11798 ///
11799 /// \returns \c true if there was an error, \c false otherwise.
11801 TemplateDecl *PrimaryTemplate,
11802 unsigned NumExplicitArgs,
11808
11810 MultiTemplateParamsArg TemplateParameterLists,
11811 Declarator &D);
11812
11813 /// Diagnose cases where we have an explicit template specialization
11814 /// before/after an explicit template instantiation, producing diagnostics
11815 /// for those cases where they are required and determining whether the
11816 /// new specialization/instantiation will have any effect.
11817 ///
11818 /// \param NewLoc the location of the new explicit specialization or
11819 /// instantiation.
11820 ///
11821 /// \param NewTSK the kind of the new explicit specialization or
11822 /// instantiation.
11823 ///
11824 /// \param PrevDecl the previous declaration of the entity.
11825 ///
11826 /// \param PrevTSK the kind of the old explicit specialization or
11827 /// instantiatin.
11828 ///
11829 /// \param PrevPointOfInstantiation if valid, indicates where the previous
11830 /// declaration was instantiated (either implicitly or explicitly).
11831 ///
11832 /// \param HasNoEffect will be set to true to indicate that the new
11833 /// specialization or instantiation has no effect and should be ignored.
11834 ///
11835 /// \returns true if there was an error that should prevent the introduction
11836 /// of the new declaration into the AST, false otherwise.
11838 SourceLocation NewLoc,
11839 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
11840 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
11841 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
11842
11843 /// Perform semantic analysis for the given dependent function
11844 /// template specialization.
11845 ///
11846 /// The only possible way to get a dependent function template specialization
11847 /// is with a friend declaration, like so:
11848 ///
11849 /// \code
11850 /// template <class T> void foo(T);
11851 /// template <class T> class A {
11852 /// friend void foo<>(T);
11853 /// };
11854 /// \endcode
11855 ///
11856 /// There really isn't any useful analysis we can do here, so we
11857 /// just store the information.
11859 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
11861
11862 /// Perform semantic analysis for the given function template
11863 /// specialization.
11864 ///
11865 /// This routine performs all of the semantic analysis required for an
11866 /// explicit function template specialization. On successful completion,
11867 /// the function declaration \p FD will become a function template
11868 /// specialization.
11869 ///
11870 /// \param FD the function declaration, which will be updated to become a
11871 /// function template specialization.
11872 ///
11873 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
11874 /// if any. Note that this may be valid info even when 0 arguments are
11875 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
11876 /// as it anyway contains info on the angle brackets locations.
11877 ///
11878 /// \param Previous the set of declarations that may be specialized by
11879 /// this function specialization.
11880 ///
11881 /// \param QualifiedFriend whether this is a lookup for a qualified friend
11882 /// declaration with no explicit template argument list that might be
11883 /// befriending a function template specialization.
11885 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
11886 LookupResult &Previous, bool QualifiedFriend = false);
11887
11888 /// Perform semantic analysis for the given non-template member
11889 /// specialization.
11890 ///
11891 /// This routine performs all of the semantic analysis required for an
11892 /// explicit member function specialization. On successful completion,
11893 /// the function declaration \p FD will become a member function
11894 /// specialization.
11895 ///
11896 /// \param Member the member declaration, which will be updated to become a
11897 /// specialization.
11898 ///
11899 /// \param Previous the set of declarations, one of which may be specialized
11900 /// by this function specialization; the set will be modified to contain the
11901 /// redeclared member.
11904
11905 // Explicit instantiation of a class template specialization
11907 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
11908 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
11909 TemplateTy Template, SourceLocation TemplateNameLoc,
11910 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
11911 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
11912
11913 // Explicit instantiation of a member class of a class template.
11915 SourceLocation TemplateLoc,
11916 unsigned TagSpec, SourceLocation KWLoc,
11917 CXXScopeSpec &SS, IdentifierInfo *Name,
11918 SourceLocation NameLoc,
11919 const ParsedAttributesView &Attr);
11920
11922 SourceLocation TemplateLoc,
11923 Declarator &D);
11924
11925 /// If the given template parameter has a default template
11926 /// argument, substitute into that default template argument and
11927 /// return the corresponding template argument.
11929 TemplateDecl *Template, SourceLocation TemplateKWLoc,
11930 SourceLocation TemplateNameLoc, SourceLocation RAngleLoc, Decl *Param,
11931 ArrayRef<TemplateArgument> SugaredConverted,
11932 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
11933
11934 /// Returns the top most location responsible for the definition of \p N.
11935 /// If \p N is a a template specialization, this is the location
11936 /// of the top of the instantiation stack.
11937 /// Otherwise, the location of \p N is returned.
11939
11940 /// Specifies the context in which a particular template
11941 /// argument is being checked.
11943 /// The template argument was specified in the code or was
11944 /// instantiated with some deduced template arguments.
11946
11947 /// The template argument was deduced via template argument
11948 /// deduction.
11950
11951 /// The template argument was deduced from an array bound
11952 /// via template argument deduction.
11954 };
11955
11963
11964 /// The checked, converted argument will be added to the
11965 /// end of these vectors.
11967
11968 /// The check is being performed in the context of partial ordering.
11970
11971 /// If true, assume these template arguments are
11972 /// the injected template arguments for a template template parameter.
11973 /// This will relax the requirement that all its possible uses are valid:
11974 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11975 /// during instantiation.
11977
11978 /// Is set to true when, in the context of TTP matching, a pack parameter
11979 /// matches non-pack arguments.
11980 bool StrictPackMatch = false;
11981 };
11982
11983 /// Check that the given template argument corresponds to the given
11984 /// template parameter.
11985 ///
11986 /// \param Param The template parameter against which the argument will be
11987 /// checked.
11988 ///
11989 /// \param Arg The template argument, which may be updated due to conversions.
11990 ///
11991 /// \param Template The template in which the template argument resides.
11992 ///
11993 /// \param TemplateLoc The location of the template name for the template
11994 /// whose argument list we're matching.
11995 ///
11996 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
11997 /// the template argument list.
11998 ///
11999 /// \param ArgumentPackIndex The index into the argument pack where this
12000 /// argument will be placed. Only valid if the parameter is a parameter pack.
12001 ///
12002 /// \param CTAK Describes how we arrived at this particular template argument:
12003 /// explicitly written, deduced, etc.
12004 ///
12005 /// \returns true on error, false otherwise.
12007 NamedDecl *Template, SourceLocation TemplateLoc,
12008 SourceLocation RAngleLoc,
12009 unsigned ArgumentPackIndex,
12012
12013 /// Check that the given template arguments can be provided to
12014 /// the given template, converting the arguments along the way.
12015 ///
12016 /// \param Template The template to which the template arguments are being
12017 /// provided.
12018 ///
12019 /// \param TemplateLoc The location of the template name in the source.
12020 ///
12021 /// \param TemplateArgs The list of template arguments. If the template is
12022 /// a template template parameter, this function may extend the set of
12023 /// template arguments to also include substituted, defaulted template
12024 /// arguments.
12025 ///
12026 /// \param PartialTemplateArgs True if the list of template arguments is
12027 /// intentionally partial, e.g., because we're checking just the initial
12028 /// set of template arguments.
12029 ///
12030 /// \param Converted Will receive the converted, canonicalized template
12031 /// arguments.
12032 ///
12033 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
12034 /// contain the converted forms of the template arguments as written.
12035 /// Otherwise, \p TemplateArgs will not be modified.
12036 ///
12037 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
12038 /// receive true if the cause for the error is the associated constraints of
12039 /// the template not being satisfied by the template arguments.
12040 ///
12041 /// \param DefaultArgs any default arguments from template specialization
12042 /// deduction.
12043 ///
12044 /// \returns true if an error occurred, false otherwise.
12046 SourceLocation TemplateLoc,
12047 TemplateArgumentListInfo &TemplateArgs,
12048 const DefaultArguments &DefaultArgs,
12049 bool PartialTemplateArgs,
12051 bool UpdateArgsWithConversions = true,
12052 bool *ConstraintsNotSatisfied = nullptr);
12053
12056 SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs,
12057 const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
12058 CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions = true,
12059 bool *ConstraintsNotSatisfied = nullptr);
12060
12063 SmallVectorImpl<TemplateArgument> &SugaredConverted,
12064 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
12065
12066 /// Check a template argument against its corresponding
12067 /// template type parameter.
12068 ///
12069 /// This routine implements the semantics of C++ [temp.arg.type]. It
12070 /// returns true if an error occurred, and false otherwise.
12072
12073 /// Check a template argument against its corresponding
12074 /// non-type template parameter.
12075 ///
12076 /// This routine implements the semantics of C++ [temp.arg.nontype].
12077 /// If an error occurred, it returns ExprError(); otherwise, it
12078 /// returns the converted template argument. \p ParamType is the
12079 /// type of the non-type template parameter after it has been instantiated.
12081 QualType InstantiatedParamType, Expr *Arg,
12082 TemplateArgument &SugaredConverted,
12083 TemplateArgument &CanonicalConverted,
12084 bool StrictCheck,
12086
12087 /// Check a template argument against its corresponding
12088 /// template template parameter.
12089 ///
12090 /// This routine implements the semantics of C++ [temp.arg.template].
12091 /// It returns true if an error occurred, and false otherwise.
12093 TemplateParameterList *Params,
12095 bool PartialOrdering,
12096 bool *StrictPackMatch);
12097
12100 const TemplateArgumentLoc &Arg);
12101
12103 std::optional<SourceRange> ParamRange = {});
12105
12106 /// Given a non-type template argument that refers to a
12107 /// declaration and the type of its corresponding non-type template
12108 /// parameter, produce an expression that properly refers to that
12109 /// declaration.
12110 /// FIXME: This is used in some contexts where the resulting expression
12111 /// doesn't need to live too long. It would be useful if this function
12112 /// could return a temporary expression.
12114 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
12115 NamedDecl *TemplateParam = nullptr);
12118 SourceLocation Loc);
12119
12120 /// Enumeration describing how template parameter lists are compared
12121 /// for equality.
12123 /// We are matching the template parameter lists of two templates
12124 /// that might be redeclarations.
12125 ///
12126 /// \code
12127 /// template<typename T> struct X;
12128 /// template<typename T> struct X;
12129 /// \endcode
12131
12132 /// We are matching the template parameter lists of two template
12133 /// template parameters as part of matching the template parameter lists
12134 /// of two templates that might be redeclarations.
12135 ///
12136 /// \code
12137 /// template<template<int I> class TT> struct X;
12138 /// template<template<int Value> class Other> struct X;
12139 /// \endcode
12141
12142 /// We are determining whether the template-parameters are equivalent
12143 /// according to C++ [temp.over.link]/6. This comparison does not consider
12144 /// constraints.
12145 ///
12146 /// \code
12147 /// template<C1 T> void f(T);
12148 /// template<C2 T> void f(T);
12149 /// \endcode
12151 };
12152
12153 // A struct to represent the 'new' declaration, which is either itself just
12154 // the named decl, or the important information we need about it in order to
12155 // do constraint comparisons.
12157 const NamedDecl *ND = nullptr;
12158 const DeclContext *DC = nullptr;
12159 const DeclContext *LexicalDC = nullptr;
12160 SourceLocation Loc;
12161
12162 public:
12165 const DeclContext *LexicalDeclCtx,
12166 SourceLocation Loc)
12167
12168 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
12169 assert(DC && LexicalDC &&
12170 "Constructor only for cases where we have the information to put "
12171 "in here");
12172 }
12173
12174 // If this was constructed with no information, we cannot do substitution
12175 // for constraint comparison, so make sure we can check that.
12176 bool isInvalid() const { return !ND && !DC; }
12177
12178 const NamedDecl *getDecl() const { return ND; }
12179
12180 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
12181
12183 return ND ? ND->getLexicalDeclContext() : LexicalDC;
12184 }
12185
12187 return ND ? ND->getDeclContext() : DC;
12188 }
12189
12190 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
12191 };
12192
12193 /// Determine whether the given template parameter lists are
12194 /// equivalent.
12195 ///
12196 /// \param New The new template parameter list, typically written in the
12197 /// source code as part of a new template declaration.
12198 ///
12199 /// \param Old The old template parameter list, typically found via
12200 /// name lookup of the template declared with this template parameter
12201 /// list.
12202 ///
12203 /// \param Complain If true, this routine will produce a diagnostic if
12204 /// the template parameter lists are not equivalent.
12205 ///
12206 /// \param Kind describes how we are to match the template parameter lists.
12207 ///
12208 /// \param TemplateArgLoc If this source location is valid, then we
12209 /// are actually checking the template parameter list of a template
12210 /// argument (New) against the template parameter list of its
12211 /// corresponding template template parameter (Old). We produce
12212 /// slightly different diagnostics in this scenario.
12213 ///
12214 /// \returns True if the template parameter lists are equal, false
12215 /// otherwise.
12217 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
12218 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
12220 SourceLocation TemplateArgLoc = SourceLocation());
12221
12223 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
12225 SourceLocation TemplateArgLoc = SourceLocation()) {
12226 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
12227 Kind, TemplateArgLoc);
12228 }
12229
12230 /// Check whether a template can be declared within this scope.
12231 ///
12232 /// If the template declaration is valid in this scope, returns
12233 /// false. Otherwise, issues a diagnostic and returns true.
12234 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
12235
12236 /// Called when the parser has parsed a C++ typename
12237 /// specifier, e.g., "typename T::type".
12238 ///
12239 /// \param S The scope in which this typename type occurs.
12240 /// \param TypenameLoc the location of the 'typename' keyword
12241 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12242 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
12243 /// \param IdLoc the location of the identifier.
12244 /// \param IsImplicitTypename context where T::type refers to a type.
12246 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
12247 const IdentifierInfo &II, SourceLocation IdLoc,
12249
12250 /// Called when the parser has parsed a C++ typename
12251 /// specifier that ends in a template-id, e.g.,
12252 /// "typename MetaFun::template apply<T1, T2>".
12253 ///
12254 /// \param S The scope in which this typename type occurs.
12255 /// \param TypenameLoc the location of the 'typename' keyword
12256 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12257 /// \param TemplateLoc the location of the 'template' keyword, if any.
12258 /// \param TemplateName The template name.
12259 /// \param TemplateII The identifier used to name the template.
12260 /// \param TemplateIILoc The location of the template name.
12261 /// \param LAngleLoc The location of the opening angle bracket ('<').
12262 /// \param TemplateArgs The template arguments.
12263 /// \param RAngleLoc The location of the closing angle bracket ('>').
12265 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
12266 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
12267 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
12268 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
12269 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
12270
12272 SourceLocation KeywordLoc,
12273 NestedNameSpecifierLoc QualifierLoc,
12274 const IdentifierInfo &II, SourceLocation IILoc,
12275 TypeSourceInfo **TSI, bool DeducedTSTContext);
12276
12278 SourceLocation KeywordLoc,
12279 NestedNameSpecifierLoc QualifierLoc,
12280 const IdentifierInfo &II, SourceLocation IILoc,
12281 bool DeducedTSTContext = true);
12282
12283 /// Rebuilds a type within the context of the current instantiation.
12284 ///
12285 /// The type \p T is part of the type of an out-of-line member definition of
12286 /// a class template (or class template partial specialization) that was
12287 /// parsed and constructed before we entered the scope of the class template
12288 /// (or partial specialization thereof). This routine will rebuild that type
12289 /// now that we have entered the declarator's scope, which may produce
12290 /// different canonical types, e.g.,
12291 ///
12292 /// \code
12293 /// template<typename T>
12294 /// struct X {
12295 /// typedef T* pointer;
12296 /// pointer data();
12297 /// };
12298 ///
12299 /// template<typename T>
12300 /// typename X<T>::pointer X<T>::data() { ... }
12301 /// \endcode
12302 ///
12303 /// Here, the type "typename X<T>::pointer" will be created as a
12304 /// DependentNameType, since we do not know that we can look into X<T> when we
12305 /// parsed the type. This function will rebuild the type, performing the
12306 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
12307 /// canonical type is the same as the canonical type of T*, allowing the
12308 /// return types of the out-of-line definition and the declaration to match.
12310 SourceLocation Loc,
12311 DeclarationName Name);
12313
12315
12316 /// Rebuild the template parameters now that we know we're in a current
12317 /// instantiation.
12318 bool
12320
12321 /// Produces a formatted string that describes the binding of
12322 /// template parameters to template arguments.
12323 std::string
12325 const TemplateArgumentList &Args);
12326
12327 std::string
12329 const TemplateArgument *Args,
12330 unsigned NumArgs);
12331
12335
12336 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12337 /// was just parsed. This is only possible with an explicit scope
12338 /// specifier naming a dependent type.
12340 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12341 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12342 const TemplateArgumentListInfo *TemplateArgs);
12343
12346 SourceLocation TemplateKWLoc,
12347 const DeclarationNameInfo &NameInfo,
12348 const TemplateArgumentListInfo *TemplateArgs);
12349
12350 // Calculates whether the expression Constraint depends on an enclosing
12351 // template, for the purposes of [temp.friend] p9.
12352 // TemplateDepth is the 'depth' of the friend function, which is used to
12353 // compare whether a declaration reference is referring to a containing
12354 // template, or just the current friend function. A 'lower' TemplateDepth in
12355 // the AST refers to a 'containing' template. As the constraint is
12356 // uninstantiated, this is relative to the 'top' of the TU.
12357 bool
12359 unsigned TemplateDepth,
12360 const Expr *Constraint);
12361
12362 /// Find the failed Boolean condition within a given Boolean
12363 /// constant expression, and describe it with a string.
12364 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12365
12367
12369 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12370 const IdentifierInfo *Name, SourceLocation NameLoc);
12371
12373 Expr *ConstraintExpr,
12374 const ParsedAttributesView &Attrs);
12375
12377 bool &AddToScope);
12379
12380 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12381 const CXXScopeSpec &SS,
12382 const IdentifierInfo *Name,
12383 SourceLocation TagLoc, SourceLocation NameLoc);
12384
12386 CachedTokens &Toks);
12389
12390 /// We've found a use of a templated declaration that would trigger an
12391 /// implicit instantiation. Check that any relevant explicit specializations
12392 /// and partial specializations are visible/reachable, and diagnose if not.
12395
12396 ///@}
12397
12398 //
12399 //
12400 // -------------------------------------------------------------------------
12401 //
12402 //
12403
12404 /// \name C++ Template Argument Deduction
12405 /// Implementations are in SemaTemplateDeduction.cpp
12406 ///@{
12407
12408public:
12409 class SFINAETrap;
12410
12413 : S(S), Prev(std::exchange(S.CurrentSFINAEContext, Cur)) {}
12414
12415 protected:
12417 ~SFINAEContextBase() { S.CurrentSFINAEContext = Prev; }
12418
12419 private:
12420 SFINAETrap *Prev;
12421 };
12422
12426
12427 /// RAII class used to determine whether SFINAE has
12428 /// trapped any errors that occur during template argument
12429 /// deduction.
12430 class SFINAETrap : SFINAEContextBase {
12431 bool HasErrorOcurred = false;
12432 bool WithAccessChecking = false;
12433 bool PrevLastDiagnosticIgnored =
12434 S.getDiagnostics().isLastDiagnosticIgnored();
12435 sema::TemplateDeductionInfo *DeductionInfo = nullptr;
12436
12437 SFINAETrap(Sema &S, sema::TemplateDeductionInfo *Info,
12438 bool WithAccessChecking)
12439 : SFINAEContextBase(S, this), WithAccessChecking(WithAccessChecking),
12440 DeductionInfo(Info) {}
12441
12442 public:
12443 /// \param WithAccessChecking If true, discard all diagnostics (from the
12444 /// immediate context) instead of adding them to the currently active
12445 /// \ref TemplateDeductionInfo.
12446 explicit SFINAETrap(Sema &S, bool WithAccessChecking = false)
12447 : SFINAETrap(S, /*Info=*/nullptr, WithAccessChecking) {}
12448
12450 : SFINAETrap(S, &Info, /*WithAccessChecking=*/false) {}
12451
12453 S.getDiagnostics().setLastDiagnosticIgnored(PrevLastDiagnosticIgnored);
12454 }
12455
12456 SFINAETrap(const SFINAETrap &) = delete;
12457 SFINAETrap &operator=(const SFINAETrap &) = delete;
12458
12460 return DeductionInfo;
12461 }
12462
12463 /// Determine whether any SFINAE errors have been trapped.
12464 bool hasErrorOccurred() const { return HasErrorOcurred; }
12465 void setErrorOccurred() { HasErrorOcurred = true; }
12466
12467 bool withAccessChecking() const { return WithAccessChecking; }
12468 };
12469
12470 /// RAII class used to indicate that we are performing provisional
12471 /// semantic analysis to determine the validity of a construct, so
12472 /// typo-correction and diagnostics in the immediate context (not within
12473 /// implicitly-instantiated templates) should be suppressed.
12475 Sema &SemaRef;
12476 // FIXME: Using a SFINAETrap for this is a hack.
12477 SFINAETrap Trap;
12478 bool PrevDisableTypoCorrection;
12479
12480 public:
12481 explicit TentativeAnalysisScope(Sema &SemaRef)
12482 : SemaRef(SemaRef), Trap(SemaRef, /*ForValidityCheck=*/true),
12483 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12484 SemaRef.DisableTypoCorrection = true;
12485 }
12487 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12488 }
12489 };
12490
12491 /// For each declaration that involved template argument deduction, the
12492 /// set of diagnostics that were suppressed during that template argument
12493 /// deduction.
12494 ///
12495 /// FIXME: Serialize this structure to the AST file.
12496 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12499
12500 /// Compare types for equality with respect to possibly compatible
12501 /// function types (noreturn adjustment, implicit calling conventions). If any
12502 /// of parameter and argument is not a function, just perform type comparison.
12503 ///
12504 /// \param P the template parameter type.
12505 ///
12506 /// \param A the argument type.
12508
12509 /// Allocate a TemplateArgumentLoc where all locations have
12510 /// been initialized to the given location.
12511 ///
12512 /// \param Arg The template argument we are producing template argument
12513 /// location information for.
12514 ///
12515 /// \param NTTPType For a declaration template argument, the type of
12516 /// the non-type template parameter that corresponds to this template
12517 /// argument. Can be null if no type sugar is available to add to the
12518 /// type from the template argument.
12519 ///
12520 /// \param Loc The source location to use for the resulting template
12521 /// argument.
12524 SourceLocation Loc,
12525 NamedDecl *TemplateParam = nullptr);
12526
12527 /// Get a template argument mapping the given template parameter to itself,
12528 /// e.g. for X in \c template<int X>, this would return an expression template
12529 /// argument referencing X.
12531 SourceLocation Location);
12532
12533 /// Adjust the type \p ArgFunctionType to match the calling convention,
12534 /// noreturn, and optionally the exception specification of \p FunctionType.
12535 /// Deduction often wants to ignore these properties when matching function
12536 /// types.
12538 bool AdjustExceptionSpec = false);
12539
12542 ArrayRef<TemplateArgument> TemplateArgs,
12544
12547 ArrayRef<TemplateArgument> TemplateArgs,
12549
12550 /// Deduce the template arguments of the given template from \p FromType.
12551 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12552 /// [over.match.class.deduct]p4.
12553 ///
12554 /// It only supports class or type alias templates.
12558
12563 bool NumberOfArgumentsMustMatch);
12564
12565 /// Substitute the explicitly-provided template arguments into the
12566 /// given function template according to C++ [temp.arg.explicit].
12567 ///
12568 /// \param FunctionTemplate the function template into which the explicit
12569 /// template arguments will be substituted.
12570 ///
12571 /// \param ExplicitTemplateArgs the explicitly-specified template
12572 /// arguments.
12573 ///
12574 /// \param Deduced the deduced template arguments, which will be populated
12575 /// with the converted and checked explicit template arguments.
12576 ///
12577 /// \param ParamTypes will be populated with the instantiated function
12578 /// parameters.
12579 ///
12580 /// \param FunctionType if non-NULL, the result type of the function template
12581 /// will also be instantiated and the pointed-to value will be updated with
12582 /// the instantiated function type.
12583 ///
12584 /// \param Info if substitution fails for any reason, this object will be
12585 /// populated with more information about the failure.
12586 ///
12587 /// \returns TemplateDeductionResult::Success if substitution was successful,
12588 /// or some failure condition.
12591 TemplateArgumentListInfo &ExplicitTemplateArgs,
12595
12596 /// brief A function argument from which we performed template argument
12597 // deduction for a call.
12610
12611 /// Finish template argument deduction for a function template,
12612 /// checking the deduced template arguments for completeness and forming
12613 /// the function template specialization.
12614 ///
12615 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12616 /// which the deduced argument types should be compared.
12617 /// \param CheckNonDependent Callback before substituting into the declaration
12618 /// with the deduced template arguments.
12619 /// \param OnlyInitializeNonUserDefinedConversions is used as a workaround for
12620 /// some breakages introduced by CWG2369, where non-user-defined conversions
12621 /// are checked first before the constraints.
12625 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12627 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12628 bool PartialOverloading, bool PartialOrdering,
12629 bool ForOverloadSetAddressResolution,
12630 llvm::function_ref<bool(bool)> CheckNonDependent =
12631 [](bool /*OnlyInitializeNonUserDefinedConversions*/) {
12632 return false;
12633 });
12634
12635 /// Perform template argument deduction from a function call
12636 /// (C++ [temp.deduct.call]).
12637 ///
12638 /// \param FunctionTemplate the function template for which we are performing
12639 /// template argument deduction.
12640 ///
12641 /// \param ExplicitTemplateArgs the explicit template arguments provided
12642 /// for this call.
12643 ///
12644 /// \param Args the function call arguments
12645 ///
12646 /// \param Specialization if template argument deduction was successful,
12647 /// this will be set to the function template specialization produced by
12648 /// template argument deduction.
12649 ///
12650 /// \param Info the argument will be updated to provide additional information
12651 /// about template argument deduction.
12652 ///
12653 /// \param CheckNonDependent A callback to invoke to check conversions for
12654 /// non-dependent parameters, between deduction and substitution, per DR1391.
12655 /// If this returns true, substitution will be skipped and we return
12656 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12657 /// passed the parameter types (after substituting explicit template
12658 /// arguments).
12659 ///
12660 /// \returns the result of template argument deduction.
12663 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12665 bool PartialOverloading, bool AggregateDeductionCandidate,
12666 bool PartialOrdering, QualType ObjectType,
12667 Expr::Classification ObjectClassification,
12668 bool ForOverloadSetAddressResolution,
12669 llvm::function_ref<bool(ArrayRef<QualType>, bool)> CheckNonDependent);
12670
12671 /// Deduce template arguments when taking the address of a function
12672 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12673 /// a template.
12674 ///
12675 /// \param FunctionTemplate the function template for which we are performing
12676 /// template argument deduction.
12677 ///
12678 /// \param ExplicitTemplateArgs the explicitly-specified template
12679 /// arguments.
12680 ///
12681 /// \param ArgFunctionType the function type that will be used as the
12682 /// "argument" type (A) when performing template argument deduction from the
12683 /// function template's function type. This type may be NULL, if there is no
12684 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12685 ///
12686 /// \param Specialization if template argument deduction was successful,
12687 /// this will be set to the function template specialization produced by
12688 /// template argument deduction.
12689 ///
12690 /// \param Info the argument will be updated to provide additional information
12691 /// about template argument deduction.
12692 ///
12693 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12694 /// the address of a function template per [temp.deduct.funcaddr] and
12695 /// [over.over]. If \c false, we are looking up a function template
12696 /// specialization based on its signature, per [temp.deduct.decl].
12697 ///
12698 /// \returns the result of template argument deduction.
12701 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12703 bool IsAddressOfFunction = false);
12704
12705 /// Deduce template arguments for a templated conversion
12706 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12707 /// conversion function template specialization.
12710 Expr::Classification ObjectClassification, QualType ToType,
12712
12713 /// Deduce template arguments for a function template when there is
12714 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12715 ///
12716 /// \param FunctionTemplate the function template for which we are performing
12717 /// template argument deduction.
12718 ///
12719 /// \param ExplicitTemplateArgs the explicitly-specified template
12720 /// arguments.
12721 ///
12722 /// \param Specialization if template argument deduction was successful,
12723 /// this will be set to the function template specialization produced by
12724 /// template argument deduction.
12725 ///
12726 /// \param Info the argument will be updated to provide additional information
12727 /// about template argument deduction.
12728 ///
12729 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12730 /// the address of a function template in a context where we do not have a
12731 /// target type, per [over.over]. If \c false, we are looking up a function
12732 /// template specialization based on its signature, which only happens when
12733 /// deducing a function parameter type from an argument that is a template-id
12734 /// naming a function template specialization.
12735 ///
12736 /// \returns the result of template argument deduction.
12739 TemplateArgumentListInfo *ExplicitTemplateArgs,
12742 bool IsAddressOfFunction = false);
12743
12744 /// Substitute Replacement for \p auto in \p TypeWithAuto
12745 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12746 /// Substitute Replacement for auto in TypeWithAuto
12748 QualType Replacement);
12749
12750 // Substitute auto in TypeWithAuto for a Dependent auto type
12752
12753 // Substitute auto in TypeWithAuto for a Dependent auto type
12756
12757 /// Completely replace the \c auto in \p TypeWithAuto by
12758 /// \p Replacement. This does not retain any \c auto type sugar.
12759 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12761 QualType Replacement);
12762
12763 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12764 ///
12765 /// Note that this is done even if the initializer is dependent. (This is
12766 /// necessary to support partial ordering of templates using 'auto'.)
12767 /// A dependent type will be produced when deducing from a dependent type.
12768 ///
12769 /// \param Type the type pattern using the auto type-specifier.
12770 /// \param Init the initializer for the variable whose type is to be deduced.
12771 /// \param Result if type deduction was successful, this will be set to the
12772 /// deduced type.
12773 /// \param Info the argument will be updated to provide additional information
12774 /// about template argument deduction.
12775 /// \param DependentDeduction Set if we should permit deduction in
12776 /// dependent cases. This is necessary for template partial ordering
12777 /// with 'auto' template parameters. The template parameter depth to be
12778 /// used should be specified in the 'Info' parameter.
12779 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12780 /// does not satisfy the type-constraint in the auto
12781 /// type.
12785 bool DependentDeduction = false,
12786 bool IgnoreConstraints = false,
12787 TemplateSpecCandidateSet *FailedTSC = nullptr);
12788 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12790 bool Diagnose = true);
12791
12793 SourceLocation Loc);
12794
12795 /// Returns the more specialized class template partial specialization
12796 /// according to the rules of partial ordering of class template partial
12797 /// specializations (C++ [temp.class.order]).
12798 ///
12799 /// \param PS1 the first class template partial specialization
12800 ///
12801 /// \param PS2 the second class template partial specialization
12802 ///
12803 /// \returns the more specialized class template partial specialization. If
12804 /// neither partial specialization is more specialized, returns NULL.
12809
12812
12816
12819
12821 TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
12822 const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
12823 bool PartialOrdering, bool *StrictPackMatch);
12824
12825 /// Mark which template parameters are used in a given expression.
12826 ///
12827 /// \param E the expression from which template parameters will be deduced.
12828 ///
12829 /// \param Used a bit vector whose elements will be set to \c true
12830 /// to indicate when the corresponding template parameter will be
12831 /// deduced.
12832 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12833 unsigned Depth, llvm::SmallBitVector &Used);
12834
12835 /// Mark which template parameters are named in a given expression.
12836 ///
12837 /// Unlike MarkUsedTemplateParameters, this excludes parameter that
12838 /// are used but not directly named by an expression - i.e. it excludes
12839 /// any template parameter that denotes the type of a referenced NTTP.
12840 ///
12841 /// \param Used a bit vector whose elements will be set to \c true
12842 /// to indicate when the corresponding template parameter will be
12843 /// deduced.
12845 const Expr *E, unsigned Depth, llvm::SmallBitVector &Used);
12846
12847 /// Mark which template parameters can be deduced from a given
12848 /// template argument list.
12849 ///
12850 /// \param TemplateArgs the template argument list from which template
12851 /// parameters will be deduced.
12852 ///
12853 /// \param Used a bit vector whose elements will be set to \c true
12854 /// to indicate when the corresponding template parameter will be
12855 /// deduced.
12856 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
12857 bool OnlyDeduced, unsigned Depth,
12858 llvm::SmallBitVector &Used);
12859
12861 unsigned Depth, llvm::SmallBitVector &Used);
12862
12864 unsigned Depth, llvm::SmallBitVector &Used);
12865
12866 void
12868 llvm::SmallBitVector &Deduced) {
12870 }
12871
12872 /// Marks all of the template parameters that will be deduced by a
12873 /// call to the given function template.
12874 static void
12877 llvm::SmallBitVector &Deduced);
12878
12879 /// Returns the more specialized function template according
12880 /// to the rules of function template partial ordering (C++
12881 /// [temp.func.order]).
12882 ///
12883 /// \param FT1 the first function template
12884 ///
12885 /// \param FT2 the second function template
12886 ///
12887 /// \param TPOC the context in which we are performing partial ordering of
12888 /// function templates.
12889 ///
12890 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
12891 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
12892 /// when calling a member function.
12893 ///
12894 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
12895 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
12896 /// template from a member function
12897 ///
12898 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
12899 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
12900 /// template from a member function
12901 ///
12902 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
12903 /// candidate with a reversed parameter order. In this case, the corresponding
12904 /// P/A pairs between FT1 and FT2 are reversed.
12905 ///
12906 /// \returns the more specialized function template. If neither
12907 /// template is more specialized, returns NULL.
12910 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
12911 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false,
12912 bool PartialOverloading = false);
12913
12914 /// Retrieve the most specialized of the given function template
12915 /// specializations.
12916 ///
12917 /// \param SpecBegin the start iterator of the function template
12918 /// specializations that we will be comparing.
12919 ///
12920 /// \param SpecEnd the end iterator of the function template
12921 /// specializations, paired with \p SpecBegin.
12922 ///
12923 /// \param Loc the location where the ambiguity or no-specializations
12924 /// diagnostic should occur.
12925 ///
12926 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
12927 /// no matching candidates.
12928 ///
12929 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
12930 /// occurs.
12931 ///
12932 /// \param CandidateDiag partial diagnostic used for each function template
12933 /// specialization that is a candidate in the ambiguous ordering. One
12934 /// parameter in this diagnostic should be unbound, which will correspond to
12935 /// the string describing the template arguments for the function template
12936 /// specialization.
12937 ///
12938 /// \returns the most specialized function template specialization, if
12939 /// found. Otherwise, returns SpecEnd.
12940 UnresolvedSetIterator
12941 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
12942 TemplateSpecCandidateSet &FailedCandidates,
12943 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
12944 const PartialDiagnostic &AmbigDiag,
12945 const PartialDiagnostic &CandidateDiag,
12946 bool Complain = true, QualType TargetType = QualType());
12947
12948 /// Returns the more constrained function according to the rules of
12949 /// partial ordering by constraints (C++ [temp.constr.order]).
12950 ///
12951 /// \param FD1 the first function
12952 ///
12953 /// \param FD2 the second function
12954 ///
12955 /// \returns the more constrained function. If neither function is
12956 /// more constrained, returns NULL.
12957 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
12958 FunctionDecl *FD2);
12959
12960 ///@}
12961
12962 //
12963 //
12964 // -------------------------------------------------------------------------
12965 //
12966 //
12967
12968 /// \name C++ Template Deduction Guide
12969 /// Implementations are in SemaTemplateDeductionGuide.cpp
12970 ///@{
12971
12972 /// Declare implicit deduction guides for a class template if we've
12973 /// not already done so.
12974 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12975 SourceLocation Loc);
12976
12977 FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12978 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12979 SourceLocation Loc);
12980
12981 ///@}
12982
12983 //
12984 //
12985 // -------------------------------------------------------------------------
12986 //
12987 //
12988
12989 /// \name C++ Template Instantiation
12990 /// Implementations are in SemaTemplateInstantiate.cpp
12991 ///@{
12992
12993public:
12994 /// A helper class for building up ExtParameterInfos.
12997 bool HasInteresting = false;
12998
12999 public:
13000 /// Set the ExtParameterInfo for the parameter at the given index,
13001 ///
13003 assert(Infos.size() <= index);
13004 Infos.resize(index);
13005 Infos.push_back(info);
13006
13007 if (!HasInteresting)
13008 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
13009 }
13010
13011 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
13012 /// ExtParameterInfo array we've built up.
13014 getPointerOrNull(unsigned numParams) {
13015 if (!HasInteresting)
13016 return nullptr;
13017 Infos.resize(numParams);
13018 return Infos.data();
13019 }
13020 };
13021
13022 /// The current instantiation scope used to store local
13023 /// variables.
13025
13026 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
13028
13029 /// A mapping from parameters with unparsed default arguments to the
13030 /// set of instantiations of each parameter.
13031 ///
13032 /// This mapping is a temporary data structure used when parsing
13033 /// nested class templates or nested classes of class templates,
13034 /// where we might end up instantiating an inner class before the
13035 /// default arguments of its methods have been parsed.
13037
13038 using InstantiatingSpecializationsKey = llvm::PointerIntPair<Decl *, 2>;
13039
13046
13048 : S(S), Key(D->getCanonicalDecl(), unsigned(Kind)) {
13049 auto [_, Created] = S.InstantiatingSpecializations.insert(Key);
13050 if (!Created)
13051 Key = {};
13052 }
13053
13055 if (Key.getOpaqueValue()) {
13056 [[maybe_unused]] bool Erased =
13057 S.InstantiatingSpecializations.erase(Key);
13058 assert(Erased);
13059 }
13060 }
13061
13062 operator bool() const { return Key.getOpaqueValue() == nullptr; }
13063
13064 private:
13065 Sema &S;
13067 };
13068
13069 /// A context in which code is being synthesized (where a source location
13070 /// alone is not sufficient to identify the context). This covers template
13071 /// instantiation and various forms of implicitly-generated functions.
13073 /// The kind of template instantiation we are performing
13075 /// We are instantiating a template declaration. The entity is
13076 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
13078
13079 /// We are instantiating a default argument for a template
13080 /// parameter. The Entity is the template parameter whose argument is
13081 /// being instantiated, the Template is the template, and the
13082 /// TemplateArgs/NumTemplateArguments provide the template arguments as
13083 /// specified.
13085
13086 /// We are instantiating a default argument for a function.
13087 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
13088 /// provides the template arguments as specified.
13090
13091 /// We are substituting explicit template arguments provided for
13092 /// a function template. The entity is a FunctionTemplateDecl.
13094
13095 /// We are substituting template argument determined as part of
13096 /// template argument deduction for either a class template
13097 /// partial specialization or a function template. The
13098 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
13099 /// a TemplateDecl.
13101
13102 /// We are substituting into a lambda expression.
13104
13105 /// We are substituting prior template arguments into a new
13106 /// template parameter. The template parameter itself is either a
13107 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
13109
13110 /// We are checking the validity of a default template argument that
13111 /// has been used when naming a template-id.
13113
13114 /// We are computing the exception specification for a defaulted special
13115 /// member function.
13117
13118 /// We are instantiating the exception specification for a function
13119 /// template which was deferred until it was needed.
13121
13122 /// We are instantiating a requirement of a requires expression.
13124
13125 /// We are checking the satisfaction of a nested requirement of a requires
13126 /// expression.
13128
13129 /// We are declaring an implicit special member function.
13131
13132 /// We are declaring an implicit 'operator==' for a defaulted
13133 /// 'operator<=>'.
13135
13136 /// We are defining a synthesized function (such as a defaulted special
13137 /// member).
13139
13140 // We are checking the constraints associated with a constrained entity or
13141 // the constraint expression of a concept. This includes the checks that
13142 // atomic constraints have the type 'bool' and that they can be constant
13143 // evaluated.
13145
13146 // We are substituting template arguments into a constraint expression.
13148
13149 // We are normalizing a constraint expression.
13151
13152 // Instantiating a Requires Expression parameter clause.
13154
13155 // We are substituting into the parameter mapping of an atomic constraint
13156 // during normalization.
13158
13159 /// We are rewriting a comparison operator in terms of an operator<=>.
13161
13162 /// We are initializing a structured binding.
13164
13165 /// We are marking a class as __dllexport.
13167
13168 /// We are building an implied call from __builtin_dump_struct. The
13169 /// arguments are in CallArgs.
13171
13172 /// Added for Template instantiation observation.
13173 /// Memoization means we are _not_ instantiating a template because
13174 /// it is already instantiated (but we entered a context where we
13175 /// would have had to if it was not already instantiated).
13177
13178 /// We are building deduction guides for a class.
13180
13181 /// We are instantiating a type alias template declaration.
13183
13184 /// We are performing partial ordering for template template parameters.
13186 } Kind;
13187
13188 /// Whether we're substituting into constraints.
13190
13191 /// Whether we're substituting into the parameter mapping of a constraint.
13193
13194 /// The point of instantiation or synthesis within the source code.
13196
13197 /// The entity that is being synthesized.
13199
13200 /// The template (or partial specialization) in which we are
13201 /// performing the instantiation, for substitutions of prior template
13202 /// arguments.
13204
13205 union {
13206 /// The list of template arguments we are substituting, if they
13207 /// are not part of the entity.
13209
13210 /// The list of argument expressions in a synthesized call.
13211 const Expr *const *CallArgs;
13212 };
13213
13214 // FIXME: Wrap this union around more members, or perhaps store the
13215 // kind-specific members in the RAII object owning the context.
13216 union {
13217 /// The number of template arguments in TemplateArgs.
13219
13220 /// The number of expressions in CallArgs.
13221 unsigned NumCallArgs;
13222
13223 /// The special member being declared or defined.
13225 };
13226
13231
13232 /// The source range that covers the construct that cause
13233 /// the instantiation, e.g., the template-id that causes a class
13234 /// template instantiation.
13236
13241
13242 /// Determines whether this template is an actual instantiation
13243 /// that should be counted toward the maximum instantiation depth.
13244 bool isInstantiationRecord() const;
13245 };
13246
13247 /// A stack object to be created when performing template
13248 /// instantiation.
13249 ///
13250 /// Construction of an object of type \c InstantiatingTemplate
13251 /// pushes the current instantiation onto the stack of active
13252 /// instantiations. If the size of this stack exceeds the maximum
13253 /// number of recursive template instantiations, construction
13254 /// produces an error and evaluates true.
13255 ///
13256 /// Destruction of this object will pop the named instantiation off
13257 /// the stack.
13259 /// Note that we are instantiating a class template,
13260 /// function template, variable template, alias template,
13261 /// or a member thereof.
13262 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13263 Decl *Entity,
13264 SourceRange InstantiationRange = SourceRange());
13265
13267 /// Note that we are instantiating an exception specification
13268 /// of a function template.
13269 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13271 SourceRange InstantiationRange = SourceRange());
13272
13273 /// Note that we are instantiating a type alias template declaration.
13274 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13275 TypeAliasTemplateDecl *Entity,
13276 ArrayRef<TemplateArgument> TemplateArgs,
13277 SourceRange InstantiationRange = SourceRange());
13278
13279 /// Note that we are instantiating a default argument in a
13280 /// template-id.
13281 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13283 ArrayRef<TemplateArgument> TemplateArgs,
13284 SourceRange InstantiationRange = SourceRange());
13285
13286 /// Note that we are substituting either explicitly-specified or
13287 /// deduced template arguments during function template argument deduction.
13288 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13290 ArrayRef<TemplateArgument> TemplateArgs,
13292 SourceRange InstantiationRange = SourceRange());
13293
13294 /// Note that we are instantiating as part of template
13295 /// argument deduction for a class template declaration.
13296 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13298 ArrayRef<TemplateArgument> TemplateArgs,
13299 SourceRange InstantiationRange = SourceRange());
13300
13301 /// Note that we are instantiating as part of template
13302 /// argument deduction for a class template partial
13303 /// specialization.
13304 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13306 ArrayRef<TemplateArgument> TemplateArgs,
13307 SourceRange InstantiationRange = SourceRange());
13308
13309 /// Note that we are instantiating as part of template
13310 /// argument deduction for a variable template partial
13311 /// specialization.
13312 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13314 ArrayRef<TemplateArgument> TemplateArgs,
13315 SourceRange InstantiationRange = SourceRange());
13316
13317 /// Note that we are instantiating a default argument for a function
13318 /// parameter.
13319 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13320 ParmVarDecl *Param,
13321 ArrayRef<TemplateArgument> TemplateArgs,
13322 SourceRange InstantiationRange = SourceRange());
13323
13324 /// Note that we are substituting prior template arguments into a
13325 /// non-type parameter.
13326 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13328 ArrayRef<TemplateArgument> TemplateArgs,
13329 SourceRange InstantiationRange);
13330
13331 /// Note that we are substituting prior template arguments into a
13332 /// template template parameter.
13333 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13335 ArrayRef<TemplateArgument> TemplateArgs,
13336 SourceRange InstantiationRange);
13337
13338 /// Note that we are checking the default template argument
13339 /// against the template parameter for a given template-id.
13340 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13342 ArrayRef<TemplateArgument> TemplateArgs,
13343 SourceRange InstantiationRange);
13344
13346 /// \brief Note that we are checking the constraints associated with some
13347 /// constrained entity (a concept declaration or a template with associated
13348 /// constraints).
13349 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13351 ArrayRef<TemplateArgument> TemplateArgs,
13352 SourceRange InstantiationRange);
13353
13355 /// \brief Note that we are checking a constraint expression associated
13356 /// with a template declaration or as part of the satisfaction check of a
13357 /// concept.
13358 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13360 SourceRange InstantiationRange);
13361
13363 /// \brief Note that we are normalizing a constraint expression.
13364 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13366 SourceRange InstantiationRange);
13367
13369 /// \brief Note that we are subtituting into the parameter mapping of an
13370 /// atomic constraint during constraint normalization.
13371 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13373 SourceRange InstantiationRange);
13374
13375 /// \brief Note that we are substituting template arguments into a part of
13376 /// a requirement of a requires expression.
13377 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13379 SourceRange InstantiationRange = SourceRange());
13380
13381 /// \brief Note that we are checking the satisfaction of the constraint
13382 /// expression inside of a nested requirement.
13383 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13385 SourceRange InstantiationRange = SourceRange());
13386
13387 /// \brief Note that we are checking a requires clause.
13388 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13389 const RequiresExpr *E,
13390 SourceRange InstantiationRange);
13391
13393 /// \brief Note that we are building deduction guides.
13394 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13396 SourceRange InstantiationRange = SourceRange());
13397
13399 /// \brief Note that we are partial ordering template template parameters.
13400 InstantiatingTemplate(Sema &SemaRef, SourceLocation ArgLoc,
13402 SourceRange InstantiationRange = SourceRange());
13403
13404 /// Note that we have finished instantiating this template.
13405 void Clear();
13406
13408
13409 /// Determines whether we have exceeded the maximum
13410 /// recursive template instantiations.
13411 bool isInvalid() const { return Invalid; }
13412
13413 private:
13414 Sema &SemaRef;
13415 bool Invalid;
13416
13419 SourceLocation PointOfInstantiation,
13420 SourceRange InstantiationRange, Decl *Entity,
13421 NamedDecl *Template = nullptr,
13422 ArrayRef<TemplateArgument> TemplateArgs = {});
13423
13425
13426 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13427 };
13428
13429 bool SubstTemplateArgument(const TemplateArgumentLoc &Input,
13430 const MultiLevelTemplateArgumentList &TemplateArgs,
13431 TemplateArgumentLoc &Output,
13432 SourceLocation Loc = {},
13433 const DeclarationName &Entity = {});
13434 bool
13435 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13436 const MultiLevelTemplateArgumentList &TemplateArgs,
13437 TemplateArgumentListInfo &Outputs);
13438
13439 /// Substitute concept template arguments in the constraint expression
13440 /// of a concept-id. This is used to implement [temp.constr.normal].
13442 SubstConceptTemplateArguments(const ConceptSpecializationExpr *CSE,
13443 const Expr *ConstraintExpr,
13444 const MultiLevelTemplateArgumentList &MLTAL);
13445
13447 ArrayRef<TemplateArgumentLoc> Args, SourceLocation BaseLoc,
13448 const MultiLevelTemplateArgumentList &TemplateArgs,
13449 TemplateArgumentListInfo &Out, bool BuildPackExpansionTypes);
13450
13451 /// Retrieve the template argument list(s) that should be used to
13452 /// instantiate the definition of the given declaration.
13453 ///
13454 /// \param ND the declaration for which we are computing template
13455 /// instantiation arguments.
13456 ///
13457 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13458 /// the decl context where it will be created. In this case, the `Innermost`
13459 /// should likely be provided. If ND is non-null, this is ignored.
13460 ///
13461 /// \param Innermost if non-NULL, specifies a template argument list for the
13462 /// template declaration passed as ND.
13463 ///
13464 /// \param RelativeToPrimary true if we should get the template
13465 /// arguments relative to the primary template, even when we're
13466 /// dealing with a specialization. This is only relevant for function
13467 /// template specializations.
13468 ///
13469 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13470 /// instantiating the definition of the given declaration, \p ND. This is
13471 /// used to determine the proper set of template instantiation arguments for
13472 /// friend function template specializations.
13473 ///
13474 /// \param ForConstraintInstantiation when collecting arguments,
13475 /// ForConstraintInstantiation indicates we should continue looking when
13476 /// encountering a lambda generic call operator, and continue looking for
13477 /// arguments on an enclosing class template.
13478 ///
13479 /// \param SkipForSpecialization when specified, any template specializations
13480 /// in a traversal would be ignored.
13481 ///
13482 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13483 /// when encountering a specialized member function template, rather than
13484 /// returning immediately.
13485 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13486 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13487 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13488 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13489 bool ForConstraintInstantiation = false,
13490 bool SkipForSpecialization = false,
13491 bool ForDefaultArgumentSubstitution = false);
13492
13493 /// RAII object to handle the state changes required to synthesize
13494 /// a function body.
13496 Sema &S;
13497 Sema::ContextRAII SavedContext;
13498 bool PushedCodeSynthesisContext = false;
13499
13500 public:
13502 : S(S), SavedContext(S, DC) {
13503 auto *FD = dyn_cast<FunctionDecl>(DC);
13504 S.PushFunctionScope();
13505 S.PushExpressionEvaluationContextForFunction(
13507 if (FD)
13508 FD->setWillHaveBody(true);
13509 else
13510 assert(isa<ObjCMethodDecl>(DC));
13511 }
13512
13514 assert(!PushedCodeSynthesisContext);
13515
13518 Ctx.PointOfInstantiation = UseLoc;
13519 Ctx.Entity = cast<Decl>(S.CurContext);
13520 S.pushCodeSynthesisContext(Ctx);
13521
13522 PushedCodeSynthesisContext = true;
13523 }
13524
13526 if (PushedCodeSynthesisContext)
13527 S.popCodeSynthesisContext();
13528 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13529 FD->setWillHaveBody(false);
13530 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13531 }
13532 S.PopExpressionEvaluationContext();
13533 S.PopFunctionScopeInfo();
13534 }
13535 };
13536
13537 /// List of active code synthesis contexts.
13538 ///
13539 /// This vector is treated as a stack. As synthesis of one entity requires
13540 /// synthesis of another, additional contexts are pushed onto the stack.
13542
13543 /// Specializations whose definitions are currently being instantiated.
13544 llvm::DenseSet<InstantiatingSpecializationsKey> InstantiatingSpecializations;
13545
13546 /// Non-dependent types used in templates that have already been instantiated
13547 /// by some template instantiation.
13548 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13549
13550 /// Extra modules inspected when performing a lookup during a template
13551 /// instantiation. Computed lazily.
13553
13554 /// Cache of additional modules that should be used for name lookup
13555 /// within the current template instantiation. Computed lazily; use
13556 /// getLookupModules() to get a complete set.
13557 llvm::DenseSet<Module *> LookupModulesCache;
13558
13559 /// Map from the most recent declaration of a namespace to the most
13560 /// recent visible declaration of that namespace.
13561 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13562
13564
13565 /// The number of \p CodeSynthesisContexts that are not template
13566 /// instantiations and, therefore, should not be counted as part of the
13567 /// instantiation depth.
13568 ///
13569 /// When the instantiation depth reaches the user-configurable limit
13570 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13571 // FIXME: Should we have a similar limit for other forms of synthesis?
13573
13574 /// The depth of the context stack at the point when the most recent
13575 /// error or warning was produced.
13576 ///
13577 /// This value is used to suppress printing of redundant context stacks
13578 /// when there are multiple errors or warnings in the same instantiation.
13579 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13581
13582 /// The template instantiation callbacks to trace or track
13583 /// instantiations (objects can be chained).
13584 ///
13585 /// This callbacks is used to print, trace or track template
13586 /// instantiations as they are being constructed.
13587 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
13589
13590 /// The current index into pack expansion arguments that will be
13591 /// used for substitution of parameter packs.
13592 ///
13593 /// The pack expansion index will be none to indicate that parameter packs
13594 /// should be instantiated as themselves. Otherwise, the index specifies
13595 /// which argument within the parameter pack will be used for substitution.
13597
13598 /// RAII object used to change the argument pack substitution index
13599 /// within a \c Sema object.
13600 ///
13601 /// See \c ArgPackSubstIndex for more information.
13603 Sema &Self;
13604 UnsignedOrNone OldSubstIndex;
13605
13606 public:
13608 : Self(Self),
13609 OldSubstIndex(std::exchange(Self.ArgPackSubstIndex, NewSubstIndex)) {}
13610
13611 ~ArgPackSubstIndexRAII() { Self.ArgPackSubstIndex = OldSubstIndex; }
13612 };
13613
13614 bool pushCodeSynthesisContext(CodeSynthesisContext Ctx);
13616
13627 /// Prints the current instantiation stack through a series of
13628 /// notes.
13633
13634 /// Returns a pointer to the current SFINAE context, if any.
13635 [[nodiscard]] SFINAETrap *getSFINAEContext() const {
13636 return CurrentSFINAEContext;
13637 }
13638 [[nodiscard]] bool isSFINAEContext() const {
13639 return CurrentSFINAEContext != nullptr;
13640 }
13641
13642 /// Perform substitution on the type T with a given set of template
13643 /// arguments.
13644 ///
13645 /// This routine substitutes the given template arguments into the
13646 /// type T and produces the instantiated type.
13647 ///
13648 /// \param T the type into which the template arguments will be
13649 /// substituted. If this type is not dependent, it will be returned
13650 /// immediately.
13651 ///
13652 /// \param Args the template arguments that will be
13653 /// substituted for the top-level template parameters within T.
13654 ///
13655 /// \param Loc the location in the source code where this substitution
13656 /// is being performed. It will typically be the location of the
13657 /// declarator (if we're instantiating the type of some declaration)
13658 /// or the location of the type in the source code (if, e.g., we're
13659 /// instantiating the type of a cast expression).
13660 ///
13661 /// \param Entity the name of the entity associated with a declaration
13662 /// being instantiated (if any). May be empty to indicate that there
13663 /// is no such entity (if, e.g., this is a type that occurs as part of
13664 /// a cast expression) or that the entity has no name (e.g., an
13665 /// unnamed function parameter).
13666 ///
13667 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13668 /// acceptable as the top level type of the result.
13669 ///
13670 /// \param IsIncompleteSubstitution If provided, the pointee will be set
13671 /// whenever substitution would perform a replacement with a null or
13672 /// non-existent template argument.
13673 ///
13674 /// \returns If the instantiation succeeds, the instantiated
13675 /// type. Otherwise, produces diagnostics and returns a NULL type.
13677 const MultiLevelTemplateArgumentList &TemplateArgs,
13678 SourceLocation Loc, DeclarationName Entity,
13679 bool AllowDeducedTST = false);
13680
13682 const MultiLevelTemplateArgumentList &TemplateArgs,
13683 SourceLocation Loc, DeclarationName Entity,
13684 bool *IsIncompleteSubstitution = nullptr);
13685
13687 const MultiLevelTemplateArgumentList &TemplateArgs,
13688 SourceLocation Loc, DeclarationName Entity);
13689
13690 /// A form of SubstType intended specifically for instantiating the
13691 /// type of a FunctionDecl. Its purpose is solely to force the
13692 /// instantiation of default-argument expressions and to avoid
13693 /// instantiating an exception-specification.
13695 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13696 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13697 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13699 const MultiLevelTemplateArgumentList &Args);
13702 SmallVectorImpl<QualType> &ExceptionStorage,
13703 const MultiLevelTemplateArgumentList &Args);
13704 ParmVarDecl *
13706 const MultiLevelTemplateArgumentList &TemplateArgs,
13707 int indexAdjustment, UnsignedOrNone NumExpansions,
13708 bool ExpectParameterPack, bool EvaluateConstraints = true);
13709
13710 /// Substitute the given template arguments into the given set of
13711 /// parameters, producing the set of parameter types that would be generated
13712 /// from such a substitution.
13714 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13715 const MultiLevelTemplateArgumentList &TemplateArgs,
13716 SmallVectorImpl<QualType> &ParamTypes,
13718 ExtParameterInfoBuilder &ParamInfos);
13719
13720 /// Substitute the given template arguments into the default argument.
13722 const MultiLevelTemplateArgumentList &TemplateArgs,
13723 bool ForCallExpr = false);
13725 const MultiLevelTemplateArgumentList &TemplateArgs);
13726 /// Substitute an expression as if it is a address-of-operand, which makes it
13727 /// act like a CXXIdExpression rather than an attempt to call.
13729 const MultiLevelTemplateArgumentList &TemplateArgs);
13730
13731 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
13732 // to disable constraint evaluation, then restore the state.
13733 template <typename InstTy> struct ConstraintEvalRAII {
13734 InstTy &TI;
13736
13738 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
13739 TI.setEvaluateConstraints(false);
13740 }
13741 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
13742 };
13743
13744 // Must be used instead of SubstExpr at 'constraint checking' time.
13747 const MultiLevelTemplateArgumentList &TemplateArgs);
13748 // Unlike the above, this does not evaluate constraints.
13750 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13751
13752 /// Substitute the given template arguments into a list of
13753 /// expressions, expanding pack expansions if required.
13754 ///
13755 /// \param Exprs The list of expressions to substitute into.
13756 ///
13757 /// \param IsCall Whether this is some form of call, in which case
13758 /// default arguments will be dropped.
13759 ///
13760 /// \param TemplateArgs The set of template arguments to substitute.
13761 ///
13762 /// \param Outputs Will receive all of the substituted arguments.
13763 ///
13764 /// \returns true if an error occurred, false otherwise.
13765 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13766 const MultiLevelTemplateArgumentList &TemplateArgs,
13767 SmallVectorImpl<Expr *> &Outputs);
13768
13770 const MultiLevelTemplateArgumentList &TemplateArgs);
13771
13774 bool CXXDirectInit);
13775
13776 /// Perform substitution on the base class specifiers of the
13777 /// given class template specialization.
13778 ///
13779 /// Produces a diagnostic and returns true on error, returns false and
13780 /// attaches the instantiated base classes to the class template
13781 /// specialization if successful.
13782 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13783 const MultiLevelTemplateArgumentList &TemplateArgs);
13784
13785 /// Instantiate the definition of a class from a given pattern.
13786 ///
13787 /// \param PointOfInstantiation The point of instantiation within the
13788 /// source code.
13789 ///
13790 /// \param Instantiation is the declaration whose definition is being
13791 /// instantiated. This will be either a class template specialization
13792 /// or a member class of a class template specialization.
13793 ///
13794 /// \param Pattern is the pattern from which the instantiation
13795 /// occurs. This will be either the declaration of a class template or
13796 /// the declaration of a member class of a class template.
13797 ///
13798 /// \param TemplateArgs The template arguments to be substituted into
13799 /// the pattern.
13800 ///
13801 /// \param TSK the kind of implicit or explicit instantiation to perform.
13802 ///
13803 /// \param Complain whether to complain if the class cannot be instantiated
13804 /// due to the lack of a definition.
13805 ///
13806 /// \returns true if an error occurred, false otherwise.
13807 bool InstantiateClass(SourceLocation PointOfInstantiation,
13808 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13809 const MultiLevelTemplateArgumentList &TemplateArgs,
13810 TemplateSpecializationKind TSK, bool Complain = true);
13811
13812private:
13813 bool InstantiateClassImpl(SourceLocation PointOfInstantiation,
13814 CXXRecordDecl *Instantiation,
13815 CXXRecordDecl *Pattern,
13816 const MultiLevelTemplateArgumentList &TemplateArgs,
13817 TemplateSpecializationKind TSK, bool Complain);
13818
13819public:
13820 /// Instantiate the definition of an enum from a given pattern.
13821 ///
13822 /// \param PointOfInstantiation The point of instantiation within the
13823 /// source code.
13824 /// \param Instantiation is the declaration whose definition is being
13825 /// instantiated. This will be a member enumeration of a class
13826 /// temploid specialization, or a local enumeration within a
13827 /// function temploid specialization.
13828 /// \param Pattern The templated declaration from which the instantiation
13829 /// occurs.
13830 /// \param TemplateArgs The template arguments to be substituted into
13831 /// the pattern.
13832 /// \param TSK The kind of implicit or explicit instantiation to perform.
13833 ///
13834 /// \return \c true if an error occurred, \c false otherwise.
13835 bool InstantiateEnum(SourceLocation PointOfInstantiation,
13836 EnumDecl *Instantiation, EnumDecl *Pattern,
13837 const MultiLevelTemplateArgumentList &TemplateArgs,
13839
13840 /// Instantiate the definition of a field from the given pattern.
13841 ///
13842 /// \param PointOfInstantiation The point of instantiation within the
13843 /// source code.
13844 /// \param Instantiation is the declaration whose definition is being
13845 /// instantiated. This will be a class of a class temploid
13846 /// specialization, or a local enumeration within a function temploid
13847 /// specialization.
13848 /// \param Pattern The templated declaration from which the instantiation
13849 /// occurs.
13850 /// \param TemplateArgs The template arguments to be substituted into
13851 /// the pattern.
13852 ///
13853 /// \return \c true if an error occurred, \c false otherwise.
13855 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
13856 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
13857
13859 SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
13860
13862 SourceLocation PointOfInstantiation,
13863 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13864 TemplateSpecializationKind TSK, bool Complain,
13865 bool PrimaryStrictPackMatch);
13866
13867 /// Instantiates the definitions of all of the member
13868 /// of the given class, which is an instantiation of a class template
13869 /// or a member class of a template.
13870 void
13871 InstantiateClassMembers(SourceLocation PointOfInstantiation,
13872 CXXRecordDecl *Instantiation,
13873 const MultiLevelTemplateArgumentList &TemplateArgs,
13875
13876 /// Instantiate the definitions of all of the members of the
13877 /// given class template specialization, which was named as part of an
13878 /// explicit instantiation.
13880 SourceLocation PointOfInstantiation,
13881 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13883
13886 const MultiLevelTemplateArgumentList &TemplateArgs);
13887
13888 /// Do template substitution on declaration name info.
13891 const MultiLevelTemplateArgumentList &TemplateArgs);
13893 SubstTemplateName(SourceLocation TemplateKWLoc,
13894 NestedNameSpecifierLoc &QualifierLoc, TemplateName Name,
13895 SourceLocation NameLoc,
13896 const MultiLevelTemplateArgumentList &TemplateArgs);
13897
13899 const MultiLevelTemplateArgumentList &TemplateArgs,
13900 bool EvaluateConstraint);
13901
13902 /// Determine whether we are currently performing template instantiation.
13905 }
13906
13907 /// Determine whether we are currently performing constraint substitution.
13909 return !CodeSynthesisContexts.empty() &&
13910 CodeSynthesisContexts.back().InConstraintSubstitution;
13911 }
13912
13914 return !CodeSynthesisContexts.empty() &&
13915 CodeSynthesisContexts.back().InParameterMappingSubstitution &&
13917 }
13918
13919 using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
13920
13921 /// \brief create a Requirement::SubstitutionDiagnostic with only a
13922 /// SubstitutedEntity and DiagLoc using ASTContext's allocator.
13925
13926 ///@}
13927
13928 //
13929 //
13930 // -------------------------------------------------------------------------
13931 //
13932 //
13933
13934 /// \name C++ Template Declaration Instantiation
13935 /// Implementations are in SemaTemplateInstantiateDecl.cpp
13936 ///@{
13937
13938public:
13939 /// An entity for which implicit template instantiation is required.
13940 ///
13941 /// The source location associated with the declaration is the first place in
13942 /// the source code where the declaration was "used". It is not necessarily
13943 /// the point of instantiation (which will be either before or after the
13944 /// namespace-scope declaration that triggered this implicit instantiation),
13945 /// However, it is the location that diagnostics should generally refer to,
13946 /// because users will need to know what code triggered the instantiation.
13947 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
13948
13949 /// The queue of implicit template instantiations that are required
13950 /// but have not yet been performed.
13951 std::deque<PendingImplicitInstantiation> PendingInstantiations;
13952
13953 /// Queue of implicit template instantiations that cannot be performed
13954 /// eagerly.
13956
13960
13961 /// The queue of implicit template instantiations that are required
13962 /// and must be performed within the current local scope.
13963 ///
13964 /// This queue is only used for member functions of local classes in
13965 /// templates, which must be instantiated in the same scope as their
13966 /// enclosing function, so that they can reference function-local
13967 /// types, static variables, enumerators, etc.
13968 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
13969
13971 public:
13973 : S(S), AtEndOfTU(AtEndOfTU) {
13974 SavedPendingLocalImplicitInstantiations.swap(
13975 S.PendingLocalImplicitInstantiations);
13976 }
13977
13978 void perform() {
13979 S.PerformPendingInstantiations(/*LocalOnly=*/true,
13980 /*AtEndOfTU=*/AtEndOfTU);
13981 }
13982
13984 assert(S.PendingLocalImplicitInstantiations.empty() &&
13985 "there shouldn't be any pending local implicit instantiations");
13986 SavedPendingLocalImplicitInstantiations.swap(
13987 S.PendingLocalImplicitInstantiations);
13988 }
13989
13990 private:
13991 Sema &S;
13992 bool AtEndOfTU;
13993 std::deque<PendingImplicitInstantiation>
13994 SavedPendingLocalImplicitInstantiations;
13995 };
13996
13997 /// Records and restores the CurFPFeatures state on entry/exit of compound
13998 /// statements.
14000 public:
14003 FPOptionsOverride getOverrides() { return OldOverrides; }
14004
14005 private:
14006 Sema &S;
14007 FPOptions OldFPFeaturesState;
14008 FPOptionsOverride OldOverrides;
14009 LangOptions::FPEvalMethodKind OldEvalMethod;
14010 SourceLocation OldFPPragmaLocation;
14011 };
14012
14014 public:
14015 GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
14016 : S(S), Enabled(Enabled), AtEndOfTU(AtEndOfTU) {
14017 if (!Enabled)
14018 return;
14019
14020 S.SavedPendingInstantiations.emplace_back();
14021 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
14022
14023 S.SavedVTableUses.emplace_back();
14024 S.SavedVTableUses.back().swap(S.VTableUses);
14025 }
14026
14027 void perform() {
14028 if (Enabled) {
14029 S.DefineUsedVTables();
14030 S.PerformPendingInstantiations(/*LocalOnly=*/false,
14031 /*AtEndOfTU=*/AtEndOfTU);
14032 }
14033 }
14034
14036 if (!Enabled)
14037 return;
14038
14039 // Restore the set of pending vtables.
14040 assert(S.VTableUses.empty() &&
14041 "VTableUses should be empty before it is discarded.");
14042 S.VTableUses.swap(S.SavedVTableUses.back());
14043 S.SavedVTableUses.pop_back();
14044
14045 // Restore the set of pending implicit instantiations.
14046 if ((S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) &&
14047 AtEndOfTU) {
14048 assert(S.PendingInstantiations.empty() &&
14049 "PendingInstantiations should be empty before it is discarded.");
14050 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
14051 S.SavedPendingInstantiations.pop_back();
14052 } else {
14053 // Template instantiations in the PCH may be delayed until the TU.
14054 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
14055 S.PendingInstantiations.insert(
14056 S.PendingInstantiations.end(),
14057 S.SavedPendingInstantiations.back().begin(),
14058 S.SavedPendingInstantiations.back().end());
14059 S.SavedPendingInstantiations.pop_back();
14060 }
14061 }
14062
14063 private:
14064 Sema &S;
14065 bool Enabled;
14066 bool AtEndOfTU;
14067 };
14068
14070 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
14071
14082
14083 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
14084 const Decl *Pattern, Decl *Inst,
14085 LateInstantiatedAttrVec *LateAttrs = nullptr,
14086 LocalInstantiationScope *OuterMostScope = nullptr);
14087
14088 /// Update instantiation attributes after template was late parsed.
14089 ///
14090 /// Some attributes are evaluated based on the body of template. If it is
14091 /// late parsed, such attributes cannot be evaluated when declaration is
14092 /// instantiated. This function is used to update instantiation attributes
14093 /// when template definition is ready.
14094 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
14095
14096 void
14098 const Decl *Pattern, Decl *Inst,
14099 LateInstantiatedAttrVec *LateAttrs = nullptr,
14100 LocalInstantiationScope *OuterMostScope = nullptr);
14101
14102 /// In the MS ABI, we need to instantiate default arguments of dllexported
14103 /// default constructors along with the constructor definition. This allows IR
14104 /// gen to emit a constructor closure which calls the default constructor with
14105 /// its default arguments.
14107
14109 ParmVarDecl *Param);
14110 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
14112
14113 /// Instantiate (or find existing instantiation of) a function template with a
14114 /// given set of template arguments.
14115 ///
14116 /// Usually this should not be used, and template argument deduction should be
14117 /// used in its place.
14120 SourceLocation Loc,
14123
14124 /// Instantiate the definition of the given function from its
14125 /// template.
14126 ///
14127 /// \param PointOfInstantiation the point at which the instantiation was
14128 /// required. Note that this is not precisely a "point of instantiation"
14129 /// for the function, but it's close.
14130 ///
14131 /// \param Function the already-instantiated declaration of a
14132 /// function template specialization or member function of a class template
14133 /// specialization.
14134 ///
14135 /// \param Recursive if true, recursively instantiates any functions that
14136 /// are required by this instantiation.
14137 ///
14138 /// \param DefinitionRequired if true, then we are performing an explicit
14139 /// instantiation where the body of the function is required. Complain if
14140 /// there is no such body.
14141 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
14143 bool Recursive = false,
14144 bool DefinitionRequired = false,
14145 bool AtEndOfTU = false);
14148 const TemplateArgumentList *PartialSpecArgs,
14150 SourceLocation PointOfInstantiation,
14151 LateInstantiatedAttrVec *LateAttrs = nullptr,
14152 LocalInstantiationScope *StartingScope = nullptr);
14153
14154 /// Instantiates a variable template specialization by completing it
14155 /// with appropriate type information and initializer.
14157 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
14158 const MultiLevelTemplateArgumentList &TemplateArgs);
14159
14160 /// BuildVariableInstantiation - Used after a new variable has been created.
14161 /// Sets basic variable data and decides whether to postpone the
14162 /// variable instantiation.
14163 void
14165 const MultiLevelTemplateArgumentList &TemplateArgs,
14166 LateInstantiatedAttrVec *LateAttrs,
14167 DeclContext *Owner,
14168 LocalInstantiationScope *StartingScope,
14169 bool InstantiatingVarTemplate = false,
14170 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
14171
14172 /// Instantiate the initializer of a variable.
14174 VarDecl *Var, VarDecl *OldVar,
14175 const MultiLevelTemplateArgumentList &TemplateArgs);
14176
14177 /// Instantiate the definition of the given variable from its
14178 /// template.
14179 ///
14180 /// \param PointOfInstantiation the point at which the instantiation was
14181 /// required. Note that this is not precisely a "point of instantiation"
14182 /// for the variable, but it's close.
14183 ///
14184 /// \param Var the already-instantiated declaration of a templated variable.
14185 ///
14186 /// \param Recursive if true, recursively instantiates any functions that
14187 /// are required by this instantiation.
14188 ///
14189 /// \param DefinitionRequired if true, then we are performing an explicit
14190 /// instantiation where a definition of the variable is required. Complain
14191 /// if there is no such definition.
14192 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
14193 VarDecl *Var, bool Recursive = false,
14194 bool DefinitionRequired = false,
14195 bool AtEndOfTU = false);
14196
14199 const MultiLevelTemplateArgumentList &TemplateArgs);
14200
14201 /// Find the instantiation of the given declaration within the
14202 /// current instantiation.
14203 ///
14204 /// This routine is intended to be used when \p D is a declaration
14205 /// referenced from within a template, that needs to mapped into the
14206 /// corresponding declaration within an instantiation. For example,
14207 /// given:
14208 ///
14209 /// \code
14210 /// template<typename T>
14211 /// struct X {
14212 /// enum Kind {
14213 /// KnownValue = sizeof(T)
14214 /// };
14215 ///
14216 /// bool getKind() const { return KnownValue; }
14217 /// };
14218 ///
14219 /// template struct X<int>;
14220 /// \endcode
14221 ///
14222 /// In the instantiation of X<int>::getKind(), we need to map the \p
14223 /// EnumConstantDecl for \p KnownValue (which refers to
14224 /// X<T>::<Kind>::KnownValue) to its instantiation
14225 /// (X<int>::<Kind>::KnownValue).
14226 /// \p FindInstantiatedDecl performs this mapping from within the
14227 /// instantiation of X<int>.
14228 NamedDecl *
14230 const MultiLevelTemplateArgumentList &TemplateArgs,
14231 bool FindingInstantiatedContext = false);
14232
14233 /// Finds the instantiation of the given declaration context
14234 /// within the current instantiation.
14235 ///
14236 /// \returns NULL if there was an error
14237 DeclContext *
14239 const MultiLevelTemplateArgumentList &TemplateArgs);
14240
14241 Decl *SubstDecl(Decl *D, DeclContext *Owner,
14242 const MultiLevelTemplateArgumentList &TemplateArgs);
14243
14244 /// Substitute the name and return type of a defaulted 'operator<=>' to form
14245 /// an implicit 'operator=='.
14247 FunctionDecl *Spaceship);
14248
14249 /// Performs template instantiation for all implicit template
14250 /// instantiations we have seen until this point.
14251 void PerformPendingInstantiations(bool LocalOnly = false,
14252 bool AtEndOfTU = true);
14253
14256 const MultiLevelTemplateArgumentList &TemplateArgs,
14257 bool EvaluateConstraints = true);
14258
14260 const DeclContext *Pattern,
14261 const MultiLevelTemplateArgumentList &TemplateArgs);
14262
14263private:
14264 /// Introduce the instantiated local variables into the local
14265 /// instantiation scope.
14266 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
14267 const FunctionDecl *PatternDecl,
14269 /// Introduce the instantiated function parameters into the local
14270 /// instantiation scope, and set the parameter names to those used
14271 /// in the template.
14272 bool addInstantiatedParametersToScope(
14273 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14275 const MultiLevelTemplateArgumentList &TemplateArgs);
14276
14277 /// Introduce the instantiated captures of the lambda into the local
14278 /// instantiation scope.
14279 bool addInstantiatedCapturesToScope(
14280 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14282 const MultiLevelTemplateArgumentList &TemplateArgs);
14283
14284 int ParsingClassDepth = 0;
14285
14286 class SavePendingParsedClassStateRAII {
14287 public:
14288 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
14289
14290 ~SavePendingParsedClassStateRAII() {
14291 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
14292 "there shouldn't be any pending delayed exception spec checks");
14293 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
14294 "there shouldn't be any pending delayed exception spec checks");
14295 swapSavedState();
14296 }
14297
14298 private:
14299 Sema &S;
14301 SavedOverridingExceptionSpecChecks;
14303 SavedEquivalentExceptionSpecChecks;
14304
14305 void swapSavedState() {
14306 SavedOverridingExceptionSpecChecks.swap(
14307 S.DelayedOverridingExceptionSpecChecks);
14308 SavedEquivalentExceptionSpecChecks.swap(
14309 S.DelayedEquivalentExceptionSpecChecks);
14310 }
14311 };
14312
14313 ///@}
14314
14315 //
14316 //
14317 // -------------------------------------------------------------------------
14318 //
14319 //
14320
14321 /// \name C++ Variadic Templates
14322 /// Implementations are in SemaTemplateVariadic.cpp
14323 ///@{
14324
14325public:
14326 /// Determine whether an unexpanded parameter pack might be permitted in this
14327 /// location. Useful for error recovery.
14329
14330 /// The context in which an unexpanded parameter pack is
14331 /// being diagnosed.
14332 ///
14333 /// Note that the values of this enumeration line up with the first
14334 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
14336 /// An arbitrary expression.
14338
14339 /// The base type of a class type.
14341
14342 /// The type of an arbitrary declaration.
14344
14345 /// The type of a data member.
14347
14348 /// The size of a bit-field.
14350
14351 /// The expression in a static assertion.
14353
14354 /// The fixed underlying type of an enumeration.
14356
14357 /// The enumerator value.
14359
14360 /// A using declaration.
14362
14363 /// A friend declaration.
14365
14366 /// A declaration qualifier.
14368
14369 /// An initializer.
14371
14372 /// A default argument.
14374
14375 /// The type of a non-type template parameter.
14377
14378 /// The type of an exception.
14380
14381 /// Explicit specialization.
14383
14384 /// Partial specialization.
14386
14387 /// Microsoft __if_exists.
14389
14390 /// Microsoft __if_not_exists.
14392
14393 /// Lambda expression.
14395
14396 /// Block expression.
14398
14399 /// A type constraint.
14401
14402 // A requirement in a requires-expression.
14404
14405 // A requires-clause.
14407 };
14408
14409 /// Diagnose unexpanded parameter packs.
14410 ///
14411 /// \param Loc The location at which we should emit the diagnostic.
14412 ///
14413 /// \param UPPC The context in which we are diagnosing unexpanded
14414 /// parameter packs.
14415 ///
14416 /// \param Unexpanded the set of unexpanded parameter packs.
14417 ///
14418 /// \returns true if an error occurred, false otherwise.
14422
14423 /// If the given type contains an unexpanded parameter pack,
14424 /// diagnose the error.
14425 ///
14426 /// \param Loc The source location where a diagnostc should be emitted.
14427 ///
14428 /// \param T The type that is being checked for unexpanded parameter
14429 /// packs.
14430 ///
14431 /// \returns true if an error occurred, false otherwise.
14434
14435 /// If the given expression contains an unexpanded parameter
14436 /// pack, diagnose the error.
14437 ///
14438 /// \param E The expression that is being checked for unexpanded
14439 /// parameter packs.
14440 ///
14441 /// \returns true if an error occurred, false otherwise.
14444
14445 /// If the given requirees-expression contains an unexpanded reference to one
14446 /// of its own parameter packs, diagnose the error.
14447 ///
14448 /// \param RE The requiress-expression that is being checked for unexpanded
14449 /// parameter packs.
14450 ///
14451 /// \returns true if an error occurred, false otherwise.
14453
14454 /// If the given nested-name-specifier contains an unexpanded
14455 /// parameter pack, diagnose the error.
14456 ///
14457 /// \param SS The nested-name-specifier that is being checked for
14458 /// unexpanded parameter packs.
14459 ///
14460 /// \returns true if an error occurred, false otherwise.
14463
14464 /// If the given name contains an unexpanded parameter pack,
14465 /// diagnose the error.
14466 ///
14467 /// \param NameInfo The name (with source location information) that
14468 /// is being checked for unexpanded parameter packs.
14469 ///
14470 /// \returns true if an error occurred, false otherwise.
14473
14474 /// If the given template name contains an unexpanded parameter pack,
14475 /// diagnose the error.
14476 ///
14477 /// \param Loc The location of the template name.
14478 ///
14479 /// \param Template The template name that is being checked for unexpanded
14480 /// parameter packs.
14481 ///
14482 /// \returns true if an error occurred, false otherwise.
14486
14487 /// If the given template argument contains an unexpanded parameter
14488 /// pack, diagnose the error.
14489 ///
14490 /// \param Arg The template argument that is being checked for unexpanded
14491 /// parameter packs.
14492 ///
14493 /// \returns true if an error occurred, false otherwise.
14496
14497 /// Collect the set of unexpanded parameter packs within the given
14498 /// template argument.
14499 ///
14500 /// \param Arg The template argument that will be traversed to find
14501 /// unexpanded parameter packs.
14503 TemplateArgument Arg,
14505
14506 /// Collect the set of unexpanded parameter packs within the given
14507 /// template argument.
14508 ///
14509 /// \param Arg The template argument that will be traversed to find
14510 /// unexpanded parameter packs.
14514
14515 /// Collect the set of unexpanded parameter packs within the given
14516 /// type.
14517 ///
14518 /// \param T The type that will be traversed to find
14519 /// unexpanded parameter packs.
14522
14523 /// Collect the set of unexpanded parameter packs within the given
14524 /// type.
14525 ///
14526 /// \param TL The type that will be traversed to find
14527 /// unexpanded parameter packs.
14530
14531 /// Collect the set of unexpanded parameter packs within the given
14532 /// nested-name-specifier.
14533 ///
14534 /// \param NNS The nested-name-specifier that will be traversed to find
14535 /// unexpanded parameter packs.
14539
14540 /// Collect the set of unexpanded parameter packs within the given
14541 /// name.
14542 ///
14543 /// \param NameInfo The name that will be traversed to find
14544 /// unexpanded parameter packs.
14546 const DeclarationNameInfo &NameInfo,
14548
14549 /// Collect the set of unexpanded parameter packs within the given
14550 /// expression.
14553
14554 /// Invoked when parsing a template argument.
14555 ///
14556 /// \param Arg the template argument, which may already be invalid.
14557 ///
14558 /// If it is followed by ellipsis, this function is called before
14559 /// `ActOnPackExpansion`.
14562
14563 /// Invoked when parsing a template argument followed by an
14564 /// ellipsis, which creates a pack expansion.
14565 ///
14566 /// \param Arg The template argument preceding the ellipsis, which
14567 /// may already be invalid.
14568 ///
14569 /// \param EllipsisLoc The location of the ellipsis.
14571 SourceLocation EllipsisLoc);
14572
14573 /// Invoked when parsing a type followed by an ellipsis, which
14574 /// creates a pack expansion.
14575 ///
14576 /// \param Type The type preceding the ellipsis, which will become
14577 /// the pattern of the pack expansion.
14578 ///
14579 /// \param EllipsisLoc The location of the ellipsis.
14581
14582 /// Construct a pack expansion type from the pattern of the pack
14583 /// expansion.
14585 SourceLocation EllipsisLoc,
14586 UnsignedOrNone NumExpansions);
14587
14588 /// Construct a pack expansion type from the pattern of the pack
14589 /// expansion.
14590 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14591 SourceLocation EllipsisLoc,
14592 UnsignedOrNone NumExpansions);
14593
14594 /// Invoked when parsing an expression followed by an ellipsis, which
14595 /// creates a pack expansion.
14596 ///
14597 /// \param Pattern The expression preceding the ellipsis, which will become
14598 /// the pattern of the pack expansion.
14599 ///
14600 /// \param EllipsisLoc The location of the ellipsis.
14601 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14602
14603 /// Invoked when parsing an expression followed by an ellipsis, which
14604 /// creates a pack expansion.
14605 ///
14606 /// \param Pattern The expression preceding the ellipsis, which will become
14607 /// the pattern of the pack expansion.
14608 ///
14609 /// \param EllipsisLoc The location of the ellipsis.
14610 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14611 UnsignedOrNone NumExpansions);
14612
14613 /// Determine whether we could expand a pack expansion with the
14614 /// given set of parameter packs into separate arguments by repeatedly
14615 /// transforming the pattern.
14616 ///
14617 /// \param EllipsisLoc The location of the ellipsis that identifies the
14618 /// pack expansion.
14619 ///
14620 /// \param PatternRange The source range that covers the entire pattern of
14621 /// the pack expansion.
14622 ///
14623 /// \param Unexpanded The set of unexpanded parameter packs within the
14624 /// pattern.
14625 ///
14626 /// \param ShouldExpand Will be set to \c true if the transformer should
14627 /// expand the corresponding pack expansions into separate arguments. When
14628 /// set, \c NumExpansions must also be set.
14629 ///
14630 /// \param RetainExpansion Whether the caller should add an unexpanded
14631 /// pack expansion after all of the expanded arguments. This is used
14632 /// when extending explicitly-specified template argument packs per
14633 /// C++0x [temp.arg.explicit]p9.
14634 ///
14635 /// \param NumExpansions The number of separate arguments that will be in
14636 /// the expanded form of the corresponding pack expansion. This is both an
14637 /// input and an output parameter, which can be set by the caller if the
14638 /// number of expansions is known a priori (e.g., due to a prior substitution)
14639 /// and will be set by the callee when the number of expansions is known.
14640 /// The callee must set this value when \c ShouldExpand is \c true; it may
14641 /// set this value in other cases.
14642 ///
14643 /// \returns true if an error occurred (e.g., because the parameter packs
14644 /// are to be instantiated with arguments of different lengths), false
14645 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14646 /// must be set.
14648 SourceLocation EllipsisLoc, SourceRange PatternRange,
14650 const MultiLevelTemplateArgumentList &TemplateArgs,
14651 bool FailOnPackProducingTemplates, bool &ShouldExpand,
14652 bool &RetainExpansion, UnsignedOrNone &NumExpansions,
14653 bool Diagnose = true);
14654
14655 /// Determine the number of arguments in the given pack expansion
14656 /// type.
14657 ///
14658 /// This routine assumes that the number of arguments in the expansion is
14659 /// consistent across all of the unexpanded parameter packs in its pattern.
14660 ///
14661 /// Returns an empty Optional if the type can't be expanded.
14663 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14664
14667 const MultiLevelTemplateArgumentList &TemplateArgs);
14668
14669 /// Determine whether the given declarator contains any unexpanded
14670 /// parameter packs.
14671 ///
14672 /// This routine is used by the parser to disambiguate function declarators
14673 /// with an ellipsis prior to the ')', e.g.,
14674 ///
14675 /// \code
14676 /// void f(T...);
14677 /// \endcode
14678 ///
14679 /// To determine whether we have an (unnamed) function parameter pack or
14680 /// a variadic function.
14681 ///
14682 /// \returns true if the declarator contains any unexpanded parameter packs,
14683 /// false otherwise.
14685
14686 /// Returns the pattern of the pack expansion for a template argument.
14687 ///
14688 /// \param OrigLoc The template argument to expand.
14689 ///
14690 /// \param Ellipsis Will be set to the location of the ellipsis.
14691 ///
14692 /// \param NumExpansions Will be set to the number of expansions that will
14693 /// be generated from this pack expansion, if known a priori.
14696 SourceLocation &Ellipsis,
14697 UnsignedOrNone &NumExpansions) const;
14698
14699 /// Given a template argument that contains an unexpanded parameter pack, but
14700 /// which has already been substituted, attempt to determine the number of
14701 /// elements that will be produced once this argument is fully-expanded.
14702 ///
14703 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14704 /// avoid actually expanding the pack where possible.
14706
14707 /// Called when an expression computing the size of a parameter pack
14708 /// is parsed.
14709 ///
14710 /// \code
14711 /// template<typename ...Types> struct count {
14712 /// static const unsigned value = sizeof...(Types);
14713 /// };
14714 /// \endcode
14715 ///
14716 //
14717 /// \param OpLoc The location of the "sizeof" keyword.
14718 /// \param Name The name of the parameter pack whose size will be determined.
14719 /// \param NameLoc The source location of the name of the parameter pack.
14720 /// \param RParenLoc The location of the closing parentheses.
14722 IdentifierInfo &Name,
14723 SourceLocation NameLoc,
14724 SourceLocation RParenLoc);
14725
14726 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14727 SourceLocation EllipsisLoc,
14728 SourceLocation LSquareLoc, Expr *IndexExpr,
14729 SourceLocation RSquareLoc);
14730
14731 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14732 SourceLocation EllipsisLoc, Expr *IndexExpr,
14733 SourceLocation RSquareLoc,
14734 ArrayRef<Expr *> ExpandedExprs = {},
14735 bool FullySubstituted = false);
14736
14737 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
14738 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14739 tok::TokenKind Operator,
14740 SourceLocation EllipsisLoc, Expr *RHS,
14741 SourceLocation RParenLoc);
14742 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
14743 SourceLocation LParenLoc, Expr *LHS,
14744 BinaryOperatorKind Operator,
14745 SourceLocation EllipsisLoc, Expr *RHS,
14746 SourceLocation RParenLoc,
14747 UnsignedOrNone NumExpansions);
14748 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
14749 BinaryOperatorKind Operator);
14750
14751 ///@}
14752
14753 //
14754 //
14755 // -------------------------------------------------------------------------
14756 //
14757 //
14758
14759 /// \name Constraints and Concepts
14760 /// Implementations are in SemaConcept.cpp
14761 ///@{
14762
14763public:
14765 const llvm::FoldingSetNodeID &ID) {
14766 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14767 SatisfactionStack.emplace_back(Can, ID);
14768 }
14769
14770 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
14771
14773 const llvm::FoldingSetNodeID &ID) const {
14774 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14775 return llvm::is_contained(SatisfactionStack,
14776 SatisfactionStackEntryTy{Can, ID});
14777 }
14778
14780 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
14781
14782 // Resets the current SatisfactionStack for cases where we are instantiating
14783 // constraints as a 'side effect' of normal instantiation in a way that is not
14784 // indicative of recursive definition.
14787 Sema &SemaRef;
14788
14789 public:
14791 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14792 }
14793
14795 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14796 }
14797 };
14798
14801 SatisfactionStack.swap(NewSS);
14802 }
14803
14805 llvm::PointerUnion<const NamedDecl *,
14807
14808 /// Check whether the given expression is a valid constraint expression.
14809 /// A diagnostic is emitted if it is not, false is returned, and
14810 /// PossibleNonPrimary will be set to true if the failure might be due to a
14811 /// non-primary expression being used as an atomic constraint.
14812 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
14813 bool *PossibleNonPrimary = nullptr,
14814 bool IsTrailingRequiresClause = false);
14815
14816 /// \brief Check whether the given list of constraint expressions are
14817 /// satisfied (as if in a 'conjunction') given template arguments.
14818 /// \param Template the template-like entity that triggered the constraints
14819 /// check (either a concept or a constrained entity).
14820 /// \param ConstraintExprs a list of constraint expressions, treated as if
14821 /// they were 'AND'ed together.
14822 /// \param TemplateArgLists the list of template arguments to substitute into
14823 /// the constraint expression.
14824 /// \param TemplateIDRange The source range of the template id that
14825 /// caused the constraints check.
14826 /// \param Satisfaction if true is returned, will contain details of the
14827 /// satisfaction, with enough information to diagnose an unsatisfied
14828 /// expression.
14829 /// \returns true if an error occurred and satisfaction could not be checked,
14830 /// false otherwise.
14833 ArrayRef<AssociatedConstraint> AssociatedConstraints,
14834 const MultiLevelTemplateArgumentList &TemplateArgLists,
14835 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction,
14836 const ConceptReference *TopLevelConceptId = nullptr,
14837 Expr **ConvertedExpr = nullptr);
14838
14839 /// \brief Check whether the given non-dependent constraint expression is
14840 /// satisfied. Returns false and updates Satisfaction with the satisfaction
14841 /// verdict if successful, emits a diagnostic and returns true if an error
14842 /// occurred and satisfaction could not be determined.
14843 ///
14844 /// \returns true if an error occurred, false otherwise.
14845 bool
14847 ConstraintSatisfaction &Satisfaction);
14848
14849 /// Check whether the given function decl's trailing requires clause is
14850 /// satisfied, if any. Returns false and updates Satisfaction with the
14851 /// satisfaction verdict if successful, emits a diagnostic and returns true if
14852 /// an error occurred and satisfaction could not be determined.
14853 ///
14854 /// \returns true if an error occurred, false otherwise.
14856 ConstraintSatisfaction &Satisfaction,
14857 SourceLocation UsageLoc = SourceLocation(),
14858 bool ForOverloadResolution = false);
14859
14860 // Calculates whether two constraint expressions are equal irrespective of a
14861 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
14862 // 'New', which are the "source" of the constraint, since this is necessary
14863 // for figuring out the relative 'depth' of the constraint. The depth of the
14864 // 'primary template' and the 'instantiated from' templates aren't necessarily
14865 // the same, such as a case when one is a 'friend' defined in a class.
14867 const Expr *OldConstr,
14869 const Expr *NewConstr);
14870
14871 // Calculates whether the friend function depends on an enclosing template for
14872 // the purposes of [temp.friend] p9.
14874
14875 /// \brief Ensure that the given template arguments satisfy the constraints
14876 /// associated with the given template, emitting a diagnostic if they do not.
14877 ///
14878 /// \param Template The template to which the template arguments are being
14879 /// provided.
14880 ///
14881 /// \param TemplateArgs The converted, canonicalized template arguments.
14882 ///
14883 /// \param TemplateIDRange The source range of the template id that
14884 /// caused the constraints check.
14885 ///
14886 /// \returns true if the constrains are not satisfied or could not be checked
14887 /// for satisfaction, false if the constraints are satisfied.
14890 const MultiLevelTemplateArgumentList &TemplateArgs,
14891 SourceRange TemplateIDRange);
14892
14893 bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation,
14895 ArrayRef<TemplateArgument> TemplateArgs,
14896 ConstraintSatisfaction &Satisfaction);
14897
14898 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14899 /// unsatisfied.
14900 /// \param First whether this is the first time an unsatisfied constraint is
14901 /// diagnosed for this error.
14903 SourceLocation Loc = {},
14904 bool First = true);
14905
14906 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14907 /// unsatisfied.
14908 void
14910 bool First = true);
14911
14914 ArrayRef<AssociatedConstraint> AssociatedConstraints);
14915
14916 /// \brief Check whether the given declaration's associated constraints are
14917 /// at least as constrained than another declaration's according to the
14918 /// partial ordering of constraints.
14919 ///
14920 /// \param Result If no error occurred, receives the result of true if D1 is
14921 /// at least constrained than D2, and false otherwise.
14922 ///
14923 /// \returns true if an error occurred, false otherwise.
14924 bool IsAtLeastAsConstrained(const NamedDecl *D1,
14926 const NamedDecl *D2,
14928 bool &Result);
14929
14930 /// If D1 was not at least as constrained as D2, but would've been if a pair
14931 /// of atomic constraints involved had been declared in a concept and not
14932 /// repeated in two separate places in code.
14933 /// \returns true if such a diagnostic was emitted, false otherwise.
14937
14938 /// Cache the satisfaction of an atomic constraint.
14939 /// The key is based on the unsubstituted expression and the parameter
14940 /// mapping. This lets us not substituting the mapping more than once,
14941 /// which is (very!) expensive.
14942 /// FIXME: this should be private.
14943 llvm::DenseMap<llvm::FoldingSetNodeID,
14946
14947private:
14948 /// Caches pairs of template-like decls whose associated constraints were
14949 /// checked for subsumption and whether or not the first's constraints did in
14950 /// fact subsume the second's.
14951 llvm::DenseMap<std::pair<const NamedDecl *, const NamedDecl *>, bool>
14952 SubsumptionCache;
14953 /// Caches the normalized associated constraints of declarations (concepts or
14954 /// constrained declarations). If an error occurred while normalizing the
14955 /// associated constraints of the template or concept, nullptr will be cached
14956 /// here.
14957 llvm::DenseMap<ConstrainedDeclOrNestedRequirement, NormalizedConstraint *>
14958 NormalizationCache;
14959
14960 /// Cache whether the associated constraint of a declaration
14961 /// is satisfied.
14962 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
14963 SatisfactionCache;
14964
14965 // The current stack of constraint satisfactions, so we can exit-early.
14967
14968 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to set up the
14969 /// LocalInstantiationScope of the current non-lambda function. For lambdas,
14970 /// use LambdaScopeForCallOperatorInstantiationRAII.
14971 bool
14972 SetupConstraintScope(FunctionDecl *FD,
14973 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14974 const MultiLevelTemplateArgumentList &MLTAL,
14976
14977 /// Used during constraint checking, sets up the constraint template argument
14978 /// lists, and calls SetupConstraintScope to set up the
14979 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
14980 std::optional<MultiLevelTemplateArgumentList>
14981 SetupConstraintCheckingTemplateArgumentsAndScope(
14982 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14984
14985 ///@}
14986
14987 //
14988 //
14989 // -------------------------------------------------------------------------
14990 //
14991 //
14992
14993 /// \name Types
14994 /// Implementations are in SemaType.cpp
14995 ///@{
14996
14997public:
14998 /// A mapping that describes the nullability we've seen in each header file.
15000
15001 static int getPrintable(int I) { return I; }
15002 static unsigned getPrintable(unsigned I) { return I; }
15003 static bool getPrintable(bool B) { return B; }
15004 static const char *getPrintable(const char *S) { return S; }
15005 static StringRef getPrintable(StringRef S) { return S; }
15006 static const std::string &getPrintable(const std::string &S) { return S; }
15007 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
15008 return II;
15009 }
15011 static QualType getPrintable(QualType T) { return T; }
15012 static SourceRange getPrintable(SourceRange R) { return R; }
15014 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
15016
15017 enum class CompleteTypeKind {
15018 /// Apply the normal rules for complete types. In particular,
15019 /// treat all sizeless types as incomplete.
15021
15022 /// Relax the normal rules for complete types so that they include
15023 /// sizeless built-in types.
15025
15026 // FIXME: Eventually we should flip the default to Normal and opt in
15027 // to AcceptSizeless rather than opt out of it.
15029 };
15030
15032 const DeclSpec *DS = nullptr);
15034 const DeclSpec *DS = nullptr);
15035
15036 /// Build a pointer type.
15037 ///
15038 /// \param T The type to which we'll be building a pointer.
15039 ///
15040 /// \param Loc The location of the entity whose type involves this
15041 /// pointer type or, if there is no such entity, the location of the
15042 /// type that will have pointer type.
15043 ///
15044 /// \param Entity The name of the entity that involves the pointer
15045 /// type, if known.
15046 ///
15047 /// \returns A suitable pointer type, if there are no
15048 /// errors. Otherwise, returns a NULL type.
15050 DeclarationName Entity);
15051
15052 /// Build a reference type.
15053 ///
15054 /// \param T The type to which we'll be building a reference.
15055 ///
15056 /// \param Loc The location of the entity whose type involves this
15057 /// reference type or, if there is no such entity, the location of the
15058 /// type that will have reference type.
15059 ///
15060 /// \param Entity The name of the entity that involves the reference
15061 /// type, if known.
15062 ///
15063 /// \returns A suitable reference type, if there are no
15064 /// errors. Otherwise, returns a NULL type.
15066 DeclarationName Entity);
15067
15068 /// Build an array type.
15069 ///
15070 /// \param T The type of each element in the array.
15071 ///
15072 /// \param ASM C99 array size modifier (e.g., '*', 'static').
15073 ///
15074 /// \param ArraySize Expression describing the size of the array.
15075 ///
15076 /// \param Brackets The range from the opening '[' to the closing ']'.
15077 ///
15078 /// \param Entity The name of the entity that involves the array
15079 /// type, if known.
15080 ///
15081 /// \returns A suitable array type, if there are no errors. Otherwise,
15082 /// returns a NULL type.
15084 unsigned Quals, SourceRange Brackets,
15085 DeclarationName Entity);
15087
15088 /// Build an ext-vector type.
15089 ///
15090 /// Run the required checks for the extended vector type.
15092 SourceLocation AttrLoc);
15093 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
15094 SourceLocation AttrLoc);
15095
15097 Expr *CountExpr,
15098 bool CountInBytes,
15099 bool OrNull);
15100
15101 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
15102 /// expression is uninstantiated. If instantiated it will apply the
15103 /// appropriate address space to the type. This function allows dependent
15104 /// template variables to be used in conjunction with the address_space
15105 /// attribute
15106 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
15107 SourceLocation AttrLoc);
15108
15109 /// Same as above, but constructs the AddressSpace index if not provided.
15111 SourceLocation AttrLoc);
15112
15114
15116
15117 /// Build a function type.
15118 ///
15119 /// This routine checks the function type according to C++ rules and
15120 /// under the assumption that the result type and parameter types have
15121 /// just been instantiated from a template. It therefore duplicates
15122 /// some of the behavior of GetTypeForDeclarator, but in a much
15123 /// simpler form that is only suitable for this narrow use case.
15124 ///
15125 /// \param T The return type of the function.
15126 ///
15127 /// \param ParamTypes The parameter types of the function. This array
15128 /// will be modified to account for adjustments to the types of the
15129 /// function parameters.
15130 ///
15131 /// \param Loc The location of the entity whose type involves this
15132 /// function type or, if there is no such entity, the location of the
15133 /// type that will have function type.
15134 ///
15135 /// \param Entity The name of the entity that involves the function
15136 /// type, if known.
15137 ///
15138 /// \param EPI Extra information about the function type. Usually this will
15139 /// be taken from an existing function with the same prototype.
15140 ///
15141 /// \returns A suitable function type, if there are no errors. The
15142 /// unqualified type will always be a FunctionProtoType.
15143 /// Otherwise, returns a NULL type.
15145 SourceLocation Loc, DeclarationName Entity,
15147
15148 /// Build a member pointer type \c T Class::*.
15149 ///
15150 /// \param T the type to which the member pointer refers.
15151 /// \param Class the class type into which the member pointer points.
15152 /// \param Loc the location where this type begins
15153 /// \param Entity the name of the entity that will have this member pointer
15154 /// type
15155 ///
15156 /// \returns a member pointer type, if successful, or a NULL type if there was
15157 /// an error.
15159 CXXRecordDecl *Cls, SourceLocation Loc,
15160 DeclarationName Entity);
15161
15162 /// Build a block pointer type.
15163 ///
15164 /// \param T The type to which we'll be building a block pointer.
15165 ///
15166 /// \param Loc The source location, used for diagnostics.
15167 ///
15168 /// \param Entity The name of the entity that involves the block pointer
15169 /// type, if known.
15170 ///
15171 /// \returns A suitable block pointer type, if there are no
15172 /// errors. Otherwise, returns a NULL type.
15174 DeclarationName Entity);
15175
15176 /// Build a paren type including \p T.
15179
15180 /// Build a Read-only Pipe type.
15181 ///
15182 /// \param T The type to which we'll be building a Pipe.
15183 ///
15184 /// \param Loc We do not use it for now.
15185 ///
15186 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15187 /// a NULL type.
15189
15190 /// Build a Write-only Pipe type.
15191 ///
15192 /// \param T The type to which we'll be building a Pipe.
15193 ///
15194 /// \param Loc We do not use it for now.
15195 ///
15196 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15197 /// a NULL type.
15199
15200 /// Build a bit-precise integer type.
15201 ///
15202 /// \param IsUnsigned Boolean representing the signedness of the type.
15203 ///
15204 /// \param BitWidth Size of this int type in bits, or an expression
15205 /// representing that.
15206 ///
15207 /// \param Loc Location of the keyword.
15208 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
15209
15210 /// GetTypeForDeclarator - Convert the type for the specified
15211 /// declarator to Type instances.
15212 ///
15213 /// The result of this call will never be null, but the associated
15214 /// type may be a null type if there's an unrecoverable error.
15217
15218 /// Package the given type and TSI into a ParsedType.
15221 TypeSourceInfo **TInfo = nullptr);
15222
15224
15225 // Check whether the size of array element of type \p EltTy is a multiple of
15226 // its alignment and return false if it isn't.
15228
15229 void
15230 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
15231 SourceLocation FallbackLoc,
15232 SourceLocation ConstQualLoc = SourceLocation(),
15233 SourceLocation VolatileQualLoc = SourceLocation(),
15234 SourceLocation RestrictQualLoc = SourceLocation(),
15235 SourceLocation AtomicQualLoc = SourceLocation(),
15236 SourceLocation UnalignedQualLoc = SourceLocation());
15237
15238 /// Retrieve the keyword associated
15240
15241 /// Adjust the calling convention of a method to be the ABI default if it
15242 /// wasn't specified explicitly. This handles method types formed from
15243 /// function type typedefs and typename template arguments.
15244 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
15245 bool IsCtorOrDtor, SourceLocation Loc);
15246
15247 // Check if there is an explicit attribute, but only look through parens.
15248 // The intent is to look for an attribute on the current declarator, but not
15249 // one that came from a typedef.
15251
15252 /// Check whether a nullability type specifier can be added to the given
15253 /// type through some means not written in source (e.g. API notes).
15254 ///
15255 /// \param Type The type to which the nullability specifier will be
15256 /// added. On success, this type will be updated appropriately.
15257 ///
15258 /// \param Nullability The nullability specifier to add.
15259 ///
15260 /// \param DiagLoc The location to use for diagnostics.
15261 ///
15262 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
15263 /// array type (e.g., because it will decay to a pointer).
15264 ///
15265 /// \param OverrideExisting Whether to override an existing, locally-specified
15266 /// nullability specifier rather than complaining about the conflict.
15267 ///
15268 /// \returns true if nullability cannot be applied, false otherwise.
15270 NullabilityKind Nullability,
15271 SourceLocation DiagLoc,
15272 bool AllowArrayTypes,
15273 bool OverrideExisting);
15274
15275 /// Get the type of expression E, triggering instantiation to complete the
15276 /// type if necessary -- that is, if the expression refers to a templated
15277 /// static data member of incomplete array type.
15278 ///
15279 /// May still return an incomplete type if instantiation was not possible or
15280 /// if the type is incomplete for a different reason. Use
15281 /// RequireCompleteExprType instead if a diagnostic is expected for an
15282 /// incomplete expression type.
15284
15286
15287 /// Ensure that the type of the given expression is complete.
15288 ///
15289 /// This routine checks whether the expression \p E has a complete type. If
15290 /// the expression refers to an instantiable construct, that instantiation is
15291 /// performed as needed to complete its type. Furthermore
15292 /// Sema::RequireCompleteType is called for the expression's type (or in the
15293 /// case of a reference type, the referred-to type).
15294 ///
15295 /// \param E The expression whose type is required to be complete.
15296 /// \param Kind Selects which completeness rules should be applied.
15297 /// \param Diagnoser The object that will emit a diagnostic if the type is
15298 /// incomplete.
15299 ///
15300 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
15301 /// otherwise.
15303 TypeDiagnoser &Diagnoser);
15304 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
15305
15306 template <typename... Ts>
15307 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
15308 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15310 }
15311
15312 // Returns the underlying type of a decltype with the given expression.
15314
15316 /// If AsUnevaluated is false, E is treated as though it were an evaluated
15317 /// context, such as when building a type for decltype(auto).
15318 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
15319
15320 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
15321 SourceLocation Loc,
15322 SourceLocation EllipsisLoc);
15323 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
15324 SourceLocation Loc, SourceLocation EllipsisLoc,
15325 bool FullySubstituted = false,
15326 ArrayRef<QualType> Expansions = {});
15327
15328 using UTTKind = UnaryTransformType::UTTKind;
15330 SourceLocation Loc);
15336 SourceLocation Loc);
15338 SourceLocation Loc);
15340 SourceLocation Loc);
15341
15343 return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc);
15344 }
15345
15347 SourceLocation Loc);
15349 SourceLocation Loc);
15350
15351 bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);
15352
15353 /// Ensure that the type T is a literal type.
15354 ///
15355 /// This routine checks whether the type @p T is a literal type. If @p T is an
15356 /// incomplete type, an attempt is made to complete it. If @p T is a literal
15357 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
15358 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
15359 /// it the type @p T), along with notes explaining why the type is not a
15360 /// literal type, and returns true.
15361 ///
15362 /// @param Loc The location in the source that the non-literal type
15363 /// diagnostic should refer to.
15364 ///
15365 /// @param T The type that this routine is examining for literalness.
15366 ///
15367 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
15368 ///
15369 /// @returns @c true if @p T is not a literal type and a diagnostic was
15370 /// emitted, @c false otherwise.
15372 TypeDiagnoser &Diagnoser);
15373 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
15374
15375 template <typename... Ts>
15376 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
15377 const Ts &...Args) {
15378 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15379 return RequireLiteralType(Loc, T, Diagnoser);
15380 }
15381
15384 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
15385 }
15386
15387 /// Ensure that the type T is a complete type.
15388 ///
15389 /// This routine checks whether the type @p T is complete in any
15390 /// context where a complete type is required. If @p T is a complete
15391 /// type, returns false. If @p T is a class template specialization,
15392 /// this routine then attempts to perform class template
15393 /// instantiation. If instantiation fails, or if @p T is incomplete
15394 /// and cannot be completed, issues the diagnostic @p diag (giving it
15395 /// the type @p T) and returns true.
15396 ///
15397 /// @param Loc The location in the source that the incomplete type
15398 /// diagnostic should refer to.
15399 ///
15400 /// @param T The type that this routine is examining for completeness.
15401 ///
15402 /// @param Kind Selects which completeness rules should be applied.
15403 ///
15404 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
15405 /// @c false otherwise.
15407 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
15409 CompleteTypeKind Kind, unsigned DiagID);
15410
15412 TypeDiagnoser &Diagnoser) {
15413 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, Diagnoser);
15414 }
15415 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID) {
15416 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, DiagID);
15417 }
15418
15419 template <typename... Ts>
15420 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
15421 const Ts &...Args) {
15422 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15423 return RequireCompleteType(Loc, T, Diagnoser);
15424 }
15425
15426 /// Determine whether a declaration is visible to name lookup.
15427 bool isVisible(const NamedDecl *D) {
15428 return D->isUnconditionallyVisible() ||
15429 isAcceptableSlow(D, AcceptableKind::Visible);
15430 }
15431
15432 /// Determine whether a declaration is reachable.
15433 bool isReachable(const NamedDecl *D) {
15434 // All visible declarations are reachable.
15435 return D->isUnconditionallyVisible() ||
15436 isAcceptableSlow(D, AcceptableKind::Reachable);
15437 }
15438
15439 /// Determine whether a declaration is acceptable (visible/reachable).
15441 return Kind == AcceptableKind::Visible ? isVisible(D) : isReachable(D);
15442 }
15443
15444 /// Determine if \p D and \p Suggested have a structurally compatible
15445 /// layout as described in C11 6.2.7/1.
15446 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15447
15448 /// Determine if \p D has a visible definition. If not, suggest a declaration
15449 /// that should be made visible to expose the definition.
15450 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15451 bool OnlyNeedComplete = false);
15453 NamedDecl *Hidden;
15454 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15455 }
15456 /// Determine if \p D has a definition which allows we redefine it in current
15457 /// TU. \p Suggested is the definition that should be made visible to expose
15458 /// the definition.
15459 bool isRedefinitionAllowedFor(NamedDecl *D, NamedDecl **Suggested,
15460 bool &Visible);
15462 NamedDecl *Hidden;
15463 return isRedefinitionAllowedFor(const_cast<NamedDecl *>(D), &Hidden,
15464 Visible);
15465 }
15466
15467 /// Determine if \p D has a reachable definition. If not, suggest a
15468 /// declaration that should be made reachable to expose the definition.
15469 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15470 bool OnlyNeedComplete = false);
15472 NamedDecl *Hidden;
15473 return hasReachableDefinition(D, &Hidden);
15474 }
15475
15476 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15477 AcceptableKind Kind,
15478 bool OnlyNeedComplete = false);
15480 NamedDecl *Hidden;
15481 return hasAcceptableDefinition(D, &Hidden, Kind);
15482 }
15483
15484 /// Try to parse the conditional expression attached to an effect attribute
15485 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
15486 /// optional on error.
15487 std::optional<FunctionEffectMode>
15488 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
15489
15490 void ActOnCleanupAttr(Decl *D, const Attr *A);
15491
15492private:
15493 /// The implementation of RequireCompleteType
15494 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15495 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15496
15497 /// Nullability type specifiers.
15498 IdentifierInfo *Ident__Nonnull = nullptr;
15499 IdentifierInfo *Ident__Nullable = nullptr;
15500 IdentifierInfo *Ident__Nullable_result = nullptr;
15501 IdentifierInfo *Ident__Null_unspecified = nullptr;
15502
15503 ///@}
15504
15505 //
15506 //
15507 // -------------------------------------------------------------------------
15508 //
15509 //
15510
15511 /// \name FixIt Helpers
15512 /// Implementations are in SemaFixItUtils.cpp
15513 ///@{
15514
15515public:
15516 /// Get a string to suggest for zero-initialization of a type.
15518 SourceLocation Loc) const;
15519 std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
15520
15521 ///@}
15522
15523 //
15524 //
15525 // -------------------------------------------------------------------------
15526 //
15527 //
15528
15529 /// \name Function Effects
15530 /// Implementations are in SemaFunctionEffects.cpp
15531 ///@{
15532public:
15535
15538 std::optional<FunctionEffectWithCondition>
15539 Old; // Invalid when 'Kind' is 'Added'.
15540 std::optional<FunctionEffectWithCondition>
15541 New; // Invalid when 'Kind' is 'Removed'.
15542
15543 StringRef effectName() const {
15544 if (Old)
15545 return Old.value().Effect.name();
15546 return New.value().Effect.name();
15547 }
15548
15549 /// Describes the result of effects differing between a base class's virtual
15550 /// method and an overriding method in a subclass.
15551 enum class OverrideResult {
15554 Merge // Merge missing effect from base to derived.
15555 };
15556
15557 /// Return true if adding or removing the effect as part of a type
15558 /// conversion should generate a diagnostic.
15560 const FunctionEffectsRef &SrcFX,
15561 QualType DstType,
15562 const FunctionEffectsRef &DstFX) const;
15563
15564 /// Return true if adding or removing the effect in a redeclaration should
15565 /// generate a diagnostic.
15566 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
15567 const FunctionEffectsRef &OldFX,
15568 const FunctionDecl &NewFunction,
15569 const FunctionEffectsRef &NewFX) const;
15570
15571 /// Return true if adding or removing the effect in a C++ virtual method
15572 /// override should generate a diagnostic.
15574 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
15575 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
15576 };
15577
15578 struct FunctionEffectDiffVector : public SmallVector<FunctionEffectDiff> {
15579 /// Caller should short-circuit by checking for equality first.
15581 const FunctionEffectsRef &New);
15582 };
15583
15584 /// All functions/lambdas/blocks which have bodies and which have a non-empty
15585 /// FunctionEffectsRef to be verified.
15587
15588 /// The union of all effects present on DeclsWithEffectsToVerify. Conditions
15589 /// are all null.
15591
15592public:
15593 /// Warn and return true if adding a function effect to a set would create a
15594 /// conflict.
15597 SourceLocation NewAttrLoc);
15598
15599 // Report a failure to merge function effects between declarations due to a
15600 // conflict.
15601 void
15603 SourceLocation NewLoc,
15604 SourceLocation OldLoc);
15605
15606 /// Inline checks from the start of maybeAddDeclWithEffects, to
15607 /// minimize performance impact on code not using effects.
15608 template <class FuncOrBlockDecl>
15609 void maybeAddDeclWithEffects(FuncOrBlockDecl *D) {
15610 if (Context.hasAnyFunctionEffects())
15611 if (FunctionEffectsRef FX = D->getFunctionEffects(); !FX.empty())
15613 }
15614
15615 /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify.
15616 void maybeAddDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15617
15618 /// Unconditionally add a Decl to DeclsWithEfffectsToVerify.
15619 void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15620
15622
15623 ///@}
15624};
15625
15626DeductionFailureInfo
15628 sema::TemplateDeductionInfo &Info);
15629
15630/// Contains a late templated function.
15631/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15634 /// The template function declaration to be late parsed.
15636 /// Floating-point options in the point of definition.
15638};
15639
15640template <>
15642 PragmaMsStackAction Action,
15643 llvm::StringRef StackSlotLabel,
15645
15646} // end namespace clang
15647
15648#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)
#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.
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:49
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:4785
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:220
Represents a member of a struct/union/class.
Definition Decl.h:3160
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:220
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:430
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:2721
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3723
Attr - This represents one attribute.
Definition Attr.h:45
Represents a C++ declaration that introduces decls from somewhere else.
Definition DeclCXX.h:3492
A binding in a decomposition declaration.
Definition DeclCXX.h:4181
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4668
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:2604
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2939
Represents a C++ base or member initializer.
Definition DeclCXX.h:2369
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2626
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
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:2129
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:73
Represents the this expression in C++.
Definition ExprCXX.h:1154
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:2877
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4940
CaseStmt - Represent a case statement.
Definition Stmt.h:1910
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3610
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:3673
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:1382
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1270
Captures information about "declaration specifiers".
Definition DeclSpec.h:217
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:859
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition DeclBase.h:842
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:978
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:1874
A decomposition declaration.
Definition DeclCXX.h:4245
Captures a template argument whose value has been deduced via c++ template argument deduction.
Definition Template.h:331
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:232
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3423
Represents an enum.
Definition Decl.h:4007
Store information needed for an explicit specifier.
Definition DeclCXX.h:1924
The return type of classify().
Definition Expr.h:337
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:802
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition Expr.cpp:276
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:3160
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
A mapping from file IDs to a record of whether we've seen nullability information in that file.
Definition Sema.h:259
FileNullability & operator[](FileID file)
Definition Sema.h:270
FileNullability Nullability
Definition Sema.h:266
Represents a function declaration or definition.
Definition Decl.h:2000
A mutable set of FunctionEffect::Kind.
Definition TypeBase.h:5123
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5237
Kind
Identifies the particular effect.
Definition TypeBase.h:4885
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition TypeBase.h:5069
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:5269
Declaration of a template function.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4491
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4465
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:621
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3467
Describes an C or C++ initializer list.
Definition Expr.h:5233
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:369
Represents the results of name lookup.
Definition Lookup.h:147
A global _GUID constant.
Definition DeclCXX.h:4394
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4340
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:3298
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3654
Abstract interface for a module loader.
Describes a module or submodule.
Definition Module.h:144
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:7911
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:1159
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Definition Attr.h:273
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2182
Represents a parameter to a function.
Definition Decl.h:1790
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:293
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:329
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:2694
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:4321
Represents the body of a requires-expression.
Definition DeclCXX.h:2098
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:1842
bool operator==(const AlignPackInfo &Info) const
Definition Sema.h:1902
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition Sema.h:1874
unsigned getPackNumber() const
Definition Sema.h:1892
bool IsXLStack() const
Definition Sema.h:1900
bool IsPackSet() const
Definition Sema.h:1894
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition Sema.h:1848
bool IsAlignAttr() const
Definition Sema.h:1888
bool IsPackAttr() const
Definition Sema.h:1886
bool operator!=(const AlignPackInfo &Info) const
Definition Sema.h:1908
AlignPackInfo(bool IsXL)
Definition Sema.h:1852
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition Sema.h:1859
Mode getAlignMode() const
Definition Sema.h:1890
ArgPackSubstIndexRAII(Sema &Self, UnsignedOrNone NewSubstIndex)
Definition Sema.h:13607
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8263
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8268
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition Sema.h:8255
std::tuple< const Ts &... > Args
Definition Sema.h:8252
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(Sema &S, bool IsStmtExpr=false)
Definition Sema.h:1293
std::pair< VarDecl *, Expr * > get() const
Definition Sema.h:7804
std::optional< bool > getKnownValue() const
Definition Sema.h:7808
A RAII object to temporarily push a declaration context.
Definition Sema.h:3468
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition Sema.h:3478
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition Sema.h:10287
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:10292
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:6375
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition Sema.h:6352
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition Sema.h:6380
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition Sema.h:6355
CXXSpecialMemberKind asSpecialMember() const
Definition Sema.h:6372
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition Sema.h:10029
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition Sema.h:1356
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition Sema.h:1375
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition Sema.h:1399
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition Sema.h:1368
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition Sema.h:1371
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:1385
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition Sema.h:1391
A helper class for building up ExtParameterInfos.
Definition Sema.h:12995
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:13014
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13002
FPOptionsOverride getOverrides()
Definition Sema.h:14003
FullExprArg(Sema &actions)
Definition Sema.h:7748
ExprResult release()
Definition Sema.h:7750
friend class Sema
Definition Sema.h:7759
Expr * get() const
Definition Sema.h:7752
GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
Definition Sema.h:14015
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:10351
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:10343
unsigned size() const
The number of exceptions in the exception specification.
Definition Sema.h:5474
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition Sema.h:5467
const QualType * data() const
The set of exceptions in the exception specification.
Definition Sema.h:5477
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:5483
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition Sema.h:5490
LambdaScopeForCallOperatorInstantiationRAII(Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope, bool ShouldAddDeclsFromParentScope=true)
LocalEagerInstantiationScope(Sema &S, bool AtEndOfTU)
Definition Sema.h:13972
static NameClassification DependentNonType()
Definition Sema.h:3682
static NameClassification VarTemplate(TemplateName Name)
Definition Sema.h:3692
ExprResult getExpression() const
Definition Sema.h:3718
NameClassification(const IdentifierInfo *Keyword)
Definition Sema.h:3655
static NameClassification Unknown()
Definition Sema.h:3662
static NameClassification OverloadSet(ExprResult E)
Definition Sema.h:3666
NameClassificationKind getKind() const
Definition Sema.h:3716
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition Sema.h:3710
static NameClassification FunctionTemplate(TemplateName Name)
Definition Sema.h:3698
NamedDecl * getNonTypeDecl() const
Definition Sema.h:3728
NameClassification(ParsedType Type)
Definition Sema.h:3652
TemplateName getTemplateName() const
Definition Sema.h:3733
ParsedType getType() const
Definition Sema.h:3723
TemplateNameKind getTemplateNameKind() const
Definition Sema.h:3742
static NameClassification NonType(NamedDecl *D)
Definition Sema.h:3672
static NameClassification Concept(TemplateName Name)
Definition Sema.h:3704
static NameClassification UndeclaredNonType()
Definition Sema.h:3678
static NameClassification TypeTemplate(TemplateName Name)
Definition Sema.h:3686
static NameClassification Error()
Definition Sema.h:3658
void operator()(sema::FunctionScopeInfo *Scope) const
Definition Sema.cpp:2467
PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct)
Definition SemaAttr.cpp:29
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition Sema.h:11379
SourceLocation getTemplateKeywordLoc() const
Definition Sema.h:11381
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition Sema.h:11376
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition Sema.h:12430
SFINAETrap & operator=(const SFINAETrap &)=delete
SFINAETrap(const SFINAETrap &)=delete
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition Sema.h:12464
SFINAETrap(Sema &S, bool WithAccessChecking=false)
Definition Sema.h:12446
bool withAccessChecking() const
Definition Sema.h:12467
sema::TemplateDeductionInfo * getDeductionInfo() const
Definition Sema.h:12459
SFINAETrap(Sema &S, sema::TemplateDeductionInfo &Info)
Definition Sema.h:12449
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition Sema.h:8280
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8285
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8282
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition Sema.h:9293
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition Sema.h:9280
CXXMethodDecl * getMethod() const
Definition Sema.h:9283
void setMethod(CXXMethodDecl *MD)
Definition Sema.h:9284
void addContextNote(SourceLocation UseLoc)
Definition Sema.h:13513
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition Sema.h:13501
SourceLocation getLocation() const
Definition Sema.h:12190
bool ContainsDecl(const NamedDecl *ND) const
Definition Sema.h:12180
const DeclContext * getDeclContext() const
Definition Sema.h:12186
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition Sema.h:12164
const NamedDecl * getDecl() const
Definition Sema.h:12178
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition Sema.h:12163
const DeclContext * getLexicalDeclContext() const
Definition Sema.h:12182
TentativeAnalysisScope(Sema &SemaRef)
Definition Sema.h:12481
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition Sema.h:7707
virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc)
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:855
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:1417
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:3560
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:13557
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:8185
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
Definition SemaAttr.cpp:503
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition Sema.h:13541
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:10935
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition Sema.h:13024
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
Definition Sema.cpp:2540
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:1121
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:1560
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:13957
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
void PopParsingClass(ParsingClassState state)
Definition Sema.h:6543
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:10040
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition Sema.cpp:1061
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:6532
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)
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:8235
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:8153
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:935
bool isAttrContext() const
Definition Sema.h:6939
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 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:8228
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition Sema.cpp:2640
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition Sema.h:6294
LookupNameKind
Describes the kind of name lookup to perform.
Definition Sema.h:9309
@ LookupLabel
Label name lookup.
Definition Sema.h:9318
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition Sema.h:9313
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition Sema.h:9340
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition Sema.h:9332
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition Sema.h:9354
@ LookupLocalFriendName
Look up a friend of a local class.
Definition Sema.h:9348
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition Sema.h:9350
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition Sema.h:9345
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition Sema.h:9325
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition Sema.h:9352
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition Sema.h:9336
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9321
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition Sema.h:9328
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9316
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition Sema.h:9356
@ LookupAnyName
Look up any declaration with any name.
Definition Sema.h:9358
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:411
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition Sema.h:9259
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition Sema.h:4875
UnaryTransformType::UTTKind UTTKind
Definition Sema.h:15328
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.
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:628
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:6231
SemaM68k & M68k()
Definition Sema.h:1467
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:13617
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:1351
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)
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:2107
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:9747
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:4820
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:5030
OpaquePtr< QualType > TypeTy
Definition Sema.h:1277
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:168
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:365
void PrintContextStack()
Definition Sema.h:13626
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:1502
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition Sema.h:9258
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:2282
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition Sema.h:6269
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition Sema.h:9623
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:1343
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.
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:15007
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:1242
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:4731
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:3542
PragmaClangSection PragmaClangRodataSection
Definition Sema.h:1814
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:15452
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:6505
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:5129
void emitAndClearUnusedLocalTypedefWarnings()
Definition Sema.cpp:1152
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:6486
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:1231
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:1442
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:371
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
Definition Sema.h:7824
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7826
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7825
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition Sema.h:1324
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:15411
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition Sema.h:15013
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
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:8173
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:9860
@ Interface
'export module X;'
Definition Sema.h:9857
@ Implementation
'module X;'
Definition Sema.h:9858
@ PartitionInterface
'export module X:Y;'
Definition Sema.h:9859
SourceLocation LocationOfExcessPrecisionNotSatisfied
Definition Sema.h:8315
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition Sema.h:1224
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:9570
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition Sema.h:10370
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition Sema.h:10373
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition Sema.h:10379
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition Sema.h:10377
void inferLifetimeCaptureByAttribute(FunctionDecl *FD)
Add [[clang:lifetime_capture_by(this)]] to STL container methods.
Definition SemaAttr.cpp:277
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:1772
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
@ AR_dependent
Definition Sema.h:1657
@ AR_accessible
Definition Sema.h:1655
@ AR_inaccessible
Definition Sema.h:1656
@ AR_delayed
Definition Sema.h:1658
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Definition Sema.cpp:2443
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:15020
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
Definition Sema.h:15024
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:925
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition Sema.h:6917
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition Sema.cpp:2312
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,...
FunctionTemplateDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:438
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:8304
void deduceOpenCLAddressSpace(ValueDecl *decl)
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition Sema.h:2045
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:8216
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition Sema.h:15014
PragmaStack< StringLiteral * > CodeSegStack
Definition Sema.h:2039
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:15590
void setFunctionHasBranchIntoScope()
Definition Sema.cpp:2493
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:4880
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:2116
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:6746
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:620
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:2034
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:11100
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:2592
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:4131
@ Default
= default ;
Definition Sema.h:4133
@ Delete
deleted-function-body
Definition Sema.h:4139
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)
llvm::function_ref< void(llvm::raw_ostream &)> EntityPrinter
Definition Sema.h:13919
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.
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:1231
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:2046
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:1457
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:847
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...
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:14945
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
void ActOnTranslationUnitScope(Scope *S)
Scope actions.
Definition Sema.cpp:172
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:1527
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:2867
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:6929
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:1654
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:663
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
Definition SemaExpr.cpp:833
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition Sema.h:11344
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:11942
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition Sema.h:11953
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition Sema.h:11945
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition Sema.h:11949
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:674
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:717
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:9253
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
SemaX86 & X86()
Definition Sema.h:1547
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:13561
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:1284
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:8140
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:680
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:9264
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition Sema.h:7769
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:935
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)
DiagnosticsEngine & getDiagnostics() const
Definition Sema.h:923
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:4357
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15376
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
void resetFPOptions(FPOptions FPO)
Definition Sema.h:11325
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition Sema.h:15479
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:9844
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:15003
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
SemaObjC & ObjC()
Definition Sema.h:1487
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:2822
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:1412
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition SemaDecl.cpp:78
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:899
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition Sema.h:3141
bool captureSwiftVersionIndependentAPINotes()
Whether APINotes should be gathered for all applicable Swift language versions, without being applied...
Definition Sema.h:1638
PragmaStack< bool > StrictGuardStackCheckStack
Definition Sema.h:2042
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void PrintInstantiationStack()
Definition Sema.h:13630
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:3550
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:754
bool isImmediateFunctionContext() const
Definition Sema.h:8165
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:926
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Definition Sema.h:1060
void addExternalSource(IntrusiveRefCntPtr< ExternalSemaSource > E)
Registers an external source.
Definition Sema.cpp:655
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition SemaExpr.cpp:764
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:6512
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:1405
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:6596
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:2038
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:756
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
Definition SemaAttr.cpp:334
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:883
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:698
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition Sema.h:2586
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:6539
@ FRS_Success
Definition Sema.h:10758
@ FRS_DiagnosticIssued
Definition Sema.h:10760
@ FRS_NoViableFunction
Definition Sema.h:10759
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:14081
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:968
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition Sema.h:9306
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:9256
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:6064
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
Definition Sema.h:6078
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
Definition Sema.h:6075
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
Definition Sema.h:6072
@ None
This is not a defaultable comparison operator.
Definition Sema.h:6066
@ Equal
This is an operator== that should be implemented as a series of subobject comparisons.
Definition Sema.h:6069
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:8995
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:15586
@ Conversions
Allow explicit conversion functions but not explicit constructors.
Definition Sema.h:10091
@ All
Allow both explicit conversion functions and explicit constructors.
Definition Sema.h:10093
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:1214
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition Sema.h:6527
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:1192
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:14804
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:636
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
Definition Sema.h:3573
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:1659
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:2583
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition Sema.h:3465
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:2503
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:12122
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition Sema.h:12140
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition Sema.h:12130
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition Sema.h:12150
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:4871
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:1673
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:8346
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
Definition SemaAttr.cpp:389
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:11394
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
Definition Sema.h:11401
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
Definition Sema.h:11398
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:795
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:2693
void PushFunctionScope()
Enter a new function scope.
Definition Sema.cpp:2331
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:426
SourceRange getExprRange(Expr *E) const
Definition SemaExpr.cpp:506
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:11330
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
Definition SemaAttr.cpp:168
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:3546
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition Sema.h:8200
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:15010
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition Sema.h:4569
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:1558
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:921
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition Sema.h:8298
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
Definition Sema.cpp:272
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:83
sema::LambdaScopeInfo * PushLambdaScope()
Definition Sema.cpp:2349
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:2482
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15420
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:14335
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition Sema.h:14355
@ UPPC_RequiresClause
Definition Sema.h:14406
@ UPPC_UsingDeclaration
A using declaration.
Definition Sema.h:14361
@ UPPC_IfExists
Microsoft __if_exists.
Definition Sema.h:14388
@ UPPC_Requirement
Definition Sema.h:14403
@ UPPC_ExceptionType
The type of an exception.
Definition Sema.h:14379
@ UPPC_EnumeratorValue
The enumerator value.
Definition Sema.h:14358
@ UPPC_Lambda
Lambda expression.
Definition Sema.h:14394
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition Sema.h:14391
@ UPPC_PartialSpecialization
Partial specialization.
Definition Sema.h:14385
@ UPPC_Initializer
An initializer.
Definition Sema.h:14370
@ UPPC_BaseType
The base type of a class type.
Definition Sema.h:14340
@ UPPC_FriendDeclaration
A friend declaration.
Definition Sema.h:14364
@ UPPC_DefaultArgument
A default argument.
Definition Sema.h:14373
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition Sema.h:14343
@ UPPC_Expression
An arbitrary expression.
Definition Sema.h:14337
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition Sema.h:14382
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition Sema.h:14367
@ UPPC_DataMemberType
The type of a data member.
Definition Sema.h:14346
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition Sema.h:14352
@ UPPC_Block
Block expression.
Definition Sema.h:14397
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition Sema.h:14349
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition Sema.h:14376
@ UPPC_TypeConstraint
A type constraint.
Definition Sema.h:14400
api_notes::APINotesManager APINotes
Definition Sema.h:1288
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:12497
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:919
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:13038
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:5843
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
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:2078
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:724
SemaCodeCompletion & CodeCompletion()
Definition Sema.h:1437
void inferLifetimeBoundAttribute(FunctionDecl *FD)
Add [[clang:lifetimebound]] attr for std:: functions and methods.
Definition SemaAttr.cpp:220
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition Sema.h:3567
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:1492
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition Sema.h:14799
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:7005
@ ReuseLambdaContextDecl
Definition Sema.h:7005
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:927
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:1432
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:1326
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:1283
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:2125
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
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:1321
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition Sema.h:2103
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:2121
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:3554
SemaDirectX & DirectX()
Definition Sema.h:1447
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition Sema.h:6488
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:1477
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:1559
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:1282
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:1220
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition Sema.cpp:2558
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:1215
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition Sema.h:8998
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:952
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition SemaStmt.cpp:416
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition Sema.h:15433
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:6490
SemaHLSL & HLSL()
Definition Sema.h:1452
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:11343
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition Sema.h:1218
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition Sema.h:9305
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:1171
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:6923
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:1815
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
static StringRef GetFormatStringTypeName(FormatStringType FST)
SemaMIPS & MIPS()
Definition Sema.h:1472
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition Sema.cpp:139
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:1517
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:15609
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition Sema.h:1804
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:5849
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:213
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:5223
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
Definition Sema.h:5226
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
Definition Sema.h:5230
MemberPointerConversionDirection
Definition Sema.h:10211
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition Sema.h:13955
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition Sema.h:6483
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
Definition SemaExpr.cpp:75
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:2759
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:15005
SemaSwift & Swift()
Definition Sema.h:1532
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:2027
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:6588
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition Sema.h:6950
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition Sema.h:13588
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition Sema.h:6520
StmtResult ActOnExprStmtError()
Definition SemaStmt.cpp:65
PragmaStack< StringLiteral * > BSSSegStack
Definition Sema.h:2037
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:1125
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition Sema.h:1335
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:2081
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:1666
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:897
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:1279
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:11748
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
Definition Sema.h:13959
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:2128
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:849
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:4746
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:10398
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition Sema.h:14999
ProcessingContextState ParsingClassState
Definition Sema.h:6538
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:1315
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:2477
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:2911
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:3819
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition Sema.h:2666
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:15342
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
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:6947
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...
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
StmtResult ActOnEndOfDeferStmt(Stmt *Body, Scope *CurScope)
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:2295
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
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:11743
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:13036
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:4831
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:5839
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:639
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:15427
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition Sema.h:8169
StringLiteral * CurInitSeg
Last section used with pragma init_seg.
Definition Sema.h:2077
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition Sema.h:9839
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:2521
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:8036
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:2513
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:6962
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:6497
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:1415
auto getDefaultDiagFunc()
Definition Sema.h:2284
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.
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:314
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:12498
ClassTemplateDecl * StdTypeIdentity
The C++ "std::type_identity" template, which is defined in <type_traits>.
Definition Sema.h:6516
SemaOpenCL & OpenCL()
Definition Sema.h:1497
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:13968
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:616
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition Sema.h:2208
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:890
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:15015
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:2596
@ FAPK_Elsewhere
Definition Sema.h:2600
@ FAPK_Fixed
Definition Sema.h:2597
@ FAPK_Variadic
Definition Sema.h:2598
@ FAPK_VAList
Definition Sema.h:2599
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:8161
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition Sema.h:13027
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition Sema.cpp:1634
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:15440
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:14779
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:8357
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:3564
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition Sema.h:6749
bool MSStructPragmaOn
Definition Sema.h:1801
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:13572
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:13903
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition Sema.h:15415
SourceManager & getSourceManager() const
Definition Sema.h:924
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:8428
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:4809
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:630
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:3517
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:946
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:696
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:12222
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:2296
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:9299
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:550
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:13908
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:5959
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:1816
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:7457
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:4070
@ NTCUK_Destruct
Definition Sema.h:4072
@ NTCUK_Init
Definition Sema.h:4071
@ NTCUK_Copy
Definition Sema.h:4073
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:1352
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:8314
PragmaClangSection PragmaClangDataSection
Definition Sema.h:1813
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:9094
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:2343
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:2026
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:6747
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition Sema.h:929
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:1228
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition Sema.h:2084
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool isSFINAEContext() const
Definition Sema.h:13638
FunctionDecl * BuildTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl, QualType AllocType, SourceLocation)
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition Sema.h:8779
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope, bool IsInstantiation=false)
ActOnLambdaError - If there is an error parsing a lambda, this callback is invoked to pop the informa...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
Definition SemaExpr.cpp:224
static SourceRange getPrintable(SourceRange R)
Definition Sema.h:15012
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:13596
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:14764
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:15382
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition Sema.h:1131
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:2873
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void emitDeferredDiags()
Definition Sema.cpp:2014
void setFunctionHasMustTail()
Definition Sema.cpp:2508
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:8353
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:14770
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:2498
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition Sema.h:15471
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:2588
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition Sema.h:6508
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:626
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:1165
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:1556
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:11206
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.
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition Sema.h:3538
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:273
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:1553
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:1285
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:4632
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
PragmaAlignPackDiagnoseKind
Definition Sema.h:2186
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:6954
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition SemaExpr.cpp:123
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition Sema.h:1320
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:1780
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition Sema.h:13951
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:9866
@ PrivateFragmentImportFinished
after 'module :private;' but a non-import decl has already been seen.
Definition Sema.h:9873
@ ImportFinished
after any non-import decl.
Definition Sema.h:9870
@ PrivateFragmentImportAllowed
after 'module :private;' but before any non-import decl.
Definition Sema.h:9871
@ FirstDecl
Parsing the first decl in a TU.
Definition Sema.h:9867
@ GlobalFragment
after 'module;' but before 'module X;'
Definition Sema.h:9868
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
Definition Sema.h:9875
@ ImportAllowed
after 'module X;' but before any non-import decl.
Definition Sema.h:9869
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:15011
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
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:109
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition Sema.h:1249
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)
ModularFormatAttr * mergeModularFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *ModularImplFn, StringRef ImplName, MutableArrayRef< StringRef > Aspects)
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:6691
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
Definition Sema.h:6713
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
Definition Sema.h:6703
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
Definition Sema.h:6718
@ DiscardedStatement
The current expression occurs within a discarded statement.
Definition Sema.h:6708
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6728
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6697
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6723
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
Definition Sema.h:6738
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:13580
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition Sema.h:4794
@ AP_PragmaClangAttribute
The availability attribute was applied using 'pragma clang attribute'.
Definition Sema.h:4800
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition Sema.h:4804
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition Sema.h:4797
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:967
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:13913
SemaPPC & PPC()
Definition Sema.h:1507
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:2356
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:4868
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:1247
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:14772
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:1325
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:8364
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:3557
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:10021
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:8151
SemaSystemZ & SystemZ()
Definition Sema.h:1537
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition Sema.cpp:123
bool isRedefinitionAllowedFor(const NamedDecl *D, bool &Visible)
Definition Sema.h:15461
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:2895
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:8301
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:10203
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:9852
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:1287
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:11371
@ TemplateNameIsRequired
Definition Sema.h:11371
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:783
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:438
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:6501
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:1286
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
void DiagnoseUnterminatedPragmaAlignPack()
Definition SemaAttr.cpp:589
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition Sema.h:7773
OpenCLOptions & getOpenCLOptions()
Definition Sema.h:920
FPOptions CurFPFeatures
Definition Sema.h:1280
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:1328
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition Sema.h:6492
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 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)
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:515
PragmaStack< StringLiteral * > DataSegStack
Definition Sema.h:2036
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:2934
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:11554
@ TPC_TemplateTemplateParameterPack
Definition Sema.h:11564
@ TPC_FriendFunctionTemplate
Definition Sema.h:11562
@ TPC_ClassTemplateMember
Definition Sema.h:11560
@ TPC_FunctionTemplate
Definition Sema.h:11559
@ TPC_FriendClassTemplate
Definition Sema.h:11561
@ TPC_FriendFunctionTemplateDefinition
Definition Sema.h:11563
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:1427
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:1557
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:2112
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:7732
void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init)
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param, SourceLocation Location)
Get a template argument mapping the given template parameter to itself, e.g.
bool CheckIfFunctionSpecializationIsImmediate(FunctionDecl *FD, SourceLocation Loc)
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:6524
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition Sema.h:13552
void PrintStats() const
Print out statistics about the semantic analysis.
Definition Sema.cpp:670
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:15002
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:1799
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:1233
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:88
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:11029
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition Sema.h:11037
@ BFRK_Build
Initial building of a for-range statement.
Definition Sema.h:11031
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition Sema.h:11034
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
SemaNVPTX & NVPTX()
Definition Sema.h:1482
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:874
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:2056
@ PSK_ConstSeg
Definition Sema.h:2059
@ PSK_DataSeg
Definition Sema.h:2057
@ PSK_CodeSeg
Definition Sema.h:2060
@ PSK_BSSSeg
Definition Sema.h:2058
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:625
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:337
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.
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation TriviallyRelocatable, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition Sema.h:6268
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,...
bool SubstTemplateArgumentsInParameterMapping(ArrayRef< TemplateArgumentLoc > Args, SourceLocation BaseLoc, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Out, bool BuildPackExpansionTypes)
FormatMatchesAttr * mergeFormatMatchesAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, StringLiteral *FormatStr)
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, IdentifierInfo *IIEnvironment)
void BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs, LateInstantiatedAttrVec *LateAttrs, DeclContext *Owner, LocalInstantiationScope *StartingScope, bool InstantiatingVarTemplate=false, VarTemplateSpecializationDecl *PrevVTSD=nullptr)
BuildVariableInstantiation - Used after a new variable has been created.
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
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:3532
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition Sema.cpp:2104
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)
PragmaClangSection PragmaClangBSSSection
Definition Sema.h:1812
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:1339
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel)
AbstractDiagSelID
Definition Sema.h:6214
@ AbstractSynthesizedIvarType
Definition Sema.h:6221
@ AbstractVariableType
Definition Sema.h:6218
@ AbstractReturnType
Definition Sema.h:6216
@ AbstractNone
Definition Sema.h:6215
@ AbstractFieldType
Definition Sema.h:6219
@ AbstractArrayType
Definition Sema.h:6222
@ AbstractParamType
Definition Sema.h:6217
@ AbstractIvarType
Definition Sema.h:6220
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 BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
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:1522
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:8350
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:7959
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
Create an CUDALaunchBoundsAttr attribute.
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
Definition Sema.h:9362
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition Sema.h:9366
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition Sema.h:9372
@ LOLR_Error
The lookup resulted in an error.
Definition Sema.h:9364
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition Sema.h:9369
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition Sema.h:9380
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition Sema.h:9376
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:2528
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition Sema.h:6935
SemaLoongArch & LoongArch()
Definition Sema.h:1462
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:6403
@ CheckValid
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
Definition Sema.h:6408
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
Definition Sema.h:6405
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:13947
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:2887
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1276
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:708
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:3513
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:1679
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:15307
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:7810
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:1542
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)
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:3461
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:13548
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:1512
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:2489
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition SemaStmt.cpp:588
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition Sema.h:11336
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:7766
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:717
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:146
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:8309
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition Sema.h:1275
static int getPrintable(int I)
Definition Sema.h:15001
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:885
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
Definition Sema.h:9632
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition Sema.h:12867
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:3805
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:15006
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:8177
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:13563
SemaARM & ARM()
Definition Sema.h:1422
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:13544
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
Definition SemaAttr.cpp:322
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:15004
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:10939
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:651
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
PragmaMsStackAction
Definition Sema.h:1818
@ PSK_Push_Set
Definition Sema.h:1824
@ PSK_Reset
Definition Sema.h:1819
@ PSK_Pop_Set
Definition Sema.h:1825
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:8641
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:13635
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:85
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:338
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3717
Exposes information about the current target.
Definition TargetInfo.h:226
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:4631
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:3513
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:8264
The base class of the type hierarchy.
Definition TypeBase.h:1833
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3667
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3562
Simple class containing the result of Sema::CorrectTypo.
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:998
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:3587
Represents C++ using-directive.
Definition DeclCXX.h:3092
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3395
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:926
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:4176
Represents a C++11 virt-specifier-seq.
Definition DeclSpec.h:2754
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:790
Retains information about a captured region.
Definition ScopeInfo.h:816
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 bool
Definition gpuintrin.h:32
#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:841
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
void threadSafetyCleanup(BeforeSet *Cache)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition TokenKinds.h:25
The JSON file list parser is used to communicate input to InstallAPI.
PragmaClangSectionAction
Definition Sema.h:475
TypeSpecifierType
Specifies the kind of type.
Definition Specifiers.h:55
ImplicitTypenameContext
Definition DeclSpec.h:1857
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
OverloadKind
Definition Sema.h:810
@ NonFunction
This is not an overload because the lookup results contain a non-function.
Definition Sema.h:821
@ Match
This is not an overload because the signature exactly matches an existing declaration.
Definition Sema.h:817
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition Sema.h:813
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:512
FunctionEffectMode
Used with attributes/effects with a boolean condition, e.g. nonblocking.
Definition Sema.h:458
CUDAFunctionTarget
Definition Cuda.h:61
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:778
@ Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition Sema.h:786
PragmaMSCommentKind
Definition PragmaKinds.h:14
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition Specifiers.h:35
ArrayRef< IdentifierLoc > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
TryCaptureKind
Definition Sema.h:652
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition Specifiers.h:39
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition Sema.h:660
@ BitwiseOp
A bitwise operation.
Definition Sema.h:664
@ Arithmetic
An arithmetic operation.
Definition Sema.h:662
@ Conditional
A conditional (?:) operator.
Definition Sema.h:668
@ CompAssign
A compound assignment expression.
Definition Sema.h:670
@ Comparison
A comparison.
Definition Sema.h:666
NullabilityKind
Describes the nullability of a particular type.
Definition Specifiers.h:348
InClassInitStyle
In-class initialization styles for non-static data members.
Definition Specifiers.h:271
@ Success
Annotation was successful.
Definition Parser.h:65
CXXConstructionKind
Definition ExprCXX.h:1540
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition Specifiers.h:149
PointerAuthDiscArgKind
Definition Sema.h:593
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h:603
@ TemplateTemplateArgument
Definition Sema.h:612
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
Definition Overload.h:84
NonTrivialCUnionContext
Definition Sema.h:531
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition Sema.h:627
@ Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition Sema.h:635
@ OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition Sema.h:641
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition Sema.h:632
@ ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition Sema.h:638
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:237
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
void inferNoReturnAttr(Sema &S, const Decl *D)
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:918
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
Definition CallGraph.h:204
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition Specifiers.h:123
@ AS_none
Definition Specifiers.h:127
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:248
Expr * Cond
};
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition Overload.h:928
@ 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:2798
@ CopyInit
[a = b], [a = {b}]
Definition DeclSpec.h:2800
@ 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:477
@ Result
The result type of a method or function.
Definition TypeBase.h:905
ActionResult< ParsedType > TypeResult
Definition Ownership.h:251
OffsetOfKind
Definition Sema.h:615
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3720
CorrectTypoKind
Definition Sema.h:805
ActionResult< CXXCtorInitializer * > MemInitResult
Definition Ownership.h:253
const FunctionProtoType * T
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:688
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition Sema.h:711
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition Sema.h:774
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition Sema.h:703
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition Sema.h:753
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition Sema.h:743
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition Sema.h:770
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition Sema.h:757
@ CompatibleVoidPtrToNonVoidPtr
CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because a void * can implicitly convert...
Definition Sema.h:695
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition Sema.h:737
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition Sema.h:732
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition Sema.h:766
@ Compatible
Compatible - the types are compatible according to the standard.
Definition Sema.h:690
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition Sema.h:722
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition Sema.h:699
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition Sema.h:707
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition Sema.h:749
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition Sema.h:716
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition Sema.h:728
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition Sema.h:761
TagUseKind
Definition Sema.h:450
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:466
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:5893
TUFragmentKind
Definition Sema.h:486
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:554
@ FunctionTemplate
The name was classified as a function template name.
Definition Sema.h:586
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:561
@ DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition Sema.h:575
@ UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition Sema.h:588
@ NonType
The name was classified as a specific non-type, non-template declaration.
Definition Sema.h:567
@ Unknown
This name is not a type or template in this context, but might be something else.
Definition Sema.h:557
@ Error
Classification failed; an error has been produced.
Definition Sema.h:559
@ Type
The name was classified as a type.
Definition Sema.h:563
@ TypeTemplate
The name was classified as a template whose specializations are types.
Definition Sema.h:582
@ Concept
The name was classified as a concept name.
Definition Sema.h:590
@ OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition Sema.h:580
@ UndeclaredNonType
The name was classified as an ADL-only function name.
Definition Sema.h:571
@ VarTemplate
The name was classified as a variable template name.
Definition Sema.h:584
LangAS
Defines the address space values used by the address space qualifier of QualType.
FormatStringType
Definition Sema.h:498
CastKind
CastKind - The kind of operation required for a conversion.
AllowFoldKind
Definition Sema.h:654
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:675
PragmaMSStructKind
Definition PragmaKinds.h:23
AssignmentAction
Definition Sema.h:215
CXXSpecialMemberKind
Kinds of C++ special members.
Definition Sema.h:426
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:520
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:132
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:135
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition ASTContext.h:149
TypeAwareAllocationMode
Definition ExprCXX.h:2251
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition Sema.h:790
@ Exists
The symbol exists.
Definition Sema.h:792
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:795
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition Specifiers.h:410
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:302
TrivialABIHandling
Definition Sema.h:644
@ ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition Sema.h:649
@ IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition Sema.h:646
TemplateDeductionResult
Describes the result of template argument deduction.
Definition Sema.h:368
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
Definition Sema.h:418
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
Definition Sema.h:413
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
Definition Sema.h:416
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
Definition Sema.h:389
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
Definition Sema.h:375
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
Definition Sema.h:411
@ CUDATargetMismatch
CUDA Target attributes do not match.
Definition Sema.h:420
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
Definition Sema.h:408
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
Definition Sema.h:378
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
Definition Sema.h:392
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
Definition Sema.h:381
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Definition Sema.h:395
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
Definition Sema.h:384
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
Definition Sema.h:405
@ AlreadyDiagnosed
Some error which was already diagnosed.
Definition Sema.h:422
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
Definition Sema.h:399
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
Definition Sema.h:402
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition Specifiers.h:188
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:278
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:1215
@ None
The alignment was not explicit in code.
Definition ASTContext.h:178
CCEKind
Contexts in which a converted constant expression is required.
Definition Sema.h:825
@ CaseValue
Expression in a case label.
Definition Sema.h:826
@ StaticAssertMessageData
Call to data() in a static assert message.
Definition Sema.h:836
@ Enumerator
Enumerator value with fixed underlying type.
Definition Sema.h:827
@ StaticAssertMessageSize
Call to size() in a static assert message.
Definition Sema.h:834
@ Noexcept
Condition in a noexcept(bool) specifier.
Definition Sema.h:833
@ ArrayBound
Array bound in array declarator or new-expression.
Definition Sema.h:831
@ TempArgStrict
As above, but applies strict template checking rules.
Definition Sema.h:829
@ ExplicitBool
Condition in an explicit(bool) specifier.
Definition Sema.h:832
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:4938
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5868
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5879
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5882
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5886
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:2245
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:1989
CheckedConversionKind
The kind of conversion being performed.
Definition Sema.h:437
@ Implicit
An implicit conversion.
Definition Sema.h:439
@ CStyleCast
A C-style cast.
Definition Sema.h:441
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
Definition Sema.h:447
@ OtherCast
A cast other than a C-style cast.
Definition Sema.h:445
@ FunctionalCast
A functional-style cast.
Definition Sema.h:443
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition Specifiers.h:173
unsigned int uint32_t
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
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:241
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition Sema.h:248
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition Sema.h:244
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition Sema.h:254
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition Sema.h:251
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h:5006
Holds information about the various types of exception specification.
Definition TypeBase.h:5326
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5328
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5331
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5334
Extra information about a function prototype.
Definition TypeBase.h:5354
Represents a complete lambda introducer.
Definition DeclSpec.h:2806
Contains a late templated function.
Definition Sema.h:15632
FPOptions FPO
Floating-point options in the point of definition.
Definition Sema.h:15637
Decl * D
The template function declaration to be late parsed.
Definition Sema.h:15635
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:932
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation CurrentPragmaLocation
Definition Sema.h:2031
bool SuppressUserConversions
Do not consider any user-defined conversions when constructing the initializing sequence.
Definition Sema.h:10490
bool OnlyInitializeNonUserDefinedConversions
Before constructing the initializing sequence, we check whether the parameter type and argument type ...
Definition Sema.h:10497
CheckNonDependentConversionsFlag(bool SuppressUserConversions, bool OnlyInitializeNonUserDefinedConversions)
Definition Sema.h:10499
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
Definition Sema.h:11980
bool MatchingTTP
If true, assume these template arguments are the injected template arguments for a template template ...
Definition Sema.h:11976
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &)=delete
CheckTemplateArgumentInfo(bool PartialOrdering=false, bool MatchingTTP=false)
Definition Sema.h:11957
bool PartialOrdering
The check is being performed in the context of partial ordering.
Definition Sema.h:11969
SmallVector< TemplateArgument, 4 > SugaredConverted
The checked, converted argument will be added to the end of these vectors.
Definition Sema.h:11966
SmallVector< TemplateArgument, 4 > CanonicalConverted
Definition Sema.h:11966
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:13072
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition Sema.h:13235
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool InParameterMappingSubstitution
Whether we're substituting into the parameter mapping of a constraint.
Definition Sema.h:13192
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition Sema.h:13208
ArrayRef< TemplateArgument > template_arguments() const
Definition Sema.h:13227
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition Sema.h:13203
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition Sema.h:13195
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition Sema.h:13221
bool InConstraintSubstitution
Whether we're substituting into constraints.
Definition Sema.h:13189
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition Sema.h:13211
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition Sema.h:13218
SynthesisKind
The kind of template instantiation we are performing.
Definition Sema.h:13074
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition Sema.h:13166
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition Sema.h:13084
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition Sema.h:13093
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition Sema.h:13112
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition Sema.h:13163
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition Sema.h:13120
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition Sema.h:13127
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition Sema.h:13170
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition Sema.h:13138
@ Memoization
Added for Template instantiation observation.
Definition Sema.h:13176
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13103
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition Sema.h:13182
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition Sema.h:13179
@ PartialOrderingTTP
We are performing partial ordering for template template parameters.
Definition Sema.h:13185
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition Sema.h:13100
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition Sema.h:13108
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition Sema.h:13116
@ TemplateInstantiation
We are instantiating a template declaration.
Definition Sema.h:13077
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition Sema.h:13130
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition Sema.h:13134
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition Sema.h:13089
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition Sema.h:13160
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition Sema.h:13123
Decl * Entity
The entity that is being synthesized.
Definition Sema.h:13198
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition Sema.h:13224
bool isInstantiationRecord() const
Determines whether this template is an actual instantiation that should be counted toward the maximum...
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition Sema.h:6852
Data structure used to record current or nested expression evaluation contexts.
Definition Sema.h:6753
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:6786
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition Sema.h:6788
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition Sema.h:6839
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition Sema.h:6773
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:6782
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition Sema.h:6793
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:6801
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition Sema.h:6797
bool IsCaseExpr
Whether evaluating an expression for a switch case label.
Definition Sema.h:6842
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition Sema.h:6807
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:6768
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition Sema.h:6815
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition Sema.h:6845
SmallVector< MisalignedMember, 4 > MisalignedMembers
Small set of gathered accesses to potentially misaligned members due to the packed attribute.
Definition Sema.h:6811
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition Sema.h:6758
VarDecl * DeclForInitializer
Declaration for initializer if one is currently being parsed.
Definition Sema.h:6778
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition Sema.h:6862
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition Sema.h:6864
ExpressionEvaluationContext Context
The expression evaluation context.
Definition Sema.h:6755
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition Sema.h:6762
FormatArgumentPassingKind ArgPassingKind
Definition Sema.h:2608
FunctionEffectDiffVector(const FunctionEffectsRef &Old, const FunctionEffectsRef &New)
Caller should short-circuit by checking for equality first.
std::optional< FunctionEffectWithCondition > Old
Definition Sema.h:15539
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:15543
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:15551
std::optional< FunctionEffectWithCondition > New
Definition Sema.h:15541
FunctionEffect::Kind EffectKind
Definition Sema.h:15536
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition Sema.h:13411
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:14074
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition Sema.h:14077
bool isMoveEligible() const
Definition Sema.h:11097
bool isCopyElidable() const
Definition Sema.h:11098
const VarDecl * Candidate
Definition Sema.h:11092
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition Sema.h:3274
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition Sema.h:3283
SourceLocation IdentifierLoc
The location of the identifier.
Definition Sema.h:3277
SourceLocation CCLoc
The location of the '::'.
Definition Sema.h:3280
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition Sema.h:3271
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition Sema.h:3289
SourceLocation LocStart
Definition Sema.h:7544
IdentifierInfo * IdentInfo
Definition Sema.h:7547
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition Sema.h:12599
This an attribute introduced by #pragma clang attribute.
Definition Sema.h:2087
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition Sema.h:2090
A push'd group of PragmaAttributeEntries.
Definition Sema.h:2095
SourceLocation Loc
The location of the push attribute.
Definition Sema.h:2097
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition Sema.h:2100
const IdentifierInfo * Namespace
The namespace of this push group.
Definition Sema.h:2099
SourceLocation PragmaLocation
Definition Sema.h:1809
PragmaMsStackAction Action
Definition Sema.h:1829
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition Sema.h:1942
llvm::StringRef StackSlotLabel
Definition Sema.h:1938
SourceLocation PragmaLocation
Definition Sema.h:1940
SourceLocation PragmaPushLocation
Definition Sema.h:1941
ValueType CurrentValue
Definition Sema.h:2012
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition Sema.h:1998
bool hasValue() const
Definition Sema.h:2008
SmallVector< Slot, 2 > Stack
Definition Sema.h:2010
ValueType DefaultValue
Definition Sema.h:2011
SourceLocation CurrentPragmaLocation
Definition Sema.h:2013
PragmaStack(const ValueType &Default)
Definition Sema.h:2005
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition Sema.h:1949
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition Sema.h:5064
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition Sema.h:5058
RecursiveInstGuard(Sema &S, Decl *D, Kind Kind)
Definition Sema.h:13047
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition Sema.h:10387
SFINAEContextBase(Sema &S, SFINAETrap *Cur)
Definition Sema.h:12412
Abstract class used to diagnose incomplete types.
Definition Sema.h:8242
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition Sema.h:2650
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition Sema.h:2659
bool CheckSameAsPrevious
Definition Sema.h:354
NamedDecl * Previous
Definition Sema.h:355
SkipBodyInfo()=default
NamedDecl * New
Definition Sema.h:356
Information about a template-id annotation token.