clang 24.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"
41#include "clang/Basic/Cuda.h"
44#include "clang/Basic/LLVM.h"
45#include "clang/Basic/Lambda.h"
47#include "clang/Basic/Module.h"
59#include "clang/Sema/Attr.h"
61#include "clang/Sema/DeclSpec.h"
67#include "clang/Sema/Scope.h"
68#include "clang/Sema/SemaBase.h"
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;
145enum class LangAS : unsigned int;
147class LookupResult;
150class ModuleLoader;
154class ObjCMethodDecl;
155struct OverloadCandidate;
156enum class OverloadCandidateParamOrder : char;
159class Preprocessor;
161struct ResolvedAllocation;
162class SemaAMDGPU;
163class SemaARM;
164class SemaAVR;
165class SemaBPF;
167class SemaCUDA;
168class SemaDirectX;
169class SemaHLSL;
170class SemaHexagon;
171class SemaLoongArch;
172class SemaM68k;
173class SemaMIPS;
174class SemaMSP430;
175class SemaNVPTX;
176class SemaObjC;
177class SemaOpenACC;
178class SemaOpenCL;
179class SemaOpenMP;
180class SemaPPC;
181class SemaPseudoObject;
182class SemaRISCV;
183class SemaSPIRV;
184class SemaSYCL;
185class SemaSwift;
186class SemaSystemZ;
187class SemaWasm;
188class SemaX86;
190class TemplateArgument;
194class Token;
195class TypeConstraint;
200
201namespace sema {
202class BlockScopeInfo;
203class Capture;
210class LambdaScopeInfo;
211class SemaPPCallbacks;
213} // namespace sema
214
215// AssignmentAction - This is used by all the assignment diagnostic functions
216// to represent what is actually causing the operation
227
228// Inline capacity for type-aware, aligned, and unaligned allocation argument
229// list candidates.
231
232namespace threadSafety {
233class BeforeSet;
234void threadSafetyCleanup(BeforeSet *Cache);
235} // namespace threadSafety
236
237// FIXME: No way to easily map from TemplateTypeParmTypes to
238// TemplateTypeParmDecls, so we have this horrible PointerUnion.
239typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *,
240 const TemplateSpecializationType *,
241 const SubstBuiltinTemplatePackType *>,
242 SourceLocation>
244
245/// Describes whether we've seen any nullability information for the given
246/// file.
248 /// The first pointer declarator (of any pointer kind) in the file that does
249 /// not have a corresponding nullability annotation.
251
252 /// The end location for the first pointer declarator in the file. Used for
253 /// placing fix-its.
255
256 /// Which kind of pointer declarator we saw.
258
259 /// Whether we saw any type nullability annotations in the given file.
260 bool SawTypeNullability = false;
261};
262
263/// A mapping from file IDs to a record of whether we've seen nullability
264/// information in that file.
266 /// A mapping from file IDs to the nullability information for each file ID.
267 llvm::DenseMap<FileID, FileNullability> Map;
268
269 /// A single-element cache based on the file ID.
270 struct {
273 } Cache;
274
275public:
277 // Check the single-element cache.
278 if (file == Cache.File)
279 return Cache.Nullability;
280
281 // It's not in the single-element cache; flush the cache if we have one.
282 if (!Cache.File.isInvalid()) {
283 Map[Cache.File] = Cache.Nullability;
284 }
285
286 // Pull this entry into the cache.
287 Cache.File = file;
288 Cache.Nullability = Map[file];
289 return Cache.Nullability;
290 }
291};
292
293/// Tracks expected type during expression parsing, for use in code completion.
294/// The type is tied to a particular token, all functions that update or consume
295/// the type take a start location of the token they are looking at as a
296/// parameter. This avoids updating the type on hot paths in the parser.
298public:
300 : Ctx(Ctx), Enabled(Enabled) {}
301
305 /// Handles e.g. BaseType{ .D = Tok...
307 const Designation &D);
308 /// Computing a type for the function argument may require running
309 /// overloading, so we postpone its computation until it is actually needed.
310 ///
311 /// Clients should be very careful when using this function, as it stores a
312 /// function_ref, clients should make sure all calls to get() with the same
313 /// location happen while function_ref is alive.
314 ///
315 /// The callback should also emit signature help as a side-effect, but only
316 /// if the completion point has been reached.
318 llvm::function_ref<QualType()> ComputeType);
319
322 SourceLocation OpLoc);
325 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
326 /// Handles all type casts, including C-style cast, C++ casts, etc.
328
329 /// Get the expected type associated with this location, if any.
330 ///
331 /// If the location is a function argument, determining the expected type
332 /// involves considering all function overloads and the arguments so far.
333 /// In this case, signature help for these function overloads will be reported
334 /// as a side-effect (only if the completion point has been reached).
336 if (!Enabled || Tok != ExpectedLoc)
337 return QualType();
338 if (!Type.isNull())
339 return Type;
340 if (ComputeType)
341 return ComputeType();
342 return QualType();
343 }
344
345private:
346 ASTContext *Ctx;
347 bool Enabled;
348 /// Start position of a token for which we store expected type.
349 SourceLocation ExpectedLoc;
350 /// Expected type for a token starting at ExpectedLoc.
352 /// A function to compute expected type at ExpectedLoc. It is only considered
353 /// if Type is null.
354 llvm::function_ref<QualType()> ComputeType;
355};
356
358 SkipBodyInfo() = default;
359 bool ShouldSkip = false;
361 NamedDecl *Previous = nullptr;
362 NamedDecl *New = nullptr;
363};
364
365/// Describes the result of template argument deduction.
366///
367/// The TemplateDeductionResult enumeration describes the result of
368/// template argument deduction, as returned from
369/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
370/// structure provides additional information about the results of
371/// template argument deduction, e.g., the deduced template argument
372/// list (if successful) or the specific template parameters or
373/// deduced arguments that were involved in the failure.
375 /// Template argument deduction was successful.
377 /// The declaration was invalid; do nothing.
379 /// Template argument deduction exceeded the maximum template
380 /// instantiation depth (which has already been diagnosed).
382 /// Template argument deduction did not deduce a value
383 /// for every template parameter.
385 /// Template argument deduction did not deduce a value for every
386 /// expansion of an expanded template parameter pack.
388 /// Template argument deduction produced inconsistent
389 /// deduced values for the given template parameter.
391 /// Template argument deduction failed due to inconsistent
392 /// cv-qualifiers on a template parameter type that would
393 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
394 /// but were given a non-const "X".
396 /// Substitution of the deduced template argument values
397 /// resulted in an error.
399 /// After substituting deduced template arguments, a dependent
400 /// parameter type did not match the corresponding argument.
402 /// After substituting deduced template arguments, an element of
403 /// a dependent parameter type did not match the corresponding element
404 /// of the corresponding argument (when deducing from an initializer list).
406 /// A non-depnedent component of the parameter did not match the
407 /// corresponding component of the argument.
409 /// When performing template argument deduction for a function
410 /// template, there were too many call arguments.
412 /// When performing template argument deduction for a function
413 /// template, there were too few call arguments.
415 /// The explicitly-specified template arguments were not valid
416 /// template arguments for the given template.
418 /// Checking non-dependent argument conversions failed.
420 /// The deduced arguments did not satisfy the constraints associated
421 /// with the template.
423 /// Deduction failed; that's all we know.
425 /// CUDA Target attributes do not match.
427 /// Some error which was already diagnosed.
429};
430
431/// The kind of conversion being performed.
433 /// An implicit conversion.
435 /// A C-style cast.
437 /// A functional-style cast.
439 /// A cast other than a C-style cast.
441 /// A conversion for an operand of a builtin overloaded operator.
443};
444
445enum class TagUseKind {
446 Reference, // Reference to a tag: 'struct foo *X;'
447 Declaration, // Fwd decl of a tag: 'struct foo;'
448 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
449 Friend // Friend declaration: 'friend struct foo;'
450};
451
452/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
454 None, // effect is not present.
455 False, // effect(false).
456 True, // effect(true).
457 Dependent // effect(expr) where expr is dependent.
458};
459
460/// pragma clang section kind
463 BSS = 1,
464 Data = 2,
466 Text = 4,
468};
469
470enum class PragmaClangSectionAction { Set = 0, Clear = 1 };
471
473 Native, // #pragma options align=native
474 Natural, // #pragma options align=natural
475 Packed, // #pragma options align=packed
476 Power, // #pragma options align=power
477 Mac68k, // #pragma options align=mac68k
478 Reset // #pragma options align=reset
479};
480
481enum class TUFragmentKind {
482 /// The global module fragment, between 'module;' and a module-declaration.
484 /// A normal translation unit fragment. For a non-module unit, this is the
485 /// entire translation unit. Otherwise, it runs from the module-declaration
486 /// to the private-module-fragment (if any) or the end of the TU (if not).
488 /// The private module fragment, between 'module :private;' and the end of
489 /// the translation unit.
491};
492
505
506// Used for emitting the right warning by DefaultVariadicArgumentPromotion
514
523
524// Contexts where using non-trivial C union types can be disallowed. This is
525// passed to err_non_trivial_c_union_in_invalid_context.
527 // Function parameter.
529 // Function return.
531 // Default-initialized object.
533 // Variable with automatic storage duration.
535 // Initializer expression that might copy from another object.
537 // Assignment.
539 // Compound literal.
541 // Block capture.
543 // lvalue-to-rvalue conversion of volatile type.
545};
546
547/// Describes the result of the name lookup and resolution performed
548/// by \c Sema::ClassifyName().
550 /// This name is not a type or template in this context, but might be
551 /// something else.
553 /// Classification failed; an error has been produced.
555 /// The name has been typo-corrected to a keyword.
557 /// The name was classified as a type.
559 /// The name was classified as a specific non-type, non-template
560 /// declaration. ActOnNameClassifiedAsNonType should be called to
561 /// convert the declaration to an expression.
563 /// The name was classified as an ADL-only function name.
564 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
565 /// result to an expression.
567 /// The name denotes a member of a dependent type that could not be
568 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
569 /// convert the result to an expression.
571 /// The name was classified as an overload set, and an expression
572 /// representing that overload set has been formed.
573 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
574 /// expression referencing the overload set.
576 /// The name was classified as a template whose specializations are types.
578 /// The name was classified as a variable template name.
580 /// The name was classified as a function template name.
582 /// The name was classified as an ADL-only function template name.
584 /// The name was classified as a concept name.
586};
587
589 // Address discrimination argument of __ptrauth.
591
592 // Extra discriminator argument of __ptrauth.
594};
595
596/// Common ways to introduce type names without a tag for use in diagnostics.
597/// Keep in sync with err_tag_reference_non_tag.
609
610enum class OffsetOfKind {
611 // Not parsing a type within __builtin_offsetof.
613 // Parsing a type within __builtin_offsetof.
615 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
616 // To improve our diagnostic message.
618};
619
620/// Describes the kind of merge to perform for availability
621/// attributes (including "deprecated", "unavailable", and "availability").
623 /// Don't merge availability attributes at all.
625 /// Merge availability attributes for a redeclaration, which requires
626 /// an exact match.
628 /// Merge availability attributes for an override, which requires
629 /// an exact match or a weakening of constraints.
631 /// Merge availability attributes for an implementation of
632 /// a protocol requirement.
634 /// Merge availability attributes for an implementation of
635 /// an optional protocol requirement.
637};
638
640 /// The triviality of a method unaffected by "trivial_abi".
642
643 /// The triviality of a method affected by "trivial_abi".
645};
646
648
649enum class AllowFoldKind {
652};
653
654/// Context in which we're performing a usual arithmetic conversion.
655enum class ArithConvKind {
656 /// An arithmetic operation.
658 /// A bitwise operation.
660 /// A comparison.
662 /// A conditional (?:) operator.
664 /// A compound assignment expression.
666};
667
668// Used for determining in which context a type is allowed to be passed to a
669// vararg function.
677
678/// AssignConvertType - All of the 'assignment' semantic checks return this
679/// enum to indicate whether the assignment was allowed. These checks are
680/// done for simple assignments, as well as initialization, return from
681/// function, argument passing, etc. The query is phrased in terms of a
682/// source and destination type.
684 /// Compatible - the types are compatible according to the standard.
686
687 /// CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because
688 /// a void * can implicitly convert to another pointer type, which we
689 /// differentiate for better diagnostic behavior.
691
692 /// PointerToInt - The assignment converts a pointer to an int, which we
693 /// accept as an extension.
695
696 /// IntToPointer - The assignment converts an int to a pointer, which we
697 /// accept as an extension.
699
700 /// FunctionVoidPointer - The assignment is between a function pointer and
701 /// void*, which the standard doesn't allow, but we accept as an extension.
703
704 /// IncompatiblePointer - The assignment is between two pointers types that
705 /// are not compatible, but we accept them as an extension.
707
708 /// IncompatibleFunctionPointer - The assignment is between two function
709 /// pointers types that are not compatible, but we accept them as an
710 /// extension.
712
713 /// IncompatibleFunctionPointerStrict - The assignment is between two
714 /// function pointer types that are not identical, but are compatible,
715 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
716 /// may trip an indirect call runtime check.
718
719 /// IncompatiblePointerSign - The assignment is between two pointers types
720 /// which point to integers which have a different sign, but are otherwise
721 /// identical. This is a subset of the above, but broken out because it's by
722 /// far the most common case of incompatible pointers.
724
725 /// CompatiblePointerDiscardsQualifiers - The assignment discards
726 /// c/v/r qualifiers, which we accept as an extension.
728
729 /// IncompatiblePointerDiscardsQualifiers - The assignment
730 /// discards qualifiers that we don't permit to be discarded,
731 /// like address spaces.
733
734 /// IncompatiblePointerDiscardsOverflowBehavior - The assignment
735 /// discards overflow behavior annotations between otherwise compatible
736 /// pointer types.
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 /// IncompatibleOBTKinds - Assigning between incompatible OverflowBehaviorType
773 /// kinds, e.g., from __ob_trap to __ob_wrap or vice versa.
775
776 /// CompatibleOBTDiscards - Assignment discards overflow behavior
778
779 /// Incompatible - We reject this conversion outright, it is invalid to
780 /// represent it in the AST.
782};
783
784/// The scope in which to find allocation functions.
786 /// Only look for allocation functions in the global scope.
788 /// Only look for allocation functions in the scope of the
789 /// allocated class.
791 /// Look for allocation functions in both the global scope
792 /// and in the scope of the allocated class.
794};
795
796/// Describes the result of an "if-exists" condition check.
797enum class IfExistsResult {
798 /// The symbol exists.
800
801 /// The symbol does not exist.
803
804 /// The name is a dependent name, so the results will differ
805 /// from one instantiation to the next.
807
808 /// An error occurred.
810};
811
812enum class CorrectTypoKind {
813 NonError, // CorrectTypo used in a non error recovery situation.
814 ErrorRecovery // CorrectTypo used in normal error recovery.
815};
816
817enum class OverloadKind {
818 /// This is a legitimate overload: the existing declarations are
819 /// functions or function templates with different signatures.
821
822 /// This is not an overload because the signature exactly matches
823 /// an existing declaration.
825
826 /// This is not an overload because the lookup results contain a
827 /// non-function.
829};
830
831/// Contexts in which a converted constant expression is required.
832enum class CCEKind {
833 CaseValue, ///< Expression in a case label.
834 Enumerator, ///< Enumerator value with fixed underlying type.
835 TemplateArg, ///< Value of a non-type template parameter.
836 TempArgStrict, ///< As above, but applies strict template checking
837 ///< rules.
838 ArrayBound, ///< Array bound in array declarator or new-expression.
839 ExplicitBool, ///< Condition in an explicit(bool) specifier.
840 Noexcept, ///< Condition in a noexcept(bool) specifier.
841 StaticAssertMessageSize, ///< Call to size() in a static assert
842 ///< message.
843 StaticAssertMessageData, ///< Call to data() in a static assert
844 ///< message.
845 PackIndex ///< Index of a pack indexing expression or specifier.
846};
847
848/// Enums for the diagnostics of target, target_version and target_clones.
849namespace DiagAttrParams {
853} // end namespace DiagAttrParams
854
855void inferNoReturnAttr(Sema &S, Decl *D);
856
857#ifdef __GNUC__
858#pragma GCC diagnostic push
859#pragma GCC diagnostic ignored "-Wattributes"
860#endif
861/// Sema - This implements semantic analysis and AST building for C.
862/// \nosubgrouping
863class Sema final : public SemaBase {
864#ifdef __GNUC__
865#pragma GCC diagnostic pop
866#endif
867 // Table of Contents
868 // -----------------
869 // 1. Semantic Analysis (Sema.cpp)
870 // 2. API Notes (SemaAPINotes.cpp)
871 // 3. C++ Access Control (SemaAccess.cpp)
872 // 4. Attributes (SemaAttr.cpp)
873 // 5. Availability Attribute Handling (SemaAvailability.cpp)
874 // 6. Bounds Safety (SemaBoundsSafety.cpp)
875 // 7. Casts (SemaCast.cpp)
876 // 8. Extra Semantic Checking (SemaChecking.cpp)
877 // 9. C++ Coroutines (SemaCoroutine.cpp)
878 // 10. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
879 // 11. Declarations (SemaDecl.cpp)
880 // 12. Declaration Attribute Handling (SemaDeclAttr.cpp)
881 // 13. C++ Declarations (SemaDeclCXX.cpp)
882 // 14. C++ Exception Specifications (SemaExceptionSpec.cpp)
883 // 15. Expressions (SemaExpr.cpp)
884 // 16. C++ Expressions (SemaExprCXX.cpp)
885 // 17. Member Access Expressions (SemaExprMember.cpp)
886 // 18. Initializers (SemaInit.cpp)
887 // 19. C++ Lambda Expressions (SemaLambda.cpp)
888 // 20. Name Lookup (SemaLookup.cpp)
889 // 21. Modules (SemaModule.cpp)
890 // 22. C++ Overloading (SemaOverload.cpp)
891 // 23. Statements (SemaStmt.cpp)
892 // 24. `inline asm` Statement (SemaStmtAsm.cpp)
893 // 25. Statement Attribute Handling (SemaStmtAttr.cpp)
894 // 26. C++ Templates (SemaTemplate.cpp)
895 // 27. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
896 // 28. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
897 // 29. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
898 // 30. C++ Template Declaration Instantiation
899 // (SemaTemplateInstantiateDecl.cpp)
900 // 31. C++ Variadic Templates (SemaTemplateVariadic.cpp)
901 // 32. Constraints and Concepts (SemaConcept.cpp)
902 // 33. Types (SemaType.cpp)
903 // 34. FixIt Helpers (SemaFixItUtils.cpp)
904 // 35. Function Effects (SemaFunctionEffects.cpp)
905 // 36. C++ Expansion Statements (SemaExpand.cpp)
906
907 /// \name Semantic Analysis
908 /// Implementations are in Sema.cpp
909 ///@{
910
911public:
912 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
914 CodeCompleteConsumer *CompletionConsumer = nullptr);
915 ~Sema();
916
917 /// Perform initialization that occurs after the parser has been
918 /// initialized but before it parses anything.
919 void Initialize();
920
921 /// This virtual key function only exists to limit the emission of debug info
922 /// describing the Sema class. GCC and Clang only emit debug info for a class
923 /// with a vtable when the vtable is emitted. Sema is final and not
924 /// polymorphic, but the debug info size savings are so significant that it is
925 /// worth adding a vtable just to take advantage of this optimization.
927
928 const LangOptions &getLangOpts() const { return LangOpts; }
931
934 Preprocessor &getPreprocessor() const { return PP; }
935 ASTContext &getASTContext() const { return Context; }
939
941 StringRef Platform);
943
944 /// Registers an external source. If an external source already exists,
945 /// creates a multiplex external source and appends to it.
946 ///
947 ///\param[in] E - A non-null external sema source.
948 ///
950
951 /// Print out statistics about the semantic analysis.
952 void PrintStats() const;
953
954 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
955 /// guaranteed). Produces a warning if we're low on stack space and allocates
956 /// more in that case. Use this in code that may recurse deeply (for example,
957 /// in template instantiation) to avoid stack overflow.
959 llvm::function_ref<void()> Fn);
960
961 /// Returns default addr space for method qualifiers.
963
964 /// Load weak undeclared identifiers from the external source.
966
967 /// Load #pragma redefine_extname'd undeclared identifiers from the external
968 /// source.
970
971 /// Determine if VD, which must be a variable or function, is an external
972 /// symbol that nonetheless can't be referenced from outside this translation
973 /// unit because its type has no linkage and it's not extern "C".
974 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
975
976 /// Determines whether the given source location is in the main file
977 /// and we're in a context where we should warn about unused entities.
978 bool isMainFileLoc(SourceLocation Loc) const;
979
980 /// Obtain a sorted list of functions that are undefined but ODR-used.
982 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
983
984 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
986 /// Retrieves list of suspicious delete-expressions that will be checked at
987 /// the end of translation unit.
988 const llvm::MapVector<FieldDecl *, DeleteLocs> &
990
991 /// Cause the built diagnostic to be emitted on the DiagosticsEngine.
992 /// This is closely coupled to the SemaDiagnosticBuilder class and
993 /// should not be used elsewhere.
994 void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB);
995
996 void addImplicitTypedef(StringRef Name, QualType T);
997
998 /// Whether uncompilable error has occurred. This includes error happens
999 /// in deferred diagnostics.
1000 bool hasUncompilableErrorOccurred() const;
1001
1002 /// Looks through the macro-expansion chain for the given
1003 /// location, looking for a macro expansion with the given name.
1004 /// If one is found, returns true and sets the location to that
1005 /// expansion loc.
1006 bool findMacroSpelling(SourceLocation &loc, StringRef name);
1007
1008 /// Calls \c Lexer::getLocForEndOfToken()
1009 SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
1010
1011 /// Calls \c Lexer::findNextToken() to find the next token, and if the
1012 /// locations of both ends of the token can be resolved it return that
1013 /// range; Otherwise it returns an invalid SourceRange.
1015 SourceLocation Loc, bool IncludeMacros, bool IncludeComments,
1016 std::optional<tok::TokenKind> ExpectedToken = std::nullopt);
1017
1018 /// Retrieve the module loader associated with the preprocessor.
1020
1021 /// Invent a new identifier for parameters of abbreviated templates.
1024 unsigned Index);
1025
1027
1028 // Emit all deferred diagnostics.
1029 void emitDeferredDiags();
1030
1031 /// This is called before the very first declaration in the translation unit
1032 /// is parsed. Note that the ASTContext may have already injected some
1033 /// declarations.
1035 /// ActOnEndOfTranslationUnit - This is called at the very end of the
1036 /// translation unit when EOF is reached and all but the top-level scope is
1037 /// popped.
1040
1041 /// Determines the active Scope associated with the given declaration
1042 /// context.
1043 ///
1044 /// This routine maps a declaration context to the active Scope object that
1045 /// represents that declaration context in the parser. It is typically used
1046 /// from "scope-less" code (e.g., template instantiation, lazy creation of
1047 /// declarations) that injects a name for name-lookup purposes and, therefore,
1048 /// must update the Scope.
1049 ///
1050 /// \returns The scope corresponding to the given declaraion context, or NULL
1051 /// if no such scope is open.
1053
1054 void PushFunctionScope();
1055 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
1057
1058 /// This is used to inform Sema what the current TemplateParameterDepth
1059 /// is during Parsing. Currently it is used to pass on the depth
1060 /// when parsing generic lambda 'auto' parameters.
1061 void RecordParsingTemplateParameterDepth(unsigned Depth);
1062
1063 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
1065 unsigned OpenMPCaptureLevel = 0);
1066
1067 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
1068 /// time after they've been popped.
1070 Sema *Self;
1071
1072 public:
1073 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
1075 };
1076
1078 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
1079
1080 /// Pop a function (or block or lambda or captured region) scope from the
1081 /// stack.
1082 ///
1083 /// \param WP The warning policy to use for CFG-based warnings, or null if
1084 /// such warnings should not be produced.
1085 /// \param D The declaration corresponding to this function scope, if
1086 /// producing CFG-based warnings.
1087 /// \param BlockType The type of the block expression, if D is a BlockDecl.
1090 Decl *D = nullptr, QualType BlockType = QualType());
1091
1093
1098
1099 void PushCompoundScope(bool IsStmtExpr);
1100 void PopCompoundScope();
1101
1102 /// Determine whether any errors occurred within this function/method/
1103 /// block.
1105
1106 /// Retrieve the current block, if any.
1108
1109 /// Get the innermost lambda or block enclosing the current location, if any.
1110 /// This looks through intervening non-lambda, non-block scopes such as local
1111 /// functions.
1113
1114 /// Retrieve the current lambda scope info, if any.
1115 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
1116 /// lambda scope info ignoring all inner capturing scopes that are not
1117 /// lambda scopes.
1119 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
1120
1121 /// Retrieve the current generic lambda info, if any.
1123
1124 /// Retrieve the current captured region, if any.
1126
1127 void ActOnComment(SourceRange Comment);
1128
1129 /// Returns true if any of the documentation warnings is enabled at \p Loc.
1131
1132 /// Discard the areDocumentationDiagsEnabled() cache, for when a
1133 /// `#pragma clang diagnostic` has changed diagnostic severities.
1135
1136private:
1137 /// The uncached answer for both documentation groups at \p Loc.
1138 bool computeDocumentationDiagsAt(SourceLocation Loc) const;
1139
1140 /// Caches results for areDocumentationDiagsEnabled().
1141 /// Flushed whenever a diagnostic pragma changes severities.
1142 /// Level one is keyed on the diagnostic state alone.
1143 const void *DocDiagsStateKey = nullptr;
1144 bool DocDiagsEnabledIgnoringSystem = false;
1145
1146 /// Level two, for when the location does matter. Bit i of each mask is a
1147 /// DiagStateSystemClass value; bit 0 is unused.
1148 uint8_t DocDiagsExactComputed = 0;
1149 uint8_t DocDiagsExactEnabled = 0;
1150
1151 // Returns if a warning suppression mapping is active and affects
1152 // documentation warnings.
1153 bool areDocumentationDiagsSourceLocationDependent();
1154
1155 /// Lazily computed cache for areDocumentationDiagsSourceLocationDependent().
1156 std::optional<bool> DocDiagsInSuppressionMapping;
1157
1158public:
1159 /// Returns true if a comment at \p Loc should be retained in the AST
1160 /// (some consumer such as -Wdocumentation, -fparse-all-comments, code
1161 /// completion, or AST-file serialization may read it back).
1163
1164 /// Retrieve the parser's current scope.
1165 ///
1166 /// This routine must only be used when it is certain that semantic analysis
1167 /// and the parser are in precisely the same context, which is not the case
1168 /// when, e.g., we are performing any kind of template instantiation.
1169 /// Therefore, the only safe places to use this scope are in the parser
1170 /// itself and in routines directly invoked from the parser and *never* from
1171 /// template substitution or instantiation.
1172 Scope *getCurScope() const { return CurScope; }
1173
1175
1179
1180 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
1181 const FunctionDecl *FD = nullptr);
1183 const PartialDiagnostic &PD,
1184 const FunctionDecl *FD = nullptr) {
1185 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
1186 }
1187
1188 /// Check if the type is allowed to be used for the current target.
1190 ValueDecl *D = nullptr);
1191
1192 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
1193 /// cast. If there is already an implicit cast, merge into the existing one.
1194 /// If isLvalue, the result of the cast is an lvalue.
1197 const CXXCastPath *BasePath = nullptr,
1199
1200 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
1201 /// to the conversion from scalar type ScalarTy to the Boolean type.
1203
1204 /// If \p AllowLambda is true, treat lambda as function.
1205 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
1206
1207 /// Returns a pointer to the innermost enclosing function, or nullptr if the
1208 /// current context is not inside a function. If \p AllowLambda is true,
1209 /// this can return the call operator of an enclosing lambda, otherwise
1210 /// lambdas are skipped when looking for an enclosing function.
1211 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
1212
1213 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
1214 /// the method decl for the method being parsed. If we're currently
1215 /// in a 'block', this returns the containing context.
1217
1218 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
1219 /// or C function we're in, otherwise return null. If we're currently
1220 /// in a 'block', this returns the containing context.
1222
1223 /// Warn if we're implicitly casting from a _Nullable pointer type to a
1224 /// _Nonnull one.
1226 SourceLocation Loc);
1227
1228 /// Warn when implicitly casting 0 to nullptr.
1229 void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
1230
1231 /// Warn when implicitly changing function effects.
1233 SourceLocation Loc);
1234
1235 /// makeUnavailableInSystemHeader - There is an error in the current
1236 /// context. If we're still in a system header, and we can plausibly
1237 /// make the relevant declaration unavailable instead of erroring, do
1238 /// so and return true.
1240 UnavailableAttr::ImplicitReason reason);
1241
1242 /// Retrieve a suitable printing policy for diagnostics.
1246
1247 /// Retrieve a suitable printing policy for diagnostics.
1249 const Preprocessor &PP);
1250
1251 /// Scope actions.
1253
1254 /// Determine whether \param D is function like (function or function
1255 /// template) for parsing.
1257
1258 /// The maximum alignment, same as in llvm::Value. We duplicate them here
1259 /// because that allows us not to duplicate the constants in clang code,
1260 /// which we must to since we can't directly use the llvm constants.
1261 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
1262 ///
1263 /// This is the greatest alignment value supported by load, store, and alloca
1264 /// instructions, and global values.
1265 static const unsigned MaxAlignmentExponent = 32;
1267
1268 /// Flag indicating whether or not to collect detailed statistics.
1270
1271 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
1272
1273 /// Stack containing information about each of the nested
1274 /// function, block, and method scopes that are currently active.
1276
1277 /// The index of the first FunctionScope that corresponds to the current
1278 /// context.
1280
1281 /// Track the number of currently active capturing scopes.
1283
1284 llvm::BumpPtrAllocator BumpAlloc;
1285
1286 /// The kind of translation unit we are processing.
1287 ///
1288 /// When we're processing a complete translation unit, Sema will perform
1289 /// end-of-translation-unit semantic tasks (such as creating
1290 /// initializers for tentative definitions in C) once parsing has
1291 /// completed. Modules and precompiled headers perform different kinds of
1292 /// checks.
1294
1295 /// Translation Unit Scope - useful to Objective-C actions that need
1296 /// to lookup file scope declarations in the "ordinary" C decl namespace.
1297 /// For example, user-defined classes, built-in "id" type, etc.
1299
1301 return CurScope->incrementMSManglingNumber();
1302 }
1303
1304 /// Try to recover by turning the given expression into a
1305 /// call. Returns true if recovery was attempted or an error was
1306 /// emitted; this may also leave the ExprResult invalid.
1308 bool ForceComplain = false,
1309 bool (*IsPlausibleResult)(QualType) = nullptr);
1310
1311 // Adds implicit lifetime bound attribute for implicit this to its
1312 // TypeSourceInfo.
1314
1315 /// Figure out if an expression could be turned into a call.
1316 ///
1317 /// Use this when trying to recover from an error where the programmer may
1318 /// have written just the name of a function instead of actually calling it.
1319 ///
1320 /// \param E - The expression to examine.
1321 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
1322 /// with no arguments, this parameter is set to the type returned by such a
1323 /// call; otherwise, it is set to an empty QualType.
1324 /// \param OverloadSet - If the expression is an overloaded function
1325 /// name, this parameter is populated with the decls of the various
1326 /// overloads.
1327 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
1328 UnresolvedSetImpl &NonTemplateOverloads);
1329
1333
1336
1344
1345 std::unique_ptr<APINotesSelectorDiagnosticState> APINotesSelectorDiagnostics;
1346
1347 /// A RAII object to enter scope of a compound statement.
1349 public:
1350 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
1351 S.ActOnStartOfCompoundStmt(IsStmtExpr);
1352 }
1353
1354 ~CompoundScopeRAII() { S.ActOnFinishOfCompoundStmt(); }
1357
1358 private:
1359 Sema &S;
1360 };
1361
1362 /// An RAII helper that pops function a function scope on exit.
1368 if (Active)
1369 S.PopFunctionScopeInfo();
1370 }
1371 void disable() { Active = false; }
1372 };
1373
1375 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
1376 }
1377
1378 /// Worker object for performing CFG-based warnings.
1381
1382 /// Callback to the parser to parse templated functions when needed.
1383 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
1386
1388 LateTemplateParser = LTP;
1389 OpaqueParser = P;
1390 }
1391
1392 /// Callback to the parser to parse a type expressed as a string.
1393 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
1395
1396 /// VAListTagName - The declaration name corresponding to __va_list_tag.
1397 /// This is used as part of a hack to omit that class from ADL results.
1399
1400 /// Is the last error level diagnostic immediate. This is used to determined
1401 /// whether the next info diagnostic should be immediate.
1403
1404 /// Track if we're currently analyzing overflow behavior types in assignment
1405 /// context.
1407
1408 class DelayedDiagnostics;
1409
1411 sema::DelayedDiagnosticPool *SavedPool = nullptr;
1413 };
1416
1417 /// A class which encapsulates the logic for delaying diagnostics
1418 /// during parsing and other processing.
1420 /// The current pool of diagnostics into which delayed
1421 /// diagnostics should go.
1422 sema::DelayedDiagnosticPool *CurPool = nullptr;
1423
1424 public:
1426
1427 /// Adds a delayed diagnostic.
1428 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
1429
1430 /// Determines whether diagnostics should be delayed.
1431 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
1432
1433 /// Returns the current delayed-diagnostics pool.
1434 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1435
1436 /// Enter a new scope. Access and deprecation diagnostics will be
1437 /// collected in this pool.
1440 state.SavedPool = CurPool;
1441 CurPool = &pool;
1442 return state;
1443 }
1444
1445 /// Leave a delayed-diagnostic state that was previously pushed.
1446 /// Do not emit any of the diagnostics. This is performed as part
1447 /// of the bookkeeping of popping a pool "properly".
1449 CurPool = state.SavedPool;
1450 }
1451
1452 /// Enter a new scope where access and deprecation diagnostics are
1453 /// not delayed.
1456 state.SavedPool = CurPool;
1457 CurPool = nullptr;
1458 return state;
1459 }
1460
1461 /// Undo a previous pushUndelayed().
1463 assert(CurPool == nullptr);
1464 CurPool = state.SavedPool;
1465 }
1467
1471
1472 /// Diagnostics that are emitted only if we discover that the given function
1473 /// must be codegen'ed. Because handling these correctly adds overhead to
1474 /// compilation, this is currently only used for offload languages like CUDA,
1475 /// OpenMP, and SYCL.
1476 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1477
1478 /// An inverse call graph, mapping known-emitted functions to their
1479 /// known-emitted callers (plus the location of the call). It is populated
1480 /// while emitting deferred diagnostics and is used to print call stack notes
1481 /// for all offload languages.
1482 ///
1483 /// Functions that we can tell a priori must be emitted aren't added to this
1484 /// map. A function may have multiple callers that force it into device
1485 /// context, so we store all of them to produce complete diagnostics.
1486 llvm::DenseMap</* Callee = */ CanonicalDeclPtr<const FunctionDecl>,
1489
1490 /// CurContext - This is the current declaration context of parsing.
1492
1494 assert(AMDGPUPtr);
1495 return *AMDGPUPtr;
1496 }
1497
1499 assert(ARMPtr);
1500 return *ARMPtr;
1501 }
1502
1504 assert(AVRPtr);
1505 return *AVRPtr;
1506 }
1507
1509 assert(BPFPtr);
1510 return *BPFPtr;
1511 }
1512
1514 assert(CodeCompletionPtr);
1515 return *CodeCompletionPtr;
1516 }
1517
1519 assert(CUDAPtr);
1520 return *CUDAPtr;
1521 }
1522
1524 assert(DirectXPtr);
1525 return *DirectXPtr;
1526 }
1527
1529 assert(HLSLPtr);
1530 return *HLSLPtr;
1531 }
1532
1534 assert(HexagonPtr);
1535 return *HexagonPtr;
1536 }
1537
1539 assert(LoongArchPtr);
1540 return *LoongArchPtr;
1541 }
1542
1544 assert(M68kPtr);
1545 return *M68kPtr;
1546 }
1547
1549 assert(MIPSPtr);
1550 return *MIPSPtr;
1551 }
1552
1554 assert(MSP430Ptr);
1555 return *MSP430Ptr;
1556 }
1557
1559 assert(NVPTXPtr);
1560 return *NVPTXPtr;
1561 }
1562
1564 assert(ObjCPtr);
1565 return *ObjCPtr;
1566 }
1567
1569 assert(OpenACCPtr);
1570 return *OpenACCPtr;
1571 }
1572
1574 assert(OpenCLPtr);
1575 return *OpenCLPtr;
1576 }
1577
1579 assert(OpenMPPtr && "SemaOpenMP is dead");
1580 return *OpenMPPtr;
1581 }
1582
1584 assert(PPCPtr);
1585 return *PPCPtr;
1586 }
1587
1589 assert(PseudoObjectPtr);
1590 return *PseudoObjectPtr;
1591 }
1592
1594 assert(RISCVPtr);
1595 return *RISCVPtr;
1596 }
1597
1599 assert(SPIRVPtr);
1600 return *SPIRVPtr;
1601 }
1602
1604 assert(SYCLPtr);
1605 return *SYCLPtr;
1606 }
1607
1609 assert(SwiftPtr);
1610 return *SwiftPtr;
1611 }
1612
1614 assert(SystemZPtr);
1615 return *SystemZPtr;
1616 }
1617
1619 assert(WasmPtr);
1620 return *WasmPtr;
1621 }
1622
1624 assert(X86Ptr);
1625 return *X86Ptr;
1626 }
1627
1628 /// Source of additional semantic information.
1630
1631protected:
1632 friend class Parser;
1634 friend class ASTReader;
1635 friend class ASTDeclReader;
1636 friend class ASTWriter;
1637
1638private:
1639 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1640 bool WarnedDarwinSDKInfoMissing = false;
1641
1642 StackExhaustionHandler StackHandler;
1643
1644 Sema(const Sema &) = delete;
1645 void operator=(const Sema &) = delete;
1646
1647 /// The handler for the FileChanged preprocessor events.
1648 ///
1649 /// Used for diagnostics that implement custom semantic analysis for #include
1650 /// directives, like -Wpragma-pack.
1651 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1652
1653 /// The parser's current scope.
1654 ///
1655 /// The parser maintains this state here.
1656 Scope *CurScope;
1657
1658 mutable IdentifierInfo *Ident_super;
1659
1660 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1661 std::unique_ptr<SemaARM> ARMPtr;
1662 std::unique_ptr<SemaAVR> AVRPtr;
1663 std::unique_ptr<SemaBPF> BPFPtr;
1664 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1665 std::unique_ptr<SemaCUDA> CUDAPtr;
1666 std::unique_ptr<SemaDirectX> DirectXPtr;
1667 std::unique_ptr<SemaHLSL> HLSLPtr;
1668 std::unique_ptr<SemaHexagon> HexagonPtr;
1669 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1670 std::unique_ptr<SemaM68k> M68kPtr;
1671 std::unique_ptr<SemaMIPS> MIPSPtr;
1672 std::unique_ptr<SemaMSP430> MSP430Ptr;
1673 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1674 std::unique_ptr<SemaObjC> ObjCPtr;
1675 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1676 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1677 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1678 std::unique_ptr<SemaPPC> PPCPtr;
1679 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1680 std::unique_ptr<SemaRISCV> RISCVPtr;
1681 std::unique_ptr<SemaSPIRV> SPIRVPtr;
1682 std::unique_ptr<SemaSYCL> SYCLPtr;
1683 std::unique_ptr<SemaSwift> SwiftPtr;
1684 std::unique_ptr<SemaSystemZ> SystemZPtr;
1685 std::unique_ptr<SemaWasm> WasmPtr;
1686 std::unique_ptr<SemaX86> X86Ptr;
1687
1688 ///@}
1689
1690 //
1691 //
1692 // -------------------------------------------------------------------------
1693 //
1694 //
1695
1696 /// \name API Notes
1697 /// Implementations are in SemaAPINotes.cpp
1698 ///@{
1699
1700public:
1701 /// Map any API notes provided for this declaration to attributes on the
1702 /// declaration.
1703 ///
1704 /// Triggered by declaration-attribute processing.
1705 void ProcessAPINotes(Decl *D);
1706 /// Apply the 'Nullability:' annotation to the specified declaration
1707 void ApplyNullability(Decl *D, NullabilityKind Nullability);
1708 /// Apply the 'Type:' annotation to the specified declaration
1709 void ApplyAPINotesType(Decl *D, StringRef TypeString);
1710
1711 /// Diagnose exact API notes selectors that were not matched by any
1712 /// declaration processed in this translation unit.
1714
1715 /// Whether APINotes should be gathered for all applicable Swift language
1716 /// versions, without being applied. Leaving clients of the current module
1717 /// to select and apply the correct version.
1719 return APINotes.captureVersionIndependentSwift();
1720 }
1721 ///@}
1722
1723 //
1724 //
1725 // -------------------------------------------------------------------------
1726 //
1727 //
1728
1729 /// \name C++ Access Control
1730 /// Implementations are in SemaAccess.cpp
1731 ///@{
1732
1733public:
1740
1741 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1742 /// Returns true on error (when the previous member decl access specifier
1743 /// is different from the new member decl access specifier).
1744 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1745 NamedDecl *PrevMemberDecl,
1746 AccessSpecifier LexicalAS);
1747
1748 /// Perform access-control checking on a previously-unresolved member
1749 /// access which has now been resolved to a member.
1751 DeclAccessPair FoundDecl);
1753 DeclAccessPair FoundDecl);
1754
1755 /// Checks access to an overloaded operator new or delete.
1757 SourceRange PlacementRange,
1758 CXXRecordDecl *NamingClass,
1759 DeclAccessPair FoundDecl,
1760 bool Diagnose = true);
1761
1762 /// Checks access to a constructor.
1764 DeclAccessPair FoundDecl,
1765 const InitializedEntity &Entity,
1766 bool IsCopyBindingRefToTemp = false);
1767
1768 /// Checks access to a constructor.
1770 DeclAccessPair FoundDecl,
1771 const InitializedEntity &Entity,
1772 const PartialDiagnostic &PDiag);
1774 CXXDestructorDecl *Dtor,
1775 const PartialDiagnostic &PDiag,
1776 QualType objectType = QualType());
1777
1778 /// Checks access to the target of a friend declaration.
1780
1781 /// Checks access to a member.
1783 CXXRecordDecl *NamingClass,
1785
1786 /// Checks implicit access to a member in a structured binding.
1789 CXXRecordDecl *DecomposedClass,
1790 DeclAccessPair Field);
1792 const SourceRange &,
1793 DeclAccessPair FoundDecl);
1794
1795 /// Checks access to an overloaded member operator, including
1796 /// conversion operators.
1798 Expr *ArgExpr,
1799 DeclAccessPair FoundDecl);
1801 ArrayRef<Expr *> ArgExprs,
1802 DeclAccessPair FoundDecl);
1804 DeclAccessPair FoundDecl);
1805
1806 /// Checks access for a hierarchy conversion.
1807 ///
1808 /// \param ForceCheck true if this check should be performed even if access
1809 /// control is disabled; some things rely on this for semantics
1810 /// \param ForceUnprivileged true if this check should proceed as if the
1811 /// context had no special privileges
1813 QualType Derived, const CXXBasePath &Path,
1814 unsigned DiagID, bool ForceCheck = false,
1815 bool ForceUnprivileged = false);
1816
1818 SourceLocation AccessLoc, CXXRecordDecl *Base, CXXRecordDecl *Derived,
1819 const CXXBasePath &Path, unsigned DiagID,
1820 llvm::function_ref<void(PartialDiagnostic &PD)> SetupPDiag,
1821 bool ForceCheck = false, bool ForceUnprivileged = false);
1822
1823 /// Checks access to all the declarations in the given result set.
1824 void CheckLookupAccess(const LookupResult &R);
1825
1826 /// Checks access to Target from the given class. The check will take access
1827 /// specifiers into account, but no member access expressions and such.
1828 ///
1829 /// \param Target the declaration to check if it can be accessed
1830 /// \param NamingClass the class in which the lookup was started.
1831 /// \param BaseType type of the left side of member access expression.
1832 /// \p BaseType and \p NamingClass are used for C++ access control.
1833 /// Depending on the lookup case, they should be set to the following:
1834 /// - lhs.target (member access without a qualifier):
1835 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1836 /// - lhs.X::target (member access with a qualifier):
1837 /// BaseType is the type of 'lhs', NamingClass is 'X'
1838 /// - X::target (qualified lookup without member access):
1839 /// BaseType is null, NamingClass is 'X'.
1840 /// - target (unqualified lookup).
1841 /// BaseType is null, NamingClass is the parent class of 'target'.
1842 /// \return true if the Target is accessible from the Class, false otherwise.
1843 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1844 QualType BaseType);
1845
1846 /// Is the given member accessible for the purposes of deciding whether to
1847 /// define a special member function as deleted?
1849 DeclAccessPair Found, QualType ObjectType,
1850 SourceLocation Loc,
1851 const PartialDiagnostic &Diag);
1854 QualType ObjectType) {
1855 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1856 SourceLocation(), PDiag());
1857 }
1858
1860 const DependentDiagnostic &DD,
1861 const MultiLevelTemplateArgumentList &TemplateArgs);
1863
1864 ///@}
1865
1866 //
1867 //
1868 // -------------------------------------------------------------------------
1869 //
1870 //
1871
1872 /// \name Attributes
1873 /// Implementations are in SemaAttr.cpp
1874 ///@{
1875
1876public:
1877 /// Controls member pointer representation format under the MS ABI.
1880
1881 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1882
1883 /// Source location for newly created implicit MSInheritanceAttrs
1885
1891
1897
1899 PSK_Reset = 0x0, // #pragma ()
1900 PSK_Set = 0x1, // #pragma (value)
1901 PSK_Push = 0x2, // #pragma (push[, id])
1902 PSK_Pop = 0x4, // #pragma (pop[, id])
1903 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1904 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1905 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1906 };
1907
1913
1914 // #pragma pack and align.
1916 public:
1917 // `Native` represents default align mode, which may vary based on the
1918 // platform.
1919 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1920
1921 // #pragma pack info constructor
1922 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1923 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1924 assert(Num == PackNumber && "The pack number has been truncated.");
1925 }
1926
1927 // #pragma align info constructor
1929 : PackAttr(false), AlignMode(M),
1930 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1931
1932 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1933
1935
1936 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1937 // integer encoding for it. This should only be passed to
1938 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1940 std::uint32_t Encoding{};
1941 if (Info.IsXLStack())
1942 Encoding |= IsXLMask;
1943
1944 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1945
1946 if (Info.IsPackAttr())
1947 Encoding |= PackAttrMask;
1948
1949 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1950
1951 return Encoding;
1952 }
1953
1954 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1955 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1957 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1958 int PackNumber = (Encoding & PackNumMask) >> 4;
1959
1960 if (Encoding & PackAttrMask)
1961 return AlignPackInfo(M, PackNumber, IsXL);
1962
1963 return AlignPackInfo(M, IsXL);
1964 }
1965
1966 bool IsPackAttr() const { return PackAttr; }
1967
1968 bool IsAlignAttr() const { return !PackAttr; }
1969
1970 Mode getAlignMode() const { return AlignMode; }
1971
1972 unsigned getPackNumber() const { return PackNumber; }
1973
1974 bool IsPackSet() const {
1975 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1976 // attriute on a decl.
1977 return PackNumber != UninitPackVal && PackNumber != 0;
1978 }
1979
1980 bool IsXLStack() const { return XLStack; }
1981
1982 bool operator==(const AlignPackInfo &Info) const {
1983 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1984 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1985 Info.XLStack);
1986 }
1987
1988 bool operator!=(const AlignPackInfo &Info) const {
1989 return !(*this == Info);
1990 }
1991
1992 private:
1993 /// \brief True if this is a pragma pack attribute,
1994 /// not a pragma align attribute.
1995 bool PackAttr;
1996
1997 /// \brief The alignment mode that is in effect.
1998 Mode AlignMode;
1999
2000 /// \brief The pack number of the stack.
2001 unsigned char PackNumber;
2002
2003 /// \brief True if it is a XL #pragma align/pack stack.
2004 bool XLStack;
2005
2006 /// \brief Uninitialized pack value.
2007 static constexpr unsigned char UninitPackVal = -1;
2008
2009 // Masks to encode and decode an AlignPackInfo.
2010 static constexpr uint32_t IsXLMask{0x0000'0001};
2011 static constexpr uint32_t AlignModeMask{0x0000'0006};
2012 static constexpr uint32_t PackAttrMask{0x00000'0008};
2013 static constexpr uint32_t PackNumMask{0x0000'01F0};
2014 };
2015
2016 template <typename ValueType> struct PragmaStack {
2028
2029 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
2030 llvm::StringRef StackSlotLabel, ValueType Value) {
2031 if (Action == PSK_Reset) {
2033 CurrentPragmaLocation = PragmaLocation;
2034 return;
2035 }
2036 if (Action & PSK_Push)
2037 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
2038 PragmaLocation);
2039 else if (Action & PSK_Pop) {
2040 if (!StackSlotLabel.empty()) {
2041 // If we've got a label, try to find it and jump there.
2042 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
2043 return x.StackSlotLabel == StackSlotLabel;
2044 });
2045 // If we found the label so pop from there.
2046 if (I != Stack.rend()) {
2047 CurrentValue = I->Value;
2048 CurrentPragmaLocation = I->PragmaLocation;
2049 Stack.erase(std::prev(I.base()), Stack.end());
2050 }
2051 } else if (!Stack.empty()) {
2052 // We do not have a label, just pop the last entry.
2053 CurrentValue = Stack.back().Value;
2054 CurrentPragmaLocation = Stack.back().PragmaLocation;
2055 Stack.pop_back();
2056 }
2057 }
2058 if (Action & PSK_Set) {
2060 CurrentPragmaLocation = PragmaLocation;
2061 }
2062 }
2063
2064 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
2065 // method body to restore the stacks on exit, so it works like this:
2066 //
2067 // struct S {
2068 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
2069 // void Method {}
2070 // #pragma <name>(pop, InternalPragmaSlot)
2071 // };
2072 //
2073 // It works even with #pragma vtordisp, although MSVC doesn't support
2074 // #pragma vtordisp(push [, id], n)
2075 // syntax.
2076 //
2077 // Push / pop a named sentinel slot.
2078 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
2079 assert((Action == PSK_Push || Action == PSK_Pop) &&
2080 "Can only push / pop #pragma stack sentinels!");
2081 Act(CurrentPragmaLocation, Action, Label, CurrentValue);
2082 }
2083
2084 // Constructors.
2085 explicit PragmaStack(const ValueType &Default)
2087
2088 bool hasValue() const { return CurrentValue != DefaultValue; }
2089
2091 ValueType DefaultValue; // Value used for PSK_Reset action.
2092 ValueType CurrentValue;
2094 };
2095 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
2096 // we shouldn't do so if they're in a module).
2097
2098 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
2099 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
2100 ///
2101 /// 0: Suppress all vtordisps
2102 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
2103 /// structors
2104 /// 2: Always insert vtordisps to support RTTI on partially constructed
2105 /// objects
2108 // The current #pragma align/pack values and locations at each #include.
2115 // Segment #pragmas.
2120
2121 // #pragma strict_gs_check.
2123
2124 // This stack tracks the current state of Sema.CurFPFeatures.
2127 FPOptionsOverride result;
2128 if (!FpPragmaStack.hasValue()) {
2129 result = FPOptionsOverride();
2130 } else {
2131 result = FpPragmaStack.CurrentValue;
2132 }
2133 return result;
2134 }
2135
2142
2143 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
2144 // Actions should be performed only if we enter / exit a C++ method body.
2146 public:
2147 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
2152
2153 private:
2154 Sema &S;
2155 StringRef SlotLabel;
2156 bool ShouldAct;
2157 };
2158
2159 /// Used for #pragma init_seg.
2166
2167 /// Sections used with #pragma alloc_text.
2168 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
2169
2170 /// VisContext - Manages the stack for \#pragma GCC visibility.
2171 void *VisContext; // Really a "PragmaVisStack*"
2172
2173 /// This an attribute introduced by \#pragma clang attribute.
2180
2181 /// A push'd group of PragmaAttributeEntries.
2183 /// The location of the push attribute.
2185 /// The namespace of this push group.
2188 };
2189
2191
2192 /// The declaration that is currently receiving an attribute from the
2193 /// #pragma attribute stack.
2195
2196 /// This represents the last location of a "#pragma clang optimize off"
2197 /// directive if such a directive has not been closed by an "on" yet. If
2198 /// optimizations are currently "on", this is set to an invalid location.
2200
2201 /// Get the location for the currently active "\#pragma clang optimize
2202 /// off". If this location is invalid, then the state of the pragma is "on".
2206
2207 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
2208 /// whether the optimizations in the list passed to the pragma should be
2209 /// turned off or on. This boolean is true by default because command line
2210 /// options are honored when `#pragma optimize("", on)`.
2211 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
2213
2214 /// Set of no-builtin functions listed by \#pragma function.
2216
2217 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
2218 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
2220
2221 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
2223
2224 /// Add gsl::Pointer attribute to std::container::iterator
2225 /// \param ND The declaration that introduces the name
2226 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
2227 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
2228
2229 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
2231
2232 /// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
2234
2235 /// Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
2237
2238 /// Add [[gsl::Pointer]] attributes for std:: types.
2240
2241 LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
2242 StringRef ParamName);
2243 // Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'
2244 // can be the name of a function parameter, we need to parse the function
2245 // declaration and rest of the parameters before processesing 'X'. Therefore
2246 // do this lazily instead of processing while parsing the annotation itself.
2248
2249 /// Add _Nullable attributes for std:: types.
2251
2252 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
2255 PragmaClangSectionKind SecKind,
2256 StringRef SecName);
2257
2258 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
2260 SourceLocation PragmaLoc);
2261
2262 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
2263 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
2264 StringRef SlotLabel, Expr *Alignment);
2265
2266 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
2267 /// (unless they are value dependent or type dependent). Returns false
2268 /// and emits a diagnostic if one or more of the arguments could not be
2269 /// folded into a constant.
2272
2277
2279 SourceLocation IncludeLoc);
2281
2282 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
2284
2285 /// ActOnPragmaMSComment - Called on well formed
2286 /// \#pragma comment(kind, "arg").
2288 StringRef Arg);
2289
2290 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
2291 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
2292 StringRef Value);
2293
2294 /// Are precise floating point semantics currently enabled?
2296 return !CurFPFeatures.getAllowFPReassociate() &&
2297 !CurFPFeatures.getNoSignedZero() &&
2298 !CurFPFeatures.getAllowReciprocal() &&
2299 !CurFPFeatures.getAllowApproxFunc();
2300 }
2301
2304
2305 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
2306 void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action,
2308
2309 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
2310 /// pointers_to_members(representation method[, general purpose
2311 /// representation]).
2314 SourceLocation PragmaLoc);
2315
2316 /// Called on well formed \#pragma vtordisp().
2317 void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
2319
2320 bool UnifySection(StringRef SectionName, int SectionFlags,
2321 NamedDecl *TheDecl);
2322 bool UnifySection(StringRef SectionName, int SectionFlags,
2323 SourceLocation PragmaSectionLocation);
2324
2325 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
2326 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
2327 PragmaMsStackAction Action,
2328 llvm::StringRef StackSlotLabel,
2329 StringLiteral *SegmentName, llvm::StringRef PragmaName);
2330
2331 /// Called on well formed \#pragma section().
2332 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
2333 StringLiteral *SegmentName);
2334
2335 /// Called on well-formed \#pragma init_seg().
2336 /// If a function name is provided (", func-name"), it is passed via Func.
2337 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
2338 StringLiteral *SegmentName,
2339 IdentifierLoc *Func = nullptr);
2340
2341 /// Called on well-formed \#pragma alloc_text().
2343 SourceLocation PragmaLocation, StringRef Section,
2344 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
2345 &Functions);
2346
2347 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
2348 /// strict_gs_check.
2350 PragmaMsStackAction Action,
2351 bool Value);
2352
2353 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
2354 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
2355 SourceLocation PragmaLoc);
2356
2358 SourceLocation PragmaLoc,
2361 const IdentifierInfo *Namespace);
2362
2363 /// Called on well-formed '\#pragma clang attribute pop'.
2365 const IdentifierInfo *Namespace);
2366
2367 /// Adds the attributes that have been specified using the
2368 /// '\#pragma clang attribute push' directives to the given declaration.
2369 void AddPragmaAttributes(Scope *S, Decl *D);
2370
2372 llvm::function_ref<void(SourceLocation, PartialDiagnostic)>;
2374 return [this](SourceLocation Loc, PartialDiagnostic PD) {
2375 // This bypasses a lot of the filters in the diag engine, as it's
2376 // to be used to attach notes to diagnostics which have already
2377 // been filtered through.
2378 DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
2379 PD.Emit(Builder);
2380 };
2381 }
2382
2388
2390
2391 /// Called on well formed \#pragma clang optimize.
2392 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
2393
2394 /// #pragma optimize("[optimization-list]", on | off).
2395 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
2396
2397 /// Call on well formed \#pragma function.
2398 void
2400 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
2401
2403 SourceLocation NameLoc,
2404 Scope *curScope);
2405
2406 /// Information from a C++ #pragma export, for a symbol that we
2407 /// haven't seen the declaration for yet.
2412
2413 llvm::DenseMap<IdentifierInfo *, PendingPragmaInfo> PendingExportedNames;
2414
2415 /// ActonPragmaExport - called on well-formed '\#pragma export'.
2416 void ActOnPragmaExport(IdentifierInfo *IdentId, SourceLocation ExportNameLoc,
2417 Scope *curScope);
2418
2419 /// Only called on function definitions; if there is a pragma in scope
2420 /// with the effect of a range-based optnone, consider marking the function
2421 /// with attribute optnone.
2423
2424 /// Only called on function definitions; if there is a `#pragma alloc_text`
2425 /// that decides which code section the function should be in, add
2426 /// attribute section to the function.
2428
2429 /// Adds the 'optnone' attribute to the function declaration if there
2430 /// are no conflicts; Loc represents the location causing the 'optnone'
2431 /// attribute to be added (usually because of a pragma).
2433
2434 /// Only called on function definitions; if there is a MSVC #pragma optimize
2435 /// in scope, consider changing the function's attributes based on the
2436 /// optimization list passed to the pragma.
2438
2439 /// Only called on function definitions; if there is a pragma in scope
2440 /// with the effect of a range-based no_builtin, consider marking the function
2441 /// with attribute no_builtin.
2443
2444 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
2445 /// add an appropriate visibility attribute.
2447
2448 /// FreeVisContext - Deallocate and null out VisContext.
2449 void FreeVisContext();
2450
2451 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
2452 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
2453 SourceLocation PragmaLoc);
2454
2455 /// ActOnPragmaFPContract - Called on well formed
2456 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
2457 /// \#pragma clang fp contract
2459
2460 /// Called on well formed
2461 /// \#pragma clang fp reassociate
2462 /// or
2463 /// \#pragma clang fp reciprocal
2465 bool IsEnabled);
2466
2467 /// ActOnPragmaFenvAccess - Called on well formed
2468 /// \#pragma STDC FENV_ACCESS
2469 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
2470
2471 /// ActOnPragmaCXLimitedRange - Called on well formed
2472 /// \#pragma STDC CX_LIMITED_RANGE
2475
2476 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
2479
2480 /// Called to set constant rounding mode for floating point operations.
2481 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
2482
2483 /// Called to set exception behavior for floating point operations.
2485
2486 /// PushNamespaceVisibilityAttr - Note that we've entered a
2487 /// namespace with a visibility attribute.
2488 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
2489 SourceLocation Loc);
2490
2491 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
2492 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2493 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2494
2495 /// Handles semantic checking for features that are common to all attributes,
2496 /// such as checking whether a parameter was properly specified, or the
2497 /// correct number of arguments were passed, etc. Returns true if the
2498 /// attribute has been diagnosed.
2499 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2500 bool SkipArgCountCheck = false);
2501 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2502 bool SkipArgCountCheck = false);
2504 bool SkipArgCountCheck = false);
2505
2506 ///@}
2507
2508 //
2509 //
2510 // -------------------------------------------------------------------------
2511 //
2512 //
2513
2514 /// \name Availability Attribute Handling
2515 /// Implementations are in SemaAvailability.cpp
2516 ///@{
2517
2518public:
2519 /// Issue any -Wunguarded-availability warnings in \c FD
2521
2523
2524 /// Retrieve the current function, if any, that should be analyzed for
2525 /// potential availability violations.
2527
2529 const ObjCInterfaceDecl *UnknownObjCClass,
2530 bool ObjCPropertyAccess,
2531 bool AvoidPartialAvailabilityChecks,
2532 ObjCInterfaceDecl *ClassReceiver);
2533
2535
2536 std::pair<AvailabilityResult, const NamedDecl *>
2537 ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message,
2538 ObjCInterfaceDecl *ClassReceiver);
2539 ///@}
2540
2541 //
2542 //
2543 // -------------------------------------------------------------------------
2544 //
2545 //
2546
2547 /// \name Bounds Safety
2548 /// Implementations are in SemaBoundsSafety.cpp
2549 ///@{
2550public:
2552 bool CountInBytes = false;
2553 bool OrNull = false;
2554 bool IsEndedBy = false;
2555
2556 /// Return the flags for a bounds attribute of kind \p K.
2558 };
2561
2562 /// Check the type shape for counted_by, sized_by and their _or_null variants.
2563 /// The caller checks declaration context, count expressions, flexible array
2564 /// member eligibility and nesting.
2565 ///
2566 /// \p Flags selects the attribute variant. For void pointers, counted_by is
2567 /// treated as a byte count outside the -fbounds-safety attribute model. Set
2568 /// \c Flags.CountInBytes in this case if \p UpdateFlags is true.
2569 /// \p AttrSpelling, \p AllowRedecl and \p AttrArg are reserved for that model
2570 /// (see LangOptions::hasBoundsSafetyAttributes).
2571 ///
2572 /// \returns false after diagnosing an attribute that must be dropped. Returns
2573 /// true if the shape is valid, after the warning for an array of structs with
2574 /// flexible array members, and, under the -fbounds-safety attribute model,
2575 /// after an error on a pointer, with \c Flags.CountInBytes set so that type
2576 /// construction can recover.
2578 SourceRange AttrRange,
2579 BoundsAttrFlags &Flags,
2580 StringRef AttrSpelling = {},
2581 bool AllowRedecl = false,
2582 Expr *AttrArg = nullptr,
2583 bool UpdateFlags = true);
2584
2585 /// Check a counted_by-family attribute in type position and initialize
2586 /// \p Flags from \p AttrKind. \p PointerNestLevel counts the pointer, array
2587 /// and function declarator chunks enclosing the attribute.
2588 ///
2589 /// \returns false after diagnosing an attribute that must be dropped (see
2590 /// ValidateBoundsAttrTypeShape).
2593 SourceRange AttrRange, unsigned PointerNestLevel, BoundsAttrFlags &Flags);
2594
2595 /// Check if applying the specified attribute variant from the "counted by"
2596 /// family of attributes to FieldDecl \p FD is semantically valid. If
2597 /// semantically invalid diagnostics will be emitted explaining the problems.
2598 ///
2599 /// \param FD The FieldDecl to apply the attribute to
2600 /// \param E The count expression on the attribute
2601 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2602 /// attributes. If the false the attribute is from
2603 /// "counted_by" family of attributes.
2604 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2605 /// of attributes. If false the attribute does not have the
2606 /// suffix.
2607 ///
2608 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2609 /// \p CountInBytes and \p OrNull both being true indicates the
2610 /// `counted_by_or_null` attribute.
2611 ///
2612 /// \returns false iff semantically valid.
2613 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2614 bool OrNull);
2615
2616 /// Late-parsed bounds types dropped while their declarator was built. The
2617 /// attribute has already been diagnosed and its node is no longer part of
2618 /// any type, so the completion pass must skip it rather than parse its
2619 /// argument and complete it.
2622
2626
2628 return RejectedLateParsedBoundsTypes.contains(BATy);
2629 }
2630
2631 /// Validate the late-parsed type attribute \p LA and wrap \p QT in a
2632 /// CountAttributedType with no count yet, recorded on \p LA for later
2633 /// completion. Returns false if \p LA is invalid.
2635
2636 /// Supply the parsed argument of a late-parsed bounds attribute to the type
2637 /// built for it by ProcessLateParsedTypeAttr, and run the checks that need
2638 /// the owning declaration. \p FD is the field the type belongs to. Returns
2639 /// false if the attribute was rejected.
2641 FieldDecl *FD, Expr *Arg);
2642
2643 /// Perform Bounds Safety Semantic checks for assigning to a `__counted_by` or
2644 /// `__counted_by_or_null` pointer type \param LHSTy.
2645 ///
2646 /// \param LHSTy The type being assigned to. Checks will only be performed if
2647 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2648 /// \param RHSExpr The expression being assigned from.
2649 /// \param Action The type assignment being performed
2650 /// \param Loc The SourceLocation to use for error diagnostics
2651 /// \param Assignee The ValueDecl being assigned. This is used to compute
2652 /// the name of the assignee. If the assignee isn't known this can
2653 /// be set to nullptr.
2654 /// \param ShowFullyQualifiedAssigneeName If set to true when using \p
2655 /// Assignee to compute the name of the assignee use the fully
2656 /// qualified name, otherwise use the unqualified name.
2657 ///
2658 /// \returns True iff no diagnostic where emitted, false otherwise.
2660 QualType LHSTy, Expr *RHSExpr, AssignmentAction Action,
2661 SourceLocation Loc, const ValueDecl *Assignee,
2662 bool ShowFullyQualifiedAssigneeName);
2663
2664 /// Perform Bounds Safety Semantic checks for initializing a Bounds Safety
2665 /// pointer.
2666 ///
2667 /// \param Entity The entity being initialized
2668 /// \param Kind The kind of initialization being performed
2669 /// \param Action The type assignment being performed
2670 /// \param LHSTy The type being assigned to. Checks will only be performed if
2671 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2672 /// \param RHSExpr The expression being used for initialization.
2673 ///
2674 /// \returns True iff no diagnostic where emitted, false otherwise.
2676 const InitializationKind &Kind,
2677 AssignmentAction Action,
2678 QualType LHSType, Expr *RHSExpr);
2679
2680 /// Perform Bounds Safety semantic checks for uses of invalid uses counted_by
2681 /// or counted_by_or_null pointers in \param E.
2682 ///
2683 /// \param E the expression to check
2684 ///
2685 /// \returns True iff no diagnostic where emitted, false otherwise.
2687 ///@}
2688
2689 //
2690 //
2691 // -------------------------------------------------------------------------
2692 //
2693 //
2694
2695 /// \name Casts
2696 /// Implementations are in SemaCast.cpp
2697 ///@{
2698
2699public:
2705
2706 /// ActOnCXXNamedCast - Parse
2707 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2709 SourceLocation LAngleBracketLoc, Declarator &D,
2710 SourceLocation RAngleBracketLoc,
2711 SourceLocation LParenLoc, Expr *E,
2712 SourceLocation RParenLoc);
2713
2715 TypeSourceInfo *Ty, Expr *E,
2716 SourceRange AngleBrackets, SourceRange Parens);
2717
2719 ExprResult Operand,
2720 SourceLocation RParenLoc);
2721
2723 Expr *Operand, SourceLocation RParenLoc);
2724
2725 // Checks that reinterpret casts don't have undefined behavior.
2726 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2727 bool IsDereference, SourceRange Range);
2728
2729 // Checks that the vector type should be initialized from a scalar
2730 // by splatting the value rather than populating a single element.
2731 // This is the case for AltiVecVector types as well as with
2732 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2733 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2734
2735 // Checks if the -faltivec-src-compat=gcc option is specified.
2736 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2737 // treated the same way as they are when trying to initialize
2738 // these vectors on gcc (an error is emitted).
2740 QualType SrcTy);
2741
2743 SourceLocation RParenLoc, Expr *Op);
2744
2746 SourceLocation LParenLoc,
2747 Expr *CastExpr,
2748 SourceLocation RParenLoc);
2749
2750 ///@}
2751
2752 //
2753 //
2754 // -------------------------------------------------------------------------
2755 //
2756 //
2757
2758 /// \name Extra Semantic Checking
2759 /// Implementations are in SemaChecking.cpp
2760 ///@{
2761
2762public:
2763 /// Used to change context to isConstantEvaluated without pushing a heavy
2764 /// ExpressionEvaluationContextRecord object.
2766
2771
2773 unsigned ByteNo) const;
2774
2776 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2777 FAPK_Variadic, // values to format are passed as variadic arguments
2778 FAPK_VAList, // values to format are passed in a va_list
2779 FAPK_Elsewhere, // values to format are not passed to this function
2780 };
2781
2782 // Used to grab the relevant information from a FormatAttr and a
2783 // FunctionDeclaration.
2789
2790 /// Given a function and its FormatAttr or FormatMatchesAttr info, attempts to
2791 /// populate the FormatStringInfo parameter with the attribute's correct
2792 /// format_idx and firstDataArg. Returns true when the format fits the
2793 /// function and the FormatStringInfo has been populated.
2794 static bool getFormatStringInfo(const Decl *Function, unsigned FormatIdx,
2795 unsigned FirstArg, FormatStringInfo *FSI);
2796 static bool getFormatStringInfo(unsigned FormatIdx, unsigned FirstArg,
2797 bool HasImplicitThisParam, bool IsVariadic,
2798 FormatStringInfo *FSI);
2799
2800 // Used by C++ template instantiation.
2802
2803 /// ConvertVectorExpr - Handle __builtin_convertvector
2805 SourceLocation BuiltinLoc,
2806 SourceLocation RParenLoc);
2807
2808 static StringRef GetFormatStringTypeName(FormatStringType FST);
2809 static FormatStringType GetFormatStringType(StringRef FormatFlavor);
2810 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2811 static FormatStringType GetFormatStringType(const FormatMatchesAttr *Format);
2812
2813 bool FormatStringHasSArg(const StringLiteral *FExpr);
2814
2815 /// Check for comparisons of floating-point values using == and !=. Issue a
2816 /// warning if the comparison is not likely to do what the programmer
2817 /// intended.
2818 void CheckFloatComparison(SourceLocation Loc, const Expr *LHS,
2819 const Expr *RHS, BinaryOperatorKind Opcode);
2820
2821 /// Register a magic integral constant to be used as a type tag.
2822 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2823 uint64_t MagicValue, QualType Type,
2824 bool LayoutCompatible, bool MustBeNull);
2825
2828
2832
2834
2835 /// If true, \c Type should be compared with other expression's types for
2836 /// layout-compatibility.
2837 LLVM_PREFERRED_TYPE(bool)
2839 LLVM_PREFERRED_TYPE(bool)
2840 unsigned MustBeNull : 1;
2841 };
2842
2843 /// A pair of ArgumentKind identifier and magic value. This uniquely
2844 /// identifies the magic value.
2846
2847 /// Diagnoses the current set of gathered accesses. This happens at the end of
2848 /// each expression evaluation context. Diagnostics are emitted only for
2849 /// accesses gathered in the current evaluation context.
2851
2852 /// This function checks if the expression is in the sef of potentially
2853 /// misaligned members and it is converted to some pointer type T with lower
2854 /// or equal alignment requirements. If so it removes it. This is used when
2855 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2856 /// void*).
2857 void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
2858
2859 /// Returns true if `From` is a function or pointer to a function with the
2860 /// `cfi_unchecked_callee` attribute but `To` is a function or pointer to
2861 /// function without this attribute.
2862 bool DiscardingCFIUncheckedCallee(QualType From, QualType To) const;
2863
2864 /// This function calls Action when it determines that E designates a
2865 /// misaligned member due to the packed attribute. This is used to emit
2866 /// local diagnostics like in reference binding.
2868 Expr *E,
2869 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2870 Action);
2871
2872 enum class AtomicArgumentOrder { API, AST };
2874 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2875 SourceLocation RParenLoc, MultiExprArg Args,
2878
2879 /// Check to see if a given expression could have '.c_str()' called on it.
2880 bool hasCStrMethod(const Expr *E);
2881
2882 /// Diagnose pointers that are always non-null.
2883 /// \param E the expression containing the pointer
2884 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2885 /// compared to a null pointer
2886 /// \param IsEqual True when the comparison is equal to a null pointer
2887 /// \param Range Extra SourceRange to highlight in the diagnostic
2890 bool IsEqual, SourceRange Range);
2891
2892 /// CheckParmsForFunctionDef - Check that the parameters of the given
2893 /// function are appropriate for the definition of a function. This
2894 /// takes care of any checks that cannot be performed on the
2895 /// declaration itself, e.g., that the types of each of the function
2896 /// parameters are complete.
2898 bool CheckParameterNames);
2899
2900 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2901 /// pointer cast increases the alignment requirements.
2902 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2903
2904 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2905 /// to weak/__unsafe_unretained type.
2906 bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
2907
2908 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2909 /// to weak/__unsafe_unretained expression.
2910 void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
2911
2912 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2913 /// statement as a \p Body, and it is located on the same line.
2914 ///
2915 /// This helps prevent bugs due to typos, such as:
2916 /// if (condition);
2917 /// do_stuff();
2918 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2919 unsigned DiagID);
2920
2921 /// Warn if a for/while loop statement \p S, which is followed by
2922 /// \p PossibleBody, has a suspicious null statement as a body.
2923 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2924
2925 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2926 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2927 SourceLocation OpLoc);
2928
2929 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2931 const TypeSourceInfo *Derived);
2932
2933 /// CheckFunctionCall - Check a direct function call for various correctness
2934 /// and safety properties not strictly enforced by the C type system.
2935 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2936 const FunctionProtoType *Proto);
2937
2944
2945 /// \param FPOnly restricts the arguments to floating-point types.
2946 std::optional<QualType>
2947 BuiltinVectorMath(CallExpr *TheCall,
2950 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2951
2952 void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
2953 const Expr *ThisArg, ArrayRef<const Expr *> Args);
2954
2955 /// Handles the checks for format strings, non-POD arguments to vararg
2956 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2957 /// attributes and AArch64 SME attributes.
2958 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2959 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2960 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2961 VariadicCallType CallType);
2962
2963 /// Verify that two format strings (as understood by attribute(format) and
2964 /// attribute(format_matches) are compatible. If they are incompatible,
2965 /// diagnostics are emitted with the assumption that \c
2966 /// AuthoritativeFormatString is correct and
2967 /// \c TestedFormatString is wrong. If \c FunctionCallArg is provided,
2968 /// diagnostics will point to it and a note will refer to \c
2969 /// TestedFormatString or \c AuthoritativeFormatString as appropriate.
2970 bool
2972 const StringLiteral *AuthoritativeFormatString,
2973 const StringLiteral *TestedFormatString,
2974 const Expr *FunctionCallArg = nullptr);
2975
2976 /// Verify that one format string (as understood by attribute(format)) is
2977 /// self-consistent; for instance, that it doesn't have multiple positional
2978 /// arguments referring to the same argument in incompatible ways. Diagnose
2979 /// if it isn't.
2981
2982 /// \brief Enforce the bounds of a TCB
2983 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2984 /// directly calls other functions in the same TCB as marked by the
2985 /// enforce_tcb and enforce_tcb_leaf attributes.
2986 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2987 const NamedDecl *Callee);
2988
2989 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2990
2991 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2992 /// TheCall is a constant expression.
2993 bool BuiltinConstantArg(CallExpr *TheCall, unsigned ArgNum,
2994 llvm::APSInt &Result);
2995
2996 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2997 /// TheCall is a constant expression in the range [Low, High].
2998 bool BuiltinConstantArgRange(CallExpr *TheCall, unsigned ArgNum, int Low,
2999 int High, bool RangeIsError = true);
3000
3001 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
3002 /// TheCall is a constant expression is a multiple of Num..
3003 bool BuiltinConstantArgMultiple(CallExpr *TheCall, unsigned ArgNum,
3004 unsigned Multiple);
3005
3006 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
3007 /// constant expression representing a power of 2.
3008 bool BuiltinConstantArgPower2(CallExpr *TheCall, unsigned ArgNum);
3009
3010 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
3011 /// a constant expression representing an arbitrary byte value shifted left by
3012 /// a multiple of 8 bits.
3013 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, unsigned ArgNum,
3014 unsigned ArgBits);
3015
3016 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
3017 /// TheCall is a constant expression representing either a shifted byte value,
3018 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
3019 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
3020 /// Arm MVE intrinsics.
3021 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, unsigned ArgNum,
3022 unsigned ArgBits);
3023
3024 /// Checks that a call expression's argument count is at least the desired
3025 /// number. This is useful when doing custom type-checking on a variadic
3026 /// function. Returns true on error.
3027 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
3028
3029 /// Checks that a call expression's argument count is at most the desired
3030 /// number. This is useful when doing custom type-checking on a variadic
3031 /// function. Returns true on error.
3032 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
3033
3034 /// Checks that a call expression's argument count is in the desired range.
3035 /// This is useful when doing custom type-checking on a variadic function.
3036 /// Returns true on error.
3037 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
3038 unsigned MaxArgCount);
3039
3040 /// Checks that a call expression's argument count is the desired number.
3041 /// This is useful when doing custom type-checking. Returns true on error.
3042 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
3043
3045
3046 /// Returns true if the argument consists of one contiguous run of 1s with any
3047 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
3048 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
3049 /// since all 1s are not contiguous.
3050 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
3051
3053 bool *ICContext = nullptr,
3054 bool IsListInit = false);
3055
3056 /// Check for overflow behavior type related implicit conversion diagnostics.
3057 /// Returns true if OBT-related diagnostic was issued, false otherwise.
3059 SourceLocation CC);
3060
3061 bool
3066 CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr =
3068
3069private:
3070 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
3071 const ArraySubscriptExpr *ASE = nullptr,
3072 bool AllowOnePastEnd = true, bool IndexNegated = false);
3073 void CheckArrayAccess(const Expr *E);
3074
3075 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
3076 const FunctionProtoType *Proto);
3077
3078 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
3079 /// such as function pointers returned from functions.
3080 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
3081
3082 /// CheckConstructorCall - Check a constructor call for correctness and safety
3083 /// properties not enforced by the C type system.
3084 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
3086 const FunctionProtoType *Proto, SourceLocation Loc);
3087
3088 /// Warn if a pointer or reference argument passed to a function points to an
3089 /// object that is less aligned than the parameter. This can happen when
3090 /// creating a typedef with a lower alignment than the original type and then
3091 /// calling functions defined in terms of the original type.
3092 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
3093 StringRef ParamName, QualType ArgTy, QualType ParamTy);
3094
3095 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
3096
3097 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
3098 CallExpr *TheCall);
3099
3100 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
3101 CallExpr *TheCall);
3102
3103 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
3104
3105 /// Argument-value fortify checks for libc functions that are not builtins,
3106 /// dispatched by name (e.g. umask). Diagnostics belong to -Wfortify-source.
3107 void checkFortifiedLibcArgument(FunctionDecl *FD, CallExpr *TheCall);
3108
3109 /// Check the arguments to '__builtin_va_start', '__builtin_ms_va_start',
3110 /// or '__builtin_c23_va_start' for validity. Emit an error and return true
3111 /// on failure; return false on success.
3112 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
3113 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
3114
3115 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
3116 /// friends. This is declared to take (...), so we have to check everything.
3117 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
3118
3119 /// BuiltinSemaBuiltinFPClassification - Handle functions like
3120 /// __builtin_isnan and friends. This is declared to take (...), so we have
3121 /// to check everything.
3122 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
3123 unsigned BuiltinID);
3124
3125 /// Perform semantic analysis for a call to __builtin_complex.
3126 bool BuiltinComplex(CallExpr *TheCall);
3127 bool BuiltinOSLogFormat(CallExpr *TheCall);
3128
3129 /// BuiltinPrefetch - Handle __builtin_prefetch.
3130 /// This is declared to take (const void*, ...) and can take two
3131 /// optional constant int args.
3132 bool BuiltinPrefetch(CallExpr *TheCall);
3133
3134 /// Handle __builtin_alloca_with_align. This is declared
3135 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
3136 /// than 8.
3137 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
3138
3139 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
3140 bool BuiltinArithmeticFence(CallExpr *TheCall);
3141
3142 /// BuiltinAssume - Handle __assume (MS Extension).
3143 /// __assume does not evaluate its arguments, and should warn if its argument
3144 /// has side effects.
3145 bool BuiltinAssume(CallExpr *TheCall);
3146
3147 /// Handle __builtin_assume_aligned. This is declared
3148 /// as (const void*, size_t, ...) and can take one optional constant int arg.
3149 bool BuiltinAssumeAligned(CallExpr *TheCall);
3150
3151 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
3152 /// This checks that the target supports __builtin_longjmp and
3153 /// that val is a constant 1.
3154 bool BuiltinLongjmp(CallExpr *TheCall);
3155
3156 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
3157 /// This checks that the target supports __builtin_setjmp.
3158 bool BuiltinSetjmp(CallExpr *TheCall);
3159
3160 /// We have a call to a function like __sync_fetch_and_add, which is an
3161 /// overloaded function based on the pointer type of its first argument.
3162 /// The main BuildCallExpr routines have already promoted the types of
3163 /// arguments because all of these calls are prototyped as void(...).
3164 ///
3165 /// This function goes through and does final semantic checking for these
3166 /// builtins, as well as generating any warnings.
3167 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
3168
3169 /// BuiltinNontemporalOverloaded - We have a call to
3170 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
3171 /// overloaded function based on the pointer type of its last argument.
3172 ///
3173 /// This function goes through and does final semantic checking for these
3174 /// builtins.
3175 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
3176 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
3178
3179 /// \param FPOnly restricts the arguments to floating-point types.
3180 bool BuiltinElementwiseMath(CallExpr *TheCall,
3183 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
3184
3185 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
3186
3187 bool CheckInvalidBuiltinCountedByRef(const Expr *E,
3189 bool BuiltinCountedByRef(CallExpr *TheCall);
3190
3191 // Matrix builtin handling.
3192 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
3193 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
3194 ExprResult CallResult);
3195 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
3196 ExprResult CallResult);
3197
3198 /// CheckFormatArguments - Check calls to printf and scanf (and similar
3199 /// functions) for correct use of format strings.
3200 /// Returns true if a format string has been fully checked.
3201 bool CheckFormatArguments(const FormatAttr *Format,
3202 ArrayRef<const Expr *> Args, bool IsCXXMember,
3203 VariadicCallType CallType, SourceLocation Loc,
3204 SourceRange Range,
3205 llvm::SmallBitVector &CheckedVarArgs);
3206 bool CheckFormatString(const FormatMatchesAttr *Format,
3207 ArrayRef<const Expr *> Args, bool IsCXXMember,
3208 VariadicCallType CallType, SourceLocation Loc,
3209 SourceRange Range,
3210 llvm::SmallBitVector &CheckedVarArgs);
3211 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
3212 FormatArgumentPassingKind FAPK,
3213 StringLiteral *ReferenceFormatString,
3214 unsigned format_idx, unsigned firstDataArg,
3216 SourceLocation Loc, SourceRange range,
3217 llvm::SmallBitVector &CheckedVarArgs);
3218
3219 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
3220
3221 /// Warn when using the wrong abs() function.
3222 void CheckAbsoluteValueFunction(const CallExpr *Call,
3223 const FunctionDecl *FDecl);
3224
3225 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
3226
3227 /// Check for dangerous or invalid arguments to memset().
3228 ///
3229 /// This issues warnings on known problematic, dangerous or unspecified
3230 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
3231 /// function calls.
3232 ///
3233 /// \param Call The call expression to diagnose.
3234 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
3235 IdentifierInfo *FnName);
3236
3237 bool CheckSizeofMemaccessArgument(const Expr *SizeOfArg, const Expr *Dest,
3238 IdentifierInfo *FnName);
3239 // Warn if the user has made the 'size' argument to strlcpy or strlcat
3240 // be the size of the source, instead of the destination.
3241 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
3242
3243 // Warn on anti-patterns as the 'size' argument to strncat.
3244 // The correct size argument should look like following:
3245 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
3246 void CheckStrncatArguments(const CallExpr *Call,
3247 const IdentifierInfo *FnName);
3248
3249 /// Alerts the user that they are attempting to free a non-malloc'd object.
3250 void CheckFreeArguments(const CallExpr *E);
3251
3252 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
3253 SourceLocation ReturnLoc, bool isObjCMethod = false,
3254 const AttrVec *Attrs = nullptr,
3255 const FunctionDecl *FD = nullptr);
3256
3257 /// Diagnoses "dangerous" implicit conversions within the given
3258 /// expression (which is a full expression). Implements -Wconversion
3259 /// and -Wsign-compare.
3260 ///
3261 /// \param CC the "context" location of the implicit conversion, i.e.
3262 /// the most location of the syntactic entity requiring the implicit
3263 /// conversion
3264 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
3265
3266 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
3267 /// Input argument E is a logical expression.
3269
3270 /// Diagnose when expression is an integer constant expression and its
3271 /// evaluation results in integer overflow
3272 void CheckForIntOverflow(const Expr *E);
3273 void CheckUnsequencedOperations(const Expr *E);
3274
3275 /// Perform semantic checks on a completed expression. This will either
3276 /// be a full-expression or a default argument expression.
3277 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
3278 bool IsConstexpr = false);
3279
3280 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
3281 Expr *Init);
3282
3283 /// A map from magic value to type information.
3284 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
3285 TypeTagForDatatypeMagicValues;
3286
3287 /// Peform checks on a call of a function with argument_with_type_tag
3288 /// or pointer_with_type_tag attributes.
3289 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
3290 const ArrayRef<const Expr *> ExprArgs,
3291 SourceLocation CallSiteLoc);
3292
3293 /// Check if we are taking the address of a packed field
3294 /// as this may be a problem if the pointer value is dereferenced.
3295 void CheckAddressOfPackedMember(Expr *rhs);
3296
3297 /// Helper class that collects misaligned member designations and
3298 /// their location info for delayed diagnostics.
3299 struct MisalignedMember {
3300 Expr *E;
3301 RecordDecl *RD;
3302 ValueDecl *MD;
3303 CharUnits Alignment;
3304
3305 MisalignedMember() : E(), RD(), MD() {}
3306 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
3307 CharUnits Alignment)
3308 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
3309 explicit MisalignedMember(Expr *E)
3310 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
3311
3312 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
3313 };
3314
3315 /// Adds an expression to the set of gathered misaligned members.
3316 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
3317 CharUnits Alignment);
3318 ///@}
3319
3320 //
3321 //
3322 // -------------------------------------------------------------------------
3323 //
3324 //
3325
3326 /// \name C++ Coroutines
3327 /// Implementations are in SemaCoroutine.cpp
3328 ///@{
3329
3330public:
3331 /// The C++ "std::coroutine_traits" template, which is defined in
3332 /// <coroutine_traits>
3334
3336 StringRef Keyword);
3340
3343 UnresolvedLookupExpr *Lookup);
3345 Expr *Awaiter, bool IsImplicit = false);
3347 UnresolvedLookupExpr *Lookup);
3350 bool IsImplicit = false);
3355
3356 // As a clang extension, enforces that a non-coroutine function must be marked
3357 // with [[clang::coro_wrapper]] if it returns a type marked with
3358 // [[clang::coro_return_type]].
3359 // Expects that FD is not a coroutine.
3361 /// Lookup 'coroutine_traits' in std namespace and std::experimental
3362 /// namespace. The namespace found is recorded in Namespace.
3364 SourceLocation FuncLoc);
3365 /// Check that the expression co_await promise.final_suspend() shall not be
3366 /// potentially-throwing.
3367 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
3368
3369 ///@}
3370
3371 //
3372 //
3373 // -------------------------------------------------------------------------
3374 //
3375 //
3376
3377 /// \name C++ Scope Specifiers
3378 /// Implementations are in SemaCXXScopeSpec.cpp
3379 ///@{
3380
3381public:
3382 // Marks SS invalid if it represents an incomplete type.
3384 // Complete an enum decl, maybe without a scope spec.
3386 CXXScopeSpec *SS = nullptr);
3387
3388 /// Compute the DeclContext that is associated with the given type.
3389 ///
3390 /// \param T the type for which we are attempting to find a DeclContext.
3391 ///
3392 /// \returns the declaration context represented by the type T,
3393 /// or NULL if the declaration context cannot be computed (e.g., because it is
3394 /// dependent and not the current instantiation).
3396
3397 /// Compute the DeclContext that is associated with the given
3398 /// scope specifier.
3399 ///
3400 /// \param SS the C++ scope specifier as it appears in the source
3401 ///
3402 /// \param EnteringContext when true, we will be entering the context of
3403 /// this scope specifier, so we can retrieve the declaration context of a
3404 /// class template or class template partial specialization even if it is
3405 /// not the current instantiation.
3406 ///
3407 /// \returns the declaration context represented by the scope specifier @p SS,
3408 /// or NULL if the declaration context cannot be computed (e.g., because it is
3409 /// dependent and not the current instantiation).
3411 bool EnteringContext = false);
3413
3414 /// If the given nested name specifier refers to the current
3415 /// instantiation, return the declaration that corresponds to that
3416 /// current instantiation (C++0x [temp.dep.type]p1).
3417 ///
3418 /// \param NNS a dependent nested name specifier.
3420
3421 /// The parser has parsed a global nested-name-specifier '::'.
3422 ///
3423 /// \param CCLoc The location of the '::'.
3424 ///
3425 /// \param SS The nested-name-specifier, which will be updated in-place
3426 /// to reflect the parsed nested-name-specifier.
3427 ///
3428 /// \returns true if an error occurred, false otherwise.
3430
3431 /// The parser has parsed a '__super' nested-name-specifier.
3432 ///
3433 /// \param SuperLoc The location of the '__super' keyword.
3434 ///
3435 /// \param ColonColonLoc The location of the '::'.
3436 ///
3437 /// \param SS The nested-name-specifier, which will be updated in-place
3438 /// to reflect the parsed nested-name-specifier.
3439 ///
3440 /// \returns true if an error occurred, false otherwise.
3442 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
3443
3444 /// Determines whether the given declaration is an valid acceptable
3445 /// result for name lookup of a nested-name-specifier.
3446 /// \param SD Declaration checked for nested-name-specifier.
3447 /// \param IsExtension If not null and the declaration is accepted as an
3448 /// extension, the pointed variable is assigned true.
3450 bool *CanCorrect = nullptr);
3451
3452 /// If the given nested-name-specifier begins with a bare identifier
3453 /// (e.g., Base::), perform name lookup for that identifier as a
3454 /// nested-name-specifier within the given scope, and return the result of
3455 /// that name lookup.
3457
3458 /// Keeps information about an identifier in a nested-name-spec.
3459 ///
3461 /// The type of the object, if we're parsing nested-name-specifier in
3462 /// a member access expression.
3464
3465 /// The identifier preceding the '::'.
3467
3468 /// The location of the identifier.
3470
3471 /// The location of the '::'.
3473
3474 /// Creates info object for the most typical case.
3476 SourceLocation ColonColonLoc,
3479 CCLoc(ColonColonLoc) {}
3480
3482 SourceLocation ColonColonLoc, QualType ObjectType)
3484 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
3485 };
3486
3487 /// Build a new nested-name-specifier for "identifier::", as described
3488 /// by ActOnCXXNestedNameSpecifier.
3489 ///
3490 /// \param S Scope in which the nested-name-specifier occurs.
3491 /// \param IdInfo Parser information about an identifier in the
3492 /// nested-name-spec.
3493 /// \param EnteringContext If true, enter the context specified by the
3494 /// nested-name-specifier.
3495 /// \param SS Optional nested name specifier preceding the identifier.
3496 /// \param ScopeLookupResult Provides the result of name lookup within the
3497 /// scope of the nested-name-specifier that was computed at template
3498 /// definition time.
3499 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
3500 /// error recovery and what kind of recovery is performed.
3501 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
3502 /// are allowed. The bool value pointed by this parameter is set to
3503 /// 'true' if the identifier is treated as if it was followed by ':',
3504 /// not '::'.
3505 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3506 ///
3507 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
3508 /// that it contains an extra parameter \p ScopeLookupResult, which provides
3509 /// the result of name lookup within the scope of the nested-name-specifier
3510 /// that was computed at template definition time.
3511 ///
3512 /// If ErrorRecoveryLookup is true, then this call is used to improve error
3513 /// recovery. This means that it should not emit diagnostics, it should
3514 /// just return true on failure. It also means it should only return a valid
3515 /// scope if it *knows* that the result is correct. It should not return in a
3516 /// dependent context, for example. Nor will it extend \p SS with the scope
3517 /// specifier.
3518 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3519 bool EnteringContext, CXXScopeSpec &SS,
3520 NamedDecl *ScopeLookupResult,
3521 bool ErrorRecoveryLookup,
3522 bool *IsCorrectedToColon = nullptr,
3523 bool OnlyNamespace = false);
3524
3525 /// The parser has parsed a nested-name-specifier 'identifier::'.
3526 ///
3527 /// \param S The scope in which this nested-name-specifier occurs.
3528 ///
3529 /// \param IdInfo Parser information about an identifier in the
3530 /// nested-name-spec.
3531 ///
3532 /// \param EnteringContext Whether we're entering the context nominated by
3533 /// this nested-name-specifier.
3534 ///
3535 /// \param SS The nested-name-specifier, which is both an input
3536 /// parameter (the nested-name-specifier before this type) and an
3537 /// output parameter (containing the full nested-name-specifier,
3538 /// including this new type).
3539 ///
3540 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
3541 /// are allowed. The bool value pointed by this parameter is set to 'true'
3542 /// if the identifier is treated as if it was followed by ':', not '::'.
3543 ///
3544 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3545 ///
3546 /// \returns true if an error occurred, false otherwise.
3547 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3548 bool EnteringContext, CXXScopeSpec &SS,
3549 bool *IsCorrectedToColon = nullptr,
3550 bool OnlyNamespace = false);
3551
3552 /// The parser has parsed a nested-name-specifier
3553 /// 'template[opt] template-name < template-args >::'.
3554 ///
3555 /// \param S The scope in which this nested-name-specifier occurs.
3556 ///
3557 /// \param SS The nested-name-specifier, which is both an input
3558 /// parameter (the nested-name-specifier before this type) and an
3559 /// output parameter (containing the full nested-name-specifier,
3560 /// including this new type).
3561 ///
3562 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
3563 /// \param TemplateName the template name.
3564 /// \param TemplateNameLoc The location of the template name.
3565 /// \param LAngleLoc The location of the opening angle bracket ('<').
3566 /// \param TemplateArgs The template arguments.
3567 /// \param RAngleLoc The location of the closing angle bracket ('>').
3568 /// \param CCLoc The location of the '::'.
3569 ///
3570 /// \param EnteringContext Whether we're entering the context of the
3571 /// nested-name-specifier.
3572 ///
3573 ///
3574 /// \returns true if an error occurred, false otherwise.
3576 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
3577 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
3578 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
3579 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
3580
3582 SourceLocation ColonColonLoc);
3583
3585 CXXScopeSpec &SS, const DeclSpec &DS, TypeSourceInfo *PatternLoc,
3586 SourceLocation ColonColonLoc, QualType Type);
3587
3588 /// IsInvalidUnlessNestedName - This method is used for error recovery
3589 /// purposes to determine whether the specified identifier is only valid as
3590 /// a nested name specifier, for example a namespace name. It is
3591 /// conservatively correct to always return false from this method.
3592 ///
3593 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
3595 NestedNameSpecInfo &IdInfo,
3596 bool EnteringContext);
3597
3598 /// Given a C++ nested-name-specifier, produce an annotation value
3599 /// that the parser can use later to reconstruct the given
3600 /// nested-name-specifier.
3601 ///
3602 /// \param SS A nested-name-specifier.
3603 ///
3604 /// \returns A pointer containing all of the information in the
3605 /// nested-name-specifier \p SS.
3607
3608 /// Given an annotation pointer for a nested-name-specifier, restore
3609 /// the nested-name-specifier structure.
3610 ///
3611 /// \param Annotation The annotation pointer, produced by
3612 /// \c SaveNestedNameSpecifierAnnotation().
3613 ///
3614 /// \param AnnotationRange The source range corresponding to the annotation.
3615 ///
3616 /// \param SS The nested-name-specifier that will be updated with the contents
3617 /// of the annotation pointer.
3618 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
3619 SourceRange AnnotationRange,
3620 CXXScopeSpec &SS);
3621
3622 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
3623
3624 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
3625 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
3626 /// After this method is called, according to [C++ 3.4.3p3], names should be
3627 /// looked up in the declarator-id's scope, until the declarator is parsed and
3628 /// ActOnCXXExitDeclaratorScope is called.
3629 /// The 'SS' should be a non-empty valid CXXScopeSpec.
3631
3632 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
3633 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
3634 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
3635 /// Used to indicate that names should revert to being looked up in the
3636 /// defining scope.
3638
3639 ///@}
3640
3641 //
3642 //
3643 // -------------------------------------------------------------------------
3644 //
3645 //
3646
3647 /// \name Declarations
3648 /// Implementations are in SemaDecl.cpp
3649 ///@{
3650
3651public:
3653
3654 /// The index of the first InventedParameterInfo that refers to the current
3655 /// context.
3657
3658 /// A RAII object to temporarily push a declaration context.
3660 private:
3661 Sema &S;
3662 DeclContext *SavedContext;
3663 ProcessingContextState SavedContextState;
3664 QualType SavedCXXThisTypeOverride;
3665 unsigned SavedFunctionScopesStart;
3666 unsigned SavedInventedParameterInfosStart;
3667
3668 public:
3669 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3670 : S(S), SavedContext(S.CurContext),
3671 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3672 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3673 SavedFunctionScopesStart(S.FunctionScopesStart),
3674 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3675 assert(ContextToPush && "pushing null context");
3676 S.CurContext = ContextToPush;
3677 if (NewThisContext)
3678 S.CXXThisTypeOverride = QualType();
3679 // Any saved FunctionScopes do not refer to this context.
3680 S.FunctionScopesStart = S.FunctionScopes.size();
3681 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3682 }
3683
3684 void pop() {
3685 if (!SavedContext)
3686 return;
3687 S.CurContext = SavedContext;
3688 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3689 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3690 S.FunctionScopesStart = SavedFunctionScopesStart;
3691 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3692 SavedContext = nullptr;
3693 }
3694
3696 ContextRAII(const ContextRAII &) = delete;
3698 };
3699
3700 void DiagnoseInvalidJumps(Stmt *Body);
3701
3702 /// The function definitions which were renamed as part of typo-correction
3703 /// to match their respective declarations. We want to keep track of them
3704 /// to ensure that we don't emit a "redefinition" error if we encounter a
3705 /// correctly named definition after the renamed definition.
3707
3708 /// A cache of the flags available in enumerations with the flag_enum
3709 /// attribute.
3710 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3711
3712 /// A cache of enumerator values for enums checked by -Wassign-enum.
3713 llvm::DenseMap<const EnumDecl *, llvm::SmallVector<llvm::APSInt>>
3715
3716 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3717 /// declared. Rare. May alias another identifier, declared or undeclared.
3718 ///
3719 /// For aliases, the target identifier is used as a key for eventual
3720 /// processing when the target is declared. For the single-identifier form,
3721 /// the sole identifier is used as the key. Each entry is a `SetVector`
3722 /// (ordered by parse order) of aliases (identified by the alias name) in case
3723 /// of multiple aliases to the same undeclared identifier.
3724 llvm::MapVector<
3726 llvm::SetVector<
3728 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3730
3731 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3732 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3733 /// to define functions that occur in multiple standards to call the version
3734 /// in the currently selected standard.
3735 llvm::MapVector<IdentifierInfo *, AsmLabelAttr *>
3737
3738 /// Set containing all typedefs that are likely unused.
3741
3742 /// Store UnusedLocalTypedefNameCandidates in \p Sorted in a deterministic
3743 /// order.
3746
3747 typedef LazyVector<const DeclaratorDecl *,
3750
3751 /// The set of file scoped decls seen so far that have not been used
3752 /// and must warn if not used. Only contains the first declaration.
3754
3756 2, 2>
3758
3759 /// All the tentative definitions encountered in the TU.
3761
3762 /// All the external declarations encoutered and used in the TU.
3764
3765 /// Generally null except when we temporarily switch decl contexts,
3766 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3768
3769 /// Is the module scope we are in a C++ Header Unit?
3771 return ModuleScopes.empty() ? false
3772 : ModuleScopes.back().Module->isHeaderUnit();
3773 }
3774
3775 /// Get the module owning an entity.
3776 Module *getOwningModule(const Decl *Entity) {
3777 return Entity->getOwningModule();
3778 }
3779
3780 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3781
3783 /// Returns the TypeDeclType for the given type declaration,
3784 /// as ASTContext::getTypeDeclType would, but
3785 /// performs the required semantic checks for name lookup of said entity.
3786 void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD,
3787 SourceLocation NameLoc);
3788
3789 /// If the identifier refers to a type name within this scope,
3790 /// return the declaration of that type.
3791 ///
3792 /// This routine performs ordinary name lookup of the identifier II
3793 /// within the given scope, with optional C++ scope specifier SS, to
3794 /// determine whether the name refers to a type. If so, returns an
3795 /// opaque pointer (actually a QualType) corresponding to that
3796 /// type. Otherwise, returns NULL.
3798 Scope *S, CXXScopeSpec *SS = nullptr,
3799 bool isClassName = false, bool HasTrailingDot = false,
3800 ParsedType ObjectType = nullptr,
3801 bool IsCtorOrDtorName = false,
3802 bool WantNontrivialTypeSourceInfo = false,
3803 bool IsClassTemplateDeductionContext = true,
3804 ImplicitTypenameContext AllowImplicitTypename =
3806 IdentifierInfo **CorrectedII = nullptr);
3807
3808 /// isTagName() - This method is called *for error recovery purposes only*
3809 /// to determine if the specified name is a valid tag name ("struct foo"). If
3810 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3811 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3812 /// diagnose cases in C where the user forgot to specify the tag.
3814
3815 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3816 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3817 /// then downgrade the missing typename error to a warning.
3818 /// This is needed for MSVC compatibility; Example:
3819 /// @code
3820 /// template<class T> class A {
3821 /// public:
3822 /// typedef int TYPE;
3823 /// };
3824 /// template<class T> class B : public A<T> {
3825 /// public:
3826 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3827 /// };
3828 /// @endcode
3829 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3831 Scope *S, CXXScopeSpec *SS,
3832 ParsedType &SuggestedType,
3833 bool IsTemplateName = false);
3834
3835 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3836 /// type name has failed in a dependent context. In these situations, we
3837 /// automatically form a DependentTypeName that will retry lookup in a related
3838 /// scope during instantiation.
3840 SourceLocation NameLoc,
3841 bool IsTemplateTypeArg);
3842
3843 class NameClassification {
3845 union {
3850 };
3851
3852 explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
3853
3854 public:
3857
3860
3861 static NameClassification Error() {
3862 return NameClassification(NameClassificationKind::Error);
3863 }
3864
3865 static NameClassification Unknown() {
3866 return NameClassification(NameClassificationKind::Unknown);
3867 }
3868
3869 static NameClassification OverloadSet(ExprResult E) {
3870 NameClassification Result(NameClassificationKind::OverloadSet);
3871 Result.Expr = E;
3872 return Result;
3873 }
3874
3875 static NameClassification NonType(NamedDecl *D) {
3876 NameClassification Result(NameClassificationKind::NonType);
3877 Result.NonTypeDecl = D;
3878 return Result;
3879 }
3880
3881 static NameClassification UndeclaredNonType() {
3882 return NameClassification(NameClassificationKind::UndeclaredNonType);
3883 }
3884
3885 static NameClassification DependentNonType() {
3886 return NameClassification(NameClassificationKind::DependentNonType);
3887 }
3888
3889 static NameClassification TypeTemplate(TemplateName Name) {
3890 NameClassification Result(NameClassificationKind::TypeTemplate);
3891 Result.Template = Name;
3892 return Result;
3893 }
3894
3895 static NameClassification VarTemplate(TemplateName Name) {
3896 NameClassification Result(NameClassificationKind::VarTemplate);
3897 Result.Template = Name;
3898 return Result;
3899 }
3900
3901 static NameClassification FunctionTemplate(TemplateName Name) {
3903 Result.Template = Name;
3904 return Result;
3905 }
3906
3907 static NameClassification Concept(TemplateName Name) {
3908 NameClassification Result(NameClassificationKind::Concept);
3909 Result.Template = Name;
3910 return Result;
3911 }
3912
3913 static NameClassification UndeclaredTemplate(TemplateName Name) {
3915 Result.Template = Name;
3916 return Result;
3917 }
3918
3919 NameClassificationKind getKind() const { return Kind; }
3920
3923 return Expr;
3924 }
3925
3927 assert(Kind == NameClassificationKind::Type);
3928 return Type;
3929 }
3930
3932 assert(Kind == NameClassificationKind::NonType);
3933 return NonTypeDecl;
3934 }
3935
3944
3946 switch (Kind) {
3948 return TNK_Type_template;
3950 return TNK_Function_template;
3952 return TNK_Var_template;
3954 return TNK_Concept_template;
3957 default:
3958 llvm_unreachable("unsupported name classification.");
3959 }
3960 }
3961 };
3962
3963 /// Perform name lookup on the given name, classifying it based on
3964 /// the results of name lookup and the following token.
3965 ///
3966 /// This routine is used by the parser to resolve identifiers and help direct
3967 /// parsing. When the identifier cannot be found, this routine will attempt
3968 /// to correct the typo and classify based on the resulting name.
3969 ///
3970 /// \param S The scope in which we're performing name lookup.
3971 ///
3972 /// \param SS The nested-name-specifier that precedes the name.
3973 ///
3974 /// \param Name The identifier. If typo correction finds an alternative name,
3975 /// this pointer parameter will be updated accordingly.
3976 ///
3977 /// \param NameLoc The location of the identifier.
3978 ///
3979 /// \param NextToken The token following the identifier. Used to help
3980 /// disambiguate the name.
3981 ///
3982 /// \param CCC The correction callback, if typo correction is desired.
3983 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3984 IdentifierInfo *&Name, SourceLocation NameLoc,
3985 const Token &NextToken,
3986 CorrectionCandidateCallback *CCC = nullptr);
3987
3988 /// Act on the result of classifying a name as an undeclared (ADL-only)
3989 /// non-type declaration.
3991 SourceLocation NameLoc);
3992 /// Act on the result of classifying a name as an undeclared member of a
3993 /// dependent base class.
3995 IdentifierInfo *Name,
3996 SourceLocation NameLoc,
3997 bool IsAddressOfOperand);
3998 /// Act on the result of classifying a name as a specific non-type
3999 /// declaration.
4002 SourceLocation NameLoc,
4003 const Token &NextToken);
4004 /// Act on the result of classifying a name as an overload set.
4006
4007 /// Describes the detailed kind of a template name. Used in diagnostics.
4019
4020 /// Determine whether it's plausible that E was intended to be a
4021 /// template-name.
4023 if (!getLangOpts().CPlusPlus || E.isInvalid())
4024 return false;
4025 Dependent = false;
4026 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
4027 return !DRE->hasExplicitTemplateArgs();
4028 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
4029 return !ME->hasExplicitTemplateArgs();
4030 Dependent = true;
4031 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
4032 return !DSDRE->hasExplicitTemplateArgs();
4033 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
4034 return !DSME->hasExplicitTemplateArgs();
4035 // Any additional cases recognized here should also be handled by
4036 // diagnoseExprIntendedAsTemplateName.
4037 return false;
4038 }
4039
4040 void warnOnReservedIdentifier(const NamedDecl *D);
4042
4043 void ProcessPragmaExport(DeclaratorDecl *newDecl);
4044
4046
4048 MultiTemplateParamsArg TemplateParameterLists);
4049
4050 /// Attempt to fold a variable-sized type to a constant-sized type, returning
4051 /// true if we were successful.
4053 SourceLocation Loc,
4054 unsigned FailedFoldDiagID);
4055
4056 /// Register the given locally-scoped extern "C" declaration so
4057 /// that it can be found later for redeclarations. We include any extern "C"
4058 /// declaration that is not visible in the translation unit here, not just
4059 /// function-scope declarations.
4061
4062 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
4063 /// If T is the name of a class, then each of the following shall have a
4064 /// name different from T:
4065 /// - every static data member of class T;
4066 /// - every member function of class T
4067 /// - every member of class T that is itself a type;
4068 /// \returns true if the declaration name violates these rules.
4070
4071 /// Diagnose a declaration whose declarator-id has the given
4072 /// nested-name-specifier.
4073 ///
4074 /// \param SS The nested-name-specifier of the declarator-id.
4075 ///
4076 /// \param DC The declaration context to which the nested-name-specifier
4077 /// resolves.
4078 ///
4079 /// \param Name The name of the entity being declared.
4080 ///
4081 /// \param Loc The location of the name of the entity being declared.
4082 ///
4083 /// \param IsMemberSpecialization Whether we are declaring a member
4084 /// specialization.
4085 ///
4086 /// \param TemplateId The template-id, if any.
4087 ///
4088 /// \returns true if we cannot safely recover from this error, false
4089 /// otherwise.
4092 TemplateIdAnnotation *TemplateId,
4093 bool IsMemberSpecialization);
4094
4096
4097 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
4098
4100 unsigned &IntVal);
4101
4102 /// Diagnose function specifiers on a declaration of an identifier that
4103 /// does not identify a function.
4104 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
4105
4106 /// Return the declaration shadowed by the given typedef \p D, or null
4107 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
4109 const LookupResult &R);
4110
4111 /// Return the declaration shadowed by the given variable \p D, or null
4112 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
4114
4115 /// Return the declaration shadowed by the given variable \p D, or null
4116 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
4118 const LookupResult &R);
4119 /// Diagnose variable or built-in function shadowing. Implements
4120 /// -Wshadow.
4121 ///
4122 /// This method is called whenever a VarDecl is added to a "useful"
4123 /// scope.
4124 ///
4125 /// \param ShadowedDecl the declaration that is shadowed by the given variable
4126 /// \param R the lookup of the name
4127 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
4128 const LookupResult &R);
4129
4130 /// Check -Wshadow without the advantage of a previous lookup.
4131 void CheckShadow(Scope *S, VarDecl *D);
4132
4133 /// Warn if 'E', which is an expression that is about to be modified, refers
4134 /// to a shadowing declaration.
4136
4137 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
4138 /// when these variables are captured by the lambda.
4140
4141 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
4142 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
4143 TypedefNameDecl *NewTD);
4146 TypeSourceInfo *TInfo,
4148
4149 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
4150 /// declares a typedef-name, either using the 'typedef' type specifier or via
4151 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
4155 TypeSourceInfo *TInfo,
4157 MultiTemplateParamsArg TemplateParamLists,
4158 bool &AddToScope,
4160
4161private:
4162 // Perform a check on an AsmLabel to verify its consistency and emit
4163 // diagnostics in case of an error.
4164 void CheckAsmLabel(Scope *S, Expr *AsmLabelExpr, StorageClass SC,
4165 TypeSourceInfo *TInfo, VarDecl *);
4166
4167public:
4168 /// Perform semantic checking on a newly-created variable
4169 /// declaration.
4170 ///
4171 /// This routine performs all of the type-checking required for a
4172 /// variable declaration once it has been built. It is used both to
4173 /// check variables after they have been parsed and their declarators
4174 /// have been translated into a declaration, and to check variables
4175 /// that have been instantiated from a template.
4176 ///
4177 /// Sets NewVD->isInvalidDecl() if an error was encountered.
4178 ///
4179 /// Returns true if the variable declaration is a redeclaration.
4180 bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
4181 void CheckVariableDeclarationType(VarDecl *NewVD);
4182 void CheckCompleteVariableDeclaration(VarDecl *VD);
4183
4184 NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
4185 TypeSourceInfo *TInfo,
4186 LookupResult &Previous,
4187 MultiTemplateParamsArg TemplateParamLists,
4188 bool &AddToScope);
4189
4190 /// Attach the ABI tag a standard calling convention variant requires, as an
4191 /// implicit abi_tag attribute. Call this once the function type is final.
4192 void addImplicitCallingConvAbiTag(FunctionDecl *FD);
4193
4194 /// AddOverriddenMethods - See if a method overrides any in the base classes,
4195 /// and if so, check that it's a valid override and remember it.
4196 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
4197
4198 /// Perform semantic checking of a new function declaration.
4199 ///
4200 /// Performs semantic analysis of the new function declaration
4201 /// NewFD. This routine performs all semantic checking that does not
4202 /// require the actual declarator involved in the declaration, and is
4203 /// used both for the declaration of functions as they are parsed
4204 /// (called via ActOnDeclarator) and for the declaration of functions
4205 /// that have been instantiated via C++ template instantiation (called
4206 /// via InstantiateDecl).
4207 ///
4208 /// \param IsMemberSpecialization whether this new function declaration is
4209 /// a member specialization (that replaces any definition provided by the
4210 /// previous declaration).
4211 ///
4212 /// This sets NewFD->isInvalidDecl() to true if there was an error.
4213 ///
4214 /// \returns true if the function declaration is a redeclaration.
4215 bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
4216 LookupResult &Previous,
4217 bool IsMemberSpecialization, bool DeclIsDefn);
4218
4219 /// Checks if the new declaration declared in dependent context must be
4220 /// put in the same redeclaration chain as the specified declaration.
4221 ///
4222 /// \param D Declaration that is checked.
4223 /// \param PrevDecl Previous declaration found with proper lookup method for
4224 /// the same declaration name.
4225 /// \returns True if D must be added to the redeclaration chain which PrevDecl
4226 /// belongs to.
4227 bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
4228
4229 /// Determines if we can perform a correct type check for \p D as a
4230 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
4231 /// best-effort check.
4232 ///
4233 /// \param NewD The new declaration.
4234 /// \param OldD The old declaration.
4235 /// \param NewT The portion of the type of the new declaration to check.
4236 /// \param OldT The portion of the type of the old declaration to check.
4237 bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
4238 QualType NewT, QualType OldT);
4239 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
4240 void CheckMSVCRTEntryPoint(FunctionDecl *FD);
4241
4242 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
4243 /// containing class. Otherwise it will return implicit SectionAttr if the
4244 /// function is a definition and there is an active value on CodeSegStack
4245 /// (from the current #pragma code-seg value).
4246 ///
4247 /// \param FD Function being declared.
4248 /// \param IsDefinition Whether it is a definition or just a declaration.
4249 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
4250 /// nullptr if no attribute should be added.
4251 Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
4252 bool IsDefinition);
4253
4254 /// Common checks for a parameter-declaration that should apply to both
4255 /// function parameters and non-type template parameters.
4256 void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
4257
4258 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
4259 /// to introduce parameters into function prototype scope.
4260 Decl *ActOnParamDeclarator(Scope *S, Declarator &D,
4261 SourceLocation ExplicitThisLoc = {});
4262
4263 /// Synthesizes a variable for a parameter arising from a
4264 /// typedef.
4265 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
4266 QualType T);
4267 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
4268 SourceLocation NameLoc,
4269 const IdentifierInfo *Name, QualType T,
4270 TypeSourceInfo *TSInfo, StorageClass SC);
4271
4272 /// Emit diagnostics if the initializer or any of its explicit or
4273 /// implicitly-generated subexpressions require copying or
4274 /// default-initializing a type that is or contains a C union type that is
4275 /// non-trivial to copy or default-initialize.
4276 void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc);
4277
4278 // These flags are passed to checkNonTrivialCUnion.
4284
4285 /// Emit diagnostics if a non-trivial C union type or a struct that contains
4286 /// a non-trivial C union is used in an invalid context.
4288 NonTrivialCUnionContext UseContext,
4289 unsigned NonTrivialKind);
4290
4291 /// Certain globally-unique variables might be accidentally duplicated if
4292 /// built into multiple shared libraries with hidden visibility. This can
4293 /// cause problems if the variable is mutable, its initialization is
4294 /// effectful, or its address is taken.
4297
4298 /// AddInitializerToDecl - Adds the initializer Init to the
4299 /// declaration dcl. If DirectInit is true, this is C++ direct
4300 /// initialization rather than copy initialization.
4301 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
4302 void ActOnUninitializedDecl(Decl *dcl);
4303
4304 /// ActOnInitializerError - Given that there was an error parsing an
4305 /// initializer for the given declaration, try to at least re-establish
4306 /// invariants such as whether a variable's type is either dependent or
4307 /// complete.
4308 void ActOnInitializerError(Decl *Dcl);
4309
4310 void ActOnCXXForRangeDecl(Decl *D, bool InExpansionStmt);
4312 IdentifierInfo *Ident,
4313 ParsedAttributes &Attrs);
4314
4315 /// Check if VD needs to be dllexport/dllimport due to being in a
4316 /// dllexport/import function.
4319
4320 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
4321 /// any semantic actions necessary after any initializer has been attached.
4322 void FinalizeDeclaration(Decl *D);
4324 ArrayRef<Decl *> Group);
4325
4326 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
4327 /// group, performing any necessary semantic checking.
4329
4330 /// Should be called on all declarations that might have attached
4331 /// documentation comments.
4332 void ActOnDocumentableDecl(Decl *D);
4334
4335 enum class FnBodyKind {
4336 /// C++26 [dcl.fct.def.general]p1
4337 /// function-body:
4338 /// ctor-initializer[opt] compound-statement
4339 /// function-try-block
4341 /// = default ;
4343 /// deleted-function-body
4344 ///
4345 /// deleted-function-body:
4346 /// = delete ;
4347 /// = delete ( unevaluated-string ) ;
4349 };
4350
4352 SourceLocation LocAfterDecls);
4354 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
4355 SkipBodyInfo *SkipBody = nullptr);
4357 MultiTemplateParamsArg TemplateParamLists,
4358 SkipBodyInfo *SkipBody = nullptr,
4359 FnBodyKind BodyKind = FnBodyKind::Other);
4361 SkipBodyInfo *SkipBody = nullptr,
4362 FnBodyKind BodyKind = FnBodyKind::Other);
4364
4365 /// Determine whether we can delay parsing the body of a function or
4366 /// function template until it is used, assuming we don't care about emitting
4367 /// code for that function.
4368 ///
4369 /// This will be \c false if we may need the body of the function in the
4370 /// middle of parsing an expression (where it's impractical to switch to
4371 /// parsing a different function), for instance, if it's constexpr in C++11
4372 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
4373 bool canDelayFunctionBody(const Declarator &D);
4374
4375 /// Determine whether we can skip parsing the body of a function
4376 /// definition, assuming we don't care about analyzing its body or emitting
4377 /// code for that function.
4378 ///
4379 /// This will be \c false only if we may need the body of the function in
4380 /// order to parse the rest of the program (for instance, if it is
4381 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
4382 bool canSkipFunctionBody(Decl *D);
4383
4384 /// Given the set of return statements within a function body,
4385 /// compute the variables that are subject to the named return value
4386 /// optimization.
4387 ///
4388 /// Each of the variables that is subject to the named return value
4389 /// optimization will be marked as NRVO variables in the AST, and any
4390 /// return statement that has a marked NRVO variable as its NRVO candidate can
4391 /// use the named return value optimization.
4392 ///
4393 /// This function applies a very simplistic algorithm for NRVO: if every
4394 /// return statement in the scope of a variable has the same NRVO candidate,
4395 /// that candidate is an NRVO variable.
4397
4398 /// Performs semantic analysis at the end of a function body.
4399 ///
4400 /// \param RetainFunctionScopeInfo If \c true, the client is responsible for
4401 /// releasing the associated \p FunctionScopeInfo. This is useful when
4402 /// building e.g. LambdaExprs.
4404 bool IsInstantiation = false,
4405 bool RetainFunctionScopeInfo = false);
4408
4409 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
4410 /// attribute for which parsing is delayed.
4412
4413 /// Diagnose any unused parameters in the given sequence of
4414 /// ParmVarDecl pointers.
4416
4417 /// Diagnose whether the size of parameters or return value of a
4418 /// function or obj-c method definition is pass-by-value and larger than a
4419 /// specified threshold.
4420 void
4422 QualType ReturnTy, NamedDecl *D);
4423
4425 SourceLocation RParenLoc);
4426
4429
4430 void ActOnPopScope(SourceLocation Loc, Scope *S);
4431
4432 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4433 /// no declarator (e.g. "struct foo;") is parsed.
4435 const ParsedAttributesView &DeclAttrs,
4436 RecordDecl *&AnonRecord);
4437
4438 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4439 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
4440 /// parameters to cope with template friend declarations.
4442 const ParsedAttributesView &DeclAttrs,
4443 MultiTemplateParamsArg TemplateParams,
4444 bool IsExplicitInstantiation,
4445 RecordDecl *&AnonRecord,
4446 SourceLocation EllipsisLoc = {});
4447
4448 /// BuildAnonymousStructOrUnion - Handle the declaration of an
4449 /// anonymous structure or union. Anonymous unions are a C++ feature
4450 /// (C++ [class.union]) and a C11 feature; anonymous structures
4451 /// are a C11 feature and GNU C++ extension.
4452 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
4453 RecordDecl *Record,
4454 const PrintingPolicy &Policy);
4455
4456 /// Called once it is known whether
4457 /// a tag declaration is an anonymous union or struct.
4459
4460 /// Emit diagnostic warnings for placeholder members.
4461 /// We can only do that after the class is fully constructed,
4462 /// as anonymous union/structs can insert placeholders
4463 /// in their parent scope (which might be a Record).
4465
4466 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
4467 /// Microsoft C anonymous structure.
4468 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
4469 /// Example:
4470 ///
4471 /// struct A { int a; };
4472 /// struct B { struct A; int b; };
4473 ///
4474 /// void foo() {
4475 /// B var;
4476 /// var.a = 3;
4477 /// }
4478 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
4479 RecordDecl *Record);
4480
4481 /// Given a non-tag type declaration, returns an enum useful for indicating
4482 /// what kind of non-tag type this is.
4483 NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
4484
4485 /// Determine whether a tag with a given kind is acceptable
4486 /// as a redeclaration of the given tag declaration.
4487 ///
4488 /// \returns true if the new tag kind is acceptable, false otherwise.
4490 bool isDefinition, SourceLocation NewTagLoc,
4491 const IdentifierInfo *Name);
4492
4493 /// This is invoked when we see 'struct foo' or 'struct {'. In the
4494 /// former case, Name will be non-null. In the later case, Name will be null.
4495 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
4496 /// a reference/declaration/definition of a tag.
4497 ///
4498 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
4499 /// trailing-type-specifier) other than one in an alias-declaration.
4500 ///
4501 /// \param SkipBody If non-null, will be set to indicate if the caller should
4502 /// skip the definition of this tag and treat it as if it were a declaration.
4503 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
4504 SourceLocation KWLoc, CXXScopeSpec &SS,
4505 IdentifierInfo *Name, SourceLocation NameLoc,
4506 const ParsedAttributesView &Attr, AccessSpecifier AS,
4507 SourceLocation ModulePrivateLoc,
4508 MultiTemplateParamsArg TemplateParameterLists,
4509 bool &OwnedDecl, bool &IsDependent,
4510 SourceLocation ScopedEnumKWLoc,
4511 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
4512 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
4513 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
4514
4515 /// ActOnField - Each field of a C struct/union is passed into this in order
4516 /// to create a FieldDecl object for it.
4517 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
4518 Declarator &D, Expr *BitfieldWidth);
4519
4520 /// HandleField - Analyze a field of a C struct or a C++ data member.
4521 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
4522 Declarator &D, Expr *BitfieldWidth,
4523 InClassInitStyle InitStyle, AccessSpecifier AS);
4524
4525 /// Build a new FieldDecl and check its well-formedness.
4526 ///
4527 /// This routine builds a new FieldDecl given the fields name, type,
4528 /// record, etc. \p PrevDecl should refer to any previous declaration
4529 /// with the same name and in the same scope as the field to be
4530 /// created.
4531 ///
4532 /// \returns a new FieldDecl.
4533 ///
4534 /// \todo The Declarator argument is a hack. It will be removed once
4535 FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
4536 TypeSourceInfo *TInfo, RecordDecl *Record,
4537 SourceLocation Loc, bool Mutable,
4538 Expr *BitfieldWidth, InClassInitStyle InitStyle,
4539 SourceLocation TSSL, AccessSpecifier AS,
4540 NamedDecl *PrevDecl, Declarator *D = nullptr);
4541
4543
4544 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
4545 /// class and class extensions. For every class \@interface and class
4546 /// extension \@interface, if the last ivar is a bitfield of any type,
4547 /// then add an implicit `char :0` ivar to the end of that interface.
4548 void ActOnLastBitfield(SourceLocation DeclStart,
4549 SmallVectorImpl<Decl *> &AllIvarDecls);
4550
4551 // This is used for both record definitions and ObjC interface declarations.
4552 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
4553 ArrayRef<Decl *> Fields, SourceLocation LBrac,
4554 SourceLocation RBrac, const ParsedAttributesView &AttrList);
4555
4556 /// ActOnTagStartDefinition - Invoked when we have entered the
4557 /// scope of a tag's definition (e.g., for an enumeration, class,
4558 /// struct, or union).
4559 void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
4560
4561 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
4562 /// Differently from C++, actually parse the body and reject / error out
4563 /// in case of a structural mismatch.
4564 bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody);
4565
4567
4568 /// Invoked when we enter a tag definition that we're skipping.
4570
4571 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
4572 /// C++ record definition's base-specifiers clause and are starting its
4573 /// member declarations.
4575 SourceLocation FinalLoc,
4576 bool IsFinalSpelledSealed,
4577 bool IsAbstract,
4578 SourceLocation LBraceLoc);
4579
4580 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
4581 /// the definition of a tag (enumeration, class, struct, or union).
4583 SourceRange BraceRange);
4584
4587
4589
4590 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
4591 /// error parsing the definition of a tag.
4593
4595 EnumConstantDecl *LastEnumConst,
4596 SourceLocation IdLoc, IdentifierInfo *Id,
4597 Expr *val);
4598
4599 /// Check that this is a valid underlying type for an enum declaration.
4601
4602 /// Check whether this is a valid redeclaration of a previous enumeration.
4603 /// \return true if the redeclaration was invalid.
4604 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
4605 QualType EnumUnderlyingTy, bool IsFixed,
4606 const EnumDecl *Prev);
4607
4608 /// Determine whether the body of an anonymous enumeration should be skipped.
4609 /// \param II The name of the first enumerator.
4611 SourceLocation IILoc);
4612
4613 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
4614 SourceLocation IdLoc, IdentifierInfo *Id,
4615 const ParsedAttributesView &Attrs,
4616 SourceLocation EqualLoc, Expr *Val,
4617 SkipBodyInfo *SkipBody = nullptr);
4618 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
4619 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
4620 const ParsedAttributesView &Attr);
4621
4622 /// Set the current declaration context until it gets popped.
4623 void PushDeclContext(Scope *S, DeclContext *DC);
4624 void PopDeclContext();
4625
4626 /// EnterDeclaratorContext - Used when we must lookup names in the context
4627 /// of a declarator's nested name specifier.
4630
4631 /// Enter a template parameter scope, after it's been associated with a
4632 /// particular DeclContext. Causes lookup within the scope to chain through
4633 /// enclosing contexts in the correct order.
4635
4636 /// Push the parameters of D, which must be a function, into scope.
4638
4639 /// Add \p Params to scope, so a late-parsed attribute can name them.
4642 /// Undo the above, for when \p S outlives the attribute so no scope pop
4643 /// removes them.
4647
4648 /// Add this decl to the scope shadowed decl chains.
4649 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4650
4651 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4652 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4653 /// true if 'D' belongs to the given declaration context.
4654 ///
4655 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4656 /// enclosing namespace set of the context, rather than contained
4657 /// directly within it.
4658 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4659 bool AllowInlineNamespace = false) const;
4660
4661 /// Determine whether a tag-like declaration found by lookup can be
4662 /// redeclared in the given scope. If lookup found a using-shadow, also
4663 /// consider the scope of the declaration named by the using-shadow.
4665 Scope *S = nullptr,
4666 bool AllowInlineNamespace = false) const;
4667
4668 /// Finds the scope corresponding to the given decl context, if it
4669 /// happens to be an enclosing scope. Otherwise return NULL.
4671
4672 /// Subroutines of ActOnDeclarator().
4674 TypeSourceInfo *TInfo);
4676
4677 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4679 NamedDecl *New, Decl *Old,
4681
4682 /// CheckAttributesOnDeducedType - Calls Sema functions for attributes that
4683 /// requires the type to be deduced.
4685
4686 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4687 /// same name and scope as a previous declaration 'Old'. Figure out
4688 /// how to resolve this situation, merging decls or emitting
4689 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4691 LookupResult &OldDecls);
4692
4693 /// CleanupMergedEnum - We have just merged the decl 'New' by making another
4694 /// definition visible.
4695 /// This method performs any necessary cleanup on the parser state to discard
4696 /// child nodes from newly parsed decl we are retiring.
4697 void CleanupMergedEnum(Scope *S, Decl *New);
4698
4699 /// MergeFunctionDecl - We just parsed a function 'New' from
4700 /// declarator D which has the same name and scope as a previous
4701 /// declaration 'Old'. Figure out how to resolve this situation,
4702 /// merging decls or emitting diagnostics as appropriate.
4703 ///
4704 /// In C++, New and Old must be declarations that are not
4705 /// overloaded. Use IsOverload to determine whether New and Old are
4706 /// overloaded, and to select the Old declaration that New should be
4707 /// merged with.
4708 ///
4709 /// Returns true if there was an error, false otherwise.
4711 bool MergeTypeWithOld, bool NewDeclIsDefn);
4712
4713 /// Completes the merge of two function declarations that are
4714 /// known to be compatible.
4715 ///
4716 /// This routine handles the merging of attributes and other
4717 /// properties of function declarations from the old declaration to
4718 /// the new declaration, once we know that New is in fact a
4719 /// redeclaration of Old.
4720 ///
4721 /// \returns false
4723 Scope *S, bool MergeTypeWithOld);
4725
4726 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4727 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4728 /// situation, merging decls or emitting diagnostics as appropriate.
4729 ///
4730 /// Tentative definition rules (C99 6.9.2p2) are checked by
4731 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4732 /// definitions here, since the initializer hasn't been attached.
4734
4735 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4736 /// scope as a previous declaration 'Old'. Figure out how to merge their
4737 /// types, emitting diagnostics as appropriate.
4738 ///
4739 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4740 /// back to here in AddInitializerToDecl. We can't check them before the
4741 /// initializer is attached.
4742 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4743
4744 /// We've just determined that \p Old and \p New both appear to be definitions
4745 /// of the same variable. Either diagnose or fix the problem.
4746 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4748
4749 /// Filters out lookup results that don't fall within the given scope
4750 /// as determined by isDeclInScope.
4752 bool ConsiderLinkage, bool AllowInlineNamespace);
4753
4754 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4755 /// have compatible owning modules.
4757
4758 /// [module.interface]p6:
4759 /// A redeclaration of an entity X is implicitly exported if X was introduced
4760 /// by an exported declaration; otherwise it shall not be exported.
4762
4763 /// A wrapper function for checking the semantic restrictions of
4764 /// a redeclaration within a module.
4766
4767 /// Check the redefinition in C++20 Modules.
4768 ///
4769 /// [basic.def.odr]p14:
4770 /// For any definable item D with definitions in multiple translation units,
4771 /// - if D is a non-inline non-templated function or variable, or
4772 /// - if the definitions in different translation units do not satisfy the
4773 /// following requirements,
4774 /// the program is ill-formed; a diagnostic is required only if the
4775 /// definable item is attached to a named module and a prior definition is
4776 /// reachable at the point where a later definition occurs.
4777 /// - Each such definition shall not be attached to a named module
4778 /// ([module.unit]).
4779 /// - Each such definition shall consist of the same sequence of tokens, ...
4780 /// ...
4781 ///
4782 /// Return true if the redefinition is not allowed. Return false otherwise.
4783 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4784
4786
4787 /// If it's a file scoped decl that must warn if not used, keep track
4788 /// of it.
4790
4791 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4793
4796 DiagReceiverTy DiagReceiver);
4797 void DiagnoseUnusedDecl(const NamedDecl *ND);
4798
4799 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4800 /// unless they are marked attr(unused).
4801 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4802
4803 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4804 /// variable.
4805 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4806
4807 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4808 /// from S, where a non-field would be declared. This routine copes
4809 /// with the difference between C and C++ scoping rules in structs and
4810 /// unions. For example, the following code is well-formed in C but
4811 /// ill-formed in C++:
4812 /// @code
4813 /// struct S6 {
4814 /// enum { BAR } e;
4815 /// };
4816 ///
4817 /// void test_S6() {
4818 /// struct S6 a;
4819 /// a.e = BAR;
4820 /// }
4821 /// @endcode
4822 /// For the declaration of BAR, this routine will return a different
4823 /// scope. The scope S will be the scope of the unnamed enumeration
4824 /// within S6. In C++, this routine will return the scope associated
4825 /// with S6, because the enumeration's scope is a transparent
4826 /// context but structures can contain non-field names. In C, this
4827 /// routine will return the translation unit scope, since the
4828 /// enumeration's scope is a transparent context and structures cannot
4829 /// contain non-field names.
4831
4833 SourceLocation Loc);
4834
4835 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4836 /// file scope. lazily create a decl for it. ForRedeclaration is true
4837 /// if we're creating this built-in in anticipation of redeclaring the
4838 /// built-in.
4839 NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S,
4840 bool ForRedeclaration, SourceLocation Loc);
4841
4842 /// Get the outermost AttributedType node that sets a calling convention.
4843 /// Valid types should not have multiple attributes with different CCs.
4844 const AttributedType *getCallingConvAttributedType(QualType T) const;
4845
4846 /// GetNameForDeclarator - Determine the full declaration name for the
4847 /// given Declarator.
4849
4850 /// Retrieves the declaration name from a parsed unqualified-id.
4852
4853 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4854 /// we are currently parsing the initializer.
4856
4857 /// Look for a locally scoped extern "C" declaration by the given name.
4859
4861
4862 /// Adjust the \c DeclContext for a function or variable that might be a
4863 /// function-local external declaration.
4865
4867
4868 /// Checks if the variant/multiversion functions are compatible.
4870 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4871 const PartialDiagnostic &NoProtoDiagID,
4872 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4873 const PartialDiagnosticAt &NoSupportDiagIDAt,
4874 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4875 bool ConstexprSupported, bool CLinkageMayDiffer);
4876
4877 /// type checking declaration initializers (C99 6.7.8)
4879 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4880
4883 SourceRange Range, bool DirectInit,
4884 Expr *Init);
4885
4887 Expr *Init);
4888
4890
4891 // Heuristically tells if the function is `get_return_object` member of a
4892 // coroutine promise_type by matching the function name.
4893 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4894 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4895
4896 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4897 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4899 Scope *S);
4900
4901 /// If this function is a C++ replaceable global allocation function
4902 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4903 /// adds any function attributes that we know a priori based on the standard.
4904 ///
4905 /// We need to check for duplicate attributes both here and where user-written
4906 /// attributes are applied to declarations.
4908 FunctionDecl *FD);
4909
4910 /// Adds any function attributes that we know a priori based on
4911 /// the declaration of this function.
4912 ///
4913 /// These attributes can apply both to implicitly-declared builtins
4914 /// (like __builtin___printf_chk) or to library-declared functions
4915 /// like NSLog or printf.
4916 ///
4917 /// We need to check for duplicate attributes both here and where user-written
4918 /// attributes are applied to declarations.
4920
4921 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4922 /// the correct width, and that the field type is valid.
4923 /// Returns false on success.
4925 const IdentifierInfo *FieldName, QualType FieldTy,
4926 bool IsMsStruct, Expr *BitWidth);
4927
4928 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4929 /// enum. If AllowMask is true, then we also allow the complement of a valid
4930 /// value, to be used as a mask.
4931 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4932 bool AllowMask) const;
4933
4934 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4935 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4936 SourceLocation WeakNameLoc);
4937
4938 /// ActOnPragmaRedefineExtname - Called on well formed
4939 /// \#pragma redefine_extname oldname newname.
4941 IdentifierInfo *AliasName,
4942 SourceLocation PragmaLoc,
4943 SourceLocation WeakNameLoc,
4944 SourceLocation AliasNameLoc);
4945
4946 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4947 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4948 SourceLocation PragmaLoc,
4949 SourceLocation WeakNameLoc,
4950 SourceLocation AliasNameLoc);
4951
4952 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4955 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4956 OMPDiscarded, // Discarded due to OpenMP hostness
4957 TemplateDiscarded, // Discarded due to uninstantiated templates
4959 };
4960 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4961 bool Final = false);
4962
4963 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4965
4966 /// Function or variable declarations to be checked for whether the deferred
4967 /// diagnostics should be emitted.
4969
4970private:
4971 /// Map of current shadowing declarations to shadowed declarations. Warn if
4972 /// it looks like the user is trying to modify the shadowing declaration.
4973 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4974
4975 // We need this to handle
4976 //
4977 // typedef struct {
4978 // void *foo() { return 0; }
4979 // } A;
4980 //
4981 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4982 // for example. If 'A', foo will have external linkage. If we have '*A',
4983 // foo will have no linkage. Since we can't know until we get to the end
4984 // of the typedef, this function finds out if D might have non-external
4985 // linkage. Callers should verify at the end of the TU if it D has external
4986 // linkage or not.
4987 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4988
4989#include "clang/Sema/AttrIsTypeDependent.inc"
4990
4991 ///@}
4992
4993 //
4994 //
4995 // -------------------------------------------------------------------------
4996 //
4997 //
4998
4999 /// \name Declaration Attribute Handling
5000 /// Implementations are in SemaDeclAttr.cpp
5001 ///@{
5002
5003public:
5004 /// Describes the kind of priority given to an availability attribute.
5005 ///
5006 /// The sum of priorities deteremines the final priority of the attribute.
5007 /// The final priority determines how the attribute will be merged.
5008 /// An attribute with a lower priority will always remove higher priority
5009 /// attributes for the specified platform when it is being applied. An
5010 /// attribute with a higher priority will not be applied if the declaration
5011 /// already has an availability attribute with a lower priority for the
5012 /// specified platform. The final prirority values are not expected to match
5013 /// the values in this enumeration, but instead should be treated as a plain
5014 /// integer value. This enumeration just names the priority weights that are
5015 /// used to calculate that final vaue.
5017 /// The availability attribute was specified explicitly next to the
5018 /// declaration.
5020
5021 /// The availability attribute was applied using '#pragma clang attribute'.
5023
5024 /// The availability attribute for a specific platform was inferred from
5025 /// an availability attribute for another platform.
5027
5028 /// The availability attribute was inferred from an 'anyAppleOS'
5029 /// availability attribute.
5031
5032 /// The availability attribute was inferred from an 'anyAppleOS'
5033 /// availability attribute that was applied using '#pragma clang attribute'.
5034 /// This has the lowest priority.
5036 };
5037
5038 /// Describes the reason a calling convention specification was ignored, used
5039 /// for diagnostics.
5046
5047 /// A helper function to provide Attribute Location for the Attr types
5048 /// AND the ParsedAttr.
5049 template <typename AttrInfo>
5050 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
5051 getAttrLoc(const AttrInfo &AL) {
5052 return AL.getLocation();
5053 }
5055
5056 /// If Expr is a valid integer constant, get the value of the integer
5057 /// expression and return success or failure. May output an error.
5058 ///
5059 /// Negative argument is implicitly converted to unsigned, unless
5060 /// \p StrictlyUnsigned is true.
5061 template <typename AttrInfo>
5062 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
5063 unsigned Idx = UINT_MAX,
5064 bool StrictlyUnsigned = false) {
5065 std::optional<llvm::APSInt> I = llvm::APSInt(32);
5066 if (Expr->isTypeDependent() ||
5068 if (Idx != UINT_MAX)
5069 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
5070 << &AI << Idx << AANT_ArgumentIntegerConstant
5071 << Expr->getSourceRange();
5072 else
5073 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
5075 return false;
5076 }
5077
5078 if (!I->isIntN(32)) {
5079 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
5080 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
5081 return false;
5082 }
5083
5084 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
5085 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
5086 << &AI << /*non-negative*/ 1;
5087 return false;
5088 }
5089
5090 Val = (uint32_t)I->getZExtValue();
5091 return true;
5092 }
5093
5094 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
5095 /// \#pragma weak during processing of other Decls.
5096 /// I couldn't figure out a clean way to generate these in-line, so
5097 /// we store them here and handle separately -- which is a hack.
5098 /// It would be best to refactor this.
5100
5101 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
5103
5105 2, 2>
5107
5108 /// ExtVectorDecls - This is a list all the extended vector types. This allows
5109 /// us to associate a raw vector type with one of the ext_vector type names.
5110 /// This is only necessary for issuing pretty diagnostics.
5112
5113 /// Check if the argument \p E is a ASCII string literal. If not emit an error
5114 /// and return false, otherwise set \p Str to the value of the string literal
5115 /// and return true.
5117 const Expr *E, StringRef &Str,
5118 SourceLocation *ArgLocation = nullptr);
5119
5120 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
5121 /// If not emit an error and return false. If the argument is an identifier it
5122 /// will emit an error with a fixit hint and treat it as if it was a string
5123 /// literal.
5124 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
5125 StringRef &Str,
5126 SourceLocation *ArgLocation = nullptr);
5127
5128 /// Determine if type T is a valid subject for a nonnull and similar
5129 /// attributes. Dependent types are considered valid so they can be checked
5130 /// during instantiation time. By default, we look through references (the
5131 /// behavior used by nonnull), but if the second parameter is true, then we
5132 /// treat a reference type as valid.
5133 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
5134
5135 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
5136 /// declaration.
5137 void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
5138 Expr *OE);
5139
5140 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
5141 /// declaration.
5142 void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
5143 Expr *ParamExpr);
5144
5145 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
5146 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
5147
5148 AvailabilityAttr *
5150 const IdentifierInfo *Platform, bool Implicit,
5151 VersionTuple Introduced, VersionTuple Deprecated,
5152 VersionTuple Obsoleted, bool IsUnavailable,
5153 StringRef Message, bool IsStrict, StringRef Replacement,
5154 AvailabilityMergeKind AMK, int Priority,
5155 const IdentifierInfo *IIEnvironment,
5156 const IdentifierInfo *InferredPlatformII = nullptr);
5157
5158 AvailabilityAttr *mergeAndInferAvailabilityAttr(
5159 NamedDecl *D, const AttributeCommonInfo &CI,
5160 const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced,
5161 VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable,
5162 StringRef Message, bool IsStrict, StringRef Replacement,
5163 AvailabilityMergeKind AMK, int Priority,
5164 const IdentifierInfo *IIEnvironment,
5165 const IdentifierInfo *InferredPlatformII);
5166
5167 TypeVisibilityAttr *
5169 TypeVisibilityAttr::VisibilityType Vis);
5170 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
5171 VisibilityAttr::VisibilityType Vis);
5173 VisibilityAttr::VisibilityType Type);
5174 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
5175 StringRef Name);
5176
5177 /// Used to implement to perform semantic checking on
5178 /// attribute((section("foo"))) specifiers.
5179 ///
5180 /// In this case, "foo" is passed in to be checked. If the section
5181 /// specifier is invalid, return an Error that indicates the problem.
5182 ///
5183 /// This is a simple quality of implementation feature to catch errors
5184 /// and give good diagnostics in cases when the assembler or code generator
5185 /// would otherwise reject the section specifier.
5186 llvm::Error isValidSectionSpecifier(StringRef Str);
5187 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
5188 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
5189 StringRef Name);
5190
5191 // Check for things we'd like to warn about. Multiversioning issues are
5192 // handled later in the process, once we know how many exist.
5193 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
5194
5195 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
5196 StringRef NewUserDiagnostic);
5197 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
5198 const IdentifierInfo *Format, int FormatIdx,
5199 int FirstArg);
5200 FormatMatchesAttr *mergeFormatMatchesAttr(Decl *D,
5201 const AttributeCommonInfo &CI,
5202 const IdentifierInfo *Format,
5203 int FormatIdx,
5204 StringLiteral *FormatStr);
5205 ModularFormatAttr *mergeModularFormatAttr(Decl *D,
5206 const AttributeCommonInfo &CI,
5207 const IdentifierInfo *ModularImplFn,
5208 StringRef ImplName,
5210
5211 PersonalityAttr *mergePersonalityAttr(Decl *D, FunctionDecl *Routine,
5212 const AttributeCommonInfo &CI);
5213
5214 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
5215 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
5216 bool IsPackExpansion);
5218 bool IsPackExpansion);
5219
5220 /// AddAlignValueAttr - Adds an align_value attribute to a particular
5221 /// declaration.
5222 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
5223
5224 /// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
5225 Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
5228
5230 bool BestCase,
5231 MSInheritanceModel SemanticSpelling);
5232
5234
5235 /// AddModeAttr - Adds a mode attribute to a particular declaration.
5236 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
5237 const IdentifierInfo *Name, bool InInstantiation = false);
5238 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
5239 const AttributeCommonInfo &CI,
5240 const IdentifierInfo *Ident);
5241 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
5242 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
5243 const AttributeCommonInfo &CI);
5244 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
5245 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
5246 const InternalLinkageAttr &AL);
5247
5248 /// Check validaty of calling convention attribute \p attr. If \p FD
5249 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
5250 /// target. Otherwise, it is specified by \p CFT.
5252 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
5254
5255 /// Checks a regparm attribute, returning true if it is ill-formed and
5256 /// otherwise setting numParams to the appropriate value.
5257 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
5258
5259 /// Create a CUDALaunchBoundsAttr attribute. By default, the function only
5260 /// supports nvptx target architectures and skips MaxBlocks if it is previous
5261 /// to sm_90. Use \p IgnoreArch to skip the architecture check.
5262 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
5263 Expr *MaxThreads,
5264 Expr *MinBlocks, Expr *MaxBlocks,
5265 bool IgnoreArch = false);
5266
5267 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
5268 /// declaration.
5269 void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
5270 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
5271
5272 /// Add a cluster_dims attribute to a particular declaration.
5273 CUDAClusterDimsAttr *createClusterDimsAttr(const AttributeCommonInfo &CI,
5274 Expr *X, Expr *Y, Expr *Z);
5275 void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X,
5276 Expr *Y, Expr *Z);
5277 /// Add a no_cluster attribute to a particular declaration.
5278 void addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI);
5279
5280 enum class RetainOwnershipKind { NS, CF, OS };
5281
5282 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
5283 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
5284
5285 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
5286
5287 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
5288 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
5289 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
5290 const AttributeCommonInfo &CI,
5291 bool BestCase,
5292 MSInheritanceModel Model);
5293
5294 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
5295 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
5296 const EnforceTCBLeafAttr &AL);
5297
5298 /// Helper for delayed processing TransparentUnion or
5299 /// BPFPreserveAccessIndexAttr attribute.
5301 const ParsedAttributesView &AttrList);
5302
5303 // Options for ProcessDeclAttributeList().
5307
5310 Result.IncludeCXX11Attributes = Val;
5311 return Result;
5312 }
5313
5316 Result.IgnoreTypeAttributes = Val;
5317 return Result;
5318 }
5319
5320 // Should C++11 attributes be processed?
5322
5323 // Should any type attributes encountered be ignored?
5324 // If this option is false, a diagnostic will be emitted for any type
5325 // attributes of a kind that does not "slide" from the declaration to
5326 // the decl-specifier-seq.
5328 };
5329
5330 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
5331 /// attribute list to the specified decl, ignoring any type attributes.
5333 const ParsedAttributesView &AttrList,
5334 const ProcessDeclAttributeOptions &Options =
5336
5337 /// Annotation attributes are the only attributes allowed after an access
5338 /// specifier.
5340 const ParsedAttributesView &AttrList);
5341
5342 /// Check that \p Record is a capability if a thread safety attribute without
5343 /// capability arguments on one of its fields refers to it. Called once the
5344 /// record's own attributes are applied; the attributes checked are those
5345 /// already on its fields, which were applied before the record's.
5347
5348 /// checkUnusedDeclAttributes - Given a declarator which is not being
5349 /// used to build a declaration, complain about any decl attributes
5350 /// which might be lying around on it.
5352
5353 void DiagnoseUnknownAttribute(const ParsedAttr &AL);
5354
5355 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
5356 /// \#pragma weak needs a non-definition decl and source may not have one.
5358 SourceLocation Loc);
5359
5360 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
5361 /// applied to it, possibly with an alias.
5362 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
5363
5364 void ProcessPragmaWeak(Scope *S, Decl *D);
5365 // Decl attributes - this routine is the top level dispatcher.
5366 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
5367
5369
5370 /// Given a set of delayed diagnostics, re-emit them as if they had
5371 /// been delayed in the current context instead of in the given pool.
5372 /// Essentially, this just moves them to the current pool.
5374
5375 /// Check that the type is a plain record with one field being a pointer
5376 /// type and the other field being an integer. This matches the common
5377 /// implementation of std::span or sized_allocation_t in P0901R11.
5378 bool CheckSpanLikeType(const AttributeCommonInfo &CI, const QualType &Ty);
5379
5380 /// Check if IdxExpr is a valid parameter index for a function or
5381 /// instance method D. May output an error.
5382 ///
5383 /// \returns true if IdxExpr is a valid index.
5384 template <typename AttrInfo>
5386 const Decl *D, const AttrInfo &AI, unsigned AttrArgNum,
5387 const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis = false,
5388 bool CanIndexVariadicArguments = false) {
5390
5391 // In C++ the implicit 'this' function parameter also counts.
5392 // Parameters are counted from one.
5393 bool HP = hasFunctionProto(D);
5394 bool IV = HP && isFunctionOrMethodVariadic(D);
5395 unsigned NumParams =
5396 HP ? getFunctionOrMethodNumParams(D, /*IncludeThis=*/true) : 0;
5397
5398 std::optional<llvm::APSInt> IdxInt;
5399 if (IdxExpr->isTypeDependent() ||
5400 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
5401 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
5402 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
5403 << IdxExpr->getSourceRange();
5404 return false;
5405 }
5406
5407 constexpr unsigned Limit = 1 << ParamIdx::IdxBitWidth;
5408 unsigned IdxSource = IdxInt->getLimitedValue(Limit);
5409 if (IdxSource < 1 || IdxSource == Limit ||
5410 ((!IV || !CanIndexVariadicArguments) && IdxSource > NumParams)) {
5411 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
5412 << &AI << AttrArgNum << IdxExpr->getSourceRange();
5413 return false;
5414 }
5415 if (hasImplicitObjectParameter(D) && !CanIndexImplicitThis) {
5416 if (IdxSource == 1) {
5417 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
5418 << &AI << IdxExpr->getSourceRange();
5419 return false;
5420 }
5421 }
5422
5423 Idx = ParamIdx(IdxSource, D);
5424 return true;
5425 }
5426
5427 ///@}
5428
5429 //
5430 //
5431 // -------------------------------------------------------------------------
5432 //
5433 //
5434
5435 /// \name C++ Declarations
5436 /// Implementations are in SemaDeclCXX.cpp
5437 ///@{
5438
5439public:
5441
5442 /// Called before parsing a function declarator belonging to a function
5443 /// declaration.
5445 unsigned TemplateParameterDepth);
5446
5447 /// Called after parsing a function declarator belonging to a function
5448 /// declaration.
5450
5451 // Act on C++ namespaces
5453 SourceLocation NamespaceLoc,
5454 SourceLocation IdentLoc, IdentifierInfo *Ident,
5455 SourceLocation LBrace,
5456 const ParsedAttributesView &AttrList,
5457 UsingDirectiveDecl *&UsingDecl, bool IsNested);
5458
5459 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
5460 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
5461 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
5462
5464
5465 /// Retrieve the special "std" namespace, which may require us to
5466 /// implicitly define the namespace.
5468
5470 EnumDecl *getStdAlignValT() const;
5471
5474 QualType AllocType, SourceLocation);
5475
5477 const IdentifierInfo *MemberOrBase);
5478
5480 /// The '<=>' operator was used in an expression and a builtin operator
5481 /// was selected.
5483 /// A defaulted 'operator<=>' needed the comparison category. This
5484 /// typically only applies to 'std::strong_ordering', due to the implicit
5485 /// fallback return value.
5487 /// A builtin needed 'std::strong_ordering' (eg. '__builtin_type_order').
5489 };
5490
5491 /// Lookup the specified comparison category types in the standard
5492 /// library, an check the VarDecls possibly returned by the operator<=>
5493 /// builtins for that type.
5494 ///
5495 /// \return The type of the comparison category type corresponding to the
5496 /// specified Kind, or a null type if an error occurs
5498 SourceLocation Loc,
5500
5501 /// Tests whether Ty is an instance of std::initializer_list and, if
5502 /// it is and Element is not NULL, assigns the element type to Element.
5503 bool isStdInitializerList(QualType Ty, QualType *Element);
5504
5505 /// Tests whether Ty is an instance of std::type_identity and, if
5506 /// it is and TypeArgument is not NULL, assigns the element type to Element.
5507 /// If MalformedDecl is not null, and type_identity was ruled out due to being
5508 /// incorrectly structured despite having the correct name, the faulty Decl
5509 /// will be assigned to MalformedDecl.
5510 bool isStdTypeIdentity(QualType Ty, QualType *TypeArgument,
5511 const Decl **MalformedDecl = nullptr);
5512
5513 /// Looks for the std::initializer_list template and instantiates it
5514 /// with Element, or emits an error if it's not found.
5515 ///
5516 /// \returns The instantiated template, or null on error.
5518
5519 /// Looks for the std::type_identity template and instantiates it
5520 /// with Type, or returns a null type if type_identity has not been declared
5521 ///
5522 /// \returns The instantiated template, or null if std::type_identity is not
5523 /// declared
5525
5526 /// Determine whether Ctor is an initializer-list constructor, as
5527 /// defined in [dcl.init.list]p2.
5528 bool isInitListConstructor(const FunctionDecl *Ctor);
5529
5530 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
5531 SourceLocation NamespcLoc, CXXScopeSpec &SS,
5532 SourceLocation IdentLoc,
5533 IdentifierInfo *NamespcName,
5534 const ParsedAttributesView &AttrList);
5535
5537
5538 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
5539 SourceLocation AliasLoc, IdentifierInfo *Alias,
5540 CXXScopeSpec &SS, SourceLocation IdentLoc,
5541 IdentifierInfo *Ident);
5542
5543 /// Remove decls we can't actually see from a lookup being used to declare
5544 /// shadow using decls.
5545 ///
5546 /// \param S - The scope of the potential shadow decl
5547 /// \param Previous - The lookup of a potential shadow decl's name.
5548 void FilterUsingLookup(Scope *S, LookupResult &lookup);
5549
5550 /// Hides a using shadow declaration. This is required by the current
5551 /// using-decl implementation when a resolvable using declaration in a
5552 /// class is followed by a declaration which would hide or override
5553 /// one or more of the using decl's targets; for example:
5554 ///
5555 /// struct Base { void foo(int); };
5556 /// struct Derived : Base {
5557 /// using Base::foo;
5558 /// void foo(int);
5559 /// };
5560 ///
5561 /// The governing language is C++03 [namespace.udecl]p12:
5562 ///
5563 /// When a using-declaration brings names from a base class into a
5564 /// derived class scope, member functions in the derived class
5565 /// override and/or hide member functions with the same name and
5566 /// parameter types in a base class (rather than conflicting).
5567 ///
5568 /// There are two ways to implement this:
5569 /// (1) optimistically create shadow decls when they're not hidden
5570 /// by existing declarations, or
5571 /// (2) don't create any shadow decls (or at least don't make them
5572 /// visible) until we've fully parsed/instantiated the class.
5573 /// The problem with (1) is that we might have to retroactively remove
5574 /// a shadow decl, which requires several O(n) operations because the
5575 /// decl structures are (very reasonably) not designed for removal.
5576 /// (2) avoids this but is very fiddly and phase-dependent.
5577 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
5578
5579 /// Determines whether to create a using shadow decl for a particular
5580 /// decl, given the set of decls existing prior to this using lookup.
5582 const LookupResult &PreviousDecls,
5583 UsingShadowDecl *&PrevShadow);
5584
5585 /// Builds a shadow declaration corresponding to a 'using' declaration.
5588 UsingShadowDecl *PrevDecl);
5589
5590 /// Checks that the given using declaration is not an invalid
5591 /// redeclaration. Note that this is checking only for the using decl
5592 /// itself, not for any ill-formedness among the UsingShadowDecls.
5594 bool HasTypenameKeyword,
5595 const CXXScopeSpec &SS,
5596 SourceLocation NameLoc,
5597 const LookupResult &Previous);
5598
5599 /// Checks that the given nested-name qualifier used in a using decl
5600 /// in the current context is appropriately related to the current
5601 /// scope. If an error is found, diagnoses it and returns true.
5602 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
5603 /// the result of that lookup. UD is likewise nullptr, except when we have an
5604 /// already-populated UsingDecl whose shadow decls contain the same
5605 /// information (i.e. we're instantiating a UsingDecl with non-dependent
5606 /// scope).
5607 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
5608 const CXXScopeSpec &SS,
5609 const DeclarationNameInfo &NameInfo,
5610 SourceLocation NameLoc,
5611 const LookupResult *R = nullptr,
5612 const UsingDecl *UD = nullptr);
5613
5614 /// Builds a using declaration.
5615 ///
5616 /// \param IsInstantiation - Whether this call arises from an
5617 /// instantiation of an unresolved using declaration. We treat
5618 /// the lookup differently for these declarations.
5620 SourceLocation UsingLoc,
5621 bool HasTypenameKeyword,
5622 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5623 DeclarationNameInfo NameInfo,
5624 SourceLocation EllipsisLoc,
5625 const ParsedAttributesView &AttrList,
5626 bool IsInstantiation, bool IsUsingIfExists);
5628 SourceLocation UsingLoc,
5629 SourceLocation EnumLoc,
5630 SourceLocation NameLoc,
5631 TypeSourceInfo *EnumType, EnumDecl *ED);
5632 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
5633 ArrayRef<NamedDecl *> Expansions);
5634
5635 /// Additional checks for a using declaration referring to a constructor name.
5637
5638 /// Given a derived-class using shadow declaration for a constructor and the
5639 /// correspnding base class constructor, find or create the implicit
5640 /// synthesized derived class constructor to use for this initialization.
5643 ConstructorUsingShadowDecl *DerivedShadow);
5644
5646 SourceLocation UsingLoc,
5647 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5648 UnqualifiedId &Name, SourceLocation EllipsisLoc,
5649 const ParsedAttributesView &AttrList);
5651 SourceLocation UsingLoc,
5652 SourceLocation EnumLoc, SourceRange TyLoc,
5653 const IdentifierInfo &II, ParsedType Ty,
5654 const CXXScopeSpec &SS);
5656 MultiTemplateParamsArg TemplateParams,
5657 SourceLocation UsingLoc, UnqualifiedId &Name,
5658 const ParsedAttributesView &AttrList,
5659 TypeResult Type, Decl *DeclFromDeclSpec);
5660
5661 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
5662 /// including handling of its default argument expressions.
5663 ///
5664 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
5666 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5668 bool HadMultipleCandidates, bool IsListInitialization,
5669 bool IsStdInitListInitialization, bool RequiresZeroInit,
5670 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5671
5672 /// Build a CXXConstructExpr whose constructor has already been resolved if
5673 /// it denotes an inherited constructor.
5675 SourceLocation ConstructLoc, QualType DeclInitType,
5676 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5677 bool HadMultipleCandidates, bool IsListInitialization,
5678 bool IsStdInitListInitialization, bool RequiresZeroInit,
5679 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5680
5681 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
5682 // the constructor can be elidable?
5684 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5685 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5686 bool HadMultipleCandidates, bool IsListInitialization,
5687 bool IsStdInitListInitialization, bool RequiresZeroInit,
5688 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5689
5691 SourceLocation InitLoc);
5693 const InitializedEntity &Entity,
5694 Expr *InitExpr,
5695 SourceLocation InitLoc);
5696
5697 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
5698 /// constructed variable.
5699 void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit);
5700
5701 /// Helper class that collects exception specifications for
5702 /// implicitly-declared special member functions.
5704 // Pointer to allow copying
5705 Sema *Self;
5706 // We order exception specifications thus:
5707 // noexcept is the most restrictive, but is only used in C++11.
5708 // throw() comes next.
5709 // Then a throw(collected exceptions)
5710 // Finally no specification, which is expressed as noexcept(false).
5711 // throw(...) is used instead if any called function uses it.
5712 ExceptionSpecificationType ComputedEST;
5713 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5714 SmallVector<QualType, 4> Exceptions;
5715
5716 void ClearExceptions() {
5717 ExceptionsSeen.clear();
5718 Exceptions.clear();
5719 }
5720
5721 public:
5723 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5724 if (!Self.getLangOpts().CPlusPlus11)
5725 ComputedEST = EST_DynamicNone;
5726 }
5727
5728 /// Get the computed exception specification type.
5730 assert(!isComputedNoexcept(ComputedEST) &&
5731 "noexcept(expr) should not be a possible result");
5732 return ComputedEST;
5733 }
5734
5735 /// The number of exceptions in the exception specification.
5736 unsigned size() const { return Exceptions.size(); }
5737
5738 /// The set of exceptions in the exception specification.
5739 const QualType *data() const { return Exceptions.data(); }
5740
5741 /// Integrate another called method into the collected data.
5742 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5743
5744 /// Integrate an invoked expression into the collected data.
5745 void CalledExpr(Expr *E) { CalledStmt(E); }
5746
5747 /// Integrate an invoked statement into the collected data.
5748 void CalledStmt(Stmt *S);
5749
5750 /// Overwrite an EPI's exception specification with this
5751 /// computed exception specification.
5754 ESI.Type = getExceptionSpecType();
5755 if (ESI.Type == EST_Dynamic) {
5756 ESI.Exceptions = Exceptions;
5757 } else if (ESI.Type == EST_None) {
5758 /// C++11 [except.spec]p14:
5759 /// The exception-specification is noexcept(false) if the set of
5760 /// potential exceptions of the special member function contains "any"
5761 ESI.Type = EST_NoexceptFalse;
5762 ESI.NoexceptExpr =
5763 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5764 }
5765 return ESI;
5766 }
5767 };
5768
5769 /// Evaluate the implicit exception specification for a defaulted
5770 /// special member function.
5772
5773 /// Check the given exception-specification and update the
5774 /// exception specification information with the results.
5775 void checkExceptionSpecification(bool IsTopLevel,
5777 ArrayRef<ParsedType> DynamicExceptions,
5778 ArrayRef<SourceRange> DynamicExceptionRanges,
5779 Expr *NoexceptExpr,
5780 SmallVectorImpl<QualType> &Exceptions,
5782
5783 /// Add an exception-specification to the given member or friend function
5784 /// (or function template). The exception-specification was parsed
5785 /// after the function itself was declared.
5787 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5788 ArrayRef<ParsedType> DynamicExceptions,
5789 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5790
5791 class InheritedConstructorInfo;
5792
5793 /// Determine if a special member function should have a deleted
5794 /// definition when it is defaulted.
5796 InheritedConstructorInfo *ICI = nullptr,
5797 bool Diagnose = false);
5798
5799 /// Produce notes explaining why a defaulted function was defined as deleted.
5801
5802 /// Declare the implicit default constructor for the given class.
5803 ///
5804 /// \param ClassDecl The class declaration into which the implicit
5805 /// default constructor will be added.
5806 ///
5807 /// \returns The implicitly-declared default constructor.
5810
5811 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5812 /// defining this constructor as the default constructor.
5815
5816 /// Declare the implicit destructor for the given class.
5817 ///
5818 /// \param ClassDecl The class declaration into which the implicit
5819 /// destructor will be added.
5820 ///
5821 /// \returns The implicitly-declared destructor.
5823
5824 /// DefineImplicitDestructor - Checks for feasibility of
5825 /// defining this destructor as the default destructor.
5826 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5828
5829 /// Build an exception spec for destructors that don't have one.
5830 ///
5831 /// C++11 says that user-defined destructors with no exception spec get one
5832 /// that looks as if the destructor was implicitly declared.
5834
5835 /// Define the specified inheriting constructor.
5838
5839 /// Declare the implicit copy constructor for the given class.
5840 ///
5841 /// \param ClassDecl The class declaration into which the implicit
5842 /// copy constructor will be added.
5843 ///
5844 /// \returns The implicitly-declared copy constructor.
5846
5847 /// DefineImplicitCopyConstructor - Checks for feasibility of
5848 /// defining this constructor as the copy constructor.
5849 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5851
5852 /// Declare the implicit move constructor for the given class.
5853 ///
5854 /// \param ClassDecl The Class declaration into which the implicit
5855 /// move constructor will be added.
5856 ///
5857 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5858 /// declared.
5860
5861 /// DefineImplicitMoveConstructor - Checks for feasibility of
5862 /// defining this constructor as the move constructor.
5863 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5865
5866 /// Declare the implicit copy assignment operator for the given class.
5867 ///
5868 /// \param ClassDecl The class declaration into which the implicit
5869 /// copy assignment operator will be added.
5870 ///
5871 /// \returns The implicitly-declared copy assignment operator.
5873
5874 /// Defines an implicitly-declared copy assignment operator.
5875 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5876 CXXMethodDecl *MethodDecl);
5877
5878 /// Declare the implicit move assignment operator for the given class.
5879 ///
5880 /// \param ClassDecl The Class declaration into which the implicit
5881 /// move assignment operator will be added.
5882 ///
5883 /// \returns The implicitly-declared move assignment operator, or NULL if it
5884 /// wasn't declared.
5886
5887 /// Defines an implicitly-declared move assignment operator.
5888 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5889 CXXMethodDecl *MethodDecl);
5890
5891 /// Check a completed declaration of an implicit special member.
5893
5894 /// Determine whether the given function is an implicitly-deleted
5895 /// special member function.
5897
5898 /// Check whether 'this' shows up in the type of a static member
5899 /// function after the (naturally empty) cv-qualifier-seq would be.
5900 ///
5901 /// \returns true if an error occurred.
5903
5904 /// Whether this' shows up in the exception specification of a static
5905 /// member function.
5907
5908 /// Check whether 'this' shows up in the attributes of the given
5909 /// static member function.
5910 ///
5911 /// \returns true if an error occurred.
5913
5915 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5916
5918
5919 /// Given a constructor and the set of arguments provided for the
5920 /// constructor, convert the arguments and add any required default arguments
5921 /// to form a proper call to this constructor.
5922 ///
5923 /// \returns true if an error occurred, false otherwise.
5925 QualType DeclInitType, MultiExprArg ArgsPtr,
5926 SourceLocation Loc,
5927 SmallVectorImpl<Expr *> &ConvertedArgs,
5928 bool AllowExplicit = false,
5929 bool IsListInitialization = false);
5930
5931 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5932 /// initializer for the declaration 'Dcl'.
5933 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5934 /// static data member of class X, names should be looked up in the scope of
5935 /// class X.
5937
5938 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5939 /// initializer for the declaration 'Dcl'.
5940 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5941
5942 /// Define the "body" of the conversion from a lambda object to a
5943 /// function pointer.
5944 ///
5945 /// This routine doesn't actually define a sensible body; rather, it fills
5946 /// in the initialization expression needed to copy the lambda object into
5947 /// the block, and IR generation actually generates the real body of the
5948 /// block pointer conversion.
5949 void
5951 CXXConversionDecl *Conv);
5952
5953 /// Define the "body" of the conversion from a lambda object to a
5954 /// block pointer.
5955 ///
5956 /// This routine doesn't actually define a sensible body; rather, it fills
5957 /// in the initialization expression needed to copy the lambda object into
5958 /// the block, and IR generation actually generates the real body of the
5959 /// block pointer conversion.
5961 CXXConversionDecl *Conv);
5962
5963 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5964 /// linkage specification, including the language and (if present)
5965 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5966 /// language string literal. LBraceLoc, if valid, provides the location of
5967 /// the '{' brace. Otherwise, this linkage specification does not
5968 /// have any braces.
5970 Expr *LangStr, SourceLocation LBraceLoc);
5971
5972 /// ActOnFinishLinkageSpecification - Complete the definition of
5973 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5974 /// valid, it's the position of the closing '}' brace in a linkage
5975 /// specification that uses braces.
5977 SourceLocation RBraceLoc);
5978
5979 //===--------------------------------------------------------------------===//
5980 // C++ Classes
5981 //
5982
5983 /// Get the class that is directly named by the current context. This is the
5984 /// class for which an unqualified-id in this scope could name a constructor
5985 /// or destructor.
5986 ///
5987 /// If the scope specifier denotes a class, this will be that class.
5988 /// If the scope specifier is empty, this will be the class whose
5989 /// member-specification we are currently within. Otherwise, there
5990 /// is no such class.
5992
5993 /// isCurrentClassName - Determine whether the identifier II is the
5994 /// name of the class type currently being defined. In the case of
5995 /// nested classes, this will only return true if II is the name of
5996 /// the innermost class.
5997 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5998 const CXXScopeSpec *SS = nullptr);
5999
6000 /// Determine whether the identifier II is a typo for the name of
6001 /// the class type currently being defined. If so, update it to the identifier
6002 /// that should have been used.
6004
6005 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
6007 SourceLocation ColonLoc,
6008 const ParsedAttributesView &Attrs);
6009
6010 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
6011 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
6012 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
6013 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
6014 /// present (but parsing it has been deferred).
6015 NamedDecl *
6017 MultiTemplateParamsArg TemplateParameterLists,
6018 Expr *BitfieldWidth, const VirtSpecifiers &VS,
6019 InClassInitStyle InitStyle);
6020
6021 /// Enter a new C++ default initializer scope. After calling this, the
6022 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
6023 /// parsing or instantiating the initializer failed.
6025
6026 /// This is invoked after parsing an in-class initializer for a
6027 /// non-static C++ class member, and after instantiating an in-class
6028 /// initializer in a class template. Such actions are deferred until the class
6029 /// is complete.
6031 SourceLocation EqualLoc,
6033
6034 /// Handle a C++ member initializer using parentheses syntax.
6036 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
6037 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
6038 const DeclSpec &DS, SourceLocation IdLoc,
6039 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
6040 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
6041
6042 /// Handle a C++ member initializer using braced-init-list syntax.
6043 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
6044 CXXScopeSpec &SS,
6045 IdentifierInfo *MemberOrBase,
6046 ParsedType TemplateTypeTy,
6047 const DeclSpec &DS, SourceLocation IdLoc,
6048 Expr *InitList, SourceLocation EllipsisLoc);
6049
6050 /// Handle a C++ member initializer.
6051 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
6052 CXXScopeSpec &SS,
6053 IdentifierInfo *MemberOrBase,
6054 ParsedType TemplateTypeTy,
6055 const DeclSpec &DS, SourceLocation IdLoc,
6056 Expr *Init, SourceLocation EllipsisLoc);
6057
6059 SourceLocation IdLoc);
6060
6062 TypeSourceInfo *BaseTInfo, Expr *Init,
6063 CXXRecordDecl *ClassDecl,
6064 SourceLocation EllipsisLoc);
6065
6067 CXXRecordDecl *ClassDecl);
6068
6071
6073 ArrayRef<CXXCtorInitializer *> Initializers = {});
6074
6075 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
6076 /// mark all the non-trivial destructors of its members and bases as
6077 /// referenced.
6078 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
6079 CXXRecordDecl *Record);
6080
6081 /// Mark destructors of virtual bases of this class referenced. In the Itanium
6082 /// C++ ABI, this is done when emitting a destructor for any non-abstract
6083 /// class. In the Microsoft C++ ABI, this is done any time a class's
6084 /// destructor is referenced.
6086 SourceLocation Location, CXXRecordDecl *ClassDecl,
6087 llvm::SmallPtrSetImpl<const CXXRecordDecl *> *DirectVirtualBases =
6088 nullptr);
6089
6090 /// Do semantic checks to allow the complete destructor variant to be emitted
6091 /// when the destructor is defined in another translation unit. In the Itanium
6092 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
6093 /// can be emitted in separate TUs. To emit the complete variant, run a subset
6094 /// of the checks performed when emitting a regular destructor.
6095 void CheckCompleteDestructorVariant(SourceLocation CurrentLocation,
6096 CXXDestructorDecl *Dtor);
6097
6098 /// The list of classes whose vtables have been used within
6099 /// this translation unit, and the source locations at which the
6100 /// first use occurred.
6101 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
6102
6103 /// The list of vtables that are required but have not yet been
6104 /// materialized.
6106
6107 /// The set of classes whose vtables have been used within
6108 /// this translation unit, and a bit that will be true if the vtable is
6109 /// required to be emitted (otherwise, it should be emitted only if needed
6110 /// by code generation).
6111 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
6112
6113 /// Load any externally-stored vtable uses.
6115
6116 /// Note that the vtable for the given class was used at the
6117 /// given location.
6119 bool DefinitionRequired = false);
6120
6121 /// Mark the exception specifications of all virtual member functions
6122 /// in the given class as needed.
6124 const CXXRecordDecl *RD);
6125
6126 /// MarkVirtualMembersReferenced - Will mark all members of the given
6127 /// CXXRecordDecl referenced.
6129 bool ConstexprOnly = false);
6130
6131 /// Define all of the vtables that have been used in this
6132 /// translation unit and reference any virtual members used by those
6133 /// vtables.
6134 ///
6135 /// \returns true if any work was done, false otherwise.
6136 bool DefineUsedVTables();
6137
6138 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
6139 /// special functions, such as the default constructor, copy
6140 /// constructor, or destructor, to the given C++ class (C++
6141 /// [special]p1). This routine can only be executed just before the
6142 /// definition of the class is complete.
6144
6145 /// ActOnMemInitializers - Handle the member initializers for a constructor.
6146 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
6148 bool AnyErrors);
6149
6150 /// Check class-level dllimport/dllexport attribute. The caller must
6151 /// ensure that referenceDLLExportedClassMethods is called some point later
6152 /// when all outer classes of Class are complete.
6155
6157
6158 /// Perform propagation of DLL attributes from a derived class to a
6159 /// templated base class for MS compatibility.
6161 CXXRecordDecl *Class, Attr *ClassAttr,
6162 ClassTemplateSpecializationDecl *BaseTemplateSpec,
6163 SourceLocation BaseLoc);
6164
6165 /// Perform semantic checks on a class definition that has been
6166 /// completing, introducing implicitly-declared members, checking for
6167 /// abstract types, etc.
6168 ///
6169 /// \param S The scope in which the class was parsed. Null if we didn't just
6170 /// parse a class definition.
6171 /// \param Record The completed class.
6173
6174 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
6175 /// conditions that are needed for the attribute to have an effect.
6177
6178 /// Check that VTable Pointer authentication is only being set on the first
6179 /// first instantiation of the vtable
6181
6183 Decl *TagDecl, SourceLocation LBrac,
6184 SourceLocation RBrac,
6185 const ParsedAttributesView &AttrList);
6186
6187 /// Perform any semantic analysis which needs to be delayed until all
6188 /// pending class member declarations have been parsed.
6191
6192 /// This is used to implement the constant expression evaluation part of the
6193 /// attribute enable_if extension. There is nothing in standard C++ which
6194 /// would require reentering parameters.
6197 llvm::function_ref<Scope *()> EnterScope);
6199
6200 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
6201 /// parsing a top-level (non-nested) C++ class, and we are now
6202 /// parsing those parts of the given Method declaration that could
6203 /// not be parsed earlier (C++ [class.mem]p2), such as default
6204 /// arguments. This action should enter the scope of the given
6205 /// Method declaration as if we had just parsed the qualified method
6206 /// name. However, it should not bring the parameters into scope;
6207 /// that will be performed by ActOnDelayedCXXMethodParameter.
6209 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
6211
6212 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
6213 /// processing the delayed method declaration for Method. The method
6214 /// declaration is now considered finished. There may be a separate
6215 /// ActOnStartOfFunctionDef action later (not necessarily
6216 /// immediately!) for this method, if it was also defined inside the
6217 /// class body.
6220
6222
6223 bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx,
6224 StringEvaluationContext EvalContext,
6225 bool ErrorOnInvalidMessage);
6226 bool EvaluateAsString(Expr *Message, std::string &Result, ASTContext &Ctx,
6227 StringEvaluationContext EvalContext,
6228 bool ErrorOnInvalidMessage);
6229
6231 Expr *AssertExpr, Expr *AssertMessageExpr,
6232 SourceLocation RParenLoc);
6234 Expr *AssertExpr, Expr *AssertMessageExpr,
6235 SourceLocation RParenLoc, bool Failed);
6236
6237 /// Try to print more useful information about a failed static_assert
6238 /// with expression \E
6239 void DiagnoseStaticAssertDetails(const Expr *E);
6240
6241 /// If E represents a built-in type trait, or a known standard type trait,
6242 /// try to print more information about why the type type-trait failed.
6243 /// This assumes we already evaluated the expression to a false boolean value.
6244 void DiagnoseTypeTraitDetails(const Expr *E);
6245
6246 /// Handle a friend type declaration. This works in tandem with
6247 /// ActOnTag.
6248 ///
6249 /// Notes on friend class templates:
6250 ///
6251 /// We generally treat friend class declarations as if they were
6252 /// declaring a class. So, for example, the elaborated type specifier
6253 /// in a friend declaration is required to obey the restrictions of a
6254 /// class-head (i.e. no typedefs in the scope chain), template
6255 /// parameters are required to match up with simple template-ids, &c.
6256 /// However, unlike when declaring a template specialization, it's
6257 /// okay to refer to a template specialization without an empty
6258 /// template parameter declaration, e.g.
6259 /// friend class A<T>::B<unsigned>;
6260 /// We permit this as a special case; if there are any template
6261 /// parameters present at all, require proper matching, i.e.
6262 /// template <> template <class T> friend class A<int>::B;
6263 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
6264 MultiTemplateParamsArg TemplateParams,
6265 SourceLocation EllipsisLoc);
6267 MultiTemplateParamsArg TemplateParams);
6268
6269 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
6270 /// the well-formedness of the constructor declarator @p D with type @p
6271 /// R. If there are any errors in the declarator, this routine will
6272 /// emit diagnostics and set the invalid bit to true. In any case, the type
6273 /// will be updated to reflect a well-formed type for the constructor and
6274 /// returned.
6276 StorageClass &SC);
6277
6278 /// CheckConstructor - Checks a fully-formed constructor for
6279 /// well-formedness, issuing any diagnostics required. Returns true if
6280 /// the constructor declarator is invalid.
6282
6283 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
6284 /// the well-formednes of the destructor declarator @p D with type @p
6285 /// R. If there are any errors in the declarator, this routine will
6286 /// emit diagnostics and set the declarator to invalid. Even if this happens,
6287 /// will be updated to reflect a well-formed type for the destructor and
6288 /// returned.
6290 StorageClass &SC);
6291
6292 /// CheckDestructor - Checks a fully-formed destructor definition for
6293 /// well-formedness, issuing any diagnostics required. Returns true
6294 /// on error.
6296
6297 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
6298 /// well-formednes of the conversion function declarator @p D with
6299 /// type @p R. If there are any errors in the declarator, this routine
6300 /// will emit diagnostics and return true. Otherwise, it will return
6301 /// false. Either way, the type @p R will be updated to reflect a
6302 /// well-formed type for the conversion operator.
6304
6305 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
6306 /// the declaration of the given C++ conversion function. This routine
6307 /// is responsible for recording the conversion function in the C++
6308 /// class, if possible.
6310
6311 /// Check the validity of a declarator that we parsed for a deduction-guide.
6312 /// These aren't actually declarators in the grammar, so we need to check that
6313 /// the user didn't specify any pieces that are not part of the
6314 /// deduction-guide grammar. Return true on invalid deduction-guide.
6316 StorageClass &SC);
6317
6319
6322 SourceLocation DefaultLoc);
6324
6328 FunctionDecl *Spaceship);
6331
6332 /// Check a defaulted postfix increment or decrement operator function
6333 /// (C++2d [over.inc.default]), defining it as deleted if necessary.
6334 ///
6335 /// \param S The scope in which the function is defaulted, used to perform
6336 /// the unqualified name lookups needed by the implicit definition, or
6337 /// \c nullptr if those lookups have already been performed.
6338 ///
6339 /// \returns \c true if the function is ill-formed.
6341 PostfixOperatorKind Kind);
6342 /// Synthesize the body of a defaulted postfix increment or decrement
6343 /// operator function (C++2d [over.inc.default]p3).
6345 PostfixOperatorKind Kind);
6346
6348 QualType R, bool IsLambda,
6349 DeclContext *DC = nullptr);
6351 DeclarationName Name, QualType R);
6353
6354 //===--------------------------------------------------------------------===//
6355 // C++ Derived Classes
6356 //
6357
6358 /// Check the validity of a C++ base class specifier.
6359 ///
6360 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
6361 /// and returns NULL otherwise.
6363 SourceRange SpecifierRange, bool Virtual,
6364 AccessSpecifier Access,
6365 TypeSourceInfo *TInfo,
6366 SourceLocation EllipsisLoc);
6367
6368 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
6369 /// one entry in the base class list of a class specifier, for
6370 /// example:
6371 /// class foo : public bar, virtual private baz {
6372 /// 'public bar' and 'virtual private baz' are each base-specifiers.
6373 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
6374 const ParsedAttributesView &Attrs, bool Virtual,
6375 AccessSpecifier Access, ParsedType basetype,
6376 SourceLocation BaseLoc,
6377 SourceLocation EllipsisLoc);
6378
6379 /// Performs the actual work of attaching the given base class
6380 /// specifiers to a C++ class.
6383
6384 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
6385 /// class, after checking whether there are any duplicate base
6386 /// classes.
6387 void ActOnBaseSpecifiers(Decl *ClassDecl,
6389
6390 /// Determine whether the type \p Derived is a C++ class that is
6391 /// derived from the type \p Base.
6392 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6394 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6398 CXXBasePaths &Paths);
6399
6400 // FIXME: I don't like this name.
6401 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
6402
6404 SourceLocation Loc, SourceRange Range,
6405 CXXCastPath *BasePath = nullptr,
6406 bool IgnoreAccess = false);
6407
6408 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
6409 /// conversion (where Derived and Base are class types) is
6410 /// well-formed, meaning that the conversion is unambiguous (and
6411 /// that all of the base classes are accessible). Returns true
6412 /// and emits a diagnostic if the code is ill-formed, returns false
6413 /// otherwise. Loc is the location where this routine should point to
6414 /// if there is an error, and Range is the source range to highlight
6415 /// if there is an error.
6416 ///
6417 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
6418 /// diagnostic for the respective type of error will be suppressed, but the
6419 /// check for ill-formed code will still be performed.
6421 unsigned InaccessibleBaseID,
6422 unsigned AmbiguousBaseConvID,
6423 SourceLocation Loc, SourceRange Range,
6424 DeclarationName Name, CXXCastPath *BasePath,
6425 bool IgnoreAccess = false);
6426
6427 /// Builds a string representing ambiguous paths from a
6428 /// specific derived class to different subobjects of the same base
6429 /// class.
6430 ///
6431 /// This function builds a string that can be used in error messages
6432 /// to show the different paths that one can take through the
6433 /// inheritance hierarchy to go from the derived class to different
6434 /// subobjects of a base class. The result looks something like this:
6435 /// @code
6436 /// struct D -> struct B -> struct A
6437 /// struct D -> struct C -> struct A
6438 /// @endcode
6439 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
6440
6442 const CXXMethodDecl *Old);
6443
6444 /// CheckOverridingFunctionReturnType - Checks whether the return types are
6445 /// covariant, according to C++ [class.virtual]p5.
6447 const CXXMethodDecl *Old);
6448
6449 // Check that the overriding method has no explicit object parameter.
6451 const CXXMethodDecl *Old);
6452
6453 /// Mark the given method pure.
6454 ///
6455 /// \param Method the method to be marked pure.
6456 ///
6457 /// \param InitRange the source range that covers the "0" initializer.
6459
6460 /// CheckOverrideControl - Check C++11 override control semantics.
6462
6463 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
6464 /// not used in the declaration of an overriding method.
6466
6467 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
6468 /// function overrides a virtual member function marked 'final', according to
6469 /// C++11 [class.virtual]p4.
6471 const CXXMethodDecl *Old);
6472
6483
6484 struct TypeDiagnoser;
6485
6488 TypeDiagnoser &Diagnoser);
6489 template <typename... Ts>
6491 const Ts &...Args) {
6492 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6493 return RequireNonAbstractType(Loc, T, Diagnoser);
6494 }
6495
6496 void DiagnoseAbstractType(const CXXRecordDecl *RD);
6497
6498 //===--------------------------------------------------------------------===//
6499 // C++ Overloaded Operators [C++ 13.5]
6500 //
6501
6502 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
6503 /// of this overloaded operator is well-formed. If so, returns false;
6504 /// otherwise, emits appropriate diagnostics and returns true.
6506
6507 /// CheckLiteralOperatorDeclaration - Check whether the declaration
6508 /// of this literal operator function is well-formed. If so, returns
6509 /// false; otherwise, emits appropriate diagnostics and returns true.
6511
6512 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
6513 /// found in an explicit(bool) specifier.
6515
6516 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
6517 /// Returns true if the explicit specifier is now resolved.
6519
6520 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
6521 /// C++ if/switch/while/for statement.
6522 /// e.g: "if (int x = f()) {...}"
6524
6525 // Emitting members of dllexported classes is delayed until the class
6526 // (including field initializers) is fully parsed.
6529
6530 /// Merge the exception specifications of two variable declarations.
6531 ///
6532 /// This is called when there's a redeclaration of a VarDecl. The function
6533 /// checks if the redeclaration might have an exception specification and
6534 /// validates compatibility and merges the specs if necessary.
6536
6537 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
6538 /// function, once we already know that they have the same
6539 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
6540 /// error, false otherwise.
6542
6543 /// Helpers for dealing with blocks and functions.
6545
6546 /// CheckExtraCXXDefaultArguments - Check for any extra default
6547 /// arguments in the declarator, which is not a function declaration
6548 /// or definition and therefore is not permitted to have default
6549 /// arguments. This routine should be invoked for every declarator
6550 /// that is not a function declaration or definition.
6552
6553 /// Perform semantic analysis for the variable declaration that
6554 /// occurs within a C++ catch clause, returning the newly-created
6555 /// variable.
6557 SourceLocation StartLoc,
6558 SourceLocation IdLoc,
6559 const IdentifierInfo *Id);
6560
6561 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
6562 /// handler.
6564
6566
6567 /// Handle a friend tag declaration where the scope specifier was
6568 /// templated.
6570 unsigned TagSpec, SourceLocation TagLoc,
6571 CXXScopeSpec &SS, IdentifierInfo *Name,
6572 SourceLocation NameLoc,
6573 SourceLocation EllipsisLoc,
6575 MultiTemplateParamsArg TempParamLists,
6576 TemplateIdAnnotation *TemplateId);
6577
6580 bool IsInstantiation);
6581
6583 NestedNameSpecifierLoc NNSLoc);
6584
6586 SourceLocation DeclStart, Declarator &D,
6587 Expr *BitfieldWidth,
6588 InClassInitStyle InitStyle,
6589 AccessSpecifier AS,
6590 const ParsedAttr &MSPropertyAttr);
6591
6592 /// Diagnose why the specified class does not have a trivial special member of
6593 /// the given kind.
6596
6597 /// Determine whether a defaulted or deleted special member function is
6598 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
6599 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
6603 bool Diagnose = false);
6604
6605 /// Handle a C++11 empty-declaration and attribute-declaration.
6607 SourceLocation SemiLoc);
6608
6610 /// Diagnose issues that are non-constant or that are extensions.
6612 /// Identify whether this function satisfies the formal rules for constexpr
6613 /// functions in the current lanugage mode (with no extensions).
6615 };
6616
6617 // Check whether a function declaration satisfies the requirements of a
6618 // constexpr function definition or a constexpr constructor definition. If so,
6619 // return true. If not, produce appropriate diagnostics (unless asked not to
6620 // by Kind) and return false.
6621 //
6622 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
6624 CheckConstexprKind Kind);
6625
6626 /// Diagnose methods which overload virtual methods in a base class
6627 /// without overriding any.
6629
6630 /// Check if a method overloads virtual methods in a base class without
6631 /// overriding any.
6632 void
6634 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6635 void
6637 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6638
6639 /// ActOnParamDefaultArgument - Check whether the default argument
6640 /// provided for a function parameter is well-formed. If so, attach it
6641 /// to the parameter declaration.
6642 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
6643 Expr *defarg);
6644
6645 /// ActOnParamUnparsedDefaultArgument - We've seen a default
6646 /// argument for a function parameter, but we can't parse it yet
6647 /// because we're inside a class definition. Note that this default
6648 /// argument will be parsed later.
6650 SourceLocation ArgLoc);
6651
6652 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
6653 /// the default argument for the parameter param failed.
6655 Expr *DefaultArg);
6657 SourceLocation EqualLoc);
6658 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
6659 SourceLocation EqualLoc);
6660
6661 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
6662 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
6663 StringLiteral *Message = nullptr);
6664 /// Mark the given declaration as explicitly defaulted.
6665 ///
6666 /// \param S The scope in which the function is defaulted, if it is
6667 /// available. It is used to perform the unqualified name lookups needed by
6668 /// the implicit definition of an out-of-class defaulted function.
6669 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc,
6670 Scope *S = nullptr);
6671
6672 void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
6673 StringLiteral *DeletedMessage = nullptr,
6674 Scope *S = nullptr);
6678
6679 NamedDecl *
6681 MultiTemplateParamsArg TemplateParamLists);
6684 RecordDecl *ClassDecl,
6685 const IdentifierInfo *Name);
6686
6688 SourceLocation Loc);
6690
6691 /// Stack containing information needed when in C++2a an 'auto' is encountered
6692 /// in a function declaration parameter type specifier in order to invent a
6693 /// corresponding template parameter in the enclosing abbreviated function
6694 /// template. This information is also present in LambdaScopeInfo, stored in
6695 /// the FunctionScopes stack.
6697
6698 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6699 std::unique_ptr<CXXFieldCollector> FieldCollector;
6700
6702 /// Set containing all declared private fields that are not used.
6704
6706
6707 /// PureVirtualClassDiagSet - a set of class declarations which we have
6708 /// emitted a list of pure virtual functions. Used to prevent emitting the
6709 /// same list more than once.
6710 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6711
6715
6716 /// All the delegating constructors seen so far in the file, used for
6717 /// cycle detection at the end of the TU.
6719
6720 /// The C++ "std" namespace, where the standard library resides.
6722
6723 /// The C++ "std::initializer_list" template, which is defined in
6724 /// <initializer_list>.
6726
6727 /// The C++ "std::type_identity" template, which is defined in
6728 /// <type_traits>.
6730
6731 // Contains the locations of the beginning of unparsed default
6732 // argument locations.
6733 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6734
6735 /// UndefinedInternals - all the used, undefined objects which require a
6736 /// definition in this translation unit.
6737 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6738
6739 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6741
6742 /// The C++ special members which we are currently in the process of
6743 /// declaring. If this process recursively triggers the declaration of the
6744 /// same special member, we should act as if it is not yet declared.
6746
6748
6749 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6750
6753 ParsingClassDepth++;
6755 }
6757 ParsingClassDepth--;
6759 }
6760
6762 CXXScopeSpec &SS,
6763 ParsedType TemplateTypeTy,
6764 IdentifierInfo *MemberOrBase);
6765
6766private:
6767 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6768 QualType ResultTy,
6769 ArrayRef<QualType> Args);
6770 // Helper for ActOnFields to check for all function pointer members.
6771 bool EntirelyFunctionPointers(const RecordDecl *Record);
6772
6773 // A cache representing if we've fully checked the various comparison category
6774 // types stored in ASTContext. The bit-index corresponds to the integer value
6775 // of a ComparisonCategoryType enumerator.
6776 llvm::SmallBitVector FullyCheckedComparisonCategories;
6777
6778 /// Check if there is a field shadowing.
6779 void CheckShadowInheritedFields(const SourceLocation &Loc,
6780 DeclarationName FieldName,
6781 const CXXRecordDecl *RD,
6782 bool DeclIsField = true);
6783
6784 ///@}
6785
6786 //
6787 //
6788 // -------------------------------------------------------------------------
6789 //
6790 //
6791
6792 /// \name C++ Exception Specifications
6793 /// Implementations are in SemaExceptionSpec.cpp
6794 ///@{
6795
6796public:
6797 /// All the overriding functions seen during a class definition
6798 /// that had their exception spec checks delayed, plus the overridden
6799 /// function.
6802
6803 /// All the function redeclarations seen during a class definition that had
6804 /// their exception spec checks delayed, plus the prior declaration they
6805 /// should be checked against. Except during error recovery, the new decl
6806 /// should always be a friend declaration, as that's the only valid way to
6807 /// redeclare a special member before its class is complete.
6810
6811 /// Determine if we're in a case where we need to (incorrectly) eagerly
6812 /// parse an exception specification to work around a libstdc++ bug.
6814
6815 /// Check the given noexcept-specifier, convert its expression, and compute
6816 /// the appropriate ExceptionSpecificationType.
6817 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6819
6820 CanThrowResult canThrow(const Stmt *E);
6821 /// Determine whether the callee of a particular function call can throw.
6822 /// E, D and Loc are all optional.
6823 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6826 const FunctionProtoType *FPT);
6829
6830 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6831 /// exception specification. Incomplete types, or pointers to incomplete types
6832 /// other than void are not allowed.
6833 ///
6834 /// \param[in,out] T The exception type. This will be decayed to a pointer
6835 /// type
6836 /// when the input is an array or a function type.
6838
6839 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6840 /// pointer to member to a function with an exception specification. This
6841 /// means that it is invalid to add another level of indirection.
6844
6845 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6846 /// exception specifications. Exception specifications are equivalent if
6847 /// they allow exactly the same set of exception types. It does not matter how
6848 /// that is achieved. See C++ [except.spec]p2.
6850 SourceLocation OldLoc,
6851 const FunctionProtoType *New,
6852 SourceLocation NewLoc);
6854 const PartialDiagnostic &NoteID,
6855 const FunctionProtoType *Old,
6856 SourceLocation OldLoc,
6857 const FunctionProtoType *New,
6858 SourceLocation NewLoc);
6859 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6860
6861 /// CheckExceptionSpecSubset - Check whether the second function type's
6862 /// exception specification is a subset (or equivalent) of the first function
6863 /// type. This is used by override and pointer assignment checks.
6865 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6866 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6867 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6868 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6869 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6870
6871 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6872 /// two functions have equivalent exception specs. This is part of the
6873 /// assignment and override compatibility check. We do not check the
6874 /// parameters of parameter function pointers recursively, as no sane
6875 /// programmer would even be able to write such a function type.
6877 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6878 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6879 SourceLocation TargetLoc, const FunctionProtoType *Source,
6880 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6881
6882 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6883
6884 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6885 /// spec is a subset of base spec.
6887 const CXXMethodDecl *Old);
6888
6889 ///@}
6890
6891 //
6892 //
6893 // -------------------------------------------------------------------------
6894 //
6895 //
6896
6897 /// \name Expressions
6898 /// Implementations are in SemaExpr.cpp
6899 ///@{
6900
6901public:
6902 /// Describes how the expressions currently being parsed are
6903 /// evaluated at run-time, if at all.
6905 /// The current expression and its subexpressions occur within an
6906 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6907 /// \c sizeof, where the type of the expression may be significant but
6908 /// no code will be generated to evaluate the value of the expression at
6909 /// run time.
6911
6912 /// The current expression occurs within a braced-init-list within
6913 /// an unevaluated operand. This is mostly like a regular unevaluated
6914 /// context, except that we still instantiate constexpr functions that are
6915 /// referenced here so that we can perform narrowing checks correctly.
6917
6918 /// The current expression occurs within a discarded statement.
6919 /// This behaves largely similarly to an unevaluated operand in preventing
6920 /// definitions from being required, but not in other ways.
6922
6923 /// The current expression occurs within an unevaluated
6924 /// operand that unconditionally permits abstract references to
6925 /// fields, such as a SIZE operator in MS-style inline assembly.
6927
6928 /// The current context is "potentially evaluated" in C++11 terms,
6929 /// but the expression is evaluated at compile-time (like the values of
6930 /// cases in a switch statement).
6932
6933 /// In addition of being constant evaluated, the current expression
6934 /// occurs in an immediate function context - either a consteval function
6935 /// or a consteval if statement.
6937
6938 /// The current expression is potentially evaluated at run time,
6939 /// which means that code may be generated to evaluate the value of the
6940 /// expression at run time.
6942
6943 /// The current expression is potentially evaluated, but any
6944 /// declarations referenced inside that expression are only used if
6945 /// in fact the current expression is used.
6946 ///
6947 /// This value is used when parsing default function arguments, for which
6948 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6949 /// through varargs) but do not want to mark declarations as "referenced"
6950 /// until the default argument is used.
6952 };
6953
6954 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6955 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6956 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6957 /// have been applied to all subexpressions of the enclosing full expression.
6958 /// This is cleared at the end of each full expression.
6961
6962 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6963
6964 /// Data structure used to record current or nested
6965 /// expression evaluation contexts.
6967 /// The expression evaluation context.
6969
6970 /// Whether the enclosing context needed a cleanup.
6972
6973 /// The number of active cleanup objects when we entered
6974 /// this expression evaluation context.
6976
6978
6979 /// The lambdas that are present within this context, if it
6980 /// is indeed an unevaluated context.
6982
6983 /// The declaration that provides context for lambda expressions
6984 /// and block literals if the normal declaration context does not
6985 /// suffice, e.g., in a default function argument.
6987
6988 /// Declaration for initializer if one is currently being
6989 /// parsed. Used when an expression has a possibly unreachable
6990 /// diagnostic to reference the declaration as a whole.
6992
6993 /// If we are processing a decltype type, a set of call expressions
6994 /// for which we have deferred checking the completeness of the return type.
6996
6997 /// If we are processing a decltype type, a set of temporary binding
6998 /// expressions for which we have deferred checking the destructor.
7000
7002
7003 /// Expressions appearing as the LHS of a volatile assignment in this
7004 /// context. We produce a warning for these when popping the context if
7005 /// they are not discarded-value expressions nor unevaluated operands.
7007
7008 /// Set of candidates for starting an immediate invocation.
7011
7012 /// Set of DeclRefExprs referencing a consteval function when used in a
7013 /// context not already known to be immediately invoked.
7015
7016 /// P2718R0 - Lifetime extension in range-based for loops.
7017 /// MaterializeTemporaryExprs in for-range-init expressions which need to
7018 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
7019 /// InLifetimeExtendingContext is true.
7021
7022 /// Small set of gathered accesses to potentially misaligned members
7023 /// due to the packed attribute.
7025
7026 /// \brief Describes whether we are in an expression constext which we have
7027 /// to handle differently.
7035
7036 // A context can be nested in both a discarded statement context and
7037 // an immediate function context, so they need to be tracked independently.
7041
7043
7044 // We are in a constant context, but we also allow
7045 // non constant expressions, for example for array bounds (which may be
7046 // VLAs).
7048
7049 /// Whether we are currently in a context in which all temporaries must be
7050 /// lifetime-extended, even if they're not bound to a reference (for
7051 /// example, in a for-range initializer).
7053
7054 /// Whether evaluating an expression for a switch case label.
7055 bool IsCaseExpr = false;
7056
7057 /// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
7059
7060 // When evaluating immediate functions in the initializer of a default
7061 // argument or default member initializer, this is the declaration whose
7062 // default initializer is being evaluated and the location of the call
7063 // or constructor definition.
7067 : Loc(Loc), Decl(Decl), Context(Context) {
7068 assert(Decl && Context && "invalid initialization context");
7069 }
7070
7072 ValueDecl *Decl = nullptr;
7074 };
7075 std::optional<InitializationContext> DelayedDefaultInitializationContext;
7076
7087
7093
7100
7105
7110 // C++23 [expr.const]p14:
7111 // An expression or conversion is in an immediate function
7112 // context if it is potentially evaluated and either:
7113 // * its innermost enclosing non-block scope is a function
7114 // parameter scope of an immediate function, or
7115 // * its enclosing statement is enclosed by the compound-
7116 // statement of a consteval if statement.
7119 }
7120
7128 };
7129
7131 assert(!ExprEvalContexts.empty() &&
7132 "Must be in an expression evaluation context");
7133 return ExprEvalContexts.back();
7134 }
7135
7137 assert(!ExprEvalContexts.empty() &&
7138 "Must be in an expression evaluation context");
7139 return ExprEvalContexts.back();
7140 }
7141
7143 assert(ExprEvalContexts.size() >= 2 &&
7144 "Must be in an expression evaluation context");
7145 return ExprEvalContexts[ExprEvalContexts.size() - 2];
7146 }
7147
7149 return const_cast<Sema *>(this)->parentEvaluationContext();
7150 }
7151
7156
7157 /// Increment when we find a reference; decrement when we find an ignored
7158 /// assignment. Ultimately the value is 0 if every reference is an ignored
7159 /// assignment.
7160 ///
7161 /// Uses canonical VarDecl as key so in-class decls and out-of-class defs of
7162 /// static data members get tracked as a single entry.
7163 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
7164
7165 /// Used to control the generation of ExprWithCleanups.
7167
7168 /// ExprCleanupObjects - This is the stack of objects requiring
7169 /// cleanup that are created by the current full expression.
7171
7172 /// Determine whether the use of this declaration is valid, without
7173 /// emitting diagnostics.
7174 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
7175 // A version of DiagnoseUseOfDecl that should be used if overload resolution
7176 // has been used to find this declaration, which means we don't have to bother
7177 // checking the trailing requires clause.
7179 return DiagnoseUseOfDecl(
7180 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
7181 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
7182 /*SkipTrailingRequiresClause=*/true);
7183 }
7184
7185 /// Determine whether the use of this declaration is valid, and
7186 /// emit any corresponding diagnostics.
7187 ///
7188 /// This routine diagnoses various problems with referencing
7189 /// declarations that can occur when using a declaration. For example,
7190 /// it might warn if a deprecated or unavailable declaration is being
7191 /// used, or produce an error (and return true) if a C++0x deleted
7192 /// function is being used.
7193 ///
7194 /// \returns true if there was an error (this declaration cannot be
7195 /// referenced), false otherwise.
7197 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
7198 bool ObjCPropertyAccess = false,
7199 bool AvoidPartialAvailabilityChecks = false,
7200 ObjCInterfaceDecl *ClassReceiver = nullptr,
7201 bool SkipTrailingRequiresClause = false);
7202
7203 /// Emit a note explaining that this function is deleted.
7205
7206 /// DiagnoseSentinelCalls - This routine checks whether a call or
7207 /// message-send is to a declaration with the sentinel attribute, and
7208 /// if so, it checks that the requirements of the sentinel are
7209 /// satisfied.
7211 ArrayRef<Expr *> Args);
7212
7214 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
7217
7219 ExpressionEvaluationContext NewContext, FunctionDecl *FD);
7220
7223 ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
7227
7229
7233
7234 /// Check whether E, which is either a discarded-value expression or an
7235 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
7236 /// lvalue, and if so, remove it from the list of volatile-qualified
7237 /// assignments that we are going to warn are deprecated.
7239
7241
7242 // Functions for marking a declaration referenced. These functions also
7243 // contain the relevant logic for marking if a reference to a function or
7244 // variable is an odr-use (in the C++11 sense). There are separate variants
7245 // for expressions referring to a decl; these exist because odr-use marking
7246 // needs to be delayed for some constant variables when we build one of the
7247 // named expressions.
7248 //
7249 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
7250 // should usually be true. This only needs to be set to false if the lack of
7251 // odr-use cannot be determined from the current context (for instance,
7252 // because the name denotes a virtual function and was written without an
7253 // explicit nested-name-specifier).
7254 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
7255
7256 /// Mark a function referenced, and check whether it is odr-used
7257 /// (C++ [basic.def.odr]p2, C99 6.9p3)
7259 bool MightBeOdrUse = true);
7260
7261 /// Mark a variable referenced, and check whether it is odr-used
7262 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
7263 /// used directly for normal expressions referring to VarDecl.
7265
7266 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
7267 ///
7268 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
7269 /// be handled with care if the DeclRefExpr is not newly-created.
7270 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
7271
7272 /// Perform reference-marking and odr-use handling for a MemberExpr.
7274
7275 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
7278 unsigned CapturingScopeIndex);
7279
7281 void CleanupVarDeclMarking();
7282
7283 /// Try to capture the given variable.
7284 ///
7285 /// \param Var The variable to capture.
7286 ///
7287 /// \param Loc The location at which the capture occurs.
7288 ///
7289 /// \param Kind The kind of capture, which may be implicit (for either a
7290 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
7291 ///
7292 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
7293 /// an explicit lambda capture.
7294 ///
7295 /// \param BuildAndDiagnose Whether we are actually supposed to add the
7296 /// captures or diagnose errors. If false, this routine merely check whether
7297 /// the capture can occur without performing the capture itself or complaining
7298 /// if the variable cannot be captured.
7299 ///
7300 /// \param CaptureType Will be set to the type of the field used to capture
7301 /// this variable in the innermost block or lambda. Only valid when the
7302 /// variable can be captured.
7303 ///
7304 /// \param DeclRefType Will be set to the type of a reference to the capture
7305 /// from within the current scope. Only valid when the variable can be
7306 /// captured.
7307 ///
7308 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
7309 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
7310 /// This is useful when enclosing lambdas must speculatively capture
7311 /// variables that may or may not be used in certain specializations of
7312 /// a nested generic lambda.
7313 ///
7314 /// \returns true if an error occurred (i.e., the variable cannot be
7315 /// captured) and false if the capture succeeded.
7317 TryCaptureKind Kind, SourceLocation EllipsisLoc,
7318 bool BuildAndDiagnose, QualType &CaptureType,
7319 QualType &DeclRefType,
7320 const unsigned *const FunctionScopeIndexToStopAt);
7321
7322 /// Try to capture the given variable.
7325 SourceLocation EllipsisLoc = SourceLocation());
7326
7327 /// Checks if the variable must be captured.
7329
7330 /// Given a variable, determine the type that a reference to that
7331 /// variable will have in the given scope.
7333
7334 /// Handle a use of the variably modified type \p T in the current context.
7335 /// Array bounds evaluated in an enclosing context are captured by the
7336 /// lambdas in between; if a local class or a block is in between instead,
7337 /// the use is diagnosed. Returns false if the use is invalid.
7339
7340 /// Mark all of the declarations referenced within a particular AST node as
7341 /// referenced. Used when template instantiation instantiates a non-dependent
7342 /// type -- entities referenced by the type are now referenced.
7344
7345 /// Mark any declarations that appear within this expression or any
7346 /// potentially-evaluated subexpressions as "referenced".
7347 ///
7348 /// \param SkipLocalVariables If true, don't mark local variables as
7349 /// 'referenced'.
7350 /// \param StopAt Subexpressions that we shouldn't recurse into.
7352 bool SkipLocalVariables = false,
7353 ArrayRef<const Expr *> StopAt = {});
7354
7355 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
7356 /// conversion.
7357 ExprResult tryConvertExprToType(Expr *E, QualType Ty);
7358
7359 /// Conditionally issue a diagnostic based on the statements's reachability
7360 /// analysis.
7361 ///
7362 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
7363 /// the function body is parsed, and then do a basic reachability analysis to
7364 /// determine if the statement is reachable. If it is unreachable, the
7365 /// diagnostic will not be emitted.
7366 bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7367 const PartialDiagnostic &PD);
7368
7369 /// Conditionally issue a diagnostic based on the current
7370 /// evaluation context.
7371 ///
7372 /// \param Statement If Statement is non-null, delay reporting the
7373 /// diagnostic until the function body is parsed, and then do a basic
7374 /// reachability analysis to determine if the statement is reachable.
7375 /// If it is unreachable, the diagnostic will not be emitted.
7376 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
7377 const PartialDiagnostic &PD);
7378 /// Similar, but diagnostic is only produced if all the specified statements
7379 /// are reachable.
7380 bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7381 const PartialDiagnostic &PD);
7382
7383 // Primary Expressions.
7384 SourceRange getExprRange(Expr *E) const;
7385
7386 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
7387 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
7388 bool IsCall, bool IsAddressOfOperand,
7389 CorrectionCandidateCallback *CCC = nullptr,
7390 bool IsInlineAsmIdentifier = false);
7391
7392 /// Decomposes the given name into a DeclarationNameInfo, its location, and
7393 /// possibly a list of template arguments.
7394 ///
7395 /// If this produces template arguments, it is permitted to call
7396 /// DecomposeTemplateName.
7397 ///
7398 /// This actually loses a lot of source location information for
7399 /// non-standard name kinds; we should consider preserving that in
7400 /// some way.
7401 void DecomposeUnqualifiedId(const UnqualifiedId &Id,
7402 TemplateArgumentListInfo &Buffer,
7403 DeclarationNameInfo &NameInfo,
7404 const TemplateArgumentListInfo *&TemplateArgs);
7405
7406 /// Diagnose a lookup that found results in an enclosing class during error
7407 /// recovery. This usually indicates that the results were found in a
7408 /// dependent base class that could not be searched as part of a template
7409 /// definition. Always issues a diagnostic (though this may be only a warning
7410 /// in MS compatibility mode).
7411 ///
7412 /// Return \c true if the error is unrecoverable, or \c false if the caller
7413 /// should attempt to recover using these lookup results.
7414 bool DiagnoseDependentMemberLookup(const LookupResult &R);
7415
7416 /// Diagnose an empty lookup.
7417 ///
7418 /// \return false if new lookup candidates were found
7419 bool
7420 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
7421 CorrectionCandidateCallback &CCC,
7422 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
7423 ArrayRef<Expr *> Args = {},
7424 DeclContext *LookupCtx = nullptr);
7425
7426 /// If \p D cannot be odr-used in the current expression evaluation context,
7427 /// return a reason explaining why. Otherwise, return NOUR_None.
7429
7430 DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7431 SourceLocation Loc,
7432 const CXXScopeSpec *SS = nullptr);
7433 DeclRefExpr *
7434 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7435 const DeclarationNameInfo &NameInfo,
7436 const CXXScopeSpec *SS = nullptr,
7437 NamedDecl *FoundD = nullptr,
7438 SourceLocation TemplateKWLoc = SourceLocation(),
7439 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7440
7441 /// BuildDeclRefExpr - Build an expression that references a
7442 /// declaration that does not require a closure capture.
7443 DeclRefExpr *
7444 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7445 const DeclarationNameInfo &NameInfo,
7446 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
7447 SourceLocation TemplateKWLoc = SourceLocation(),
7448 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7449
7450 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
7451 bool IsCall);
7452
7453 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
7454 /// declaration name, generally during template instantiation.
7455 /// There's a large number of things which don't need to be done along
7456 /// this path.
7458 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
7459 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
7460
7461 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
7462 bool NeedsADL,
7463 bool AcceptInvalidDecl = false);
7464
7465 /// Complete semantic analysis for a reference to the given declaration.
7467 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
7468 NamedDecl *FoundD = nullptr,
7469 const TemplateArgumentListInfo *TemplateArgs = nullptr,
7470 bool AcceptInvalidDecl = false);
7471
7472 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
7473 // where Tokens representing function local predefined macros (such as
7474 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
7475 std::vector<Token> ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks);
7476
7477 ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK);
7478 ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
7479 ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
7480
7481 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
7482
7483 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
7485 Scope *UDLScope = nullptr);
7486 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
7487 ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
7488 MultiExprArg Val);
7489 ExprResult ActOnCXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
7490 unsigned NumUserSpecifiedExprs,
7491 SourceLocation InitLoc,
7492 SourceLocation LParenLoc,
7493 SourceLocation RParenLoc);
7494
7495 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
7496 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
7497 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
7498 /// from multiple tokens. However, the common case is that StringToks points
7499 /// to one string.
7500 ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
7501 Scope *UDLScope = nullptr,
7503
7504 ExprResult ActOnUnevaluatedStringLiteral(ArrayRef<Token> StringToks);
7505
7506 /// ControllingExprOrType is either an opaque pointer coming out of a
7507 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
7508 /// into two so we don't take a void *, but that's awkward because one of
7509 /// the operands is either a ParsedType or an Expr *, which doesn't lend
7510 /// itself to generic code very well.
7511 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
7512 SourceLocation DefaultLoc,
7513 SourceLocation RParenLoc,
7514 bool PredicateIsExpr,
7515 void *ControllingExprOrType,
7516 ArrayRef<ParsedType> ArgTypes,
7517 ArrayRef<Expr *> ArgExprs);
7518 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
7519 /// it'd be better to split this interface into two so we don't take a
7520 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
7521 /// isn't a trivial change.
7522 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
7523 SourceLocation DefaultLoc,
7524 SourceLocation RParenLoc,
7525 bool PredicateIsExpr,
7526 void *ControllingExprOrType,
7527 ArrayRef<TypeSourceInfo *> Types,
7528 ArrayRef<Expr *> Exprs);
7529
7530 // Binary/Unary Operators. 'Tok' is the token for the operator.
7531 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
7532 Expr *InputExpr, bool IsAfterAmp = false);
7533 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc,
7534 Expr *Input, bool IsAfterAmp = false);
7535
7536 /// Unary Operators. 'Tok' is the token for the operator.
7537 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op,
7538 Expr *Input, bool IsAfterAmp = false);
7539
7540 /// Determine whether the given expression is a qualified member
7541 /// access expression, of a form that could be turned into a pointer to member
7542 /// with the address-of operator.
7543 bool isQualifiedMemberAccess(Expr *E);
7544 bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
7545 const Expr *Op,
7546 const CXXMethodDecl *MD);
7547
7548 /// CheckAddressOfOperand - The operand of & must be either a function
7549 /// designator or an lvalue designating an object. If it is an lvalue, the
7550 /// object cannot be declared with storage class register or be a bit field.
7551 /// Note: The usual conversions are *not* applied to the operand of the &
7552 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
7553 /// In C++, the operand might be an overloaded function name, in which case
7554 /// we allow the '&' but retain the overloaded-function type.
7555 QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
7556
7557 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
7558 /// _Alignas(type-name) .
7559 /// [dcl.align] An alignment-specifier of the form
7560 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
7561 ///
7562 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
7563 /// _Alignas(_Alignof(type-name)).
7564 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
7565 SourceLocation OpLoc, SourceRange R);
7566 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
7567 SourceLocation OpLoc, SourceRange R);
7568
7569 /// Build a sizeof or alignof expression given a type operand.
7570 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
7571 SourceLocation OpLoc,
7572 UnaryExprOrTypeTrait ExprKind,
7573 SourceRange R);
7574
7575 /// Build a sizeof or alignof expression given an expression
7576 /// operand.
7577 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
7578 UnaryExprOrTypeTrait ExprKind);
7579
7580 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
7581 /// expr and the same for @c alignof and @c __alignof
7582 /// Note that the ArgRange is invalid if isType is false.
7583 ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
7584 UnaryExprOrTypeTrait ExprKind,
7585 bool IsType, void *TyOrEx,
7586 SourceRange ArgRange);
7587
7588 /// Check for operands with placeholder types and complain if found.
7589 /// Returns ExprError() if there was an error and no recovery was possible.
7591 bool CheckVecStepExpr(Expr *E);
7592
7593 /// Check the constraints on expression operands to unary type expression
7594 /// and type traits.
7595 ///
7596 /// Completes any types necessary and validates the constraints on the operand
7597 /// expression. The logic mostly mirrors the type-based overload, but may
7598 /// modify the expression as it completes the type for that expression through
7599 /// template instantiation, etc.
7600 bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind);
7601
7602 /// Check the constraints on operands to unary expression and type
7603 /// traits.
7604 ///
7605 /// This will complete any types necessary, and validate the various
7606 /// constraints on those operands.
7607 ///
7608 /// The UsualUnaryConversions() function is *not* called by this routine.
7609 /// C99 6.3.2.1p[2-4] all state:
7610 /// Except when it is the operand of the sizeof operator ...
7611 ///
7612 /// C++ [expr.sizeof]p4
7613 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
7614 /// standard conversions are not applied to the operand of sizeof.
7615 ///
7616 /// This policy is followed for all of the unary trait expressions.
7617 bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
7618 SourceRange ExprRange,
7619 UnaryExprOrTypeTrait ExprKind,
7620 StringRef KWName);
7621
7622 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
7623 tok::TokenKind Kind, Expr *Input);
7624
7625 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
7626 MultiExprArg ArgExprs,
7627 SourceLocation RLoc);
7628 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
7629 Expr *Idx, SourceLocation RLoc);
7630
7631 ExprResult CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx,
7632 SourceLocation RBLoc);
7633
7634 ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx,
7635 Expr *ColumnIdx,
7636 SourceLocation RBLoc);
7637
7638 /// ConvertArgumentsForCall - Converts the arguments specified in
7639 /// Args/NumArgs to the parameter types of the function FDecl with
7640 /// function prototype Proto. Call is the call expression itself, and
7641 /// Fn is the function expression. For a C++ member function, this
7642 /// routine does not attempt to convert the object argument. Returns
7643 /// true if the call is ill-formed.
7644 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl,
7645 const FunctionProtoType *Proto,
7646 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
7647 bool ExecConfig = false);
7648
7649 /// CheckStaticArrayArgument - If the given argument corresponds to a static
7650 /// array parameter, check that it is non-null, and that if it is formed by
7651 /// array-to-pointer decay, the underlying array is sufficiently large.
7652 ///
7653 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
7654 /// the array type derivation, then for each call to the function, the value
7655 /// of the corresponding actual argument shall provide access to the first
7656 /// element of an array with at least as many elements as specified by the
7657 /// size expression.
7658 void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
7659 const Expr *ArgExpr);
7660
7661 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
7662 /// This provides the location of the left/right parens and a list of comma
7663 /// locations.
7664 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7665 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7666 Expr *ExecConfig = nullptr);
7667
7668 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
7669 /// This provides the location of the left/right parens and a list of comma
7670 /// locations.
7671 ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7672 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7673 Expr *ExecConfig = nullptr,
7674 bool IsExecConfig = false,
7675 bool AllowRecovery = false);
7676
7677 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
7678 /// with the specified CallArgs. Id is unsigned rather than Builtin::ID, so
7679 /// that it can also be a target-specific builtin ID, which is not in
7680 /// Builtin::ID, e.g., BPF::BI__builtin_preserve_enum_value.
7681 Expr *BuildBuiltinCallExpr(SourceLocation Loc, unsigned Id,
7682 MultiExprArg CallArgs);
7683
7685
7686 /// BuildResolvedCallExpr - Build a call to a resolved expression,
7687 /// i.e. an expression not of \p OverloadTy. The expression should
7688 /// unary-convert to an expression of function-pointer or
7689 /// block-pointer type.
7690 ///
7691 /// \param NDecl the declaration being called, if available
7693 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
7694 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
7695 Expr *Config = nullptr, bool IsExecConfig = false,
7696 ADLCallKind UsesADL = ADLCallKind::NotADL);
7697
7699 ParsedType &Ty, SourceLocation RParenLoc,
7700 Expr *CastExpr);
7701
7702 /// Prepares for a scalar cast, performing all the necessary stages
7703 /// except the final cast and returning the kind required.
7705
7706 /// Build an altivec or OpenCL literal.
7708 SourceLocation RParenLoc, Expr *E,
7709 TypeSourceInfo *TInfo);
7710
7711 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7712 /// the ParenListExpr into a sequence of comma binary operators.
7714
7716 SourceLocation RParenLoc, Expr *InitExpr);
7717
7719 TypeSourceInfo *TInfo,
7720 SourceLocation RParenLoc,
7721 Expr *LiteralExpr);
7722
7723 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7724 SourceLocation RBraceLoc);
7725
7726 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7727 SourceLocation RBraceLoc, bool IsExplicit);
7728
7729 /// Binary Operators. 'Tok' is the token for the operator.
7731 Expr *LHSExpr, Expr *RHSExpr);
7733 Expr *LHSExpr, Expr *RHSExpr,
7734 bool ForFoldExpression = false);
7735
7736 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7737 /// operator @p Opc at location @c TokLoc. This routine only supports
7738 /// built-in operations; ActOnBinOp handles overloaded operators.
7740 Expr *LHSExpr, Expr *RHSExpr,
7741 bool ForFoldExpression = false);
7743 UnresolvedSetImpl &Functions);
7744
7745 /// Look for instances where it is likely the comma operator is confused with
7746 /// another operator. There is an explicit list of acceptable expressions for
7747 /// the left hand side of the comma operator, otherwise emit a warning.
7748 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7749
7750 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7751 /// in the case of a the GNU conditional expr extension.
7753 SourceLocation ColonLoc, Expr *CondExpr,
7754 Expr *LHSExpr, Expr *RHSExpr);
7755
7756 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7758 LabelDecl *TheDecl);
7759
7760 void ActOnStartStmtExpr();
7761 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7762 SourceLocation RPLoc);
7764 SourceLocation RPLoc, unsigned TemplateDepth);
7765 // Handle the final expression in a statement expression.
7767 void ActOnStmtExprError();
7768
7769 /// __builtin_offsetof(type, a.b[123][456].c)
7771 TypeSourceInfo *TInfo,
7772 const Designation &Desig,
7773 SourceLocation RParenLoc);
7776 ParsedType ParsedArgTy,
7777 const Designation &Desig,
7778 SourceLocation RParenLoc);
7779
7780 // __builtin_choose_expr(constExpr, expr1, expr2)
7781 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7782 Expr *LHSExpr, Expr *RHSExpr,
7783 SourceLocation RPLoc);
7784
7785 // __builtin_va_arg(expr, type)
7787 SourceLocation RPLoc);
7789 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7790
7791 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7792 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7794 SourceLocation BuiltinLoc,
7795 SourceLocation RPLoc);
7796
7797 // #embed
7799 StringLiteral *BinaryData, StringRef FileName);
7800
7801 // Build a potentially resolved SourceLocExpr.
7803 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7804 DeclContext *ParentContext);
7805
7806 // __null
7808
7809 bool CheckCaseExpression(Expr *E);
7810
7811 //===------------------------- "Block" Extension ------------------------===//
7812
7813 /// ActOnBlockStart - This callback is invoked when a block literal is
7814 /// started.
7815 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7816
7817 /// ActOnBlockArguments - This callback allows processing of block arguments.
7818 /// If there are no arguments, this is still invoked.
7819 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7820 Scope *CurScope);
7821
7822 /// ActOnBlockError - If there is an error parsing a block, this callback
7823 /// is invoked to pop the information about the block from the action impl.
7824 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7825
7826 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7827 /// literal was successfully completed. ^(int x){...}
7829 Scope *CurScope);
7830
7831 //===---------------------------- Clang Extensions ----------------------===//
7832
7833 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7834 /// provided arguments.
7835 ///
7836 /// __builtin_convertvector( value, dst type )
7837 ///
7839 SourceLocation BuiltinLoc,
7840 SourceLocation RParenLoc);
7841
7842 //===---------------------------- OpenCL Features -----------------------===//
7843
7844 /// Parse a __builtin_astype expression.
7845 ///
7846 /// __builtin_astype( value, dst type )
7847 ///
7848 ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
7849 SourceLocation BuiltinLoc,
7850 SourceLocation RParenLoc);
7851
7852 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7854 SourceLocation BuiltinLoc,
7855 SourceLocation RParenLoc);
7856
7857 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7859 ArrayRef<Expr *> SubExprs,
7860 QualType T = QualType());
7861
7862 /// Cast a base object to a member's actual type.
7863 ///
7864 /// There are two relevant checks:
7865 ///
7866 /// C++ [class.access.base]p7:
7867 ///
7868 /// If a class member access operator [...] is used to access a non-static
7869 /// data member or non-static member function, the reference is ill-formed
7870 /// if the left operand [...] cannot be implicitly converted to a pointer to
7871 /// the naming class of the right operand.
7872 ///
7873 /// C++ [expr.ref]p7:
7874 ///
7875 /// If E2 is a non-static data member or a non-static member function, the
7876 /// program is ill-formed if the class of which E2 is directly a member is
7877 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7878 ///
7879 /// Note that the latter check does not consider access; the access of the
7880 /// "real" base class is checked as appropriate when checking the access of
7881 /// the member name.
7883 NestedNameSpecifier Qualifier,
7884 NamedDecl *FoundDecl,
7885 NamedDecl *Member);
7886
7887 /// CheckCallReturnType - Checks that a call expression's return type is
7888 /// complete. Returns true on failure. The location passed in is the location
7889 /// that best represents the call.
7890 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
7891 CallExpr *CE, FunctionDecl *FD);
7892
7893 /// Emit a warning for all pending noderef expressions that we recorded.
7895
7896private:
7897 /// Shared logic for building default member initializer which used in a
7898 /// constructor or an aggregate initialization.
7899 ///
7900 ///
7901 /// The caller enters that evaluation context and decides whether the result
7902 /// is finished as a full-expression. \p NestedDefaultChecking and
7903 /// \p NeedRebuild have to be sampled before entering it.
7904 ExprResult BuildCXXDefaultInitInternal(SourceLocation Loc, FieldDecl *Field,
7905 const InitializedEntity &Entity,
7906 bool NestedDefaultChecking,
7907 bool NeedRebuild);
7908
7909public:
7913 const InitializedEntity &MemberEntity);
7914
7915 /// Instantiate or parse a C++ default argument expression as necessary.
7916 /// Return true on error.
7918 ParmVarDecl *Param, Expr *Init = nullptr,
7919 bool SkipImmediateInvocations = true);
7920
7921 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7922 /// the default expr if needed.
7924 ParmVarDecl *Param, Expr *Init = nullptr);
7925
7926 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7927 /// invocation.
7929
7931
7932 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7933 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7934
7935 /// Abstract base class used for diagnosing integer constant
7936 /// expression violations.
7938 public:
7940
7942
7943 virtual SemaDiagnosticBuilder
7944 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7946 SourceLocation Loc) = 0;
7949 };
7950
7951 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7952 /// and reports the appropriate diagnostics. Returns false on success.
7953 /// Can optionally return the value of the expression.
7956 VerifyICEDiagnoser &Diagnoser,
7960 unsigned DiagID,
7963 VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result = nullptr,
7967 AllowFoldKind CanFold = AllowFoldKind::No) {
7968 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7969 }
7970
7971 /// DiagnoseAssignmentAsCondition - Given that an expression is
7972 /// being used as a boolean condition, warn if it's an assignment.
7974
7975 /// Redundant parentheses over an equality comparison can indicate
7976 /// that the user intended an assignment used as condition.
7978
7980 public:
7982 FullExprArg(Sema &actions) : E(nullptr) {}
7983
7984 ExprResult release() { return E; }
7985
7986 Expr *get() const { return E; }
7987
7988 Expr *operator->() { return E; }
7989
7990 private:
7991 // FIXME: No need to make the entire Sema class a friend when it's just
7992 // Sema::MakeFullExpr that needs access to the constructor below.
7993 friend class Sema;
7994
7995 explicit FullExprArg(Expr *expr) : E(expr) {}
7996
7997 Expr *E;
7998 };
7999
8001 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
8002 }
8004 return FullExprArg(
8005 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
8006 }
8008 ExprResult FE =
8009 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
8010 /*DiscardedValue*/ true);
8011 return FullExprArg(FE.get());
8012 }
8013
8014 class ConditionResult {
8015 Decl *ConditionVar;
8016 ExprResult Condition;
8017 bool Invalid;
8018 std::optional<bool> KnownValue;
8019
8020 friend class Sema;
8021 ConditionResult(Sema &S, Decl *ConditionVar, ExprResult Condition,
8022 bool IsConstexpr)
8023 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
8024 if (IsConstexpr && Condition.get()) {
8025 if (std::optional<llvm::APSInt> Val =
8026 Condition.get()->getIntegerConstantExpr(S.Context)) {
8027 KnownValue = !!(*Val);
8028 }
8029 }
8030 }
8031 explicit ConditionResult(bool Invalid)
8032 : ConditionVar(nullptr), Condition(Invalid), Invalid(Invalid),
8033 KnownValue(std::nullopt) {}
8034
8035 public:
8036 ConditionResult() : ConditionResult(false) {}
8037 bool isInvalid() const { return Invalid; }
8038 std::pair<VarDecl *, Expr *> get() const {
8039 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
8040 Condition.get());
8041 }
8042 std::optional<bool> getKnownValue() const { return KnownValue; }
8043 };
8045
8046 /// CheckBooleanCondition - Diagnose problems involving the use of
8047 /// the given expression as a boolean condition (e.g. in an if
8048 /// statement). Also performs the standard function and array
8049 /// decays, possibly changing the input variable.
8050 ///
8051 /// \param Loc - A location associated with the condition, e.g. the
8052 /// 'if' keyword.
8053 /// \return true iff there were any errors
8055 bool IsConstexpr = false);
8056
8057 enum class ConditionKind {
8058 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
8059 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
8060 Switch ///< An integral condition for a 'switch' statement.
8061 };
8062
8063 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
8064 ConditionKind CK, bool MissingOK = false);
8065
8066 QualType CheckConditionalOperands( // C99 6.5.15
8067 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
8068 ExprObjectKind &OK, SourceLocation QuestionLoc);
8069
8070 /// Emit a specialized diagnostic when one expression is a null pointer
8071 /// constant and the other is not a pointer. Returns true if a diagnostic is
8072 /// emitted.
8073 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
8074 SourceLocation QuestionLoc);
8075
8076 /// type checking for vector binary operators.
8078 SourceLocation Loc, bool IsCompAssign,
8079 bool AllowBothBool, bool AllowBoolConversion,
8080 bool AllowBoolOperation);
8081
8082 /// Return a signed ext_vector_type that is of identical size and number of
8083 /// elements. For floating point vectors, return an integer type of identical
8084 /// size and number of elements. In the non ext_vector_type case, search from
8085 /// the largest type to the smallest type to avoid cases where long long ==
8086 /// long, where long gets picked over long long.
8089
8090 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
8091 /// operates on extended vector types. Instead of producing an IntTy result,
8092 /// like a scalar comparison, a vector comparison produces a vector of integer
8093 /// types.
8095 SourceLocation Loc,
8096 BinaryOperatorKind Opc);
8098 SourceLocation Loc,
8099 BinaryOperatorKind Opc);
8101 SourceLocation Loc,
8102 BinaryOperatorKind Opc);
8104 SourceLocation Loc,
8105 BinaryOperatorKind Opc);
8107 SourceLocation Loc,
8108 BinaryOperatorKind Opc);
8109 // type checking for sizeless vector binary operators.
8111 SourceLocation Loc, bool IsCompAssign,
8112 ArithConvKind OperationKind);
8113
8114 /// Type checking for matrix binary operators.
8116 SourceLocation Loc,
8117 bool IsCompAssign);
8119 SourceLocation Loc, bool IsCompAssign);
8120
8121 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
8122 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
8123 /// VLST) allowed?
8124 ///
8125 /// This will also return false if the two given types do not make sense from
8126 /// the perspective of SVE bitcasts.
8127 bool isValidSveBitcast(QualType srcType, QualType destType);
8128
8129 /// Are the two types matrix types and do they have the same dimensions i.e.
8130 /// do they have the same number of rows and the same number of columns?
8132
8133 bool areVectorTypesSameSize(QualType srcType, QualType destType);
8134
8135 /// Are the two types lax-compatible vector types? That is, given
8136 /// that one of them is a vector, do they have equal storage sizes,
8137 /// where the storage size is the number of elements times the element
8138 /// size?
8139 ///
8140 /// This will also return false if either of the types is neither a
8141 /// vector nor a real type.
8142 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
8143
8144 /// Is this a legal conversion between two types, one of which is
8145 /// known to be a vector type?
8146 bool isLaxVectorConversion(QualType srcType, QualType destType);
8147
8148 // This returns true if at least one of the types is an altivec vector.
8149 bool anyAltivecTypes(QualType srcType, QualType destType);
8150
8151 // type checking C++ declaration initializers (C++ [dcl.init]).
8152
8153 /// Check a cast of an unknown-any type. We intentionally only
8154 /// trigger this for C-style casts.
8157 ExprValueKind &VK, CXXCastPath &Path);
8158
8159 /// Force an expression with unknown-type to an expression of the
8160 /// given type.
8162
8163 /// Type-check an expression that's being passed to an
8164 /// __unknown_anytype parameter.
8166 QualType &paramType);
8167
8168 // CheckMatrixCast - Check type constraints for matrix casts.
8169 // We allow casting between matrixes of the same dimensions i.e. when they
8170 // have the same number of rows and column. Returns true if the cast is
8171 // invalid.
8172 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
8173 CastKind &Kind);
8174
8175 // CheckVectorCast - check type constraints for vectors.
8176 // Since vectors are an extension, there are no C standard reference for this.
8177 // We allow casting between vectors and integer datatypes of the same size.
8178 // returns true if the cast is invalid
8179 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
8180 CastKind &Kind);
8181
8182 /// Prepare `SplattedExpr` for a vector splat operation, adding
8183 /// implicit casts if necessary.
8184 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
8185
8186 /// Prepare `SplattedExpr` for a matrix splat operation, adding
8187 /// implicit casts if necessary.
8188 ExprResult prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr);
8189
8190 // CheckExtVectorCast - check type constraints for extended vectors.
8191 // Since vectors are an extension, there are no C standard reference for this.
8192 // We allow casting between vectors and integer datatypes of the same size,
8193 // or vectors and the element type of that vector.
8194 // returns the cast expr
8196 CastKind &Kind);
8197
8199 return K == ConditionKind::Switch ? Context.IntTy : Context.BoolTy;
8200 }
8201
8202 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2), converts
8203 // functions and arrays to their respective pointers (C99 6.3.2.1), and
8204 // promotes floating-piont types according to the language semantics.
8206
8207 // UsualUnaryFPConversions - promotes floating-point types according to the
8208 // current language semantics.
8210
8211 /// CallExprUnaryConversions - a special case of an unary conversion
8212 /// performed on a function designator of a call expression.
8214
8215 // DefaultFunctionArrayConversion - converts functions and arrays
8216 // to their respective pointers (C99 6.3.2.1).
8218
8219 // DefaultFunctionArrayLvalueConversion - converts functions and
8220 // arrays to their respective pointers and performs the
8221 // lvalue-to-rvalue conversion.
8223 bool Diagnose = true);
8224
8225 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
8226 // the operand. This function is a no-op if the operand has a function type
8227 // or an array type.
8229
8230 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
8231 // do not have a prototype. Integer promotions are performed on each
8232 // argument, and arguments that have type float are promoted to double.
8234
8236 const FunctionProtoType *Proto,
8237 Expr *Fn);
8238
8239 /// Determine the degree of POD-ness for an expression.
8240 /// Incomplete types are considered POD, since this check can be performed
8241 /// when we're in an unevaluated context.
8243
8244 /// Check to see if the given expression is a valid argument to a variadic
8245 /// function, issuing a diagnostic if not.
8246 void checkVariadicArgument(const Expr *E, VariadicCallType CT);
8247
8248 /// GatherArgumentsForCall - Collector argument expressions for various
8249 /// form of call prototypes.
8251 SourceLocation CallLoc, FunctionDecl *FDecl,
8252 const FunctionProtoType *Proto, unsigned FirstParam,
8255 bool AllowExplicit = false, bool IsListInitialization = false);
8256
8257 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
8258 // will create a runtime trap if the resulting type is not a POD type.
8260 FunctionDecl *FDecl);
8261
8262 // Check that the usual arithmetic conversions can be performed on this pair
8263 // of expressions that might be of enumeration type.
8265 ArithConvKind ACK);
8266
8267 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
8268 // operands and then handles various conversions that are common to binary
8269 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
8270 // routine returns the first non-arithmetic type found. The client is
8271 // responsible for emitting appropriate error diagnostics.
8273 SourceLocation Loc, ArithConvKind ACK);
8274
8276 switch (ConvTy) {
8277 default:
8278 return false;
8282 return true;
8283 }
8284 llvm_unreachable("impossible");
8285 }
8286
8287 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
8288 /// assignment conversion type specified by ConvTy. This returns true if the
8289 /// conversion was invalid or false if the conversion was accepted.
8291 QualType DstType, QualType SrcType,
8292 Expr *SrcExpr, AssignmentAction Action,
8293 bool *Complained = nullptr);
8294
8295 /// CheckAssignmentConstraints - Perform type checking for assignment,
8296 /// argument passing, variable initialization, and function return values.
8297 /// C99 6.5.16.
8299 QualType LHSType,
8300 QualType RHSType);
8301
8302 /// Check assignment constraints and optionally prepare for a conversion of
8303 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
8304 /// is true.
8306 ExprResult &RHS, CastKind &Kind,
8307 bool ConvertRHS = true);
8308
8309 /// Check assignment constraints for an assignment of RHS to LHSType.
8310 ///
8311 /// \param LHSType The destination type for the assignment.
8312 /// \param RHS The source expression for the assignment.
8313 /// \param Diagnose If \c true, diagnostics may be produced when checking
8314 /// for assignability. If a diagnostic is produced, \p RHS will be
8315 /// set to ExprError(). Note that this function may still return
8316 /// without producing a diagnostic, even for an invalid assignment.
8317 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
8318 /// in an audited Core Foundation API and does not need to be checked
8319 /// for ARC retain issues.
8320 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
8321 /// conversions necessary to perform the assignment. If \c false,
8322 /// \p Diagnose must also be \c false.
8324 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
8325 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
8326
8327 // If the lhs type is a transparent union, check whether we
8328 // can initialize the transparent union with the given expression.
8330 ExprResult &RHS);
8331
8332 /// the following "Check" methods will return a valid/converted QualType
8333 /// or a null QualType (indicating an error diagnostic was issued).
8334
8335 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
8337 ExprResult &RHS);
8338
8339 /// Diagnose cases where a scalar was implicitly converted to a vector and
8340 /// diagnose the underlying types. Otherwise, diagnose the error
8341 /// as invalid vector logical operands for non-C++ cases.
8343 ExprResult &RHS);
8344
8346 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8347 BinaryOperatorKind Opc);
8348 QualType CheckRemainderOperands( // C99 6.5.5
8349 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8350 bool IsCompAssign = false);
8351 QualType CheckAdditionOperands( // C99 6.5.6
8352 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8353 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8355 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8356 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8357 QualType CheckShiftOperands( // C99 6.5.7
8358 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8359 BinaryOperatorKind Opc, bool IsCompAssign = false);
8361 QualType CheckCompareOperands( // C99 6.5.8/9
8362 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8363 BinaryOperatorKind Opc);
8364 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
8365 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8366 BinaryOperatorKind Opc);
8367 QualType CheckLogicalOperands( // C99 6.5.[13,14]
8368 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8369 BinaryOperatorKind Opc);
8370 // CheckAssignmentOperands is used for both simple and compound assignment.
8371 // For simple assignment, pass both expressions and a null converted type.
8372 // For compound assignment, pass both expressions and the converted type.
8373 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
8374 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
8375 BinaryOperatorKind Opc);
8376
8377 /// To be used for checking whether the arguments being passed to
8378 /// function exceeds the number of parameters expected for it.
8379 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
8380 bool PartialOverloading = false) {
8381 // We check whether we're just after a comma in code-completion.
8382 if (NumArgs > 0 && PartialOverloading)
8383 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
8384 return NumArgs > NumParams;
8385 }
8386
8387 /// Whether the AST is currently being rebuilt to correct immediate
8388 /// invocations. Immediate invocation candidates and references to consteval
8389 /// functions aren't tracked when this is set.
8391
8397
8398 /// Determines whether we are currently in a context that
8399 /// is not evaluated as per C++ [expr] p5.
8402 }
8403
8407
8411
8415
8422
8423 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8425 assert(!ExprEvalContexts.empty() &&
8426 "Must be in an expression evaluation context");
8427 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8429 Ctx.DelayedDefaultInitializationContext)
8430 return Ctx.DelayedDefaultInitializationContext;
8431 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8432 Ctx.isUnevaluated())
8433 break;
8434 }
8435 return std::nullopt;
8436 }
8437
8438 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8440 assert(!ExprEvalContexts.empty() &&
8441 "Must be in an expression evaluation context");
8442 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
8443 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8445 !Ctx.DelayedDefaultInitializationContext && Res)
8446 break;
8447 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8448 Ctx.isUnevaluated())
8449 break;
8450 Res = Ctx.DelayedDefaultInitializationContext;
8451 }
8452 return Res;
8453 }
8454
8455 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
8456 /// SelfAssigned when inside a CXXMethodDecl.
8457 const FieldDecl *
8459
8461
8462 template <typename... Ts>
8464 const Ts &...Args) {
8465 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8466 return RequireCompleteType(Loc, T, CompleteTypeKind::Normal, Diagnoser);
8467 }
8468
8469 template <typename... Ts>
8470 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
8471 const Ts &...Args) {
8472 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8474 }
8475
8476 /// Abstract class used to diagnose incomplete types.
8479
8480 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
8481 virtual ~TypeDiagnoser() {}
8482 };
8483
8484 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
8485 protected:
8486 unsigned DiagID;
8487 std::tuple<const Ts &...> Args;
8488
8489 template <std::size_t... Is>
8491 std::index_sequence<Is...>) const {
8492 // Apply all tuple elements to the builder in order.
8493 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
8494 (void)Dummy;
8495 }
8496
8497 public:
8498 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8499 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
8500 assert(DiagID != 0 && "no diagnostic for type diagnoser");
8501 }
8502
8503 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8504 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
8505 emit(DB, std::index_sequence_for<Ts...>());
8506 DB << T;
8507 }
8508 };
8509
8510 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
8511 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
8512 /// For example, a diagnostic with no other parameters would generally have
8513 /// the form "...%select{incomplete|sizeless}0 type %1...".
8514 template <typename... Ts>
8516 public:
8517 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8518 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
8519
8520 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8521 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
8522 this->emit(DB, std::index_sequence_for<Ts...>());
8523 DB << T->isSizelessType() << T;
8524 }
8525 };
8526
8527 /// Check an argument list for placeholders that we won't try to
8528 /// handle later.
8530
8531 /// The C++ "std::source_location::__impl" struct, defined in
8532 /// <source_location>.
8534
8535 /// A stack of expression evaluation contexts.
8537
8538 // Set of failed immediate invocations to avoid double diagnosing.
8540
8541 /// List of SourceLocations where 'self' is implicitly retained inside a
8542 /// block.
8545
8546 /// Do an explicit extend of the given block pointer if we're in ARC.
8548
8549 std::vector<std::pair<QualType, unsigned>> ExcessPrecisionNotSatisfied;
8552
8553private:
8554 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
8555
8556 /// Maps the size expression of each VLA type created inside a function,
8557 /// block or lambda to the context in which that size is evaluated.
8558 llvm::DenseMap<const Expr *, const DeclContext *> VLASizeExprOwners;
8559
8560 /// Methods for marking which expressions involve dereferencing a pointer
8561 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
8562 /// they are parsed, meaning that a noderef pointer may not be accessed. For
8563 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
8564 /// `*p`, but need to check that `address of` is called on it. This requires
8565 /// keeping a container of all pending expressions and checking if the address
8566 /// of them are eventually taken.
8567 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
8568 void CheckAddressOfNoDeref(const Expr *E);
8569
8570 ///@}
8571
8572 //
8573 //
8574 // -------------------------------------------------------------------------
8575 //
8576 //
8577
8578 /// \name C++ Expressions
8579 /// Implementations are in SemaExprCXX.cpp
8580 ///@{
8581
8582public:
8583 /// The C++ "std::bad_alloc" class, which is defined by the C++
8584 /// standard library.
8586
8587 /// The C++ "std::align_val_t" enum class, which is defined by the C++
8588 /// standard library.
8590
8591 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
8593
8594 /// A flag to remember whether the implicit forms of operator new and delete
8595 /// have been declared.
8597
8598 /// Delete-expressions to be analyzed at the end of translation unit
8599 ///
8600 /// This list contains class members, and locations of delete-expressions
8601 /// that could not be proven as to whether they mismatch with new-expression
8602 /// used in initializer of the field.
8603 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
8604
8605 /// Handle the result of the special case name lookup for inheriting
8606 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
8607 /// constructor names in member using declarations, even if 'X' is not the
8608 /// name of the corresponding type.
8610 SourceLocation NameLoc,
8611 const IdentifierInfo &Name);
8612
8614 SourceLocation NameLoc, Scope *S,
8615 CXXScopeSpec &SS, bool EnteringContext);
8617 Scope *S, CXXScopeSpec &SS,
8618 ParsedType ObjectType, bool EnteringContext);
8619
8621 ParsedType ObjectType);
8622
8623 /// Build a C++ typeid expression with a type operand.
8624 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8625 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8626
8627 /// Build a C++ typeid expression with an expression operand.
8628 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8629 Expr *Operand, SourceLocation RParenLoc);
8630
8631 /// ActOnCXXTypeid - Parse typeid( something ).
8633 bool isType, void *TyOrExpr,
8634 SourceLocation RParenLoc);
8635
8636 /// Build a Microsoft __uuidof expression with a type operand.
8637 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8638 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8639
8640 /// Build a Microsoft __uuidof expression with an expression operand.
8641 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8642 Expr *Operand, SourceLocation RParenLoc);
8643
8644 /// ActOnCXXUuidof - Parse __uuidof( something ).
8646 bool isType, void *TyOrExpr,
8647 SourceLocation RParenLoc);
8648
8649 //// ActOnCXXThis - Parse 'this' pointer.
8651
8652 /// Check whether the type of 'this' is valid in the current context.
8654
8655 /// Build a CXXThisExpr and mark it referenced in the current context.
8656 Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
8658
8659 /// Try to retrieve the type of the 'this' pointer.
8660 ///
8661 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8663
8664 /// When non-NULL, the C++ 'this' expression is allowed despite the
8665 /// current context not being a non-static member function. In such cases,
8666 /// this provides the type used for 'this'.
8668
8669 /// RAII object used to temporarily allow the C++ 'this' expression
8670 /// to be used, with the given qualifiers on the current class type.
8672 Sema &S;
8673 QualType OldCXXThisTypeOverride;
8674 bool Enabled;
8675
8676 public:
8677 /// Introduce a new scope where 'this' may be allowed (when enabled),
8678 /// using the given declaration (which is either a class template or a
8679 /// class) along with the given qualifiers.
8680 /// along with the qualifiers placed on '*this'.
8681 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8682 bool Enabled = true);
8683
8687 };
8688
8689 /// Make sure the value of 'this' is actually available in the current
8690 /// context, if it is a potentially evaluated context.
8691 ///
8692 /// \param Loc The location at which the capture of 'this' occurs.
8693 ///
8694 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8695 /// capture list.
8696 ///
8697 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8698 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8699 /// This is useful when enclosing lambdas must speculatively capture
8700 /// 'this' that may or may not be used in certain specializations of
8701 /// a nested generic lambda (depending on whether the name resolves to
8702 /// a non-static member function or a static function).
8703 /// \return returns 'true' if failed, 'false' if success.
8705 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8706 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8707 bool ByCopy = false);
8708
8709 /// Determine whether the given type is the type of *this that is used
8710 /// outside of the body of a member function for a type that is currently
8711 /// being defined.
8713
8714 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8716
8717 /// Build a boolean-typed literal expression.
8719
8720 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8722
8723 //// ActOnCXXThrow - Parse throw expressions.
8726 bool IsThrownVarInScope);
8727
8728 /// CheckCXXThrowOperand - Validate the operand of a throw.
8729 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8730
8731 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8732 /// Can be interpreted either as function-style casting ("int(x)")
8733 /// or class type construction ("ClassType(x,y,z)")
8734 /// or creation of a value-initialized type ("int()").
8736 SourceLocation LParenOrBraceLoc,
8737 MultiExprArg Exprs,
8738 SourceLocation RParenOrBraceLoc,
8739 bool ListInitialization);
8740
8742 SourceLocation LParenLoc,
8743 MultiExprArg Exprs,
8744 SourceLocation RParenLoc,
8745 bool ListInitialization);
8746
8747 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8748 ///
8749 /// E.g.:
8750 /// @code new (memory) int[size][4] @endcode
8751 /// or
8752 /// @code ::new Foo(23, "hello") @endcode
8753 ///
8754 /// \param StartLoc The first location of the expression.
8755 /// \param UseGlobal True if 'new' was prefixed with '::'.
8756 /// \param PlacementLParen Opening paren of the placement arguments.
8757 /// \param PlacementArgs Placement new arguments.
8758 /// \param PlacementRParen Closing paren of the placement arguments.
8759 /// \param TypeIdParens If the type is in parens, the source range.
8760 /// \param D The type to be allocated, as well as array dimensions.
8761 /// \param Initializer The initializing expression or initializer-list, or
8762 /// null if there is none.
8763 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8764 SourceLocation PlacementLParen,
8765 MultiExprArg PlacementArgs,
8766 SourceLocation PlacementRParen,
8767 SourceRange TypeIdParens, Declarator &D,
8768 Expr *Initializer);
8770 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8771 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8772 SourceRange TypeIdParens, QualType AllocType,
8773 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8774 SourceRange DirectInitRange, Expr *Initializer);
8775
8776 /// Determine whether \p FD is an aligned allocation or deallocation
8777 /// function that is unavailable.
8779
8780 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8781 /// function that is unavailable.
8783 SourceLocation Loc);
8784
8785 /// Checks that a type is suitable as the allocated type
8786 /// in a new-expression.
8787 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
8788 SourceRange R);
8789
8790 /// Finds the overloads of operator new and delete that are appropriate
8791 /// for the allocation.
8792 std::optional<ResolvedAllocation> FindAllocationFunctions(
8793 SourceLocation StartLoc, SourceRange Range,
8795 QualType AllocType, bool IsArray, const ImplicitAllocationParameters &IAP,
8796 MultiExprArg PlaceArgs, bool Diagnose = true);
8797
8798 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8799 /// delete. These are:
8800 /// @code
8801 /// // C++03:
8802 /// void* operator new(std::size_t) throw(std::bad_alloc);
8803 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8804 /// void operator delete(void *) throw();
8805 /// void operator delete[](void *) throw();
8806 /// // C++11:
8807 /// void* operator new(std::size_t);
8808 /// void* operator new[](std::size_t);
8809 /// void operator delete(void *) noexcept;
8810 /// void operator delete[](void *) noexcept;
8811 /// // C++1y:
8812 /// void* operator new(std::size_t);
8813 /// void* operator new[](std::size_t);
8814 /// void operator delete(void *) noexcept;
8815 /// void operator delete[](void *) noexcept;
8816 /// void operator delete(void *, std::size_t) noexcept;
8817 /// void operator delete[](void *, std::size_t) noexcept;
8818 /// @endcode
8819 /// Note that the placement and nothrow forms of new are *not* implicitly
8820 /// declared. Their use requires including <new>.
8823 ArrayRef<QualType> Params);
8824
8826 DeclarationName Name, FunctionDecl *&Operator,
8828 bool Diagnose = true);
8831 DeclarationName Name,
8832 bool Diagnose = true);
8834 CXXRecordDecl *RD,
8835 bool Diagnose,
8836 bool LookForGlobal,
8837 DeclarationName Name);
8838
8839 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8840 /// @code ::delete ptr; @endcode
8841 /// or
8842 /// @code delete [] ptr; @endcode
8843 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8844 bool ArrayForm, Expr *Operand);
8846 bool IsDelete, bool CallCanBeVirtual,
8847 bool WarnOnNonAbstractTypes,
8848 SourceLocation DtorLoc);
8849
8851 Expr *Operand, SourceLocation RParen);
8853 SourceLocation RParen);
8854
8856 SourceLocation OpLoc,
8857 tok::TokenKind OpKind,
8858 ParsedType &ObjectType,
8859 bool &MayBePseudoDestructor);
8860
8862 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8863 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8864 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8865
8867 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8868 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8869 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8870
8872 SourceLocation OpLoc,
8873 tok::TokenKind OpKind,
8874 SourceLocation TildeLoc,
8875 const DeclSpec &DS);
8876
8877 /// MaybeCreateExprWithCleanups - If the current full-expression
8878 /// requires any cleanups, surround it with a ExprWithCleanups node.
8879 /// Otherwise, just returns the passed-in expression.
8883
8884 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8885 return ActOnFinishFullExpr(
8886 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8887 }
8889 bool DiscardedValue, bool IsConstexpr = false,
8890 bool IsTemplateArgument = false);
8892
8893 /// Process the expression contained within a decltype. For such expressions,
8894 /// certain semantic checks on temporaries are delayed until this point, and
8895 /// are omitted for the 'topmost' call in the decltype expression. If the
8896 /// topmost call bound a temporary, strip that temporary off the expression.
8898
8899 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8900 bool IsUDSuffix);
8901
8903
8904 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8905 SourceLocation StmtLoc,
8906 ConditionKind CK);
8907
8908 /// Check the use of the given variable as a C++ condition in an if,
8909 /// while, do-while, or switch statement.
8911 SourceLocation StmtLoc, ConditionKind CK);
8912
8913 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8914 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8915
8916 /// Helper function to determine whether this is the (deprecated) C++
8917 /// conversion from a string literal to a pointer to non-const char or
8918 /// non-const wchar_t (for narrow and wide string literals,
8919 /// respectively).
8921
8922 /// PerformImplicitConversion - Perform an implicit conversion of the
8923 /// expression From to the type ToType using the pre-computed implicit
8924 /// conversion sequence ICS. Returns the converted
8925 /// expression. Action is the kind of conversion we're performing,
8926 /// used in the error message.
8928 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8929 AssignmentAction Action,
8931
8932 /// PerformImplicitConversion - Perform an implicit conversion of the
8933 /// expression From to the type ToType by following the standard
8934 /// conversion sequence SCS. Returns the converted
8935 /// expression. Flavor is the context in which we're performing this
8936 /// conversion, for use in error messages.
8938 const StandardConversionSequence &SCS,
8939 AssignmentAction Action,
8941
8942 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8943
8944 /// Parsed one of the type trait support pseudo-functions.
8945 ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
8947 SourceLocation RParenLoc);
8948 ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
8950 SourceLocation RParenLoc);
8951
8952 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8953 /// pseudo-functions.
8954 ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc,
8955 ParsedType LhsTy, Expr *DimExpr,
8956 SourceLocation RParen);
8957
8958 ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc,
8959 TypeSourceInfo *TSInfo, Expr *DimExpr,
8960 SourceLocation RParen);
8961
8962 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8963 /// pseudo-functions.
8964 ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc,
8965 Expr *Queried, SourceLocation RParen);
8966
8967 ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc,
8968 Expr *Queried, SourceLocation RParen);
8969
8972 bool isIndirect);
8974 ExprResult &RHS,
8975 SourceLocation QuestionLoc);
8976
8977 //// Determines if a type is trivially relocatable
8978 /// according to the C++26 rules.
8979 // FIXME: This is in Sema because it requires
8980 // overload resolution, can we move to ASTContext?
8983
8984 /// Check the operands of ?: under C++ semantics.
8985 ///
8986 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8987 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8988 ///
8989 /// This function also implements GCC's vector extension and the
8990 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8991 /// permit the use of a?b:c where the type of a is that of a integer vector
8992 /// with the same number of elements and size as the vectors of b and c. If
8993 /// one of either b or c is a scalar it is implicitly converted to match the
8994 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8995 /// c are scalars, then b and c are checked and converted to the type of a if
8996 /// possible.
8997 ///
8998 /// The expressions are evaluated differently for GCC's and OpenCL's
8999 /// extensions. For the GCC extension, the ?: operator is evaluated as
9000 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
9001 /// For the OpenCL extensions, the ?: operator is evaluated as
9002 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
9003 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
9005 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
9006 ExprObjectKind &OK, SourceLocation questionLoc);
9007
9008 /// Find a merged pointer type and convert the two expressions to it.
9009 ///
9010 /// This finds the composite pointer type for \p E1 and \p E2 according to
9011 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
9012 /// it. It does not emit diagnostics (FIXME: that's not true if \p
9013 /// ConvertArgs is \c true).
9014 ///
9015 /// \param Loc The location of the operator requiring these two expressions to
9016 /// be converted to the composite pointer type.
9017 ///
9018 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
9019 /// type.
9021 bool ConvertArgs = true);
9023 ExprResult &E2, bool ConvertArgs = true) {
9024 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
9025 QualType Composite =
9026 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
9027 E1 = E1Tmp;
9028 E2 = E2Tmp;
9029 return Composite;
9030 }
9031
9032 /// MaybeBindToTemporary - If the passed in expression has a record type with
9033 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
9034 /// it simply returns the passed in expression.
9036
9037 /// IgnoredValueConversions - Given that an expression's result is
9038 /// syntactically ignored, perform any conversions that are
9039 /// required.
9041
9043
9046 const DeclarationNameInfo &TargetNameInfo);
9047
9049 SourceLocation KeywordLoc,
9050 bool IsIfExists, CXXScopeSpec &SS,
9051 UnqualifiedId &Name);
9052
9055 ArrayRef<ParmVarDecl *> LocalParameters,
9056 Scope *BodyScope);
9060 CXXScopeSpec &SS,
9061 SourceLocation NameLoc,
9062 const IdentifierInfo *TypeName,
9063 TemplateIdAnnotation *TemplateId);
9065 SourceLocation NoexceptLoc);
9067 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
9068 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
9071 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
9075 bool IsSatisfied, SourceLocation NoexceptLoc,
9083 SourceLocation LParenLoc,
9084 ArrayRef<ParmVarDecl *> LocalParameters,
9085 SourceLocation RParenLoc,
9087 SourceLocation ClosingBraceLoc);
9088
9089private:
9090 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
9091 bool IsDelete);
9092
9093 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
9094 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
9095 bool DeleteWasArrayForm);
9096
9097 std::optional<AllocationArgumentSet>
9098 resolveAllocationArguments(LookupResult &R,
9100 ArrayRef<Expr *> PlacementArguments);
9101
9102 // Attempts to construct the type identity argument for the call to a
9103 // type aware operator new. Returns null on failure.
9104 Expr *tryGetTypeIdentityArgument(QualType Type, SourceLocation);
9105
9106 Expr *AllocationSizeExpr = nullptr;
9107 Expr *AllocationAlignmentExpr = nullptr;
9108 llvm::DenseMap<QualType, Expr *> AllocationTypeIdentityArguments;
9109
9110 ///@}
9111
9112 //
9113 //
9114 // -------------------------------------------------------------------------
9115 //
9116 //
9117
9118 /// \name Member Access Expressions
9119 /// Implementations are in SemaExprMember.cpp
9120 ///@{
9121
9122public:
9123 /// Check whether an expression might be an implicit class member access.
9125 bool IsAddressOfOperand);
9126
9127 /// Builds an expression which might be an implicit member expression.
9129 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
9130 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
9131
9132 /// Builds an implicit member access expression. The current context
9133 /// is known to be an instance method, and the given unqualified lookup
9134 /// set is known to contain only instance members, at least one of which
9135 /// is from an appropriate type.
9137 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9138 LookupResult &R,
9139 const TemplateArgumentListInfo *TemplateArgs,
9140 bool IsDefiniteInstance, const Scope *S);
9141
9143 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
9144 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9145 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
9146 const TemplateArgumentListInfo *TemplateArgs);
9147
9148 /// The main callback when the parser finds something like
9149 /// expression . [nested-name-specifier] identifier
9150 /// expression -> [nested-name-specifier] identifier
9151 /// where 'identifier' encompasses a fairly broad spectrum of
9152 /// possibilities, including destructor and operator references.
9153 ///
9154 /// \param OpKind either tok::arrow or tok::period
9155 /// \param ObjCImpDecl the current Objective-C \@implementation
9156 /// decl; this is an ugly hack around the fact that Objective-C
9157 /// \@implementations aren't properly put in the context chain
9159 tok::TokenKind OpKind, CXXScopeSpec &SS,
9160 SourceLocation TemplateKWLoc,
9161 UnqualifiedId &Member, Decl *ObjCImpDecl);
9162
9163 MemberExpr *
9164 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
9165 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
9166 ValueDecl *Member, DeclAccessPair FoundDecl,
9167 bool HadMultipleCandidates,
9168 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
9170 const TemplateArgumentListInfo *TemplateArgs = nullptr);
9171
9172 // Check whether the declarations we found through a nested-name
9173 // specifier in a member expression are actually members of the base
9174 // type. The restriction here is:
9175 //
9176 // C++ [expr.ref]p2:
9177 // ... In these cases, the id-expression shall name a
9178 // member of the class or of one of its base classes.
9179 //
9180 // So it's perfectly legitimate for the nested-name specifier to name
9181 // an unrelated class, and for us to find an overload set including
9182 // decls from classes which are not superclasses, as long as the decl
9183 // we actually pick through overload resolution is from a superclass.
9184 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
9185 const CXXScopeSpec &SS,
9186 const LookupResult &R);
9187
9188 // This struct is for use by ActOnMemberAccess to allow
9189 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
9190 // changing the access operator from a '.' to a '->' (to see if that is the
9191 // change needed to fix an error about an unknown member, e.g. when the class
9192 // defines a custom operator->).
9198
9200 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
9201 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9202 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
9203 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
9204 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
9205
9208 bool IsArrow, const CXXScopeSpec &SS,
9209 SourceLocation TemplateKWLoc,
9210 NamedDecl *FirstQualifierInScope, LookupResult &R,
9211 const TemplateArgumentListInfo *TemplateArgs,
9212 const Scope *S, bool SuppressQualifierCheck = false,
9213 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
9214
9215 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
9216 SourceLocation OpLoc,
9217 const CXXScopeSpec &SS, FieldDecl *Field,
9218 DeclAccessPair FoundDecl,
9219 const DeclarationNameInfo &MemberNameInfo);
9220
9221 /// Perform conversions on the LHS of a member access expression.
9223
9225 const CXXScopeSpec &SS, SourceLocation nameLoc,
9226 IndirectFieldDecl *indirectField,
9227 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
9228 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
9229
9230private:
9231 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
9232
9233 ///@}
9234
9235 //
9236 //
9237 // -------------------------------------------------------------------------
9238 //
9239 //
9240
9241 /// \name Initializers
9242 /// Implementations are in SemaInit.cpp
9243 ///@{
9244
9245public:
9246 /// Stack of types that correspond to the parameter entities that are
9247 /// currently being copy-initialized. Can be empty.
9249
9250 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
9252
9253 bool IsStringInit(Expr *Init, const ArrayType *AT);
9254
9255 /// The initializers of \p ILE with each multi-element EmbedExpr split into
9256 /// one EmbedExpr per embedded element; \p Storage is used only if needed.
9258 SmallVectorImpl<Expr *> &Storage);
9259
9260 /// Determine whether we can perform aggregate initialization for the purposes
9261 /// of overload resolution.
9263 const InitializedEntity &Entity, InitListExpr *From);
9264
9266 SourceLocation EqualOrColonLoc,
9267 bool GNUSyntax, ExprResult Init);
9268
9269 /// Check that the lifetime of the initializer (and its subobjects) is
9270 /// sufficient for initializing the entity, and perform lifetime extension
9271 /// (when permitted) if not.
9273
9276 bool BoundToLvalueReference);
9277
9278 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
9279 /// it as an xvalue. In C++98, the result will still be a prvalue, because
9280 /// we don't have xvalues there.
9282
9286
9290 SourceLocation EqualLoc, ExprResult Init,
9291 bool TopLevelOfInitList = false,
9292 bool AllowExplicit = false);
9293
9295 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
9296 const InitializationKind &Kind, MultiExprArg Init);
9297
9298 ///@}
9299
9300 //
9301 //
9302 // -------------------------------------------------------------------------
9303 //
9304 //
9305
9306 /// \name C++ Lambda Expressions
9307 /// Implementations are in SemaLambda.cpp
9308 ///@{
9309
9310public:
9311 /// Create a new lambda closure type.
9313 TypeSourceInfo *Info,
9314 unsigned LambdaDependencyKind,
9315 LambdaCaptureDefault CaptureDefault);
9316
9317 /// Number lambda for linkage purposes if necessary.
9319 std::optional<CXXRecordDecl::LambdaNumbering>
9320 NumberingOverride = std::nullopt);
9321
9322 /// Endow the lambda scope info with the relevant properties.
9323 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
9324 SourceRange IntroducerRange,
9325 LambdaCaptureDefault CaptureDefault,
9326 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
9327 bool Mutable);
9328
9331
9333 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
9334 TemplateParameterList *TemplateParams);
9335
9336 void
9338 SourceLocation CallOperatorLoc,
9339 const AssociatedConstraint &TrailingRequiresClause,
9340 TypeSourceInfo *MethodTyInfo,
9341 ConstexprSpecKind ConstexprKind, StorageClass SC,
9343 bool HasExplicitResultType);
9344
9345 /// Returns true if the explicit object parameter was invalid.
9347 SourceLocation CallLoc);
9348
9349 /// Perform initialization analysis of the init-capture and perform
9350 /// any implicit conversions such as an lvalue-to-rvalue conversion if
9351 /// not being used to initialize a reference.
9353 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
9354 IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init) {
9356 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
9358 }
9360 SourceLocation EllipsisLoc,
9361 UnsignedOrNone NumExpansions,
9362 IdentifierInfo *Id,
9363 bool DirectInit, Expr *&Init);
9364
9365 /// Create a dummy variable within the declcontext of the lambda's
9366 /// call operator, for name lookup purposes for a lambda init capture.
9367 ///
9368 /// CodeGen handles emission of lambda captures, ignoring these dummy
9369 /// variables appropriately.
9371 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
9372 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
9373
9374 /// Add an init-capture to a lambda scope.
9375 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
9376
9377 /// Note that we have finished the explicit captures for the
9378 /// given lambda.
9380
9381 /// Deduce a block or lambda's return type based on the return
9382 /// statements present in the body.
9384
9385 /// Once the Lambdas capture are known, we can start to create the closure,
9386 /// call operator method, and keep track of the captures.
9387 /// We do the capture lookup here, but they are not actually captured until
9388 /// after we know what the qualifiers of the call operator are.
9390 Scope *CurContext);
9391
9392 /// This is called after parsing the explicit template parameter list
9393 /// on a lambda (if it exists) in C++2a.
9395 SourceLocation LAngleLoc,
9396 ArrayRef<NamedDecl *> TParams,
9397 SourceLocation RAngleLoc,
9398 ExprResult RequiresClause);
9399
9401 SourceLocation MutableLoc);
9402
9404 Scope *LambdaScope,
9406
9407 /// ActOnStartOfLambdaDefinition - This is called just before we start
9408 /// parsing the body of a lambda; it analyzes the explicit captures and
9409 /// arguments, and sets up various data-structures for the body of the
9410 /// lambda.
9412 Declarator &ParamInfo, const DeclSpec &DS);
9413
9414 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
9415 /// is invoked to pop the information about the lambda.
9416 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
9417 bool IsInstantiation = false);
9418
9419 /// ActOnLambdaExpr - This is called when the body of a lambda expression
9420 /// was successfully completed.
9422
9423 /// Does copying/destroying the captured variable have side effects?
9424 bool CaptureHasSideEffects(const sema::Capture &From);
9425
9426 /// Diagnose if an explicit lambda capture is unused. Returns true if a
9427 /// diagnostic is emitted.
9428 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
9429 SourceRange FixItRange,
9430 const sema::Capture &From);
9431
9432 /// Build a FieldDecl suitable to hold the given capture.
9434 bool IsOpenMP = false);
9435
9436 /// Initialize the given capture with a suitable expression.
9438 SourceLocation ImplicitCaptureLoc,
9439 bool IsOpenMPMapping = false);
9440
9441 /// Complete a lambda-expression having processed and attached the
9442 /// lambda body.
9444
9445 /// Get the return type to use for a lambda's conversion function(s) to
9446 /// function pointer type, given the type of the call operator.
9447 QualType
9449 CallingConv CC);
9450
9452 SourceLocation ConvLocation,
9453 CXXConversionDecl *Conv, Expr *Src);
9454
9456 : private FunctionScopeRAII {
9457 public:
9459 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
9461 bool ShouldAddDeclsFromParentScope = true);
9462 };
9463
9464 /// Compute the mangling number context for a lambda expression or
9465 /// block literal. Also return the extra mangling decl if any.
9466 ///
9467 /// \param DC - The DeclContext containing the lambda expression or
9468 /// block literal.
9469 std::tuple<MangleNumberingContext *, Decl *>
9471
9472 ///@}
9473
9474 //
9475 //
9476 // -------------------------------------------------------------------------
9477 //
9478 //
9479
9480 /// \name Name Lookup
9481 ///
9482 /// These routines provide name lookup that is used during semantic
9483 /// analysis to resolve the various kinds of names (identifiers,
9484 /// overloaded operator names, constructor names, etc.) into zero or
9485 /// more declarations within a particular scope. The major entry
9486 /// points are LookupName, which performs unqualified name lookup,
9487 /// and LookupQualifiedName, which performs qualified name lookup.
9488 ///
9489 /// All name lookup is performed based on some specific criteria,
9490 /// which specify what names will be visible to name lookup and how
9491 /// far name lookup should work. These criteria are important both
9492 /// for capturing language semantics (certain lookups will ignore
9493 /// certain names, for example) and for performance, since name
9494 /// lookup is often a bottleneck in the compilation of C++. Name
9495 /// lookup criteria is specified via the LookupCriteria enumeration.
9496 ///
9497 /// The results of name lookup can vary based on the kind of name
9498 /// lookup performed, the current language, and the translation
9499 /// unit. In C, for example, name lookup will either return nothing
9500 /// (no entity found) or a single declaration. In C++, name lookup
9501 /// can additionally refer to a set of overloaded functions or
9502 /// result in an ambiguity. All of the possible results of name
9503 /// lookup are captured by the LookupResult class, which provides
9504 /// the ability to distinguish among them.
9505 ///
9506 /// Implementations are in SemaLookup.cpp
9507 ///@{
9508
9509public:
9510 /// Tracks whether we are in a context where typo correction is
9511 /// disabled.
9513
9514 /// The number of typos corrected by CorrectTypo.
9516
9517 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
9518 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
9519
9520 /// A cache containing identifiers for which typo correction failed and
9521 /// their locations, so that repeated attempts to correct an identifier in a
9522 /// given location are ignored if typo correction already failed for it.
9524
9525 /// SpecialMemberOverloadResult - The overloading result for a special member
9526 /// function.
9527 ///
9528 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
9529 /// integer are used to determine whether overload resolution succeeded.
9531 public:
9533
9534 private:
9535 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
9536
9537 public:
9540 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
9541
9542 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
9543 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
9544
9545 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
9546 void setKind(Kind K) { Pair.setInt(K); }
9547 };
9548
9549 using SpecialMemberCacheKey = std::pair<const CXXRecordDecl *, unsigned>;
9550
9551 /// A cache of special member function overload resolution results
9552 /// for C++ records.
9553 llvm::DenseMap<SpecialMemberCacheKey, SpecialMemberOverloadResult>
9555
9557
9558 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
9559 // TODO: make this is a typesafe union.
9562
9563 /// Describes the kind of name lookup to perform.
9565 /// Ordinary name lookup, which finds ordinary names (functions,
9566 /// variables, typedefs, etc.) in C and most kinds of names
9567 /// (functions, variables, members, types, etc.) in C++.
9569 /// Tag name lookup, which finds the names of enums, classes,
9570 /// structs, and unions.
9572 /// Label name lookup.
9574 /// Member name lookup, which finds the names of
9575 /// class/struct/union members.
9577 /// Look up of an operator name (e.g., operator+) for use with
9578 /// operator overloading. This lookup is similar to ordinary name
9579 /// lookup, but will ignore any declarations that are class members.
9581 /// Look up a name following ~ in a destructor name. This is an ordinary
9582 /// lookup, but prefers tags to typedefs.
9584 /// Look up of a name that precedes the '::' scope resolution
9585 /// operator in C++. This lookup completely ignores operator, object,
9586 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9588 /// Look up a namespace name within a C++ using directive or
9589 /// namespace alias definition, ignoring non-namespace names (C++
9590 /// [basic.lookup.udir]p1).
9592 /// Look up all declarations in a scope with the given name,
9593 /// including resolved using declarations. This is appropriate
9594 /// for checking redeclarations for a using declaration.
9596 /// Look up an ordinary name that is going to be redeclared as a
9597 /// name with linkage. This lookup ignores any declarations that
9598 /// are outside of the current scope unless they have linkage. See
9599 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9601 /// Look up a friend of a local class. This lookup does not look
9602 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9604 /// Look up the name of an Objective-C protocol.
9606 /// Look up implicit 'self' parameter of an objective-c method.
9608 /// Look up the name of an OpenMP user-defined reduction operation.
9610 /// Look up the name of an OpenMP user-defined mapper.
9612 /// Look up any declaration with any name.
9614 };
9615
9616 /// The possible outcomes of name lookup for a literal operator.
9618 /// The lookup resulted in an error.
9620 /// The lookup found no match but no diagnostic was issued.
9622 /// The lookup found a single 'cooked' literal operator, which
9623 /// expects a normal literal to be built and passed to it.
9625 /// The lookup found a single 'raw' literal operator, which expects
9626 /// a string literal containing the spelling of the literal token.
9628 /// The lookup found an overload set of literal operator templates,
9629 /// which expect the characters of the spelling of the literal token to be
9630 /// passed as a non-type template argument pack.
9632 /// The lookup found an overload set of literal operator templates,
9633 /// which expect the character type and characters of the spelling of the
9634 /// string literal token to be passed as template arguments.
9636 };
9637
9638 SpecialMemberOverloadResult
9640 bool VolatileArg, bool RValueThis, bool ConstThis,
9641 bool VolatileThis);
9642
9644
9645 /// Look up a name, looking for a single declaration. Return
9646 /// null if the results were absent, ambiguous, or overloaded.
9647 ///
9648 /// It is preferable to use the elaborated form and explicitly handle
9649 /// ambiguity and overloaded.
9651 Scope *S, DeclarationName Name, SourceLocation Loc,
9652 LookupNameKind NameKind,
9654
9655 /// Lookup a builtin function, when name lookup would otherwise
9656 /// fail.
9657 bool LookupBuiltin(LookupResult &R);
9658 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9659
9660 /// Perform unqualified name lookup starting from a given
9661 /// scope.
9662 ///
9663 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9664 /// used to find names within the current scope. For example, 'x' in
9665 /// @code
9666 /// int x;
9667 /// int f() {
9668 /// return x; // unqualified name look finds 'x' in the global scope
9669 /// }
9670 /// @endcode
9671 ///
9672 /// Different lookup criteria can find different names. For example, a
9673 /// particular scope can have both a struct and a function of the same
9674 /// name, and each can be found by certain lookup criteria. For more
9675 /// information about lookup criteria, see the documentation for the
9676 /// class LookupCriteria.
9677 ///
9678 /// @param S The scope from which unqualified name lookup will
9679 /// begin. If the lookup criteria permits, name lookup may also search
9680 /// in the parent scopes.
9681 ///
9682 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9683 /// look up and the lookup kind), and is updated with the results of lookup
9684 /// including zero or more declarations and possibly additional information
9685 /// used to diagnose ambiguities.
9686 ///
9687 /// @returns \c true if lookup succeeded and false otherwise.
9688 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9689 bool ForceNoCPlusPlus = false);
9690
9691 /// Perform qualified name lookup into a given context.
9692 ///
9693 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9694 /// names when the context of those names is explicit specified, e.g.,
9695 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9696 ///
9697 /// Different lookup criteria can find different names. For example, a
9698 /// particular scope can have both a struct and a function of the same
9699 /// name, and each can be found by certain lookup criteria. For more
9700 /// information about lookup criteria, see the documentation for the
9701 /// class LookupCriteria.
9702 ///
9703 /// \param R captures both the lookup criteria and any lookup results found.
9704 ///
9705 /// \param LookupCtx The context in which qualified name lookup will
9706 /// search. If the lookup criteria permits, name lookup may also search
9707 /// in the parent contexts or (for C++ classes) base classes.
9708 ///
9709 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9710 /// occurs as part of unqualified name lookup.
9711 ///
9712 /// \returns true if lookup succeeded, false if it failed.
9713 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9714 bool InUnqualifiedLookup = false);
9715
9716 /// Performs qualified name lookup or special type of lookup for
9717 /// "__super::" scope specifier.
9718 ///
9719 /// This routine is a convenience overload meant to be called from contexts
9720 /// that need to perform a qualified name lookup with an optional C++ scope
9721 /// specifier that might require special kind of lookup.
9722 ///
9723 /// \param R captures both the lookup criteria and any lookup results found.
9724 ///
9725 /// \param LookupCtx The context in which qualified name lookup will
9726 /// search.
9727 ///
9728 /// \param SS An optional C++ scope-specifier.
9729 ///
9730 /// \returns true if lookup succeeded, false if it failed.
9731 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9732 CXXScopeSpec &SS);
9733
9734 /// Performs name lookup for a name that was parsed in the
9735 /// source code, and may contain a C++ scope specifier.
9736 ///
9737 /// This routine is a convenience routine meant to be called from
9738 /// contexts that receive a name and an optional C++ scope specifier
9739 /// (e.g., "N::M::x"). It will then perform either qualified or
9740 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9741 /// respectively) on the given name and return those results. It will
9742 /// perform a special type of lookup for "__super::" scope specifier.
9743 ///
9744 /// @param S The scope from which unqualified name lookup will
9745 /// begin.
9746 ///
9747 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9748 ///
9749 /// @param EnteringContext Indicates whether we are going to enter the
9750 /// context of the scope-specifier SS (if present).
9751 ///
9752 /// @returns True if any decls were found (but possibly ambiguous)
9754 QualType ObjectType, bool AllowBuiltinCreation = false,
9755 bool EnteringContext = false);
9756
9757 /// Perform qualified name lookup into all base classes of the given
9758 /// class.
9759 ///
9760 /// \param R captures both the lookup criteria and any lookup results found.
9761 ///
9762 /// \param Class The context in which qualified name lookup will
9763 /// search. Name lookup will search in all base classes merging the results.
9764 ///
9765 /// @returns True if any decls were found (but possibly ambiguous)
9767
9769 UnresolvedSetImpl &Functions);
9770
9771 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9772 /// If GnuLabelLoc is a valid source location, then this is a definition
9773 /// of an __label__ label name, otherwise it is a normal label definition
9774 /// or use. If IsLabelStmt is true, then this is the label of a
9775 /// labeled-statement.
9777 SourceLocation GnuLabelLoc = SourceLocation(),
9778 bool IsLabelStmt = false);
9779
9780 /// Perform a name lookup for a label with the specified name; this does not
9781 /// create a new label if the lookup fails.
9783
9784 /// Look up the constructors for the given class.
9786
9787 /// Look up the default constructor for the given class.
9789
9790 /// Look up the copying constructor for the given class.
9792 unsigned Quals);
9793
9794 /// Look up the copying assignment operator for the given class.
9796 bool RValueThis, unsigned ThisQuals);
9797
9798 /// Look up the moving constructor for the given class.
9800 unsigned Quals);
9801
9802 /// Look up the moving assignment operator for the given class.
9804 bool RValueThis, unsigned ThisQuals);
9805
9806 /// Look for the destructor of the given class.
9807 ///
9808 /// During semantic analysis, this routine should be used in lieu of
9809 /// CXXRecordDecl::getDestructor().
9810 ///
9811 /// \returns The destructor for this class.
9813
9814 /// Force the declaration of any implicitly-declared members of this
9815 /// class.
9817
9818 /// Make a merged definition of an existing hidden definition \p ND
9819 /// visible at the specified location.
9821
9822 /// Check ODR hashes for C/ObjC when merging types from modules.
9823 /// Differently from C++, actually parse the body and reject in case
9824 /// of a mismatch.
9825 template <typename T,
9826 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9828 if (Duplicate->getODRHash() != Previous->getODRHash())
9829 return false;
9830
9831 // Make the previous decl visible.
9833 return true;
9834 }
9835
9836 /// Get the set of additional modules that should be checked during
9837 /// name lookup. A module and its imports become visible when instanting a
9838 /// template defined within it.
9839 llvm::DenseSet<Module *> &getLookupModules();
9840
9841 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9843
9844 /// Determine if the template parameter \p D has a visible default argument.
9845 bool
9847 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9848 /// Determine if the template parameter \p D has a reachable default argument.
9850 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9851 /// Determine if the template parameter \p D has a reachable default argument.
9855
9856 /// Determine if there is a visible declaration of \p D that is an explicit
9857 /// specialization declaration for a specialization of a template. (For a
9858 /// member specialization, use hasVisibleMemberSpecialization.)
9860 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9861 /// Determine if there is a reachable declaration of \p D that is an explicit
9862 /// specialization declaration for a specialization of a template. (For a
9863 /// member specialization, use hasReachableMemberSpecialization.)
9865 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9866
9867 /// Determine if there is a visible declaration of \p D that is a member
9868 /// specialization declaration (as opposed to an instantiated declaration).
9870 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9871 /// Determine if there is a reachable declaration of \p D that is a member
9872 /// specialization declaration (as opposed to an instantiated declaration).
9874 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9875
9876 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9877
9878 /// Determine whether any declaration of an entity is visible.
9879 bool
9881 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9882 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9883 }
9884
9887 /// Determine whether any declaration of an entity is reachable.
9888 bool
9890 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9891 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9892 }
9894 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9895
9896 void diagnoseTypo(const TypoCorrection &Correction,
9897 const PartialDiagnostic &TypoDiag,
9898 bool ErrorRecovery = true);
9899
9900 /// Diagnose a successfully-corrected typo. Separated from the correction
9901 /// itself to allow external validation of the result, etc.
9902 ///
9903 /// \param Correction The result of performing typo correction.
9904 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9905 /// string added to it (and usually also a fixit).
9906 /// \param PrevNote A note to use when indicating the location of the entity
9907 /// to which we are correcting. Will have the correction string added
9908 /// to it.
9909 /// \param ErrorRecovery If \c true (the default), the caller is going to
9910 /// recover from the typo as if the corrected string had been typed.
9911 /// In this case, \c PDiag must be an error, and we will attach a fixit
9912 /// to it.
9913 void diagnoseTypo(const TypoCorrection &Correction,
9914 const PartialDiagnostic &TypoDiag,
9915 const PartialDiagnostic &PrevNote,
9916 bool ErrorRecovery = true);
9917
9918 /// Find the associated classes and namespaces for
9919 /// argument-dependent lookup for a call with the given set of
9920 /// arguments.
9921 ///
9922 /// This routine computes the sets of associated classes and associated
9923 /// namespaces searched by argument-dependent lookup
9924 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9926 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9927 AssociatedNamespaceSet &AssociatedNamespaces,
9928 AssociatedClassSet &AssociatedClasses);
9929
9930 /// Produce a diagnostic describing the ambiguity that resulted
9931 /// from name lookup.
9932 ///
9933 /// \param Result The result of the ambiguous lookup to be diagnosed.
9935
9936 /// LookupLiteralOperator - Determine which literal operator should be used
9937 /// for a user-defined literal, per C++11 [lex.ext].
9938 ///
9939 /// Normal overload resolution is not used to select which literal operator to
9940 /// call for a user-defined literal. Look up the provided literal operator
9941 /// name, and filter the results to the appropriate set for the given argument
9942 /// types.
9945 bool AllowRaw, bool AllowTemplate,
9946 bool AllowStringTemplate, bool DiagnoseMissing,
9947 StringLiteral *StringLit = nullptr);
9948
9950 ArrayRef<Expr *> Args, ADLResult &Functions);
9951
9952 void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
9954 bool IncludeGlobalScope = true,
9955 bool LoadExternal = true);
9956 void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
9958 bool IncludeGlobalScope = true,
9959 bool IncludeDependentBases = false,
9960 bool LoadExternal = true);
9961
9962 /// Try to "correct" a typo in the source code by finding
9963 /// visible declarations whose names are similar to the name that was
9964 /// present in the source code.
9965 ///
9966 /// \param TypoName the \c DeclarationNameInfo structure that contains
9967 /// the name that was present in the source code along with its location.
9968 ///
9969 /// \param LookupKind the name-lookup criteria used to search for the name.
9970 ///
9971 /// \param S the scope in which name lookup occurs.
9972 ///
9973 /// \param SS the nested-name-specifier that precedes the name we're
9974 /// looking for, if present.
9975 ///
9976 /// \param CCC A CorrectionCandidateCallback object that provides further
9977 /// validation of typo correction candidates. It also provides flags for
9978 /// determining the set of keywords permitted.
9979 ///
9980 /// \param MemberContext if non-NULL, the context in which to look for
9981 /// a member access expression.
9982 ///
9983 /// \param EnteringContext whether we're entering the context described by
9984 /// the nested-name-specifier SS.
9985 ///
9986 /// \param OPT when non-NULL, the search for visible declarations will
9987 /// also walk the protocols in the qualified interfaces of \p OPT.
9988 ///
9989 /// \returns a \c TypoCorrection containing the corrected name if the typo
9990 /// along with information such as the \c NamedDecl where the corrected name
9991 /// was declared, and any additional \c NestedNameSpecifier needed to access
9992 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9994 Sema::LookupNameKind LookupKind, Scope *S,
9996 CorrectTypoKind Mode,
9997 DeclContext *MemberContext = nullptr,
9998 bool EnteringContext = false,
9999 const ObjCObjectPointerType *OPT = nullptr,
10000 bool RecordFailure = true);
10001
10002 /// Kinds of missing import. Note, the values of these enumerators correspond
10003 /// to %select values in diagnostics.
10011
10012 /// Diagnose that the specified declaration needs to be visible but
10013 /// isn't, and suggest a module import that would resolve the problem.
10015 MissingImportKind MIK, bool Recover = true);
10017 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
10018 MissingImportKind MIK, bool Recover);
10019
10020 /// Called on #pragma clang __debug dump II
10022
10023 /// Called on #pragma clang __debug dump E
10024 void ActOnPragmaDump(Expr *E);
10025
10026private:
10027 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
10028 //
10029 // The boolean value will be true to indicate that the namespace was loaded
10030 // from an AST/PCH file, or false otherwise.
10031 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
10032
10033 /// Whether we have already loaded known namespaces from an extenal
10034 /// source.
10035 bool LoadedExternalKnownNamespaces;
10036
10037 bool CppLookupName(LookupResult &R, Scope *S);
10038
10039 /// Determine if we could use all the declarations in the module.
10040 bool isUsableModule(const Module *M);
10041
10042 /// Helper for CorrectTypo used to create and populate a new
10043 /// TypoCorrectionConsumer. Returns nullptr if typo correction should be
10044 /// skipped entirely.
10045 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
10046 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
10048 DeclContext *MemberContext, bool EnteringContext,
10049 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
10050
10051 /// Cache for module units which is usable for current module.
10052 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
10053
10054 /// Record the typo correction failure and return an empty correction.
10055 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
10056 bool RecordFailure = true) {
10057 if (RecordFailure)
10058 TypoCorrectionFailures[Typo].insert(TypoLoc);
10059 return TypoCorrection();
10060 }
10061
10062 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
10063
10064 /// Determine whether two declarations should be linked together, given that
10065 /// the old declaration might not be visible and the new declaration might
10066 /// not have external linkage.
10067 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
10068 const NamedDecl *New) {
10069 if (isVisible(Old))
10070 return true;
10071 // See comment in below overload for why it's safe to compute the linkage
10072 // of the new declaration here.
10073 if (New->isExternallyDeclarable()) {
10074 assert(Old->isExternallyDeclarable() &&
10075 "should not have found a non-externally-declarable previous decl");
10076 return true;
10077 }
10078 return false;
10079 }
10080 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
10081
10082 ///@}
10083
10084 //
10085 //
10086 // -------------------------------------------------------------------------
10087 //
10088 //
10089
10090 /// \name Modules
10091 /// Implementations are in SemaModule.cpp
10092 ///@{
10093
10094public:
10095 /// Get the module unit whose scope we are currently within.
10097 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
10098 }
10099
10100 /// Is the module scope we are an implementation unit?
10102 if (ModuleScopes.empty())
10103 return false;
10104 const Module *M = ModuleScopes.back().Module;
10106 }
10107
10108 // When loading a non-modular PCH files, this is used to restore module
10109 // visibility.
10111 VisibleModules.setVisible(Mod, ImportLoc);
10112 }
10113
10114 enum class ModuleDeclKind {
10115 Interface, ///< 'export module X;'
10116 Implementation, ///< 'module X;'
10117 PartitionInterface, ///< 'export module X:Y;'
10118 PartitionImplementation, ///< 'module X:Y;'
10119 };
10120
10121 /// An enumeration to represent the transition of states in parsing module
10122 /// fragments and imports. If we are not parsing a C++20 TU, or we find
10123 /// an error in state transition, the state is set to NotACXX20Module.
10125 FirstDecl, ///< Parsing the first decl in a TU.
10126 GlobalFragment, ///< after 'module;' but before 'module X;'
10127 ImportAllowed, ///< after 'module X;' but before any non-import decl.
10128 ImportFinished, ///< after any non-import decl.
10129 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
10130 ///< non-import decl.
10131 PrivateFragmentImportFinished, ///< after 'module :private;' but a
10132 ///< non-import decl has already been seen.
10133 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
10134 };
10135
10136 /// The parser has processed a module-declaration that begins the definition
10137 /// of a module interface or implementation.
10139 SourceLocation ModuleLoc, ModuleDeclKind MDK,
10140 ModuleIdPath Path, ModuleIdPath Partition,
10141 ModuleImportState &ImportState,
10142 bool SeenNoTrivialPPDirective);
10143
10144 /// The parser has processed a global-module-fragment declaration that begins
10145 /// the definition of the global module fragment of the current module unit.
10146 /// \param ModuleLoc The location of the 'module' keyword.
10148
10149 /// The parser has processed a private-module-fragment declaration that begins
10150 /// the definition of the private module fragment of the current module unit.
10151 /// \param ModuleLoc The location of the 'module' keyword.
10152 /// \param PrivateLoc The location of the 'private' keyword.
10154 SourceLocation PrivateLoc);
10155
10156 /// The parser has processed a module import declaration.
10157 ///
10158 /// \param StartLoc The location of the first token in the declaration. This
10159 /// could be the location of an '@', 'export', or 'import'.
10160 /// \param ExportLoc The location of the 'export' keyword, if any.
10161 /// \param ImportLoc The location of the 'import' keyword.
10162 /// \param Path The module toplevel name as an access path.
10163 /// \param IsPartition If the name is for a partition.
10165 SourceLocation ExportLoc,
10166 SourceLocation ImportLoc, ModuleIdPath Path,
10167 bool IsPartition = false);
10169 SourceLocation ExportLoc,
10170 SourceLocation ImportLoc, Module *M,
10171 ModuleIdPath Path = {});
10172
10173 /// The parser has processed a module import translated from a
10174 /// #include or similar preprocessing directive.
10175 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
10176 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
10177
10178 /// The parsed has entered a submodule.
10179 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
10180 /// The parser has left a submodule.
10181 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
10182
10183 /// Create an implicit import of the given module at the given
10184 /// source location, for error recovery, if possible.
10185 ///
10186 /// This routine is typically used when an entity found by name lookup
10187 /// is actually hidden within a module that we know about but the user
10188 /// has forgotten to import.
10189 void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
10190 Module *Mod);
10191
10192 /// We have parsed the start of an export declaration, including the '{'
10193 /// (if present).
10194 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
10195 SourceLocation LBraceLoc);
10196
10197 /// Complete the definition of an export declaration.
10198 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
10199 SourceLocation RBraceLoc);
10200
10201private:
10202 /// The parser has begun a translation unit to be compiled as a C++20
10203 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
10204 void HandleStartOfHeaderUnit();
10205
10206 struct ModuleScope {
10207 SourceLocation BeginLoc;
10208 clang::Module *Module = nullptr;
10209 VisibleModuleSet OuterVisibleModules;
10210 };
10211 /// The modules we're currently parsing.
10212 llvm::SmallVector<ModuleScope, 16> ModuleScopes;
10213
10214 /// For an interface unit, this is the implicitly imported interface unit.
10215 clang::Module *ThePrimaryInterface = nullptr;
10216
10217 /// The explicit global module fragment of the current translation unit.
10218 /// The explicit Global Module Fragment, as specified in C++
10219 /// [module.global.frag].
10220 clang::Module *TheGlobalModuleFragment = nullptr;
10221
10222 /// The implicit global module fragments of the current translation unit.
10223 ///
10224 /// The contents in the implicit global module fragment can't be discarded.
10225 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
10226
10227 /// Namespace definitions that we will export when they finish.
10228 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
10229
10230 /// In a C++ standard module, inline declarations require a definition to be
10231 /// present at the end of a definition domain. This set holds the decls to
10232 /// be checked at the end of the TU.
10233 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
10234
10235 /// Helper function to judge if we are in module purview.
10236 /// Return false if we are not in a module.
10237 bool isCurrentModulePurview() const;
10238
10239 /// Enter the scope of the explicit global module fragment.
10240 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
10241 /// Leave the scope of the explicit global module fragment.
10242 void PopGlobalModuleFragment();
10243
10244 /// Enter the scope of an implicit global module fragment.
10245 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
10246 /// Leave the scope of an implicit global module fragment.
10247 void PopImplicitGlobalModuleFragment();
10248
10249 VisibleModuleSet VisibleModules;
10250
10251 /// Whether we had imported any named modules.
10252 bool HadImportedNamedModules = false;
10253 /// The set of instantiations we need to check if they references TU-local
10254 /// entity from TUs. This only makes sense if we imported any named modules.
10255 llvm::SmallVector<std::pair<FunctionDecl *, SourceLocation>>
10256 PendingCheckReferenceForTULocal;
10257 /// Implement [basic.link]p18, which requires that we can't use TU-local
10258 /// entities from other TUs (ignoring header units).
10259 void checkReferenceToTULocalFromOtherTU(FunctionDecl *FD,
10260 SourceLocation PointOfInstantiation);
10261 /// Implement [basic.link]p17, which diagnose for non TU local exposure in
10262 /// module interface or module partition.
10263 void checkExposure(const TranslationUnitDecl *TU);
10264
10265 ///@}
10266
10267 //
10268 //
10269 // -------------------------------------------------------------------------
10270 //
10271 //
10272
10273 /// \name C++ Overloading
10274 /// Implementations are in SemaOverload.cpp
10275 ///@{
10276
10277public:
10278 /// Whether deferrable diagnostics should be deferred.
10279 bool DeferDiags = false;
10280
10281 /// RAII class to control scope of DeferDiags.
10283 Sema &S;
10284 bool SavedDeferDiags = false;
10285
10286 public:
10288 : S(S), SavedDeferDiags(S.DeferDiags) {
10289 S.DeferDiags = SavedDeferDiags || DeferDiags;
10290 }
10291 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
10294 };
10295
10296 /// Flag indicating if Sema is building a recovery call expression.
10297 ///
10298 /// This flag is used to avoid building recovery call expressions
10299 /// if Sema is already doing so, which would cause infinite recursions.
10301
10302 /// Determine whether the given New declaration is an overload of the
10303 /// declarations in Old. This routine returns OverloadKind::Match or
10304 /// OverloadKind::NonFunction if New and Old cannot be overloaded, e.g., if
10305 /// New has the same signature as some function in Old (C++ 1.3.10) or if the
10306 /// Old declarations aren't functions (or function templates) at all. When it
10307 /// does return OverloadKind::Match or OverloadKind::NonFunction, MatchedDecl
10308 /// will point to the decl that New cannot be overloaded with. This decl may
10309 /// be a UsingShadowDecl on top of the underlying declaration.
10310 ///
10311 /// Example: Given the following input:
10312 ///
10313 /// void f(int, float); // #1
10314 /// void f(int, int); // #2
10315 /// int f(int, int); // #3
10316 ///
10317 /// When we process #1, there is no previous declaration of "f", so IsOverload
10318 /// will not be used.
10319 ///
10320 /// When we process #2, Old contains only the FunctionDecl for #1. By
10321 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
10322 /// they have different signatures), so this routine returns
10323 /// OverloadKind::Overload; MatchedDecl is unchanged.
10324 ///
10325 /// When we process #3, Old is an overload set containing #1 and #2. We
10326 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
10327 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
10328 /// types of functions are not part of the signature), IsOverload returns
10329 /// OverloadKind::Match and MatchedDecl will be set to point to the
10330 /// FunctionDecl for #2.
10331 ///
10332 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
10333 /// class by a using declaration. The rules for whether to hide shadow
10334 /// declarations ignore some properties which otherwise figure into a function
10335 /// template's signature.
10337 const LookupResult &OldDecls, NamedDecl *&OldDecl,
10338 bool UseMemberUsingDeclRules);
10340 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10341
10342 // Checks whether MD constitutes an override the base class method BaseMD.
10343 // When checking for overrides, the object object members are ignored.
10344 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
10345 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10346
10347 enum class AllowedExplicit {
10348 /// Allow no explicit functions to be used.
10350 /// Allow explicit conversion functions but not explicit constructors.
10352 /// Allow both explicit conversion functions and explicit constructors.
10354 };
10355
10357 Expr *From, QualType ToType, bool SuppressUserConversions,
10358 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
10359 bool AllowObjCWritebackConversion);
10360
10361 /// PerformImplicitConversion - Perform an implicit conversion of the
10362 /// expression From to the type ToType. Returns the
10363 /// converted expression. Flavor is the kind of conversion we're
10364 /// performing, used in the error message. If @p AllowExplicit,
10365 /// explicit user-defined conversions are permitted.
10367 AssignmentAction Action,
10368 bool AllowExplicit = false);
10369
10370 /// IsIntegralPromotion - Determines whether the conversion from the
10371 /// expression From (whose potentially-adjusted type is FromType) to
10372 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
10373 /// sets PromotedType to the promoted type.
10374 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
10375
10376 /// IsFloatingPointPromotion - Determines whether the conversion from
10377 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
10378 /// returns true and sets PromotedType to the promoted type.
10379 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
10380
10381 /// Determine if a conversion is a complex promotion.
10382 ///
10383 /// A complex promotion is defined as a complex -> complex conversion
10384 /// where the conversion between the underlying real types is a
10385 /// floating-point or integral promotion.
10386 bool IsComplexPromotion(QualType FromType, QualType ToType);
10387
10388 /// IsOverflowBehaviorTypePromotion - Determines whether the conversion from
10389 /// FromType to ToType involves an OverflowBehaviorType FromType being
10390 /// promoted to an OverflowBehaviorType ToType which has a larger bitwidth.
10391 /// If so, returns true and sets FromType to ToType.
10392 bool IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType);
10393
10394 /// IsOverflowBehaviorTypeConversion - Determines whether the conversion from
10395 /// FromType to ToType necessarily involves both an OverflowBehaviorType and
10396 /// a non-OverflowBehaviorType. If so, returns true and sets FromType to
10397 /// ToType.
10398 bool IsOverflowBehaviorTypeConversion(QualType FromType, QualType ToType);
10399
10400 /// IsPointerConversion - Determines whether the conversion of the
10401 /// expression From, which has the (possibly adjusted) type FromType,
10402 /// can be converted to the type ToType via a pointer conversion (C++
10403 /// 4.10). If so, returns true and places the converted type (that
10404 /// might differ from ToType in its cv-qualifiers at some level) into
10405 /// ConvertedType.
10406 ///
10407 /// This routine also supports conversions to and from block pointers
10408 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
10409 /// pointers to interfaces. FIXME: Once we've determined the
10410 /// appropriate overloading rules for Objective-C, we may want to
10411 /// split the Objective-C checks into a different routine; however,
10412 /// GCC seems to consider all of these conversions to be pointer
10413 /// conversions, so for now they live here. IncompatibleObjC will be
10414 /// set if the conversion is an allowed Objective-C conversion that
10415 /// should result in a warning.
10416 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
10417 bool InOverloadResolution, QualType &ConvertedType,
10418 bool &IncompatibleObjC);
10419
10420 /// isObjCPointerConversion - Determines whether this is an
10421 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
10422 /// with the same arguments and return values.
10423 bool isObjCPointerConversion(QualType FromType, QualType ToType,
10424 QualType &ConvertedType, bool &IncompatibleObjC);
10425 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
10426 QualType &ConvertedType);
10427
10428 /// FunctionParamTypesAreEqual - This routine checks two function proto types
10429 /// for equality of their parameter types. Caller has already checked that
10430 /// they have same number of parameters. If the parameters are different,
10431 /// ArgPos will have the parameter index of the first different parameter.
10432 /// If `Reversed` is true, the parameters of `NewType` will be compared in
10433 /// reverse order. That's useful if one of the functions is being used as a
10434 /// C++20 synthesized operator overload with a reversed parameter order.
10437 unsigned *ArgPos = nullptr,
10438 bool Reversed = false);
10439
10441 const FunctionProtoType *NewType,
10442 unsigned *ArgPos = nullptr,
10443 bool Reversed = false);
10444
10445 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
10446 const FunctionDecl *NewFunction,
10447 unsigned *ArgPos = nullptr,
10448 bool Reversed = false);
10449
10450 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
10451 /// function types. Catches different number of parameter, mismatch in
10452 /// parameter types, and different return types.
10454 QualType ToType);
10455
10456 /// CheckPointerConversion - Check the pointer conversion from the
10457 /// expression From to the type ToType. This routine checks for
10458 /// ambiguous or inaccessible derived-to-base pointer
10459 /// conversions for which IsPointerConversion has already returned
10460 /// true. It returns true and produces a diagnostic if there was an
10461 /// error, or returns false otherwise.
10462 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
10463 CXXCastPath &BasePath, bool IgnoreBaseAccess,
10464 bool Diagnose = true);
10465
10466 /// IsMemberPointerConversion - Determines whether the conversion of the
10467 /// expression From, which has the (possibly adjusted) type FromType, can be
10468 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
10469 /// If so, returns true and places the converted type (that might differ from
10470 /// ToType in its cv-qualifiers at some level) into ConvertedType.
10471 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
10472 bool InOverloadResolution,
10473 QualType &ConvertedType);
10474
10484 /// CheckMemberPointerConversion - Check the member pointer conversion from
10485 /// the expression From to the type ToType. This routine checks for ambiguous
10486 /// or virtual or inaccessible base-to-derived member pointer conversions for
10487 /// which IsMemberPointerConversion has already returned true. It produces a
10488 // diagnostic if there was an error.
10490 QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind,
10491 CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange,
10492 bool IgnoreBaseAccess, MemberPointerConversionDirection Direction);
10493
10494 /// IsQualificationConversion - Determines whether the conversion from
10495 /// an rvalue of type FromType to ToType is a qualification conversion
10496 /// (C++ 4.4).
10497 ///
10498 /// \param ObjCLifetimeConversion Output parameter that will be set to
10499 /// indicate when the qualification conversion involves a change in the
10500 /// Objective-C object lifetime.
10501 bool IsQualificationConversion(QualType FromType, QualType ToType,
10502 bool CStyle, bool &ObjCLifetimeConversion);
10503
10504 /// Determine whether the conversion from FromType to ToType is a valid
10505 /// conversion of ExtInfo/ExtProtoInfo on the nested function type.
10506 /// More precisely, this method checks whether FromType can be transformed
10507 /// into an exact match for ToType, by transforming its extended function
10508 /// type information in legal manner (e.g. by strictly stripping "noreturn"
10509 /// or "noexcept", or by stripping "noescape" for arguments).
10510 bool IsFunctionConversion(QualType FromType, QualType ToType) const;
10511
10512 /// Same as `IsFunctionConversion`, but if this would return true, it sets
10513 /// `ResultTy` to `ToType`.
10514 bool TryFunctionConversion(QualType FromType, QualType ToType,
10515 QualType &ResultTy) const;
10516
10519 DeclarationName Name,
10520 OverloadCandidateSet &CandidateSet,
10521 FunctionDecl *Fn, MultiExprArg Args,
10522 bool IsMember = false);
10523
10525 FunctionDecl *Fun);
10527 Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl,
10529
10530 /// PerformContextuallyConvertToBool - Perform a contextual conversion
10531 /// of the expression From to bool (C++0x [conv]p3).
10533
10534 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
10535 /// conversion of the expression From to an Objective-C pointer type.
10536 /// Returns a valid but null ExprResult if no conversion sequence exists.
10538
10540 CCEKind CCE,
10541 NamedDecl *Dest = nullptr);
10542
10544 llvm::APSInt &Value, CCEKind CCE);
10546 APValue &Value, CCEKind CCE,
10547 NamedDecl *Dest = nullptr);
10548
10549 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10550 /// That is a converted constant expression
10551 /// (which was built with BuildConvertedConstantExpression)
10554 CCEKind CCE, bool RequireInt,
10555 const APValue &PreNarrowingValue);
10556
10557 /// Abstract base class used to perform a contextual implicit
10558 /// conversion from an expression to any type passing a filter.
10560 public:
10563
10567
10568 /// Determine whether the specified type is a valid destination type
10569 /// for this conversion.
10570 virtual bool match(QualType T) = 0;
10571
10572 /// Emits a diagnostic complaining that the expression does not have
10573 /// integral or enumeration type.
10575 QualType T) = 0;
10576
10577 /// Emits a diagnostic when the expression has incomplete class type.
10578 virtual SemaDiagnosticBuilder
10580
10581 /// Emits a diagnostic when the only matching conversion function
10582 /// is explicit.
10584 SourceLocation Loc,
10585 QualType T,
10586 QualType ConvTy) = 0;
10587
10588 /// Emits a note for the explicit conversion function.
10589 virtual SemaDiagnosticBuilder
10591
10592 /// Emits a diagnostic when there are multiple possible conversion
10593 /// functions.
10595 QualType T) = 0;
10596
10597 /// Emits a note for one of the candidate conversions.
10598 virtual SemaDiagnosticBuilder
10600
10601 /// Emits a diagnostic when we picked a conversion function
10602 /// (for cases when we are not allowed to pick a conversion function).
10604 SourceLocation Loc,
10605 QualType T,
10606 QualType ConvTy) = 0;
10607
10609 };
10610
10612 bool AllowScopedEnumerations;
10613
10614 public:
10615 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10616 bool SuppressConversion)
10618 AllowScopedEnumerations(AllowScopedEnumerations) {}
10619
10620 /// Match an integral or (possibly scoped) enumeration type.
10621 bool match(QualType T) override;
10622
10624 QualType T) override {
10625 return diagnoseNotInt(S, Loc, T);
10626 }
10627
10628 /// Emits a diagnostic complaining that the expression does not have
10629 /// integral or enumeration type.
10631 QualType T) = 0;
10632 };
10633
10634 /// Perform a contextual implicit conversion.
10637 ContextualImplicitConverter &Converter);
10638
10639 /// ReferenceCompareResult - Expresses the result of comparing two
10640 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10641 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10643 /// Ref_Incompatible - The two types are incompatible, so direct
10644 /// reference binding is not possible.
10646 /// Ref_Related - The two types are reference-related, which means
10647 /// that their unqualified forms (T1 and T2) are either the same
10648 /// or T1 is a base class of T2.
10650 /// Ref_Compatible - The two types are reference-compatible.
10652 };
10653
10654 // Fake up a scoped enumeration that still contextually converts to bool.
10656 /// The conversions that would be performed on an lvalue of type T2 when
10657 /// binding a reference of type T1 to it, as determined when evaluating
10658 /// whether T1 is reference-compatible with T2.
10664 ObjC = 0x10,
10666
10667 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
10668 };
10669 };
10671
10672 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10673 /// determine whether they are reference-compatible,
10674 /// reference-related, or incompatible, for use in C++ initialization by
10675 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10676 /// type, and the first type (T1) is the pointee type of the reference
10677 /// type being initialized.
10680 ReferenceConversions *Conv = nullptr);
10681
10682 /// AddOverloadCandidate - Adds the given function to the set of
10683 /// candidate functions, using the given function call arguments. If
10684 /// @p SuppressUserConversions, then don't allow user-defined
10685 /// conversions via constructors or conversion operators.
10686 ///
10687 /// \param PartialOverloading true if we are performing "partial" overloading
10688 /// based on an incomplete set of function arguments. This feature is used by
10689 /// code completion.
10692 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10693 bool PartialOverloading = false, bool AllowExplicit = true,
10694 bool AllowExplicitConversion = false,
10695 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10696 ConversionSequenceList EarlyConversions = {},
10698 bool AggregateCandidateDeduction = false, bool StrictPackMatch = false);
10699
10700 /// Add all of the function declarations in the given function set to
10701 /// the overload candidate set.
10703 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10704 OverloadCandidateSet &CandidateSet,
10705 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10706 bool SuppressUserConversions = false, bool PartialOverloading = false,
10707 bool FirstArgumentIsBase = false);
10708
10709 /// AddMethodCandidate - Adds a named decl (which is some kind of
10710 /// method) as a method candidate to the given overload set.
10711 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10712 Expr::Classification ObjectClassification,
10713 ArrayRef<Expr *> Args,
10714 OverloadCandidateSet &CandidateSet,
10715 bool SuppressUserConversion = false,
10716 OverloadCandidateParamOrder PO = {});
10717
10718 /// AddMethodCandidate - Adds the given C++ member function to the set
10719 /// of candidate functions, using the given function call arguments
10720 /// and the object argument (@c Object). For example, in a call
10721 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10722 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10723 /// allow user-defined conversions via constructors or conversion
10724 /// operators.
10725 void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10726 CXXRecordDecl *ActingContext, QualType ObjectType,
10727 Expr::Classification ObjectClassification,
10728 ArrayRef<Expr *> Args,
10729 OverloadCandidateSet &CandidateSet,
10730 bool SuppressUserConversions = false,
10731 bool PartialOverloading = false,
10732 ConversionSequenceList EarlyConversions = {},
10734 bool StrictPackMatch = false);
10735
10736 /// Add a C++ member function template as a candidate to the candidate
10737 /// set, using template argument deduction to produce an appropriate member
10738 /// function template specialization.
10740 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10741 CXXRecordDecl *ActingContext,
10742 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10743 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10744 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10745 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10746
10747 /// Add a C++ function template specialization as a candidate
10748 /// in the candidate set, using template argument deduction to produce
10749 /// an appropriate function template specialization.
10751 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10752 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10753 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10754 bool PartialOverloading = false, bool AllowExplicit = true,
10755 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10757 bool AggregateCandidateDeduction = false);
10758
10760 /// Do not consider any user-defined conversions when constructing the
10761 /// initializing sequence.
10763
10764 /// Before constructing the initializing sequence, we check whether the
10765 /// parameter type and argument type contain any user defined conversions.
10766 /// If so, do not initialize them. This effectively bypasses some undesired
10767 /// instantiation before checking constaints, which might otherwise result
10768 /// in non-SFINAE errors e.g. recursive constraints.
10770
10777 };
10778
10779 /// Check that implicit conversion sequences can be formed for each argument
10780 /// whose corresponding parameter has a non-dependent type, per DR1391's
10781 /// [temp.deduct.call]p10.
10784 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10786 CheckNonDependentConversionsFlag UserConversionFlag,
10787 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10788 Expr::Classification ObjectClassification = {},
10789 OverloadCandidateParamOrder PO = {});
10790
10791 /// AddConversionCandidate - Add a C++ conversion function as a
10792 /// candidate in the candidate set (C++ [over.match.conv],
10793 /// C++ [over.match.copy]). From is the expression we're converting from,
10794 /// and ToType is the type that we're eventually trying to convert to
10795 /// (which may or may not be the same type as the type that the
10796 /// conversion function produces).
10798 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10799 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10800 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10801 bool AllowExplicit, bool AllowResultConversion = true,
10802 bool StrictPackMatch = false);
10803
10804 /// Adds a conversion function template specialization
10805 /// candidate to the overload set, using template argument deduction
10806 /// to deduce the template arguments of the conversion function
10807 /// template from the type that we are converting to (C++
10808 /// [temp.deduct.conv]).
10810 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10811 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10812 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10813 bool AllowExplicit, bool AllowResultConversion = true);
10814
10815 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10816 /// converts the given @c Object to a function pointer via the
10817 /// conversion function @c Conversion, and then attempts to call it
10818 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10819 /// the type of function that we'll eventually be calling.
10820 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10821 DeclAccessPair FoundDecl,
10822 CXXRecordDecl *ActingContext,
10823 const FunctionProtoType *Proto, Expr *Object,
10824 ArrayRef<Expr *> Args,
10825 OverloadCandidateSet &CandidateSet);
10826
10827 /// Add all of the non-member operator function declarations in the given
10828 /// function set to the overload candidate set.
10830 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10831 OverloadCandidateSet &CandidateSet,
10832 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10833
10834 /// Add overload candidates for overloaded operators that are
10835 /// member functions.
10836 ///
10837 /// Add the overloaded operator candidates that are member functions
10838 /// for the operator Op that was used in an operator expression such
10839 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10840 /// CandidateSet will store the added overload candidates. (C++
10841 /// [over.match.oper]).
10843 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10844 OverloadCandidateSet &CandidateSet,
10846
10847 /// AddBuiltinCandidate - Add a candidate for a built-in
10848 /// operator. ResultTy and ParamTys are the result and parameter types
10849 /// of the built-in candidate, respectively. Args and NumArgs are the
10850 /// arguments being passed to the candidate. IsAssignmentOperator
10851 /// should be true when this built-in candidate is an assignment
10852 /// operator. NumContextualBoolArguments is the number of arguments
10853 /// (at the beginning of the argument list) that will be contextually
10854 /// converted to bool.
10855 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10856 OverloadCandidateSet &CandidateSet,
10857 bool IsAssignmentOperator = false,
10858 unsigned NumContextualBoolArguments = 0);
10859
10860 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10861 /// operator overloads to the candidate set (C++ [over.built]), based
10862 /// on the operator @p Op and the arguments given. For example, if the
10863 /// operator is a binary '+', this routine might add "int
10864 /// operator+(int, int)" to cover integer addition.
10866 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10867 OverloadCandidateSet &CandidateSet);
10868
10869 /// Add function candidates found via argument-dependent lookup
10870 /// to the set of overloading candidates.
10871 ///
10872 /// This routine performs argument-dependent name lookup based on the
10873 /// given function name (which may also be an operator name) and adds
10874 /// all of the overload candidates found by ADL to the overload
10875 /// candidate set (C++ [basic.lookup.argdep]).
10877 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10878 TemplateArgumentListInfo *ExplicitTemplateArgs,
10879 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10880
10881 /// Check the enable_if expressions on the given function. Returns the first
10882 /// failing attribute, or NULL if they were all successful.
10883 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10884 ArrayRef<Expr *> Args,
10885 bool MissingImplicitThis = false);
10886
10887 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10888 /// non-ArgDependent DiagnoseIfAttrs.
10889 ///
10890 /// Argument-dependent diagnose_if attributes should be checked each time a
10891 /// function is used as a direct callee of a function call.
10892 ///
10893 /// Returns true if any errors were emitted.
10894 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10895 const Expr *ThisArg,
10896 ArrayRef<const Expr *> Args,
10897 SourceLocation Loc);
10898
10899 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10900 /// ArgDependent DiagnoseIfAttrs.
10901 ///
10902 /// Argument-independent diagnose_if attributes should be checked on every use
10903 /// of a function.
10904 ///
10905 /// Returns true if any errors were emitted.
10906 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10907 SourceLocation Loc);
10908
10909 /// Determine if \p A and \p B are equivalent internal linkage declarations
10910 /// from different modules, and thus an ambiguity error can be downgraded to
10911 /// an extension warning.
10912 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10913 const NamedDecl *B);
10915 SourceLocation Loc, const NamedDecl *D,
10916 ArrayRef<const NamedDecl *> Equiv);
10917
10918 // Emit as a 'note' the specific overload candidate
10920 const NamedDecl *Found, const FunctionDecl *Fn,
10922 QualType DestType = QualType(), bool TakingAddress = false);
10923
10924 // Emit as a series of 'note's all template and non-templates identified by
10925 // the expression Expr
10926 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10927 bool TakingAddress = false);
10928
10929 /// Returns whether the given function's address can be taken or not,
10930 /// optionally emitting a diagnostic if the address can't be taken.
10931 ///
10932 /// Returns false if taking the address of the function is illegal.
10933 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10934 bool Complain = false,
10935 SourceLocation Loc = SourceLocation());
10936
10937 // [PossiblyAFunctionType] --> [Return]
10938 // NonFunctionType --> NonFunctionType
10939 // R (A) --> R(A)
10940 // R (*)(A) --> R (A)
10941 // R (&)(A) --> R (A)
10942 // R (S::*)(A) --> R (A)
10943 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10944
10945 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10946 /// an overloaded function (C++ [over.over]), where @p From is an
10947 /// expression with overloaded function type and @p ToType is the type
10948 /// we're trying to resolve to. For example:
10949 ///
10950 /// @code
10951 /// int f(double);
10952 /// int f(int);
10953 ///
10954 /// int (*pfd)(double) = f; // selects f(double)
10955 /// @endcode
10956 ///
10957 /// This routine returns the resulting FunctionDecl if it could be
10958 /// resolved, and NULL otherwise. When @p Complain is true, this
10959 /// routine will emit diagnostics if there is an error.
10960 FunctionDecl *
10961 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10962 bool Complain, DeclAccessPair &Found,
10963 bool *pHadMultipleCandidates = nullptr);
10964
10965 /// Given an expression that refers to an overloaded function, try to
10966 /// resolve that function to a single function that can have its address
10967 /// taken. This will modify `Pair` iff it returns non-null.
10968 ///
10969 /// This routine can only succeed if from all of the candidates in the
10970 /// overload set for SrcExpr that can have their addresses taken, there is one
10971 /// candidate that is more constrained than the rest.
10972 FunctionDecl *
10973 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10974
10975 /// Given an overloaded function, tries to turn it into a non-overloaded
10976 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10977 /// will perform access checks, diagnose the use of the resultant decl, and,
10978 /// if requested, potentially perform a function-to-pointer decay.
10979 ///
10980 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10981 /// Otherwise, returns true. This may emit diagnostics and return true.
10983 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10984
10985 /// Given an expression that refers to an overloaded function, try to
10986 /// resolve that overloaded function expression down to a single function.
10987 ///
10988 /// This routine can only resolve template-ids that refer to a single function
10989 /// template, where that template-id refers to a single template whose
10990 /// template arguments are either provided by the template-id or have
10991 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10992 ///
10993 /// If no template-ids are found, no diagnostics are emitted and NULL is
10994 /// returned.
10996 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10997 TemplateSpecCandidateSet *FailedTSC = nullptr,
10998 bool ForTypeDeduction = false);
10999
11000 // Resolve and fix an overloaded expression that can be resolved
11001 // because it identifies a single function template specialization.
11002 //
11003 // Last three arguments should only be supplied if Complain = true
11004 //
11005 // Return true if it was logically possible to so resolve the
11006 // expression, regardless of whether or not it succeeded. Always
11007 // returns true if 'complain' is set.
11009 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
11010 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
11011 QualType DestTypeForComplaining = QualType(),
11012 unsigned DiagIDForComplaining = 0);
11013
11014 /// Add the overload candidates named by callee and/or found by argument
11015 /// dependent lookup to the given overload set.
11016 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
11017 ArrayRef<Expr *> Args,
11018 OverloadCandidateSet &CandidateSet,
11019 bool PartialOverloading = false);
11020
11021 /// Add the call candidates from the given set of lookup results to the given
11022 /// overload set. Non-function lookup results are ignored.
11024 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
11025 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
11026
11027 // An enum used to represent the different possible results of building a
11028 // range-based for loop.
11034
11035 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
11036 /// given LookupResult is non-empty, it is assumed to describe a member which
11037 /// will be invoked. Otherwise, the function will be found via argument
11038 /// dependent lookup.
11039 /// CallExpr is set to a valid expression and FRS_Success returned on success,
11040 /// otherwise CallExpr is set to ExprError() and some non-success value
11041 /// is returned.
11043 SourceLocation RangeLoc,
11044 const DeclarationNameInfo &NameInfo,
11045 LookupResult &MemberLookup,
11046 OverloadCandidateSet *CandidateSet,
11047 Expr *Range, ExprResult *CallExpr);
11048
11049 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
11050 /// (which eventually refers to the declaration Func) and the call
11051 /// arguments Args/NumArgs, attempt to resolve the function call down
11052 /// to a specific function. If overload resolution succeeds, returns
11053 /// the call expression produced by overload resolution.
11054 /// Otherwise, emits diagnostics and returns ExprError.
11056 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
11057 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
11058 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
11059
11060 /// Constructs and populates an OverloadedCandidateSet from
11061 /// the given function.
11062 /// \returns true when an the ExprResult output parameter has been set.
11064 MultiExprArg Args, SourceLocation RParenLoc,
11065 OverloadCandidateSet *CandidateSet,
11067
11071 const UnresolvedSetImpl &Fns,
11072 bool PerformADL = true);
11073
11074 /// Perform lookup for an overloaded unary operator.
11077 const UnresolvedSetImpl &Fns,
11078 ArrayRef<Expr *> Args, bool RequiresADL = true);
11079
11080 /// Create a unary operation that may resolve to an overloaded
11081 /// operator.
11082 ///
11083 /// \param OpLoc The location of the operator itself (e.g., '*').
11084 ///
11085 /// \param Opc The UnaryOperatorKind that describes this operator.
11086 ///
11087 /// \param Fns The set of non-member functions that will be
11088 /// considered by overload resolution. The caller needs to build this
11089 /// set based on the context using, e.g.,
11090 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
11091 /// set should not contain any member functions; those will be added
11092 /// by CreateOverloadedUnaryOp().
11093 ///
11094 /// \param Input The input argument.
11097 const UnresolvedSetImpl &Fns, Expr *input,
11098 bool RequiresADL = true);
11099
11100 /// Perform lookup for an overloaded binary operator.
11103 const UnresolvedSetImpl &Fns,
11104 ArrayRef<Expr *> Args, bool RequiresADL = true);
11105
11106 /// Create a binary operation that may resolve to an overloaded
11107 /// operator.
11108 ///
11109 /// \param OpLoc The location of the operator itself (e.g., '+').
11110 ///
11111 /// \param Opc The BinaryOperatorKind that describes this operator.
11112 ///
11113 /// \param Fns The set of non-member functions that will be
11114 /// considered by overload resolution. The caller needs to build this
11115 /// set based on the context using, e.g.,
11116 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
11117 /// set should not contain any member functions; those will be added
11118 /// by CreateOverloadedBinOp().
11119 ///
11120 /// \param LHS Left-hand argument.
11121 /// \param RHS Right-hand argument.
11122 /// \param PerformADL Whether to consider operator candidates found by ADL.
11123 /// \param AllowRewrittenCandidates Whether to consider candidates found by
11124 /// C++20 operator rewrites.
11125 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
11126 /// the function in question. Such a function is never a candidate in
11127 /// our overload resolution. This also enables synthesizing a three-way
11128 /// comparison from < and == as described in C++20 [class.spaceship]p1.
11130 const UnresolvedSetImpl &Fns, Expr *LHS,
11131 Expr *RHS, bool RequiresADL = true,
11132 bool AllowRewrittenCandidates = true,
11133 FunctionDecl *DefaultedFn = nullptr);
11135 const UnresolvedSetImpl &Fns,
11136 Expr *LHS, Expr *RHS,
11137 FunctionDecl *DefaultedFn);
11138
11140 SourceLocation RLoc, Expr *Base,
11141 MultiExprArg Args);
11142
11143 /// BuildCallToMemberFunction - Build a call to a member
11144 /// function. MemExpr is the expression that refers to the member
11145 /// function (and includes the object parameter), Args/NumArgs are the
11146 /// arguments to the function call (not including the object
11147 /// parameter). The caller needs to validate that the member
11148 /// expression refers to a non-static member function or an overloaded
11149 /// member function.
11151 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
11152 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
11153 bool IsExecConfig = false, bool AllowRecovery = false);
11154
11155 /// BuildCallToObjectOfClassType - Build a call to an object of class
11156 /// type (C++ [over.call.object]), which can end up invoking an
11157 /// overloaded function call operator (@c operator()) or performing a
11158 /// user-defined conversion on the object argument.
11160 SourceLocation LParenLoc,
11161 MultiExprArg Args,
11162 SourceLocation RParenLoc);
11163
11164 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
11165 /// (if one exists), where @c Base is an expression of class type and
11166 /// @c Member is the name of the member we're trying to find.
11168 SourceLocation OpLoc,
11169 bool *NoArrowOperatorFound = nullptr);
11170
11173 bool HadMultipleCandidates);
11174
11175 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
11176 /// to a literal operator described by the provided lookup results.
11179 SourceLocation LitEndLoc,
11180 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
11181
11182 /// FixOverloadedFunctionReference - E is an expression that refers to
11183 /// a C++ overloaded function (possibly with some parentheses and
11184 /// perhaps a '&' around it). We have resolved the overloaded function
11185 /// to the function declaration Fn, so patch up the expression E to
11186 /// refer (possibly indirectly) to Fn. Returns the new expr.
11188 FunctionDecl *Fn);
11190 DeclAccessPair FoundDecl,
11191 FunctionDecl *Fn);
11192
11193 /// - Returns a selector which best matches given argument list or
11194 /// nullptr if none could be found
11196 bool IsInstance,
11198
11199 ///@}
11200
11201 //
11202 //
11203 // -------------------------------------------------------------------------
11204 //
11205 //
11206
11207 /// \name Statements
11208 /// Implementations are in SemaStmt.cpp
11209 ///@{
11210
11211public:
11212 /// Stack of active SEH __finally scopes. Can be empty.
11214
11215 /// Stack of '_Defer' statements that are currently being parsed, as well
11216 /// as the locations of their '_Defer' keywords. Can be empty.
11218
11219 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
11221
11223 bool HasLeadingEmptyMacro = false);
11224
11226 SourceLocation EndLoc);
11228
11229 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
11230 /// whose result is unused, warn.
11231 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
11232
11233 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
11237 ArrayRef<Stmt *> Elts, bool isStmtExpr);
11238
11240
11243 SourceLocation DotDotDotLoc, ExprResult RHS,
11244 SourceLocation ColonLoc);
11245
11246 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
11247 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
11248
11250 SourceLocation ColonLoc, Stmt *SubStmt,
11251 Scope *CurScope);
11253 SourceLocation ColonLoc, Stmt *SubStmt);
11254
11256 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
11258 Stmt *SubStmt);
11259
11260 /// Check whether the given statement can have musttail applied to it,
11261 /// issuing a diagnostic and returning false if not. In the success case,
11262 /// the statement is rewritten to remove implicit nodes from the return
11263 /// value.
11264 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
11265
11267 SourceLocation LParenLoc, Stmt *InitStmt,
11268 ConditionResult Cond, SourceLocation RParenLoc,
11269 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
11271 SourceLocation LParenLoc, Stmt *InitStmt,
11272 ConditionResult Cond, SourceLocation RParenLoc,
11273 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
11274
11276
11278 SourceLocation LParenLoc, Stmt *InitStmt,
11279 ConditionResult Cond,
11280 SourceLocation RParenLoc);
11282 Stmt *Body);
11283
11284 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
11285 /// integer not in the range of enum values.
11286 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
11287 Expr *SrcExpr);
11288
11290 ConditionResult Cond, SourceLocation RParenLoc,
11291 Stmt *Body);
11293 SourceLocation WhileLoc, SourceLocation CondLParen,
11294 Expr *Cond, SourceLocation CondRParen);
11295
11297 Stmt *First, ConditionResult Second,
11298 FullExprArg Third, SourceLocation RParenLoc,
11299 Stmt *Body);
11300
11301 /// In an Objective C collection iteration statement:
11302 /// for (x in y)
11303 /// x can be an arbitrary l-value expression. Bind it up as a
11304 /// full-expression.
11306
11308 /// Initial building of a for-range statement.
11310 /// Instantiation or recovery rebuild of a for-range statement. Don't
11311 /// attempt any typo-correction.
11313 /// Determining whether a for-range statement could be built. Avoid any
11314 /// unnecessary or irreversible actions.
11316 };
11317
11318 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
11319 ///
11320 /// C++11 [stmt.ranged]:
11321 /// A range-based for statement is equivalent to
11322 ///
11323 /// {
11324 /// auto && __range = range-init;
11325 /// for ( auto __begin = begin-expr,
11326 /// __end = end-expr;
11327 /// __begin != __end;
11328 /// ++__begin ) {
11329 /// for-range-declaration = *__begin;
11330 /// statement
11331 /// }
11332 /// }
11333 ///
11334 /// The body of the loop is not available yet, since it cannot be analysed
11335 /// until we have determined the type of the for-range-declaration.
11337 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
11338 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
11339 SourceLocation RParenLoc, BuildForRangeKind Kind,
11340 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11341
11342 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
11343 StmtResult BuildCXXForRangeStmt(
11344 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
11345 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
11346 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
11347 BuildForRangeKind Kind,
11348 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11349
11350 /// Set the type of a for-range declaration whose for-range or expansion
11351 /// initialiser is dependent.
11352 void ActOnDependentForRangeInitializer(VarDecl *LoopVar,
11353 BuildForRangeKind BFRK);
11354
11355 /// Holds the 'begin' and 'end' variables of a range-based for loop or
11356 /// expansion statement; begin-expr and end-expr are also provided; the
11357 /// latter are used in some diagnostics.
11359 VarDecl *BeginVar = nullptr;
11360 VarDecl *EndVar = nullptr;
11361 Expr *BeginExpr = nullptr;
11362 Expr *EndExpr = nullptr;
11363 bool isValid() const { return BeginVar != nullptr && EndVar != nullptr; }
11364 };
11365
11366 /// Determine begin-expr and end-expr and build variable declarations for
11367 /// them as per [stmt.ranged].
11368 ForRangeBeginEndInfo BuildCXXForRangeBeginEndVars(
11369 Scope *S, VarDecl *RangeVar, SourceLocation ColonLoc,
11370 SourceLocation CoawaitLoc,
11371 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps,
11372 BuildForRangeKind Kind, bool IsConstexpr,
11373 StmtResult *RebuildResult = nullptr,
11374 llvm::function_ref<StmtResult()> RebuildWithDereference = {},
11375 IdentifierInfo *BeginName = nullptr, IdentifierInfo *EndName = nullptr);
11376
11377 /// Helper used by the expansion statements and for-range code to build
11378 /// a variable declaration for e.g. 'begin' and 'end'.
11379 VarDecl *BuildForRangeVarDecl(SourceLocation Loc, QualType Type,
11380 IdentifierInfo *Name, bool IsConstexpr);
11381
11382 /// Build the range variable of a range-based for loop or iterating
11383 /// expansion statement and return its DeclStmt.
11384 StmtResult BuildCXXForRangeRangeVar(Scope *S, Expr *Range, QualType Type,
11385 bool IsConstexpr = false);
11386
11387 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
11388 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
11389 /// body cannot be performed until after the type of the range variable is
11390 /// determined.
11391 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
11392
11393 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
11394 LabelDecl *TheDecl);
11395 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
11396 SourceLocation StarLoc, Expr *DestExp);
11397 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope,
11398 LabelDecl *Label, SourceLocation LabelLoc);
11399 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope,
11400 LabelDecl *Label, SourceLocation LabelLoc);
11401
11402 void ActOnStartOfDeferStmt(SourceLocation DeferLoc, Scope *CurScope);
11403 void ActOnDeferStmtError(Scope *CurScope);
11404 StmtResult ActOnEndOfDeferStmt(Stmt *Body, Scope *CurScope);
11405
11408
11411
11412 bool isMoveEligible() const { return S != None; };
11414 };
11416
11417 /// Determine whether the given expression might be move-eligible or
11418 /// copy-elidable in either a (co_)return statement or throw expression,
11419 /// without considering function return type, if applicable.
11420 ///
11421 /// \param E The expression being returned from the function or block,
11422 /// being thrown, or being co_returned from a coroutine. This expression
11423 /// might be modified by the implementation.
11424 ///
11425 /// \param Mode Overrides detection of current language mode
11426 /// and uses the rules for C++23.
11427 ///
11428 /// \returns An aggregate which contains the Candidate and isMoveEligible
11429 /// and isCopyElidable methods. If Candidate is non-null, it means
11430 /// isMoveEligible() would be true under the most permissive language
11431 /// standard.
11432 NamedReturnInfo getNamedReturnInfo(
11434
11435 /// Determine whether the given NRVO candidate variable is move-eligible or
11436 /// copy-elidable, without considering function return type.
11437 ///
11438 /// \param VD The NRVO candidate variable.
11439 ///
11440 /// \returns An aggregate which contains the Candidate and isMoveEligible
11441 /// and isCopyElidable methods. If Candidate is non-null, it means
11442 /// isMoveEligible() would be true under the most permissive language
11443 /// standard.
11444 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
11445
11446 /// Updates given NamedReturnInfo's move-eligible and
11447 /// copy-elidable statuses, considering the function
11448 /// return type criteria as applicable to return statements.
11449 ///
11450 /// \param Info The NamedReturnInfo object to update.
11451 ///
11452 /// \param ReturnType This is the return type of the function.
11453 /// \returns The copy elision candidate, in case the initial return expression
11454 /// was copy elidable, or nullptr otherwise.
11455 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
11456 QualType ReturnType);
11457
11458 /// Perform the initialization of a potentially-movable value, which
11459 /// is the result of return value.
11460 ///
11461 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
11462 /// treat returned lvalues as rvalues in certain cases (to prefer move
11463 /// construction), then falls back to treating them as lvalues if that failed.
11466 const NamedReturnInfo &NRInfo, Expr *Value,
11467 bool SupressSimplerImplicitMoves = false);
11468
11470
11471 /// Deduce the return type for a function from a returned expression, per
11472 /// C++1y [dcl.spec.auto]p6.
11474 SourceLocation ReturnLoc, Expr *RetExpr,
11475 const AutoType *AT);
11476
11477 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11478 Scope *CurScope);
11479 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11480 bool AllowRecovery = false);
11481
11482 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
11483 /// for capturing scopes.
11485 NamedReturnInfo &NRInfo,
11486 bool SupressSimplerImplicitMoves);
11487
11488 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
11489 /// and creates a proper catch handler from them.
11491 Stmt *HandlerBlock);
11492
11493 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
11494 /// handlers and creates a try statement from them.
11496 ArrayRef<Stmt *> Handlers);
11497
11498 void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry);
11499
11500 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
11501 SourceLocation TryLoc, Stmt *TryBlock,
11502 Stmt *Handler);
11504 Stmt *Block);
11509
11511 bool IsIfExists,
11512 NestedNameSpecifierLoc QualifierLoc,
11513 DeclarationNameInfo NameInfo,
11514 Stmt *Nested);
11516 bool IsIfExists, CXXScopeSpec &SS,
11517 UnqualifiedId &Name, Stmt *Nested);
11518
11519 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11520 CapturedRegionKind Kind, unsigned NumParams);
11521 typedef std::pair<StringRef, QualType> CapturedParamNameType;
11522 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11523 CapturedRegionKind Kind,
11525 unsigned OpenMPCaptureLevel = 0);
11529 SourceLocation Loc,
11530 unsigned NumParams);
11531
11533 VarDecl *RangeVar, ArrayRef<MaterializeTemporaryExpr *> Temporaries);
11534
11535private:
11536 /// Check whether the given statement can have musttail applied to it,
11537 /// issuing a diagnostic and returning false if not.
11538 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
11539
11540 ///@}
11541
11542 //
11543 //
11544 // -------------------------------------------------------------------------
11545 //
11546 //
11547
11548 /// \name `inline asm` Statement
11549 /// Implementations are in SemaStmtAsm.cpp
11550 ///@{
11551
11552public:
11553 ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel,
11554 bool IsConstexpr = false);
11555 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
11556 bool IsVolatile, unsigned NumOutputs,
11557 unsigned NumInputs, IdentifierInfo **Names,
11558 MultiExprArg Constraints, MultiExprArg Exprs,
11559 Expr *AsmString, MultiExprArg Clobbers,
11560 unsigned NumLabels, SourceLocation RParenLoc);
11561
11563 llvm::InlineAsmIdentifierInfo &Info);
11565 SourceLocation TemplateKWLoc,
11566 UnqualifiedId &Id,
11567 bool IsUnevaluatedContext);
11568 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
11569 SourceLocation AsmLoc);
11571 SourceLocation AsmLoc);
11573 ArrayRef<Token> AsmToks, StringRef AsmString,
11574 unsigned NumOutputs, unsigned NumInputs,
11575 ArrayRef<StringRef> Constraints,
11576 ArrayRef<StringRef> Clobbers,
11577 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
11578 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
11579 SourceLocation Location, bool AlwaysCreate);
11580
11581 ///@}
11582
11583 //
11584 //
11585 // -------------------------------------------------------------------------
11586 //
11587 //
11588
11589 /// \name Statement Attribute Handling
11590 /// Implementations are in SemaStmtAttr.cpp
11591 ///@{
11592
11593public:
11594 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11595 const AttributeCommonInfo &A);
11596 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11597 const AttributeCommonInfo &A);
11598
11599 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11601
11602 /// Process the attributes before creating an attributed statement. Returns
11603 /// the semantic attributes that have been processed.
11604 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11606
11608 SourceRange Range);
11610 const IdentifierInfo *AttrName,
11611 SourceRange Range);
11612
11613 ///@}
11614
11615 //
11616 //
11617 // -------------------------------------------------------------------------
11618 //
11619 //
11620
11621 /// \name C++ Templates
11622 /// Implementations are in SemaTemplate.cpp
11623 ///@{
11624
11625public:
11626 // Saves the current floating-point pragma stack and clear it in this Sema.
11628 public:
11630 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11631 S.FpPragmaStack.Stack.clear();
11632 }
11633 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11636
11637 private:
11638 Sema &S;
11640 };
11641
11643 CurFPFeatures = FPO;
11644 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11645 }
11646
11652
11657
11658 typedef llvm::MapVector<const FunctionDecl *,
11659 std::unique_ptr<LateParsedTemplate>>
11662
11663 /// Determine the number of levels of enclosing template parameters. This is
11664 /// only usable while parsing. Note that this does not include dependent
11665 /// contexts in which no template parameters have yet been declared, such as
11666 /// in a terse function template or generic lambda before the first 'auto' is
11667 /// encountered.
11668 unsigned getTemplateDepth(Scope *S) const;
11669
11671 bool AllowFunctionTemplates = true,
11672 bool AllowDependent = true);
11674 bool AllowFunctionTemplates = true,
11675 bool AllowDependent = true,
11676 bool AllowNonTemplateFunctions = false);
11677 /// Try to interpret the lookup result D as a template-name.
11678 ///
11679 /// \param D A declaration found by name lookup.
11680 /// \param AllowFunctionTemplates Whether function templates should be
11681 /// considered valid results.
11682 /// \param AllowDependent Whether unresolved using declarations (that might
11683 /// name templates) should be considered valid results.
11685 bool AllowFunctionTemplates = true,
11686 bool AllowDependent = true);
11687
11689 /// Whether and why a template name is required in this lookup.
11691 public:
11692 /// Template name is required if TemplateKWLoc is valid.
11694 : TemplateKW(TemplateKWLoc) {}
11695 /// Template name is unconditionally required.
11697
11699 return TemplateKW.value_or(SourceLocation());
11700 }
11701 bool hasTemplateKeyword() const {
11702 return getTemplateKeywordLoc().isValid();
11703 }
11704 bool isRequired() const { return TemplateKW != SourceLocation(); }
11705 explicit operator bool() const { return isRequired(); }
11706
11707 private:
11708 std::optional<SourceLocation> TemplateKW;
11709 };
11710
11712 /// This is not assumed to be a template name.
11714 /// This is assumed to be a template name because lookup found nothing.
11716 /// This is assumed to be a template name because lookup found one or more
11717 /// functions (but no function templates).
11719 };
11720
11721 bool
11723 QualType ObjectType, bool EnteringContext,
11724 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11725 AssumedTemplateKind *ATK = nullptr,
11726 bool AllowTypoCorrection = true);
11727
11729 bool hasTemplateKeyword,
11730 const UnqualifiedId &Name,
11731 ParsedType ObjectType, bool EnteringContext,
11733 bool &MemberOfUnknownSpecialization,
11734 bool AllowTypoCorrection = true);
11735
11736 /// Try to resolve an undeclared template name as a type template.
11737 ///
11738 /// Sets II to the identifier corresponding to the template name, and updates
11739 /// Name to a corresponding (typo-corrected) type template name and TNK to
11740 /// the corresponding kind, if possible.
11742 TemplateNameKind &TNK,
11743 SourceLocation NameLoc,
11744 IdentifierInfo *&II);
11745
11746 /// Determine whether a particular identifier might be the name in a C++1z
11747 /// deduction-guide declaration.
11748 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11749 SourceLocation NameLoc, CXXScopeSpec &SS,
11750 ParsedTemplateTy *Template = nullptr);
11751
11753 SourceLocation IILoc, Scope *S,
11754 const CXXScopeSpec *SS,
11755 TemplateTy &SuggestedTemplate,
11756 TemplateNameKind &SuggestedKind);
11757
11758 /// Determine whether we would be unable to instantiate this template (because
11759 /// it either has no definition, or is in the process of being instantiated).
11761 SourceLocation PointOfInstantiation, NamedDecl *Instantiation,
11762 bool InstantiatedFromMember, const NamedDecl *Pattern,
11763 const NamedDecl *PatternDef, TemplateSpecializationKind TSK,
11764 bool Complain = true, bool *Unreachable = nullptr);
11765
11766 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11767 /// that the template parameter 'PrevDecl' is being shadowed by a new
11768 /// declaration at location Loc. Returns true to indicate that this is
11769 /// an error, and false otherwise.
11770 ///
11771 /// \param Loc The location of the declaration that shadows a template
11772 /// parameter.
11773 ///
11774 /// \param PrevDecl The template parameter that the declaration shadows.
11775 ///
11776 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11777 /// a warning for compatibility with older versions of clang.
11778 /// Ignored when MSVC compatibility is enabled.
11780 bool SupportedForCompatibility = false);
11781
11782 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11783 /// the parameter D to reference the templated declaration and return a
11784 /// pointer to the template declaration. Otherwise, do nothing to D and return
11785 /// null.
11787
11788 /// ActOnTypeParameter - Called when a C++ template type parameter
11789 /// (e.g., "typename T") has been parsed. Typename specifies whether
11790 /// the keyword "typename" was used to declare the type parameter
11791 /// (otherwise, "class" was used), and KeyLoc is the location of the
11792 /// "class" or "typename" keyword. ParamName is the name of the
11793 /// parameter (NULL indicates an unnamed template parameter) and
11794 /// ParamNameLoc is the location of the parameter name (if any).
11795 /// If the type parameter has a default argument, it will be added
11796 /// later via ActOnTypeParameterDefault.
11798 SourceLocation EllipsisLoc,
11799 SourceLocation KeyLoc,
11800 IdentifierInfo *ParamName,
11801 SourceLocation ParamNameLoc, unsigned Depth,
11802 unsigned Position, SourceLocation EqualLoc,
11803 ParsedType DefaultArg, bool HasTypeConstraint);
11804
11806
11807 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11809 TemplateTypeParmDecl *ConstrainedParameter,
11810 SourceLocation EllipsisLoc);
11811 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11813 TemplateTypeParmDecl *ConstrainedParameter,
11814 SourceLocation EllipsisLoc,
11815 bool AllowUnexpandedPack);
11816
11817 /// Attach a type-constraint to a template parameter.
11818 /// \returns true if an error occurred. This can happen if the
11819 /// immediately-declared constraint could not be formed (e.g. incorrect number
11820 /// of arguments for the named concept).
11822 DeclarationNameInfo NameInfo,
11823 TemplateName NamedConcept, NamedDecl *FoundDecl,
11824 const TemplateArgumentListInfo *TemplateArgs,
11825 TemplateTypeParmDecl *ConstrainedParameter,
11826 SourceLocation EllipsisLoc);
11827
11829 NonTypeTemplateParmDecl *NewConstrainedParm,
11830 NonTypeTemplateParmDecl *OrigConstrainedParm,
11831 SourceLocation EllipsisLoc);
11832
11833 /// Require the given type to be a structural type, and diagnose if it is not.
11834 ///
11835 /// \return \c true if an error was produced.
11837
11838 /// Check that the type of a non-type template parameter is
11839 /// well-formed.
11840 ///
11841 /// \returns the (possibly-promoted) parameter type if valid;
11842 /// otherwise, produces a diagnostic and returns a NULL type.
11844 SourceLocation Loc);
11846
11848 unsigned Depth, unsigned Position,
11849 SourceLocation EqualLoc,
11850 Expr *DefaultArg);
11851
11852 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11853 /// parameter (e.g. T in template <template <typename> class T> class array)
11854 /// has been parsed. S is the current scope.
11856 Scope *S, SourceLocation TmpLoc, TemplateNameKind Kind,
11857 bool TypenameKeyword, TemplateParameterList *Params,
11858 SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11859 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11860 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11861
11862 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11863 /// constrained by RequiresClause, that contains the template parameters in
11864 /// Params.
11866 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11867 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11868 SourceLocation RAngleLoc, Expr *RequiresClause);
11869
11870 /// The context in which we are checking a template parameter list.
11872 // For this context, Class, Variable, TypeAlias, and non-pack Template
11873 // Template Parameters are treated uniformly.
11875
11882 };
11883
11884 /// Checks the validity of a template parameter list, possibly
11885 /// considering the template parameter list from a previous
11886 /// declaration.
11887 ///
11888 /// If an "old" template parameter list is provided, it must be
11889 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11890 /// template parameter list.
11891 ///
11892 /// \param NewParams Template parameter list for a new template
11893 /// declaration. This template parameter list will be updated with any
11894 /// default arguments that are carried through from the previous
11895 /// template parameter list.
11896 ///
11897 /// \param OldParams If provided, template parameter list from a
11898 /// previous declaration of the same template. Default template
11899 /// arguments will be merged from the old template parameter list to
11900 /// the new template parameter list.
11901 ///
11902 /// \param TPC Describes the context in which we are checking the given
11903 /// template parameter list.
11904 ///
11905 /// \param SkipBody If we might have already made a prior merged definition
11906 /// of this template visible, the corresponding body-skipping information.
11907 /// Default argument redefinition is not an error when skipping such a body,
11908 /// because (under the ODR) we can assume the default arguments are the same
11909 /// as the prior merged definition.
11910 ///
11911 /// \returns true if an error occurred, false otherwise.
11913 TemplateParameterList *OldParams,
11915 SkipBodyInfo *SkipBody = nullptr);
11916
11917 /// Match the given template parameter lists to the given scope
11918 /// specifier, returning the template parameter list that applies to the
11919 /// name.
11920 ///
11921 /// \param DeclStartLoc the start of the declaration that has a scope
11922 /// specifier or a template parameter list.
11923 ///
11924 /// \param DeclLoc The location of the declaration itself.
11925 ///
11926 /// \param SS the scope specifier that will be matched to the given template
11927 /// parameter lists. This scope specifier precedes a qualified name that is
11928 /// being declared.
11929 ///
11930 /// \param TemplateId The template-id following the scope specifier, if there
11931 /// is one. Used to check for a missing 'template<>'.
11932 ///
11933 /// \param ParamLists the template parameter lists, from the outermost to the
11934 /// innermost template parameter lists.
11935 ///
11936 /// \param IsFriend Whether to apply the slightly different rules for
11937 /// matching template parameters to scope specifiers in friend
11938 /// declarations.
11939 ///
11940 /// \param IsMemberSpecialization will be set true if the scope specifier
11941 /// denotes a fully-specialized type, and therefore this is a declaration of
11942 /// a member specialization.
11943 ///
11944 /// \returns the template parameter list, if any, that corresponds to the
11945 /// name that is preceded by the scope specifier @p SS. This template
11946 /// parameter list may have template parameters (if we're declaring a
11947 /// template) or may have no template parameters (if we're declaring a
11948 /// template specialization), or may be NULL (if what we're declaring isn't
11949 /// itself a template).
11951 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11952 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11953 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11954 bool &IsMemberSpecialization, bool &Invalid,
11955 bool SuppressDiagnostic = false);
11956
11957 /// Returns the template parameter list with all default template argument
11958 /// information.
11960
11962 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11963 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11964 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11965 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11966 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11967 TemplateParameterList **OuterTemplateParamLists,
11968 bool IsMemberSpecialization, SkipBodyInfo *SkipBody = nullptr);
11969
11970 /// Translates template arguments as provided by the parser
11971 /// into template arguments used by semantic analysis.
11974
11975 /// Convert a parsed type into a parsed template argument. This is mostly
11976 /// trivial, except that we may have parsed a C++17 deduced class template
11977 /// specialization type, in which case we should form a template template
11978 /// argument instead of a type template argument.
11980
11982
11985 SourceLocation TemplateLoc,
11986 TemplateArgumentListInfo &TemplateArgs,
11987 Scope *Scope, bool ForNestedNameSpecifier);
11988
11990 ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword,
11991 SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS,
11992 SourceLocation TemplateKWLoc, TemplateTy Template,
11993 const IdentifierInfo *TemplateII,
11994 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11995 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11996 bool IsCtorOrDtorName = false, bool IsClassName = false,
11997 ImplicitTypenameContext AllowImplicitTypename =
11999
12000 /// Parsed an elaborated-type-specifier that refers to a template-id,
12001 /// such as \c class T::template apply<U>.
12003 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
12004 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
12005 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
12006 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
12007
12010 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
12012
12013 /// Get the specialization of the given variable template corresponding to
12014 /// the specified argument list, or a null-but-valid result if the arguments
12015 /// are dependent.
12017 SourceLocation TemplateLoc,
12018 SourceLocation TemplateNameLoc,
12019 const TemplateArgumentListInfo &TemplateArgs,
12020 bool SetWrittenArgs);
12021
12022 /// Form a reference to the specialization of the given variable template
12023 /// corresponding to the specified argument list, or a null-but-valid result
12024 /// if the arguments are dependent.
12026 const DeclarationNameInfo &NameInfo,
12028 SourceLocation TemplateLoc,
12029 const TemplateArgumentListInfo *TemplateArgs);
12030
12032 const DeclarationNameInfo &NameInfo, TemplateName Template,
12033 const TemplateArgumentListInfo *TemplateArgs);
12034
12036 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12037 const DeclarationNameInfo &ConceptNameInfo,
12038 NamedDecl *FoundDecl, TemplateDecl *NamedConcept,
12039 const TemplateArgumentListInfo *TemplateArgs,
12040 bool DoCheckConstraintSatisfaction = true);
12041
12044 bool TemplateKeyword, TemplateDecl *TD,
12045 SourceLocation Loc);
12046
12048 SourceLocation TemplateKWLoc, LookupResult &R,
12049 bool RequiresADL,
12050 const TemplateArgumentListInfo *TemplateArgs);
12051
12052 // We actually only call this from template instantiation.
12055 const DeclarationNameInfo &NameInfo,
12056 const TemplateArgumentListInfo *TemplateArgs,
12057 bool IsAddressOfOperand);
12058
12060 return Pack.pack_size() - 1 - *ArgPackSubstIndex;
12061 }
12062
12065 Arg = Arg.pack_elements()[*ArgPackSubstIndex];
12066 if (Arg.isPackExpansion())
12067 Arg = Arg.getPackExpansionPattern();
12068 return Arg;
12069 }
12070
12072 BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index,
12073 QualType ParamType, SourceLocation loc,
12074 TemplateArgument Replacement,
12075 UnsignedOrNone PackIndex, bool Final);
12076
12077 /// Form a template name from a name that is syntactically required to name a
12078 /// template, either due to use of the 'template' keyword or because a name in
12079 /// this syntactic context is assumed to name a template (C++
12080 /// [temp.names]p2-4).
12081 ///
12082 /// This action forms a template name given the name of the template and its
12083 /// optional scope specifier. This is used when the 'template' keyword is used
12084 /// or when the parsing context unambiguously treats a following '<' as
12085 /// introducing a template argument list. Note that this may produce a
12086 /// non-dependent template name if we can perform the lookup now and identify
12087 /// the named template.
12088 ///
12089 /// For example, given "x.MetaFun::template apply", the scope specifier
12090 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
12091 /// of the "template" keyword, and "apply" is the \p Name.
12093 SourceLocation TemplateKWLoc,
12094 const UnqualifiedId &Name,
12095 ParsedType ObjectType,
12096 bool EnteringContext, TemplateTy &Template,
12097 bool AllowInjectedClassName = false);
12098
12100 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
12101 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
12103 MultiTemplateParamsArg TemplateParameterLists,
12104 SkipBodyInfo *SkipBody = nullptr);
12105
12106 /// Check the non-type template arguments of a class template
12107 /// partial specialization according to C++ [temp.class.spec]p9.
12108 ///
12109 /// \param TemplateNameLoc the location of the template name.
12110 /// \param PrimaryTemplate the template parameters of the primary class
12111 /// template.
12112 /// \param NumExplicit the number of explicitly-specified template arguments.
12113 /// \param TemplateArgs the template arguments of the class template
12114 /// partial specialization.
12115 ///
12116 /// \returns \c true if there was an error, \c false otherwise.
12118 TemplateDecl *PrimaryTemplate,
12119 unsigned NumExplicitArgs,
12125
12127 MultiTemplateParamsArg TemplateParameterLists,
12128 Declarator &D);
12129
12130 /// Diagnose cases where we have an explicit template specialization
12131 /// before/after an explicit template instantiation, producing diagnostics
12132 /// for those cases where they are required and determining whether the
12133 /// new specialization/instantiation will have any effect.
12134 ///
12135 /// \param NewLoc the location of the new explicit specialization or
12136 /// instantiation.
12137 ///
12138 /// \param NewTSK the kind of the new explicit specialization or
12139 /// instantiation.
12140 ///
12141 /// \param PrevDecl the previous declaration of the entity.
12142 ///
12143 /// \param PrevTSK the kind of the old explicit specialization or
12144 /// instantiatin.
12145 ///
12146 /// \param PrevPointOfInstantiation if valid, indicates where the previous
12147 /// declaration was instantiated (either implicitly or explicitly).
12148 ///
12149 /// \param HasNoEffect will be set to true to indicate that the new
12150 /// specialization or instantiation has no effect and should be ignored.
12151 ///
12152 /// \returns true if there was an error that should prevent the introduction
12153 /// of the new declaration into the AST, false otherwise.
12155 SourceLocation NewLoc,
12156 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
12157 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
12158 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
12159
12160 /// Perform semantic analysis for the given dependent function
12161 /// template specialization.
12162 ///
12163 /// The only possible way to get a dependent function template specialization
12164 /// is with a friend declaration, like so:
12165 ///
12166 /// \code
12167 /// template <class T> void foo(T);
12168 /// template <class T> class A {
12169 /// friend void foo<>(T);
12170 /// };
12171 /// \endcode
12172 ///
12173 /// There really isn't any useful analysis we can do here, so we
12174 /// just store the information.
12176 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
12178
12179 /// Perform semantic analysis for the given function template
12180 /// specialization.
12181 ///
12182 /// This routine performs all of the semantic analysis required for an
12183 /// explicit function template specialization. On successful completion,
12184 /// the function declaration \p FD will become a function template
12185 /// specialization.
12186 ///
12187 /// \param FD the function declaration, which will be updated to become a
12188 /// function template specialization.
12189 ///
12190 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
12191 /// if any. Note that this may be valid info even when 0 arguments are
12192 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
12193 /// as it anyway contains info on the angle brackets locations.
12194 ///
12195 /// \param Previous the set of declarations that may be specialized by
12196 /// this function specialization.
12197 ///
12198 /// \param QualifiedFriend whether this is a lookup for a qualified friend
12199 /// declaration with no explicit template argument list that might be
12200 /// befriending a function template specialization.
12202 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
12203 LookupResult &Previous, bool QualifiedFriend = false);
12204
12205 /// Perform semantic analysis for the given non-template member
12206 /// specialization.
12207 ///
12208 /// This routine performs all of the semantic analysis required for an
12209 /// explicit member function specialization. On successful completion,
12210 /// the function declaration \p FD will become a member function
12211 /// specialization.
12212 ///
12213 /// \param Member the member declaration, which will be updated to become a
12214 /// specialization.
12215 ///
12216 /// \param Previous the set of declarations, one of which may be specialized
12217 /// by this function specialization; the set will be modified to contain the
12218 /// redeclared member.
12221
12222 // Explicit instantiation of a class template specialization
12224 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
12225 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
12226 TemplateTy Template, SourceLocation TemplateNameLoc,
12227 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
12228 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
12229
12230 // Explicit instantiation of a member class of a class template.
12232 SourceLocation TemplateLoc,
12233 unsigned TagSpec, SourceLocation KWLoc,
12234 CXXScopeSpec &SS, IdentifierInfo *Name,
12235 SourceLocation NameLoc,
12236 const ParsedAttributesView &Attr);
12237
12239 SourceLocation TemplateLoc,
12240 Declarator &D);
12241
12242 /// If the given template parameter has a default template
12243 /// argument, substitute into that default template argument and
12244 /// return the corresponding template argument.
12246 TemplateDecl *Template, SourceLocation TemplateKWLoc,
12247 SourceLocation TemplateNameLoc, SourceLocation RAngleLoc, Decl *Param,
12248 ArrayRef<TemplateArgument> SugaredConverted,
12249 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
12250
12251 /// Returns the top most location responsible for the definition of \p N.
12252 /// If \p N is a a template specialization, this is the location
12253 /// of the top of the instantiation stack.
12254 /// Otherwise, the location of \p N is returned.
12256
12257 /// Specifies the context in which a particular template
12258 /// argument is being checked.
12260 /// The template argument was specified in the code or was
12261 /// instantiated with some deduced template arguments.
12263
12264 /// The template argument was deduced via template argument
12265 /// deduction.
12267
12268 /// The template argument was deduced from an array bound
12269 /// via template argument deduction.
12271 };
12272
12280
12281 /// The checked, converted argument will be added to the
12282 /// end of these vectors.
12284
12285 /// The check is being performed in the context of partial ordering.
12287
12288 /// If true, assume these template arguments are
12289 /// the injected template arguments for a template template parameter.
12290 /// This will relax the requirement that all its possible uses are valid:
12291 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
12292 /// during instantiation.
12294
12295 /// Is set to true when, in the context of TTP matching, a pack parameter
12296 /// matches non-pack arguments.
12297 bool StrictPackMatch = false;
12298 };
12299
12300 /// Check that the given template argument corresponds to the given
12301 /// template parameter.
12302 ///
12303 /// \param Param The template parameter against which the argument will be
12304 /// checked.
12305 ///
12306 /// \param Arg The template argument, which may be updated due to conversions.
12307 ///
12308 /// \param Template The template in which the template argument resides.
12309 ///
12310 /// \param TemplateLoc The location of the template name for the template
12311 /// whose argument list we're matching.
12312 ///
12313 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
12314 /// the template argument list.
12315 ///
12316 /// \param ArgumentPackIndex The index into the argument pack where this
12317 /// argument will be placed. Only valid if the parameter is a parameter pack.
12318 ///
12319 /// \param CTAK Describes how we arrived at this particular template argument:
12320 /// explicitly written, deduced, etc.
12321 ///
12322 /// \returns true on error, false otherwise.
12324 NamedDecl *Template, SourceLocation TemplateLoc,
12325 SourceLocation RAngleLoc,
12326 unsigned ArgumentPackIndex,
12329
12330 /// Check that the given template arguments can be provided to
12331 /// the given template, converting the arguments along the way.
12332 ///
12333 /// \param Template The template to which the template arguments are being
12334 /// provided.
12335 ///
12336 /// \param TemplateLoc The location of the template name in the source.
12337 ///
12338 /// \param TemplateArgs The list of template arguments. If the template is
12339 /// a template template parameter, this function may extend the set of
12340 /// template arguments to also include substituted, defaulted template
12341 /// arguments.
12342 ///
12343 /// \param PartialTemplateArgs True if the list of template arguments is
12344 /// intentionally partial, e.g., because we're checking just the initial
12345 /// set of template arguments.
12346 ///
12347 /// \param Converted Will receive the converted, canonicalized template
12348 /// arguments.
12349 ///
12350 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
12351 /// contain the converted forms of the template arguments as written.
12352 /// Otherwise, \p TemplateArgs will not be modified.
12353 ///
12354 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
12355 /// receive true if the cause for the error is the associated constraints of
12356 /// the template not being satisfied by the template arguments.
12357 ///
12358 /// \param DefaultArgs any default arguments from template specialization
12359 /// deduction.
12360 ///
12361 /// \returns true if an error occurred, false otherwise.
12363 SourceLocation TemplateLoc,
12364 TemplateArgumentListInfo &TemplateArgs,
12365 const DefaultArguments &DefaultArgs,
12366 bool PartialTemplateArgs,
12368 bool UpdateArgsWithConversions = true,
12369 bool *ConstraintsNotSatisfied = nullptr);
12370
12373 SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs,
12374 const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
12375 CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions = true,
12376 bool *ConstraintsNotSatisfied = nullptr);
12377
12380 SmallVectorImpl<TemplateArgument> &SugaredConverted,
12381 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
12382
12383 /// Check a template argument against its corresponding
12384 /// template type parameter.
12385 ///
12386 /// This routine implements the semantics of C++ [temp.arg.type]. It
12387 /// returns true if an error occurred, and false otherwise.
12389
12390 /// Check a template argument against its corresponding
12391 /// non-type template parameter.
12392 ///
12393 /// This routine implements the semantics of C++ [temp.arg.nontype].
12394 /// If an error occurred, it returns ExprError(); otherwise, it
12395 /// returns the converted template argument. \p ParamType is the
12396 /// type of the non-type template parameter after it has been instantiated.
12398 QualType InstantiatedParamType, Expr *Arg,
12399 TemplateArgument &SugaredConverted,
12400 TemplateArgument &CanonicalConverted,
12401 bool StrictCheck,
12403
12404 /// Check a template argument against its corresponding
12405 /// template template parameter.
12406 ///
12407 /// This routine implements the semantics of C++ [temp.arg.template].
12408 /// It returns true if an error occurred, and false otherwise.
12410 TemplateParameterList *Params,
12412 bool PartialOrdering,
12413 bool *StrictPackMatch);
12414
12417 const TemplateArgumentLoc &Arg);
12418
12420 std::optional<SourceRange> ParamRange = {});
12422
12423 /// Given a non-type template argument that refers to a
12424 /// declaration and the type of its corresponding non-type template
12425 /// parameter, produce an expression that properly refers to that
12426 /// declaration.
12427 /// FIXME: This is used in some contexts where the resulting expression
12428 /// doesn't need to live too long. It would be useful if this function
12429 /// could return a temporary expression.
12431 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc);
12434 SourceLocation Loc);
12435
12436 /// Enumeration describing how template parameter lists are compared
12437 /// for equality.
12439 /// We are matching the template parameter lists of two templates
12440 /// that might be redeclarations.
12441 ///
12442 /// \code
12443 /// template<typename T> struct X;
12444 /// template<typename T> struct X;
12445 /// \endcode
12447
12448 /// We are matching the template parameter lists of two template
12449 /// template parameters as part of matching the template parameter lists
12450 /// of two templates that might be redeclarations.
12451 ///
12452 /// \code
12453 /// template<template<int I> class TT> struct X;
12454 /// template<template<int Value> class Other> struct X;
12455 /// \endcode
12457
12458 /// We are determining whether the template-parameters are equivalent
12459 /// according to C++ [temp.over.link]/6. This comparison does not consider
12460 /// constraints.
12461 ///
12462 /// \code
12463 /// template<C1 T> void f(T);
12464 /// template<C2 T> void f(T);
12465 /// \endcode
12467 };
12468
12469 // A struct to represent the 'new' declaration, which is either itself just
12470 // the named decl, or the important information we need about it in order to
12471 // do constraint comparisons.
12473 const NamedDecl *ND = nullptr;
12474 const DeclContext *DC = nullptr;
12475 const DeclContext *LexicalDC = nullptr;
12476 SourceLocation Loc;
12477
12478 public:
12481 const DeclContext *LexicalDeclCtx,
12482 SourceLocation Loc)
12483
12484 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
12485 assert(DC && LexicalDC &&
12486 "Constructor only for cases where we have the information to put "
12487 "in here");
12488 }
12489
12490 // If this was constructed with no information, we cannot do substitution
12491 // for constraint comparison, so make sure we can check that.
12492 bool isInvalid() const { return !ND && !DC; }
12493
12494 const NamedDecl *getDecl() const { return ND; }
12495
12496 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
12497
12499 return ND ? ND->getLexicalDeclContext() : LexicalDC;
12500 }
12501
12503 return ND ? ND->getDeclContext() : DC;
12504 }
12505
12506 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
12507 };
12508
12509 /// Determine whether the given template parameter lists are
12510 /// equivalent.
12511 ///
12512 /// \param New The new template parameter list, typically written in the
12513 /// source code as part of a new template declaration.
12514 ///
12515 /// \param Old The old template parameter list, typically found via
12516 /// name lookup of the template declared with this template parameter
12517 /// list.
12518 ///
12519 /// \param Complain If true, this routine will produce a diagnostic if
12520 /// the template parameter lists are not equivalent.
12521 ///
12522 /// \param Kind describes how we are to match the template parameter lists.
12523 ///
12524 /// \param TemplateArgLoc If this source location is valid, then we
12525 /// are actually checking the template parameter list of a template
12526 /// argument (New) against the template parameter list of its
12527 /// corresponding template template parameter (Old). We produce
12528 /// slightly different diagnostics in this scenario.
12529 ///
12530 /// \returns True if the template parameter lists are equal, false
12531 /// otherwise.
12533 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
12534 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
12536 SourceLocation TemplateArgLoc = SourceLocation());
12537
12539 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
12541 SourceLocation TemplateArgLoc = SourceLocation()) {
12542 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
12543 Kind, TemplateArgLoc);
12544 }
12545
12546 /// Check whether a template can be declared within this scope.
12547 ///
12548 /// If the template declaration is valid in this scope, returns
12549 /// false. Otherwise, issues a diagnostic and returns true.
12550 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
12551
12552 /// Called when the parser has parsed a C++ typename
12553 /// specifier, e.g., "typename T::type".
12554 ///
12555 /// \param S The scope in which this typename type occurs.
12556 /// \param TypenameLoc the location of the 'typename' keyword
12557 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12558 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
12559 /// \param IdLoc the location of the identifier.
12560 /// \param IsImplicitTypename context where T::type refers to a type.
12562 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
12563 const IdentifierInfo &II, SourceLocation IdLoc,
12565
12566 /// Called when the parser has parsed a C++ typename
12567 /// specifier that ends in a template-id, e.g.,
12568 /// "typename MetaFun::template apply<T1, T2>".
12569 ///
12570 /// \param S The scope in which this typename type occurs.
12571 /// \param TypenameLoc the location of the 'typename' keyword
12572 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12573 /// \param TemplateLoc the location of the 'template' keyword, if any.
12574 /// \param TemplateName The template name.
12575 /// \param TemplateII The identifier used to name the template.
12576 /// \param TemplateIILoc The location of the template name.
12577 /// \param LAngleLoc The location of the opening angle bracket ('<').
12578 /// \param TemplateArgs The template arguments.
12579 /// \param RAngleLoc The location of the closing angle bracket ('>').
12581 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
12582 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
12583 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
12584 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
12585 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
12586
12588 SourceLocation KeywordLoc,
12589 NestedNameSpecifierLoc QualifierLoc,
12590 const IdentifierInfo &II, SourceLocation IILoc,
12591 TypeSourceInfo **TSI, bool DeducedTSTContext);
12592
12594 SourceLocation KeywordLoc,
12595 NestedNameSpecifierLoc QualifierLoc,
12596 const IdentifierInfo &II, SourceLocation IILoc,
12597 bool DeducedTSTContext = true);
12598
12599 /// Rebuilds a type within the context of the current instantiation.
12600 ///
12601 /// The type \p T is part of the type of an out-of-line member definition of
12602 /// a class template (or class template partial specialization) that was
12603 /// parsed and constructed before we entered the scope of the class template
12604 /// (or partial specialization thereof). This routine will rebuild that type
12605 /// now that we have entered the declarator's scope, which may produce
12606 /// different canonical types, e.g.,
12607 ///
12608 /// \code
12609 /// template<typename T>
12610 /// struct X {
12611 /// typedef T* pointer;
12612 /// pointer data();
12613 /// };
12614 ///
12615 /// template<typename T>
12616 /// typename X<T>::pointer X<T>::data() { ... }
12617 /// \endcode
12618 ///
12619 /// Here, the type "typename X<T>::pointer" will be created as a
12620 /// DependentNameType, since we do not know that we can look into X<T> when we
12621 /// parsed the type. This function will rebuild the type, performing the
12622 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
12623 /// canonical type is the same as the canonical type of T*, allowing the
12624 /// return types of the out-of-line definition and the declaration to match.
12626 SourceLocation Loc,
12627 DeclarationName Name);
12629
12631
12632 /// Rebuild the template parameters now that we know we're in a current
12633 /// instantiation.
12634 bool
12636
12637 /// Produces a formatted string that describes the binding of
12638 /// template parameters to template arguments.
12639 std::string
12641 const TemplateArgumentList &Args);
12642
12643 std::string
12645 const TemplateArgument *Args,
12646 unsigned NumArgs);
12647
12651
12652 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12653 /// was just parsed. This is only possible with an explicit scope
12654 /// specifier naming a dependent type.
12656 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12657 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12658 const TemplateArgumentListInfo *TemplateArgs);
12659
12662 SourceLocation TemplateKWLoc,
12663 const DeclarationNameInfo &NameInfo,
12664 const TemplateArgumentListInfo *TemplateArgs);
12665
12666 // Calculates whether the expression Constraint depends on an enclosing
12667 // template, for the purposes of [temp.friend] p9.
12668 // TemplateDepth is the 'depth' of the friend function, which is used to
12669 // compare whether a declaration reference is referring to a containing
12670 // template, or just the current friend function. A 'lower' TemplateDepth in
12671 // the AST refers to a 'containing' template. As the constraint is
12672 // uninstantiated, this is relative to the 'top' of the TU.
12673 bool
12675 unsigned TemplateDepth,
12676 const Expr *Constraint);
12677
12678 /// Find the failed Boolean condition within a given Boolean
12679 /// constant expression, and describe it with a string.
12680 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12681
12683
12685 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12686 const IdentifierInfo *Name, SourceLocation NameLoc);
12687
12689 Expr *ConstraintExpr,
12690 const ParsedAttributesView &Attrs);
12691
12693 bool &AddToScope);
12695
12696 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12697 const CXXScopeSpec &SS,
12698 const IdentifierInfo *Name,
12699 SourceLocation TagLoc, SourceLocation NameLoc);
12700
12702 CachedTokens &Toks);
12705
12706 /// We've found a use of a templated declaration that would trigger an
12707 /// implicit instantiation. Check that any relevant explicit specializations
12708 /// and partial specializations are visible/reachable, and diagnose if not.
12711
12712 ///@}
12713
12714 //
12715 //
12716 // -------------------------------------------------------------------------
12717 //
12718 //
12719
12720 /// \name C++ Template Argument Deduction
12721 /// Implementations are in SemaTemplateDeduction.cpp
12722 ///@{
12723
12724public:
12725 class SFINAETrap;
12726
12729 : S(S), Prev(std::exchange(S.CurrentSFINAEContext, Cur)) {}
12730
12731 protected:
12733 ~SFINAEContextBase() { S.CurrentSFINAEContext = Prev; }
12736
12737 private:
12738 SFINAETrap *Prev;
12739 };
12740
12744
12745 /// RAII class used to determine whether SFINAE has
12746 /// trapped any errors that occur during template argument
12747 /// deduction.
12748 class SFINAETrap : SFINAEContextBase {
12749 bool HasErrorOcurred = false;
12750 bool WithAccessChecking = false;
12751 bool PrevLastDiagnosticIgnored =
12752 S.getDiagnostics().isLastDiagnosticIgnored();
12753 sema::TemplateDeductionInfo *DeductionInfo = nullptr;
12754
12755 SFINAETrap(Sema &S, sema::TemplateDeductionInfo *Info,
12756 bool WithAccessChecking)
12757 : SFINAEContextBase(S, this), WithAccessChecking(WithAccessChecking),
12758 DeductionInfo(Info) {}
12759
12760 public:
12761 /// \param WithAccessChecking If true, discard all diagnostics (from the
12762 /// immediate context) instead of adding them to the currently active
12763 /// \ref TemplateDeductionInfo.
12764 explicit SFINAETrap(Sema &S, bool WithAccessChecking = false)
12765 : SFINAETrap(S, /*Info=*/nullptr, WithAccessChecking) {}
12766
12768 : SFINAETrap(S, &Info, /*WithAccessChecking=*/false) {}
12769
12771 S.getDiagnostics().setLastDiagnosticIgnored(PrevLastDiagnosticIgnored);
12772 }
12773
12774 SFINAETrap(const SFINAETrap &) = delete;
12775 SFINAETrap &operator=(const SFINAETrap &) = delete;
12776
12778 return DeductionInfo;
12779 }
12780
12781 /// Determine whether any SFINAE errors have been trapped.
12782 bool hasErrorOccurred() const { return HasErrorOcurred; }
12783 void setErrorOccurred() { HasErrorOcurred = true; }
12784
12785 bool withAccessChecking() const { return WithAccessChecking; }
12786 };
12787
12788 /// RAII class used to indicate that we are performing provisional
12789 /// semantic analysis to determine the validity of a construct, so
12790 /// typo-correction and diagnostics in the immediate context (not within
12791 /// implicitly-instantiated templates) should be suppressed.
12793 Sema &SemaRef;
12794 // FIXME: Using a SFINAETrap for this is a hack.
12795 SFINAETrap Trap;
12796 bool PrevDisableTypoCorrection;
12797
12798 public:
12799 explicit TentativeAnalysisScope(Sema &SemaRef)
12800 : SemaRef(SemaRef), Trap(SemaRef, /*ForValidityCheck=*/true),
12801 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12802 SemaRef.DisableTypoCorrection = true;
12803 }
12805 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12806 }
12807
12810 };
12811
12812 /// For each declaration that involved template argument deduction, the
12813 /// set of diagnostics that were suppressed during that template argument
12814 /// deduction.
12815 ///
12816 /// FIXME: Serialize this structure to the AST file.
12817 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12820
12821 /// Compare types for equality with respect to possibly compatible
12822 /// function types (noreturn adjustment, implicit calling conventions). If any
12823 /// of parameter and argument is not a function, just perform type comparison.
12824 ///
12825 /// \param P the template parameter type.
12826 ///
12827 /// \param A the argument type.
12829
12830 /// Allocate a TemplateArgumentLoc where all locations have
12831 /// been initialized to the given location.
12832 ///
12833 /// \param Arg The template argument we are producing template argument
12834 /// location information for.
12835 ///
12836 /// \param NTTPType For a declaration template argument, the type of
12837 /// the non-type template parameter that corresponds to this template
12838 /// argument. Can be null if no type sugar is available to add to the
12839 /// type from the template argument.
12840 ///
12841 /// \param Loc The source location to use for the resulting template
12842 /// argument.
12844 QualType NTTPType,
12845 SourceLocation Loc);
12846
12847 /// Get a template argument mapping the given template parameter to itself,
12848 /// e.g. for X in \c template<int X>, this would return an expression template
12849 /// argument referencing X.
12851 SourceLocation Location);
12852
12853 /// Adjust the type \p ArgFunctionType to match the calling convention,
12854 /// noreturn, and optionally the exception specification of \p FunctionType.
12855 /// Deduction often wants to ignore these properties when matching function
12856 /// types.
12858 bool AdjustExceptionSpec = false);
12859
12862 ArrayRef<TemplateArgument> TemplateArgs,
12864
12867 ArrayRef<TemplateArgument> TemplateArgs,
12869
12870 /// Deduce the template arguments of the given template from \p FromType.
12871 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12872 /// [over.match.class.deduct]p4.
12873 ///
12874 /// It only supports class or type alias templates.
12878
12883 bool NumberOfArgumentsMustMatch);
12884
12885 /// Substitute the explicitly-provided template arguments into the
12886 /// given function template according to C++ [temp.arg.explicit].
12887 ///
12888 /// \param FunctionTemplate the function template into which the explicit
12889 /// template arguments will be substituted.
12890 ///
12891 /// \param ExplicitTemplateArgs the explicitly-specified template
12892 /// arguments.
12893 ///
12894 /// \param Deduced the deduced template arguments, which will be populated
12895 /// with the converted and checked explicit template arguments.
12896 ///
12897 /// \param ParamTypes will be populated with the instantiated function
12898 /// parameters.
12899 ///
12900 /// \param FunctionType if non-NULL, the result type of the function template
12901 /// will also be instantiated and the pointed-to value will be updated with
12902 /// the instantiated function type.
12903 ///
12904 /// \param Info if substitution fails for any reason, this object will be
12905 /// populated with more information about the failure.
12906 ///
12907 /// \returns TemplateDeductionResult::Success if substitution was successful,
12908 /// or some failure condition.
12911 TemplateArgumentListInfo &ExplicitTemplateArgs,
12915
12916 /// brief A function argument from which we performed template argument
12917 // deduction for a call.
12930
12931 /// Finish template argument deduction for a function template,
12932 /// checking the deduced template arguments for completeness and forming
12933 /// the function template specialization.
12934 ///
12935 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12936 /// which the deduced argument types should be compared.
12937 /// \param CheckNonDependent Callback before substituting into the declaration
12938 /// with the deduced template arguments.
12939 /// \param OnlyInitializeNonUserDefinedConversions is used as a workaround for
12940 /// some breakages introduced by CWG2369, where non-user-defined conversions
12941 /// are checked first before the constraints.
12945 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12947 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12948 bool PartialOverloading, bool PartialOrdering,
12949 bool ForOverloadSetAddressResolution,
12950 llvm::function_ref<bool(bool)> CheckNonDependent =
12951 [](bool /*OnlyInitializeNonUserDefinedConversions*/) {
12952 return false;
12953 });
12954
12955 /// Perform [temp.friend] p5 template argument deduction for a dependent
12956 /// friend declaration and a candidate class template specialization.
12958 ClassTemplateDecl *PatternCTD,
12959 ClassTemplateDecl *CandidateCTD,
12961 ArrayRef<TemplateArgument> PatternArgs,
12962 ArrayRef<TemplateArgument> CandidateArgs,
12963 SourceLocation Loc,
12964 TemplateSpecCandidateSet *FailedTSC,
12965 MultiLevelTemplateArgumentList &DeducedArgs);
12966
12967 /// Perform template argument deduction from a function call
12968 /// (C++ [temp.deduct.call]).
12969 ///
12970 /// \param FunctionTemplate the function template for which we are performing
12971 /// template argument deduction.
12972 ///
12973 /// \param ExplicitTemplateArgs the explicit template arguments provided
12974 /// for this call.
12975 ///
12976 /// \param Args the function call arguments
12977 ///
12978 /// \param Specialization if template argument deduction was successful,
12979 /// this will be set to the function template specialization produced by
12980 /// template argument deduction.
12981 ///
12982 /// \param Info the argument will be updated to provide additional information
12983 /// about template argument deduction.
12984 ///
12985 /// \param CheckNonDependent A callback to invoke to check conversions for
12986 /// non-dependent parameters, between deduction and substitution, per DR1391.
12987 /// If this returns true, substitution will be skipped and we return
12988 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12989 /// passed the parameter types (after substituting explicit template
12990 /// arguments).
12991 ///
12992 /// \returns the result of template argument deduction.
12995 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12997 bool PartialOverloading, bool AggregateDeductionCandidate,
12998 bool PartialOrdering, QualType ObjectType,
12999 Expr::Classification ObjectClassification,
13000 bool ForOverloadSetAddressResolution,
13001 llvm::function_ref<bool(ArrayRef<QualType>, bool)> CheckNonDependent);
13002
13003 /// Deduce template arguments when taking the address of a function
13004 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
13005 /// a template.
13006 ///
13007 /// \param FunctionTemplate the function template for which we are performing
13008 /// template argument deduction.
13009 ///
13010 /// \param ExplicitTemplateArgs the explicitly-specified template
13011 /// arguments.
13012 ///
13013 /// \param ArgFunctionType the function type that will be used as the
13014 /// "argument" type (A) when performing template argument deduction from the
13015 /// function template's function type. This type may be NULL, if there is no
13016 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
13017 ///
13018 /// \param Specialization if template argument deduction was successful,
13019 /// this will be set to the function template specialization produced by
13020 /// template argument deduction.
13021 ///
13022 /// \param Info the argument will be updated to provide additional information
13023 /// about template argument deduction.
13024 ///
13025 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
13026 /// the address of a function template per [temp.deduct.funcaddr] and
13027 /// [over.over]. If \c false, we are looking up a function template
13028 /// specialization based on its signature, per [temp.deduct.decl].
13029 ///
13030 /// \returns the result of template argument deduction.
13033 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
13035 bool IsAddressOfFunction = false);
13036
13037 /// Deduce template arguments for a templated conversion
13038 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
13039 /// conversion function template specialization.
13042 Expr::Classification ObjectClassification, QualType ToType,
13044
13045 /// Deduce template arguments for a function template when there is
13046 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
13047 ///
13048 /// \param FunctionTemplate the function template for which we are performing
13049 /// template argument deduction.
13050 ///
13051 /// \param ExplicitTemplateArgs the explicitly-specified template
13052 /// arguments.
13053 ///
13054 /// \param Specialization if template argument deduction was successful,
13055 /// this will be set to the function template specialization produced by
13056 /// template argument deduction.
13057 ///
13058 /// \param Info the argument will be updated to provide additional information
13059 /// about template argument deduction.
13060 ///
13061 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
13062 /// the address of a function template in a context where we do not have a
13063 /// target type, per [over.over]. If \c false, we are looking up a function
13064 /// template specialization based on its signature, which only happens when
13065 /// deducing a function parameter type from an argument that is a template-id
13066 /// naming a function template specialization.
13067 ///
13068 /// \returns the result of template argument deduction.
13071 TemplateArgumentListInfo *ExplicitTemplateArgs,
13074 bool IsAddressOfFunction = false);
13075
13076 /// Substitute Replacement for \p auto in \p TypeWithAuto
13077 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
13078 /// Substitute Replacement for auto in TypeWithAuto
13080 QualType Replacement);
13081
13082 // Substitute auto in TypeWithAuto for a Dependent auto type
13084
13085 // Substitute auto in TypeWithAuto for a Dependent auto type
13088
13089 /// Completely replace the \c auto in \p TypeWithAuto by
13090 /// \p Replacement. This does not retain any \c auto type sugar.
13091 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
13093 QualType Replacement);
13094
13095 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
13096 ///
13097 /// Note that this is done even if the initializer is dependent. (This is
13098 /// necessary to support partial ordering of templates using 'auto'.)
13099 /// A dependent type will be produced when deducing from a dependent type.
13100 ///
13101 /// \param Type the type pattern using the auto type-specifier.
13102 /// \param Init the initializer for the variable whose type is to be deduced.
13103 /// \param Result if type deduction was successful, this will be set to the
13104 /// deduced type.
13105 /// \param Info the argument will be updated to provide additional information
13106 /// about template argument deduction.
13107 /// \param DependentDeduction Set if we should permit deduction in
13108 /// dependent cases. This is necessary for template partial ordering
13109 /// with 'auto' template parameters. The template parameter depth to be
13110 /// used should be specified in the 'Info' parameter.
13111 /// \param IgnoreConstraints Set if we should not fail if the deduced type
13112 /// does not satisfy the type-constraint in the auto
13113 /// type.
13117 bool DependentDeduction = false,
13118 bool IgnoreConstraints = false,
13119 TemplateSpecCandidateSet *FailedTSC = nullptr);
13120 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
13122 bool Diagnose = true);
13123
13125 SourceLocation Loc);
13126
13127 /// Returns the more specialized class template partial specialization
13128 /// according to the rules of partial ordering of class template partial
13129 /// specializations (C++ [temp.class.order]).
13130 ///
13131 /// \param PS1 the first class template partial specialization
13132 ///
13133 /// \param PS2 the second class template partial specialization
13134 ///
13135 /// \returns the more specialized class template partial specialization. If
13136 /// neither partial specialization is more specialized, returns NULL.
13141
13144
13148
13151
13153 TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
13154 const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
13155 bool PartialOrdering, bool *StrictPackMatch);
13156
13157 /// Determine the declared type of the constant template parameter that \p Arg
13158 /// names, if any.
13159 static QualType
13161
13162 /// Mark which template parameters are used in a given expression.
13163 ///
13164 /// \param E the expression from which template parameters will be deduced.
13165 ///
13166 /// \param Used a bit vector whose elements will be set to \c true
13167 /// to indicate when the corresponding template parameter will be
13168 /// deduced.
13169 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
13170 unsigned Depth, llvm::SmallBitVector &Used);
13171
13172 /// Mark which template parameters are named in a given expression.
13173 ///
13174 /// Unlike MarkUsedTemplateParameters, this excludes parameter that
13175 /// are used but not directly named by an expression - i.e. it excludes
13176 /// any template parameter that denotes the type of a referenced NTTP.
13177 ///
13178 /// \param Used a bit vector whose elements will be set to \c true
13179 /// to indicate when the corresponding template parameter will be
13180 /// deduced.
13182 const Expr *E, unsigned Depth, llvm::SmallBitVector &Used);
13183
13184 /// Mark which template parameters can be deduced from a given
13185 /// template argument list.
13186 ///
13187 /// \param TemplateArgs the template argument list from which template
13188 /// parameters will be deduced.
13189 ///
13190 /// \param Used a bit vector whose elements will be set to \c true
13191 /// to indicate when the corresponding template parameter will be
13192 /// deduced.
13193 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
13194 bool OnlyDeduced, unsigned Depth,
13195 llvm::SmallBitVector &Used);
13196
13198 bool OnlyDeduced, unsigned Depth,
13199 llvm::SmallBitVector &Used);
13200
13202 unsigned Depth, llvm::SmallBitVector &Used);
13203
13204 void
13209
13210 /// Marks all of the template parameters that will be deduced by a
13211 /// call to the given function template.
13212 static void
13215 llvm::SmallBitVector &Deduced);
13216
13217 /// Returns the more specialized function template according
13218 /// to the rules of function template partial ordering (C++
13219 /// [temp.func.order]).
13220 ///
13221 /// \param FT1 the first function template
13222 ///
13223 /// \param FT2 the second function template
13224 ///
13225 /// \param TPOC the context in which we are performing partial ordering of
13226 /// function templates.
13227 ///
13228 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
13229 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
13230 /// when calling a member function.
13231 ///
13232 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
13233 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
13234 /// template from a member function
13235 ///
13236 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
13237 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
13238 /// template from a member function
13239 ///
13240 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
13241 /// candidate with a reversed parameter order. In this case, the corresponding
13242 /// P/A pairs between FT1 and FT2 are reversed.
13243 ///
13244 /// \returns the more specialized function template. If neither
13245 /// template is more specialized, returns NULL.
13248 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
13249 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false,
13250 bool PartialOverloading = false);
13251
13252 /// Retrieve the most specialized of the given function template
13253 /// specializations.
13254 ///
13255 /// \param SpecBegin the start iterator of the function template
13256 /// specializations that we will be comparing.
13257 ///
13258 /// \param SpecEnd the end iterator of the function template
13259 /// specializations, paired with \p SpecBegin.
13260 ///
13261 /// \param Loc the location where the ambiguity or no-specializations
13262 /// diagnostic should occur.
13263 ///
13264 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
13265 /// no matching candidates.
13266 ///
13267 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
13268 /// occurs.
13269 ///
13270 /// \param CandidateDiag partial diagnostic used for each function template
13271 /// specialization that is a candidate in the ambiguous ordering. One
13272 /// parameter in this diagnostic should be unbound, which will correspond to
13273 /// the string describing the template arguments for the function template
13274 /// specialization.
13275 ///
13276 /// \returns the most specialized function template specialization, if
13277 /// found. Otherwise, returns SpecEnd.
13278 UnresolvedSetIterator
13279 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
13280 TemplateSpecCandidateSet &FailedCandidates,
13281 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
13282 const PartialDiagnostic &AmbigDiag,
13283 const PartialDiagnostic &CandidateDiag,
13284 bool Complain = true, QualType TargetType = QualType());
13285
13286 /// Returns the more constrained function according to the rules of
13287 /// partial ordering by constraints (C++ [temp.constr.order]).
13288 ///
13289 /// \param FD1 the first function
13290 ///
13291 /// \param FD2 the second function
13292 ///
13293 /// \returns the more constrained function. If neither function is
13294 /// more constrained, returns NULL.
13295 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
13296 FunctionDecl *FD2);
13297
13298 ///@}
13299
13300 //
13301 //
13302 // -------------------------------------------------------------------------
13303 //
13304 //
13305
13306 /// \name C++ Template Deduction Guide
13307 /// Implementations are in SemaTemplateDeductionGuide.cpp
13308 ///@{
13309
13310 /// Declare implicit deduction guides for a class template if we've
13311 /// not already done so.
13312 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
13313 SourceLocation Loc);
13314
13315 CXXDeductionGuideDecl *DeclareAggregateDeductionGuideFromInitList(
13316 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
13317 SourceLocation Loc);
13318
13319 ///@}
13320
13321 //
13322 //
13323 // -------------------------------------------------------------------------
13324 //
13325 //
13326
13327 /// \name C++ Template Instantiation
13328 /// Implementations are in SemaTemplateInstantiate.cpp
13329 ///@{
13330
13331public:
13332 /// A helper class for building up ExtParameterInfos.
13335 bool HasInteresting = false;
13336
13337 public:
13338 /// Set the ExtParameterInfo for the parameter at the given index,
13339 ///
13341 assert(Infos.size() <= index);
13342 Infos.resize(index);
13343 Infos.push_back(info);
13344
13345 if (!HasInteresting)
13346 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
13347 }
13348
13349 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
13350 /// ExtParameterInfo array we've built up.
13352 getPointerOrNull(unsigned numParams) {
13353 if (!HasInteresting)
13354 return nullptr;
13355 Infos.resize(numParams);
13356 return Infos.data();
13357 }
13358 };
13359
13360 /// The current instantiation scope used to store local
13361 /// variables.
13363
13364 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
13366
13367 /// A mapping from parameters with unparsed default arguments to the
13368 /// set of instantiations of each parameter.
13369 ///
13370 /// This mapping is a temporary data structure used when parsing
13371 /// nested class templates or nested classes of class templates,
13372 /// where we might end up instantiating an inner class before the
13373 /// default arguments of its methods have been parsed.
13375
13376 using InstantiatingSpecializationsKey = llvm::PointerIntPair<Decl *, 2>;
13377
13384
13386 : S(S), Key(D->getCanonicalDecl(), unsigned(Kind)) {
13387 auto [_, Created] = S.InstantiatingSpecializations.insert(Key);
13388 if (!Created)
13389 Key = {};
13390 }
13391
13393 if (Key.getOpaqueValue()) {
13394 [[maybe_unused]] bool Erased =
13395 S.InstantiatingSpecializations.erase(Key);
13396 assert(Erased);
13397 }
13398 }
13399
13402
13403 operator bool() const { return Key.getOpaqueValue() == nullptr; }
13404
13405 private:
13406 Sema &S;
13408 };
13409
13410 /// A context in which code is being synthesized (where a source location
13411 /// alone is not sufficient to identify the context). This covers template
13412 /// instantiation and various forms of implicitly-generated functions.
13414 /// The kind of template instantiation we are performing
13416 /// We are instantiating a template declaration. The entity is
13417 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
13419
13420 /// We are instantiating a default argument for a template
13421 /// parameter. The Entity is the template parameter whose argument is
13422 /// being instantiated, the Template is the template, and the
13423 /// TemplateArgs/NumTemplateArguments provide the template arguments as
13424 /// specified.
13426
13427 /// We are instantiating a default argument for a function.
13428 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
13429 /// provides the template arguments as specified.
13431
13432 /// We are substituting explicit template arguments provided for
13433 /// a function template. The entity is a FunctionTemplateDecl.
13435
13436 /// We are substituting template argument determined as part of
13437 /// template argument deduction for either a class template
13438 /// partial specialization or a function template. The
13439 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
13440 /// a TemplateDecl.
13442
13443 /// We are substituting into a lambda expression.
13445
13446 /// We are substituting prior template arguments into a new
13447 /// template parameter. The template parameter itself is either a
13448 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
13450
13451 /// We are checking the validity of a default template argument that
13452 /// has been used when naming a template-id.
13454
13455 /// We are computing the exception specification for a defaulted special
13456 /// member function.
13458
13459 /// We are instantiating the exception specification for a function
13460 /// template which was deferred until it was needed.
13462
13463 /// We are instantiating a requirement of a requires expression.
13465
13466 /// We are checking the satisfaction of a nested requirement of a requires
13467 /// expression.
13469
13470 /// We are declaring an implicit special member function.
13472
13473 /// We are declaring an implicit 'operator==' for a defaulted
13474 /// 'operator<=>'.
13476
13477 /// We are defining a synthesized function (such as a defaulted special
13478 /// member).
13480
13481 // We are checking the constraints associated with a constrained entity or
13482 // the constraint expression of a concept. This includes the checks that
13483 // atomic constraints have the type 'bool' and that they can be constant
13484 // evaluated.
13486
13487 // We are substituting template arguments into a constraint expression.
13489
13490 // Instantiating a Requires Expression parameter clause.
13492
13493 // We are substituting into the parameter mapping of an atomic constraint
13494 // during normalization.
13496
13497 /// We are rewriting a comparison operator in terms of an operator<=>.
13499
13500 /// We are initializing a structured binding.
13502
13503 /// We are marking a class as __dllexport.
13505
13506 /// We are building an implied call from __builtin_dump_struct. The
13507 /// arguments are in CallArgs.
13509
13510 /// Added for Template instantiation observation.
13511 /// Memoization means we are _not_ instantiating a template because
13512 /// it is already instantiated (but we entered a context where we
13513 /// would have had to if it was not already instantiated).
13515
13516 /// We are building deduction guides for a class.
13518
13519 /// We are instantiating a type alias template declaration.
13521
13522 /// We are performing partial ordering for template template parameters.
13524
13525 /// We are performing name lookup for a function template or variable
13526 /// template named 'sycl_kernel_launch'.
13528
13529 /// We are performing overload resolution for a call to a function
13530 /// template or variable template named 'sycl_kernel_launch'.
13532
13533 /// We are instantiating an expansion statement.
13535 } Kind;
13536
13537 /// Whether we're substituting into constraints.
13539
13540 /// Whether we're substituting into the parameter mapping of a constraint.
13542
13543 /// The point of instantiation or synthesis within the source code.
13545
13546 /// The entity that is being synthesized.
13548
13549 /// The template (or partial specialization) in which we are
13550 /// performing the instantiation, for substitutions of prior template
13551 /// arguments.
13553
13554 union {
13555 /// The list of template arguments we are substituting, if they
13556 /// are not part of the entity.
13558
13559 /// The list of argument expressions in a synthesized call.
13560 const Expr *const *CallArgs;
13561 };
13562
13563 // FIXME: Wrap this union around more members, or perhaps store the
13564 // kind-specific members in the RAII object owning the context.
13565 union {
13566 /// The number of template arguments in TemplateArgs.
13568
13569 /// The number of expressions in CallArgs.
13570 unsigned NumCallArgs;
13571
13572 /// The special member being declared or defined.
13574 };
13575
13580
13581 /// The source range that covers the construct that cause
13582 /// the instantiation, e.g., the template-id that causes a class
13583 /// template instantiation.
13585
13590
13591 /// Determines whether this template is an actual instantiation
13592 /// that should be counted toward the maximum instantiation depth.
13593 bool isInstantiationRecord() const;
13594 };
13595
13596 /// A stack object to be created when performing template
13597 /// instantiation.
13598 ///
13599 /// Construction of an object of type \c InstantiatingTemplate
13600 /// pushes the current instantiation onto the stack of active
13601 /// instantiations. If the size of this stack exceeds the maximum
13602 /// number of recursive template instantiations, construction
13603 /// produces an error and evaluates true.
13604 ///
13605 /// Destruction of this object will pop the named instantiation off
13606 /// the stack.
13608 /// Note that we are instantiating a class template,
13609 /// function template, variable template, alias template,
13610 /// or a member thereof.
13611 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13612 Decl *Entity,
13613 SourceRange InstantiationRange = SourceRange());
13614
13616 /// Note that we are instantiating an exception specification
13617 /// of a function template.
13618 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13620 SourceRange InstantiationRange = SourceRange());
13621
13622 /// Note that we are instantiating a type alias template declaration.
13623 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13624 TypeAliasTemplateDecl *Entity,
13625 ArrayRef<TemplateArgument> TemplateArgs,
13626 SourceRange InstantiationRange = SourceRange());
13627
13628 /// Note that we are instantiating a default argument in a
13629 /// template-id.
13630 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13632 ArrayRef<TemplateArgument> TemplateArgs,
13633 SourceRange InstantiationRange = SourceRange());
13634
13635 /// Note that we are substituting either explicitly-specified or
13636 /// deduced template arguments during function template argument deduction.
13637 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13639 ArrayRef<TemplateArgument> TemplateArgs,
13641 SourceRange InstantiationRange = SourceRange());
13642
13643 /// Note that we are instantiating as part of template
13644 /// argument deduction for a class template declaration.
13645 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13647 ArrayRef<TemplateArgument> TemplateArgs,
13648 SourceRange InstantiationRange = SourceRange());
13649
13650 /// Note that we are instantiating as part of template
13651 /// argument deduction for a class template partial
13652 /// specialization.
13653 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13655 ArrayRef<TemplateArgument> TemplateArgs,
13656 SourceRange InstantiationRange = SourceRange());
13657
13658 /// Note that we are instantiating as part of template
13659 /// argument deduction for a variable template partial
13660 /// specialization.
13661 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13663 ArrayRef<TemplateArgument> TemplateArgs,
13664 SourceRange InstantiationRange = SourceRange());
13665
13666 /// Note that we are instantiating a default argument for a function
13667 /// parameter.
13668 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13669 ParmVarDecl *Param,
13670 ArrayRef<TemplateArgument> TemplateArgs,
13671 SourceRange InstantiationRange = SourceRange());
13672
13673 /// Note that we are substituting prior template arguments into a
13674 /// non-type parameter.
13675 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13677 ArrayRef<TemplateArgument> TemplateArgs,
13678 SourceRange InstantiationRange);
13679
13680 /// Note that we are substituting prior template arguments into a
13681 /// template template parameter.
13682 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13684 ArrayRef<TemplateArgument> TemplateArgs,
13685 SourceRange InstantiationRange);
13686
13687 /// Note that we are checking the default template argument
13688 /// against the template parameter for a given template-id.
13689 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13691 ArrayRef<TemplateArgument> TemplateArgs,
13692 SourceRange InstantiationRange);
13693
13695 /// \brief Note that we are checking the constraints associated with some
13696 /// constrained entity (a concept declaration or a template with associated
13697 /// constraints).
13698 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13700 ArrayRef<TemplateArgument> TemplateArgs,
13701 SourceRange InstantiationRange);
13702
13704 /// \brief Note that we are checking a constraint expression associated
13705 /// with a template declaration or as part of the satisfaction check of a
13706 /// concept.
13707 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13709 SourceRange InstantiationRange);
13710
13712 /// \brief Note that we are subtituting into the parameter mapping of an
13713 /// atomic constraint during constraint normalization.
13714 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13716 SourceRange InstantiationRange);
13717
13718 /// \brief Note that we are substituting template arguments into a part of
13719 /// a requirement of a requires expression.
13720 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13722 SourceRange InstantiationRange = SourceRange());
13723
13724 /// \brief Note that we are substituting the body of an expansion statement.
13725 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13726 CXXExpansionStmtPattern *ExpansionStmt,
13728 SourceRange InstantiationRange);
13729
13730 /// \brief Note that we are checking the satisfaction of the constraint
13731 /// expression inside of a nested requirement.
13732 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13734 SourceRange InstantiationRange = SourceRange());
13735
13736 /// \brief Note that we are checking a requires clause.
13737 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13738 const RequiresExpr *E,
13739 SourceRange InstantiationRange);
13740
13742 /// \brief Note that we are building deduction guides.
13743 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13745 SourceRange InstantiationRange = SourceRange());
13746
13748 /// \brief Note that we are partial ordering template template parameters.
13749 InstantiatingTemplate(Sema &SemaRef, SourceLocation ArgLoc,
13751 SourceRange InstantiationRange = SourceRange());
13752
13753 /// Note that we have finished instantiating this template.
13754 void Clear();
13755
13757
13758 /// Determines whether we have exceeded the maximum
13759 /// recursive template instantiations.
13760 bool isInvalid() const { return Invalid; }
13761
13762 private:
13763 Sema &SemaRef;
13764 bool Invalid;
13765
13768 SourceLocation PointOfInstantiation,
13769 SourceRange InstantiationRange, Decl *Entity,
13770 NamedDecl *Template = nullptr,
13771 ArrayRef<TemplateArgument> TemplateArgs = {});
13772
13774
13775 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13776 };
13777
13778 bool SubstTemplateArgument(const TemplateArgumentLoc &Input,
13779 const MultiLevelTemplateArgumentList &TemplateArgs,
13780 TemplateArgumentLoc &Output,
13781 SourceLocation Loc = {},
13782 const DeclarationName &Entity = {});
13783 bool
13784 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13785 const MultiLevelTemplateArgumentList &TemplateArgs,
13786 TemplateArgumentListInfo &Outputs);
13787
13788 /// Substitute concept template arguments in the constraint expression
13789 /// of a concept-id. This is used to implement [temp.constr.normal].
13791 SubstConceptTemplateArguments(const ConceptSpecializationExpr *CSE,
13792 const Expr *ConstraintExpr,
13793 const MultiLevelTemplateArgumentList &MLTAL);
13794
13796 ArrayRef<TemplateArgumentLoc> Args, SourceLocation BaseLoc,
13797 const MultiLevelTemplateArgumentList &TemplateArgs,
13798 TemplateArgumentListInfo &Out);
13799
13800 /// Retrieve the template argument list(s) that should be used to
13801 /// instantiate the definition of the given declaration.
13802 ///
13803 /// \param ND the declaration for which we are computing template
13804 /// instantiation arguments.
13805 ///
13806 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13807 /// the decl context where it will be created. In this case, the `Innermost`
13808 /// should likely be provided. If ND is non-null, this is ignored.
13809 ///
13810 /// \param Innermost if non-NULL, specifies a template argument list for the
13811 /// template declaration passed as ND.
13812 ///
13813 /// \param RelativeToPrimary true if we should get the template
13814 /// arguments relative to the primary template, even when we're
13815 /// dealing with a specialization. This is only relevant for function
13816 /// template specializations.
13817 ///
13818 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13819 /// instantiating the definition of the given declaration, \p ND. This is
13820 /// used to determine the proper set of template instantiation arguments for
13821 /// friend function template specializations.
13822 ///
13823 /// \param ForConstraintInstantiation when collecting arguments,
13824 /// ForConstraintInstantiation indicates we should continue looking when
13825 /// encountering a lambda generic call operator, and continue looking for
13826 /// arguments on an enclosing class template.
13827 ///
13828 /// \param SkipForSpecialization when specified, any template specializations
13829 /// in a traversal would be ignored.
13830 ///
13831 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13832 /// when encountering a specialized member function template, rather than
13833 /// returning immediately.
13834 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13835 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13836 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13837 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13838 bool ForConstraintInstantiation = false,
13839 bool SkipForSpecialization = false,
13840 bool ForDefaultArgumentSubstitution = false);
13841
13842 /// RAII object to handle the state changes required to synthesize
13843 /// a function body.
13845 Sema &S;
13846 Sema::ContextRAII SavedContext;
13847 bool PushedCodeSynthesisContext = false;
13848
13849 public:
13851 : S(S), SavedContext(S, DC) {
13852 auto *FD = dyn_cast<FunctionDecl>(DC);
13853 S.PushFunctionScope();
13854 S.PushExpressionEvaluationContextForFunction(
13856 if (FD)
13857 FD->setWillHaveBody(true);
13858 else
13859 assert(isa<ObjCMethodDecl>(DC));
13860 }
13861
13863 assert(!PushedCodeSynthesisContext);
13864
13867 Ctx.PointOfInstantiation = UseLoc;
13868 Ctx.Entity = cast<Decl>(S.CurContext);
13869 S.pushCodeSynthesisContext(Ctx);
13870
13871 PushedCodeSynthesisContext = true;
13872 }
13873
13875 if (PushedCodeSynthesisContext)
13876 S.popCodeSynthesisContext();
13877 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13878 FD->setWillHaveBody(false);
13879 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13880 }
13881 S.PopExpressionEvaluationContext();
13882 S.PopFunctionScopeInfo();
13883 }
13884
13888 };
13889
13890 /// RAII object to ensure that a code synthesis context is popped on scope
13891 /// exit.
13893 Sema &S;
13894
13895 public:
13897 : S(S) {
13898 S.pushCodeSynthesisContext(Ctx);
13899 }
13900
13901 ~ScopedCodeSynthesisContext() { S.popCodeSynthesisContext(); }
13905 };
13906
13907 /// List of active code synthesis contexts.
13908 ///
13909 /// This vector is treated as a stack. As synthesis of one entity requires
13910 /// synthesis of another, additional contexts are pushed onto the stack.
13912
13913 /// Specializations whose definitions are currently being instantiated.
13914 llvm::DenseSet<InstantiatingSpecializationsKey> InstantiatingSpecializations;
13915
13916 /// Non-dependent types used in templates that have already been instantiated
13917 /// by some template instantiation.
13918 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13919
13920 /// Extra modules inspected when performing a lookup during a template
13921 /// instantiation. Computed lazily.
13923
13924 /// Cache of additional modules that should be used for name lookup
13925 /// within the current template instantiation. Computed lazily; use
13926 /// getLookupModules() to get a complete set.
13927 llvm::DenseSet<Module *> LookupModulesCache;
13928
13929 /// Map from the most recent declaration of a namespace to the most
13930 /// recent visible declaration of that namespace.
13931 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13932
13934
13935 /// The number of \p CodeSynthesisContexts that are not template
13936 /// instantiations and, therefore, should not be counted as part of the
13937 /// instantiation depth.
13938 ///
13939 /// When the instantiation depth reaches the user-configurable limit
13940 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13941 // FIXME: Should we have a similar limit for other forms of synthesis?
13943
13944 /// The depth of the context stack at the point when the most recent
13945 /// error or warning was produced.
13946 ///
13947 /// This value is used to suppress printing of redundant context stacks
13948 /// when there are multiple errors or warnings in the same instantiation.
13949 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13951
13952 /// The current index into pack expansion arguments that will be
13953 /// used for substitution of parameter packs.
13954 ///
13955 /// The pack expansion index will be none to indicate that parameter packs
13956 /// should be instantiated as themselves. Otherwise, the index specifies
13957 /// which argument within the parameter pack will be used for substitution.
13959
13960 /// RAII object used to change the argument pack substitution index
13961 /// within a \c Sema object.
13962 ///
13963 /// See \c ArgPackSubstIndex for more information.
13965 Sema &Self;
13966 UnsignedOrNone OldSubstIndex;
13967
13968 public:
13970 : Self(Self),
13971 OldSubstIndex(std::exchange(Self.ArgPackSubstIndex, NewSubstIndex)) {}
13972
13973 ~ArgPackSubstIndexRAII() { Self.ArgPackSubstIndex = OldSubstIndex; }
13976 };
13977
13980
13991 /// Prints the current instantiation stack through a series of
13992 /// notes.
13997
13998 /// Returns a pointer to the current SFINAE context, if any.
13999 [[nodiscard]] SFINAETrap *getSFINAEContext() const {
14000 return CurrentSFINAEContext;
14001 }
14002 [[nodiscard]] bool isSFINAEContext() const {
14003 return CurrentSFINAEContext != nullptr;
14004 }
14005
14006 /// Perform substitution on the type T with a given set of template
14007 /// arguments.
14008 ///
14009 /// This routine substitutes the given template arguments into the
14010 /// type T and produces the instantiated type.
14011 ///
14012 /// \param T the type into which the template arguments will be
14013 /// substituted. If this type is not dependent, it will be returned
14014 /// immediately.
14015 ///
14016 /// \param Args the template arguments that will be
14017 /// substituted for the top-level template parameters within T.
14018 ///
14019 /// \param Loc the location in the source code where this substitution
14020 /// is being performed. It will typically be the location of the
14021 /// declarator (if we're instantiating the type of some declaration)
14022 /// or the location of the type in the source code (if, e.g., we're
14023 /// instantiating the type of a cast expression).
14024 ///
14025 /// \param Entity the name of the entity associated with a declaration
14026 /// being instantiated (if any). May be empty to indicate that there
14027 /// is no such entity (if, e.g., this is a type that occurs as part of
14028 /// a cast expression) or that the entity has no name (e.g., an
14029 /// unnamed function parameter).
14030 ///
14031 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
14032 /// acceptable as the top level type of the result.
14033 ///
14034 /// \param IsIncompleteSubstitution If provided, the pointee will be set
14035 /// whenever substitution would perform a replacement with a null or
14036 /// non-existent template argument.
14037 ///
14038 /// \returns If the instantiation succeeds, the instantiated
14039 /// type. Otherwise, produces diagnostics and returns a NULL type.
14041 const MultiLevelTemplateArgumentList &TemplateArgs,
14042 SourceLocation Loc, DeclarationName Entity,
14043 bool AllowDeducedTST = false);
14044
14046 const MultiLevelTemplateArgumentList &TemplateArgs,
14047 SourceLocation Loc, DeclarationName Entity,
14048 bool *IsIncompleteSubstitution = nullptr);
14049
14051 const MultiLevelTemplateArgumentList &TemplateArgs,
14052 SourceLocation Loc, DeclarationName Entity);
14053
14056 const MultiLevelTemplateArgumentList &TemplateArgs,
14057 SourceLocation Loc, DeclarationName Entity);
14058
14060 const MultiLevelTemplateArgumentList &Args);
14063 SmallVectorImpl<QualType> &ExceptionStorage,
14064 const MultiLevelTemplateArgumentList &Args);
14065 /// An attribute whose instantiation is deferred, together with the
14066 /// instantiation scope to instantiate it in.
14077
14078 /// A form of SubstType intended specifically for instantiating the
14079 /// type of a FunctionDecl. Its purpose is solely to force the
14080 /// instantiation of default-argument expressions and to avoid
14081 /// instantiating an exception-specification.
14082 ///
14083 /// If \p ParamAttrs is not null, the late-parsed attributes of the parameters
14084 /// of \p Fn are deferred to it, to be instantiated later.
14086 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
14087 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
14088 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true,
14089 const FunctionDecl *Fn = nullptr,
14090 LateInstantiatedAttrVec *ParamAttrs = nullptr);
14091
14092 /// Substitute into a function parameter. If \p LateAttrs is given, its
14093 /// late-parsed attributes are deferred there, since they may name a
14094 /// parameter that is not substituted yet; see \ref InstantiateLateAttrs.
14095 ParmVarDecl *
14097 const MultiLevelTemplateArgumentList &TemplateArgs,
14098 int indexAdjustment, UnsignedOrNone NumExpansions,
14099 bool ExpectParameterPack, bool EvaluateConstraints = true,
14100 LateInstantiatedAttrVec *LateAttrs = nullptr);
14101
14102 /// Substitute the given template arguments into the given set of
14103 /// parameters, producing the set of parameter types that would be generated
14104 /// from such a substitution. If there is a parameter with no ParmVarDecl to
14105 /// substitute (a null entry of \p Params, as from a typedef'd function
14106 /// type), its type needs to come from \p OldParamTypes instead, which must
14107 /// then be passed, and \p OutParams gets null for it.
14108 ///
14109 /// If \p ParamAttrs is not null, the late-parsed attributes of the parameters
14110 /// of \p Fn are deferred to it, as for SubstFunctionDeclType.
14112 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
14113 const MultiLevelTemplateArgumentList &TemplateArgs,
14114 SmallVectorImpl<QualType> &ParamTypes,
14116 ExtParameterInfoBuilder &ParamInfos,
14117 const QualType *OldParamTypes = nullptr,
14118 bool EvaluateConstraints = true,
14119 const FunctionDecl *Fn = nullptr,
14120 LateInstantiatedAttrVec *ParamAttrs = nullptr);
14121
14122 /// Substitute the given template arguments into the default argument.
14124 const MultiLevelTemplateArgumentList &TemplateArgs,
14125 bool ForCallExpr = false);
14127 const MultiLevelTemplateArgumentList &TemplateArgs);
14128 /// Substitute an expression as if it is a address-of-operand, which makes it
14129 /// act like a CXXIdExpression rather than an attempt to call.
14131 const MultiLevelTemplateArgumentList &TemplateArgs);
14132
14133 // Must be used instead of SubstExpr at 'constraint checking' time.
14136 const MultiLevelTemplateArgumentList &TemplateArgs);
14137 // Unlike the above, this does not evaluate constraints.
14139 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
14140
14141 /// Substitute the given template arguments into a list of
14142 /// expressions, expanding pack expansions if required.
14143 ///
14144 /// \param Exprs The list of expressions to substitute into.
14145 ///
14146 /// \param IsCall Whether this is some form of call, in which case
14147 /// default arguments will be dropped.
14148 ///
14149 /// \param TemplateArgs The set of template arguments to substitute.
14150 ///
14151 /// \param Outputs Will receive all of the substituted arguments.
14152 ///
14153 /// \returns true if an error occurred, false otherwise.
14154 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
14155 const MultiLevelTemplateArgumentList &TemplateArgs,
14156 SmallVectorImpl<Expr *> &Outputs);
14157
14159 const MultiLevelTemplateArgumentList &TemplateArgs);
14160
14163 bool CXXDirectInit);
14164
14165 /// Perform substitution on the base class specifiers of the
14166 /// given class template specialization.
14167 ///
14168 /// Produces a diagnostic and returns true on error, returns false and
14169 /// attaches the instantiated base classes to the class template
14170 /// specialization if successful.
14171 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
14172 const MultiLevelTemplateArgumentList &TemplateArgs);
14173
14174 /// Instantiate the definition of a class from a given pattern.
14175 ///
14176 /// \param PointOfInstantiation The point of instantiation within the
14177 /// source code.
14178 ///
14179 /// \param Instantiation is the declaration whose definition is being
14180 /// instantiated. This will be either a class template specialization
14181 /// or a member class of a class template specialization.
14182 ///
14183 /// \param Pattern is the pattern from which the instantiation
14184 /// occurs. This will be either the declaration of a class template or
14185 /// the declaration of a member class of a class template.
14186 ///
14187 /// \param TemplateArgs The template arguments to be substituted into
14188 /// the pattern.
14189 ///
14190 /// \param TSK the kind of implicit or explicit instantiation to perform.
14191 ///
14192 /// \param Complain whether to complain if the class cannot be instantiated
14193 /// due to the lack of a definition.
14194 ///
14195 /// \returns true if an error occurred, false otherwise.
14196 bool InstantiateClass(SourceLocation PointOfInstantiation,
14197 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
14198 const MultiLevelTemplateArgumentList &TemplateArgs,
14199 TemplateSpecializationKind TSK, bool Complain = true);
14200
14201private:
14202 bool InstantiateClassImpl(SourceLocation PointOfInstantiation,
14203 CXXRecordDecl *Instantiation,
14204 CXXRecordDecl *Pattern,
14205 const MultiLevelTemplateArgumentList &TemplateArgs,
14206 TemplateSpecializationKind TSK, bool Complain);
14207
14208public:
14209 /// Instantiate the definition of an enum from a given pattern.
14210 ///
14211 /// \param PointOfInstantiation The point of instantiation within the
14212 /// source code.
14213 /// \param Instantiation is the declaration whose definition is being
14214 /// instantiated. This will be a member enumeration of a class
14215 /// temploid specialization, or a local enumeration within a
14216 /// function temploid specialization.
14217 /// \param Pattern The templated declaration from which the instantiation
14218 /// occurs.
14219 /// \param TemplateArgs The template arguments to be substituted into
14220 /// the pattern.
14221 /// \param TSK The kind of implicit or explicit instantiation to perform.
14222 ///
14223 /// \return \c true if an error occurred, \c false otherwise.
14224 bool InstantiateEnum(SourceLocation PointOfInstantiation,
14225 EnumDecl *Instantiation, EnumDecl *Pattern,
14226 const MultiLevelTemplateArgumentList &TemplateArgs,
14228
14229 /// Instantiate the definition of a field from the given pattern.
14230 ///
14231 /// \param PointOfInstantiation The point of instantiation within the
14232 /// source code.
14233 /// \param Instantiation is the declaration whose definition is being
14234 /// instantiated. This will be a class of a class temploid
14235 /// specialization, or a local enumeration within a function temploid
14236 /// specialization.
14237 /// \param Pattern The templated declaration from which the instantiation
14238 /// occurs.
14239 /// \param TemplateArgs The template arguments to be substituted into
14240 /// the pattern.
14241 ///
14242 /// \return \c true if an error occurred, \c false otherwise.
14244 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
14245 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
14246
14248 SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
14249
14251 SourceLocation PointOfInstantiation,
14252 ClassTemplateSpecializationDecl *ClassTemplateSpec,
14253 TemplateSpecializationKind TSK, bool Complain,
14254 bool PrimaryStrictPackMatch);
14255
14256 /// Instantiates the definitions of all of the member
14257 /// of the given class, which is an instantiation of a class template
14258 /// or a member class of a template.
14259 void
14260 InstantiateClassMembers(SourceLocation PointOfInstantiation,
14261 CXXRecordDecl *Instantiation,
14262 const MultiLevelTemplateArgumentList &TemplateArgs,
14264
14265 /// Instantiate the definitions of all of the members of the
14266 /// given class template specialization, which was named as part of an
14267 /// explicit instantiation.
14269 SourceLocation PointOfInstantiation,
14270 ClassTemplateSpecializationDecl *ClassTemplateSpec,
14272
14275 const MultiLevelTemplateArgumentList &TemplateArgs);
14276
14277 /// Do template substitution on declaration name info.
14280 const MultiLevelTemplateArgumentList &TemplateArgs);
14282 SubstTemplateName(SourceLocation TemplateKWLoc,
14283 NestedNameSpecifierLoc &QualifierLoc, TemplateName Name,
14284 SourceLocation NameLoc,
14285 const MultiLevelTemplateArgumentList &TemplateArgs);
14286
14288 const MultiLevelTemplateArgumentList &TemplateArgs,
14289 bool EvaluateConstraint);
14290
14291 /// Determine whether we are currently performing template instantiation.
14294 }
14295
14296 /// Determine whether we are currently performing constraint substitution.
14298 return !CodeSynthesisContexts.empty() &&
14299 CodeSynthesisContexts.back().InConstraintSubstitution;
14300 }
14301
14303 return !CodeSynthesisContexts.empty() &&
14304 CodeSynthesisContexts.back().InParameterMappingSubstitution &&
14306 }
14307
14308 using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
14309
14310 /// \brief create a Requirement::SubstitutionDiagnostic with only a
14311 /// SubstitutedEntity and DiagLoc using ASTContext's allocator.
14314
14315 ///@}
14316
14317 //
14318 //
14319 // -------------------------------------------------------------------------
14320 //
14321 //
14322
14323 /// \name C++ Template Declaration Instantiation
14324 /// Implementations are in SemaTemplateInstantiateDecl.cpp
14325 ///@{
14326
14327public:
14328 /// An entity for which implicit template instantiation is required.
14329 ///
14330 /// The source location associated with the declaration is the first place in
14331 /// the source code where the declaration was "used". It is not necessarily
14332 /// the point of instantiation (which will be either before or after the
14333 /// namespace-scope declaration that triggered this implicit instantiation),
14334 /// However, it is the location that diagnostics should generally refer to,
14335 /// because users will need to know what code triggered the instantiation.
14336 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
14337
14338 /// The queue of implicit template instantiations that are required
14339 /// but have not yet been performed.
14340 std::deque<PendingImplicitInstantiation> PendingInstantiations;
14341
14342 /// Queue of implicit template instantiations that cannot be performed
14343 /// eagerly.
14345
14349
14350 /// The queue of implicit template instantiations that are required
14351 /// and must be performed within the current local scope.
14352 ///
14353 /// This queue is only used for member functions of local classes in
14354 /// templates, which must be instantiated in the same scope as their
14355 /// enclosing function, so that they can reference function-local
14356 /// types, static variables, enumerators, etc.
14357 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
14358
14360 public:
14362 : S(S), AtEndOfTU(AtEndOfTU) {
14363 SavedPendingLocalImplicitInstantiations.swap(
14364 S.PendingLocalImplicitInstantiations);
14365 }
14366
14367 void perform() {
14368 S.PerformPendingInstantiations(/*LocalOnly=*/true,
14369 /*AtEndOfTU=*/AtEndOfTU);
14370 }
14371
14373 assert(S.PendingLocalImplicitInstantiations.empty() &&
14374 "there shouldn't be any pending local implicit instantiations");
14375 SavedPendingLocalImplicitInstantiations.swap(
14376 S.PendingLocalImplicitInstantiations);
14377 }
14378
14382
14383 private:
14384 Sema &S;
14385 bool AtEndOfTU;
14386 std::deque<PendingImplicitInstantiation>
14387 SavedPendingLocalImplicitInstantiations;
14388 };
14389
14390 /// Records and restores the CurFPFeatures state on entry/exit of compound
14391 /// statements.
14393 public:
14398 FPOptionsOverride getOverrides() { return OldOverrides; }
14399
14400 private:
14401 Sema &S;
14402 FPOptions OldFPFeaturesState;
14403 FPOptionsOverride OldOverrides;
14404 LangOptions::FPEvalMethodKind OldEvalMethod;
14405 SourceLocation OldFPPragmaLocation;
14406 };
14407
14409 public:
14410 GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
14411 : S(S), Enabled(Enabled), AtEndOfTU(AtEndOfTU) {
14412 if (!Enabled)
14413 return;
14414
14415 S.SavedPendingInstantiations.emplace_back();
14416 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
14417
14418 S.SavedVTableUses.emplace_back();
14419 S.SavedVTableUses.back().swap(S.VTableUses);
14420 }
14421
14422 void perform() {
14423 if (Enabled) {
14424 S.DefineUsedVTables();
14425 S.PerformPendingInstantiations(/*LocalOnly=*/false,
14426 /*AtEndOfTU=*/AtEndOfTU);
14427 }
14428 }
14429
14431 if (!Enabled)
14432 return;
14433
14434 // Restore the set of pending vtables.
14435 assert(S.VTableUses.empty() &&
14436 "VTableUses should be empty before it is discarded.");
14437 S.VTableUses.swap(S.SavedVTableUses.back());
14438 S.SavedVTableUses.pop_back();
14439
14440 // Restore the set of pending implicit instantiations.
14441 if ((S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) &&
14442 AtEndOfTU) {
14443 assert(S.PendingInstantiations.empty() &&
14444 "PendingInstantiations should be empty before it is discarded.");
14445 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
14446 S.SavedPendingInstantiations.pop_back();
14447 } else {
14448 // Template instantiations in the PCH may be delayed until the TU.
14449 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
14450 S.PendingInstantiations.insert(
14451 S.PendingInstantiations.end(),
14452 S.SavedPendingInstantiations.back().begin(),
14453 S.SavedPendingInstantiations.back().end());
14454 S.SavedPendingInstantiations.pop_back();
14455 }
14456 }
14457
14459 delete;
14462
14463 private:
14464 Sema &S;
14465 bool Enabled;
14466 bool AtEndOfTU;
14467 };
14468
14470 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
14471
14472 /// Recheck instantiated thread-safety attributes that could not be validated
14473 /// on the dependent pattern declaration.
14474 bool checkInstantiatedThreadSafetyAttrs(const Decl *D, const Attr *A);
14475
14476 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
14477 const Decl *Pattern, Decl *Inst,
14478 LateInstantiatedAttrVec *LateAttrs = nullptr,
14479 LocalInstantiationScope *OuterMostScope = nullptr);
14480
14481 /// Instantiate the attributes that \ref InstantiateAttrs deferred to \p
14482 /// LateAttrs, and attach them to their declarations. They are instantiated
14483 /// in the scopes saved with them, which extend \p OuterMostScope, the
14484 /// current scope.
14486 LateInstantiatedAttrVec &LateAttrs,
14487 LocalInstantiationScope *OuterMostScope);
14488
14489 /// Update instantiation attributes after template was late parsed.
14490 ///
14491 /// Some attributes are evaluated based on the body of template. If it is
14492 /// late parsed, such attributes cannot be evaluated when declaration is
14493 /// instantiated. This function is used to update instantiation attributes
14494 /// when template definition is ready.
14495 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
14496
14497 void
14499 const Decl *Pattern, Decl *Inst,
14500 LateInstantiatedAttrVec *LateAttrs = nullptr,
14501 LocalInstantiationScope *OuterMostScope = nullptr);
14502
14504 bool IsCopy = false);
14505
14507 ParmVarDecl *Param);
14508 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
14510
14511 /// Instantiate (or find existing instantiation of) a function template with a
14512 /// given set of template arguments.
14513 ///
14514 /// Usually this should not be used, and template argument deduction should be
14515 /// used in its place.
14518 SourceLocation Loc,
14521
14522 /// Instantiate the definition of the given function from its
14523 /// template.
14524 ///
14525 /// \param PointOfInstantiation the point at which the instantiation was
14526 /// required. Note that this is not precisely a "point of instantiation"
14527 /// for the function, but it's close.
14528 ///
14529 /// \param Function the already-instantiated declaration of a
14530 /// function template specialization or member function of a class template
14531 /// specialization.
14532 ///
14533 /// \param Recursive if true, recursively instantiates any functions that
14534 /// are required by this instantiation.
14535 ///
14536 /// \param DefinitionRequired if true, then we are performing an explicit
14537 /// instantiation where the body of the function is required. Complain if
14538 /// there is no such body.
14539 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
14541 bool Recursive = false,
14542 bool DefinitionRequired = false,
14543 bool AtEndOfTU = false);
14546 const TemplateArgumentList *PartialSpecArgs,
14548 SourceLocation PointOfInstantiation,
14549 LateInstantiatedAttrVec *LateAttrs = nullptr,
14550 LocalInstantiationScope *StartingScope = nullptr);
14551
14552 /// Instantiates a variable template specialization by completing it
14553 /// with appropriate type information and initializer.
14555 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
14556 const MultiLevelTemplateArgumentList &TemplateArgs);
14557
14558 /// BuildVariableInstantiation - Used after a new variable has been created.
14559 /// Sets basic variable data and decides whether to postpone the
14560 /// variable instantiation.
14561 void
14563 const MultiLevelTemplateArgumentList &TemplateArgs,
14564 LateInstantiatedAttrVec *LateAttrs,
14565 DeclContext *Owner,
14566 LocalInstantiationScope *StartingScope,
14567 bool InstantiatingVarTemplate = false,
14568 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
14569
14570 /// Instantiate the initializer of a variable.
14572 VarDecl *Var, VarDecl *OldVar,
14573 const MultiLevelTemplateArgumentList &TemplateArgs);
14574
14575 /// Instantiate the definition of the given variable from its
14576 /// template.
14577 ///
14578 /// \param PointOfInstantiation the point at which the instantiation was
14579 /// required. Note that this is not precisely a "point of instantiation"
14580 /// for the variable, but it's close.
14581 ///
14582 /// \param Var the already-instantiated declaration of a templated variable.
14583 ///
14584 /// \param Recursive if true, recursively instantiates any functions that
14585 /// are required by this instantiation.
14586 ///
14587 /// \param DefinitionRequired if true, then we are performing an explicit
14588 /// instantiation where a definition of the variable is required. Complain
14589 /// if there is no such definition.
14590 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
14591 VarDecl *Var, bool Recursive = false,
14592 bool DefinitionRequired = false,
14593 bool AtEndOfTU = false);
14594
14597 const MultiLevelTemplateArgumentList &TemplateArgs);
14598
14599 /// Find the instantiation of the given declaration within the
14600 /// current instantiation.
14601 ///
14602 /// This routine is intended to be used when \p D is a declaration
14603 /// referenced from within a template, that needs to mapped into the
14604 /// corresponding declaration within an instantiation. For example,
14605 /// given:
14606 ///
14607 /// \code
14608 /// template<typename T>
14609 /// struct X {
14610 /// enum Kind {
14611 /// KnownValue = sizeof(T)
14612 /// };
14613 ///
14614 /// bool getKind() const { return KnownValue; }
14615 /// };
14616 ///
14617 /// template struct X<int>;
14618 /// \endcode
14619 ///
14620 /// In the instantiation of X<int>::getKind(), we need to map the \p
14621 /// EnumConstantDecl for \p KnownValue (which refers to
14622 /// X<T>::<Kind>::KnownValue) to its instantiation
14623 /// (X<int>::<Kind>::KnownValue).
14624 /// \p FindInstantiatedDecl performs this mapping from within the
14625 /// instantiation of X<int>.
14626 NamedDecl *
14628 const MultiLevelTemplateArgumentList &TemplateArgs,
14629 bool FindingInstantiatedContext = false);
14630
14631 /// Finds the instantiation of the given declaration context
14632 /// within the current instantiation.
14633 ///
14634 /// \returns NULL if there was an error
14635 DeclContext *
14637 const MultiLevelTemplateArgumentList &TemplateArgs);
14638
14639 Decl *SubstDecl(Decl *D, DeclContext *Owner,
14640 const MultiLevelTemplateArgumentList &TemplateArgs);
14641
14642 /// Substitute the name and return type of a defaulted 'operator<=>' to form
14643 /// an implicit 'operator=='.
14645 FunctionDecl *Spaceship);
14646
14647 /// Performs template instantiation for all implicit template
14648 /// instantiations we have seen until this point.
14649 void PerformPendingInstantiations(bool LocalOnly = false,
14650 bool AtEndOfTU = true);
14651
14654 const MultiLevelTemplateArgumentList &TemplateArgs,
14655 bool EvaluateConstraints = true);
14656
14658 const DeclContext *Pattern,
14659 const MultiLevelTemplateArgumentList &TemplateArgs);
14660
14661private:
14662 /// Introduce the instantiated local variables into the local
14663 /// instantiation scope.
14664 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
14665 const FunctionDecl *PatternDecl,
14667 /// Introduce the instantiated function parameters into the local
14668 /// instantiation scope, and set the parameter names to those used
14669 /// in the template.
14670 bool addInstantiatedParametersToScope(
14671 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14673 const MultiLevelTemplateArgumentList &TemplateArgs);
14674
14675 /// Introduce the instantiated captures of the lambda into the local
14676 /// instantiation scope.
14677 bool addInstantiatedCapturesToScope(
14678 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14680 const MultiLevelTemplateArgumentList &TemplateArgs);
14681
14682 int ParsingClassDepth = 0;
14683
14684 class SavePendingParsedClassStateRAII {
14685 public:
14686 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
14687
14688 ~SavePendingParsedClassStateRAII() {
14689 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
14690 "there shouldn't be any pending delayed exception spec checks");
14691 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
14692 "there shouldn't be any pending delayed exception spec checks");
14693 swapSavedState();
14694 }
14695
14696 SavePendingParsedClassStateRAII(const SavePendingParsedClassStateRAII &) =
14697 delete;
14698 SavePendingParsedClassStateRAII &
14699 operator=(const SavePendingParsedClassStateRAII &) = delete;
14700
14701 private:
14702 Sema &S;
14704 SavedOverridingExceptionSpecChecks;
14706 SavedEquivalentExceptionSpecChecks;
14707
14708 void swapSavedState() {
14709 SavedOverridingExceptionSpecChecks.swap(
14710 S.DelayedOverridingExceptionSpecChecks);
14711 SavedEquivalentExceptionSpecChecks.swap(
14712 S.DelayedEquivalentExceptionSpecChecks);
14713 }
14714 };
14715
14716 ///@}
14717
14718 //
14719 //
14720 // -------------------------------------------------------------------------
14721 //
14722 //
14723
14724 /// \name C++ Variadic Templates
14725 /// Implementations are in SemaTemplateVariadic.cpp
14726 ///@{
14727
14728public:
14729 /// Determine whether an unexpanded parameter pack might be permitted in this
14730 /// location. Useful for error recovery.
14732
14733 /// The context in which an unexpanded parameter pack is
14734 /// being diagnosed.
14735 ///
14736 /// Note that the values of this enumeration line up with the first
14737 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
14739 /// An arbitrary expression.
14741
14742 /// The base type of a class type.
14744
14745 /// The type of an arbitrary declaration.
14747
14748 /// The type of a data member.
14750
14751 /// The size of a bit-field.
14753
14754 /// The expression in a static assertion.
14756
14757 /// The fixed underlying type of an enumeration.
14759
14760 /// The enumerator value.
14762
14763 /// A using declaration.
14765
14766 /// A friend declaration.
14768
14769 /// A declaration qualifier.
14771
14772 /// An initializer.
14774
14775 /// A default argument.
14777
14778 /// The type of a non-type template parameter.
14780
14781 /// The type of an exception.
14783
14784 /// Explicit specialization.
14786
14787 /// Partial specialization.
14789
14790 /// Microsoft __if_exists.
14792
14793 /// Microsoft __if_not_exists.
14795
14796 /// Lambda expression.
14798
14799 /// Block expression.
14801
14802 /// A type constraint.
14804
14805 // A requirement in a requires-expression.
14807
14808 // A requires-clause.
14810 };
14811
14812 /// Diagnose unexpanded parameter packs.
14813 ///
14814 /// \param Loc The location at which we should emit the diagnostic.
14815 ///
14816 /// \param UPPC The context in which we are diagnosing unexpanded
14817 /// parameter packs.
14818 ///
14819 /// \param Unexpanded the set of unexpanded parameter packs.
14820 ///
14821 /// \returns true if an error occurred, false otherwise.
14825
14826 /// If the given type contains an unexpanded parameter pack,
14827 /// diagnose the error.
14828 ///
14829 /// \param Loc The source location where a diagnostc should be emitted.
14830 ///
14831 /// \param T The type that is being checked for unexpanded parameter
14832 /// packs.
14833 ///
14834 /// \returns true if an error occurred, false otherwise.
14837
14838 /// If the given expression contains an unexpanded parameter
14839 /// pack, diagnose the error.
14840 ///
14841 /// \param E The expression that is being checked for unexpanded
14842 /// parameter packs.
14843 ///
14844 /// \returns true if an error occurred, false otherwise.
14847
14848 /// If the given requirees-expression contains an unexpanded reference to one
14849 /// of its own parameter packs, diagnose the error.
14850 ///
14851 /// \param RE The requiress-expression that is being checked for unexpanded
14852 /// parameter packs.
14853 ///
14854 /// \returns true if an error occurred, false otherwise.
14856
14857 /// If the given nested-name-specifier contains an unexpanded
14858 /// parameter pack, diagnose the error.
14859 ///
14860 /// \param SS The nested-name-specifier that is being checked for
14861 /// unexpanded parameter packs.
14862 ///
14863 /// \returns true if an error occurred, false otherwise.
14866
14867 /// If the given name contains an unexpanded parameter pack,
14868 /// diagnose the error.
14869 ///
14870 /// \param NameInfo The name (with source location information) that
14871 /// is being checked for unexpanded parameter packs.
14872 ///
14873 /// \returns true if an error occurred, false otherwise.
14876
14877 /// If the given template name contains an unexpanded parameter pack,
14878 /// diagnose the error.
14879 ///
14880 /// \param Loc The location of the template name.
14881 ///
14882 /// \param Template The template name that is being checked for unexpanded
14883 /// parameter packs.
14884 ///
14885 /// \returns true if an error occurred, false otherwise.
14889
14890 /// If the given template argument contains an unexpanded parameter
14891 /// pack, diagnose the error.
14892 ///
14893 /// \param Arg The template argument that is being checked for unexpanded
14894 /// parameter packs.
14895 ///
14896 /// \returns true if an error occurred, false otherwise.
14899
14900 /// Collect the set of unexpanded parameter packs within the given
14901 /// template argument.
14902 ///
14903 /// \param Arg The template argument that will be traversed to find
14904 /// unexpanded parameter packs.
14906 TemplateArgument Arg,
14908
14909 /// Collect the set of unexpanded parameter packs within the given
14910 /// template argument.
14911 ///
14912 /// \param Arg The template argument that will be traversed to find
14913 /// unexpanded parameter packs.
14917
14918 /// Collect the set of unexpanded parameter packs within the given
14919 /// type.
14920 ///
14921 /// \param T The type that will be traversed to find
14922 /// unexpanded parameter packs.
14925
14926 /// Collect the set of unexpanded parameter packs within the given
14927 /// template name.
14928 ///
14929 /// \param Template The template name that will be traversed to find
14930 /// unexpanded parameter packs.
14934
14935 /// Collect the set of unexpanded parameter packs within the given
14936 /// type.
14937 ///
14938 /// \param TL The type that will be traversed to find
14939 /// unexpanded parameter packs.
14942
14943 /// Collect the set of unexpanded parameter packs within the given
14944 /// nested-name-specifier.
14945 ///
14946 /// \param NNS The nested-name-specifier that will be traversed to find
14947 /// unexpanded parameter packs.
14951
14952 /// Collect the set of unexpanded parameter packs within the given
14953 /// name.
14954 ///
14955 /// \param NameInfo The name that will be traversed to find
14956 /// unexpanded parameter packs.
14958 const DeclarationNameInfo &NameInfo,
14960
14961 /// Collect the set of unexpanded parameter packs within the given
14962 /// expression.
14965
14966 /// Invoked when parsing a template argument.
14967 ///
14968 /// \param Arg the template argument, which may already be invalid.
14969 ///
14970 /// If it is followed by ellipsis, this function is called before
14971 /// `ActOnPackExpansion`.
14974
14975 /// Invoked when parsing a template argument followed by an
14976 /// ellipsis, which creates a pack expansion.
14977 ///
14978 /// \param Arg The template argument preceding the ellipsis, which
14979 /// may already be invalid.
14980 ///
14981 /// \param EllipsisLoc The location of the ellipsis.
14983 SourceLocation EllipsisLoc);
14984
14985 /// Invoked when parsing a type followed by an ellipsis, which
14986 /// creates a pack expansion.
14987 ///
14988 /// \param Type The type preceding the ellipsis, which will become
14989 /// the pattern of the pack expansion.
14990 ///
14991 /// \param EllipsisLoc The location of the ellipsis.
14993
14994 /// Construct a pack expansion type from the pattern of the pack
14995 /// expansion.
14997 SourceLocation EllipsisLoc,
14998 UnsignedOrNone NumExpansions);
14999
15000 /// Construct a pack expansion type from the pattern of the pack
15001 /// expansion.
15002 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
15003 SourceLocation EllipsisLoc,
15004 UnsignedOrNone NumExpansions);
15005
15006 /// Invoked when parsing an expression followed by an ellipsis, which
15007 /// creates a pack expansion.
15008 ///
15009 /// \param Pattern The expression preceding the ellipsis, which will become
15010 /// the pattern of the pack expansion.
15011 ///
15012 /// \param EllipsisLoc The location of the ellipsis.
15013 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
15014
15015 /// Invoked when parsing an expression followed by an ellipsis, which
15016 /// creates a pack expansion.
15017 ///
15018 /// \param Pattern The expression preceding the ellipsis, which will become
15019 /// the pattern of the pack expansion.
15020 ///
15021 /// \param EllipsisLoc The location of the ellipsis.
15022 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
15023 UnsignedOrNone NumExpansions);
15024
15025 /// Determine whether we could expand a pack expansion with the
15026 /// given set of parameter packs into separate arguments by repeatedly
15027 /// transforming the pattern.
15028 ///
15029 /// \param EllipsisLoc The location of the ellipsis that identifies the
15030 /// pack expansion.
15031 ///
15032 /// \param PatternRange The source range that covers the entire pattern of
15033 /// the pack expansion.
15034 ///
15035 /// \param Unexpanded The set of unexpanded parameter packs within the
15036 /// pattern.
15037 ///
15038 /// \param ShouldExpand Will be set to \c true if the transformer should
15039 /// expand the corresponding pack expansions into separate arguments. When
15040 /// set, \c NumExpansions must also be set.
15041 ///
15042 /// \param RetainExpansion Whether the caller should add an unexpanded
15043 /// pack expansion after all of the expanded arguments. This is used
15044 /// when extending explicitly-specified template argument packs per
15045 /// C++0x [temp.arg.explicit]p9.
15046 ///
15047 /// \param NumExpansions The number of separate arguments that will be in
15048 /// the expanded form of the corresponding pack expansion. This is both an
15049 /// input and an output parameter, which can be set by the caller if the
15050 /// number of expansions is known a priori (e.g., due to a prior substitution)
15051 /// and will be set by the callee when the number of expansions is known.
15052 /// The callee must set this value when \c ShouldExpand is \c true; it may
15053 /// set this value in other cases.
15054 ///
15055 /// \returns true if an error occurred (e.g., because the parameter packs
15056 /// are to be instantiated with arguments of different lengths), false
15057 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
15058 /// must be set.
15060 SourceLocation EllipsisLoc, SourceRange PatternRange,
15062 const MultiLevelTemplateArgumentList &TemplateArgs,
15063 bool FailOnPackProducingTemplates, bool &ShouldExpand,
15064 bool &RetainExpansion, UnsignedOrNone &NumExpansions,
15065 bool Diagnose = true);
15066
15067 /// Determine the number of arguments in the given pack expansion
15068 /// type.
15069 ///
15070 /// This routine assumes that the number of arguments in the expansion is
15071 /// consistent across all of the unexpanded parameter packs in its pattern.
15072 ///
15073 /// Returns an empty Optional if the type can't be expanded.
15075 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
15076
15079 const MultiLevelTemplateArgumentList &TemplateArgs);
15080
15081 /// Determine whether the given declarator contains any unexpanded
15082 /// parameter packs.
15083 ///
15084 /// This routine is used by the parser to disambiguate function declarators
15085 /// with an ellipsis prior to the ')', e.g.,
15086 ///
15087 /// \code
15088 /// void f(T...);
15089 /// \endcode
15090 ///
15091 /// To determine whether we have an (unnamed) function parameter pack or
15092 /// a variadic function.
15093 ///
15094 /// \returns true if the declarator contains any unexpanded parameter packs,
15095 /// false otherwise.
15097
15098 /// Returns the pattern of the pack expansion for a template argument.
15099 ///
15100 /// \param OrigLoc The template argument to expand.
15101 ///
15102 /// \param Ellipsis Will be set to the location of the ellipsis.
15103 ///
15104 /// \param NumExpansions Will be set to the number of expansions that will
15105 /// be generated from this pack expansion, if known a priori.
15108 SourceLocation &Ellipsis,
15109 UnsignedOrNone &NumExpansions) const;
15110
15111 /// Given a template argument that contains an unexpanded parameter pack, but
15112 /// which has already been substituted, attempt to determine the number of
15113 /// elements that will be produced once this argument is fully-expanded.
15114 ///
15115 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
15116 /// avoid actually expanding the pack where possible.
15118
15119 /// Called when an expression computing the size of a parameter pack
15120 /// is parsed.
15121 ///
15122 /// \code
15123 /// template<typename ...Types> struct count {
15124 /// static const unsigned value = sizeof...(Types);
15125 /// };
15126 /// \endcode
15127 ///
15128 //
15129 /// \param OpLoc The location of the "sizeof" keyword.
15130 /// \param Name The name of the parameter pack whose size will be determined.
15131 /// \param NameLoc The source location of the name of the parameter pack.
15132 /// \param RParenLoc The location of the closing parentheses.
15134 IdentifierInfo &Name,
15135 SourceLocation NameLoc,
15136 SourceLocation RParenLoc);
15137
15138 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
15139 SourceLocation EllipsisLoc,
15140 SourceLocation LSquareLoc, Expr *IndexExpr,
15141 SourceLocation RSquareLoc);
15142
15143 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
15144 SourceLocation EllipsisLoc, Expr *IndexExpr,
15145 SourceLocation RSquareLoc,
15146 ArrayRef<Expr *> ExpandedExprs = {},
15147 bool FullySubstituted = false);
15148
15150 SourceLocation NameLoc,
15151 Expr *IndexExpr);
15152
15154 BuildPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr,
15155 bool FullySubstituted = false,
15156 ArrayRef<TemplateName> Expansions = {});
15157
15160 SourceLocation NameLoc);
15161
15162 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
15163 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
15164 tok::TokenKind Operator,
15165 SourceLocation EllipsisLoc, Expr *RHS,
15166 SourceLocation RParenLoc);
15167 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
15168 SourceLocation LParenLoc, Expr *LHS,
15169 BinaryOperatorKind Operator,
15170 SourceLocation EllipsisLoc, Expr *RHS,
15171 SourceLocation RParenLoc,
15172 UnsignedOrNone NumExpansions);
15173 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
15174 BinaryOperatorKind Operator);
15175
15176 ///@}
15177
15178 //
15179 //
15180 // -------------------------------------------------------------------------
15181 //
15182 //
15183
15184 /// \name Constraints and Concepts
15185 /// Implementations are in SemaConcept.cpp
15186 ///@{
15187
15188public:
15189 ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, TypeSourceInfo *TSI);
15190
15191 ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc,
15192 TypeSourceInfo *TSI);
15193
15194public:
15196 const llvm::FoldingSetNodeID &ID) {
15197 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
15198 SatisfactionStack.emplace_back(Can, ID);
15199 }
15200
15201 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
15202
15204 const llvm::FoldingSetNodeID &ID) const {
15205 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
15206 return llvm::is_contained(SatisfactionStack,
15207 SatisfactionStackEntryTy{Can, ID});
15208 }
15209
15211 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
15212
15213 // Resets the current SatisfactionStack for cases where we are instantiating
15214 // constraints as a 'side effect' of normal instantiation in a way that is not
15215 // indicative of recursive definition.
15218 Sema &SemaRef;
15219
15220 public:
15222 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
15223 }
15224
15226 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
15227 }
15228
15232 };
15233
15236 SatisfactionStack.swap(NewSS);
15237 }
15238
15240 llvm::PointerUnion<const NamedDecl *,
15242
15243 /// Check whether the given expression is a valid constraint expression.
15244 /// A diagnostic is emitted if it is not, false is returned, and
15245 /// PossibleNonPrimary will be set to true if the failure might be due to a
15246 /// non-primary expression being used as an atomic constraint.
15247 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
15248 bool *PossibleNonPrimary = nullptr,
15249 bool IsTrailingRequiresClause = false);
15250
15251 /// \brief Check whether the given list of constraint expressions are
15252 /// satisfied (as if in a 'conjunction') given template arguments.
15253 /// \param Template the template-like entity that triggered the constraints
15254 /// check (either a concept or a constrained entity).
15255 /// \param ConstraintExprs a list of constraint expressions, treated as if
15256 /// they were 'AND'ed together.
15257 /// \param TemplateArgLists the list of template arguments to substitute into
15258 /// the constraint expression.
15259 /// \param TemplateIDRange The source range of the template id that
15260 /// caused the constraints check.
15261 /// \param Satisfaction if true is returned, will contain details of the
15262 /// satisfaction, with enough information to diagnose an unsatisfied
15263 /// expression.
15264 /// \returns true if an error occurred and satisfaction could not be checked,
15265 /// false otherwise.
15268 ArrayRef<AssociatedConstraint> AssociatedConstraints,
15269 const MultiLevelTemplateArgumentList &TemplateArgLists,
15270 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction,
15271 const ConceptReference *TopLevelConceptId = nullptr,
15272 Expr **ConvertedExpr = nullptr);
15273
15274 /// Check whether the given function decl's trailing requires clause is
15275 /// satisfied, if any. Returns false and updates Satisfaction with the
15276 /// satisfaction verdict if successful, emits a diagnostic and returns true if
15277 /// an error occurred and satisfaction could not be determined.
15278 ///
15279 /// \returns true if an error occurred, false otherwise.
15281 ConstraintSatisfaction &Satisfaction,
15282 SourceLocation UsageLoc = SourceLocation(),
15283 bool ForOverloadResolution = false);
15284
15285 // Calculates whether two constraint expressions are equal irrespective of a
15286 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
15287 // 'New', which are the "source" of the constraint, since this is necessary
15288 // for figuring out the relative 'depth' of the constraint. The depth of the
15289 // 'primary template' and the 'instantiated from' templates aren't necessarily
15290 // the same, such as a case when one is a 'friend' defined in a class.
15292 const Expr *OldConstr,
15294 const Expr *NewConstr);
15295
15296 // Calculates whether the friend function depends on an enclosing template for
15297 // the purposes of [temp.friend] p9.
15299
15300 /// \brief Ensure that the given template arguments satisfy the constraints
15301 /// associated with the given template, emitting a diagnostic if they do not.
15302 ///
15303 /// \param Template The template to which the template arguments are being
15304 /// provided.
15305 ///
15306 /// \param TemplateArgs The converted, canonicalized template arguments.
15307 ///
15308 /// \param TemplateIDRange The source range of the template id that
15309 /// caused the constraints check.
15310 ///
15311 /// \returns true if the constrains are not satisfied or could not be checked
15312 /// for satisfaction, false if the constraints are satisfied.
15315 const MultiLevelTemplateArgumentList &TemplateArgs,
15316 SourceRange TemplateIDRange);
15317
15318 bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation,
15320 ArrayRef<TemplateArgument> TemplateArgs,
15321 ConstraintSatisfaction &Satisfaction);
15322
15323 /// \brief Emit diagnostics explaining why a constraint expression was deemed
15324 /// unsatisfied.
15325 /// \param First whether this is the first time an unsatisfied constraint is
15326 /// diagnosed for this error.
15328 SourceLocation Loc = {},
15329 bool First = true);
15330
15331 /// \brief Emit diagnostics explaining why a constraint expression was deemed
15332 /// unsatisfied.
15333 void
15335 bool First = true);
15336
15338 bool First = true);
15339
15342 ArrayRef<AssociatedConstraint> AssociatedConstraints);
15343
15344 /// \brief Check whether the given declaration's associated constraints are
15345 /// at least as constrained than another declaration's according to the
15346 /// partial ordering of constraints.
15347 ///
15348 /// \param Result If no error occurred, receives the result of true if D1 is
15349 /// at least constrained than D2, and false otherwise.
15350 ///
15351 /// \returns true if an error occurred, false otherwise.
15352 bool IsAtLeastAsConstrained(const NamedDecl *D1,
15354 const NamedDecl *D2,
15356 bool &Result);
15357
15358 /// If D1 was not at least as constrained as D2, but would've been if a pair
15359 /// of atomic constraints involved had been declared in a concept and not
15360 /// repeated in two separate places in code.
15361 /// \returns true if such a diagnostic was emitted, false otherwise.
15365
15366private:
15369
15370 UnsignedOrNone EvaluateFoldExpandedConstraintSize(
15371 const Expr *Pattern, const MultiLevelTemplateArgumentList &MLTAL);
15372
15373 /// Cache the satisfaction of an atomic constraint.
15374 /// The key is based on the unsubstituted expression and the parameter
15375 /// mapping. This lets us not substituting the mapping more than once,
15376 /// which is (very!) expensive.
15377 llvm::DenseMap<llvm::FoldingSetNodeIDRef,
15379 UnsubstitutedConstraintSatisfactionCache;
15380
15381 /// Cache the instantiation results of template parameter mappings within
15382 /// concepts. Substituting into normalized concepts can be extremely expensive
15383 /// due to the redundancy of template parameters. This cache is intended for
15384 /// use by TemplateInstantiator to avoid redundant semantic checking.
15385 llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc>
15386 *CurrentCachedTemplateArgs = nullptr;
15387
15388 /// Caches pairs of template-like decls whose associated constraints were
15389 /// checked for subsumption and whether or not the first's constraints did in
15390 /// fact subsume the second's.
15391 llvm::DenseMap<std::pair<const NamedDecl *, const NamedDecl *>, bool>
15392 SubsumptionCache;
15393 /// Caches the normal form of constraint expressions (and their pack
15394 /// substitution index). These are shared by e.g. the members of all
15395 /// specializations of a class template. If an error occurred while
15396 /// normalizing an expression, nullptr will be cached here.
15397 llvm::DenseMap<std::pair<const Expr *, unsigned>, NormalizedConstraint *>
15398 NormalizedConstraintExprCache;
15399
15400 /// Cache whether the associated constraint of a declaration
15401 /// is satisfied.
15402 llvm::DenseMap<llvm::FoldingSetNodeIDRef, ConstraintSatisfaction *>
15403 SatisfactionCache;
15404
15405 // The current stack of constraint satisfactions, so we can exit-early.
15407
15408 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to set up the
15409 /// LocalInstantiationScope of the current non-lambda function. For lambdas,
15410 /// use LambdaScopeForCallOperatorInstantiationRAII.
15411 bool
15412 SetupConstraintScope(FunctionDecl *FD,
15413 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
15414 const MultiLevelTemplateArgumentList &MLTAL,
15416
15417 /// Used during constraint checking, sets up the constraint template argument
15418 /// lists, and calls SetupConstraintScope to set up the
15419 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
15420 std::optional<MultiLevelTemplateArgumentList>
15421 SetupConstraintCheckingTemplateArgumentsAndScope(
15422 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
15424
15425 ///@}
15426
15427 //
15428 //
15429 // -------------------------------------------------------------------------
15430 //
15431 //
15432
15433 /// \name Types
15434 /// Implementations are in SemaType.cpp
15435 ///@{
15436
15437public:
15438 /// A mapping that describes the nullability we've seen in each header file.
15440
15441 static int getPrintable(int I) { return I; }
15442 static unsigned getPrintable(unsigned I) { return I; }
15443 static bool getPrintable(bool B) { return B; }
15444 static const char *getPrintable(const char *S) { return S; }
15445 static StringRef getPrintable(StringRef S) { return S; }
15446 static const std::string &getPrintable(const std::string &S) { return S; }
15447 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
15448 return II;
15449 }
15451 static QualType getPrintable(QualType T) { return T; }
15452 static SourceRange getPrintable(SourceRange R) { return R; }
15454 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
15456
15457 enum class CompleteTypeKind {
15458 /// Apply the normal rules for complete types. In particular,
15459 /// treat all sizeless types as incomplete.
15461
15462 /// Relax the normal rules for complete types so that they include
15463 /// sizeless built-in types.
15465
15466 // FIXME: Eventually we should flip the default to Normal and opt in
15467 // to AcceptSizeless rather than opt out of it.
15469 };
15470
15472 const DeclSpec *DS = nullptr);
15474 const DeclSpec *DS = nullptr);
15475
15476 /// Build a pointer type.
15477 ///
15478 /// \param T The type to which we'll be building a pointer.
15479 ///
15480 /// \param Loc The location of the entity whose type involves this
15481 /// pointer type or, if there is no such entity, the location of the
15482 /// type that will have pointer type.
15483 ///
15484 /// \param Entity The name of the entity that involves the pointer
15485 /// type, if known.
15486 ///
15487 /// \returns A suitable pointer type, if there are no
15488 /// errors. Otherwise, returns a NULL type.
15490 DeclarationName Entity);
15491
15492 /// Build a reference type.
15493 ///
15494 /// \param T The type to which we'll be building a reference.
15495 ///
15496 /// \param Loc The location of the entity whose type involves this
15497 /// reference type or, if there is no such entity, the location of the
15498 /// type that will have reference type.
15499 ///
15500 /// \param Entity The name of the entity that involves the reference
15501 /// type, if known.
15502 ///
15503 /// \returns A suitable reference type, if there are no
15504 /// errors. Otherwise, returns a NULL type.
15506 DeclarationName Entity);
15507
15508 /// Build an array type.
15509 ///
15510 /// \param T The type of each element in the array.
15511 ///
15512 /// \param ASM C99 array size modifier (e.g., '*', 'static').
15513 ///
15514 /// \param ArraySize Expression describing the size of the array.
15515 ///
15516 /// \param Brackets The range from the opening '[' to the closing ']'.
15517 ///
15518 /// \param Entity The name of the entity that involves the array
15519 /// type, if known.
15520 ///
15521 /// \returns A suitable array type, if there are no errors. Otherwise,
15522 /// returns a NULL type.
15524 unsigned Quals, SourceRange Brackets,
15525 DeclarationName Entity);
15526
15527 /// Diagnose an array of \p NumElements elements of type \p ElementType
15528 /// that is too large. Returns true if a diagnostic was emitted.
15529 bool checkArrayTooLarge(QualType ElementType, const llvm::APSInt &NumElements,
15530 SourceLocation Loc,
15531 SourceRange Range = SourceRange());
15533
15534 /// Build an ext-vector type.
15535 ///
15536 /// Run the required checks for the extended vector type.
15538 SourceLocation AttrLoc);
15539 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
15540 SourceLocation AttrLoc);
15541
15543 Expr *CountExpr,
15544 bool CountInBytes,
15545 bool OrNull);
15546
15547 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
15548 /// expression is uninstantiated. If instantiated it will apply the
15549 /// appropriate address space to the type. This function allows dependent
15550 /// template variables to be used in conjunction with the address_space
15551 /// attribute
15552 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
15553 SourceLocation AttrLoc);
15554
15555 /// Same as above, but constructs the AddressSpace index if not provided.
15557 SourceLocation AttrLoc);
15558
15560
15562
15563 /// Build a function type.
15564 ///
15565 /// This routine checks the function type according to C++ rules and
15566 /// under the assumption that the result type and parameter types have
15567 /// just been instantiated from a template. It therefore duplicates
15568 /// some of the behavior of GetTypeForDeclarator, but in a much
15569 /// simpler form that is only suitable for this narrow use case.
15570 ///
15571 /// \param T The return type of the function.
15572 ///
15573 /// \param ParamTypes The parameter types of the function. This array
15574 /// will be modified to account for adjustments to the types of the
15575 /// function parameters.
15576 ///
15577 /// \param Loc The location of the entity whose type involves this
15578 /// function type or, if there is no such entity, the location of the
15579 /// type that will have function type.
15580 ///
15581 /// \param Entity The name of the entity that involves the function
15582 /// type, if known.
15583 ///
15584 /// \param EPI Extra information about the function type. Usually this will
15585 /// be taken from an existing function with the same prototype.
15586 ///
15587 /// \returns A suitable function type, if there are no errors. The
15588 /// unqualified type will always be a FunctionProtoType.
15589 /// Otherwise, returns a NULL type.
15591 SourceLocation Loc, DeclarationName Entity,
15593
15594 /// Build a member pointer type \c T Class::*.
15595 ///
15596 /// \param T the type to which the member pointer refers.
15597 /// \param Class the class type into which the member pointer points.
15598 /// \param Loc the location where this type begins
15599 /// \param Entity the name of the entity that will have this member pointer
15600 /// type
15601 ///
15602 /// \returns a member pointer type, if successful, or a NULL type if there was
15603 /// an error.
15605 CXXRecordDecl *Cls, SourceLocation Loc,
15606 DeclarationName Entity);
15607
15608 /// Build a block pointer type.
15609 ///
15610 /// \param T The type to which we'll be building a block pointer.
15611 ///
15612 /// \param Loc The source location, used for diagnostics.
15613 ///
15614 /// \param Entity The name of the entity that involves the block pointer
15615 /// type, if known.
15616 ///
15617 /// \returns A suitable block pointer type, if there are no
15618 /// errors. Otherwise, returns a NULL type.
15620 DeclarationName Entity);
15621
15622 /// Build a paren type including \p T.
15625
15626 /// Build a Read-only Pipe type.
15627 ///
15628 /// \param T The type to which we'll be building a Pipe.
15629 ///
15630 /// \param Loc We do not use it for now.
15631 ///
15632 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15633 /// a NULL type.
15635
15636 /// Build a Write-only Pipe type.
15637 ///
15638 /// \param T The type to which we'll be building a Pipe.
15639 ///
15640 /// \param Loc We do not use it for now.
15641 ///
15642 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15643 /// a NULL type.
15645
15646 /// Build a bit-precise integer type.
15647 ///
15648 /// \param IsUnsigned Boolean representing the signedness of the type.
15649 ///
15650 /// \param BitWidth Size of this int type in bits, or an expression
15651 /// representing that.
15652 ///
15653 /// \param Loc Location of the keyword.
15654 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
15655
15656 /// GetTypeForDeclarator - Convert the type for the specified
15657 /// declarator to Type instances.
15658 ///
15659 /// The result of this call will never be null, but the associated
15660 /// type may be a null type if there's an unrecoverable error.
15663
15664 /// Package the given type and TSI into a ParsedType.
15667 TypeSourceInfo **TInfo = nullptr);
15668
15670
15671 // Check whether the size of array element of type \p EltTy is a multiple of
15672 // its alignment and return false if it isn't.
15674
15675 void
15676 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
15677 SourceLocation FallbackLoc,
15678 SourceLocation ConstQualLoc = SourceLocation(),
15679 SourceLocation VolatileQualLoc = SourceLocation(),
15680 SourceLocation RestrictQualLoc = SourceLocation(),
15681 SourceLocation AtomicQualLoc = SourceLocation(),
15682 SourceLocation UnalignedQualLoc = SourceLocation());
15683
15684 /// Retrieve the keyword associated
15686
15687 /// Adjust the calling convention of a method to be the ABI default if it
15688 /// wasn't specified explicitly. This handles method types formed from
15689 /// function type typedefs and typename template arguments.
15690 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
15691 bool IsCtorOrDtor, SourceLocation Loc);
15692
15693 // Check if there is an explicit attribute, but only look through parens.
15694 // The intent is to look for an attribute on the current declarator, but not
15695 // one that came from a typedef.
15697
15698 /// Check whether a nullability type specifier can be added to the given
15699 /// type through some means not written in source (e.g. API notes).
15700 ///
15701 /// \param Type The type to which the nullability specifier will be
15702 /// added. On success, this type will be updated appropriately.
15703 ///
15704 /// \param Nullability The nullability specifier to add.
15705 ///
15706 /// \param DiagLoc The location to use for diagnostics.
15707 ///
15708 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
15709 /// array type (e.g., because it will decay to a pointer).
15710 ///
15711 /// \param OverrideExisting Whether to override an existing, locally-specified
15712 /// nullability specifier rather than complaining about the conflict.
15713 ///
15714 /// \returns true if nullability cannot be applied, false otherwise.
15716 NullabilityKind Nullability,
15717 SourceLocation DiagLoc,
15718 bool AllowArrayTypes,
15719 bool OverrideExisting);
15720
15721 /// Check whether the given variable declaration has a size that fits within
15722 /// the address space it is declared in. This issues a diagnostic if not.
15723 ///
15724 /// \param VD The variable declaration to check the size of.
15725 ///
15726 /// \param AS The address space to check the size of \p VD against.
15727 ///
15728 /// \returns true if the variable's size fits within the address space, false
15729 /// otherwise.
15730 bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS);
15731
15732 /// Get the type of expression E, triggering instantiation to complete the
15733 /// type if necessary -- that is, if the expression refers to a templated
15734 /// static data member of incomplete array type.
15735 ///
15736 /// May still return an incomplete type if instantiation was not possible or
15737 /// if the type is incomplete for a different reason. Use
15738 /// RequireCompleteExprType instead if a diagnostic is expected for an
15739 /// incomplete expression type.
15741
15743
15744 /// Ensure that the type of the given expression is complete.
15745 ///
15746 /// This routine checks whether the expression \p E has a complete type. If
15747 /// the expression refers to an instantiable construct, that instantiation is
15748 /// performed as needed to complete its type. Furthermore
15749 /// Sema::RequireCompleteType is called for the expression's type (or in the
15750 /// case of a reference type, the referred-to type).
15751 ///
15752 /// \param E The expression whose type is required to be complete.
15753 /// \param Kind Selects which completeness rules should be applied.
15754 /// \param Diagnoser The object that will emit a diagnostic if the type is
15755 /// incomplete.
15756 ///
15757 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
15758 /// otherwise.
15760 TypeDiagnoser &Diagnoser);
15761 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
15762
15763 template <typename... Ts>
15764 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
15765 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15767 }
15768
15769 // Returns the underlying type of a decltype with the given expression.
15771
15773 /// If AsUnevaluated is false, E is treated as though it were an evaluated
15774 /// context, such as when building a type for decltype(auto).
15775 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
15776
15777 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
15778 SourceLocation Loc);
15779 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
15780 SourceLocation Loc,
15781 bool FullySubstituted = false,
15782 ArrayRef<QualType> Expansions = {});
15783
15784 using UTTKind = UnaryTransformType::UTTKind;
15786 SourceLocation Loc);
15792 SourceLocation Loc);
15794 SourceLocation Loc);
15796 SourceLocation Loc);
15797
15799 return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc);
15800 }
15801
15803 SourceLocation Loc);
15805 SourceLocation Loc);
15806
15807 bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);
15808
15809 /// Ensure that the type T is a literal type.
15810 ///
15811 /// This routine checks whether the type @p T is a literal type. If @p T is an
15812 /// incomplete type, an attempt is made to complete it. If @p T is a literal
15813 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
15814 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
15815 /// it the type @p T), along with notes explaining why the type is not a
15816 /// literal type, and returns true.
15817 ///
15818 /// @param Loc The location in the source that the non-literal type
15819 /// diagnostic should refer to.
15820 ///
15821 /// @param T The type that this routine is examining for literalness.
15822 ///
15823 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
15824 ///
15825 /// @returns @c true if @p T is not a literal type and a diagnostic was
15826 /// emitted, @c false otherwise.
15828 TypeDiagnoser &Diagnoser);
15829 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
15830
15831 template <typename... Ts>
15832 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
15833 const Ts &...Args) {
15834 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15835 return RequireLiteralType(Loc, T, Diagnoser);
15836 }
15837
15840 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
15841 }
15842
15843 /// Ensure that the type T is a complete type.
15844 ///
15845 /// This routine checks whether the type @p T is complete in any
15846 /// context where a complete type is required. If @p T is a complete
15847 /// type, returns false. If @p T is a class template specialization,
15848 /// this routine then attempts to perform class template
15849 /// instantiation. If instantiation fails, or if @p T is incomplete
15850 /// and cannot be completed, issues the diagnostic @p diag (giving it
15851 /// the type @p T) and returns true.
15852 ///
15853 /// @param Loc The location in the source that the incomplete type
15854 /// diagnostic should refer to.
15855 ///
15856 /// @param T The type that this routine is examining for completeness.
15857 ///
15858 /// @param Kind Selects which completeness rules should be applied.
15859 ///
15860 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
15861 /// @c false otherwise.
15863 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
15865 CompleteTypeKind Kind, unsigned DiagID);
15866
15868 TypeDiagnoser &Diagnoser) {
15869 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, Diagnoser);
15870 }
15871 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID) {
15872 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, DiagID);
15873 }
15874
15875 template <typename... Ts>
15876 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
15877 const Ts &...Args) {
15878 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15879 return RequireCompleteType(Loc, T, Diagnoser);
15880 }
15881
15882 /// Determine whether a declaration is visible to name lookup.
15883 bool isVisible(const NamedDecl *D) {
15884 return D->isUnconditionallyVisible() ||
15885 isAcceptableSlow(D, AcceptableKind::Visible);
15886 }
15887
15888 /// Determine whether a declaration is reachable.
15889 bool isReachable(const NamedDecl *D) {
15890 // All visible declarations are reachable.
15891 return D->isUnconditionallyVisible() ||
15892 isAcceptableSlow(D, AcceptableKind::Reachable);
15893 }
15894
15895 /// Determine whether a declaration is acceptable (visible/reachable).
15897 return Kind == AcceptableKind::Visible ? isVisible(D) : isReachable(D);
15898 }
15899
15900 /// Determine if \p D and \p Suggested have a structurally compatible
15901 /// layout as described in C11 6.2.7/1.
15902 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15903
15904 /// Determine if \p D has a visible definition. If not, suggest a declaration
15905 /// that should be made visible to expose the definition.
15906 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15907 bool OnlyNeedComplete = false);
15909 NamedDecl *Hidden;
15910 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15911 }
15912 /// Determine if \p D has a definition which allows we redefine it in current
15913 /// TU. \p Suggested is the definition that should be made visible to expose
15914 /// the definition.
15915 bool isRedefinitionAllowedFor(NamedDecl *D, SourceLocation NewDefinitionLoc,
15916 NamedDecl **Suggested, bool &Visible);
15918 bool &Visible) {
15919 NamedDecl *Hidden;
15920 return isRedefinitionAllowedFor(const_cast<NamedDecl *>(D), NewLoc, &Hidden,
15921 Visible);
15922 }
15923
15924 /// Determine if \p D has a reachable definition. If not, suggest a
15925 /// declaration that should be made reachable to expose the definition.
15926 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15927 bool OnlyNeedComplete = false);
15929 NamedDecl *Hidden;
15930 return hasReachableDefinition(D, &Hidden);
15931 }
15932
15933 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15934 AcceptableKind Kind,
15935 bool OnlyNeedComplete = false);
15937 NamedDecl *Hidden;
15938 return hasAcceptableDefinition(D, &Hidden, Kind);
15939 }
15940
15941 /// Determine if a definition at \p NewLoc coincides with \p PrevD.
15942 ///
15943 /// Including the same header as a non-modular and a modular allows to process
15944 /// its content twice despite guards against multiple inclusions. To handle
15945 /// such cases this method allows to detect if a currently-parsed decl is at
15946 /// the same location as an existing decl imported from a module.
15947 bool isFromSameSingleIncludeHeader(const Decl *PrevD, SourceLocation NewLoc);
15948
15949 /// Try to parse the conditional expression attached to an effect attribute
15950 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
15951 /// optional on error.
15952 std::optional<FunctionEffectMode>
15953 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
15954
15955 void ActOnCleanupAttr(Decl *D, const Attr *A);
15956 void ActOnInitPriorityAttr(Decl *D, const Attr *A);
15957
15958private:
15959 /// The implementation of RequireCompleteType
15960 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15961 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15962
15963 /// Nullability type specifiers.
15964 IdentifierInfo *Ident__Nonnull = nullptr;
15965 IdentifierInfo *Ident__Nullable = nullptr;
15966 IdentifierInfo *Ident__Nullable_result = nullptr;
15967 IdentifierInfo *Ident__Null_unspecified = nullptr;
15968
15969 ///@}
15970
15971 //
15972 //
15973 // -------------------------------------------------------------------------
15974 //
15975 //
15976
15977 /// \name FixIt Helpers
15978 /// Implementations are in SemaFixItUtils.cpp
15979 ///@{
15980
15981public:
15982 /// Get a string to suggest for zero-initialization of a type.
15984 SourceLocation Loc) const;
15985 std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
15986
15987 ///@}
15988
15989 //
15990 //
15991 // -------------------------------------------------------------------------
15992 //
15993 //
15994
15995 /// \name Function Effects
15996 /// Implementations are in SemaFunctionEffects.cpp
15997 ///@{
15998public:
16001
16004 std::optional<FunctionEffectWithCondition>
16005 Old; // Invalid when 'Kind' is 'Added'.
16006 std::optional<FunctionEffectWithCondition>
16007 New; // Invalid when 'Kind' is 'Removed'.
16008
16009 StringRef effectName() const {
16010 if (Old)
16011 return Old.value().Effect.name();
16012 return New.value().Effect.name();
16013 }
16014
16015 /// Describes the result of effects differing between a base class's virtual
16016 /// method and an overriding method in a subclass.
16017 enum class OverrideResult {
16020 Merge // Merge missing effect from base to derived.
16021 };
16022
16023 /// Return true if adding or removing the effect as part of a type
16024 /// conversion should generate a diagnostic.
16026 const FunctionEffectsRef &SrcFX,
16027 QualType DstType,
16028 const FunctionEffectsRef &DstFX) const;
16029
16030 /// Return true if adding or removing the effect in a redeclaration should
16031 /// generate a diagnostic.
16032 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
16033 const FunctionEffectsRef &OldFX,
16034 const FunctionDecl &NewFunction,
16035 const FunctionEffectsRef &NewFX) const;
16036
16037 /// Return true if adding or removing the effect in a C++ virtual method
16038 /// override should generate a diagnostic.
16040 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
16041 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
16042 };
16043
16044 struct FunctionEffectDiffVector : public SmallVector<FunctionEffectDiff> {
16045 /// Caller should short-circuit by checking for equality first.
16047 const FunctionEffectsRef &New);
16048 };
16049
16050 /// All functions/lambdas/blocks which have bodies and which have a non-empty
16051 /// FunctionEffectsRef to be verified.
16053
16054 /// The union of all effects present on DeclsWithEffectsToVerify. Conditions
16055 /// are all null.
16057
16058public:
16059 /// Warn and return true if adding a function effect to a set would create a
16060 /// conflict.
16063 SourceLocation NewAttrLoc);
16064
16065 // Report a failure to merge function effects between declarations due to a
16066 // conflict.
16067 void
16069 SourceLocation NewLoc,
16070 SourceLocation OldLoc);
16071
16072 /// Inline checks from the start of maybeAddDeclWithEffects, to
16073 /// minimize performance impact on code not using effects.
16074 template <class FuncOrBlockDecl>
16075 void maybeAddDeclWithEffects(FuncOrBlockDecl *D) {
16076 if (Context.hasAnyFunctionEffects())
16077 if (FunctionEffectsRef FX = D->getFunctionEffects(); !FX.empty())
16079 }
16080
16081 /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify.
16082 void maybeAddDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
16083
16084 /// Unconditionally add a Decl to DeclsWithEfffectsToVerify.
16085 void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
16086
16088
16089 ///@}
16090
16091 //
16092 //
16093 // -------------------------------------------------------------------------
16094 //
16095 //
16096
16097 /// \name Expansion Statements
16098 /// Implementations are in SemaExpand.cpp
16099 ///@{
16100public:
16101 CXXExpansionStmtDecl *ActOnCXXExpansionStmtDecl(unsigned TemplateDepth,
16102 SourceLocation TemplateKWLoc);
16103
16107
16109 SourceLocation LBraceLoc,
16110 SourceLocation RBraceLoc);
16111
16113 CXXExpansionStmtDecl *ESD, Stmt *Init, Stmt *ExpansionVarStmt,
16114 Expr *ExpansionInitializer, SourceLocation LParenLoc,
16115 SourceLocation ColonLoc, SourceLocation RParenLoc,
16116 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps);
16117
16118 StmtResult FinishCXXExpansionStmt(Stmt *Expansion, Stmt *Body);
16119
16121 Stmt *ExpansionVar,
16122 SourceLocation LParenLoc,
16123 SourceLocation ColonLoc,
16124 SourceLocation RParenLoc);
16125
16127 CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVarStmt,
16128 Expr *ExpansionInitializer, SourceLocation LParenLoc,
16129 SourceLocation ColonLoc, SourceLocation RParenLoc,
16130 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
16131
16132 ExprResult BuildCXXExpansionSelectExpr(InitListExpr *Range, Expr *Idx);
16133
16134 std::optional<uint64_t>
16135 ComputeExpansionSize(CXXExpansionStmtPattern *Expansion);
16136 ///@}
16137};
16138
16142
16143/// Contains a late templated function.
16144/// Will be parsed at the end of the translation unit, used by Sema & Parser.
16147 /// The template function declaration to be late parsed.
16149 /// Floating-point options in the point of definition.
16151};
16152
16153template <>
16155 PragmaMsStackAction Action,
16156 llvm::StringRef StackSlotLabel,
16158
16159} // end namespace clang
16160
16161#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 enumerations for traits support.
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.
Token Tok
The Token.
FormatToken * Previous
The previous token in the unwrapped line.
static const Decl * getCanonicalDecl(const Decl *D)
Result
Implement __builtin_bit_cast and related operations.
#define X(type, name)
Definition Value.h:97
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
Definition MachO.h:31
Defines the clang::Module class, which describes a module in the source code.
Defines the clang::OpenCLOptions class.
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
llvm::json::Object Object
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
AccessResult
A copy of Sema's enum without AR_delayed.
CastType
Definition SemaCast.cpp:52
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
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.
C Language Family Type Representation.
Represents a member of a struct/union/class.
Definition Decl.h:3341
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:158
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:75
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:245
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Reads an AST files chain containing the contents of a translation unit.
Definition ASTReader.h:427
Writes an AST file containing the contents of a translation unit.
Definition ASTWriter.h:98
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:2790
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3820
Attr - This represents one attribute.
Definition Attr.h:47
Represents a C++ declaration that introduces decls from somewhere else.
Definition DeclCXX.h:3543
A binding in a decomposition declaration.
Definition DeclCXX.h:4232
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4856
[BoundsSafety] Represents a parent type class for CountAttributedType and similar sugar types that wi...
Definition TypeBase.h:3457
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:2645
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2994
Represents a C++ base or member initializer.
Definition DeclCXX.h:2410
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2631
Represents a C++ destructor within a class.
Definition DeclCXX.h:2924
Represents a C++26 expansion statement declaration.
CXXExpansionStmtPattern - Represents an unexpanded C++ expansion statement.
Definition StmtCXX.h:675
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:2153
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:77
Represents the this expression in C++.
Definition ExprCXX.h:1159
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:70
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:3012
A wrapper class around a pointer that always points to its canonical declaration.
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:5131
CaseStmt - Represent a case statement.
Definition Stmt.h:1931
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3745
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:127
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:3724
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:1400
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1467
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1315
Captures information about "declaration specifiers".
Definition DeclSpec.h:284
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1642
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:872
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition DeclBase.h:855
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:996
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:782
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:2000
A decomposition declaration.
Definition DeclCXX.h:4296
Captures a template argument whose value has been deduced via c++ template argument deduction.
Definition Template.h:339
A dependently-generated diagnostic.
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:221
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:240
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3604
Represents an enum.
Definition Decl.h:4192
Store information needed for an explicit specifier.
Definition DeclCXX.h:1949
The return type of classify().
Definition Expr.h:341
This represents one expression.
Definition Expr.h:114
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:196
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) 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:847
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition Expr.cpp:283
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:3341
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:265
FileNullability & operator[](FileID file)
Definition Sema.h:276
FileNullability Nullability
Definition Sema.h:272
Declaration of a friend template.
Represents a function declaration or definition.
Definition Decl.h:2082
A mutable set of FunctionEffect::Kind.
Definition TypeBase.h:5402
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5516
Kind
Identifies the particular effect.
Definition TypeBase.h:5164
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition TypeBase.h:5348
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4895
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5548
Declaration of a template function.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4770
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4744
One of these records is kept for each identifier that is lexed.
A simple pair of identifier info and location.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Definition Overload.h:624
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3648
Describes an C or C++ initializer list.
Definition Expr.h:5377
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:526
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:377
Represents the results of name lookup.
Definition Lookup.h:147
A global _GUID constant.
Definition DeclCXX.h:4468
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4414
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:4974
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3433
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3751
Abstract interface for a module loader.
Describes a module or submodule.
Definition Module.h:340
bool isModulePartitionImplementation() const
Is this a module partition implementation unit.
Definition Module.h:880
Module(ModuleConstructorTag, StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit, unsigned VisibilityID)
Construct a new module or submodule.
Definition Module.cpp:37
bool isModuleImplementation() const
Is this a module implementation.
Definition Module.h:885
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:276
Represent a C++ namespace.
Definition Decl.h:594
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:1160
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition TypeBase.h:8219
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:1162
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Definition Attr.h:280
static constexpr unsigned IdxBitWidth
Definition Attr.h:282
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2251
Represents a parameter to a function.
Definition Decl.h:1832
ParsedAttr - Represents a syntactic attribute.
Definition ParsedAttr.h:119
ParsedAttributes - A collection of parsed attributes.
Definition ParsedAttr.h:958
Represents the parsed form of a C++ template argument.
void Emit(const DiagnosticBuilder &DB) const
PreferredTypeBuilder(ASTContext *Ctx, bool Enabled)
Definition Sema.h:299
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:335
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:2699
A (possibly-)qualified type.
Definition TypeBase.h:938
The collection of all-type qualifiers we support.
Definition TypeBase.h:332
Represents a struct/union/class.
Definition Decl.h:4506
Represents the body of a requires-expression.
Definition DeclCXX.h:2122
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:120
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:49
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
Definition Sema.h:1922
bool operator==(const AlignPackInfo &Info) const
Definition Sema.h:1982
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition Sema.h:1954
unsigned getPackNumber() const
Definition Sema.h:1972
bool IsXLStack() const
Definition Sema.h:1980
bool IsPackSet() const
Definition Sema.h:1974
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition Sema.h:1928
bool IsAlignAttr() const
Definition Sema.h:1968
bool IsPackAttr() const
Definition Sema.h:1966
bool operator!=(const AlignPackInfo &Info) const
Definition Sema.h:1988
AlignPackInfo(bool IsXL)
Definition Sema.h:1932
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition Sema.h:1939
Mode getAlignMode() const
Definition Sema.h:1970
ArgPackSubstIndexRAII(Sema &Self, UnsignedOrNone NewSubstIndex)
Definition Sema.h:13969
ArgPackSubstIndexRAII & operator=(const ArgPackSubstIndexRAII &)=delete
ArgPackSubstIndexRAII(const ArgPackSubstIndexRAII &)=delete
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8498
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8503
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition Sema.h:8490
std::tuple< const Ts &... > Args
Definition Sema.h:8487
CXXThisScopeRAII(const CXXThisScopeRAII &)=delete
CXXThisScopeRAII & operator=(const CXXThisScopeRAII &)=delete
CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals, bool Enabled=true)
Introduce a new scope where 'this' may be allowed (when enabled), using the given declaration (which ...
CompoundScopeRAII & operator=(const CompoundScopeRAII &)=delete
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition Sema.h:1350
CompoundScopeRAII(const CompoundScopeRAII &)=delete
std::pair< VarDecl *, Expr * > get() const
Definition Sema.h:8038
std::optional< bool > getKnownValue() const
Definition Sema.h:8042
A RAII object to temporarily push a declaration context.
Definition Sema.h:3659
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition Sema.h:3669
ContextRAII & operator=(const ContextRAII &)=delete
ContextRAII(const ContextRAII &)=delete
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition Sema.h:10559
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:10564
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.
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition Sema.h:10287
DeferDiagsRAII & operator=(const DeferDiagsRAII &)=delete
DeferDiagsRAII(const DeferDiagsRAII &)=delete
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition Sema.h:1419
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition Sema.h:1438
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition Sema.h:1462
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition Sema.h:1431
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition Sema.h:1434
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:1448
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition Sema.h:1454
A helper class for building up ExtParameterInfos.
Definition Sema.h:13333
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:13352
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13340
FPFeaturesStateRAII(const FPFeaturesStateRAII &)=delete
FPOptionsOverride getOverrides()
Definition Sema.h:14398
FPFeaturesStateRAII & operator=(const FPFeaturesStateRAII &)=delete
FpPragmaStackSaveRAII(const FpPragmaStackSaveRAII &)=delete
FpPragmaStackSaveRAII & operator=(const FpPragmaStackSaveRAII &)=delete
FullExprArg(Sema &actions)
Definition Sema.h:7982
ExprResult release()
Definition Sema.h:7984
friend class Sema
Definition Sema.h:7993
Expr * get() const
Definition Sema.h:7986
GlobalEagerInstantiationScope(const GlobalEagerInstantiationScope &)=delete
GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
Definition Sema.h:14410
GlobalEagerInstantiationScope & operator=(const GlobalEagerInstantiationScope &)=delete
SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) override
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
Definition Sema.h:10623
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:10615
unsigned size() const
The number of exceptions in the exception specification.
Definition Sema.h:5736
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition Sema.h:5729
const QualType * data() const
The set of exceptions in the exception specification.
Definition Sema.h:5739
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:5745
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition Sema.h:5752
LambdaScopeForCallOperatorInstantiationRAII(Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope, bool ShouldAddDeclsFromParentScope=true)
LocalEagerInstantiationScope & operator=(const LocalEagerInstantiationScope &)=delete
LocalEagerInstantiationScope(Sema &S, bool AtEndOfTU)
Definition Sema.h:14361
LocalEagerInstantiationScope(const LocalEagerInstantiationScope &)=delete
static NameClassification DependentNonType()
Definition Sema.h:3885
static NameClassification VarTemplate(TemplateName Name)
Definition Sema.h:3895
ExprResult getExpression() const
Definition Sema.h:3921
NameClassification(const IdentifierInfo *Keyword)
Definition Sema.h:3858
static NameClassification Unknown()
Definition Sema.h:3865
static NameClassification OverloadSet(ExprResult E)
Definition Sema.h:3869
NameClassificationKind getKind() const
Definition Sema.h:3919
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition Sema.h:3913
static NameClassification FunctionTemplate(TemplateName Name)
Definition Sema.h:3901
NamedDecl * getNonTypeDecl() const
Definition Sema.h:3931
NameClassification(ParsedType Type)
Definition Sema.h:3855
TemplateName getTemplateName() const
Definition Sema.h:3936
ParsedType getType() const
Definition Sema.h:3926
TemplateNameKind getTemplateNameKind() const
Definition Sema.h:3945
static NameClassification NonType(NamedDecl *D)
Definition Sema.h:3875
static NameClassification Concept(TemplateName Name)
Definition Sema.h:3907
static NameClassification UndeclaredNonType()
Definition Sema.h:3881
static NameClassification TypeTemplate(TemplateName Name)
Definition Sema.h:3889
static NameClassification Error()
Definition Sema.h:3861
void operator()(sema::FunctionScopeInfo *Scope) const
Definition Sema.cpp:2649
PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct)
Definition SemaAttr.cpp:29
PragmaStackSentinelRAII(const PragmaStackSentinelRAII &)=delete
PragmaStackSentinelRAII & operator=(const PragmaStackSentinelRAII &)=delete
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition Sema.h:11696
SourceLocation getTemplateKeywordLoc() const
Definition Sema.h:11698
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition Sema.h:11693
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition Sema.h:12748
SFINAETrap & operator=(const SFINAETrap &)=delete
SFINAETrap(const SFINAETrap &)=delete
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition Sema.h:12782
SFINAETrap(Sema &S, bool WithAccessChecking=false)
Definition Sema.h:12764
bool withAccessChecking() const
Definition Sema.h:12785
sema::TemplateDeductionInfo * getDeductionInfo() const
Definition Sema.h:12777
SFINAETrap(Sema &S, sema::TemplateDeductionInfo &Info)
Definition Sema.h:12767
SatisfactionStackResetRAII(const SatisfactionStackResetRAII &)=delete
SatisfactionStackResetRAII & operator=(const SatisfactionStackResetRAII &)=delete
ScopedCodeSynthesisContext(Sema &S, const CodeSynthesisContext &Ctx)
Definition Sema.h:13896
ScopedCodeSynthesisContext & operator=(const ScopedCodeSynthesisContext &)=delete
ScopedCodeSynthesisContext(const ScopedCodeSynthesisContext &)=delete
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition Sema.h:8515
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8520
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8517
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition Sema.h:9539
CXXMethodDecl * getMethod() const
Definition Sema.h:9542
void setMethod(CXXMethodDecl *MD)
Definition Sema.h:9543
void addContextNote(SourceLocation UseLoc)
Definition Sema.h:13862
SynthesizedFunctionScope(const SynthesizedFunctionScope &)=delete
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition Sema.h:13850
SynthesizedFunctionScope & operator=(const SynthesizedFunctionScope &)=delete
SourceLocation getLocation() const
Definition Sema.h:12506
bool ContainsDecl(const NamedDecl *ND) const
Definition Sema.h:12496
const DeclContext * getDeclContext() const
Definition Sema.h:12502
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition Sema.h:12480
const NamedDecl * getDecl() const
Definition Sema.h:12494
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition Sema.h:12479
const DeclContext * getLexicalDeclContext() const
Definition Sema.h:12498
TentativeAnalysisScope(Sema &SemaRef)
Definition Sema.h:12799
TentativeAnalysisScope & operator=(const TentativeAnalysisScope &)=delete
TentativeAnalysisScope(const TentativeAnalysisScope &)=delete
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition Sema.h:7941
virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc)
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:863
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:1493
bool ActOnLateParsedTypeAttrArgument(BoundsAttributedType *BATy, FieldDecl *FD, Expr *Arg)
Supply the parsed argument of a late-parsed bounds attribute to the type built for it by ProcessLateP...
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:3763
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:13927
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:8424
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
Definition SemaAttr.cpp:546
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition Sema.h:13911
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:11213
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition Sema.h:13362
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
Definition Sema.cpp:2722
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition Sema.h:1172
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:1636
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:14346
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
void PopParsingClass(ParsingClassState state)
Definition Sema.h:6756
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:10300
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition Sema.cpp:1099
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
std::optional< QualType > BuiltinVectorMath(CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr=EltwiseBuiltinArgTyRestriction::None)
std::optional< uint64_t > ComputeExpansionSize(CXXExpansionStmtPattern *Expansion)
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:6745
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)
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
void ActOnPragmaExport(IdentifierInfo *IdentId, SourceLocation ExportNameLoc, Scope *curScope)
ActonPragmaExport - called on well-formed '#pragma export'.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs, SmallVectorImpl< const Attr * > &OutAttrs)
Process the attributes before creating an attributed statement.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
Unary Operators. 'Tok' is the token for the operator.
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition Sema.h:8470
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:8392
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:967
bool isAttrContext() const
Definition Sema.h:7152
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
ExprResult BuildBoolLiteral(SourceLocation Loc, bool Value)
Build a boolean-typed literal expression.
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:8463
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition Sema.cpp:2914
bool isFromSameSingleIncludeHeader(const Decl *PrevD, SourceLocation NewLoc)
Determine if a definition at NewLoc coincides with PrevD.
LookupNameKind
Describes the kind of name lookup to perform.
Definition Sema.h:9564
@ LookupLabel
Label name lookup.
Definition Sema.h:9573
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition Sema.h:9568
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition Sema.h:9595
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition Sema.h:9587
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition Sema.h:9609
@ LookupLocalFriendName
Look up a friend of a local class.
Definition Sema.h:9603
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition Sema.h:9605
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition Sema.h:9600
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition Sema.h:9580
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition Sema.h:9607
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition Sema.h:9591
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9576
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition Sema.h:9583
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9571
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition Sema.h:9611
@ LookupAnyName
Look up any declaration with any name.
Definition Sema.h:9613
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:421
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition Sema.h:9518
UnaryTransformType::UTTKind UTTKind
Definition Sema.h:15784
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
void ActOnPopScope(SourceLocation Loc, Scope *S)
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
ExprResult CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBLoc)
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
ActOnPragmaDetectMismatch - Call on well-formed #pragma detect_mismatch.
Definition SemaAttr.cpp:671
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:6490
SemaM68k & M68k()
Definition Sema.h:1543
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:13981
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.
std::pair< const CXXRecordDecl *, unsigned > SpecialMemberCacheKey
Definition Sema.h:9549
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:1414
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
bool BuildTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc, bool AllowUnexpandedPack)
void deduceOpenCLAddressSpace(VarDecl *decl)
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
const Decl * PragmaAttributeCurrentTargetDecl
The declaration that is currently receiving an attribute from the pragma attribute stack.
Definition Sema.h:2194
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:10004
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:5051
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:5280
OpaquePtr< QualType > TypeTy
Definition Sema.h:1332
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void DiagnoseAlwaysNonNullPointer(Expr *E, Expr::NullPointerConstantKind NullType, bool IsEqual, SourceRange Range)
Diagnose pointers that are always non-null.
bool IsStringInit(Expr *Init, const ArrayType *AT)
Definition SemaInit.cpp:170
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
TypeSourceInfo * SubstFriendType(TypeSourceInfo *TSI, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity)
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:371
void PrintContextStack()
Definition Sema.h:13990
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:700
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings={})
SemaOpenMP & OpenMP()
Definition Sema.h:1578
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition Sema.h:9517
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:2371
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition Sema.h:6528
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition Sema.h:9880
bool FormatStringHasSArg(const StringLiteral *FExpr)
StmtResult BuildCXXForRangeRangeVar(Scope *S, Expr *Range, QualType Type, bool IsConstexpr=false)
Build the range variable of a range-based for loop or iterating expansion statement and return its De...
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:1402
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
bool BoundsSafetyCheckAssignmentToCountAttrPtr(QualType LHSTy, Expr *RHSExpr, AssignmentAction Action, SourceLocation Loc, const ValueDecl *Assignee, bool ShowFullyQualifiedAssigneeName)
Perform Bounds Safety Semantic checks for assigning to a __counted_by or __counted_by_or_null pointer...
void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
llvm::DenseMap< const EnumDecl *, llvm::SmallVector< llvm::APSInt > > AssignEnumCache
A cache of enumerator values for enums checked by -Wassign-enum.
Definition Sema.h:3714
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:15447
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:1293
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:4953
void CheckFloatComparison(SourceLocation Loc, const Expr *LHS, const Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
PragmaClangSection PragmaClangRodataSection
Definition Sema.h:1894
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:15908
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, const IdentifierInfo *IIEnvironment, const IdentifierInfo *InferredPlatformII=nullptr)
DelegatingCtorDeclsType DelegatingCtorDecls
All the delegating constructors seen so far in the file, used for cycle detection at the end of the T...
Definition Sema.h:6718
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:5385
void emitAndClearUnusedLocalTypedefWarnings()
Definition Sema.cpp:1213
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:6699
bool areDocumentationDiagsEnabled(SourceLocation Loc)
Returns true if any of the documentation warnings is enabled at Loc.
Definition Sema.cpp:2832
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
Definition SemaStmt.cpp:87
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:1282
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
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:1518
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:377
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
Definition Sema.h:8058
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:8060
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:8059
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition Sema.h:1383
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:15867
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition Sema.h:15453
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)
bool needsRebuildOfDefaultArgOrInit() const
Definition Sema.h:8412
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:10118
@ Interface
'export module X;'
Definition Sema.h:10115
@ Implementation
'module X;'
Definition Sema.h:10116
@ PartitionInterface
'export module X:Y;'
Definition Sema.h:10117
SourceLocation LocationOfExcessPrecisionNotSatisfied
Definition Sema.h:8550
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition Sema.h:1275
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:9827
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsCall, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false)
void clearDocumentationDiagsCache()
Discard the areDocumentationDiagsEnabled() cache, for when a #pragma clang diagnostic has changed dia...
Definition Sema.cpp:2810
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition Sema.h:10642
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition Sema.h:10645
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition Sema.h:10651
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition Sema.h:10649
void inferLifetimeCaptureByAttribute(FunctionDecl *FD)
Add [[clang:lifetime_capture_by(this)]] to STL container methods.
Definition SemaAttr.cpp:318
void RefersToMemberWithReducedAlignment(Expr *E, llvm::function_ref< void(Expr *, RecordDecl *, FieldDecl *, CharUnits)> Action)
This function calls Action when it determines that E designates a misaligned member due to the packed...
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType)
Definition Sema.h:1852
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
@ AR_dependent
Definition Sema.h:1737
@ AR_accessible
Definition Sema.h:1735
@ AR_inaccessible
Definition Sema.h:1736
@ AR_delayed
Definition Sema.h:1738
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:15460
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
Definition Sema.h:15464
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:729
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
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:934
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition Sema.h:7130
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition Sema.cpp:2494
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope, LabelDecl *Label, SourceLocation LabelLoc)
QualType GetSignedSizelessVectorType(QualType V)
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
void ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, Scope *CurContext)
Once the Lambdas capture are known, we can start to create the closure, call operator method,...
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:445
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:8539
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition Sema.h:2125
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...
static SourceRange getPrintable(const Expr *E)
Definition Sema.h:15454
PragmaStack< StringLiteral * > CodeSegStack
Definition Sema.h:2119
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 InstantiateLateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, LateInstantiatedAttrVec &LateAttrs, LocalInstantiationScope *OuterMostScope)
Instantiate the attributes that InstantiateAttrs deferred to LateAttrs, and attach them to their decl...
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:16056
void setFunctionHasBranchIntoScope()
Definition Sema.cpp:2675
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:5111
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition SemaStmt.cpp:527
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimizeoff". If this location is invalid,...
Definition Sema.h:2203
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:6959
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool CheckOverridingFunctionAttributes(CXXMethodDecl *New, const CXXMethodDecl *Old)
void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind, StringRef Arg)
ActOnPragmaMSComment - Called on well formed #pragma comment(kind, "arg").
Definition SemaAttr.cpp:663
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
StmtResult BuildNonEnumeratingCXXExpansionStmtPattern(CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVarStmt, Expr *ExpansionInitializer, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition Sema.h:2114
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:11415
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)
void ActOnComment(SourceRange Comment)
Definition Sema.cpp:2867
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:4340
@ Default
= default ;
Definition Sema.h:4342
@ Delete
deleted-function-body
Definition Sema.h:4348
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
bool RequireStructuralType(QualType T, SourceLocation Loc)
Require the given type to be a structural type, and diagnose if it is not.
ExprResult VerifyBitField(SourceLocation FieldLoc, const IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width,...
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
bool CheckOverflowBehaviorTypeConversion(Expr *E, QualType T, SourceLocation CC)
Check for overflow behavior type related implicit conversion diagnostics.
llvm::function_ref< void(llvm::raw_ostream &)> EntityPrinter
Definition Sema.h:14308
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
Definition SemaStmt.cpp:50
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS)
Check whether the given variable declaration has a size that fits within the address space it is decl...
TemplateDeductionResult FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, SmallVectorImpl< OriginalCallArg > const *OriginalCallArgs, bool PartialOverloading, bool PartialOrdering, bool ForOverloadSetAddressResolution, llvm::function_ref< bool(bool)> CheckNonDependent=[](bool) { return false;})
Finish template argument deduction for a function template, checking the deduced template arguments f...
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition Sema.cpp:1294
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:2126
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:1533
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.
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:888
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...
TemplateName BuildPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< TemplateName > Expansions={})
PersonalityAttr * mergePersonalityAttr(Decl *D, FunctionDecl *Routine, const AttributeCommonInfo &CI)
bool IsInsideALocalClassWithinATemplateFunction()
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
void ActOnTranslationUnitScope(Scope *S)
Scope actions.
Definition Sema.cpp:173
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD, bool Diagnose, bool LookForGlobal, DeclarationName Name)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
void ActOnCXXForRangeDecl(Decl *D, bool InExpansionStmt)
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)
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, const Designation &Desig, SourceLocation RParenLoc)
SemaSYCL & SYCL()
Definition Sema.h:1603
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:3141
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool IsCall)
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:7142
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:1780
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
bool CheckConceptUseInDefinition(NamedDecl *Concept, SourceLocation Loc)
void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action, PragmaFloatControlKind Value)
ActOnPragmaFloatControl - Call on well-formed #pragma float_control.
Definition SemaAttr.cpp:706
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
Definition SemaExpr.cpp:851
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition Sema.h:11661
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)
QualType CheckMatrixCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition Sema.h:12259
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition Sema.h:12270
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition Sema.h:12262
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition Sema.h:12266
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:691
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
void ActOnPragmaMSPointersToMembers(LangOptions::PragmaMSPointersToMembersKind Kind, SourceLocation PragmaLoc)
ActOnPragmaMSPointersToMembers - called on well formed #pragma pointers_to_members(representation met...
Definition SemaAttr.cpp:760
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old)
[module.interface]p6: A redeclaration of an entity X is implicitly exported if X was introduced by an...
void DiagnosePrecisionLossInComplexDivision()
ExprResult CheckUnevaluatedOperand(Expr *E)
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
Definition Sema.h:9512
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
AvailabilityAttr * mergeAndInferAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, const IdentifierInfo *IIEnvironment, const IdentifierInfo *InferredPlatformII)
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
SemaX86 & X86()
Definition Sema.h:1623
void markLateParsedBoundsTypeRejected(const BoundsAttributedType *BATy)
Definition Sema.h:2623
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.
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:13931
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:1339
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:8379
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:698
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:9523
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition Sema.h:8003
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
Definition SemaExpr.cpp:231
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'.
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
llvm::DenseMap< IdentifierInfo *, PendingPragmaInfo > PendingExportedNames
Definition Sema.h:2413
DiagnosticsEngine & getDiagnostics() const
Definition Sema.h:932
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)
void ActOnReenterFunctionPrototypeParams(Scope *S, ArrayRef< ParmVarDecl * > Params)
Add Params to scope, so a late-parsed attribute can name them.
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...
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateName NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, bool EvaluateConstraints=true, const FunctionDecl *Fn=nullptr, LateInstantiatedAttrVec *ParamAttrs=nullptr)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
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:4566
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15832
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
TypeResult ActOnPackIndexingDeducedTemplateSpecializationType(TemplateName Name, SourceLocation NameLoc)
void resetFPOptions(FPOptions FPO)
Definition Sema.h:11642
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition Sema.h:15936
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:10101
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:15443
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
SemaObjC & ObjC()
Definition Sema.h:1563
bool InOverflowBehaviorAssignmentContext
Track if we're currently analyzing overflow behavior types in assignment context.
Definition Sema.h:1406
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:3096
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:1476
TemplateName ActOnPackIndexingTemplateName(TemplateName Pattern, SourceLocation NameLoc, Expr *IndexExpr)
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition SemaDecl.cpp:83
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 SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc, Scope *S=nullptr)
Mark the given declaration as explicitly defaulted.
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:970
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition Sema.h:3333
bool captureSwiftVersionIndependentAPINotes()
Whether APINotes should be gathered for all applicable Swift language versions, without being applied...
Definition Sema.h:1718
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
PragmaStack< bool > StrictGuardStackCheckStack
Definition Sema.h:2122
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void PrintInstantiationStack()
Definition Sema.h:13994
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:3753
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:772
bool isImmediateFunctionContext() const
Definition Sema.h:8404
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:935
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Definition Sema.h:1077
void addExternalSource(IntrusiveRefCntPtr< ExternalSemaSource > E)
Registers an external source.
Definition Sema.cpp:673
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition SemaExpr.cpp:782
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:6725
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:1468
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:6809
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)
llvm::DenseMap< CanonicalDeclPtr< const FunctionDecl >, llvm::SmallVector< FunctionDeclAndLoc, 1 > > DeviceKnownEmittedFns
An inverse call graph, mapping known-emitted functions to their known-emitted callers (plus the locat...
Definition Sema.h:1488
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:2118
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:774
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
Definition SemaAttr.cpp:377
bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction, const FunctionDecl *NewFunction, unsigned *ArgPos=nullptr, bool Reversed=false)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
Definition SemaExpr.cpp:901
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.
void LookupOverloadedUnaryOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded unary operator.
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:715
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition Sema.h:2765
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:6752
InitSegPragmaState CurInitSeg
Definition Sema.h:2165
void CheckFieldCapabilityAttrs(const RecordDecl *Record)
Check that Record is a capability if a thread safety attribute without capability arguments on one of...
@ FRS_Success
Definition Sema.h:11030
@ FRS_DiagnosticIssued
Definition Sema.h:11032
@ FRS_NoViableFunction
Definition Sema.h:11031
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.
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:14076
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:985
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
void mergeVisibilityType(Decl *D, SourceLocation Loc, VisibilityAttr::VisibilityType Type)
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition Sema.h:9561
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:9515
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.
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)
friend class SubstituteParameterMappings
Definition Sema.h:15368
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized.
Definition Sema.h:9248
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:16052
@ Conversions
Allow explicit conversion functions but not explicit constructors.
Definition Sema.h:10351
@ All
Allow both explicit conversion functions and explicit constructors.
Definition Sema.h:10353
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:1265
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition Sema.h:6740
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)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, const Designation &Desig, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
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:1243
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:15239
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union.
bool CheckDeclCompatibleWithTemplateTemplate(TemplateDecl *Template, TemplateTemplateParmDecl *Param, const TemplateArgumentLoc &Arg)
bool pushCodeSynthesisContext(CodeSynthesisContext Ctx)
void ActOnPragmaFPEvalMethod(SourceLocation Loc, LangOptions::FPEvalMethodKind Value)
Definition SemaAttr.cpp:679
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
Definition Sema.h:3776
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
FieldDecl * BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture, bool IsOpenMP=false)
Build a FieldDecl suitable to hold the given capture.
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:1785
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:2765
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition Sema.h:3656
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:2685
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:12438
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition Sema.h:12456
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition Sema.h:12446
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition Sema.h:12466
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:5102
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:1799
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:8585
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
Definition SemaAttr.cpp:432
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr * > Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
AssumedTemplateKind
Definition Sema.h:11711
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
Definition Sema.h:11718
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
Definition Sema.h:11715
bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Target, bool SkipTargetFirstParameter, SourceLocation TargetLoc, const FunctionProtoType *Source, bool SkipSourceFirstParameter, SourceLocation SourceLoc)
CheckParamExceptionSpec - Check if the parameter and return types of the two functions have equivalen...
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, OverloadCandidateParamOrder PO={})
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
Definition SemaAttr.cpp:838
StmtResult ActOnCXXExpansionStmtPattern(CXXExpansionStmtDecl *ESD, Stmt *Init, Stmt *ExpansionVarStmt, Expr *ExpansionInitializer, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps)
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:2872
void PushFunctionScope()
Enter a new function scope.
Definition Sema.cpp:2513
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:433
SourceRange getExprRange(Expr *E) const
Definition SemaExpr.cpp:519
bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS)
The parser has parsed a global nested-name-specifier '::'.
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:11647
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
Definition SemaAttr.cpp:170
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition Sema.h:8439
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:15450
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition Sema.h:4792
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:1634
bool FriendConstraintsDependOnEnclosingTemplate(const FunctionDecl *FD)
void addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI)
Add a no_cluster attribute to a particular declaration.
void addImplicitCallingConvAbiTag(FunctionDecl *FD)
Attach the ABI tag a standard calling convention variant requires, as an implicit abi_tag attribute.
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
Definition SemaStmt.cpp:407
FPOptions & getCurFPFeatures()
Definition Sema.h:930
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition Sema.h:8533
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
Definition Sema.cpp:278
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:84
sema::LambdaScopeInfo * PushLambdaScope()
Definition Sema.cpp:2531
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 DiagnoseUnsatisfiedRequiresExpr(const RequiresExpr *RequiresExpr, bool First=true)
void PopCompoundScope()
Definition Sema.cpp:2664
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15876
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:14738
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition Sema.h:14758
@ UPPC_RequiresClause
Definition Sema.h:14809
@ UPPC_UsingDeclaration
A using declaration.
Definition Sema.h:14764
@ UPPC_IfExists
Microsoft __if_exists.
Definition Sema.h:14791
@ UPPC_Requirement
Definition Sema.h:14806
@ UPPC_ExceptionType
The type of an exception.
Definition Sema.h:14782
@ UPPC_EnumeratorValue
The enumerator value.
Definition Sema.h:14761
@ UPPC_Lambda
Lambda expression.
Definition Sema.h:14797
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition Sema.h:14794
@ UPPC_PartialSpecialization
Partial specialization.
Definition Sema.h:14788
@ UPPC_Initializer
An initializer.
Definition Sema.h:14773
@ UPPC_BaseType
The base type of a class type.
Definition Sema.h:14743
@ UPPC_FriendDeclaration
A friend declaration.
Definition Sema.h:14767
@ UPPC_DefaultArgument
A default argument.
Definition Sema.h:14776
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition Sema.h:14746
@ UPPC_Expression
An arbitrary expression.
Definition Sema.h:14740
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition Sema.h:14785
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition Sema.h:14770
@ UPPC_DataMemberType
The type of a data member.
Definition Sema.h:14749
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition Sema.h:14755
@ UPPC_Block
Block expression.
Definition Sema.h:14800
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition Sema.h:14752
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition Sema.h:14779
@ UPPC_TypeConstraint
A type constraint.
Definition Sema.h:14803
api_notes::APINotesManager APINotes
Definition Sema.h:1343
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:12818
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:928
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:13376
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:6105
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Definition Sema.cpp:2625
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)
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
bool isLateParsedBoundsTypeRejected(const BoundsAttributedType *BATy) const
Definition Sema.h:2627
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition SemaAttr.cpp:767
SemaCodeCompletion & CodeCompletion()
Definition Sema.h:1513
void inferLifetimeBoundAttribute(FunctionDecl *FD)
Add [[clang:lifetimebound]] attr for std:: functions and methods.
Definition SemaAttr.cpp:238
ModularFormatAttr * mergeModularFormatAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *ModularImplFn, StringRef ImplName, MutableArrayRef< StringRef > Aspects)
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition Sema.h:3770
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc)
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:1568
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition Sema.h:15234
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
bool ProcessLateParsedTypeAttr(LateParsedTypeAttrInfo &LA, QualType &QT)
Validate the late-parsed type attribute LA and wrap QT in a CountAttributedType with no count yet,...
ReuseLambdaContextDecl_t
Definition Sema.h:7221
@ ReuseLambdaContextDecl
Definition Sema.h:7221
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:936
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:1508
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:1385
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:1338
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:2212
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
bool SubstTemplateArgumentsInParameterMapping(ArrayRef< TemplateArgumentLoc > Args, SourceLocation BaseLoc, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Out)
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition Sema.h:1380
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition Sema.h:2190
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
bool BuildCtorClosureDefaultArgs(SourceLocation Loc, CXXConstructorDecl *Ctor, bool IsCopy=false)
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:2300
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.
SemaDirectX & DirectX()
Definition Sema.h:1523
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition Sema.h:6701
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:1553
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:1635
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:1337
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 ...
bool CheckExplicitlyDefaultedPostfixOperator(Scope *S, FunctionDecl *FD, PostfixOperatorKind Kind)
Check a defaulted postfix increment or decrement operator function (C++2d [over.inc....
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,...
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition Sema.h:1271
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition Sema.cpp:2740
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:1266
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition Sema.h:9251
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:970
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition SemaStmt.cpp:418
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition Sema.h:15889
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:6703
SemaHLSL & HLSL()
Definition Sema.h:1528
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:11660
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition Sema.h:1269
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition Sema.h:9560
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:1234
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:7136
bool shouldRetainCommentsInAST(SourceLocation Loc)
Returns true if a comment at Loc should be retained in the AST (some consumer such as -Wdocumentation...
Definition Sema.cpp:2773
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr, ConversionAction Action=CA_ToLiteralEncoding)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e....
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:1895
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
static StringRef GetFormatStringTypeName(FormatStringType FST)
SemaMIPS & MIPS()
Definition Sema.h:1548
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition Sema.cpp:140
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
void CompleteLambdaCallOperator(CXXMethodDecl *Method, SourceLocation LambdaLoc, SourceLocation CallOperatorLoc, const AssociatedConstraint &TrailingRequiresClause, TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind, StorageClass SC, ArrayRef< ParmVarDecl * > Params, bool HasExplicitResultType)
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
SemaRISCV & RISCV()
Definition Sema.h:1593
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:16075
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition Sema.h:1884
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:6111
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.
bool convertArgumentToType(Expr *&Value, QualType Ty)
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
Definition SemaExpr.cpp:220
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:5479
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
Definition Sema.h:5482
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
Definition Sema.h:5486
@ Builtin
A builtin needed 'std::strong_ordering' (eg. '__builtin_type_order').
Definition Sema.h:5488
MemberPointerConversionDirection
Definition Sema.h:10483
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition Sema.h:14344
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition Sema.h:6696
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, TypeSourceInfo *TSI)
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
Definition SemaExpr.cpp:82
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:2938
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:15445
SemaSwift & Swift()
Definition Sema.h:1608
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:2107
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:6801
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition Sema.h:7166
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition Sema.h:6733
StmtResult ActOnExprStmtError()
Definition SemaStmt.cpp:67
PragmaStack< StringLiteral * > BSSSegStack
Definition Sema.h:2117
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.
StmtResult BuildCXXEnumeratingExpansionStmtPattern(Decl *ESD, Stmt *Init, Stmt *ExpansionVar, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
void completeExprArrayBound(Expr *E)
DeclContext * getCurLexicalContext() const
Definition Sema.h:1176
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition Sema.h:1394
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:2168
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:1792
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:914
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
Definition SemaStmt.cpp:72
OpenCLOptions OpenCLFeatures
Definition Sema.h:1334
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:12064
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
Definition Sema.h:14348
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:2215
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
bool isRedefinitionAllowedFor(const NamedDecl *D, SourceLocation NewLoc, bool &Visible)
Definition Sema.h:15917
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:881
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:4968
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:10670
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition Sema.h:15439
ProcessingContextState ParsingClassState
Definition Sema.h:6751
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:1374
NamedDecl * lookupExternCFunctionOrVariable(IdentifierInfo *IdentId, SourceLocation NameLoc, Scope *curScope)
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
void PushCompoundScope(bool IsStmtExpr)
Definition Sema.cpp:2659
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 ActOnCXXExpansionInitList(MultiExprArg SubExprs, SourceLocation LBraceLoc, SourceLocation RBraceLoc)
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:3185
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:4022
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition Sema.h:2845
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:15798
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.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
ExprResult BuildCXXAggregateDefaultInitExpr(SourceLocation Loc, FieldDecl *Field, const InitializedEntity &MemberEntity)
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...
bool DiagnosePackIndexingInFriendNNS(SourceLocation Loc, NestedNameSpecifierLoc NNSLoc)
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition Sema.h:7163
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID, const FunctionProtoType *Superset, bool SkipSupersetFirstParameter, SourceLocation SuperLoc, const FunctionProtoType *Subset, bool SkipSubsetFirstParameter, SourceLocation SubLoc)
CheckExceptionSpecSubset - Check whether the second function type's exception specification is a subs...
bool checkArrayTooLarge(QualType ElementType, const llvm::APSInt &NumElements, SourceLocation Loc, SourceRange Range=SourceRange())
Diagnose an array of NumElements elements of type ElementType that is too large.
bool IsOverflowBehaviorTypeConversion(QualType FromType, QualType ToType)
IsOverflowBehaviorTypeConversion - Determines whether the conversion from FromType to ToType necessar...
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
StmtResult ActOnEndOfDeferStmt(Stmt *Body, Scope *CurScope)
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
TemplateDeductionResult SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate, TemplateArgumentListInfo &ExplicitTemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< QualType > &ParamTypes, QualType *FunctionType, sema::TemplateDeductionInfo &Info)
Substitute the explicitly-provided template arguments into the given function template according to C...
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true, LateInstantiatedAttrVec *LateAttrs=nullptr)
Substitute into a function parameter.
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:2477
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation)
type checking for vector binary operators.
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:12059
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:13374
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:5062
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:6101
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:652
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:15883
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition Sema.h:8408
llvm::MapVector< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition Sema.h:3736
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
llvm::SmallPtrSet< const BoundsAttributedType *, 1 > RejectedLateParsedBoundsTypes
Late-parsed bounds types dropped while their declarator was built.
Definition Sema.h:2621
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition Sema.h:10096
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,...
LazyVector< TypedefNameDecl *, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition Sema.h:5106
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:2700
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:8275
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:2695
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:7178
void ApplyForRangeOrExpansionStatementLifetimeExtension(VarDecl *RangeVar, ArrayRef< MaterializeTemporaryExpr * > Temporaries)
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:6710
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...
void ActOnExitFunctionPrototypeParams(Scope *S, ArrayRef< ParmVarDecl * > Params)
Undo the above, for when S outlives the attribute so no scope pop removes them.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1491
auto getDefaultDiagFunc()
Definition Sema.h:2373
void ActOnInitPriorityAttr(Decl *D, const Attr *A)
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount)
Checks that a call expression's argument count is at least the desired number.
bool IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType)
IsOverflowBehaviorTypePromotion - Determines whether the conversion from FromType to ToType involves ...
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc)
ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const,addrspace}_cast's.
Definition SemaCast.cpp:317
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:12819
ClassTemplateDecl * StdTypeIdentity
The C++ "std::type_identity" template, which is defined in <type_traits>.
Definition Sema.h:6729
SemaOpenCL & OpenCL()
Definition Sema.h:1573
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:14357
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, SourceLocation Loc={}, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams, SourceLocation EllipsisLoc)
Handle a friend type declaration.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
Definition SemaAttr.cpp:659
bool CheckVariablyModifiedTypeUse(QualType T, SourceLocation Loc)
Handle a use of the variably modified type T in the current context.
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition Sema.h:2295
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.
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:15455
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:2775
@ FAPK_Elsewhere
Definition Sema.h:2779
@ FAPK_Fixed
Definition Sema.h:2776
@ FAPK_Variadic
Definition Sema.h:2777
@ FAPK_VAList
Definition Sema.h:2778
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:8400
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition Sema.h:13365
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition Sema.cpp:1759
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...
LazyVector< const DeclaratorDecl *, &ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2 > UnusedFileScopedDeclsType
Definition Sema.h:3749
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)
bool ValidateBoundsAttrTypeForTypePosition(QualType Ty, AttributeCommonInfo::Kind AttrKind, SourceLocation AttrLoc, SourceRange AttrRange, unsigned PointerNestLevel, BoundsAttrFlags &Flags)
Check a counted_by-family attribute in type position and initialize Flags from AttrKind.
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:15896
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:15210
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:8596
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:3767
ExprResult CheckVarOrConceptTemplateTemplateId(const DeclarationNameInfo &NameInfo, TemplateName Template, const TemplateArgumentListInfo *TemplateArgs)
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition Sema.h:6962
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index, QualType ParamType, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
bool MSStructPragmaOn
Definition Sema.h:1881
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)
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:13942
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:14292
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition Sema.h:15871
SourceManager & getSourceManager() const
Definition Sema.h:933
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:8667
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:5040
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:648
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_enum attribute.
Definition Sema.h:3710
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:984
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:714
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:12538
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:2385
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition SemaAttr.cpp:593
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
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:14297
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...
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr, Scope *S=nullptr)
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:6221
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.
CXXExpansionStmtDecl * ActOnCXXExpansionStmtDecl(unsigned TemplateDepth, SourceLocation TemplateKWLoc)
bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc)
PragmaClangSection PragmaClangTextSection
Definition Sema.h:1896
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:7684
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.
NonTrivialCUnionKind
Definition Sema.h:4279
@ NTCUK_Destruct
Definition Sema.h:4281
@ NTCUK_Init
Definition Sema.h:4280
@ NTCUK_Copy
Definition Sema.h:4282
FormatMatchesAttr * mergeFormatMatchesAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Format, int FormatIdx, StringLiteral *FormatStr)
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr=EltwiseBuiltinArgTyRestriction::None)
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
DelayedDiagnosticsState ProcessingContextState
Definition Sema.h:1415
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:8549
PragmaClangSection PragmaClangDataSection
Definition Sema.h:1893
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.
bool SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams, ExtParameterInfoBuilder &ParamInfos, const QualType *OldParamTypes=nullptr, bool EvaluateConstraints=true, const FunctionDecl *Fn=nullptr, LateInstantiatedAttrVec *ParamAttrs=nullptr)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
LazyVector< VarDecl *, &ExternalSemaSource::ReadTentativeDefinitions, 2, 2 > TentativeDefinitionsType
Definition Sema.h:3757
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
ParsedType actOnLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init)
Perform initialization analysis of the init-capture and perform any implicit conversions such as an l...
Definition Sema.h:9352
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...
CXXExpansionStmtDecl * BuildCXXExpansionStmtDecl(DeclContext *Ctx, SourceLocation TemplateKWLoc, NonTypeTemplateParmDecl *NTTP)
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:2525
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:2106
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:6960
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition Sema.h:938
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:1279
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition Sema.h:2171
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool isSFINAEContext() const
Definition Sema.h:14002
FunctionDecl * BuildTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl, QualType AllocType, SourceLocation)
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition Sema.h:9022
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope, bool IsInstantiation=false)
ActOnLambdaError - If there is an error parsing a lambda, this callback is invoked to pop the informa...
static SourceRange getPrintable(SourceRange R)
Definition Sema.h:15452
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:13958
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)
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:15195
ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, TypeSourceInfo *TSI)
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc, ImplicitTypenameContext IsImplicitTypename=ImplicitTypenameContext::No)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition Sema.h:15838
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition Sema.h:1182
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:3147
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
void ProcessPragmaExport(DeclaratorDecl *newDecl)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void emitDeferredDiags()
Definition Sema.cpp:2163
void setFunctionHasMustTail()
Definition Sema.cpp:2690
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...
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation(), bool IsLabelStmt=false)
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
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:8592
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:15201
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:2680
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition Sema.h:15928
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:2767
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition Sema.h:6721
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:643
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:1228
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:1632
bool isRedefinitionAllowedFor(NamedDecl *D, SourceLocation NewDefinitionLoc, NamedDecl **Suggested, bool &Visible)
Determine if D has a definition which allows we redefine it in current TU.
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:11521
void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
void ApplyNullability(Decl *D, NullabilityKind Nullability)
Apply the 'Nullability:' annotation to the specified declaration.
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
Definition SemaDecl.cpp:278
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:1629
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:1340
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:4855
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
void DefineDefaultedPostfixOperator(SourceLocation Loc, FunctionDecl *FD, PostfixOperatorKind Kind)
Synthesize the body of a defaulted postfix increment or decrement operator function (C++2d [over....
PragmaAlignPackDiagnoseKind
Definition Sema.h:2273
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:7170
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition SemaExpr.cpp:130
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition Sema.h:1379
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:1906
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition Sema.h:14340
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:10124
@ PrivateFragmentImportFinished
after 'module :private;' but a non-import decl has already been seen.
Definition Sema.h:10131
@ ImportFinished
after any non-import decl.
Definition Sema.h:10128
@ PrivateFragmentImportAllowed
after 'module :private;' but before any non-import decl.
Definition Sema.h:10129
@ FirstDecl
Parsing the first decl in a TU.
Definition Sema.h:10125
@ GlobalFragment
after 'module;' but before 'module X;'
Definition Sema.h:10126
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
Definition Sema.h:10133
@ ImportAllowed
after 'module X;' but before any non-import decl.
Definition Sema.h:10127
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:15451
bool checkInstantiatedThreadSafetyAttrs(const Decl *D, const Attr *A)
Recheck instantiated thread-safety attributes that could not be validated on the dependent pattern de...
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks, bool IgnoreArch=false)
Create a CUDALaunchBoundsAttr attribute.
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition Sema.cpp:110
VarDecl * BuildForRangeVarDecl(SourceLocation Loc, QualType Type, IdentifierInfo *Name, bool IsConstexpr)
Helper used by the expansion statements and for-range code to build a variable declaration for e....
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition Sema.h:1300
void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc)
bool CheckDistantExceptionSpec(QualType T)
CheckDistantExceptionSpec - Check if the given type is a pointer or pointer to member to a function w...
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, const ParsedAttributesView &Attr)
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
void AddNonMemberOperatorCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
Add all of the non-member operator function declarations in the given function set to the overload ca...
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X, Expr *Y, Expr *Z)
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition Sema.h:6904
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
Definition Sema.h:6926
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
Definition Sema.h:6916
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
Definition Sema.h:6931
@ DiscardedStatement
The current expression occurs within a discarded statement.
Definition Sema.h:6921
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6941
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6910
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6936
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
Definition Sema.h:6951
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:13950
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel, bool IsConstexpr=false)
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:5016
@ AP_InferredFromAnyAppleOS
The availability attribute was inferred from an 'anyAppleOS' availability attribute.
Definition Sema.h:5030
@ AP_PragmaClangAttribute
The availability attribute was applied using 'pragma clang attribute'.
Definition Sema.h:5022
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition Sema.h:5026
@ AP_PragmaClangAttribute_InferredFromAnyAppleOS
The availability attribute was inferred from an 'anyAppleOS' availability attribute that was applied ...
Definition Sema.h:5035
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition Sema.h:5019
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:984
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:14302
SemaPPC & PPC()
Definition Sema.h:1583
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:2538
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:422
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:77
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition Sema.h:5099
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:1298
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:15203
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:1384
bool CheckDependentFriend(SourceLocation Loc, NestedNameSpecifierLoc NNSLoc, ArrayRef< TemplateParameterList * > TPLs, bool IsInstantiation)
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:8603
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:3760
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:10279
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:8390
SemaSystemZ & SystemZ()
Definition Sema.h:1613
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition Sema.cpp:124
MultiExprArg getInitsWithEmbedExpanded(InitListExpr *ILE, SmallVectorImpl< Expr * > &Storage)
The initializers of ILE with each multi-element EmbedExpr split into one EmbedExpr per embedded eleme...
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:3169
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.
llvm::SmallPtrSet< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition Sema.h:3740
static QualType getTypeOfConstantTemplateParameter(const TemplateArgument &Arg)
Determine the declared type of the constant template parameter that Arg names, if any.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8536
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:10475
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
static BoundsAttributedType::BoundsAttrKind getBoundsAttrKind(const BoundsAttrFlags &)
ParsedType ActOnCXXNestedNameSpecifierIndexedPack(CXXScopeSpec &SS, const DeclSpec &DS, TypeSourceInfo *PatternLoc, SourceLocation ColonColonLoc, QualType Type)
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:10110
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:717
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...
LazyVector< CXXConstructorDecl *, &ExternalSemaSource::ReadDelegatingConstructors, 2, 2 > DelegatingCtorDeclsType
Definition Sema.h:6714
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition Sema.h:1342
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:11688
@ TemplateNameIsRequired
Definition Sema.h:11688
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:801
ExprResult BuildCXXCtorDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const
Determine whether FD is an aligned allocation or deallocation function that is unavailable.
bool hasReachableExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is an explicit specialization declaration for...
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure.
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, CXXScopeSpec &SS, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration.
TypeSourceInfo * SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, StringRef SlotLabel, Expr *Alignment)
ActOnPragmaPack - Called on well formed #pragma pack(...).
Definition SemaAttr.cpp:481
static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD)
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
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:1341
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
void DiagnoseUnterminatedPragmaAlignPack()
Definition SemaAttr.cpp:632
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition Sema.h:8007
OpenCLOptions & getOpenCLOptions()
Definition Sema.h:929
FPOptions CurFPFeatures
Definition Sema.h:1335
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:1387
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition Sema.h:6705
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 ValidateBoundsAttrTypeShape(QualType Ty, SourceLocation AttrLoc, SourceRange AttrRange, BoundsAttrFlags &Flags, StringRef AttrSpelling={}, bool AllowRedecl=false, Expr *AttrArg=nullptr, bool UpdateFlags=true)
Check the type shape for counted_by, sized_by and their _or_null variants.
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
ExprResult BuildCXXExpansionSelectExpr(InitListExpr *Range, Expr *Idx)
void addLifetimeBoundToImplicitThis(CXXMethodDecl *MD)
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
void LoadExternalExtnameUndeclaredIdentifiers()
Load pragma redefine_extname'd undeclared identifiers from the external source.
Definition Sema.cpp:1109
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:528
PragmaStack< StringLiteral * > DataSegStack
Definition Sema.h:2116
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)
friend class ConstraintSatisfactionChecker
Definition Sema.h:15367
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:3208
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc, bool IsExplicit)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
std::unique_ptr< APINotesSelectorDiagnosticState > APINotesSelectorDiagnostics
Definition Sema.h:1345
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< ParsedType > Args, SourceLocation RParenLoc)
Parsed one of the type trait support pseudo-functions.
StmtResult FinishCXXExpansionStmt(Stmt *Expansion, Stmt *Body)
TemplateParamListContext
The context in which we are checking a template parameter list.
Definition Sema.h:11871
@ TPC_TemplateTemplateParameterPack
Definition Sema.h:11881
@ TPC_FriendFunctionTemplate
Definition Sema.h:11879
@ TPC_ClassTemplateMember
Definition Sema.h:11877
@ TPC_FunctionTemplate
Definition Sema.h:11876
@ TPC_FriendClassTemplate
Definition Sema.h:11878
@ TPC_FriendFunctionTemplateDefinition
Definition Sema.h:11880
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:1503
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
friend class InitializationSequence
Definition Sema.h:1633
bool GloballyUniqueObjectMightBeAccidentallyDuplicated(const VarDecl *Dcl)
Certain globally-unique variables might be accidentally duplicated if built into multiple shared libr...
void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, StringLiteral *SegmentName, IdentifierLoc *Func=nullptr)
Called on well-formed #pragma init_seg().
Definition SemaAttr.cpp:931
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:2199
bool isMainFileLoc(SourceLocation Loc) const
Determines whether the given source location is in the main file and we're in a context where we shou...
Definition Sema.cpp:976
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:7966
void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init)
CXXDeductionGuideDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param, SourceLocation Location)
Get a template argument mapping the given template parameter to itself, e.g.
bool CheckIfFunctionSpecializationIsImmediate(FunctionDecl *FD, SourceLocation Loc)
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc)
Complete a lambda-expression having processed and attached the lambda body.
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
void ActOnDeferStmtError(Scope *CurScope)
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
concepts::NestedRequirement * BuildNestedRequirement(Expr *E)
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
Definition Sema.h:6737
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition Sema.h:13922
void PrintStats() const
Print out statistics about the semantic analysis.
Definition Sema.cpp:688
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:15442
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:1879
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:1284
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, const FunctionProtoType *Proto, Expr *Object, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddSurrogateCandidate - Adds a "surrogate" candidate function that converts the given Object to a fun...
SourceRange getRangeForNextToken(SourceLocation Loc, bool IncludeMacros, bool IncludeComments, std::optional< tok::TokenKind > ExpectedToken=std::nullopt)
Calls Lexer::findNextToken() to find the next token, and if the locations of both ends of the token c...
Definition Sema.cpp:89
MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
BuildForRangeKind
Definition Sema.h:11307
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition Sema.h:11315
@ BFRK_Build
Initial building of a for-range statement.
Definition Sema.h:11309
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition Sema.h:11312
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
SemaNVPTX & NVPTX()
Definition Sema.h:1558
void checkIncorrectVTablePointerAuthenticationAttribute(CXXRecordDecl &RD)
Check that VTable Pointer authentication is only being set on the first first instantiation of the vt...
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool AllowTypoCorrection=true)
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:915
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().
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:629
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:2136
@ PSK_ConstSeg
Definition Sema.h:2139
@ PSK_DataSeg
Definition Sema.h:2137
@ PSK_CodeSeg
Definition Sema.h:2140
@ PSK_BSSSeg
Definition Sema.h:2138
void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope)
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
bool isTagRedeclarationInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
Determine whether a tag-like declaration found by lookup can be redeclared in the given scope.
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:643
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:340
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition Sema.h:6527
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
bool BuiltinConstantArgPower2(CallExpr *TheCall, unsigned ArgNum)
BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a constant expression representing ...
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
void BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs, LateInstantiatedAttrVec *LateAttrs, DeclContext *Owner, LocalInstantiationScope *StartingScope, bool InstantiatingVarTemplate=false, VarTemplateSpecializationDecl *PrevVTSD=nullptr)
BuildVariableInstantiation - Used after a new variable has been created.
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
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:3729
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition Sema.cpp:2281
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
UnsignedOrNone GetDecompositionElementCount(QualType DecompType, SourceLocation Loc)
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, bool IsMemberSpecialization, SkipBodyInfo *SkipBody=nullptr)
PragmaClangSection PragmaClangBSSSection
Definition Sema.h:1892
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:1398
QualType CheckMatrixLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
AbstractDiagSelID
Definition Sema.h:6473
@ AbstractSynthesizedIvarType
Definition Sema.h:6480
@ AbstractVariableType
Definition Sema.h:6477
@ AbstractReturnType
Definition Sema.h:6475
@ AbstractNone
Definition Sema.h:6474
@ AbstractFieldType
Definition Sema.h:6478
@ AbstractArrayType
Definition Sema.h:6481
@ AbstractParamType
Definition Sema.h:6476
@ AbstractIvarType
Definition Sema.h:6479
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
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.
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:1598
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:8589
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...
void getSortedUnusedLocalTypedefNameCandidates(SmallVectorImpl< const TypedefNameDecl * > &Sorted) const
Store UnusedLocalTypedefNameCandidates in Sorted in a deterministic order.
Definition Sema.cpp:1200
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.
std::optional< ResolvedAllocation > FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, AllocationFunctionScope NewScope, AllocationFunctionScope DeleteScope, QualType AllocType, bool IsArray, const ImplicitAllocationParameters &IAP, MultiExprArg PlaceArgs, bool Diagnose=true)
Finds the overloads of operator new and delete that are appropriate for the allocation.
llvm::DenseMap< SpecialMemberCacheKey, SpecialMemberOverloadResult > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Definition Sema.h:9554
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
void DiagnoseUnusedAPINotesSelectors()
Diagnose exact API notes selectors that were not matched by any declaration processed in this transla...
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, SourceLocation EllipsisLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists, TemplateIdAnnotation *TemplateId)
Handle a friend tag declaration where the scope specifier was templated.
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:8198
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:9617
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition Sema.h:9621
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition Sema.h:9627
@ LOLR_Error
The lookup resulted in an error.
Definition Sema.h:9619
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition Sema.h:9624
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition Sema.h:9635
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition Sema.h:9631
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:2710
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition Sema.h:7148
SemaLoongArch & LoongArch()
Definition Sema.h:1538
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:6609
@ CheckValid
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
Definition Sema.h:6614
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
Definition Sema.h:6611
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:14336
void CheckVariableDeclarationType(VarDecl *NewVD)
sema::CompoundScopeInfo & getCurCompoundScope() const
Definition SemaStmt.cpp:454
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:3161
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1331
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
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:726
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:3706
void ActOnFinishOfCompoundStmt()
Definition SemaStmt.cpp:430
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:1805
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:15764
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:8044
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:458
void NoteTemplateParameterLocation(const NamedDecl &Decl)
SemaWasm & Wasm()
Definition Sema.h:1618
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Format, int FormatIdx, int FirstArg)
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
IdentifierResolver IdResolver
Definition Sema.h:3652
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:13918
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 ...
SemaPseudoObject & PseudoObject()
Definition Sema.h:1588
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:2671
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition SemaStmt.cpp:657
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition Sema.h:11653
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:8000
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:734
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:151
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:8544
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition Sema.h:1330
static int getPrintable(int I)
Definition Sema.h:15441
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:926
void ActOnDependentForRangeInitializer(VarDecl *LoopVar, BuildForRangeKind BFRK)
Set the type of a for-range declaration whose for-range or expansion initialiser is dependent.
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
Definition Sema.h:9889
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition Sema.h:13205
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:634
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:4008
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:15446
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:595
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:8416
ForRangeBeginEndInfo BuildCXXForRangeBeginEndVars(Scope *S, VarDecl *RangeVar, SourceLocation ColonLoc, SourceLocation CoawaitLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps, BuildForRangeKind Kind, bool IsConstexpr, StmtResult *RebuildResult=nullptr, llvm::function_ref< StmtResult()> RebuildWithDereference={}, IdentifierInfo *BeginName=nullptr, IdentifierInfo *EndName=nullptr)
Determine begin-expr and end-expr and build variable declarations for them as per [stmt....
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:13933
SemaARM & ARM()
Definition Sema.h:1498
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:13914
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
Definition SemaAttr.cpp:365
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
static const char * getPrintable(const char *S)
Definition Sema.h:15444
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:11217
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:669
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
PragmaMsStackAction
Definition Sema.h:1898
@ PSK_Push_Set
Definition Sema.h:1904
@ PSK_Reset
Definition Sema.h:1899
@ PSK_Pop_Set
Definition Sema.h:1905
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:8884
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
Expr * BuildBuiltinCallExpr(SourceLocation Loc, unsigned Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id with the specified CallArg...
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:13999
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:301
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:343
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1844
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3898
Exposes information about the current target.
Definition TargetInfo.h:228
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.).
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:4816
The top declaration context.
Definition Decl.h:107
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:224
Represents a declaration of a type.
Definition Decl.h:3694
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:8549
The base class of the type hierarchy.
Definition TypeBase.h:1879
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3848
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3743
Simple class containing the result of Sema::CorrectTypo.
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1114
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3373
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4180
A set of unresolved declarations.
The iterator over UnresolvedSets.
Represents a C++ using-declaration.
Definition DeclCXX.h:3638
Represents C++ using-directive.
Definition DeclCXX.h:3143
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3446
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:714
Represents a variable declaration or definition.
Definition Decl.h:934
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:4398
Represents a C++11 virt-specifier-seq.
Definition DeclSpec.h:2904
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:791
Retains information about a captured region.
Definition ScopeInfo.h:817
Contains information about the compound statement currently being parsed.
Definition ScopeInfo.h:67
A collection of diagnostics which were delayed.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
Retains information about a function, method, or block that is currently being parsed.
Definition ScopeInfo.h:104
Provides information about an attempted template argument deduction, whose success or failure was des...
#define UINT_MAX
Definition limits.h:64
Definition SPIR.cpp:47
Enums for the diagnostics of target, target_version and target_clones.
Definition Sema.h:849
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
bool operator==(const ValueType &a, const ValueType &b)
void threadSafetyCleanup(BeforeSet *Cache)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition TokenKinds.h:33
Top level wrappers for InstallAPI frontend operations.
PragmaClangSectionAction
Definition Sema.h:470
TypeSpecifierType
Specifies the kind of type.
Definition Specifiers.h:56
ImplicitTypenameContext
Definition DeclSpec.h:1983
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
OverloadKind
Definition Sema.h:817
@ NonFunction
This is not an overload because the lookup results contain a non-function.
Definition Sema.h:828
@ Match
This is not an overload because the signature exactly matches an existing declaration.
Definition Sema.h:824
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition Sema.h:820
bool isa(CodeGen::Address addr)
Definition Address.h:330
OpaquePtr< TemplateName > ParsedTemplateTy
Definition Ownership.h:256
@ CPlusPlus
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
Definition Ownership.h:263
VariadicCallType
Definition Sema.h:507
FunctionEffectMode
Used with attributes/effects with a boolean condition, e.g. nonblocking.
Definition Sema.h:453
CUDAFunctionTarget
Definition Cuda.h:65
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:785
@ Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition Sema.h:793
PragmaMSCommentKind
Definition PragmaKinds.h:14
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition Specifiers.h:36
ArrayRef< IdentifierLoc > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
TryCaptureKind
Definition Sema.h:647
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition Specifiers.h:40
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition Sema.h:655
@ BitwiseOp
A bitwise operation.
Definition Sema.h:659
@ Arithmetic
An arithmetic operation.
Definition Sema.h:657
@ Conditional
A conditional (?:) operator.
Definition Sema.h:663
@ CompAssign
A compound assignment expression.
Definition Sema.h:665
@ Comparison
A comparison.
Definition Sema.h:661
NullabilityKind
Describes the nullability of a particular type.
Definition Specifiers.h:350
InClassInitStyle
In-class initialization styles for non-static data members.
Definition Specifiers.h:275
@ Success
Annotation was successful.
Definition Parser.h:65
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
CXXConstructionKind
Definition ExprCXX.h:1545
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition Specifiers.h:153
PointerAuthDiscArgKind
Definition Sema.h:588
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h:598
@ TemplateTemplateArgument
Definition Sema.h:607
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
Definition Overload.h:84
NonTrivialCUnionContext
Definition Sema.h:526
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition Sema.h:622
@ Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition Sema.h:630
@ OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition Sema.h:636
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition Sema.h:627
@ ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition Sema.h:633
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:243
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:919
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition Specifiers.h:127
@ AS_none
Definition Specifiers.h:131
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:252
void inferNoReturnAttr(Sema &S, Decl *D)
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition Overload.h:931
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
Definition Parser.h:142
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:41
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:2948
@ CopyInit
[a = b], [a = {b}]
Definition DeclSpec.h:2950
@ 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:472
@ Undefined
Keep undefined.
@ Result
The result type of a method or function.
Definition TypeBase.h:906
ActionResult< ParsedType > TypeResult
Definition Ownership.h:251
OffsetOfKind
Definition Sema.h:610
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3817
SmallVector< ImplicitAllocationArguments, 3 > AllocationArgumentSet
Definition Sema.h:230
CorrectTypoKind
Definition Sema.h:812
ActionResult< CXXCtorInitializer * > MemInitResult
Definition Ownership.h:253
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isFunctionOrMethodVariadic(const Decl *D)
Definition Attr.h:150
@ 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:683
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition Sema.h:706
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition Sema.h:781
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition Sema.h:698
@ 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
@ CompatibleOBTDiscards
CompatibleOBTDiscards - Assignment discards overflow behavior.
Definition Sema.h:777
@ IncompatibleOBTKinds
IncompatibleOBTKinds - Assigning between incompatible OverflowBehaviorType kinds, e....
Definition Sema.h:774
@ CompatibleVoidPtrToNonVoidPtr
CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because a void * can implicitly convert...
Definition Sema.h:690
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition Sema.h:732
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition Sema.h:727
@ 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:685
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition Sema.h:717
@ IncompatiblePointerDiscardsOverflowBehavior
IncompatiblePointerDiscardsOverflowBehavior - The assignment discards overflow behavior annotations b...
Definition Sema.h:737
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition Sema.h:694
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition Sema.h:702
@ 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:711
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition Sema.h:723
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition Sema.h:761
TagUseKind
Definition Sema.h:445
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
Definition LangOptions.h:39
PragmaClangSectionKind
pragma clang section kind
Definition Sema.h:461
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:6171
TUFragmentKind
Definition Sema.h:481
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...
@ On
Always emit colors regardless of the output stream.
NameClassificationKind
Describes the result of the name lookup and resolution performed by Sema::ClassifyName().
Definition Sema.h:549
@ FunctionTemplate
The name was classified as a function template name.
Definition Sema.h:581
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:556
@ DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition Sema.h:570
@ UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition Sema.h:583
@ NonType
The name was classified as a specific non-type, non-template declaration.
Definition Sema.h:562
@ Unknown
This name is not a type or template in this context, but might be something else.
Definition Sema.h:552
@ Error
Classification failed; an error has been produced.
Definition Sema.h:554
@ Type
The name was classified as a type.
Definition Sema.h:558
@ TypeTemplate
The name was classified as a template whose specializations are types.
Definition Sema.h:577
@ Concept
The name was classified as a concept name.
Definition Sema.h:585
@ OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition Sema.h:575
@ UndeclaredNonType
The name was classified as an ADL-only function name.
Definition Sema.h:566
@ VarTemplate
The name was classified as a variable template name.
Definition Sema.h:579
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition Decl.h:2053
LangAS
Defines the address space values used by the address space qualifier of QualType.
FormatStringType
Definition Sema.h:493
CastKind
CastKind - The kind of operation required for a conversion.
unsigned getFunctionOrMethodNumParams(const Decl *D, bool IncludeThis=false)
getFunctionOrMethodNumParams - Return number of function or method parameters, optionally including t...
Definition Attr.h:66
AllowFoldKind
Definition Sema.h:649
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:670
PragmaMSStructKind
Definition PragmaKinds.h:24
AssignmentAction
Definition Sema.h:217
@ Deduced
The normal deduced case.
Definition TypeBase.h:1818
CXXSpecialMemberKind
Kinds of C++ special members.
Definition Decl.h:2031
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:515
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:164
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition Lambda.h:22
PragmaFloatControlKind
Definition PragmaKinds.h:29
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition Specifiers.h:136
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:139
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition ASTContext.h:147
TypeAwareAllocationMode
Definition ExprCXX.h:2256
ConversionAction
@ CA_ToLiteralEncoding
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition Sema.h:797
@ Exists
The symbol exists.
Definition Sema.h:799
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:802
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition Specifiers.h:414
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
Definition Attr.h:56
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
TPOC
The context in which partial ordering of function templates occurs.
Definition Template.h:310
TrivialABIHandling
Definition Sema.h:639
@ ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition Sema.h:644
@ IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition Sema.h:641
TemplateDeductionResult
Describes the result of template argument deduction.
Definition Sema.h:374
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
Definition Sema.h:424
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
Definition Sema.h:419
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
Definition Sema.h:422
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
Definition Sema.h:395
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
Definition Sema.h:381
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
Definition Sema.h:417
@ CUDATargetMismatch
CUDA Target attributes do not match.
Definition Sema.h:426
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
Definition Sema.h:414
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
Definition Sema.h:384
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
Definition Sema.h:398
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
Definition Sema.h:387
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Definition Sema.h:401
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
Definition Sema.h:390
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
Definition Sema.h:411
@ AlreadyDiagnosed
Some error which was already diagnosed.
Definition Sema.h:428
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
Definition Sema.h:405
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
Definition Sema.h:408
PostfixOperatorKind
Kinds of defaulted postfix increment and decrement operator functions (C++2d [over....
Definition Decl.h:2043
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition Specifiers.h:192
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:282
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:218
CCEKind
Contexts in which a converted constant expression is required.
Definition Sema.h:832
@ CaseValue
Expression in a case label.
Definition Sema.h:833
@ StaticAssertMessageData
Call to data() in a static assert message.
Definition Sema.h:843
@ Enumerator
Enumerator value with fixed underlying type.
Definition Sema.h:834
@ StaticAssertMessageSize
Call to size() in a static assert message.
Definition Sema.h:841
@ Noexcept
Condition in a noexcept(bool) specifier.
Definition Sema.h:840
@ ArrayBound
Array bound in array declarator or new-expression.
Definition Sema.h:838
@ TempArgStrict
As above, but applies strict template checking rules.
Definition Sema.h:836
@ PackIndex
Index of a pack indexing expression or specifier.
Definition Sema.h:845
@ ExplicitBool
Condition in an explicit(bool) specifier.
Definition Sema.h:839
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:5082
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:6146
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6157
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6160
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:6164
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h:2250
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:2058
CheckedConversionKind
The kind of conversion being performed.
Definition Sema.h:432
@ Implicit
An implicit conversion.
Definition Sema.h:434
@ CStyleCast
A C-style cast.
Definition Sema.h:436
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
Definition Sema.h:442
@ OtherCast
A cast other than a C-style cast.
Definition Sema.h:440
@ FunctionalCast
A functional-style cast.
Definition Sema.h:438
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition Specifiers.h:177
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
int const char * function
Definition c++config.h:31
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 unsigned
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t int64_t
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
int32_t uint32_t uint32_t __builtin_riscv_mhracc_i32 __builtin_riscv_mhraccu_u32 __builtin_riscv_mhraccsu_i32 __builtin_riscv_mhacc_h1_i32 __builtin_riscv_mhaccsu_h1_i32 __builtin_riscv_mulqr_i32 __builtin_riscv_mqrwacc_i64 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
#define false
Definition stdbool.h:26
#define true
Definition stdbool.h:25
Selector diagnostic state for all API notes readers used by one Sema.
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:247
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition Sema.h:254
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition Sema.h:250
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition Sema.h:260
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition Sema.h:257
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h:5285
Holds information about the various types of exception specification.
Definition TypeBase.h:5605
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5607
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5610
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5613
Extra information about a function prototype.
Definition TypeBase.h:5633
Represents a complete lambda introducer.
Definition DeclSpec.h:2956
Contains a late templated function.
Definition Sema.h:16145
FPOptions FPO
Floating-point options in the point of definition.
Definition Sema.h:16150
Decl * D
The template function declaration to be late parsed.
Definition Sema.h:16148
The part of a late-parsed type attribute that Sema reads and fills in during type construction.
Definition DeclSpec.h:256
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:935
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation CurrentPragmaLocation
Definition Sema.h:2111
static BoundsAttrFlags get(AttributeCommonInfo::Kind K)
Return the flags for a bounds attribute of kind K.
bool SuppressUserConversions
Do not consider any user-defined conversions when constructing the initializing sequence.
Definition Sema.h:10762
bool OnlyInitializeNonUserDefinedConversions
Before constructing the initializing sequence, we check whether the parameter type and argument type ...
Definition Sema.h:10769
CheckNonDependentConversionsFlag(bool SuppressUserConversions, bool OnlyInitializeNonUserDefinedConversions)
Definition Sema.h:10771
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
Definition Sema.h:12297
bool MatchingTTP
If true, assume these template arguments are the injected template arguments for a template template ...
Definition Sema.h:12293
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &)=delete
CheckTemplateArgumentInfo(bool PartialOrdering=false, bool MatchingTTP=false)
Definition Sema.h:12274
bool PartialOrdering
The check is being performed in the context of partial ordering.
Definition Sema.h:12286
SmallVector< TemplateArgument, 4 > SugaredConverted
The checked, converted argument will be added to the end of these vectors.
Definition Sema.h:12283
SmallVector< TemplateArgument, 4 > CanonicalConverted
Definition Sema.h:12283
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:13413
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition Sema.h:13584
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool InParameterMappingSubstitution
Whether we're substituting into the parameter mapping of a constraint.
Definition Sema.h:13541
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition Sema.h:13557
ArrayRef< TemplateArgument > template_arguments() const
Definition Sema.h:13576
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition Sema.h:13552
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition Sema.h:13544
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition Sema.h:13570
bool InConstraintSubstitution
Whether we're substituting into constraints.
Definition Sema.h:13538
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition Sema.h:13560
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition Sema.h:13567
SynthesisKind
The kind of template instantiation we are performing.
Definition Sema.h:13415
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition Sema.h:13504
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition Sema.h:13425
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition Sema.h:13434
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition Sema.h:13453
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition Sema.h:13501
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition Sema.h:13461
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition Sema.h:13468
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition Sema.h:13508
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition Sema.h:13479
@ Memoization
Added for Template instantiation observation.
Definition Sema.h:13514
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13444
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition Sema.h:13520
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition Sema.h:13517
@ PartialOrderingTTP
We are performing partial ordering for template template parameters.
Definition Sema.h:13523
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition Sema.h:13441
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition Sema.h:13449
@ SYCLKernelLaunchOverloadResolution
We are performing overload resolution for a call to a function template or variable template named 's...
Definition Sema.h:13531
@ ExpansionStmtInstantiation
We are instantiating an expansion statement.
Definition Sema.h:13534
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition Sema.h:13457
@ TemplateInstantiation
We are instantiating a template declaration.
Definition Sema.h:13418
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition Sema.h:13471
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition Sema.h:13475
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition Sema.h:13430
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition Sema.h:13498
@ SYCLKernelLaunchLookup
We are performing name lookup for a function template or variable template named 'sycl_kernel_launch'...
Definition Sema.h:13527
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition Sema.h:13464
Decl * Entity
The entity that is being synthesized.
Definition Sema.h:13547
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition Sema.h:13573
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:7065
Data structure used to record current or nested expression evaluation contexts.
Definition Sema.h:6966
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:6999
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition Sema.h:7001
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition Sema.h:7052
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition Sema.h:6986
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:6995
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition Sema.h:7006
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:7014
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition Sema.h:7010
bool IsCaseExpr
Whether evaluating an expression for a switch case label.
Definition Sema.h:7055
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition Sema.h:7020
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:6981
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition Sema.h:7028
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition Sema.h:7058
SmallVector< MisalignedMember, 4 > MisalignedMembers
Small set of gathered accesses to potentially misaligned members due to the packed attribute.
Definition Sema.h:7024
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition Sema.h:6971
VarDecl * DeclForInitializer
Declaration for initializer if one is currently being parsed.
Definition Sema.h:6991
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition Sema.h:7075
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition Sema.h:7077
ExpressionEvaluationContext Context
The expression evaluation context.
Definition Sema.h:6968
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition Sema.h:6975
Holds the 'begin' and 'end' variables of a range-based for loop or expansion statement; begin-expr an...
Definition Sema.h:11358
FormatArgumentPassingKind ArgPassingKind
Definition Sema.h:2787
FunctionEffectDiffVector(const FunctionEffectsRef &Old, const FunctionEffectsRef &New)
Caller should short-circuit by checking for equality first.
std::optional< FunctionEffectWithCondition > Old
Definition Sema.h:16005
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:16009
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:16017
std::optional< FunctionEffectWithCondition > New
Definition Sema.h:16007
FunctionEffect::Kind EffectKind
Definition Sema.h:16002
Used for pragma init_seg.
Definition Sema.h:2160
SourceLocation PragmaLocation
Definition Sema.h:2161
StringLiteral * Segment
Definition Sema.h:2162
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition Sema.h:13760
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:14069
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition Sema.h:14072
bool isMoveEligible() const
Definition Sema.h:11412
bool isCopyElidable() const
Definition Sema.h:11413
const VarDecl * Candidate
Definition Sema.h:11407
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition Sema.h:3466
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition Sema.h:3475
SourceLocation IdentifierLoc
The location of the identifier.
Definition Sema.h:3469
SourceLocation CCLoc
The location of the '::'.
Definition Sema.h:3472
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition Sema.h:3463
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition Sema.h:3481
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition Sema.h:12919
Information from a C++ pragma export, for a symbol that we haven't seen the declaration for yet.
Definition Sema.h:2408
This an attribute introduced by #pragma clang attribute.
Definition Sema.h:2174
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition Sema.h:2177
A push'd group of PragmaAttributeEntries.
Definition Sema.h:2182
SourceLocation Loc
The location of the push attribute.
Definition Sema.h:2184
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition Sema.h:2187
const IdentifierInfo * Namespace
The namespace of this push group.
Definition Sema.h:2186
SourceLocation PragmaLocation
Definition Sema.h:1889
PragmaMsStackAction Action
Definition Sema.h:1909
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition Sema.h:2022
llvm::StringRef StackSlotLabel
Definition Sema.h:2018
SourceLocation PragmaLocation
Definition Sema.h:2020
SourceLocation PragmaPushLocation
Definition Sema.h:2021
ValueType CurrentValue
Definition Sema.h:2092
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition Sema.h:2078
bool hasValue() const
Definition Sema.h:2088
SmallVector< Slot, 2 > Stack
Definition Sema.h:2090
ValueType DefaultValue
Definition Sema.h:2091
SourceLocation CurrentPragmaLocation
Definition Sema.h:2093
PragmaStack(const ValueType &Default)
Definition Sema.h:2085
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition Sema.h:2029
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition Sema.h:5314
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition Sema.h:5308
RecursiveInstGuard(Sema &S, Decl *D, Kind Kind)
Definition Sema.h:13385
RecursiveInstGuard(const RecursiveInstGuard &)=delete
RecursiveInstGuard & operator=(const RecursiveInstGuard &)=delete
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition Sema.h:10659
SFINAEContextBase & operator=(const SFINAEContextBase &)=delete
SFINAEContextBase(Sema &S, SFINAETrap *Cur)
Definition Sema.h:12728
SFINAEContextBase(const SFINAEContextBase &)=delete
Abstract class used to diagnose incomplete types.
Definition Sema.h:8477
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition Sema.h:2829
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition Sema.h:2838
bool CheckSameAsPrevious
Definition Sema.h:360
NamedDecl * Previous
Definition Sema.h:361
SkipBodyInfo()=default
NamedDecl * New
Definition Sema.h:362
Information about a template-id annotation token.