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"
58#include "clang/Sema/Attr.h"
60#include "clang/Sema/DeclSpec.h"
66#include "clang/Sema/Scope.h"
67#include "clang/Sema/SemaBase.h"
70#include "clang/Sema/Weak.h"
71#include "llvm/ADT/APInt.h"
72#include "llvm/ADT/ArrayRef.h"
73#include "llvm/ADT/BitmaskEnum.h"
74#include "llvm/ADT/DenseMap.h"
75#include "llvm/ADT/DenseSet.h"
76#include "llvm/ADT/FloatingPointMode.h"
77#include "llvm/ADT/FoldingSet.h"
78#include "llvm/ADT/MapVector.h"
79#include "llvm/ADT/PointerIntPair.h"
80#include "llvm/ADT/PointerUnion.h"
81#include "llvm/ADT/STLExtras.h"
82#include "llvm/ADT/STLForwardCompat.h"
83#include "llvm/ADT/STLFunctionalExtras.h"
84#include "llvm/ADT/SetVector.h"
85#include "llvm/ADT/SmallBitVector.h"
86#include "llvm/ADT/SmallPtrSet.h"
87#include "llvm/ADT/SmallSet.h"
88#include "llvm/ADT/SmallVector.h"
89#include "llvm/ADT/StringExtras.h"
90#include "llvm/ADT/StringMap.h"
91#include "llvm/ADT/TinyPtrVector.h"
92#include "llvm/Support/Allocator.h"
93#include "llvm/Support/Compiler.h"
94#include "llvm/Support/Error.h"
95#include "llvm/Support/ErrorHandling.h"
96#include <cassert>
97#include <climits>
98#include <cstddef>
99#include <cstdint>
100#include <deque>
101#include <functional>
102#include <iterator>
103#include <memory>
104#include <optional>
105#include <string>
106#include <tuple>
107#include <type_traits>
108#include <utility>
109#include <vector>
110
111namespace llvm {
112struct InlineAsmIdentifierInfo;
113} // namespace llvm
114
115namespace clang {
116class ADLResult;
117class APValue;
119class ASTConsumer;
120class ASTContext;
121class ASTDeclReader;
123class ASTReader;
124class ASTWriter;
125class CXXBasePath;
126class CXXBasePaths;
129enum class ComparisonCategoryType : unsigned char;
131class DarwinSDKInfo;
132class DeclGroupRef;
136class Designation;
137class IdentifierInfo;
144enum class LangAS : unsigned int;
146class LookupResult;
149class ModuleLoader;
153class ObjCMethodDecl;
154struct OverloadCandidate;
155enum class OverloadCandidateParamOrder : char;
156enum OverloadCandidateRewriteKind : unsigned;
158class Preprocessor;
160struct ResolvedAllocation;
161class SemaAMDGPU;
162class SemaARM;
163class SemaAVR;
164class SemaBPF;
166class SemaCUDA;
167class SemaDirectX;
168class SemaHLSL;
169class SemaHexagon;
170class SemaLoongArch;
171class SemaM68k;
172class SemaMIPS;
173class SemaMSP430;
174class SemaNVPTX;
175class SemaObjC;
176class SemaOpenACC;
177class SemaOpenCL;
178class SemaOpenMP;
179class SemaPPC;
180class SemaPseudoObject;
181class SemaRISCV;
182class SemaSPIRV;
183class SemaSYCL;
184class SemaSwift;
185class SemaSystemZ;
186class SemaWasm;
187class SemaX86;
189class TemplateArgument;
191class TemplateInstantiationCallback;
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
1151public:
1152 /// Returns true if a comment at \p Loc should be retained in the AST
1153 /// (some consumer such as -Wdocumentation, -fparse-all-comments, code
1154 /// completion, or AST-file serialization may read it back).
1156
1157 /// Retrieve the parser's current scope.
1158 ///
1159 /// This routine must only be used when it is certain that semantic analysis
1160 /// and the parser are in precisely the same context, which is not the case
1161 /// when, e.g., we are performing any kind of template instantiation.
1162 /// Therefore, the only safe places to use this scope are in the parser
1163 /// itself and in routines directly invoked from the parser and *never* from
1164 /// template substitution or instantiation.
1165 Scope *getCurScope() const { return CurScope; }
1166
1168
1172
1173 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
1174 const FunctionDecl *FD = nullptr);
1176 const PartialDiagnostic &PD,
1177 const FunctionDecl *FD = nullptr) {
1178 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
1179 }
1180
1181 /// Check if the type is allowed to be used for the current target.
1183 ValueDecl *D = nullptr);
1184
1185 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
1186 /// cast. If there is already an implicit cast, merge into the existing one.
1187 /// If isLvalue, the result of the cast is an lvalue.
1190 const CXXCastPath *BasePath = nullptr,
1192
1193 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
1194 /// to the conversion from scalar type ScalarTy to the Boolean type.
1196
1197 /// If \p AllowLambda is true, treat lambda as function.
1198 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
1199
1200 /// Returns a pointer to the innermost enclosing function, or nullptr if the
1201 /// current context is not inside a function. If \p AllowLambda is true,
1202 /// this can return the call operator of an enclosing lambda, otherwise
1203 /// lambdas are skipped when looking for an enclosing function.
1204 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
1205
1206 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
1207 /// the method decl for the method being parsed. If we're currently
1208 /// in a 'block', this returns the containing context.
1210
1211 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
1212 /// or C function we're in, otherwise return null. If we're currently
1213 /// in a 'block', this returns the containing context.
1215
1216 /// Warn if we're implicitly casting from a _Nullable pointer type to a
1217 /// _Nonnull one.
1219 SourceLocation Loc);
1220
1221 /// Warn when implicitly casting 0 to nullptr.
1222 void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
1223
1224 /// Warn when implicitly changing function effects.
1226 SourceLocation Loc);
1227
1228 /// makeUnavailableInSystemHeader - There is an error in the current
1229 /// context. If we're still in a system header, and we can plausibly
1230 /// make the relevant declaration unavailable instead of erroring, do
1231 /// so and return true.
1233 UnavailableAttr::ImplicitReason reason);
1234
1235 /// Retrieve a suitable printing policy for diagnostics.
1239
1240 /// Retrieve a suitable printing policy for diagnostics.
1242 const Preprocessor &PP);
1243
1244 /// Scope actions.
1246
1247 /// Determine whether \param D is function like (function or function
1248 /// template) for parsing.
1250
1251 /// The maximum alignment, same as in llvm::Value. We duplicate them here
1252 /// because that allows us not to duplicate the constants in clang code,
1253 /// which we must to since we can't directly use the llvm constants.
1254 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
1255 ///
1256 /// This is the greatest alignment value supported by load, store, and alloca
1257 /// instructions, and global values.
1258 static const unsigned MaxAlignmentExponent = 32;
1259 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
1260
1261 /// Flag indicating whether or not to collect detailed statistics.
1263
1264 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
1265
1266 /// Stack containing information about each of the nested
1267 /// function, block, and method scopes that are currently active.
1269
1270 /// The index of the first FunctionScope that corresponds to the current
1271 /// context.
1273
1274 /// Track the number of currently active capturing scopes.
1276
1277 llvm::BumpPtrAllocator BumpAlloc;
1278
1279 /// The kind of translation unit we are processing.
1280 ///
1281 /// When we're processing a complete translation unit, Sema will perform
1282 /// end-of-translation-unit semantic tasks (such as creating
1283 /// initializers for tentative definitions in C) once parsing has
1284 /// completed. Modules and precompiled headers perform different kinds of
1285 /// checks.
1287
1288 /// Translation Unit Scope - useful to Objective-C actions that need
1289 /// to lookup file scope declarations in the "ordinary" C decl namespace.
1290 /// For example, user-defined classes, built-in "id" type, etc.
1292
1294 return CurScope->incrementMSManglingNumber();
1295 }
1296
1297 /// Try to recover by turning the given expression into a
1298 /// call. Returns true if recovery was attempted or an error was
1299 /// emitted; this may also leave the ExprResult invalid.
1301 bool ForceComplain = false,
1302 bool (*IsPlausibleResult)(QualType) = nullptr);
1303
1304 // Adds implicit lifetime bound attribute for implicit this to its
1305 // TypeSourceInfo.
1307
1308 /// Figure out if an expression could be turned into a call.
1309 ///
1310 /// Use this when trying to recover from an error where the programmer may
1311 /// have written just the name of a function instead of actually calling it.
1312 ///
1313 /// \param E - The expression to examine.
1314 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
1315 /// with no arguments, this parameter is set to the type returned by such a
1316 /// call; otherwise, it is set to an empty QualType.
1317 /// \param OverloadSet - If the expression is an overloaded function
1318 /// name, this parameter is populated with the decls of the various
1319 /// overloads.
1320 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
1321 UnresolvedSetImpl &NonTemplateOverloads);
1322
1326
1329
1337
1338 std::unique_ptr<APINotesSelectorDiagnosticState> APINotesSelectorDiagnostics;
1339
1340 /// A RAII object to enter scope of a compound statement.
1342 public:
1343 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
1344 S.ActOnStartOfCompoundStmt(IsStmtExpr);
1345 }
1346
1347 ~CompoundScopeRAII() { S.ActOnFinishOfCompoundStmt(); }
1350
1351 private:
1352 Sema &S;
1353 };
1354
1355 /// An RAII helper that pops function a function scope on exit.
1361 if (Active)
1362 S.PopFunctionScopeInfo();
1363 }
1364 void disable() { Active = false; }
1365 };
1366
1368 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
1369 }
1370
1371 /// Worker object for performing CFG-based warnings.
1374
1375 /// Callback to the parser to parse templated functions when needed.
1376 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
1379
1381 LateTemplateParser = LTP;
1382 OpaqueParser = P;
1383 }
1384
1385 /// Callback to the parser to parse a type expressed as a string.
1386 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
1388
1389 /// VAListTagName - The declaration name corresponding to __va_list_tag.
1390 /// This is used as part of a hack to omit that class from ADL results.
1392
1393 /// Is the last error level diagnostic immediate. This is used to determined
1394 /// whether the next info diagnostic should be immediate.
1396
1397 /// Track if we're currently analyzing overflow behavior types in assignment
1398 /// context.
1400
1401 class DelayedDiagnostics;
1402
1404 sema::DelayedDiagnosticPool *SavedPool = nullptr;
1406 };
1409
1410 /// A class which encapsulates the logic for delaying diagnostics
1411 /// during parsing and other processing.
1413 /// The current pool of diagnostics into which delayed
1414 /// diagnostics should go.
1415 sema::DelayedDiagnosticPool *CurPool = nullptr;
1416
1417 public:
1419
1420 /// Adds a delayed diagnostic.
1421 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
1422
1423 /// Determines whether diagnostics should be delayed.
1424 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
1425
1426 /// Returns the current delayed-diagnostics pool.
1427 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1428
1429 /// Enter a new scope. Access and deprecation diagnostics will be
1430 /// collected in this pool.
1433 state.SavedPool = CurPool;
1434 CurPool = &pool;
1435 return state;
1436 }
1437
1438 /// Leave a delayed-diagnostic state that was previously pushed.
1439 /// Do not emit any of the diagnostics. This is performed as part
1440 /// of the bookkeeping of popping a pool "properly".
1442 CurPool = state.SavedPool;
1443 }
1444
1445 /// Enter a new scope where access and deprecation diagnostics are
1446 /// not delayed.
1449 state.SavedPool = CurPool;
1450 CurPool = nullptr;
1451 return state;
1452 }
1453
1454 /// Undo a previous pushUndelayed().
1456 assert(CurPool == nullptr);
1457 CurPool = state.SavedPool;
1458 }
1460
1464
1465 /// Diagnostics that are emitted only if we discover that the given function
1466 /// must be codegen'ed. Because handling these correctly adds overhead to
1467 /// compilation, this is currently only used for offload languages like CUDA,
1468 /// OpenMP, and SYCL.
1469 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1470
1471 /// CurContext - This is the current declaration context of parsing.
1473
1475 assert(AMDGPUPtr);
1476 return *AMDGPUPtr;
1477 }
1478
1480 assert(ARMPtr);
1481 return *ARMPtr;
1482 }
1483
1485 assert(AVRPtr);
1486 return *AVRPtr;
1487 }
1488
1490 assert(BPFPtr);
1491 return *BPFPtr;
1492 }
1493
1495 assert(CodeCompletionPtr);
1496 return *CodeCompletionPtr;
1497 }
1498
1500 assert(CUDAPtr);
1501 return *CUDAPtr;
1502 }
1503
1505 assert(DirectXPtr);
1506 return *DirectXPtr;
1507 }
1508
1510 assert(HLSLPtr);
1511 return *HLSLPtr;
1512 }
1513
1515 assert(HexagonPtr);
1516 return *HexagonPtr;
1517 }
1518
1520 assert(LoongArchPtr);
1521 return *LoongArchPtr;
1522 }
1523
1525 assert(M68kPtr);
1526 return *M68kPtr;
1527 }
1528
1530 assert(MIPSPtr);
1531 return *MIPSPtr;
1532 }
1533
1535 assert(MSP430Ptr);
1536 return *MSP430Ptr;
1537 }
1538
1540 assert(NVPTXPtr);
1541 return *NVPTXPtr;
1542 }
1543
1545 assert(ObjCPtr);
1546 return *ObjCPtr;
1547 }
1548
1550 assert(OpenACCPtr);
1551 return *OpenACCPtr;
1552 }
1553
1555 assert(OpenCLPtr);
1556 return *OpenCLPtr;
1557 }
1558
1560 assert(OpenMPPtr && "SemaOpenMP is dead");
1561 return *OpenMPPtr;
1562 }
1563
1565 assert(PPCPtr);
1566 return *PPCPtr;
1567 }
1568
1570 assert(PseudoObjectPtr);
1571 return *PseudoObjectPtr;
1572 }
1573
1575 assert(RISCVPtr);
1576 return *RISCVPtr;
1577 }
1578
1580 assert(SPIRVPtr);
1581 return *SPIRVPtr;
1582 }
1583
1585 assert(SYCLPtr);
1586 return *SYCLPtr;
1587 }
1588
1590 assert(SwiftPtr);
1591 return *SwiftPtr;
1592 }
1593
1595 assert(SystemZPtr);
1596 return *SystemZPtr;
1597 }
1598
1600 assert(WasmPtr);
1601 return *WasmPtr;
1602 }
1603
1605 assert(X86Ptr);
1606 return *X86Ptr;
1607 }
1608
1609 /// Source of additional semantic information.
1611
1612protected:
1613 friend class Parser;
1615 friend class ASTReader;
1616 friend class ASTDeclReader;
1617 friend class ASTWriter;
1618
1619private:
1620 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1621 bool WarnedDarwinSDKInfoMissing = false;
1622
1623 StackExhaustionHandler StackHandler;
1624
1625 Sema(const Sema &) = delete;
1626 void operator=(const Sema &) = delete;
1627
1628 /// The handler for the FileChanged preprocessor events.
1629 ///
1630 /// Used for diagnostics that implement custom semantic analysis for #include
1631 /// directives, like -Wpragma-pack.
1632 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1633
1634 /// The parser's current scope.
1635 ///
1636 /// The parser maintains this state here.
1637 Scope *CurScope;
1638
1639 mutable IdentifierInfo *Ident_super;
1640
1641 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1642 std::unique_ptr<SemaARM> ARMPtr;
1643 std::unique_ptr<SemaAVR> AVRPtr;
1644 std::unique_ptr<SemaBPF> BPFPtr;
1645 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1646 std::unique_ptr<SemaCUDA> CUDAPtr;
1647 std::unique_ptr<SemaDirectX> DirectXPtr;
1648 std::unique_ptr<SemaHLSL> HLSLPtr;
1649 std::unique_ptr<SemaHexagon> HexagonPtr;
1650 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1651 std::unique_ptr<SemaM68k> M68kPtr;
1652 std::unique_ptr<SemaMIPS> MIPSPtr;
1653 std::unique_ptr<SemaMSP430> MSP430Ptr;
1654 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1655 std::unique_ptr<SemaObjC> ObjCPtr;
1656 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1657 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1658 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1659 std::unique_ptr<SemaPPC> PPCPtr;
1660 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1661 std::unique_ptr<SemaRISCV> RISCVPtr;
1662 std::unique_ptr<SemaSPIRV> SPIRVPtr;
1663 std::unique_ptr<SemaSYCL> SYCLPtr;
1664 std::unique_ptr<SemaSwift> SwiftPtr;
1665 std::unique_ptr<SemaSystemZ> SystemZPtr;
1666 std::unique_ptr<SemaWasm> WasmPtr;
1667 std::unique_ptr<SemaX86> X86Ptr;
1668
1669 ///@}
1670
1671 //
1672 //
1673 // -------------------------------------------------------------------------
1674 //
1675 //
1676
1677 /// \name API Notes
1678 /// Implementations are in SemaAPINotes.cpp
1679 ///@{
1680
1681public:
1682 /// Map any API notes provided for this declaration to attributes on the
1683 /// declaration.
1684 ///
1685 /// Triggered by declaration-attribute processing.
1686 void ProcessAPINotes(Decl *D);
1687 /// Apply the 'Nullability:' annotation to the specified declaration
1688 void ApplyNullability(Decl *D, NullabilityKind Nullability);
1689 /// Apply the 'Type:' annotation to the specified declaration
1690 void ApplyAPINotesType(Decl *D, StringRef TypeString);
1691
1692 /// Diagnose exact API notes selectors that were not matched by any
1693 /// declaration processed in this translation unit.
1695
1696 /// Whether APINotes should be gathered for all applicable Swift language
1697 /// versions, without being applied. Leaving clients of the current module
1698 /// to select and apply the correct version.
1700 return APINotes.captureVersionIndependentSwift();
1701 }
1702 ///@}
1703
1704 //
1705 //
1706 // -------------------------------------------------------------------------
1707 //
1708 //
1709
1710 /// \name C++ Access Control
1711 /// Implementations are in SemaAccess.cpp
1712 ///@{
1713
1714public:
1721
1722 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1723 /// Returns true on error (when the previous member decl access specifier
1724 /// is different from the new member decl access specifier).
1725 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1726 NamedDecl *PrevMemberDecl,
1727 AccessSpecifier LexicalAS);
1728
1729 /// Perform access-control checking on a previously-unresolved member
1730 /// access which has now been resolved to a member.
1732 DeclAccessPair FoundDecl);
1734 DeclAccessPair FoundDecl);
1735
1736 /// Checks access to an overloaded operator new or delete.
1738 SourceRange PlacementRange,
1739 CXXRecordDecl *NamingClass,
1740 DeclAccessPair FoundDecl,
1741 bool Diagnose = true);
1742
1743 /// Checks access to a constructor.
1745 DeclAccessPair FoundDecl,
1746 const InitializedEntity &Entity,
1747 bool IsCopyBindingRefToTemp = false);
1748
1749 /// Checks access to a constructor.
1751 DeclAccessPair FoundDecl,
1752 const InitializedEntity &Entity,
1753 const PartialDiagnostic &PDiag);
1755 CXXDestructorDecl *Dtor,
1756 const PartialDiagnostic &PDiag,
1757 QualType objectType = QualType());
1758
1759 /// Checks access to the target of a friend declaration.
1761
1762 /// Checks access to a member.
1764 CXXRecordDecl *NamingClass,
1766
1767 /// Checks implicit access to a member in a structured binding.
1770 CXXRecordDecl *DecomposedClass,
1771 DeclAccessPair Field);
1773 const SourceRange &,
1774 DeclAccessPair FoundDecl);
1775
1776 /// Checks access to an overloaded member operator, including
1777 /// conversion operators.
1779 Expr *ArgExpr,
1780 DeclAccessPair FoundDecl);
1782 ArrayRef<Expr *> ArgExprs,
1783 DeclAccessPair FoundDecl);
1785 DeclAccessPair FoundDecl);
1786
1787 /// Checks access for a hierarchy conversion.
1788 ///
1789 /// \param ForceCheck true if this check should be performed even if access
1790 /// control is disabled; some things rely on this for semantics
1791 /// \param ForceUnprivileged true if this check should proceed as if the
1792 /// context had no special privileges
1794 QualType Derived, const CXXBasePath &Path,
1795 unsigned DiagID, bool ForceCheck = false,
1796 bool ForceUnprivileged = false);
1797
1799 SourceLocation AccessLoc, CXXRecordDecl *Base, CXXRecordDecl *Derived,
1800 const CXXBasePath &Path, unsigned DiagID,
1801 llvm::function_ref<void(PartialDiagnostic &PD)> SetupPDiag,
1802 bool ForceCheck = false, bool ForceUnprivileged = false);
1803
1804 /// Checks access to all the declarations in the given result set.
1805 void CheckLookupAccess(const LookupResult &R);
1806
1807 /// Checks access to Target from the given class. The check will take access
1808 /// specifiers into account, but no member access expressions and such.
1809 ///
1810 /// \param Target the declaration to check if it can be accessed
1811 /// \param NamingClass the class in which the lookup was started.
1812 /// \param BaseType type of the left side of member access expression.
1813 /// \p BaseType and \p NamingClass are used for C++ access control.
1814 /// Depending on the lookup case, they should be set to the following:
1815 /// - lhs.target (member access without a qualifier):
1816 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1817 /// - lhs.X::target (member access with a qualifier):
1818 /// BaseType is the type of 'lhs', NamingClass is 'X'
1819 /// - X::target (qualified lookup without member access):
1820 /// BaseType is null, NamingClass is 'X'.
1821 /// - target (unqualified lookup).
1822 /// BaseType is null, NamingClass is the parent class of 'target'.
1823 /// \return true if the Target is accessible from the Class, false otherwise.
1824 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1825 QualType BaseType);
1826
1827 /// Is the given member accessible for the purposes of deciding whether to
1828 /// define a special member function as deleted?
1830 DeclAccessPair Found, QualType ObjectType,
1831 SourceLocation Loc,
1832 const PartialDiagnostic &Diag);
1835 QualType ObjectType) {
1836 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1837 SourceLocation(), PDiag());
1838 }
1839
1841 const DependentDiagnostic &DD,
1842 const MultiLevelTemplateArgumentList &TemplateArgs);
1844
1845 ///@}
1846
1847 //
1848 //
1849 // -------------------------------------------------------------------------
1850 //
1851 //
1852
1853 /// \name Attributes
1854 /// Implementations are in SemaAttr.cpp
1855 ///@{
1856
1857public:
1858 /// Controls member pointer representation format under the MS ABI.
1861
1862 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1863
1864 /// Source location for newly created implicit MSInheritanceAttrs
1866
1872
1878
1880 PSK_Reset = 0x0, // #pragma ()
1881 PSK_Set = 0x1, // #pragma (value)
1882 PSK_Push = 0x2, // #pragma (push[, id])
1883 PSK_Pop = 0x4, // #pragma (pop[, id])
1884 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1885 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1886 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1887 };
1888
1894
1895 // #pragma pack and align.
1897 public:
1898 // `Native` represents default align mode, which may vary based on the
1899 // platform.
1900 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1901
1902 // #pragma pack info constructor
1903 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1904 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1905 assert(Num == PackNumber && "The pack number has been truncated.");
1906 }
1907
1908 // #pragma align info constructor
1910 : PackAttr(false), AlignMode(M),
1911 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1912
1913 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1914
1916
1917 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1918 // integer encoding for it. This should only be passed to
1919 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1921 std::uint32_t Encoding{};
1922 if (Info.IsXLStack())
1923 Encoding |= IsXLMask;
1924
1925 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1926
1927 if (Info.IsPackAttr())
1928 Encoding |= PackAttrMask;
1929
1930 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1931
1932 return Encoding;
1933 }
1934
1935 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1936 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1938 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1939 int PackNumber = (Encoding & PackNumMask) >> 4;
1940
1941 if (Encoding & PackAttrMask)
1942 return AlignPackInfo(M, PackNumber, IsXL);
1943
1944 return AlignPackInfo(M, IsXL);
1945 }
1946
1947 bool IsPackAttr() const { return PackAttr; }
1948
1949 bool IsAlignAttr() const { return !PackAttr; }
1950
1951 Mode getAlignMode() const { return AlignMode; }
1952
1953 unsigned getPackNumber() const { return PackNumber; }
1954
1955 bool IsPackSet() const {
1956 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1957 // attriute on a decl.
1958 return PackNumber != UninitPackVal && PackNumber != 0;
1959 }
1960
1961 bool IsXLStack() const { return XLStack; }
1962
1963 bool operator==(const AlignPackInfo &Info) const {
1964 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1965 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1966 Info.XLStack);
1967 }
1968
1969 bool operator!=(const AlignPackInfo &Info) const {
1970 return !(*this == Info);
1971 }
1972
1973 private:
1974 /// \brief True if this is a pragma pack attribute,
1975 /// not a pragma align attribute.
1976 bool PackAttr;
1977
1978 /// \brief The alignment mode that is in effect.
1979 Mode AlignMode;
1980
1981 /// \brief The pack number of the stack.
1982 unsigned char PackNumber;
1983
1984 /// \brief True if it is a XL #pragma align/pack stack.
1985 bool XLStack;
1986
1987 /// \brief Uninitialized pack value.
1988 static constexpr unsigned char UninitPackVal = -1;
1989
1990 // Masks to encode and decode an AlignPackInfo.
1991 static constexpr uint32_t IsXLMask{0x0000'0001};
1992 static constexpr uint32_t AlignModeMask{0x0000'0006};
1993 static constexpr uint32_t PackAttrMask{0x00000'0008};
1994 static constexpr uint32_t PackNumMask{0x0000'01F0};
1995 };
1996
1997 template <typename ValueType> struct PragmaStack {
2009
2010 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
2011 llvm::StringRef StackSlotLabel, ValueType Value) {
2012 if (Action == PSK_Reset) {
2014 CurrentPragmaLocation = PragmaLocation;
2015 return;
2016 }
2017 if (Action & PSK_Push)
2018 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
2019 PragmaLocation);
2020 else if (Action & PSK_Pop) {
2021 if (!StackSlotLabel.empty()) {
2022 // If we've got a label, try to find it and jump there.
2023 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
2024 return x.StackSlotLabel == StackSlotLabel;
2025 });
2026 // If we found the label so pop from there.
2027 if (I != Stack.rend()) {
2028 CurrentValue = I->Value;
2029 CurrentPragmaLocation = I->PragmaLocation;
2030 Stack.erase(std::prev(I.base()), Stack.end());
2031 }
2032 } else if (!Stack.empty()) {
2033 // We do not have a label, just pop the last entry.
2034 CurrentValue = Stack.back().Value;
2035 CurrentPragmaLocation = Stack.back().PragmaLocation;
2036 Stack.pop_back();
2037 }
2038 }
2039 if (Action & PSK_Set) {
2041 CurrentPragmaLocation = PragmaLocation;
2042 }
2043 }
2044
2045 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
2046 // method body to restore the stacks on exit, so it works like this:
2047 //
2048 // struct S {
2049 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
2050 // void Method {}
2051 // #pragma <name>(pop, InternalPragmaSlot)
2052 // };
2053 //
2054 // It works even with #pragma vtordisp, although MSVC doesn't support
2055 // #pragma vtordisp(push [, id], n)
2056 // syntax.
2057 //
2058 // Push / pop a named sentinel slot.
2059 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
2060 assert((Action == PSK_Push || Action == PSK_Pop) &&
2061 "Can only push / pop #pragma stack sentinels!");
2062 Act(CurrentPragmaLocation, Action, Label, CurrentValue);
2063 }
2064
2065 // Constructors.
2066 explicit PragmaStack(const ValueType &Default)
2068
2069 bool hasValue() const { return CurrentValue != DefaultValue; }
2070
2072 ValueType DefaultValue; // Value used for PSK_Reset action.
2073 ValueType CurrentValue;
2075 };
2076 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
2077 // we shouldn't do so if they're in a module).
2078
2079 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
2080 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
2081 ///
2082 /// 0: Suppress all vtordisps
2083 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
2084 /// structors
2085 /// 2: Always insert vtordisps to support RTTI on partially constructed
2086 /// objects
2089 // The current #pragma align/pack values and locations at each #include.
2096 // Segment #pragmas.
2101
2102 // #pragma strict_gs_check.
2104
2105 // This stack tracks the current state of Sema.CurFPFeatures.
2108 FPOptionsOverride result;
2109 if (!FpPragmaStack.hasValue()) {
2110 result = FPOptionsOverride();
2111 } else {
2112 result = FpPragmaStack.CurrentValue;
2113 }
2114 return result;
2115 }
2116
2123
2124 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
2125 // Actions should be performed only if we enter / exit a C++ method body.
2127 public:
2128 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
2133
2134 private:
2135 Sema &S;
2136 StringRef SlotLabel;
2137 bool ShouldAct;
2138 };
2139
2140 /// Last section used with #pragma init_seg.
2143
2144 /// Sections used with #pragma alloc_text.
2145 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
2146
2147 /// VisContext - Manages the stack for \#pragma GCC visibility.
2148 void *VisContext; // Really a "PragmaVisStack*"
2149
2150 /// This an attribute introduced by \#pragma clang attribute.
2157
2158 /// A push'd group of PragmaAttributeEntries.
2160 /// The location of the push attribute.
2162 /// The namespace of this push group.
2165 };
2166
2168
2169 /// The declaration that is currently receiving an attribute from the
2170 /// #pragma attribute stack.
2172
2173 /// This represents the last location of a "#pragma clang optimize off"
2174 /// directive if such a directive has not been closed by an "on" yet. If
2175 /// optimizations are currently "on", this is set to an invalid location.
2177
2178 /// Get the location for the currently active "\#pragma clang optimize
2179 /// off". If this location is invalid, then the state of the pragma is "on".
2183
2184 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
2185 /// whether the optimizations in the list passed to the pragma should be
2186 /// turned off or on. This boolean is true by default because command line
2187 /// options are honored when `#pragma optimize("", on)`.
2188 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
2190
2191 /// Set of no-builtin functions listed by \#pragma function.
2193
2194 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
2195 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
2197
2198 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
2200
2201 /// Add gsl::Pointer attribute to std::container::iterator
2202 /// \param ND The declaration that introduces the name
2203 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
2204 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
2205
2206 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
2208
2209 /// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
2211
2212 /// Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
2214
2215 /// Add [[gsl::Pointer]] attributes for std:: types.
2217
2218 LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
2219 StringRef ParamName);
2220 // Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'
2221 // can be the name of a function parameter, we need to parse the function
2222 // declaration and rest of the parameters before processesing 'X'. Therefore
2223 // do this lazily instead of processing while parsing the annotation itself.
2225
2226 /// Add _Nullable attributes for std:: types.
2228
2229 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
2232 PragmaClangSectionKind SecKind,
2233 StringRef SecName);
2234
2235 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
2237 SourceLocation PragmaLoc);
2238
2239 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
2240 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
2241 StringRef SlotLabel, Expr *Alignment);
2242
2243 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
2244 /// (unless they are value dependent or type dependent). Returns false
2245 /// and emits a diagnostic if one or more of the arguments could not be
2246 /// folded into a constant.
2249
2254
2256 SourceLocation IncludeLoc);
2258
2259 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
2261
2262 /// ActOnPragmaMSComment - Called on well formed
2263 /// \#pragma comment(kind, "arg").
2265 StringRef Arg);
2266
2267 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
2268 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
2269 StringRef Value);
2270
2271 /// Are precise floating point semantics currently enabled?
2273 return !CurFPFeatures.getAllowFPReassociate() &&
2274 !CurFPFeatures.getNoSignedZero() &&
2275 !CurFPFeatures.getAllowReciprocal() &&
2276 !CurFPFeatures.getAllowApproxFunc();
2277 }
2278
2281
2282 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
2283 void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action,
2285
2286 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
2287 /// pointers_to_members(representation method[, general purpose
2288 /// representation]).
2291 SourceLocation PragmaLoc);
2292
2293 /// Called on well formed \#pragma vtordisp().
2294 void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
2296
2297 bool UnifySection(StringRef SectionName, int SectionFlags,
2298 NamedDecl *TheDecl);
2299 bool UnifySection(StringRef SectionName, int SectionFlags,
2300 SourceLocation PragmaSectionLocation);
2301
2302 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
2303 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
2304 PragmaMsStackAction Action,
2305 llvm::StringRef StackSlotLabel,
2306 StringLiteral *SegmentName, llvm::StringRef PragmaName);
2307
2308 /// Called on well formed \#pragma section().
2309 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
2310 StringLiteral *SegmentName);
2311
2312 /// Called on well-formed \#pragma init_seg().
2313 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
2314 StringLiteral *SegmentName);
2315
2316 /// Called on well-formed \#pragma alloc_text().
2318 SourceLocation PragmaLocation, StringRef Section,
2319 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
2320 &Functions);
2321
2322 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
2323 /// strict_gs_check.
2325 PragmaMsStackAction Action,
2326 bool Value);
2327
2328 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
2329 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
2330 SourceLocation PragmaLoc);
2331
2333 SourceLocation PragmaLoc,
2336 const IdentifierInfo *Namespace);
2337
2338 /// Called on well-formed '\#pragma clang attribute pop'.
2340 const IdentifierInfo *Namespace);
2341
2342 /// Adds the attributes that have been specified using the
2343 /// '\#pragma clang attribute push' directives to the given declaration.
2344 void AddPragmaAttributes(Scope *S, Decl *D);
2345
2347 llvm::function_ref<void(SourceLocation, PartialDiagnostic)>;
2349 return [this](SourceLocation Loc, PartialDiagnostic PD) {
2350 // This bypasses a lot of the filters in the diag engine, as it's
2351 // to be used to attach notes to diagnostics which have already
2352 // been filtered through.
2353 DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
2354 PD.Emit(Builder);
2355 };
2356 }
2357
2363
2365
2366 /// Called on well formed \#pragma clang optimize.
2367 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
2368
2369 /// #pragma optimize("[optimization-list]", on | off).
2370 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
2371
2372 /// Call on well formed \#pragma function.
2373 void
2375 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
2376
2378 SourceLocation NameLoc,
2379 Scope *curScope);
2380
2381 /// Information from a C++ #pragma export, for a symbol that we
2382 /// haven't seen the declaration for yet.
2387
2388 llvm::DenseMap<IdentifierInfo *, PendingPragmaInfo> PendingExportedNames;
2389
2390 /// ActonPragmaExport - called on well-formed '\#pragma export'.
2391 void ActOnPragmaExport(IdentifierInfo *IdentId, SourceLocation ExportNameLoc,
2392 Scope *curScope);
2393
2394 /// Only called on function definitions; if there is a pragma in scope
2395 /// with the effect of a range-based optnone, consider marking the function
2396 /// with attribute optnone.
2398
2399 /// Only called on function definitions; if there is a `#pragma alloc_text`
2400 /// that decides which code section the function should be in, add
2401 /// attribute section to the function.
2403
2404 /// Adds the 'optnone' attribute to the function declaration if there
2405 /// are no conflicts; Loc represents the location causing the 'optnone'
2406 /// attribute to be added (usually because of a pragma).
2408
2409 /// Only called on function definitions; if there is a MSVC #pragma optimize
2410 /// in scope, consider changing the function's attributes based on the
2411 /// optimization list passed to the pragma.
2413
2414 /// Only called on function definitions; if there is a pragma in scope
2415 /// with the effect of a range-based no_builtin, consider marking the function
2416 /// with attribute no_builtin.
2418
2419 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
2420 /// add an appropriate visibility attribute.
2422
2423 /// FreeVisContext - Deallocate and null out VisContext.
2424 void FreeVisContext();
2425
2426 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
2427 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
2428 SourceLocation PragmaLoc);
2429
2430 /// ActOnPragmaFPContract - Called on well formed
2431 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
2432 /// \#pragma clang fp contract
2434
2435 /// Called on well formed
2436 /// \#pragma clang fp reassociate
2437 /// or
2438 /// \#pragma clang fp reciprocal
2440 bool IsEnabled);
2441
2442 /// ActOnPragmaFenvAccess - Called on well formed
2443 /// \#pragma STDC FENV_ACCESS
2444 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
2445
2446 /// ActOnPragmaCXLimitedRange - Called on well formed
2447 /// \#pragma STDC CX_LIMITED_RANGE
2450
2451 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
2454
2455 /// Called to set constant rounding mode for floating point operations.
2456 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
2457
2458 /// Called to set exception behavior for floating point operations.
2460
2461 /// PushNamespaceVisibilityAttr - Note that we've entered a
2462 /// namespace with a visibility attribute.
2463 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
2464 SourceLocation Loc);
2465
2466 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
2467 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2468 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2469
2470 /// Handles semantic checking for features that are common to all attributes,
2471 /// such as checking whether a parameter was properly specified, or the
2472 /// correct number of arguments were passed, etc. Returns true if the
2473 /// attribute has been diagnosed.
2474 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2475 bool SkipArgCountCheck = false);
2476 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2477 bool SkipArgCountCheck = false);
2478
2479 ///@}
2480
2481 //
2482 //
2483 // -------------------------------------------------------------------------
2484 //
2485 //
2486
2487 /// \name Availability Attribute Handling
2488 /// Implementations are in SemaAvailability.cpp
2489 ///@{
2490
2491public:
2492 /// Issue any -Wunguarded-availability warnings in \c FD
2494
2496
2497 /// Retrieve the current function, if any, that should be analyzed for
2498 /// potential availability violations.
2500
2502 const ObjCInterfaceDecl *UnknownObjCClass,
2503 bool ObjCPropertyAccess,
2504 bool AvoidPartialAvailabilityChecks,
2505 ObjCInterfaceDecl *ClassReceiver);
2506
2508
2509 std::pair<AvailabilityResult, const NamedDecl *>
2510 ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message,
2511 ObjCInterfaceDecl *ClassReceiver);
2512 ///@}
2513
2514 //
2515 //
2516 // -------------------------------------------------------------------------
2517 //
2518 //
2519
2520 /// \name Bounds Safety
2521 /// Implementations are in SemaBoundsSafety.cpp
2522 ///@{
2523public:
2524 /// Check if applying the specified attribute variant from the "counted by"
2525 /// family of attributes to FieldDecl \p FD is semantically valid. If
2526 /// semantically invalid diagnostics will be emitted explaining the problems.
2527 ///
2528 /// \param FD The FieldDecl to apply the attribute to
2529 /// \param E The count expression on the attribute
2530 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2531 /// attributes. If the false the attribute is from
2532 /// "counted_by" family of attributes.
2533 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2534 /// of attributes. If false the attribute does not have the
2535 /// suffix.
2536 ///
2537 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2538 /// \p CountInBytes and \p OrNull both being true indicates the
2539 /// `counted_by_or_null` attribute.
2540 ///
2541 /// \returns false iff semantically valid.
2542 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2543 bool OrNull);
2544
2545 /// Late-parsed bounds types dropped while their declarator was built. The
2546 /// attribute has already been diagnosed and its node is no longer part of
2547 /// any type, so the completion pass must skip it rather than parse its
2548 /// argument and complete it.
2551
2555
2557 return RejectedLateParsedBoundsTypes.contains(BATy);
2558 }
2559
2560 /// Supply the parsed argument of a late-parsed bounds attribute to the type
2561 /// built for it by ActOnLateParsedTypeAttr, and run the checks that need the
2562 /// owning declaration. \p FD is the field the type belongs to. Returns false
2563 /// if the attribute was rejected.
2565 FieldDecl *FD, Expr *Arg);
2566
2567 /// Perform Bounds Safety Semantic checks for assigning to a `__counted_by` or
2568 /// `__counted_by_or_null` pointer type \param LHSTy.
2569 ///
2570 /// \param LHSTy The type being assigned to. Checks will only be performed if
2571 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2572 /// \param RHSExpr The expression being assigned from.
2573 /// \param Action The type assignment being performed
2574 /// \param Loc The SourceLocation to use for error diagnostics
2575 /// \param Assignee The ValueDecl being assigned. This is used to compute
2576 /// the name of the assignee. If the assignee isn't known this can
2577 /// be set to nullptr.
2578 /// \param ShowFullyQualifiedAssigneeName If set to true when using \p
2579 /// Assignee to compute the name of the assignee use the fully
2580 /// qualified name, otherwise use the unqualified name.
2581 ///
2582 /// \returns True iff no diagnostic where emitted, false otherwise.
2584 QualType LHSTy, Expr *RHSExpr, AssignmentAction Action,
2585 SourceLocation Loc, const ValueDecl *Assignee,
2586 bool ShowFullyQualifiedAssigneeName);
2587
2588 /// Perform Bounds Safety Semantic checks for initializing a Bounds Safety
2589 /// pointer.
2590 ///
2591 /// \param Entity The entity being initialized
2592 /// \param Kind The kind of initialization being performed
2593 /// \param Action The type assignment being performed
2594 /// \param LHSTy The type being assigned to. Checks will only be performed if
2595 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2596 /// \param RHSExpr The expression being used for initialization.
2597 ///
2598 /// \returns True iff no diagnostic where emitted, false otherwise.
2600 const InitializationKind &Kind,
2601 AssignmentAction Action,
2602 QualType LHSType, Expr *RHSExpr);
2603
2604 /// Perform Bounds Safety semantic checks for uses of invalid uses counted_by
2605 /// or counted_by_or_null pointers in \param E.
2606 ///
2607 /// \param E the expression to check
2608 ///
2609 /// \returns True iff no diagnostic where emitted, false otherwise.
2611 ///@}
2612
2613 //
2614 //
2615 // -------------------------------------------------------------------------
2616 //
2617 //
2618
2619 /// \name Casts
2620 /// Implementations are in SemaCast.cpp
2621 ///@{
2622
2623public:
2629
2630 /// ActOnCXXNamedCast - Parse
2631 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2633 SourceLocation LAngleBracketLoc, Declarator &D,
2634 SourceLocation RAngleBracketLoc,
2635 SourceLocation LParenLoc, Expr *E,
2636 SourceLocation RParenLoc);
2637
2639 TypeSourceInfo *Ty, Expr *E,
2640 SourceRange AngleBrackets, SourceRange Parens);
2641
2643 ExprResult Operand,
2644 SourceLocation RParenLoc);
2645
2647 Expr *Operand, SourceLocation RParenLoc);
2648
2649 // Checks that reinterpret casts don't have undefined behavior.
2650 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2651 bool IsDereference, SourceRange Range);
2652
2653 // Checks that the vector type should be initialized from a scalar
2654 // by splatting the value rather than populating a single element.
2655 // This is the case for AltiVecVector types as well as with
2656 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2657 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2658
2659 // Checks if the -faltivec-src-compat=gcc option is specified.
2660 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2661 // treated the same way as they are when trying to initialize
2662 // these vectors on gcc (an error is emitted).
2664 QualType SrcTy);
2665
2667 SourceLocation RParenLoc, Expr *Op);
2668
2670 SourceLocation LParenLoc,
2671 Expr *CastExpr,
2672 SourceLocation RParenLoc);
2673
2674 ///@}
2675
2676 //
2677 //
2678 // -------------------------------------------------------------------------
2679 //
2680 //
2681
2682 /// \name Extra Semantic Checking
2683 /// Implementations are in SemaChecking.cpp
2684 ///@{
2685
2686public:
2687 /// Used to change context to isConstantEvaluated without pushing a heavy
2688 /// ExpressionEvaluationContextRecord object.
2690
2695
2697 unsigned ByteNo) const;
2698
2700 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2701 FAPK_Variadic, // values to format are passed as variadic arguments
2702 FAPK_VAList, // values to format are passed in a va_list
2703 FAPK_Elsewhere, // values to format are not passed to this function
2704 };
2705
2706 // Used to grab the relevant information from a FormatAttr and a
2707 // FunctionDeclaration.
2713
2714 /// Given a function and its FormatAttr or FormatMatchesAttr info, attempts to
2715 /// populate the FormatStringInfo parameter with the attribute's correct
2716 /// format_idx and firstDataArg. Returns true when the format fits the
2717 /// function and the FormatStringInfo has been populated.
2718 static bool getFormatStringInfo(const Decl *Function, unsigned FormatIdx,
2719 unsigned FirstArg, FormatStringInfo *FSI);
2720 static bool getFormatStringInfo(unsigned FormatIdx, unsigned FirstArg,
2721 bool HasImplicitThisParam, bool IsVariadic,
2722 FormatStringInfo *FSI);
2723
2724 // Used by C++ template instantiation.
2726
2727 /// ConvertVectorExpr - Handle __builtin_convertvector
2729 SourceLocation BuiltinLoc,
2730 SourceLocation RParenLoc);
2731
2732 static StringRef GetFormatStringTypeName(FormatStringType FST);
2733 static FormatStringType GetFormatStringType(StringRef FormatFlavor);
2734 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2735 static FormatStringType GetFormatStringType(const FormatMatchesAttr *Format);
2736
2737 bool FormatStringHasSArg(const StringLiteral *FExpr);
2738
2739 /// Check for comparisons of floating-point values using == and !=. Issue a
2740 /// warning if the comparison is not likely to do what the programmer
2741 /// intended.
2742 void CheckFloatComparison(SourceLocation Loc, const Expr *LHS,
2743 const Expr *RHS, BinaryOperatorKind Opcode);
2744
2745 /// Register a magic integral constant to be used as a type tag.
2746 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2747 uint64_t MagicValue, QualType Type,
2748 bool LayoutCompatible, bool MustBeNull);
2749
2752
2756
2758
2759 /// If true, \c Type should be compared with other expression's types for
2760 /// layout-compatibility.
2761 LLVM_PREFERRED_TYPE(bool)
2763 LLVM_PREFERRED_TYPE(bool)
2764 unsigned MustBeNull : 1;
2765 };
2766
2767 /// A pair of ArgumentKind identifier and magic value. This uniquely
2768 /// identifies the magic value.
2769 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2770
2771 /// Diagnoses the current set of gathered accesses. This happens at the end of
2772 /// each expression evaluation context. Diagnostics are emitted only for
2773 /// accesses gathered in the current evaluation context.
2775
2776 /// This function checks if the expression is in the sef of potentially
2777 /// misaligned members and it is converted to some pointer type T with lower
2778 /// or equal alignment requirements. If so it removes it. This is used when
2779 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2780 /// void*).
2781 void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
2782
2783 /// Returns true if `From` is a function or pointer to a function with the
2784 /// `cfi_unchecked_callee` attribute but `To` is a function or pointer to
2785 /// function without this attribute.
2786 bool DiscardingCFIUncheckedCallee(QualType From, QualType To) const;
2787
2788 /// This function calls Action when it determines that E designates a
2789 /// misaligned member due to the packed attribute. This is used to emit
2790 /// local diagnostics like in reference binding.
2792 Expr *E,
2793 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2794 Action);
2795
2796 enum class AtomicArgumentOrder { API, AST };
2798 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2799 SourceLocation RParenLoc, MultiExprArg Args,
2802
2803 /// Check to see if a given expression could have '.c_str()' called on it.
2804 bool hasCStrMethod(const Expr *E);
2805
2806 /// Diagnose pointers that are always non-null.
2807 /// \param E the expression containing the pointer
2808 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2809 /// compared to a null pointer
2810 /// \param IsEqual True when the comparison is equal to a null pointer
2811 /// \param Range Extra SourceRange to highlight in the diagnostic
2814 bool IsEqual, SourceRange Range);
2815
2816 /// CheckParmsForFunctionDef - Check that the parameters of the given
2817 /// function are appropriate for the definition of a function. This
2818 /// takes care of any checks that cannot be performed on the
2819 /// declaration itself, e.g., that the types of each of the function
2820 /// parameters are complete.
2822 bool CheckParameterNames);
2823
2824 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2825 /// pointer cast increases the alignment requirements.
2826 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2827
2828 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2829 /// to weak/__unsafe_unretained type.
2830 bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
2831
2832 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2833 /// to weak/__unsafe_unretained expression.
2834 void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
2835
2836 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2837 /// statement as a \p Body, and it is located on the same line.
2838 ///
2839 /// This helps prevent bugs due to typos, such as:
2840 /// if (condition);
2841 /// do_stuff();
2842 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2843 unsigned DiagID);
2844
2845 /// Warn if a for/while loop statement \p S, which is followed by
2846 /// \p PossibleBody, has a suspicious null statement as a body.
2847 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2848
2849 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2850 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2851 SourceLocation OpLoc);
2852
2853 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2855 const TypeSourceInfo *Derived);
2856
2857 /// CheckFunctionCall - Check a direct function call for various correctness
2858 /// and safety properties not strictly enforced by the C type system.
2859 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2860 const FunctionProtoType *Proto);
2861
2868
2869 /// \param FPOnly restricts the arguments to floating-point types.
2870 std::optional<QualType>
2871 BuiltinVectorMath(CallExpr *TheCall,
2874 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2875
2876 void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
2877 const Expr *ThisArg, ArrayRef<const Expr *> Args);
2878
2879 /// Handles the checks for format strings, non-POD arguments to vararg
2880 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2881 /// attributes and AArch64 SME attributes.
2882 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2883 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2884 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2885 VariadicCallType CallType);
2886
2887 /// Verify that two format strings (as understood by attribute(format) and
2888 /// attribute(format_matches) are compatible. If they are incompatible,
2889 /// diagnostics are emitted with the assumption that \c
2890 /// AuthoritativeFormatString is correct and
2891 /// \c TestedFormatString is wrong. If \c FunctionCallArg is provided,
2892 /// diagnostics will point to it and a note will refer to \c
2893 /// TestedFormatString or \c AuthoritativeFormatString as appropriate.
2894 bool
2896 const StringLiteral *AuthoritativeFormatString,
2897 const StringLiteral *TestedFormatString,
2898 const Expr *FunctionCallArg = nullptr);
2899
2900 /// Verify that one format string (as understood by attribute(format)) is
2901 /// self-consistent; for instance, that it doesn't have multiple positional
2902 /// arguments referring to the same argument in incompatible ways. Diagnose
2903 /// if it isn't.
2905
2906 /// \brief Enforce the bounds of a TCB
2907 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2908 /// directly calls other functions in the same TCB as marked by the
2909 /// enforce_tcb and enforce_tcb_leaf attributes.
2910 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2911 const NamedDecl *Callee);
2912
2913 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2914
2915 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2916 /// TheCall is a constant expression.
2917 bool BuiltinConstantArg(CallExpr *TheCall, unsigned ArgNum,
2918 llvm::APSInt &Result);
2919
2920 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2921 /// TheCall is a constant expression in the range [Low, High].
2922 bool BuiltinConstantArgRange(CallExpr *TheCall, unsigned ArgNum, int Low,
2923 int High, bool RangeIsError = true);
2924
2925 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2926 /// TheCall is a constant expression is a multiple of Num..
2927 bool BuiltinConstantArgMultiple(CallExpr *TheCall, unsigned ArgNum,
2928 unsigned Multiple);
2929
2930 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2931 /// constant expression representing a power of 2.
2932 bool BuiltinConstantArgPower2(CallExpr *TheCall, unsigned ArgNum);
2933
2934 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2935 /// a constant expression representing an arbitrary byte value shifted left by
2936 /// a multiple of 8 bits.
2937 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, unsigned ArgNum,
2938 unsigned ArgBits);
2939
2940 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2941 /// TheCall is a constant expression representing either a shifted byte value,
2942 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2943 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2944 /// Arm MVE intrinsics.
2945 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, unsigned ArgNum,
2946 unsigned ArgBits);
2947
2948 /// Checks that a call expression's argument count is at least the desired
2949 /// number. This is useful when doing custom type-checking on a variadic
2950 /// function. Returns true on error.
2951 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2952
2953 /// Checks that a call expression's argument count is at most the desired
2954 /// number. This is useful when doing custom type-checking on a variadic
2955 /// function. Returns true on error.
2956 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2957
2958 /// Checks that a call expression's argument count is in the desired range.
2959 /// This is useful when doing custom type-checking on a variadic function.
2960 /// Returns true on error.
2961 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2962 unsigned MaxArgCount);
2963
2964 /// Checks that a call expression's argument count is the desired number.
2965 /// This is useful when doing custom type-checking. Returns true on error.
2966 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2967
2969
2970 /// Returns true if the argument consists of one contiguous run of 1s with any
2971 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2972 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2973 /// since all 1s are not contiguous.
2974 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2975
2977 bool *ICContext = nullptr,
2978 bool IsListInit = false);
2979
2980 /// Check for overflow behavior type related implicit conversion diagnostics.
2981 /// Returns true if OBT-related diagnostic was issued, false otherwise.
2983 SourceLocation CC);
2984
2985 bool
2990 CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr =
2992
2993private:
2994 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2995 const ArraySubscriptExpr *ASE = nullptr,
2996 bool AllowOnePastEnd = true, bool IndexNegated = false);
2997 void CheckArrayAccess(const Expr *E);
2998
2999 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
3000 const FunctionProtoType *Proto);
3001
3002 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
3003 /// such as function pointers returned from functions.
3004 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
3005
3006 /// CheckConstructorCall - Check a constructor call for correctness and safety
3007 /// properties not enforced by the C type system.
3008 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
3010 const FunctionProtoType *Proto, SourceLocation Loc);
3011
3012 /// Warn if a pointer or reference argument passed to a function points to an
3013 /// object that is less aligned than the parameter. This can happen when
3014 /// creating a typedef with a lower alignment than the original type and then
3015 /// calling functions defined in terms of the original type.
3016 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
3017 StringRef ParamName, QualType ArgTy, QualType ParamTy);
3018
3019 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
3020
3021 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
3022 CallExpr *TheCall);
3023
3024 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
3025 CallExpr *TheCall);
3026
3027 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
3028
3029 /// Argument-value fortify checks for libc functions that are not builtins,
3030 /// dispatched by name (e.g. umask). Diagnostics belong to -Wfortify-source.
3031 void checkFortifiedLibcArgument(FunctionDecl *FD, CallExpr *TheCall);
3032
3033 /// Check the arguments to '__builtin_va_start', '__builtin_ms_va_start',
3034 /// or '__builtin_c23_va_start' for validity. Emit an error and return true
3035 /// on failure; return false on success.
3036 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
3037 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
3038
3039 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
3040 /// friends. This is declared to take (...), so we have to check everything.
3041 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
3042
3043 /// BuiltinSemaBuiltinFPClassification - Handle functions like
3044 /// __builtin_isnan and friends. This is declared to take (...), so we have
3045 /// to check everything.
3046 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
3047 unsigned BuiltinID);
3048
3049 /// Perform semantic analysis for a call to __builtin_complex.
3050 bool BuiltinComplex(CallExpr *TheCall);
3051 bool BuiltinOSLogFormat(CallExpr *TheCall);
3052
3053 /// BuiltinPrefetch - Handle __builtin_prefetch.
3054 /// This is declared to take (const void*, ...) and can take two
3055 /// optional constant int args.
3056 bool BuiltinPrefetch(CallExpr *TheCall);
3057
3058 /// Handle __builtin_alloca_with_align. This is declared
3059 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
3060 /// than 8.
3061 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
3062
3063 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
3064 bool BuiltinArithmeticFence(CallExpr *TheCall);
3065
3066 /// BuiltinAssume - Handle __assume (MS Extension).
3067 /// __assume does not evaluate its arguments, and should warn if its argument
3068 /// has side effects.
3069 bool BuiltinAssume(CallExpr *TheCall);
3070
3071 /// Handle __builtin_assume_aligned. This is declared
3072 /// as (const void*, size_t, ...) and can take one optional constant int arg.
3073 bool BuiltinAssumeAligned(CallExpr *TheCall);
3074
3075 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
3076 /// This checks that the target supports __builtin_longjmp and
3077 /// that val is a constant 1.
3078 bool BuiltinLongjmp(CallExpr *TheCall);
3079
3080 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
3081 /// This checks that the target supports __builtin_setjmp.
3082 bool BuiltinSetjmp(CallExpr *TheCall);
3083
3084 /// We have a call to a function like __sync_fetch_and_add, which is an
3085 /// overloaded function based on the pointer type of its first argument.
3086 /// The main BuildCallExpr routines have already promoted the types of
3087 /// arguments because all of these calls are prototyped as void(...).
3088 ///
3089 /// This function goes through and does final semantic checking for these
3090 /// builtins, as well as generating any warnings.
3091 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
3092
3093 /// BuiltinNontemporalOverloaded - We have a call to
3094 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
3095 /// overloaded function based on the pointer type of its last argument.
3096 ///
3097 /// This function goes through and does final semantic checking for these
3098 /// builtins.
3099 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
3100 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
3102
3103 /// \param FPOnly restricts the arguments to floating-point types.
3104 bool BuiltinElementwiseMath(CallExpr *TheCall,
3107 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
3108
3109 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
3110
3111 bool CheckInvalidBuiltinCountedByRef(const Expr *E,
3113 bool BuiltinCountedByRef(CallExpr *TheCall);
3114
3115 // Matrix builtin handling.
3116 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
3117 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
3118 ExprResult CallResult);
3119 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
3120 ExprResult CallResult);
3121
3122 /// CheckFormatArguments - Check calls to printf and scanf (and similar
3123 /// functions) for correct use of format strings.
3124 /// Returns true if a format string has been fully checked.
3125 bool CheckFormatArguments(const FormatAttr *Format,
3126 ArrayRef<const Expr *> Args, bool IsCXXMember,
3127 VariadicCallType CallType, SourceLocation Loc,
3128 SourceRange Range,
3129 llvm::SmallBitVector &CheckedVarArgs);
3130 bool CheckFormatString(const FormatMatchesAttr *Format,
3131 ArrayRef<const Expr *> Args, bool IsCXXMember,
3132 VariadicCallType CallType, SourceLocation Loc,
3133 SourceRange Range,
3134 llvm::SmallBitVector &CheckedVarArgs);
3135 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
3136 FormatArgumentPassingKind FAPK,
3137 StringLiteral *ReferenceFormatString,
3138 unsigned format_idx, unsigned firstDataArg,
3140 SourceLocation Loc, SourceRange range,
3141 llvm::SmallBitVector &CheckedVarArgs);
3142
3143 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
3144
3145 /// Warn when using the wrong abs() function.
3146 void CheckAbsoluteValueFunction(const CallExpr *Call,
3147 const FunctionDecl *FDecl);
3148
3149 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
3150
3151 /// Check for dangerous or invalid arguments to memset().
3152 ///
3153 /// This issues warnings on known problematic, dangerous or unspecified
3154 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
3155 /// function calls.
3156 ///
3157 /// \param Call The call expression to diagnose.
3158 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
3159 IdentifierInfo *FnName);
3160
3161 bool CheckSizeofMemaccessArgument(const Expr *SizeOfArg, const Expr *Dest,
3162 IdentifierInfo *FnName);
3163 // Warn if the user has made the 'size' argument to strlcpy or strlcat
3164 // be the size of the source, instead of the destination.
3165 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
3166
3167 // Warn on anti-patterns as the 'size' argument to strncat.
3168 // The correct size argument should look like following:
3169 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
3170 void CheckStrncatArguments(const CallExpr *Call,
3171 const IdentifierInfo *FnName);
3172
3173 /// Alerts the user that they are attempting to free a non-malloc'd object.
3174 void CheckFreeArguments(const CallExpr *E);
3175
3176 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
3177 SourceLocation ReturnLoc, bool isObjCMethod = false,
3178 const AttrVec *Attrs = nullptr,
3179 const FunctionDecl *FD = nullptr);
3180
3181 /// Diagnoses "dangerous" implicit conversions within the given
3182 /// expression (which is a full expression). Implements -Wconversion
3183 /// and -Wsign-compare.
3184 ///
3185 /// \param CC the "context" location of the implicit conversion, i.e.
3186 /// the most location of the syntactic entity requiring the implicit
3187 /// conversion
3188 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
3189
3190 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
3191 /// Input argument E is a logical expression.
3193
3194 /// Diagnose when expression is an integer constant expression and its
3195 /// evaluation results in integer overflow
3196 void CheckForIntOverflow(const Expr *E);
3197 void CheckUnsequencedOperations(const Expr *E);
3198
3199 /// Perform semantic checks on a completed expression. This will either
3200 /// be a full-expression or a default argument expression.
3201 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
3202 bool IsConstexpr = false);
3203
3204 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
3205 Expr *Init);
3206
3207 /// A map from magic value to type information.
3208 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
3209 TypeTagForDatatypeMagicValues;
3210
3211 /// Peform checks on a call of a function with argument_with_type_tag
3212 /// or pointer_with_type_tag attributes.
3213 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
3214 const ArrayRef<const Expr *> ExprArgs,
3215 SourceLocation CallSiteLoc);
3216
3217 /// Check if we are taking the address of a packed field
3218 /// as this may be a problem if the pointer value is dereferenced.
3219 void CheckAddressOfPackedMember(Expr *rhs);
3220
3221 /// Helper class that collects misaligned member designations and
3222 /// their location info for delayed diagnostics.
3223 struct MisalignedMember {
3224 Expr *E;
3225 RecordDecl *RD;
3226 ValueDecl *MD;
3227 CharUnits Alignment;
3228
3229 MisalignedMember() : E(), RD(), MD() {}
3230 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
3231 CharUnits Alignment)
3232 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
3233 explicit MisalignedMember(Expr *E)
3234 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
3235
3236 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
3237 };
3238
3239 /// Adds an expression to the set of gathered misaligned members.
3240 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
3241 CharUnits Alignment);
3242 ///@}
3243
3244 //
3245 //
3246 // -------------------------------------------------------------------------
3247 //
3248 //
3249
3250 /// \name C++ Coroutines
3251 /// Implementations are in SemaCoroutine.cpp
3252 ///@{
3253
3254public:
3255 /// The C++ "std::coroutine_traits" template, which is defined in
3256 /// <coroutine_traits>
3258
3260 StringRef Keyword);
3264
3267 UnresolvedLookupExpr *Lookup);
3269 Expr *Awaiter, bool IsImplicit = false);
3271 UnresolvedLookupExpr *Lookup);
3274 bool IsImplicit = false);
3279
3280 // As a clang extension, enforces that a non-coroutine function must be marked
3281 // with [[clang::coro_wrapper]] if it returns a type marked with
3282 // [[clang::coro_return_type]].
3283 // Expects that FD is not a coroutine.
3285 /// Lookup 'coroutine_traits' in std namespace and std::experimental
3286 /// namespace. The namespace found is recorded in Namespace.
3288 SourceLocation FuncLoc);
3289 /// Check that the expression co_await promise.final_suspend() shall not be
3290 /// potentially-throwing.
3291 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
3292
3293 ///@}
3294
3295 //
3296 //
3297 // -------------------------------------------------------------------------
3298 //
3299 //
3300
3301 /// \name C++ Scope Specifiers
3302 /// Implementations are in SemaCXXScopeSpec.cpp
3303 ///@{
3304
3305public:
3306 // Marks SS invalid if it represents an incomplete type.
3308 // Complete an enum decl, maybe without a scope spec.
3310 CXXScopeSpec *SS = nullptr);
3311
3312 /// Compute the DeclContext that is associated with the given type.
3313 ///
3314 /// \param T the type for which we are attempting to find a DeclContext.
3315 ///
3316 /// \returns the declaration context represented by the type T,
3317 /// or NULL if the declaration context cannot be computed (e.g., because it is
3318 /// dependent and not the current instantiation).
3320
3321 /// Compute the DeclContext that is associated with the given
3322 /// scope specifier.
3323 ///
3324 /// \param SS the C++ scope specifier as it appears in the source
3325 ///
3326 /// \param EnteringContext when true, we will be entering the context of
3327 /// this scope specifier, so we can retrieve the declaration context of a
3328 /// class template or class template partial specialization even if it is
3329 /// not the current instantiation.
3330 ///
3331 /// \returns the declaration context represented by the scope specifier @p SS,
3332 /// or NULL if the declaration context cannot be computed (e.g., because it is
3333 /// dependent and not the current instantiation).
3335 bool EnteringContext = false);
3337
3338 /// If the given nested name specifier refers to the current
3339 /// instantiation, return the declaration that corresponds to that
3340 /// current instantiation (C++0x [temp.dep.type]p1).
3341 ///
3342 /// \param NNS a dependent nested name specifier.
3344
3345 /// The parser has parsed a global nested-name-specifier '::'.
3346 ///
3347 /// \param CCLoc The location of the '::'.
3348 ///
3349 /// \param SS The nested-name-specifier, which will be updated in-place
3350 /// to reflect the parsed nested-name-specifier.
3351 ///
3352 /// \returns true if an error occurred, false otherwise.
3354
3355 /// The parser has parsed a '__super' nested-name-specifier.
3356 ///
3357 /// \param SuperLoc The location of the '__super' keyword.
3358 ///
3359 /// \param ColonColonLoc The location of the '::'.
3360 ///
3361 /// \param SS The nested-name-specifier, which will be updated in-place
3362 /// to reflect the parsed nested-name-specifier.
3363 ///
3364 /// \returns true if an error occurred, false otherwise.
3366 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
3367
3368 /// Determines whether the given declaration is an valid acceptable
3369 /// result for name lookup of a nested-name-specifier.
3370 /// \param SD Declaration checked for nested-name-specifier.
3371 /// \param IsExtension If not null and the declaration is accepted as an
3372 /// extension, the pointed variable is assigned true.
3374 bool *CanCorrect = nullptr);
3375
3376 /// If the given nested-name-specifier begins with a bare identifier
3377 /// (e.g., Base::), perform name lookup for that identifier as a
3378 /// nested-name-specifier within the given scope, and return the result of
3379 /// that name lookup.
3381
3382 /// Keeps information about an identifier in a nested-name-spec.
3383 ///
3385 /// The type of the object, if we're parsing nested-name-specifier in
3386 /// a member access expression.
3388
3389 /// The identifier preceding the '::'.
3391
3392 /// The location of the identifier.
3394
3395 /// The location of the '::'.
3397
3398 /// Creates info object for the most typical case.
3400 SourceLocation ColonColonLoc,
3403 CCLoc(ColonColonLoc) {}
3404
3406 SourceLocation ColonColonLoc, QualType ObjectType)
3408 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
3409 };
3410
3411 /// Build a new nested-name-specifier for "identifier::", as described
3412 /// by ActOnCXXNestedNameSpecifier.
3413 ///
3414 /// \param S Scope in which the nested-name-specifier occurs.
3415 /// \param IdInfo Parser information about an identifier in the
3416 /// nested-name-spec.
3417 /// \param EnteringContext If true, enter the context specified by the
3418 /// nested-name-specifier.
3419 /// \param SS Optional nested name specifier preceding the identifier.
3420 /// \param ScopeLookupResult Provides the result of name lookup within the
3421 /// scope of the nested-name-specifier that was computed at template
3422 /// definition time.
3423 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
3424 /// error recovery and what kind of recovery is performed.
3425 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
3426 /// are allowed. The bool value pointed by this parameter is set to
3427 /// 'true' if the identifier is treated as if it was followed by ':',
3428 /// not '::'.
3429 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3430 ///
3431 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
3432 /// that it contains an extra parameter \p ScopeLookupResult, which provides
3433 /// the result of name lookup within the scope of the nested-name-specifier
3434 /// that was computed at template definition time.
3435 ///
3436 /// If ErrorRecoveryLookup is true, then this call is used to improve error
3437 /// recovery. This means that it should not emit diagnostics, it should
3438 /// just return true on failure. It also means it should only return a valid
3439 /// scope if it *knows* that the result is correct. It should not return in a
3440 /// dependent context, for example. Nor will it extend \p SS with the scope
3441 /// specifier.
3442 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3443 bool EnteringContext, CXXScopeSpec &SS,
3444 NamedDecl *ScopeLookupResult,
3445 bool ErrorRecoveryLookup,
3446 bool *IsCorrectedToColon = nullptr,
3447 bool OnlyNamespace = false);
3448
3449 /// The parser has parsed a nested-name-specifier 'identifier::'.
3450 ///
3451 /// \param S The scope in which this nested-name-specifier occurs.
3452 ///
3453 /// \param IdInfo Parser information about an identifier in the
3454 /// nested-name-spec.
3455 ///
3456 /// \param EnteringContext Whether we're entering the context nominated by
3457 /// this nested-name-specifier.
3458 ///
3459 /// \param SS The nested-name-specifier, which is both an input
3460 /// parameter (the nested-name-specifier before this type) and an
3461 /// output parameter (containing the full nested-name-specifier,
3462 /// including this new type).
3463 ///
3464 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
3465 /// are allowed. The bool value pointed by this parameter is set to 'true'
3466 /// if the identifier is treated as if it was followed by ':', not '::'.
3467 ///
3468 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3469 ///
3470 /// \returns true if an error occurred, false otherwise.
3471 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3472 bool EnteringContext, CXXScopeSpec &SS,
3473 bool *IsCorrectedToColon = nullptr,
3474 bool OnlyNamespace = false);
3475
3476 /// The parser has parsed a nested-name-specifier
3477 /// 'template[opt] template-name < template-args >::'.
3478 ///
3479 /// \param S The scope in which this nested-name-specifier occurs.
3480 ///
3481 /// \param SS The nested-name-specifier, which is both an input
3482 /// parameter (the nested-name-specifier before this type) and an
3483 /// output parameter (containing the full nested-name-specifier,
3484 /// including this new type).
3485 ///
3486 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
3487 /// \param TemplateName the template name.
3488 /// \param TemplateNameLoc The location of the template name.
3489 /// \param LAngleLoc The location of the opening angle bracket ('<').
3490 /// \param TemplateArgs The template arguments.
3491 /// \param RAngleLoc The location of the closing angle bracket ('>').
3492 /// \param CCLoc The location of the '::'.
3493 ///
3494 /// \param EnteringContext Whether we're entering the context of the
3495 /// nested-name-specifier.
3496 ///
3497 ///
3498 /// \returns true if an error occurred, false otherwise.
3500 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
3501 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
3502 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
3503 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
3504
3506 SourceLocation ColonColonLoc);
3507
3509 const DeclSpec &DS,
3510 SourceLocation ColonColonLoc,
3511 QualType Type);
3512
3513 /// IsInvalidUnlessNestedName - This method is used for error recovery
3514 /// purposes to determine whether the specified identifier is only valid as
3515 /// a nested name specifier, for example a namespace name. It is
3516 /// conservatively correct to always return false from this method.
3517 ///
3518 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
3520 NestedNameSpecInfo &IdInfo,
3521 bool EnteringContext);
3522
3523 /// Given a C++ nested-name-specifier, produce an annotation value
3524 /// that the parser can use later to reconstruct the given
3525 /// nested-name-specifier.
3526 ///
3527 /// \param SS A nested-name-specifier.
3528 ///
3529 /// \returns A pointer containing all of the information in the
3530 /// nested-name-specifier \p SS.
3532
3533 /// Given an annotation pointer for a nested-name-specifier, restore
3534 /// the nested-name-specifier structure.
3535 ///
3536 /// \param Annotation The annotation pointer, produced by
3537 /// \c SaveNestedNameSpecifierAnnotation().
3538 ///
3539 /// \param AnnotationRange The source range corresponding to the annotation.
3540 ///
3541 /// \param SS The nested-name-specifier that will be updated with the contents
3542 /// of the annotation pointer.
3543 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
3544 SourceRange AnnotationRange,
3545 CXXScopeSpec &SS);
3546
3547 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
3548
3549 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
3550 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
3551 /// After this method is called, according to [C++ 3.4.3p3], names should be
3552 /// looked up in the declarator-id's scope, until the declarator is parsed and
3553 /// ActOnCXXExitDeclaratorScope is called.
3554 /// The 'SS' should be a non-empty valid CXXScopeSpec.
3556
3557 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
3558 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
3559 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
3560 /// Used to indicate that names should revert to being looked up in the
3561 /// defining scope.
3563
3564 ///@}
3565
3566 //
3567 //
3568 // -------------------------------------------------------------------------
3569 //
3570 //
3571
3572 /// \name Declarations
3573 /// Implementations are in SemaDecl.cpp
3574 ///@{
3575
3576public:
3578
3579 /// The index of the first InventedParameterInfo that refers to the current
3580 /// context.
3582
3583 /// A RAII object to temporarily push a declaration context.
3585 private:
3586 Sema &S;
3587 DeclContext *SavedContext;
3588 ProcessingContextState SavedContextState;
3589 QualType SavedCXXThisTypeOverride;
3590 unsigned SavedFunctionScopesStart;
3591 unsigned SavedInventedParameterInfosStart;
3592
3593 public:
3594 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3595 : S(S), SavedContext(S.CurContext),
3596 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3597 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3598 SavedFunctionScopesStart(S.FunctionScopesStart),
3599 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3600 assert(ContextToPush && "pushing null context");
3601 S.CurContext = ContextToPush;
3602 if (NewThisContext)
3603 S.CXXThisTypeOverride = QualType();
3604 // Any saved FunctionScopes do not refer to this context.
3605 S.FunctionScopesStart = S.FunctionScopes.size();
3606 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3607 }
3608
3609 void pop() {
3610 if (!SavedContext)
3611 return;
3612 S.CurContext = SavedContext;
3613 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3614 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3615 S.FunctionScopesStart = SavedFunctionScopesStart;
3616 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3617 SavedContext = nullptr;
3618 }
3619
3621 ContextRAII(const ContextRAII &) = delete;
3623 };
3624
3625 void DiagnoseInvalidJumps(Stmt *Body);
3626
3627 /// The function definitions which were renamed as part of typo-correction
3628 /// to match their respective declarations. We want to keep track of them
3629 /// to ensure that we don't emit a "redefinition" error if we encounter a
3630 /// correctly named definition after the renamed definition.
3632
3633 /// A cache of the flags available in enumerations with the flag_enum
3634 /// attribute.
3635 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3636
3637 /// A cache of enumerator values for enums checked by -Wassign-enum.
3638 llvm::DenseMap<const EnumDecl *, llvm::SmallVector<llvm::APSInt>>
3640
3641 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3642 /// declared. Rare. May alias another identifier, declared or undeclared.
3643 ///
3644 /// For aliases, the target identifier is used as a key for eventual
3645 /// processing when the target is declared. For the single-identifier form,
3646 /// the sole identifier is used as the key. Each entry is a `SetVector`
3647 /// (ordered by parse order) of aliases (identified by the alias name) in case
3648 /// of multiple aliases to the same undeclared identifier.
3649 llvm::MapVector<
3651 llvm::SetVector<
3653 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3655
3656 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3657 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3658 /// to define functions that occur in multiple standards to call the version
3659 /// in the currently selected standard.
3660 llvm::MapVector<IdentifierInfo *, AsmLabelAttr *>
3662
3663 /// Set containing all typedefs that are likely unused.
3666
3667 /// Store UnusedLocalTypedefNameCandidates in \p Sorted in a deterministic
3668 /// order.
3671
3672 typedef LazyVector<const DeclaratorDecl *,
3675
3676 /// The set of file scoped decls seen so far that have not been used
3677 /// and must warn if not used. Only contains the first declaration.
3679
3681 2, 2>
3683
3684 /// All the tentative definitions encountered in the TU.
3686
3687 /// All the external declarations encoutered and used in the TU.
3689
3690 /// Generally null except when we temporarily switch decl contexts,
3691 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3693
3694 /// Is the module scope we are in a C++ Header Unit?
3696 return ModuleScopes.empty() ? false
3697 : ModuleScopes.back().Module->isHeaderUnit();
3698 }
3699
3700 /// Get the module owning an entity.
3701 Module *getOwningModule(const Decl *Entity) {
3702 return Entity->getOwningModule();
3703 }
3704
3705 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3706
3708 /// Returns the TypeDeclType for the given type declaration,
3709 /// as ASTContext::getTypeDeclType would, but
3710 /// performs the required semantic checks for name lookup of said entity.
3711 void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD,
3712 SourceLocation NameLoc);
3713
3714 /// If the identifier refers to a type name within this scope,
3715 /// return the declaration of that type.
3716 ///
3717 /// This routine performs ordinary name lookup of the identifier II
3718 /// within the given scope, with optional C++ scope specifier SS, to
3719 /// determine whether the name refers to a type. If so, returns an
3720 /// opaque pointer (actually a QualType) corresponding to that
3721 /// type. Otherwise, returns NULL.
3723 Scope *S, CXXScopeSpec *SS = nullptr,
3724 bool isClassName = false, bool HasTrailingDot = false,
3725 ParsedType ObjectType = nullptr,
3726 bool IsCtorOrDtorName = false,
3727 bool WantNontrivialTypeSourceInfo = false,
3728 bool IsClassTemplateDeductionContext = true,
3729 ImplicitTypenameContext AllowImplicitTypename =
3731 IdentifierInfo **CorrectedII = nullptr);
3732
3733 /// isTagName() - This method is called *for error recovery purposes only*
3734 /// to determine if the specified name is a valid tag name ("struct foo"). If
3735 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3736 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3737 /// diagnose cases in C where the user forgot to specify the tag.
3739
3740 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3741 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3742 /// then downgrade the missing typename error to a warning.
3743 /// This is needed for MSVC compatibility; Example:
3744 /// @code
3745 /// template<class T> class A {
3746 /// public:
3747 /// typedef int TYPE;
3748 /// };
3749 /// template<class T> class B : public A<T> {
3750 /// public:
3751 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3752 /// };
3753 /// @endcode
3754 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3756 Scope *S, CXXScopeSpec *SS,
3757 ParsedType &SuggestedType,
3758 bool IsTemplateName = false);
3759
3760 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3761 /// type name has failed in a dependent context. In these situations, we
3762 /// automatically form a DependentTypeName that will retry lookup in a related
3763 /// scope during instantiation.
3765 SourceLocation NameLoc,
3766 bool IsTemplateTypeArg);
3767
3768 class NameClassification {
3770 union {
3775 };
3776
3777 explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
3778
3779 public:
3782
3785
3786 static NameClassification Error() {
3787 return NameClassification(NameClassificationKind::Error);
3788 }
3789
3790 static NameClassification Unknown() {
3791 return NameClassification(NameClassificationKind::Unknown);
3792 }
3793
3794 static NameClassification OverloadSet(ExprResult E) {
3795 NameClassification Result(NameClassificationKind::OverloadSet);
3796 Result.Expr = E;
3797 return Result;
3798 }
3799
3800 static NameClassification NonType(NamedDecl *D) {
3801 NameClassification Result(NameClassificationKind::NonType);
3802 Result.NonTypeDecl = D;
3803 return Result;
3804 }
3805
3806 static NameClassification UndeclaredNonType() {
3807 return NameClassification(NameClassificationKind::UndeclaredNonType);
3808 }
3809
3810 static NameClassification DependentNonType() {
3811 return NameClassification(NameClassificationKind::DependentNonType);
3812 }
3813
3814 static NameClassification TypeTemplate(TemplateName Name) {
3815 NameClassification Result(NameClassificationKind::TypeTemplate);
3816 Result.Template = Name;
3817 return Result;
3818 }
3819
3820 static NameClassification VarTemplate(TemplateName Name) {
3821 NameClassification Result(NameClassificationKind::VarTemplate);
3822 Result.Template = Name;
3823 return Result;
3824 }
3825
3826 static NameClassification FunctionTemplate(TemplateName Name) {
3828 Result.Template = Name;
3829 return Result;
3830 }
3831
3832 static NameClassification Concept(TemplateName Name) {
3833 NameClassification Result(NameClassificationKind::Concept);
3834 Result.Template = Name;
3835 return Result;
3836 }
3837
3838 static NameClassification UndeclaredTemplate(TemplateName Name) {
3840 Result.Template = Name;
3841 return Result;
3842 }
3843
3844 NameClassificationKind getKind() const { return Kind; }
3845
3848 return Expr;
3849 }
3850
3852 assert(Kind == NameClassificationKind::Type);
3853 return Type;
3854 }
3855
3857 assert(Kind == NameClassificationKind::NonType);
3858 return NonTypeDecl;
3859 }
3860
3869
3871 switch (Kind) {
3873 return TNK_Type_template;
3875 return TNK_Function_template;
3877 return TNK_Var_template;
3879 return TNK_Concept_template;
3882 default:
3883 llvm_unreachable("unsupported name classification.");
3884 }
3885 }
3886 };
3887
3888 /// Perform name lookup on the given name, classifying it based on
3889 /// the results of name lookup and the following token.
3890 ///
3891 /// This routine is used by the parser to resolve identifiers and help direct
3892 /// parsing. When the identifier cannot be found, this routine will attempt
3893 /// to correct the typo and classify based on the resulting name.
3894 ///
3895 /// \param S The scope in which we're performing name lookup.
3896 ///
3897 /// \param SS The nested-name-specifier that precedes the name.
3898 ///
3899 /// \param Name The identifier. If typo correction finds an alternative name,
3900 /// this pointer parameter will be updated accordingly.
3901 ///
3902 /// \param NameLoc The location of the identifier.
3903 ///
3904 /// \param NextToken The token following the identifier. Used to help
3905 /// disambiguate the name.
3906 ///
3907 /// \param CCC The correction callback, if typo correction is desired.
3908 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3909 IdentifierInfo *&Name, SourceLocation NameLoc,
3910 const Token &NextToken,
3911 CorrectionCandidateCallback *CCC = nullptr);
3912
3913 /// Act on the result of classifying a name as an undeclared (ADL-only)
3914 /// non-type declaration.
3916 SourceLocation NameLoc);
3917 /// Act on the result of classifying a name as an undeclared member of a
3918 /// dependent base class.
3920 IdentifierInfo *Name,
3921 SourceLocation NameLoc,
3922 bool IsAddressOfOperand);
3923 /// Act on the result of classifying a name as a specific non-type
3924 /// declaration.
3927 SourceLocation NameLoc,
3928 const Token &NextToken);
3929 /// Act on the result of classifying a name as an overload set.
3931
3932 /// Describes the detailed kind of a template name. Used in diagnostics.
3944
3945 /// Determine whether it's plausible that E was intended to be a
3946 /// template-name.
3948 if (!getLangOpts().CPlusPlus || E.isInvalid())
3949 return false;
3950 Dependent = false;
3951 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3952 return !DRE->hasExplicitTemplateArgs();
3953 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3954 return !ME->hasExplicitTemplateArgs();
3955 Dependent = true;
3956 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3957 return !DSDRE->hasExplicitTemplateArgs();
3958 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3959 return !DSME->hasExplicitTemplateArgs();
3960 // Any additional cases recognized here should also be handled by
3961 // diagnoseExprIntendedAsTemplateName.
3962 return false;
3963 }
3964
3965 void warnOnReservedIdentifier(const NamedDecl *D);
3967
3968 void ProcessPragmaExport(DeclaratorDecl *newDecl);
3969
3971
3973 MultiTemplateParamsArg TemplateParameterLists);
3974
3975 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3976 /// true if we were successful.
3978 SourceLocation Loc,
3979 unsigned FailedFoldDiagID);
3980
3981 /// Register the given locally-scoped extern "C" declaration so
3982 /// that it can be found later for redeclarations. We include any extern "C"
3983 /// declaration that is not visible in the translation unit here, not just
3984 /// function-scope declarations.
3986
3987 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3988 /// If T is the name of a class, then each of the following shall have a
3989 /// name different from T:
3990 /// - every static data member of class T;
3991 /// - every member function of class T
3992 /// - every member of class T that is itself a type;
3993 /// \returns true if the declaration name violates these rules.
3995
3996 /// Diagnose a declaration whose declarator-id has the given
3997 /// nested-name-specifier.
3998 ///
3999 /// \param SS The nested-name-specifier of the declarator-id.
4000 ///
4001 /// \param DC The declaration context to which the nested-name-specifier
4002 /// resolves.
4003 ///
4004 /// \param Name The name of the entity being declared.
4005 ///
4006 /// \param Loc The location of the name of the entity being declared.
4007 ///
4008 /// \param IsMemberSpecialization Whether we are declaring a member
4009 /// specialization.
4010 ///
4011 /// \param TemplateId The template-id, if any.
4012 ///
4013 /// \returns true if we cannot safely recover from this error, false
4014 /// otherwise.
4017 TemplateIdAnnotation *TemplateId,
4018 bool IsMemberSpecialization);
4019
4021
4022 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
4023
4025 unsigned &IntVal);
4026
4027 /// Diagnose function specifiers on a declaration of an identifier that
4028 /// does not identify a function.
4029 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
4030
4031 /// Return the declaration shadowed by the given typedef \p D, or null
4032 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
4034 const LookupResult &R);
4035
4036 /// Return the declaration shadowed by the given variable \p D, or null
4037 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
4039
4040 /// Return the declaration shadowed by the given variable \p D, or null
4041 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
4043 const LookupResult &R);
4044 /// Diagnose variable or built-in function shadowing. Implements
4045 /// -Wshadow.
4046 ///
4047 /// This method is called whenever a VarDecl is added to a "useful"
4048 /// scope.
4049 ///
4050 /// \param ShadowedDecl the declaration that is shadowed by the given variable
4051 /// \param R the lookup of the name
4052 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
4053 const LookupResult &R);
4054
4055 /// Check -Wshadow without the advantage of a previous lookup.
4056 void CheckShadow(Scope *S, VarDecl *D);
4057
4058 /// Warn if 'E', which is an expression that is about to be modified, refers
4059 /// to a shadowing declaration.
4061
4062 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
4063 /// when these variables are captured by the lambda.
4065
4066 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
4067 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
4068 TypedefNameDecl *NewTD);
4071 TypeSourceInfo *TInfo,
4073
4074 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
4075 /// declares a typedef-name, either using the 'typedef' type specifier or via
4076 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
4080 TypeSourceInfo *TInfo,
4082 MultiTemplateParamsArg TemplateParamLists,
4083 bool &AddToScope,
4085
4086private:
4087 // Perform a check on an AsmLabel to verify its consistency and emit
4088 // diagnostics in case of an error.
4089 void CheckAsmLabel(Scope *S, Expr *AsmLabelExpr, StorageClass SC,
4090 TypeSourceInfo *TInfo, VarDecl *);
4091
4092public:
4093 /// Perform semantic checking on a newly-created variable
4094 /// declaration.
4095 ///
4096 /// This routine performs all of the type-checking required for a
4097 /// variable declaration once it has been built. It is used both to
4098 /// check variables after they have been parsed and their declarators
4099 /// have been translated into a declaration, and to check variables
4100 /// that have been instantiated from a template.
4101 ///
4102 /// Sets NewVD->isInvalidDecl() if an error was encountered.
4103 ///
4104 /// Returns true if the variable declaration is a redeclaration.
4105 bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
4106 void CheckVariableDeclarationType(VarDecl *NewVD);
4107 void CheckCompleteVariableDeclaration(VarDecl *VD);
4108
4109 NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
4110 TypeSourceInfo *TInfo,
4111 LookupResult &Previous,
4112 MultiTemplateParamsArg TemplateParamLists,
4113 bool &AddToScope);
4114
4115 /// Attach the ABI tag a standard calling convention variant requires, as an
4116 /// implicit abi_tag attribute. Call this once the function type is final.
4117 void addImplicitCallingConvAbiTag(FunctionDecl *FD);
4118
4119 /// AddOverriddenMethods - See if a method overrides any in the base classes,
4120 /// and if so, check that it's a valid override and remember it.
4121 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
4122
4123 /// Perform semantic checking of a new function declaration.
4124 ///
4125 /// Performs semantic analysis of the new function declaration
4126 /// NewFD. This routine performs all semantic checking that does not
4127 /// require the actual declarator involved in the declaration, and is
4128 /// used both for the declaration of functions as they are parsed
4129 /// (called via ActOnDeclarator) and for the declaration of functions
4130 /// that have been instantiated via C++ template instantiation (called
4131 /// via InstantiateDecl).
4132 ///
4133 /// \param IsMemberSpecialization whether this new function declaration is
4134 /// a member specialization (that replaces any definition provided by the
4135 /// previous declaration).
4136 ///
4137 /// This sets NewFD->isInvalidDecl() to true if there was an error.
4138 ///
4139 /// \returns true if the function declaration is a redeclaration.
4140 bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
4141 LookupResult &Previous,
4142 bool IsMemberSpecialization, bool DeclIsDefn);
4143
4144 /// Checks if the new declaration declared in dependent context must be
4145 /// put in the same redeclaration chain as the specified declaration.
4146 ///
4147 /// \param D Declaration that is checked.
4148 /// \param PrevDecl Previous declaration found with proper lookup method for
4149 /// the same declaration name.
4150 /// \returns True if D must be added to the redeclaration chain which PrevDecl
4151 /// belongs to.
4152 bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
4153
4154 /// Determines if we can perform a correct type check for \p D as a
4155 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
4156 /// best-effort check.
4157 ///
4158 /// \param NewD The new declaration.
4159 /// \param OldD The old declaration.
4160 /// \param NewT The portion of the type of the new declaration to check.
4161 /// \param OldT The portion of the type of the old declaration to check.
4162 bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
4163 QualType NewT, QualType OldT);
4164 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
4165 void CheckMSVCRTEntryPoint(FunctionDecl *FD);
4166
4167 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
4168 /// containing class. Otherwise it will return implicit SectionAttr if the
4169 /// function is a definition and there is an active value on CodeSegStack
4170 /// (from the current #pragma code-seg value).
4171 ///
4172 /// \param FD Function being declared.
4173 /// \param IsDefinition Whether it is a definition or just a declaration.
4174 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
4175 /// nullptr if no attribute should be added.
4176 Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
4177 bool IsDefinition);
4178
4179 /// Common checks for a parameter-declaration that should apply to both
4180 /// function parameters and non-type template parameters.
4181 void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
4182
4183 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
4184 /// to introduce parameters into function prototype scope.
4185 Decl *ActOnParamDeclarator(Scope *S, Declarator &D,
4186 SourceLocation ExplicitThisLoc = {});
4187
4188 /// Synthesizes a variable for a parameter arising from a
4189 /// typedef.
4190 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
4191 QualType T);
4192 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
4193 SourceLocation NameLoc,
4194 const IdentifierInfo *Name, QualType T,
4195 TypeSourceInfo *TSInfo, StorageClass SC);
4196
4197 /// Emit diagnostics if the initializer or any of its explicit or
4198 /// implicitly-generated subexpressions require copying or
4199 /// default-initializing a type that is or contains a C union type that is
4200 /// non-trivial to copy or default-initialize.
4201 void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc);
4202
4203 // These flags are passed to checkNonTrivialCUnion.
4209
4210 /// Emit diagnostics if a non-trivial C union type or a struct that contains
4211 /// a non-trivial C union is used in an invalid context.
4213 NonTrivialCUnionContext UseContext,
4214 unsigned NonTrivialKind);
4215
4216 /// Certain globally-unique variables might be accidentally duplicated if
4217 /// built into multiple shared libraries with hidden visibility. This can
4218 /// cause problems if the variable is mutable, its initialization is
4219 /// effectful, or its address is taken.
4222
4223 /// AddInitializerToDecl - Adds the initializer Init to the
4224 /// declaration dcl. If DirectInit is true, this is C++ direct
4225 /// initialization rather than copy initialization.
4226 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
4227 void ActOnUninitializedDecl(Decl *dcl);
4228
4229 /// ActOnInitializerError - Given that there was an error parsing an
4230 /// initializer for the given declaration, try to at least re-establish
4231 /// invariants such as whether a variable's type is either dependent or
4232 /// complete.
4233 void ActOnInitializerError(Decl *Dcl);
4234
4235 void ActOnCXXForRangeDecl(Decl *D, bool InExpansionStmt);
4237 IdentifierInfo *Ident,
4238 ParsedAttributes &Attrs);
4239
4240 /// Check if VD needs to be dllexport/dllimport due to being in a
4241 /// dllexport/import function.
4244
4245 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
4246 /// any semantic actions necessary after any initializer has been attached.
4247 void FinalizeDeclaration(Decl *D);
4249 ArrayRef<Decl *> Group);
4250
4251 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
4252 /// group, performing any necessary semantic checking.
4254
4255 /// Should be called on all declarations that might have attached
4256 /// documentation comments.
4257 void ActOnDocumentableDecl(Decl *D);
4259
4260 enum class FnBodyKind {
4261 /// C++26 [dcl.fct.def.general]p1
4262 /// function-body:
4263 /// ctor-initializer[opt] compound-statement
4264 /// function-try-block
4266 /// = default ;
4268 /// deleted-function-body
4269 ///
4270 /// deleted-function-body:
4271 /// = delete ;
4272 /// = delete ( unevaluated-string ) ;
4274 };
4275
4277 SourceLocation LocAfterDecls);
4279 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
4280 SkipBodyInfo *SkipBody = nullptr);
4282 MultiTemplateParamsArg TemplateParamLists,
4283 SkipBodyInfo *SkipBody = nullptr,
4284 FnBodyKind BodyKind = FnBodyKind::Other);
4286 SkipBodyInfo *SkipBody = nullptr,
4287 FnBodyKind BodyKind = FnBodyKind::Other);
4289
4290 /// Determine whether we can delay parsing the body of a function or
4291 /// function template until it is used, assuming we don't care about emitting
4292 /// code for that function.
4293 ///
4294 /// This will be \c false if we may need the body of the function in the
4295 /// middle of parsing an expression (where it's impractical to switch to
4296 /// parsing a different function), for instance, if it's constexpr in C++11
4297 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
4298 bool canDelayFunctionBody(const Declarator &D);
4299
4300 /// Determine whether we can skip parsing the body of a function
4301 /// definition, assuming we don't care about analyzing its body or emitting
4302 /// code for that function.
4303 ///
4304 /// This will be \c false only if we may need the body of the function in
4305 /// order to parse the rest of the program (for instance, if it is
4306 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
4307 bool canSkipFunctionBody(Decl *D);
4308
4309 /// Given the set of return statements within a function body,
4310 /// compute the variables that are subject to the named return value
4311 /// optimization.
4312 ///
4313 /// Each of the variables that is subject to the named return value
4314 /// optimization will be marked as NRVO variables in the AST, and any
4315 /// return statement that has a marked NRVO variable as its NRVO candidate can
4316 /// use the named return value optimization.
4317 ///
4318 /// This function applies a very simplistic algorithm for NRVO: if every
4319 /// return statement in the scope of a variable has the same NRVO candidate,
4320 /// that candidate is an NRVO variable.
4322
4323 /// Performs semantic analysis at the end of a function body.
4324 ///
4325 /// \param RetainFunctionScopeInfo If \c true, the client is responsible for
4326 /// releasing the associated \p FunctionScopeInfo. This is useful when
4327 /// building e.g. LambdaExprs.
4329 bool IsInstantiation = false,
4330 bool RetainFunctionScopeInfo = false);
4333
4334 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
4335 /// attribute for which parsing is delayed.
4337
4338 /// Diagnose any unused parameters in the given sequence of
4339 /// ParmVarDecl pointers.
4341
4342 /// Diagnose whether the size of parameters or return value of a
4343 /// function or obj-c method definition is pass-by-value and larger than a
4344 /// specified threshold.
4345 void
4347 QualType ReturnTy, NamedDecl *D);
4348
4350 SourceLocation RParenLoc);
4351
4354
4355 void ActOnPopScope(SourceLocation Loc, Scope *S);
4356
4357 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4358 /// no declarator (e.g. "struct foo;") is parsed.
4360 const ParsedAttributesView &DeclAttrs,
4361 RecordDecl *&AnonRecord);
4362
4363 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4364 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
4365 /// parameters to cope with template friend declarations.
4367 const ParsedAttributesView &DeclAttrs,
4368 MultiTemplateParamsArg TemplateParams,
4369 bool IsExplicitInstantiation,
4370 RecordDecl *&AnonRecord,
4371 SourceLocation EllipsisLoc = {});
4372
4373 /// BuildAnonymousStructOrUnion - Handle the declaration of an
4374 /// anonymous structure or union. Anonymous unions are a C++ feature
4375 /// (C++ [class.union]) and a C11 feature; anonymous structures
4376 /// are a C11 feature and GNU C++ extension.
4377 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
4378 RecordDecl *Record,
4379 const PrintingPolicy &Policy);
4380
4381 /// Called once it is known whether
4382 /// a tag declaration is an anonymous union or struct.
4384
4385 /// Emit diagnostic warnings for placeholder members.
4386 /// We can only do that after the class is fully constructed,
4387 /// as anonymous union/structs can insert placeholders
4388 /// in their parent scope (which might be a Record).
4390
4391 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
4392 /// Microsoft C anonymous structure.
4393 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
4394 /// Example:
4395 ///
4396 /// struct A { int a; };
4397 /// struct B { struct A; int b; };
4398 ///
4399 /// void foo() {
4400 /// B var;
4401 /// var.a = 3;
4402 /// }
4403 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
4404 RecordDecl *Record);
4405
4406 /// Given a non-tag type declaration, returns an enum useful for indicating
4407 /// what kind of non-tag type this is.
4408 NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
4409
4410 /// Determine whether a tag with a given kind is acceptable
4411 /// as a redeclaration of the given tag declaration.
4412 ///
4413 /// \returns true if the new tag kind is acceptable, false otherwise.
4415 bool isDefinition, SourceLocation NewTagLoc,
4416 const IdentifierInfo *Name);
4417
4418 /// This is invoked when we see 'struct foo' or 'struct {'. In the
4419 /// former case, Name will be non-null. In the later case, Name will be null.
4420 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
4421 /// a reference/declaration/definition of a tag.
4422 ///
4423 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
4424 /// trailing-type-specifier) other than one in an alias-declaration.
4425 ///
4426 /// \param SkipBody If non-null, will be set to indicate if the caller should
4427 /// skip the definition of this tag and treat it as if it were a declaration.
4428 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
4429 SourceLocation KWLoc, CXXScopeSpec &SS,
4430 IdentifierInfo *Name, SourceLocation NameLoc,
4431 const ParsedAttributesView &Attr, AccessSpecifier AS,
4432 SourceLocation ModulePrivateLoc,
4433 MultiTemplateParamsArg TemplateParameterLists,
4434 bool &OwnedDecl, bool &IsDependent,
4435 SourceLocation ScopedEnumKWLoc,
4436 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
4437 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
4438 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
4439
4440 /// ActOnField - Each field of a C struct/union is passed into this in order
4441 /// to create a FieldDecl object for it.
4442 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
4443 Declarator &D, Expr *BitfieldWidth);
4444
4445 /// HandleField - Analyze a field of a C struct or a C++ data member.
4446 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
4447 Declarator &D, Expr *BitfieldWidth,
4448 InClassInitStyle InitStyle, AccessSpecifier AS);
4449
4450 /// Build a new FieldDecl and check its well-formedness.
4451 ///
4452 /// This routine builds a new FieldDecl given the fields name, type,
4453 /// record, etc. \p PrevDecl should refer to any previous declaration
4454 /// with the same name and in the same scope as the field to be
4455 /// created.
4456 ///
4457 /// \returns a new FieldDecl.
4458 ///
4459 /// \todo The Declarator argument is a hack. It will be removed once
4460 FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
4461 TypeSourceInfo *TInfo, RecordDecl *Record,
4462 SourceLocation Loc, bool Mutable,
4463 Expr *BitfieldWidth, InClassInitStyle InitStyle,
4464 SourceLocation TSSL, AccessSpecifier AS,
4465 NamedDecl *PrevDecl, Declarator *D = nullptr);
4466
4468
4469 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
4470 /// class and class extensions. For every class \@interface and class
4471 /// extension \@interface, if the last ivar is a bitfield of any type,
4472 /// then add an implicit `char :0` ivar to the end of that interface.
4473 void ActOnLastBitfield(SourceLocation DeclStart,
4474 SmallVectorImpl<Decl *> &AllIvarDecls);
4475
4476 // This is used for both record definitions and ObjC interface declarations.
4477 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
4478 ArrayRef<Decl *> Fields, SourceLocation LBrac,
4479 SourceLocation RBrac, const ParsedAttributesView &AttrList);
4480
4481 /// ActOnTagStartDefinition - Invoked when we have entered the
4482 /// scope of a tag's definition (e.g., for an enumeration, class,
4483 /// struct, or union).
4484 void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
4485
4486 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
4487 /// Differently from C++, actually parse the body and reject / error out
4488 /// in case of a structural mismatch.
4489 bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody);
4490
4492
4493 /// Invoked when we enter a tag definition that we're skipping.
4495
4496 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
4497 /// C++ record definition's base-specifiers clause and are starting its
4498 /// member declarations.
4500 SourceLocation FinalLoc,
4501 bool IsFinalSpelledSealed,
4502 bool IsAbstract,
4503 SourceLocation LBraceLoc);
4504
4505 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
4506 /// the definition of a tag (enumeration, class, struct, or union).
4508 SourceRange BraceRange);
4509
4512
4514
4515 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
4516 /// error parsing the definition of a tag.
4518
4520 EnumConstantDecl *LastEnumConst,
4521 SourceLocation IdLoc, IdentifierInfo *Id,
4522 Expr *val);
4523
4524 /// Check that this is a valid underlying type for an enum declaration.
4526
4527 /// Check whether this is a valid redeclaration of a previous enumeration.
4528 /// \return true if the redeclaration was invalid.
4529 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
4530 QualType EnumUnderlyingTy, bool IsFixed,
4531 const EnumDecl *Prev);
4532
4533 /// Determine whether the body of an anonymous enumeration should be skipped.
4534 /// \param II The name of the first enumerator.
4536 SourceLocation IILoc);
4537
4538 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
4539 SourceLocation IdLoc, IdentifierInfo *Id,
4540 const ParsedAttributesView &Attrs,
4541 SourceLocation EqualLoc, Expr *Val,
4542 SkipBodyInfo *SkipBody = nullptr);
4543 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
4544 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
4545 const ParsedAttributesView &Attr);
4546
4547 /// Set the current declaration context until it gets popped.
4548 void PushDeclContext(Scope *S, DeclContext *DC);
4549 void PopDeclContext();
4550
4551 /// EnterDeclaratorContext - Used when we must lookup names in the context
4552 /// of a declarator's nested name specifier.
4555
4556 /// Enter a template parameter scope, after it's been associated with a
4557 /// particular DeclContext. Causes lookup within the scope to chain through
4558 /// enclosing contexts in the correct order.
4560
4561 /// Push the parameters of D, which must be a function, into scope.
4564
4565 /// Add this decl to the scope shadowed decl chains.
4566 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4567
4568 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4569 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4570 /// true if 'D' belongs to the given declaration context.
4571 ///
4572 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4573 /// enclosing namespace set of the context, rather than contained
4574 /// directly within it.
4575 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4576 bool AllowInlineNamespace = false) const;
4577
4578 /// Determine whether a tag-like declaration found by lookup can be
4579 /// redeclared in the given scope. If lookup found a using-shadow, also
4580 /// consider the scope of the declaration named by the using-shadow.
4582 Scope *S = nullptr,
4583 bool AllowInlineNamespace = false) const;
4584
4585 /// Finds the scope corresponding to the given decl context, if it
4586 /// happens to be an enclosing scope. Otherwise return NULL.
4588
4589 /// Subroutines of ActOnDeclarator().
4591 TypeSourceInfo *TInfo);
4593
4594 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4596 NamedDecl *New, Decl *Old,
4598
4599 /// CheckAttributesOnDeducedType - Calls Sema functions for attributes that
4600 /// requires the type to be deduced.
4602
4603 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4604 /// same name and scope as a previous declaration 'Old'. Figure out
4605 /// how to resolve this situation, merging decls or emitting
4606 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4608 LookupResult &OldDecls);
4609
4610 /// CleanupMergedEnum - We have just merged the decl 'New' by making another
4611 /// definition visible.
4612 /// This method performs any necessary cleanup on the parser state to discard
4613 /// child nodes from newly parsed decl we are retiring.
4614 void CleanupMergedEnum(Scope *S, Decl *New);
4615
4616 /// MergeFunctionDecl - We just parsed a function 'New' from
4617 /// declarator D which has the same name and scope as a previous
4618 /// declaration 'Old'. Figure out how to resolve this situation,
4619 /// merging decls or emitting diagnostics as appropriate.
4620 ///
4621 /// In C++, New and Old must be declarations that are not
4622 /// overloaded. Use IsOverload to determine whether New and Old are
4623 /// overloaded, and to select the Old declaration that New should be
4624 /// merged with.
4625 ///
4626 /// Returns true if there was an error, false otherwise.
4628 bool MergeTypeWithOld, bool NewDeclIsDefn);
4629
4630 /// Completes the merge of two function declarations that are
4631 /// known to be compatible.
4632 ///
4633 /// This routine handles the merging of attributes and other
4634 /// properties of function declarations from the old declaration to
4635 /// the new declaration, once we know that New is in fact a
4636 /// redeclaration of Old.
4637 ///
4638 /// \returns false
4640 Scope *S, bool MergeTypeWithOld);
4642
4643 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4644 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4645 /// situation, merging decls or emitting diagnostics as appropriate.
4646 ///
4647 /// Tentative definition rules (C99 6.9.2p2) are checked by
4648 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4649 /// definitions here, since the initializer hasn't been attached.
4651
4652 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4653 /// scope as a previous declaration 'Old'. Figure out how to merge their
4654 /// types, emitting diagnostics as appropriate.
4655 ///
4656 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4657 /// back to here in AddInitializerToDecl. We can't check them before the
4658 /// initializer is attached.
4659 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4660
4661 /// We've just determined that \p Old and \p New both appear to be definitions
4662 /// of the same variable. Either diagnose or fix the problem.
4663 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4665
4666 /// Filters out lookup results that don't fall within the given scope
4667 /// as determined by isDeclInScope.
4669 bool ConsiderLinkage, bool AllowInlineNamespace);
4670
4671 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4672 /// have compatible owning modules.
4674
4675 /// [module.interface]p6:
4676 /// A redeclaration of an entity X is implicitly exported if X was introduced
4677 /// by an exported declaration; otherwise it shall not be exported.
4679
4680 /// A wrapper function for checking the semantic restrictions of
4681 /// a redeclaration within a module.
4683
4684 /// Check the redefinition in C++20 Modules.
4685 ///
4686 /// [basic.def.odr]p14:
4687 /// For any definable item D with definitions in multiple translation units,
4688 /// - if D is a non-inline non-templated function or variable, or
4689 /// - if the definitions in different translation units do not satisfy the
4690 /// following requirements,
4691 /// the program is ill-formed; a diagnostic is required only if the
4692 /// definable item is attached to a named module and a prior definition is
4693 /// reachable at the point where a later definition occurs.
4694 /// - Each such definition shall not be attached to a named module
4695 /// ([module.unit]).
4696 /// - Each such definition shall consist of the same sequence of tokens, ...
4697 /// ...
4698 ///
4699 /// Return true if the redefinition is not allowed. Return false otherwise.
4700 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4701
4703
4704 /// If it's a file scoped decl that must warn if not used, keep track
4705 /// of it.
4707
4708 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4710
4713 DiagReceiverTy DiagReceiver);
4714 void DiagnoseUnusedDecl(const NamedDecl *ND);
4715
4716 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4717 /// unless they are marked attr(unused).
4718 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4719
4720 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4721 /// variable.
4722 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4723
4724 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4725 /// from S, where a non-field would be declared. This routine copes
4726 /// with the difference between C and C++ scoping rules in structs and
4727 /// unions. For example, the following code is well-formed in C but
4728 /// ill-formed in C++:
4729 /// @code
4730 /// struct S6 {
4731 /// enum { BAR } e;
4732 /// };
4733 ///
4734 /// void test_S6() {
4735 /// struct S6 a;
4736 /// a.e = BAR;
4737 /// }
4738 /// @endcode
4739 /// For the declaration of BAR, this routine will return a different
4740 /// scope. The scope S will be the scope of the unnamed enumeration
4741 /// within S6. In C++, this routine will return the scope associated
4742 /// with S6, because the enumeration's scope is a transparent
4743 /// context but structures can contain non-field names. In C, this
4744 /// routine will return the translation unit scope, since the
4745 /// enumeration's scope is a transparent context and structures cannot
4746 /// contain non-field names.
4748
4750 SourceLocation Loc);
4751
4752 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4753 /// file scope. lazily create a decl for it. ForRedeclaration is true
4754 /// if we're creating this built-in in anticipation of redeclaring the
4755 /// built-in.
4756 NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S,
4757 bool ForRedeclaration, SourceLocation Loc);
4758
4759 /// Get the outermost AttributedType node that sets a calling convention.
4760 /// Valid types should not have multiple attributes with different CCs.
4761 const AttributedType *getCallingConvAttributedType(QualType T) const;
4762
4763 /// GetNameForDeclarator - Determine the full declaration name for the
4764 /// given Declarator.
4766
4767 /// Retrieves the declaration name from a parsed unqualified-id.
4769
4770 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4771 /// we are currently parsing the initializer.
4773
4774 /// Look for a locally scoped extern "C" declaration by the given name.
4776
4779
4780 /// Adjust the \c DeclContext for a function or variable that might be a
4781 /// function-local external declaration.
4783
4785
4786 /// Checks if the variant/multiversion functions are compatible.
4788 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4789 const PartialDiagnostic &NoProtoDiagID,
4790 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4791 const PartialDiagnosticAt &NoSupportDiagIDAt,
4792 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4793 bool ConstexprSupported, bool CLinkageMayDiffer);
4794
4795 /// type checking declaration initializers (C99 6.7.8)
4797 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4798
4801 SourceRange Range, bool DirectInit,
4802 Expr *Init);
4803
4805 Expr *Init);
4806
4808
4809 // Heuristically tells if the function is `get_return_object` member of a
4810 // coroutine promise_type by matching the function name.
4811 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4812 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4813
4814 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4815 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4817 Scope *S);
4818
4819 /// If this function is a C++ replaceable global allocation function
4820 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4821 /// adds any function attributes that we know a priori based on the standard.
4822 ///
4823 /// We need to check for duplicate attributes both here and where user-written
4824 /// attributes are applied to declarations.
4826 FunctionDecl *FD);
4827
4828 /// Adds any function attributes that we know a priori based on
4829 /// the declaration of this function.
4830 ///
4831 /// These attributes can apply both to implicitly-declared builtins
4832 /// (like __builtin___printf_chk) or to library-declared functions
4833 /// like NSLog or printf.
4834 ///
4835 /// We need to check for duplicate attributes both here and where user-written
4836 /// attributes are applied to declarations.
4838
4839 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4840 /// the correct width, and that the field type is valid.
4841 /// Returns false on success.
4843 const IdentifierInfo *FieldName, QualType FieldTy,
4844 bool IsMsStruct, Expr *BitWidth);
4845
4846 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4847 /// enum. If AllowMask is true, then we also allow the complement of a valid
4848 /// value, to be used as a mask.
4849 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4850 bool AllowMask) const;
4851
4852 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4853 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4854 SourceLocation WeakNameLoc);
4855
4856 /// ActOnPragmaRedefineExtname - Called on well formed
4857 /// \#pragma redefine_extname oldname newname.
4859 IdentifierInfo *AliasName,
4860 SourceLocation PragmaLoc,
4861 SourceLocation WeakNameLoc,
4862 SourceLocation AliasNameLoc);
4863
4864 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4865 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4866 SourceLocation PragmaLoc,
4867 SourceLocation WeakNameLoc,
4868 SourceLocation AliasNameLoc);
4869
4870 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4873 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4874 OMPDiscarded, // Discarded due to OpenMP hostness
4875 TemplateDiscarded, // Discarded due to uninstantiated templates
4877 };
4878 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4879 bool Final = false);
4880
4881 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4883
4884 /// Function or variable declarations to be checked for whether the deferred
4885 /// diagnostics should be emitted.
4887
4888private:
4889 /// Map of current shadowing declarations to shadowed declarations. Warn if
4890 /// it looks like the user is trying to modify the shadowing declaration.
4891 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4892
4893 // We need this to handle
4894 //
4895 // typedef struct {
4896 // void *foo() { return 0; }
4897 // } A;
4898 //
4899 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4900 // for example. If 'A', foo will have external linkage. If we have '*A',
4901 // foo will have no linkage. Since we can't know until we get to the end
4902 // of the typedef, this function finds out if D might have non-external
4903 // linkage. Callers should verify at the end of the TU if it D has external
4904 // linkage or not.
4905 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4906
4907#include "clang/Sema/AttrIsTypeDependent.inc"
4908
4909 ///@}
4910
4911 //
4912 //
4913 // -------------------------------------------------------------------------
4914 //
4915 //
4916
4917 /// \name Declaration Attribute Handling
4918 /// Implementations are in SemaDeclAttr.cpp
4919 ///@{
4920
4921public:
4922 /// Describes the kind of priority given to an availability attribute.
4923 ///
4924 /// The sum of priorities deteremines the final priority of the attribute.
4925 /// The final priority determines how the attribute will be merged.
4926 /// An attribute with a lower priority will always remove higher priority
4927 /// attributes for the specified platform when it is being applied. An
4928 /// attribute with a higher priority will not be applied if the declaration
4929 /// already has an availability attribute with a lower priority for the
4930 /// specified platform. The final prirority values are not expected to match
4931 /// the values in this enumeration, but instead should be treated as a plain
4932 /// integer value. This enumeration just names the priority weights that are
4933 /// used to calculate that final vaue.
4935 /// The availability attribute was specified explicitly next to the
4936 /// declaration.
4938
4939 /// The availability attribute was applied using '#pragma clang attribute'.
4941
4942 /// The availability attribute for a specific platform was inferred from
4943 /// an availability attribute for another platform.
4945
4946 /// The availability attribute was inferred from an 'anyAppleOS'
4947 /// availability attribute.
4949
4950 /// The availability attribute was inferred from an 'anyAppleOS'
4951 /// availability attribute that was applied using '#pragma clang attribute'.
4952 /// This has the lowest priority.
4954 };
4955
4956 /// Describes the reason a calling convention specification was ignored, used
4957 /// for diagnostics.
4964
4965 /// A helper function to provide Attribute Location for the Attr types
4966 /// AND the ParsedAttr.
4967 template <typename AttrInfo>
4968 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4969 getAttrLoc(const AttrInfo &AL) {
4970 return AL.getLocation();
4971 }
4973
4974 /// If Expr is a valid integer constant, get the value of the integer
4975 /// expression and return success or failure. May output an error.
4976 ///
4977 /// Negative argument is implicitly converted to unsigned, unless
4978 /// \p StrictlyUnsigned is true.
4979 template <typename AttrInfo>
4980 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4981 unsigned Idx = UINT_MAX,
4982 bool StrictlyUnsigned = false) {
4983 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4984 if (Expr->isTypeDependent() ||
4986 if (Idx != UINT_MAX)
4987 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4988 << &AI << Idx << AANT_ArgumentIntegerConstant
4989 << Expr->getSourceRange();
4990 else
4991 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4993 return false;
4994 }
4995
4996 if (!I->isIntN(32)) {
4997 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4998 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4999 return false;
5000 }
5001
5002 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
5003 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
5004 << &AI << /*non-negative*/ 1;
5005 return false;
5006 }
5007
5008 Val = (uint32_t)I->getZExtValue();
5009 return true;
5010 }
5011
5012 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
5013 /// \#pragma weak during processing of other Decls.
5014 /// I couldn't figure out a clean way to generate these in-line, so
5015 /// we store them here and handle separately -- which is a hack.
5016 /// It would be best to refactor this.
5018
5019 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
5021
5023 2, 2>
5025
5026 /// ExtVectorDecls - This is a list all the extended vector types. This allows
5027 /// us to associate a raw vector type with one of the ext_vector type names.
5028 /// This is only necessary for issuing pretty diagnostics.
5030
5031 /// Check if the argument \p E is a ASCII string literal. If not emit an error
5032 /// and return false, otherwise set \p Str to the value of the string literal
5033 /// and return true.
5035 const Expr *E, StringRef &Str,
5036 SourceLocation *ArgLocation = nullptr);
5037
5038 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
5039 /// If not emit an error and return false. If the argument is an identifier it
5040 /// will emit an error with a fixit hint and treat it as if it was a string
5041 /// literal.
5042 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
5043 StringRef &Str,
5044 SourceLocation *ArgLocation = nullptr);
5045
5046 /// Determine if type T is a valid subject for a nonnull and similar
5047 /// attributes. Dependent types are considered valid so they can be checked
5048 /// during instantiation time. By default, we look through references (the
5049 /// behavior used by nonnull), but if the second parameter is true, then we
5050 /// treat a reference type as valid.
5051 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
5052
5053 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
5054 /// declaration.
5055 void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
5056 Expr *OE);
5057
5058 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
5059 /// declaration.
5060 void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
5061 Expr *ParamExpr);
5062
5063 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
5064 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
5065
5066 AvailabilityAttr *
5068 const IdentifierInfo *Platform, bool Implicit,
5069 VersionTuple Introduced, VersionTuple Deprecated,
5070 VersionTuple Obsoleted, bool IsUnavailable,
5071 StringRef Message, bool IsStrict, StringRef Replacement,
5072 AvailabilityMergeKind AMK, int Priority,
5073 const IdentifierInfo *IIEnvironment,
5074 const IdentifierInfo *InferredPlatformII = nullptr);
5075
5076 AvailabilityAttr *mergeAndInferAvailabilityAttr(
5077 NamedDecl *D, const AttributeCommonInfo &CI,
5078 const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced,
5079 VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable,
5080 StringRef Message, bool IsStrict, StringRef Replacement,
5081 AvailabilityMergeKind AMK, int Priority,
5082 const IdentifierInfo *IIEnvironment,
5083 const IdentifierInfo *InferredPlatformII);
5084
5085 TypeVisibilityAttr *
5087 TypeVisibilityAttr::VisibilityType Vis);
5088 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
5089 VisibilityAttr::VisibilityType Vis);
5091 VisibilityAttr::VisibilityType Type);
5092 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
5093 StringRef Name);
5094
5095 /// Used to implement to perform semantic checking on
5096 /// attribute((section("foo"))) specifiers.
5097 ///
5098 /// In this case, "foo" is passed in to be checked. If the section
5099 /// specifier is invalid, return an Error that indicates the problem.
5100 ///
5101 /// This is a simple quality of implementation feature to catch errors
5102 /// and give good diagnostics in cases when the assembler or code generator
5103 /// would otherwise reject the section specifier.
5104 llvm::Error isValidSectionSpecifier(StringRef Str);
5105 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
5106 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
5107 StringRef Name);
5108
5109 // Check for things we'd like to warn about. Multiversioning issues are
5110 // handled later in the process, once we know how many exist.
5111 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
5112
5113 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
5114 StringRef NewUserDiagnostic);
5115 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
5116 const IdentifierInfo *Format, int FormatIdx,
5117 int FirstArg);
5118 FormatMatchesAttr *mergeFormatMatchesAttr(Decl *D,
5119 const AttributeCommonInfo &CI,
5120 const IdentifierInfo *Format,
5121 int FormatIdx,
5122 StringLiteral *FormatStr);
5123 ModularFormatAttr *mergeModularFormatAttr(Decl *D,
5124 const AttributeCommonInfo &CI,
5125 const IdentifierInfo *ModularImplFn,
5126 StringRef ImplName,
5128
5129 PersonalityAttr *mergePersonalityAttr(Decl *D, FunctionDecl *Routine,
5130 const AttributeCommonInfo &CI);
5131
5132 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
5133 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
5134 bool IsPackExpansion);
5136 bool IsPackExpansion);
5137
5138 /// AddAlignValueAttr - Adds an align_value attribute to a particular
5139 /// declaration.
5140 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
5141
5142 /// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
5143 Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
5146
5148 bool BestCase,
5149 MSInheritanceModel SemanticSpelling);
5150
5152
5153 /// AddModeAttr - Adds a mode attribute to a particular declaration.
5154 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
5155 const IdentifierInfo *Name, bool InInstantiation = false);
5156 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
5157 const AttributeCommonInfo &CI,
5158 const IdentifierInfo *Ident);
5159 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
5160 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
5161 const AttributeCommonInfo &CI);
5162 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
5163 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
5164 const InternalLinkageAttr &AL);
5165
5166 /// Check validaty of calling convention attribute \p attr. If \p FD
5167 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
5168 /// target. Otherwise, it is specified by \p CFT.
5170 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
5172
5173 /// Checks a regparm attribute, returning true if it is ill-formed and
5174 /// otherwise setting numParams to the appropriate value.
5175 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
5176
5177 /// Create a CUDALaunchBoundsAttr attribute. By default, the function only
5178 /// supports nvptx target architectures and skips MaxBlocks if it is previous
5179 /// to sm_90. Use \p IgnoreArch to skip the architecture check.
5180 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
5181 Expr *MaxThreads,
5182 Expr *MinBlocks, Expr *MaxBlocks,
5183 bool IgnoreArch = false);
5184
5185 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
5186 /// declaration.
5187 void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
5188 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
5189
5190 /// Add a cluster_dims attribute to a particular declaration.
5191 CUDAClusterDimsAttr *createClusterDimsAttr(const AttributeCommonInfo &CI,
5192 Expr *X, Expr *Y, Expr *Z);
5193 void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X,
5194 Expr *Y, Expr *Z);
5195 /// Add a no_cluster attribute to a particular declaration.
5196 void addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI);
5197
5198 enum class RetainOwnershipKind { NS, CF, OS };
5199
5200 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
5201 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
5202
5203 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
5204
5205 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
5206 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
5207 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
5208 const AttributeCommonInfo &CI,
5209 bool BestCase,
5210 MSInheritanceModel Model);
5211
5212 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
5213 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
5214 const EnforceTCBLeafAttr &AL);
5215
5216 /// Helper for delayed processing TransparentUnion or
5217 /// BPFPreserveAccessIndexAttr attribute.
5219 const ParsedAttributesView &AttrList);
5220
5221 // Options for ProcessDeclAttributeList().
5225
5228 Result.IncludeCXX11Attributes = Val;
5229 return Result;
5230 }
5231
5234 Result.IgnoreTypeAttributes = Val;
5235 return Result;
5236 }
5237
5238 // Should C++11 attributes be processed?
5240
5241 // Should any type attributes encountered be ignored?
5242 // If this option is false, a diagnostic will be emitted for any type
5243 // attributes of a kind that does not "slide" from the declaration to
5244 // the decl-specifier-seq.
5246 };
5247
5248 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
5249 /// attribute list to the specified decl, ignoring any type attributes.
5251 const ParsedAttributesView &AttrList,
5252 const ProcessDeclAttributeOptions &Options =
5254
5255 /// Annotation attributes are the only attributes allowed after an access
5256 /// specifier.
5258 const ParsedAttributesView &AttrList);
5259
5260 /// checkUnusedDeclAttributes - Given a declarator which is not being
5261 /// used to build a declaration, complain about any decl attributes
5262 /// which might be lying around on it.
5264
5265 void DiagnoseUnknownAttribute(const ParsedAttr &AL);
5266
5267 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
5268 /// \#pragma weak needs a non-definition decl and source may not have one.
5270 SourceLocation Loc);
5271
5272 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
5273 /// applied to it, possibly with an alias.
5274 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
5275
5276 void ProcessPragmaWeak(Scope *S, Decl *D);
5277 // Decl attributes - this routine is the top level dispatcher.
5278 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
5279
5281
5282 /// Given a set of delayed diagnostics, re-emit them as if they had
5283 /// been delayed in the current context instead of in the given pool.
5284 /// Essentially, this just moves them to the current pool.
5286
5287 /// Check that the type is a plain record with one field being a pointer
5288 /// type and the other field being an integer. This matches the common
5289 /// implementation of std::span or sized_allocation_t in P0901R11.
5290 bool CheckSpanLikeType(const AttributeCommonInfo &CI, const QualType &Ty);
5291
5292 /// Check if IdxExpr is a valid parameter index for a function or
5293 /// instance method D. May output an error.
5294 ///
5295 /// \returns true if IdxExpr is a valid index.
5296 template <typename AttrInfo>
5298 const Decl *D, const AttrInfo &AI, unsigned AttrArgNum,
5299 const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis = false,
5300 bool CanIndexVariadicArguments = false) {
5302
5303 // In C++ the implicit 'this' function parameter also counts.
5304 // Parameters are counted from one.
5305 bool HP = hasFunctionProto(D);
5306 bool IV = HP && isFunctionOrMethodVariadic(D);
5307 unsigned NumParams =
5308 HP ? getFunctionOrMethodNumParams(D, /*IncludeThis=*/true) : 0;
5309
5310 std::optional<llvm::APSInt> IdxInt;
5311 if (IdxExpr->isTypeDependent() ||
5312 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
5313 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
5314 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
5315 << IdxExpr->getSourceRange();
5316 return false;
5317 }
5318
5319 constexpr unsigned Limit = 1 << ParamIdx::IdxBitWidth;
5320 unsigned IdxSource = IdxInt->getLimitedValue(Limit);
5321 if (IdxSource < 1 || IdxSource == Limit ||
5322 ((!IV || !CanIndexVariadicArguments) && IdxSource > NumParams)) {
5323 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
5324 << &AI << AttrArgNum << IdxExpr->getSourceRange();
5325 return false;
5326 }
5327 if (hasImplicitObjectParameter(D) && !CanIndexImplicitThis) {
5328 if (IdxSource == 1) {
5329 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
5330 << &AI << IdxExpr->getSourceRange();
5331 return false;
5332 }
5333 }
5334
5335 Idx = ParamIdx(IdxSource, D);
5336 return true;
5337 }
5338
5339 ///@}
5340
5341 //
5342 //
5343 // -------------------------------------------------------------------------
5344 //
5345 //
5346
5347 /// \name C++ Declarations
5348 /// Implementations are in SemaDeclCXX.cpp
5349 ///@{
5350
5351public:
5353
5354 /// Called before parsing a function declarator belonging to a function
5355 /// declaration.
5357 unsigned TemplateParameterDepth);
5358
5359 /// Called after parsing a function declarator belonging to a function
5360 /// declaration.
5362
5363 // Act on C++ namespaces
5365 SourceLocation NamespaceLoc,
5366 SourceLocation IdentLoc, IdentifierInfo *Ident,
5367 SourceLocation LBrace,
5368 const ParsedAttributesView &AttrList,
5369 UsingDirectiveDecl *&UsingDecl, bool IsNested);
5370
5371 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
5372 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
5373 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
5374
5376
5377 /// Retrieve the special "std" namespace, which may require us to
5378 /// implicitly define the namespace.
5380
5382 EnumDecl *getStdAlignValT() const;
5383
5386 QualType AllocType, SourceLocation);
5387
5389 const IdentifierInfo *MemberOrBase);
5390
5392 /// The '<=>' operator was used in an expression and a builtin operator
5393 /// was selected.
5395 /// A defaulted 'operator<=>' needed the comparison category. This
5396 /// typically only applies to 'std::strong_ordering', due to the implicit
5397 /// fallback return value.
5399 /// A builtin needed 'std::strong_ordering' (eg. '__builtin_type_order').
5401 };
5402
5403 /// Lookup the specified comparison category types in the standard
5404 /// library, an check the VarDecls possibly returned by the operator<=>
5405 /// builtins for that type.
5406 ///
5407 /// \return The type of the comparison category type corresponding to the
5408 /// specified Kind, or a null type if an error occurs
5410 SourceLocation Loc,
5412
5413 /// Tests whether Ty is an instance of std::initializer_list and, if
5414 /// it is and Element is not NULL, assigns the element type to Element.
5415 bool isStdInitializerList(QualType Ty, QualType *Element);
5416
5417 /// Tests whether Ty is an instance of std::type_identity and, if
5418 /// it is and TypeArgument is not NULL, assigns the element type to Element.
5419 /// If MalformedDecl is not null, and type_identity was ruled out due to being
5420 /// incorrectly structured despite having the correct name, the faulty Decl
5421 /// will be assigned to MalformedDecl.
5422 bool isStdTypeIdentity(QualType Ty, QualType *TypeArgument,
5423 const Decl **MalformedDecl = nullptr);
5424
5425 /// Looks for the std::initializer_list template and instantiates it
5426 /// with Element, or emits an error if it's not found.
5427 ///
5428 /// \returns The instantiated template, or null on error.
5430
5431 /// Looks for the std::type_identity template and instantiates it
5432 /// with Type, or returns a null type if type_identity has not been declared
5433 ///
5434 /// \returns The instantiated template, or null if std::type_identity is not
5435 /// declared
5437
5438 /// Determine whether Ctor is an initializer-list constructor, as
5439 /// defined in [dcl.init.list]p2.
5440 bool isInitListConstructor(const FunctionDecl *Ctor);
5441
5442 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
5443 SourceLocation NamespcLoc, CXXScopeSpec &SS,
5444 SourceLocation IdentLoc,
5445 IdentifierInfo *NamespcName,
5446 const ParsedAttributesView &AttrList);
5447
5449
5450 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
5451 SourceLocation AliasLoc, IdentifierInfo *Alias,
5452 CXXScopeSpec &SS, SourceLocation IdentLoc,
5453 IdentifierInfo *Ident);
5454
5455 /// Remove decls we can't actually see from a lookup being used to declare
5456 /// shadow using decls.
5457 ///
5458 /// \param S - The scope of the potential shadow decl
5459 /// \param Previous - The lookup of a potential shadow decl's name.
5460 void FilterUsingLookup(Scope *S, LookupResult &lookup);
5461
5462 /// Hides a using shadow declaration. This is required by the current
5463 /// using-decl implementation when a resolvable using declaration in a
5464 /// class is followed by a declaration which would hide or override
5465 /// one or more of the using decl's targets; for example:
5466 ///
5467 /// struct Base { void foo(int); };
5468 /// struct Derived : Base {
5469 /// using Base::foo;
5470 /// void foo(int);
5471 /// };
5472 ///
5473 /// The governing language is C++03 [namespace.udecl]p12:
5474 ///
5475 /// When a using-declaration brings names from a base class into a
5476 /// derived class scope, member functions in the derived class
5477 /// override and/or hide member functions with the same name and
5478 /// parameter types in a base class (rather than conflicting).
5479 ///
5480 /// There are two ways to implement this:
5481 /// (1) optimistically create shadow decls when they're not hidden
5482 /// by existing declarations, or
5483 /// (2) don't create any shadow decls (or at least don't make them
5484 /// visible) until we've fully parsed/instantiated the class.
5485 /// The problem with (1) is that we might have to retroactively remove
5486 /// a shadow decl, which requires several O(n) operations because the
5487 /// decl structures are (very reasonably) not designed for removal.
5488 /// (2) avoids this but is very fiddly and phase-dependent.
5489 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
5490
5491 /// Determines whether to create a using shadow decl for a particular
5492 /// decl, given the set of decls existing prior to this using lookup.
5494 const LookupResult &PreviousDecls,
5495 UsingShadowDecl *&PrevShadow);
5496
5497 /// Builds a shadow declaration corresponding to a 'using' declaration.
5500 UsingShadowDecl *PrevDecl);
5501
5502 /// Checks that the given using declaration is not an invalid
5503 /// redeclaration. Note that this is checking only for the using decl
5504 /// itself, not for any ill-formedness among the UsingShadowDecls.
5506 bool HasTypenameKeyword,
5507 const CXXScopeSpec &SS,
5508 SourceLocation NameLoc,
5509 const LookupResult &Previous);
5510
5511 /// Checks that the given nested-name qualifier used in a using decl
5512 /// in the current context is appropriately related to the current
5513 /// scope. If an error is found, diagnoses it and returns true.
5514 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
5515 /// the result of that lookup. UD is likewise nullptr, except when we have an
5516 /// already-populated UsingDecl whose shadow decls contain the same
5517 /// information (i.e. we're instantiating a UsingDecl with non-dependent
5518 /// scope).
5519 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
5520 const CXXScopeSpec &SS,
5521 const DeclarationNameInfo &NameInfo,
5522 SourceLocation NameLoc,
5523 const LookupResult *R = nullptr,
5524 const UsingDecl *UD = nullptr);
5525
5526 /// Builds a using declaration.
5527 ///
5528 /// \param IsInstantiation - Whether this call arises from an
5529 /// instantiation of an unresolved using declaration. We treat
5530 /// the lookup differently for these declarations.
5532 SourceLocation UsingLoc,
5533 bool HasTypenameKeyword,
5534 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5535 DeclarationNameInfo NameInfo,
5536 SourceLocation EllipsisLoc,
5537 const ParsedAttributesView &AttrList,
5538 bool IsInstantiation, bool IsUsingIfExists);
5540 SourceLocation UsingLoc,
5541 SourceLocation EnumLoc,
5542 SourceLocation NameLoc,
5543 TypeSourceInfo *EnumType, EnumDecl *ED);
5544 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
5545 ArrayRef<NamedDecl *> Expansions);
5546
5547 /// Additional checks for a using declaration referring to a constructor name.
5549
5550 /// Given a derived-class using shadow declaration for a constructor and the
5551 /// correspnding base class constructor, find or create the implicit
5552 /// synthesized derived class constructor to use for this initialization.
5555 ConstructorUsingShadowDecl *DerivedShadow);
5556
5558 SourceLocation UsingLoc,
5559 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5560 UnqualifiedId &Name, SourceLocation EllipsisLoc,
5561 const ParsedAttributesView &AttrList);
5563 SourceLocation UsingLoc,
5564 SourceLocation EnumLoc, SourceRange TyLoc,
5565 const IdentifierInfo &II, ParsedType Ty,
5566 const CXXScopeSpec &SS);
5568 MultiTemplateParamsArg TemplateParams,
5569 SourceLocation UsingLoc, UnqualifiedId &Name,
5570 const ParsedAttributesView &AttrList,
5571 TypeResult Type, Decl *DeclFromDeclSpec);
5572
5573 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
5574 /// including handling of its default argument expressions.
5575 ///
5576 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
5578 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5580 bool HadMultipleCandidates, bool IsListInitialization,
5581 bool IsStdInitListInitialization, bool RequiresZeroInit,
5582 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5583
5584 /// Build a CXXConstructExpr whose constructor has already been resolved if
5585 /// it denotes an inherited constructor.
5587 SourceLocation ConstructLoc, QualType DeclInitType,
5588 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5589 bool HadMultipleCandidates, bool IsListInitialization,
5590 bool IsStdInitListInitialization, bool RequiresZeroInit,
5591 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5592
5593 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
5594 // the constructor can be elidable?
5596 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5597 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5598 bool HadMultipleCandidates, bool IsListInitialization,
5599 bool IsStdInitListInitialization, bool RequiresZeroInit,
5600 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5601
5603 SourceLocation InitLoc);
5605 const InitializedEntity &Entity,
5606 Expr *InitExpr,
5607 SourceLocation InitLoc);
5608
5609 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
5610 /// constructed variable.
5611 void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit);
5612
5613 /// Helper class that collects exception specifications for
5614 /// implicitly-declared special member functions.
5616 // Pointer to allow copying
5617 Sema *Self;
5618 // We order exception specifications thus:
5619 // noexcept is the most restrictive, but is only used in C++11.
5620 // throw() comes next.
5621 // Then a throw(collected exceptions)
5622 // Finally no specification, which is expressed as noexcept(false).
5623 // throw(...) is used instead if any called function uses it.
5624 ExceptionSpecificationType ComputedEST;
5625 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5626 SmallVector<QualType, 4> Exceptions;
5627
5628 void ClearExceptions() {
5629 ExceptionsSeen.clear();
5630 Exceptions.clear();
5631 }
5632
5633 public:
5635 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5636 if (!Self.getLangOpts().CPlusPlus11)
5637 ComputedEST = EST_DynamicNone;
5638 }
5639
5640 /// Get the computed exception specification type.
5642 assert(!isComputedNoexcept(ComputedEST) &&
5643 "noexcept(expr) should not be a possible result");
5644 return ComputedEST;
5645 }
5646
5647 /// The number of exceptions in the exception specification.
5648 unsigned size() const { return Exceptions.size(); }
5649
5650 /// The set of exceptions in the exception specification.
5651 const QualType *data() const { return Exceptions.data(); }
5652
5653 /// Integrate another called method into the collected data.
5654 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5655
5656 /// Integrate an invoked expression into the collected data.
5657 void CalledExpr(Expr *E) { CalledStmt(E); }
5658
5659 /// Integrate an invoked statement into the collected data.
5660 void CalledStmt(Stmt *S);
5661
5662 /// Overwrite an EPI's exception specification with this
5663 /// computed exception specification.
5666 ESI.Type = getExceptionSpecType();
5667 if (ESI.Type == EST_Dynamic) {
5668 ESI.Exceptions = Exceptions;
5669 } else if (ESI.Type == EST_None) {
5670 /// C++11 [except.spec]p14:
5671 /// The exception-specification is noexcept(false) if the set of
5672 /// potential exceptions of the special member function contains "any"
5673 ESI.Type = EST_NoexceptFalse;
5674 ESI.NoexceptExpr =
5675 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5676 }
5677 return ESI;
5678 }
5679 };
5680
5681 /// Evaluate the implicit exception specification for a defaulted
5682 /// special member function.
5684
5685 /// Check the given exception-specification and update the
5686 /// exception specification information with the results.
5687 void checkExceptionSpecification(bool IsTopLevel,
5689 ArrayRef<ParsedType> DynamicExceptions,
5690 ArrayRef<SourceRange> DynamicExceptionRanges,
5691 Expr *NoexceptExpr,
5692 SmallVectorImpl<QualType> &Exceptions,
5694
5695 /// Add an exception-specification to the given member or friend function
5696 /// (or function template). The exception-specification was parsed
5697 /// after the function itself was declared.
5699 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5700 ArrayRef<ParsedType> DynamicExceptions,
5701 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5702
5703 class InheritedConstructorInfo;
5704
5705 /// Determine if a special member function should have a deleted
5706 /// definition when it is defaulted.
5708 InheritedConstructorInfo *ICI = nullptr,
5709 bool Diagnose = false);
5710
5711 /// Produce notes explaining why a defaulted function was defined as deleted.
5713
5714 /// Declare the implicit default constructor for the given class.
5715 ///
5716 /// \param ClassDecl The class declaration into which the implicit
5717 /// default constructor will be added.
5718 ///
5719 /// \returns The implicitly-declared default constructor.
5722
5723 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5724 /// defining this constructor as the default constructor.
5727
5728 /// Declare the implicit destructor for the given class.
5729 ///
5730 /// \param ClassDecl The class declaration into which the implicit
5731 /// destructor will be added.
5732 ///
5733 /// \returns The implicitly-declared destructor.
5735
5736 /// DefineImplicitDestructor - Checks for feasibility of
5737 /// defining this destructor as the default destructor.
5738 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5740
5741 /// Build an exception spec for destructors that don't have one.
5742 ///
5743 /// C++11 says that user-defined destructors with no exception spec get one
5744 /// that looks as if the destructor was implicitly declared.
5746
5747 /// Define the specified inheriting constructor.
5750
5751 /// Declare the implicit copy constructor for the given class.
5752 ///
5753 /// \param ClassDecl The class declaration into which the implicit
5754 /// copy constructor will be added.
5755 ///
5756 /// \returns The implicitly-declared copy constructor.
5758
5759 /// DefineImplicitCopyConstructor - Checks for feasibility of
5760 /// defining this constructor as the copy constructor.
5761 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5763
5764 /// Declare the implicit move constructor for the given class.
5765 ///
5766 /// \param ClassDecl The Class declaration into which the implicit
5767 /// move constructor will be added.
5768 ///
5769 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5770 /// declared.
5772
5773 /// DefineImplicitMoveConstructor - Checks for feasibility of
5774 /// defining this constructor as the move constructor.
5775 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5777
5778 /// Declare the implicit copy assignment operator for the given class.
5779 ///
5780 /// \param ClassDecl The class declaration into which the implicit
5781 /// copy assignment operator will be added.
5782 ///
5783 /// \returns The implicitly-declared copy assignment operator.
5785
5786 /// Defines an implicitly-declared copy assignment operator.
5787 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5788 CXXMethodDecl *MethodDecl);
5789
5790 /// Declare the implicit move assignment operator for the given class.
5791 ///
5792 /// \param ClassDecl The Class declaration into which the implicit
5793 /// move assignment operator will be added.
5794 ///
5795 /// \returns The implicitly-declared move assignment operator, or NULL if it
5796 /// wasn't declared.
5798
5799 /// Defines an implicitly-declared move assignment operator.
5800 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5801 CXXMethodDecl *MethodDecl);
5802
5803 /// Check a completed declaration of an implicit special member.
5805
5806 /// Determine whether the given function is an implicitly-deleted
5807 /// special member function.
5809
5810 /// Check whether 'this' shows up in the type of a static member
5811 /// function after the (naturally empty) cv-qualifier-seq would be.
5812 ///
5813 /// \returns true if an error occurred.
5815
5816 /// Whether this' shows up in the exception specification of a static
5817 /// member function.
5819
5820 /// Check whether 'this' shows up in the attributes of the given
5821 /// static member function.
5822 ///
5823 /// \returns true if an error occurred.
5825
5827 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5828
5830
5831 /// Given a constructor and the set of arguments provided for the
5832 /// constructor, convert the arguments and add any required default arguments
5833 /// to form a proper call to this constructor.
5834 ///
5835 /// \returns true if an error occurred, false otherwise.
5837 QualType DeclInitType, MultiExprArg ArgsPtr,
5838 SourceLocation Loc,
5839 SmallVectorImpl<Expr *> &ConvertedArgs,
5840 bool AllowExplicit = false,
5841 bool IsListInitialization = false);
5842
5843 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5844 /// initializer for the declaration 'Dcl'.
5845 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5846 /// static data member of class X, names should be looked up in the scope of
5847 /// class X.
5849
5850 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5851 /// initializer for the declaration 'Dcl'.
5852 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5853
5854 /// Define the "body" of the conversion from a lambda object to a
5855 /// function pointer.
5856 ///
5857 /// This routine doesn't actually define a sensible body; rather, it fills
5858 /// in the initialization expression needed to copy the lambda object into
5859 /// the block, and IR generation actually generates the real body of the
5860 /// block pointer conversion.
5861 void
5863 CXXConversionDecl *Conv);
5864
5865 /// Define the "body" of the conversion from a lambda object to a
5866 /// block pointer.
5867 ///
5868 /// This routine doesn't actually define a sensible body; rather, it fills
5869 /// in the initialization expression needed to copy the lambda object into
5870 /// the block, and IR generation actually generates the real body of the
5871 /// block pointer conversion.
5873 CXXConversionDecl *Conv);
5874
5875 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5876 /// linkage specification, including the language and (if present)
5877 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5878 /// language string literal. LBraceLoc, if valid, provides the location of
5879 /// the '{' brace. Otherwise, this linkage specification does not
5880 /// have any braces.
5882 Expr *LangStr, SourceLocation LBraceLoc);
5883
5884 /// ActOnFinishLinkageSpecification - Complete the definition of
5885 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5886 /// valid, it's the position of the closing '}' brace in a linkage
5887 /// specification that uses braces.
5889 SourceLocation RBraceLoc);
5890
5891 //===--------------------------------------------------------------------===//
5892 // C++ Classes
5893 //
5894
5895 /// Get the class that is directly named by the current context. This is the
5896 /// class for which an unqualified-id in this scope could name a constructor
5897 /// or destructor.
5898 ///
5899 /// If the scope specifier denotes a class, this will be that class.
5900 /// If the scope specifier is empty, this will be the class whose
5901 /// member-specification we are currently within. Otherwise, there
5902 /// is no such class.
5904
5905 /// isCurrentClassName - Determine whether the identifier II is the
5906 /// name of the class type currently being defined. In the case of
5907 /// nested classes, this will only return true if II is the name of
5908 /// the innermost class.
5909 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5910 const CXXScopeSpec *SS = nullptr);
5911
5912 /// Determine whether the identifier II is a typo for the name of
5913 /// the class type currently being defined. If so, update it to the identifier
5914 /// that should have been used.
5916
5917 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5919 SourceLocation ColonLoc,
5920 const ParsedAttributesView &Attrs);
5921
5922 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5923 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5924 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5925 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5926 /// present (but parsing it has been deferred).
5927 NamedDecl *
5929 MultiTemplateParamsArg TemplateParameterLists,
5930 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5931 InClassInitStyle InitStyle);
5932
5933 /// Enter a new C++ default initializer scope. After calling this, the
5934 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5935 /// parsing or instantiating the initializer failed.
5937
5938 /// This is invoked after parsing an in-class initializer for a
5939 /// non-static C++ class member, and after instantiating an in-class
5940 /// initializer in a class template. Such actions are deferred until the class
5941 /// is complete.
5943 SourceLocation EqualLoc,
5945
5946 /// Handle a C++ member initializer using parentheses syntax.
5948 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5949 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5950 const DeclSpec &DS, SourceLocation IdLoc,
5951 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5952 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5953
5954 /// Handle a C++ member initializer using braced-init-list syntax.
5955 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5956 CXXScopeSpec &SS,
5957 IdentifierInfo *MemberOrBase,
5958 ParsedType TemplateTypeTy,
5959 const DeclSpec &DS, SourceLocation IdLoc,
5960 Expr *InitList, SourceLocation EllipsisLoc);
5961
5962 /// Handle a C++ member initializer.
5963 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5964 CXXScopeSpec &SS,
5965 IdentifierInfo *MemberOrBase,
5966 ParsedType TemplateTypeTy,
5967 const DeclSpec &DS, SourceLocation IdLoc,
5968 Expr *Init, SourceLocation EllipsisLoc);
5969
5971 SourceLocation IdLoc);
5972
5974 TypeSourceInfo *BaseTInfo, Expr *Init,
5975 CXXRecordDecl *ClassDecl,
5976 SourceLocation EllipsisLoc);
5977
5979 CXXRecordDecl *ClassDecl);
5980
5983
5985 ArrayRef<CXXCtorInitializer *> Initializers = {});
5986
5987 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5988 /// mark all the non-trivial destructors of its members and bases as
5989 /// referenced.
5990 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
5991 CXXRecordDecl *Record);
5992
5993 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5994 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5995 /// class. In the Microsoft C++ ABI, this is done any time a class's
5996 /// destructor is referenced.
5998 SourceLocation Location, CXXRecordDecl *ClassDecl,
5999 llvm::SmallPtrSetImpl<const CXXRecordDecl *> *DirectVirtualBases =
6000 nullptr);
6001
6002 /// Do semantic checks to allow the complete destructor variant to be emitted
6003 /// when the destructor is defined in another translation unit. In the Itanium
6004 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
6005 /// can be emitted in separate TUs. To emit the complete variant, run a subset
6006 /// of the checks performed when emitting a regular destructor.
6007 void CheckCompleteDestructorVariant(SourceLocation CurrentLocation,
6008 CXXDestructorDecl *Dtor);
6009
6010 /// The list of classes whose vtables have been used within
6011 /// this translation unit, and the source locations at which the
6012 /// first use occurred.
6013 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
6014
6015 /// The list of vtables that are required but have not yet been
6016 /// materialized.
6018
6019 /// The set of classes whose vtables have been used within
6020 /// this translation unit, and a bit that will be true if the vtable is
6021 /// required to be emitted (otherwise, it should be emitted only if needed
6022 /// by code generation).
6023 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
6024
6025 /// Load any externally-stored vtable uses.
6027
6028 /// Note that the vtable for the given class was used at the
6029 /// given location.
6031 bool DefinitionRequired = false);
6032
6033 /// Mark the exception specifications of all virtual member functions
6034 /// in the given class as needed.
6036 const CXXRecordDecl *RD);
6037
6038 /// MarkVirtualMembersReferenced - Will mark all members of the given
6039 /// CXXRecordDecl referenced.
6041 bool ConstexprOnly = false);
6042
6043 /// Define all of the vtables that have been used in this
6044 /// translation unit and reference any virtual members used by those
6045 /// vtables.
6046 ///
6047 /// \returns true if any work was done, false otherwise.
6048 bool DefineUsedVTables();
6049
6050 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
6051 /// special functions, such as the default constructor, copy
6052 /// constructor, or destructor, to the given C++ class (C++
6053 /// [special]p1). This routine can only be executed just before the
6054 /// definition of the class is complete.
6056
6057 /// ActOnMemInitializers - Handle the member initializers for a constructor.
6058 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
6060 bool AnyErrors);
6061
6062 /// Check class-level dllimport/dllexport attribute. The caller must
6063 /// ensure that referenceDLLExportedClassMethods is called some point later
6064 /// when all outer classes of Class are complete.
6067
6069
6070 /// Perform propagation of DLL attributes from a derived class to a
6071 /// templated base class for MS compatibility.
6073 CXXRecordDecl *Class, Attr *ClassAttr,
6074 ClassTemplateSpecializationDecl *BaseTemplateSpec,
6075 SourceLocation BaseLoc);
6076
6077 /// Perform semantic checks on a class definition that has been
6078 /// completing, introducing implicitly-declared members, checking for
6079 /// abstract types, etc.
6080 ///
6081 /// \param S The scope in which the class was parsed. Null if we didn't just
6082 /// parse a class definition.
6083 /// \param Record The completed class.
6085
6086 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
6087 /// conditions that are needed for the attribute to have an effect.
6089
6090 /// Check that VTable Pointer authentication is only being set on the first
6091 /// first instantiation of the vtable
6093
6095 Decl *TagDecl, SourceLocation LBrac,
6096 SourceLocation RBrac,
6097 const ParsedAttributesView &AttrList);
6098
6099 /// Perform any semantic analysis which needs to be delayed until all
6100 /// pending class member declarations have been parsed.
6103
6104 /// This is used to implement the constant expression evaluation part of the
6105 /// attribute enable_if extension. There is nothing in standard C++ which
6106 /// would require reentering parameters.
6109 llvm::function_ref<Scope *()> EnterScope);
6111
6112 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
6113 /// parsing a top-level (non-nested) C++ class, and we are now
6114 /// parsing those parts of the given Method declaration that could
6115 /// not be parsed earlier (C++ [class.mem]p2), such as default
6116 /// arguments. This action should enter the scope of the given
6117 /// Method declaration as if we had just parsed the qualified method
6118 /// name. However, it should not bring the parameters into scope;
6119 /// that will be performed by ActOnDelayedCXXMethodParameter.
6121 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
6123
6124 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
6125 /// processing the delayed method declaration for Method. The method
6126 /// declaration is now considered finished. There may be a separate
6127 /// ActOnStartOfFunctionDef action later (not necessarily
6128 /// immediately!) for this method, if it was also defined inside the
6129 /// class body.
6132
6134
6135 bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx,
6136 StringEvaluationContext EvalContext,
6137 bool ErrorOnInvalidMessage);
6138 bool EvaluateAsString(Expr *Message, std::string &Result, ASTContext &Ctx,
6139 StringEvaluationContext EvalContext,
6140 bool ErrorOnInvalidMessage);
6141
6143 Expr *AssertExpr, Expr *AssertMessageExpr,
6144 SourceLocation RParenLoc);
6146 Expr *AssertExpr, Expr *AssertMessageExpr,
6147 SourceLocation RParenLoc, bool Failed);
6148
6149 /// Try to print more useful information about a failed static_assert
6150 /// with expression \E
6151 void DiagnoseStaticAssertDetails(const Expr *E);
6152
6153 /// If E represents a built-in type trait, or a known standard type trait,
6154 /// try to print more information about why the type type-trait failed.
6155 /// This assumes we already evaluated the expression to a false boolean value.
6156 void DiagnoseTypeTraitDetails(const Expr *E);
6157
6158 /// Handle a friend type declaration. This works in tandem with
6159 /// ActOnTag.
6160 ///
6161 /// Notes on friend class templates:
6162 ///
6163 /// We generally treat friend class declarations as if they were
6164 /// declaring a class. So, for example, the elaborated type specifier
6165 /// in a friend declaration is required to obey the restrictions of a
6166 /// class-head (i.e. no typedefs in the scope chain), template
6167 /// parameters are required to match up with simple template-ids, &c.
6168 /// However, unlike when declaring a template specialization, it's
6169 /// okay to refer to a template specialization without an empty
6170 /// template parameter declaration, e.g.
6171 /// friend class A<T>::B<unsigned>;
6172 /// We permit this as a special case; if there are any template
6173 /// parameters present at all, require proper matching, i.e.
6174 /// template <> template <class T> friend class A<int>::B;
6175 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
6176 MultiTemplateParamsArg TemplateParams,
6177 SourceLocation EllipsisLoc);
6179 MultiTemplateParamsArg TemplateParams);
6180
6181 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
6182 /// the well-formedness of the constructor declarator @p D with type @p
6183 /// R. If there are any errors in the declarator, this routine will
6184 /// emit diagnostics and set the invalid bit to true. In any case, the type
6185 /// will be updated to reflect a well-formed type for the constructor and
6186 /// returned.
6188 StorageClass &SC);
6189
6190 /// CheckConstructor - Checks a fully-formed constructor for
6191 /// well-formedness, issuing any diagnostics required. Returns true if
6192 /// the constructor declarator is invalid.
6194
6195 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
6196 /// the well-formednes of the destructor declarator @p D with type @p
6197 /// R. If there are any errors in the declarator, this routine will
6198 /// emit diagnostics and set the declarator to invalid. Even if this happens,
6199 /// will be updated to reflect a well-formed type for the destructor and
6200 /// returned.
6202 StorageClass &SC);
6203
6204 /// CheckDestructor - Checks a fully-formed destructor definition for
6205 /// well-formedness, issuing any diagnostics required. Returns true
6206 /// on error.
6208
6209 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
6210 /// well-formednes of the conversion function declarator @p D with
6211 /// type @p R. If there are any errors in the declarator, this routine
6212 /// will emit diagnostics and return true. Otherwise, it will return
6213 /// false. Either way, the type @p R will be updated to reflect a
6214 /// well-formed type for the conversion operator.
6216
6217 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
6218 /// the declaration of the given C++ conversion function. This routine
6219 /// is responsible for recording the conversion function in the C++
6220 /// class, if possible.
6222
6223 /// Check the validity of a declarator that we parsed for a deduction-guide.
6224 /// These aren't actually declarators in the grammar, so we need to check that
6225 /// the user didn't specify any pieces that are not part of the
6226 /// deduction-guide grammar. Return true on invalid deduction-guide.
6228 StorageClass &SC);
6229
6231
6234 SourceLocation DefaultLoc);
6236
6240 FunctionDecl *Spaceship);
6243
6245 QualType R, bool IsLambda,
6246 DeclContext *DC = nullptr);
6248 DeclarationName Name, QualType R);
6250
6251 //===--------------------------------------------------------------------===//
6252 // C++ Derived Classes
6253 //
6254
6255 /// Check the validity of a C++ base class specifier.
6256 ///
6257 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
6258 /// and returns NULL otherwise.
6260 SourceRange SpecifierRange, bool Virtual,
6261 AccessSpecifier Access,
6262 TypeSourceInfo *TInfo,
6263 SourceLocation EllipsisLoc);
6264
6265 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
6266 /// one entry in the base class list of a class specifier, for
6267 /// example:
6268 /// class foo : public bar, virtual private baz {
6269 /// 'public bar' and 'virtual private baz' are each base-specifiers.
6270 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
6271 const ParsedAttributesView &Attrs, bool Virtual,
6272 AccessSpecifier Access, ParsedType basetype,
6273 SourceLocation BaseLoc,
6274 SourceLocation EllipsisLoc);
6275
6276 /// Performs the actual work of attaching the given base class
6277 /// specifiers to a C++ class.
6280
6281 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
6282 /// class, after checking whether there are any duplicate base
6283 /// classes.
6284 void ActOnBaseSpecifiers(Decl *ClassDecl,
6286
6287 /// Determine whether the type \p Derived is a C++ class that is
6288 /// derived from the type \p Base.
6289 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6291 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6295 CXXBasePaths &Paths);
6296
6297 // FIXME: I don't like this name.
6298 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
6299
6301 SourceLocation Loc, SourceRange Range,
6302 CXXCastPath *BasePath = nullptr,
6303 bool IgnoreAccess = false);
6304
6305 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
6306 /// conversion (where Derived and Base are class types) is
6307 /// well-formed, meaning that the conversion is unambiguous (and
6308 /// that all of the base classes are accessible). Returns true
6309 /// and emits a diagnostic if the code is ill-formed, returns false
6310 /// otherwise. Loc is the location where this routine should point to
6311 /// if there is an error, and Range is the source range to highlight
6312 /// if there is an error.
6313 ///
6314 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
6315 /// diagnostic for the respective type of error will be suppressed, but the
6316 /// check for ill-formed code will still be performed.
6318 unsigned InaccessibleBaseID,
6319 unsigned AmbiguousBaseConvID,
6320 SourceLocation Loc, SourceRange Range,
6321 DeclarationName Name, CXXCastPath *BasePath,
6322 bool IgnoreAccess = false);
6323
6324 /// Builds a string representing ambiguous paths from a
6325 /// specific derived class to different subobjects of the same base
6326 /// class.
6327 ///
6328 /// This function builds a string that can be used in error messages
6329 /// to show the different paths that one can take through the
6330 /// inheritance hierarchy to go from the derived class to different
6331 /// subobjects of a base class. The result looks something like this:
6332 /// @code
6333 /// struct D -> struct B -> struct A
6334 /// struct D -> struct C -> struct A
6335 /// @endcode
6336 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
6337
6339 const CXXMethodDecl *Old);
6340
6341 /// CheckOverridingFunctionReturnType - Checks whether the return types are
6342 /// covariant, according to C++ [class.virtual]p5.
6344 const CXXMethodDecl *Old);
6345
6346 // Check that the overriding method has no explicit object parameter.
6348 const CXXMethodDecl *Old);
6349
6350 /// Mark the given method pure.
6351 ///
6352 /// \param Method the method to be marked pure.
6353 ///
6354 /// \param InitRange the source range that covers the "0" initializer.
6356
6357 /// CheckOverrideControl - Check C++11 override control semantics.
6359
6360 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
6361 /// not used in the declaration of an overriding method.
6363
6364 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
6365 /// function overrides a virtual member function marked 'final', according to
6366 /// C++11 [class.virtual]p4.
6368 const CXXMethodDecl *Old);
6369
6380
6381 struct TypeDiagnoser;
6382
6385 TypeDiagnoser &Diagnoser);
6386 template <typename... Ts>
6388 const Ts &...Args) {
6389 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6390 return RequireNonAbstractType(Loc, T, Diagnoser);
6391 }
6392
6393 void DiagnoseAbstractType(const CXXRecordDecl *RD);
6394
6395 //===--------------------------------------------------------------------===//
6396 // C++ Overloaded Operators [C++ 13.5]
6397 //
6398
6399 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
6400 /// of this overloaded operator is well-formed. If so, returns false;
6401 /// otherwise, emits appropriate diagnostics and returns true.
6403
6404 /// CheckLiteralOperatorDeclaration - Check whether the declaration
6405 /// of this literal operator function is well-formed. If so, returns
6406 /// false; otherwise, emits appropriate diagnostics and returns true.
6408
6409 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
6410 /// found in an explicit(bool) specifier.
6412
6413 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
6414 /// Returns true if the explicit specifier is now resolved.
6416
6417 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
6418 /// C++ if/switch/while/for statement.
6419 /// e.g: "if (int x = f()) {...}"
6421
6422 // Emitting members of dllexported classes is delayed until the class
6423 // (including field initializers) is fully parsed.
6426
6427 /// Merge the exception specifications of two variable declarations.
6428 ///
6429 /// This is called when there's a redeclaration of a VarDecl. The function
6430 /// checks if the redeclaration might have an exception specification and
6431 /// validates compatibility and merges the specs if necessary.
6433
6434 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
6435 /// function, once we already know that they have the same
6436 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
6437 /// error, false otherwise.
6439
6440 /// Helpers for dealing with blocks and functions.
6442
6443 /// CheckExtraCXXDefaultArguments - Check for any extra default
6444 /// arguments in the declarator, which is not a function declaration
6445 /// or definition and therefore is not permitted to have default
6446 /// arguments. This routine should be invoked for every declarator
6447 /// that is not a function declaration or definition.
6449
6450 /// Perform semantic analysis for the variable declaration that
6451 /// occurs within a C++ catch clause, returning the newly-created
6452 /// variable.
6454 SourceLocation StartLoc,
6455 SourceLocation IdLoc,
6456 const IdentifierInfo *Id);
6457
6458 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
6459 /// handler.
6461
6463
6464 /// Handle a friend tag declaration where the scope specifier was
6465 /// templated.
6467 unsigned TagSpec, SourceLocation TagLoc,
6468 CXXScopeSpec &SS, IdentifierInfo *Name,
6469 SourceLocation NameLoc,
6470 SourceLocation EllipsisLoc,
6472 MultiTemplateParamsArg TempParamLists,
6473 TemplateIdAnnotation *TemplateId);
6474
6477 bool IsInstantiation);
6478
6480 NestedNameSpecifierLoc NNSLoc);
6481
6483 SourceLocation DeclStart, Declarator &D,
6484 Expr *BitfieldWidth,
6485 InClassInitStyle InitStyle,
6486 AccessSpecifier AS,
6487 const ParsedAttr &MSPropertyAttr);
6488
6489 /// Diagnose why the specified class does not have a trivial special member of
6490 /// the given kind.
6493
6494 /// Determine whether a defaulted or deleted special member function is
6495 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
6496 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
6500 bool Diagnose = false);
6501
6502 /// Handle a C++11 empty-declaration and attribute-declaration.
6504 SourceLocation SemiLoc);
6505
6507 /// Diagnose issues that are non-constant or that are extensions.
6509 /// Identify whether this function satisfies the formal rules for constexpr
6510 /// functions in the current lanugage mode (with no extensions).
6512 };
6513
6514 // Check whether a function declaration satisfies the requirements of a
6515 // constexpr function definition or a constexpr constructor definition. If so,
6516 // return true. If not, produce appropriate diagnostics (unless asked not to
6517 // by Kind) and return false.
6518 //
6519 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
6521 CheckConstexprKind Kind);
6522
6523 /// Diagnose methods which overload virtual methods in a base class
6524 /// without overriding any.
6526
6527 /// Check if a method overloads virtual methods in a base class without
6528 /// overriding any.
6529 void
6531 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6532 void
6534 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6535
6536 /// ActOnParamDefaultArgument - Check whether the default argument
6537 /// provided for a function parameter is well-formed. If so, attach it
6538 /// to the parameter declaration.
6539 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
6540 Expr *defarg);
6541
6542 /// ActOnParamUnparsedDefaultArgument - We've seen a default
6543 /// argument for a function parameter, but we can't parse it yet
6544 /// because we're inside a class definition. Note that this default
6545 /// argument will be parsed later.
6547 SourceLocation ArgLoc);
6548
6549 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
6550 /// the default argument for the parameter param failed.
6552 Expr *DefaultArg);
6554 SourceLocation EqualLoc);
6555 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
6556 SourceLocation EqualLoc);
6557
6558 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
6559 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
6560 StringLiteral *Message = nullptr);
6561 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6562
6563 void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
6564 StringLiteral *DeletedMessage = nullptr);
6568
6569 NamedDecl *
6571 MultiTemplateParamsArg TemplateParamLists);
6574 RecordDecl *ClassDecl,
6575 const IdentifierInfo *Name);
6576
6578 SourceLocation Loc);
6580
6581 /// Stack containing information needed when in C++2a an 'auto' is encountered
6582 /// in a function declaration parameter type specifier in order to invent a
6583 /// corresponding template parameter in the enclosing abbreviated function
6584 /// template. This information is also present in LambdaScopeInfo, stored in
6585 /// the FunctionScopes stack.
6587
6588 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6589 std::unique_ptr<CXXFieldCollector> FieldCollector;
6590
6592 /// Set containing all declared private fields that are not used.
6594
6596
6597 /// PureVirtualClassDiagSet - a set of class declarations which we have
6598 /// emitted a list of pure virtual functions. Used to prevent emitting the
6599 /// same list more than once.
6600 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6601
6605
6606 /// All the delegating constructors seen so far in the file, used for
6607 /// cycle detection at the end of the TU.
6609
6610 /// The C++ "std" namespace, where the standard library resides.
6612
6613 /// The C++ "std::initializer_list" template, which is defined in
6614 /// <initializer_list>.
6616
6617 /// The C++ "std::type_identity" template, which is defined in
6618 /// <type_traits>.
6620
6621 // Contains the locations of the beginning of unparsed default
6622 // argument locations.
6623 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6624
6625 /// UndefinedInternals - all the used, undefined objects which require a
6626 /// definition in this translation unit.
6627 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6628
6629 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6631
6632 /// The C++ special members which we are currently in the process of
6633 /// declaring. If this process recursively triggers the declaration of the
6634 /// same special member, we should act as if it is not yet declared.
6636
6638
6639 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6640
6643 ParsingClassDepth++;
6645 }
6647 ParsingClassDepth--;
6649 }
6650
6652 CXXScopeSpec &SS,
6653 ParsedType TemplateTypeTy,
6654 IdentifierInfo *MemberOrBase);
6655
6656private:
6657 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6658 QualType ResultTy,
6659 ArrayRef<QualType> Args);
6660 // Helper for ActOnFields to check for all function pointer members.
6661 bool EntirelyFunctionPointers(const RecordDecl *Record);
6662
6663 // A cache representing if we've fully checked the various comparison category
6664 // types stored in ASTContext. The bit-index corresponds to the integer value
6665 // of a ComparisonCategoryType enumerator.
6666 llvm::SmallBitVector FullyCheckedComparisonCategories;
6667
6668 /// Check if there is a field shadowing.
6669 void CheckShadowInheritedFields(const SourceLocation &Loc,
6670 DeclarationName FieldName,
6671 const CXXRecordDecl *RD,
6672 bool DeclIsField = true);
6673
6674 ///@}
6675
6676 //
6677 //
6678 // -------------------------------------------------------------------------
6679 //
6680 //
6681
6682 /// \name C++ Exception Specifications
6683 /// Implementations are in SemaExceptionSpec.cpp
6684 ///@{
6685
6686public:
6687 /// All the overriding functions seen during a class definition
6688 /// that had their exception spec checks delayed, plus the overridden
6689 /// function.
6692
6693 /// All the function redeclarations seen during a class definition that had
6694 /// their exception spec checks delayed, plus the prior declaration they
6695 /// should be checked against. Except during error recovery, the new decl
6696 /// should always be a friend declaration, as that's the only valid way to
6697 /// redeclare a special member before its class is complete.
6700
6701 /// Determine if we're in a case where we need to (incorrectly) eagerly
6702 /// parse an exception specification to work around a libstdc++ bug.
6704
6705 /// Check the given noexcept-specifier, convert its expression, and compute
6706 /// the appropriate ExceptionSpecificationType.
6707 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6709
6710 CanThrowResult canThrow(const Stmt *E);
6711 /// Determine whether the callee of a particular function call can throw.
6712 /// E, D and Loc are all optional.
6713 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6716 const FunctionProtoType *FPT);
6719
6720 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6721 /// exception specification. Incomplete types, or pointers to incomplete types
6722 /// other than void are not allowed.
6723 ///
6724 /// \param[in,out] T The exception type. This will be decayed to a pointer
6725 /// type
6726 /// when the input is an array or a function type.
6728
6729 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6730 /// pointer to member to a function with an exception specification. This
6731 /// means that it is invalid to add another level of indirection.
6734
6735 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6736 /// exception specifications. Exception specifications are equivalent if
6737 /// they allow exactly the same set of exception types. It does not matter how
6738 /// that is achieved. See C++ [except.spec]p2.
6740 SourceLocation OldLoc,
6741 const FunctionProtoType *New,
6742 SourceLocation NewLoc);
6744 const PartialDiagnostic &NoteID,
6745 const FunctionProtoType *Old,
6746 SourceLocation OldLoc,
6747 const FunctionProtoType *New,
6748 SourceLocation NewLoc);
6749 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6750
6751 /// CheckExceptionSpecSubset - Check whether the second function type's
6752 /// exception specification is a subset (or equivalent) of the first function
6753 /// type. This is used by override and pointer assignment checks.
6755 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6756 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6757 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6758 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6759 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6760
6761 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6762 /// two functions have equivalent exception specs. This is part of the
6763 /// assignment and override compatibility check. We do not check the
6764 /// parameters of parameter function pointers recursively, as no sane
6765 /// programmer would even be able to write such a function type.
6767 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6768 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6769 SourceLocation TargetLoc, const FunctionProtoType *Source,
6770 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6771
6772 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6773
6774 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6775 /// spec is a subset of base spec.
6777 const CXXMethodDecl *Old);
6778
6779 ///@}
6780
6781 //
6782 //
6783 // -------------------------------------------------------------------------
6784 //
6785 //
6786
6787 /// \name Expressions
6788 /// Implementations are in SemaExpr.cpp
6789 ///@{
6790
6791public:
6792 /// Describes how the expressions currently being parsed are
6793 /// evaluated at run-time, if at all.
6795 /// The current expression and its subexpressions occur within an
6796 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6797 /// \c sizeof, where the type of the expression may be significant but
6798 /// no code will be generated to evaluate the value of the expression at
6799 /// run time.
6801
6802 /// The current expression occurs within a braced-init-list within
6803 /// an unevaluated operand. This is mostly like a regular unevaluated
6804 /// context, except that we still instantiate constexpr functions that are
6805 /// referenced here so that we can perform narrowing checks correctly.
6807
6808 /// The current expression occurs within a discarded statement.
6809 /// This behaves largely similarly to an unevaluated operand in preventing
6810 /// definitions from being required, but not in other ways.
6812
6813 /// The current expression occurs within an unevaluated
6814 /// operand that unconditionally permits abstract references to
6815 /// fields, such as a SIZE operator in MS-style inline assembly.
6817
6818 /// The current context is "potentially evaluated" in C++11 terms,
6819 /// but the expression is evaluated at compile-time (like the values of
6820 /// cases in a switch statement).
6822
6823 /// In addition of being constant evaluated, the current expression
6824 /// occurs in an immediate function context - either a consteval function
6825 /// or a consteval if statement.
6827
6828 /// The current expression is potentially evaluated at run time,
6829 /// which means that code may be generated to evaluate the value of the
6830 /// expression at run time.
6832
6833 /// The current expression is potentially evaluated, but any
6834 /// declarations referenced inside that expression are only used if
6835 /// in fact the current expression is used.
6836 ///
6837 /// This value is used when parsing default function arguments, for which
6838 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6839 /// through varargs) but do not want to mark declarations as "referenced"
6840 /// until the default argument is used.
6842 };
6843
6844 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6845 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6846 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6847 /// have been applied to all subexpressions of the enclosing full expression.
6848 /// This is cleared at the end of each full expression.
6851
6852 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6853
6854 /// Data structure used to record current or nested
6855 /// expression evaluation contexts.
6857 /// The expression evaluation context.
6859
6860 /// Whether the enclosing context needed a cleanup.
6862
6863 /// The number of active cleanup objects when we entered
6864 /// this expression evaluation context.
6866
6868
6869 /// The lambdas that are present within this context, if it
6870 /// is indeed an unevaluated context.
6872
6873 /// The declaration that provides context for lambda expressions
6874 /// and block literals if the normal declaration context does not
6875 /// suffice, e.g., in a default function argument.
6877
6878 /// Declaration for initializer if one is currently being
6879 /// parsed. Used when an expression has a possibly unreachable
6880 /// diagnostic to reference the declaration as a whole.
6882
6883 /// If we are processing a decltype type, a set of call expressions
6884 /// for which we have deferred checking the completeness of the return type.
6886
6887 /// If we are processing a decltype type, a set of temporary binding
6888 /// expressions for which we have deferred checking the destructor.
6890
6892
6893 /// Expressions appearing as the LHS of a volatile assignment in this
6894 /// context. We produce a warning for these when popping the context if
6895 /// they are not discarded-value expressions nor unevaluated operands.
6897
6898 /// Set of candidates for starting an immediate invocation.
6901
6902 /// Set of DeclRefExprs referencing a consteval function when used in a
6903 /// context not already known to be immediately invoked.
6905
6906 /// P2718R0 - Lifetime extension in range-based for loops.
6907 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6908 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6909 /// InLifetimeExtendingContext is true.
6911
6912 /// Small set of gathered accesses to potentially misaligned members
6913 /// due to the packed attribute.
6915
6916 /// \brief Describes whether we are in an expression constext which we have
6917 /// to handle differently.
6925
6926 // A context can be nested in both a discarded statement context and
6927 // an immediate function context, so they need to be tracked independently.
6931
6933
6934 // We are in a constant context, but we also allow
6935 // non constant expressions, for example for array bounds (which may be
6936 // VLAs).
6938
6939 /// Whether we are currently in a context in which all temporaries must be
6940 /// lifetime-extended, even if they're not bound to a reference (for
6941 /// example, in a for-range initializer).
6943
6944 /// Whether evaluating an expression for a switch case label.
6945 bool IsCaseExpr = false;
6946
6947 /// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
6949
6950 // When evaluating immediate functions in the initializer of a default
6951 // argument or default member initializer, this is the declaration whose
6952 // default initializer is being evaluated and the location of the call
6953 // or constructor definition.
6957 : Loc(Loc), Decl(Decl), Context(Context) {
6958 assert(Decl && Context && "invalid initialization context");
6959 }
6960
6962 ValueDecl *Decl = nullptr;
6964 };
6965 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6966
6977
6983
6990
6995
7000 // C++23 [expr.const]p14:
7001 // An expression or conversion is in an immediate function
7002 // context if it is potentially evaluated and either:
7003 // * its innermost enclosing non-block scope is a function
7004 // parameter scope of an immediate function, or
7005 // * its enclosing statement is enclosed by the compound-
7006 // statement of a consteval if statement.
7009 }
7010
7018 };
7019
7021 assert(!ExprEvalContexts.empty() &&
7022 "Must be in an expression evaluation context");
7023 return ExprEvalContexts.back();
7024 }
7025
7027 assert(!ExprEvalContexts.empty() &&
7028 "Must be in an expression evaluation context");
7029 return ExprEvalContexts.back();
7030 }
7031
7033 assert(ExprEvalContexts.size() >= 2 &&
7034 "Must be in an expression evaluation context");
7035 return ExprEvalContexts[ExprEvalContexts.size() - 2];
7036 }
7037
7039 return const_cast<Sema *>(this)->parentEvaluationContext();
7040 }
7041
7046
7047 /// Increment when we find a reference; decrement when we find an ignored
7048 /// assignment. Ultimately the value is 0 if every reference is an ignored
7049 /// assignment.
7050 ///
7051 /// Uses canonical VarDecl as key so in-class decls and out-of-class defs of
7052 /// static data members get tracked as a single entry.
7053 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
7054
7055 /// Used to control the generation of ExprWithCleanups.
7057
7058 /// ExprCleanupObjects - This is the stack of objects requiring
7059 /// cleanup that are created by the current full expression.
7061
7062 /// Determine whether the use of this declaration is valid, without
7063 /// emitting diagnostics.
7064 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
7065 // A version of DiagnoseUseOfDecl that should be used if overload resolution
7066 // has been used to find this declaration, which means we don't have to bother
7067 // checking the trailing requires clause.
7069 return DiagnoseUseOfDecl(
7070 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
7071 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
7072 /*SkipTrailingRequiresClause=*/true);
7073 }
7074
7075 /// Determine whether the use of this declaration is valid, and
7076 /// emit any corresponding diagnostics.
7077 ///
7078 /// This routine diagnoses various problems with referencing
7079 /// declarations that can occur when using a declaration. For example,
7080 /// it might warn if a deprecated or unavailable declaration is being
7081 /// used, or produce an error (and return true) if a C++0x deleted
7082 /// function is being used.
7083 ///
7084 /// \returns true if there was an error (this declaration cannot be
7085 /// referenced), false otherwise.
7087 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
7088 bool ObjCPropertyAccess = false,
7089 bool AvoidPartialAvailabilityChecks = false,
7090 ObjCInterfaceDecl *ClassReceiver = nullptr,
7091 bool SkipTrailingRequiresClause = false);
7092
7093 /// Emit a note explaining that this function is deleted.
7095
7096 /// DiagnoseSentinelCalls - This routine checks whether a call or
7097 /// message-send is to a declaration with the sentinel attribute, and
7098 /// if so, it checks that the requirements of the sentinel are
7099 /// satisfied.
7101 ArrayRef<Expr *> Args);
7102
7104 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
7107
7109 ExpressionEvaluationContext NewContext, FunctionDecl *FD);
7110
7113 ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
7117
7119
7123
7124 /// Check whether E, which is either a discarded-value expression or an
7125 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
7126 /// lvalue, and if so, remove it from the list of volatile-qualified
7127 /// assignments that we are going to warn are deprecated.
7129
7131
7132 // Functions for marking a declaration referenced. These functions also
7133 // contain the relevant logic for marking if a reference to a function or
7134 // variable is an odr-use (in the C++11 sense). There are separate variants
7135 // for expressions referring to a decl; these exist because odr-use marking
7136 // needs to be delayed for some constant variables when we build one of the
7137 // named expressions.
7138 //
7139 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
7140 // should usually be true. This only needs to be set to false if the lack of
7141 // odr-use cannot be determined from the current context (for instance,
7142 // because the name denotes a virtual function and was written without an
7143 // explicit nested-name-specifier).
7144 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
7145
7146 /// Mark a function referenced, and check whether it is odr-used
7147 /// (C++ [basic.def.odr]p2, C99 6.9p3)
7149 bool MightBeOdrUse = true);
7150
7151 /// Mark a variable referenced, and check whether it is odr-used
7152 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
7153 /// used directly for normal expressions referring to VarDecl.
7155
7156 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
7157 ///
7158 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
7159 /// be handled with care if the DeclRefExpr is not newly-created.
7160 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
7161
7162 /// Perform reference-marking and odr-use handling for a MemberExpr.
7164
7165 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
7168 unsigned CapturingScopeIndex);
7169
7171 void CleanupVarDeclMarking();
7172
7173 /// Try to capture the given variable.
7174 ///
7175 /// \param Var The variable to capture.
7176 ///
7177 /// \param Loc The location at which the capture occurs.
7178 ///
7179 /// \param Kind The kind of capture, which may be implicit (for either a
7180 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
7181 ///
7182 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
7183 /// an explicit lambda capture.
7184 ///
7185 /// \param BuildAndDiagnose Whether we are actually supposed to add the
7186 /// captures or diagnose errors. If false, this routine merely check whether
7187 /// the capture can occur without performing the capture itself or complaining
7188 /// if the variable cannot be captured.
7189 ///
7190 /// \param CaptureType Will be set to the type of the field used to capture
7191 /// this variable in the innermost block or lambda. Only valid when the
7192 /// variable can be captured.
7193 ///
7194 /// \param DeclRefType Will be set to the type of a reference to the capture
7195 /// from within the current scope. Only valid when the variable can be
7196 /// captured.
7197 ///
7198 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
7199 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
7200 /// This is useful when enclosing lambdas must speculatively capture
7201 /// variables that may or may not be used in certain specializations of
7202 /// a nested generic lambda.
7203 ///
7204 /// \returns true if an error occurred (i.e., the variable cannot be
7205 /// captured) and false if the capture succeeded.
7207 TryCaptureKind Kind, SourceLocation EllipsisLoc,
7208 bool BuildAndDiagnose, QualType &CaptureType,
7209 QualType &DeclRefType,
7210 const unsigned *const FunctionScopeIndexToStopAt);
7211
7212 /// Try to capture the given variable.
7215 SourceLocation EllipsisLoc = SourceLocation());
7216
7217 /// Checks if the variable must be captured.
7219
7220 /// Given a variable, determine the type that a reference to that
7221 /// variable will have in the given scope.
7223
7224 /// Mark all of the declarations referenced within a particular AST node as
7225 /// referenced. Used when template instantiation instantiates a non-dependent
7226 /// type -- entities referenced by the type are now referenced.
7228
7229 /// Mark any declarations that appear within this expression or any
7230 /// potentially-evaluated subexpressions as "referenced".
7231 ///
7232 /// \param SkipLocalVariables If true, don't mark local variables as
7233 /// 'referenced'.
7234 /// \param StopAt Subexpressions that we shouldn't recurse into.
7236 bool SkipLocalVariables = false,
7237 ArrayRef<const Expr *> StopAt = {});
7238
7239 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
7240 /// conversion.
7241 ExprResult tryConvertExprToType(Expr *E, QualType Ty);
7242
7243 /// Conditionally issue a diagnostic based on the statements's reachability
7244 /// analysis.
7245 ///
7246 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
7247 /// the function body is parsed, and then do a basic reachability analysis to
7248 /// determine if the statement is reachable. If it is unreachable, the
7249 /// diagnostic will not be emitted.
7250 bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7251 const PartialDiagnostic &PD);
7252
7253 /// Conditionally issue a diagnostic based on the current
7254 /// evaluation context.
7255 ///
7256 /// \param Statement If Statement is non-null, delay reporting the
7257 /// diagnostic until the function body is parsed, and then do a basic
7258 /// reachability analysis to determine if the statement is reachable.
7259 /// If it is unreachable, the diagnostic will not be emitted.
7260 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
7261 const PartialDiagnostic &PD);
7262 /// Similar, but diagnostic is only produced if all the specified statements
7263 /// are reachable.
7264 bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7265 const PartialDiagnostic &PD);
7266
7267 // Primary Expressions.
7268 SourceRange getExprRange(Expr *E) const;
7269
7270 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
7271 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
7272 bool HasTrailingLParen, bool IsAddressOfOperand,
7273 CorrectionCandidateCallback *CCC = nullptr,
7274 bool IsInlineAsmIdentifier = false);
7275
7276 /// Decomposes the given name into a DeclarationNameInfo, its location, and
7277 /// possibly a list of template arguments.
7278 ///
7279 /// If this produces template arguments, it is permitted to call
7280 /// DecomposeTemplateName.
7281 ///
7282 /// This actually loses a lot of source location information for
7283 /// non-standard name kinds; we should consider preserving that in
7284 /// some way.
7285 void DecomposeUnqualifiedId(const UnqualifiedId &Id,
7286 TemplateArgumentListInfo &Buffer,
7287 DeclarationNameInfo &NameInfo,
7288 const TemplateArgumentListInfo *&TemplateArgs);
7289
7290 /// Diagnose a lookup that found results in an enclosing class during error
7291 /// recovery. This usually indicates that the results were found in a
7292 /// dependent base class that could not be searched as part of a template
7293 /// definition. Always issues a diagnostic (though this may be only a warning
7294 /// in MS compatibility mode).
7295 ///
7296 /// Return \c true if the error is unrecoverable, or \c false if the caller
7297 /// should attempt to recover using these lookup results.
7298 bool DiagnoseDependentMemberLookup(const LookupResult &R);
7299
7300 /// Diagnose an empty lookup.
7301 ///
7302 /// \return false if new lookup candidates were found
7303 bool
7304 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
7305 CorrectionCandidateCallback &CCC,
7306 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
7307 ArrayRef<Expr *> Args = {},
7308 DeclContext *LookupCtx = nullptr);
7309
7310 /// If \p D cannot be odr-used in the current expression evaluation context,
7311 /// return a reason explaining why. Otherwise, return NOUR_None.
7313
7314 DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7315 SourceLocation Loc,
7316 const CXXScopeSpec *SS = nullptr);
7317 DeclRefExpr *
7318 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7319 const DeclarationNameInfo &NameInfo,
7320 const CXXScopeSpec *SS = nullptr,
7321 NamedDecl *FoundD = nullptr,
7322 SourceLocation TemplateKWLoc = SourceLocation(),
7323 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7324
7325 /// BuildDeclRefExpr - Build an expression that references a
7326 /// declaration that does not require a closure capture.
7327 DeclRefExpr *
7328 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7329 const DeclarationNameInfo &NameInfo,
7330 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
7331 SourceLocation TemplateKWLoc = SourceLocation(),
7332 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7333
7334 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
7335 bool HasTrailingLParen);
7336
7337 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
7338 /// declaration name, generally during template instantiation.
7339 /// There's a large number of things which don't need to be done along
7340 /// this path.
7342 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
7343 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
7344
7345 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
7346 bool NeedsADL,
7347 bool AcceptInvalidDecl = false);
7348
7349 /// Complete semantic analysis for a reference to the given declaration.
7351 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
7352 NamedDecl *FoundD = nullptr,
7353 const TemplateArgumentListInfo *TemplateArgs = nullptr,
7354 bool AcceptInvalidDecl = false);
7355
7356 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
7357 // where Tokens representing function local predefined macros (such as
7358 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
7359 std::vector<Token> ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks);
7360
7361 ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK);
7362 ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
7363 ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
7364
7365 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
7366
7367 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
7369 Scope *UDLScope = nullptr);
7370 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
7371 ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
7372 MultiExprArg Val);
7373 ExprResult ActOnCXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
7374 unsigned NumUserSpecifiedExprs,
7375 SourceLocation InitLoc,
7376 SourceLocation LParenLoc,
7377 SourceLocation RParenLoc);
7378
7379 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
7380 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
7381 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
7382 /// from multiple tokens. However, the common case is that StringToks points
7383 /// to one string.
7384 ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
7385 Scope *UDLScope = nullptr);
7386
7387 ExprResult ActOnUnevaluatedStringLiteral(ArrayRef<Token> StringToks);
7388
7389 /// ControllingExprOrType is either an opaque pointer coming out of a
7390 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
7391 /// into two so we don't take a void *, but that's awkward because one of
7392 /// the operands is either a ParsedType or an Expr *, which doesn't lend
7393 /// itself to generic code very well.
7394 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
7395 SourceLocation DefaultLoc,
7396 SourceLocation RParenLoc,
7397 bool PredicateIsExpr,
7398 void *ControllingExprOrType,
7399 ArrayRef<ParsedType> ArgTypes,
7400 ArrayRef<Expr *> ArgExprs);
7401 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
7402 /// it'd be better to split this interface into two so we don't take a
7403 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
7404 /// isn't a trivial change.
7405 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
7406 SourceLocation DefaultLoc,
7407 SourceLocation RParenLoc,
7408 bool PredicateIsExpr,
7409 void *ControllingExprOrType,
7410 ArrayRef<TypeSourceInfo *> Types,
7411 ArrayRef<Expr *> Exprs);
7412
7413 // Binary/Unary Operators. 'Tok' is the token for the operator.
7414 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
7415 Expr *InputExpr, bool IsAfterAmp = false);
7416 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc,
7417 Expr *Input, bool IsAfterAmp = false);
7418
7419 /// Unary Operators. 'Tok' is the token for the operator.
7420 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op,
7421 Expr *Input, bool IsAfterAmp = false);
7422
7423 /// Determine whether the given expression is a qualified member
7424 /// access expression, of a form that could be turned into a pointer to member
7425 /// with the address-of operator.
7426 bool isQualifiedMemberAccess(Expr *E);
7427 bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
7428 const Expr *Op,
7429 const CXXMethodDecl *MD);
7430
7431 /// CheckAddressOfOperand - The operand of & must be either a function
7432 /// designator or an lvalue designating an object. If it is an lvalue, the
7433 /// object cannot be declared with storage class register or be a bit field.
7434 /// Note: The usual conversions are *not* applied to the operand of the &
7435 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
7436 /// In C++, the operand might be an overloaded function name, in which case
7437 /// we allow the '&' but retain the overloaded-function type.
7438 QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
7439
7440 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
7441 /// _Alignas(type-name) .
7442 /// [dcl.align] An alignment-specifier of the form
7443 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
7444 ///
7445 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
7446 /// _Alignas(_Alignof(type-name)).
7447 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
7448 SourceLocation OpLoc, SourceRange R);
7449 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
7450 SourceLocation OpLoc, SourceRange R);
7451
7452 /// Build a sizeof or alignof expression given a type operand.
7453 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
7454 SourceLocation OpLoc,
7455 UnaryExprOrTypeTrait ExprKind,
7456 SourceRange R);
7457
7458 /// Build a sizeof or alignof expression given an expression
7459 /// operand.
7460 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
7461 UnaryExprOrTypeTrait ExprKind);
7462
7463 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
7464 /// expr and the same for @c alignof and @c __alignof
7465 /// Note that the ArgRange is invalid if isType is false.
7466 ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
7467 UnaryExprOrTypeTrait ExprKind,
7468 bool IsType, void *TyOrEx,
7469 SourceRange ArgRange);
7470
7471 /// Check for operands with placeholder types and complain if found.
7472 /// Returns ExprError() if there was an error and no recovery was possible.
7474 bool CheckVecStepExpr(Expr *E);
7475
7476 /// Check the constraints on expression operands to unary type expression
7477 /// and type traits.
7478 ///
7479 /// Completes any types necessary and validates the constraints on the operand
7480 /// expression. The logic mostly mirrors the type-based overload, but may
7481 /// modify the expression as it completes the type for that expression through
7482 /// template instantiation, etc.
7483 bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind);
7484
7485 /// Check the constraints on operands to unary expression and type
7486 /// traits.
7487 ///
7488 /// This will complete any types necessary, and validate the various
7489 /// constraints on those operands.
7490 ///
7491 /// The UsualUnaryConversions() function is *not* called by this routine.
7492 /// C99 6.3.2.1p[2-4] all state:
7493 /// Except when it is the operand of the sizeof operator ...
7494 ///
7495 /// C++ [expr.sizeof]p4
7496 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
7497 /// standard conversions are not applied to the operand of sizeof.
7498 ///
7499 /// This policy is followed for all of the unary trait expressions.
7500 bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
7501 SourceRange ExprRange,
7502 UnaryExprOrTypeTrait ExprKind,
7503 StringRef KWName);
7504
7505 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
7506 tok::TokenKind Kind, Expr *Input);
7507
7508 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
7509 MultiExprArg ArgExprs,
7510 SourceLocation RLoc);
7511 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
7512 Expr *Idx, SourceLocation RLoc);
7513
7514 ExprResult CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx,
7515 SourceLocation RBLoc);
7516
7517 ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx,
7518 Expr *ColumnIdx,
7519 SourceLocation RBLoc);
7520
7521 /// ConvertArgumentsForCall - Converts the arguments specified in
7522 /// Args/NumArgs to the parameter types of the function FDecl with
7523 /// function prototype Proto. Call is the call expression itself, and
7524 /// Fn is the function expression. For a C++ member function, this
7525 /// routine does not attempt to convert the object argument. Returns
7526 /// true if the call is ill-formed.
7527 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl,
7528 const FunctionProtoType *Proto,
7529 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
7530 bool ExecConfig = false);
7531
7532 /// CheckStaticArrayArgument - If the given argument corresponds to a static
7533 /// array parameter, check that it is non-null, and that if it is formed by
7534 /// array-to-pointer decay, the underlying array is sufficiently large.
7535 ///
7536 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
7537 /// the array type derivation, then for each call to the function, the value
7538 /// of the corresponding actual argument shall provide access to the first
7539 /// element of an array with at least as many elements as specified by the
7540 /// size expression.
7541 void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
7542 const Expr *ArgExpr);
7543
7544 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
7545 /// This provides the location of the left/right parens and a list of comma
7546 /// locations.
7547 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7548 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7549 Expr *ExecConfig = nullptr);
7550
7551 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
7552 /// This provides the location of the left/right parens and a list of comma
7553 /// locations.
7554 ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7555 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7556 Expr *ExecConfig = nullptr,
7557 bool IsExecConfig = false,
7558 bool AllowRecovery = false);
7559
7560 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
7561 // with the specified CallArgs
7562 Expr *BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id,
7563 MultiExprArg CallArgs);
7564
7566
7567 /// BuildResolvedCallExpr - Build a call to a resolved expression,
7568 /// i.e. an expression not of \p OverloadTy. The expression should
7569 /// unary-convert to an expression of function-pointer or
7570 /// block-pointer type.
7571 ///
7572 /// \param NDecl the declaration being called, if available
7574 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
7575 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
7576 Expr *Config = nullptr, bool IsExecConfig = false,
7577 ADLCallKind UsesADL = ADLCallKind::NotADL);
7578
7580 ParsedType &Ty, SourceLocation RParenLoc,
7581 Expr *CastExpr);
7582
7583 /// Prepares for a scalar cast, performing all the necessary stages
7584 /// except the final cast and returning the kind required.
7586
7587 /// Build an altivec or OpenCL literal.
7589 SourceLocation RParenLoc, Expr *E,
7590 TypeSourceInfo *TInfo);
7591
7592 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7593 /// the ParenListExpr into a sequence of comma binary operators.
7595
7597 SourceLocation RParenLoc, Expr *InitExpr);
7598
7600 TypeSourceInfo *TInfo,
7601 SourceLocation RParenLoc,
7602 Expr *LiteralExpr);
7603
7604 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7605 SourceLocation RBraceLoc);
7606
7607 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7608 SourceLocation RBraceLoc, bool IsExplicit);
7609
7610 /// Binary Operators. 'Tok' is the token for the operator.
7612 Expr *LHSExpr, Expr *RHSExpr);
7614 Expr *LHSExpr, Expr *RHSExpr,
7615 bool ForFoldExpression = false);
7616
7617 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7618 /// operator @p Opc at location @c TokLoc. This routine only supports
7619 /// built-in operations; ActOnBinOp handles overloaded operators.
7621 Expr *LHSExpr, Expr *RHSExpr,
7622 bool ForFoldExpression = false);
7624 UnresolvedSetImpl &Functions);
7625
7626 /// Look for instances where it is likely the comma operator is confused with
7627 /// another operator. There is an explicit list of acceptable expressions for
7628 /// the left hand side of the comma operator, otherwise emit a warning.
7629 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7630
7631 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7632 /// in the case of a the GNU conditional expr extension.
7634 SourceLocation ColonLoc, Expr *CondExpr,
7635 Expr *LHSExpr, Expr *RHSExpr);
7636
7637 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7639 LabelDecl *TheDecl);
7640
7641 void ActOnStartStmtExpr();
7642 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7643 SourceLocation RPLoc);
7645 SourceLocation RPLoc, unsigned TemplateDepth);
7646 // Handle the final expression in a statement expression.
7648 void ActOnStmtExprError();
7649
7650 /// __builtin_offsetof(type, a.b[123][456].c)
7652 TypeSourceInfo *TInfo,
7653 const Designation &Desig,
7654 SourceLocation RParenLoc);
7657 ParsedType ParsedArgTy,
7658 const Designation &Desig,
7659 SourceLocation RParenLoc);
7660
7661 // __builtin_choose_expr(constExpr, expr1, expr2)
7662 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7663 Expr *LHSExpr, Expr *RHSExpr,
7664 SourceLocation RPLoc);
7665
7666 // __builtin_va_arg(expr, type)
7668 SourceLocation RPLoc);
7670 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7671
7672 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7673 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7675 SourceLocation BuiltinLoc,
7676 SourceLocation RPLoc);
7677
7678 // #embed
7680 StringLiteral *BinaryData, StringRef FileName);
7681
7682 // Build a potentially resolved SourceLocExpr.
7684 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7685 DeclContext *ParentContext);
7686
7687 // __null
7689
7690 bool CheckCaseExpression(Expr *E);
7691
7692 //===------------------------- "Block" Extension ------------------------===//
7693
7694 /// ActOnBlockStart - This callback is invoked when a block literal is
7695 /// started.
7696 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7697
7698 /// ActOnBlockArguments - This callback allows processing of block arguments.
7699 /// If there are no arguments, this is still invoked.
7700 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7701 Scope *CurScope);
7702
7703 /// ActOnBlockError - If there is an error parsing a block, this callback
7704 /// is invoked to pop the information about the block from the action impl.
7705 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7706
7707 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7708 /// literal was successfully completed. ^(int x){...}
7710 Scope *CurScope);
7711
7712 //===---------------------------- Clang Extensions ----------------------===//
7713
7714 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7715 /// provided arguments.
7716 ///
7717 /// __builtin_convertvector( value, dst type )
7718 ///
7720 SourceLocation BuiltinLoc,
7721 SourceLocation RParenLoc);
7722
7723 //===---------------------------- OpenCL Features -----------------------===//
7724
7725 /// Parse a __builtin_astype expression.
7726 ///
7727 /// __builtin_astype( value, dst type )
7728 ///
7729 ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
7730 SourceLocation BuiltinLoc,
7731 SourceLocation RParenLoc);
7732
7733 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7735 SourceLocation BuiltinLoc,
7736 SourceLocation RParenLoc);
7737
7738 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7740 ArrayRef<Expr *> SubExprs,
7741 QualType T = QualType());
7742
7743 /// Cast a base object to a member's actual type.
7744 ///
7745 /// There are two relevant checks:
7746 ///
7747 /// C++ [class.access.base]p7:
7748 ///
7749 /// If a class member access operator [...] is used to access a non-static
7750 /// data member or non-static member function, the reference is ill-formed
7751 /// if the left operand [...] cannot be implicitly converted to a pointer to
7752 /// the naming class of the right operand.
7753 ///
7754 /// C++ [expr.ref]p7:
7755 ///
7756 /// If E2 is a non-static data member or a non-static member function, the
7757 /// program is ill-formed if the class of which E2 is directly a member is
7758 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7759 ///
7760 /// Note that the latter check does not consider access; the access of the
7761 /// "real" base class is checked as appropriate when checking the access of
7762 /// the member name.
7764 NestedNameSpecifier Qualifier,
7765 NamedDecl *FoundDecl,
7766 NamedDecl *Member);
7767
7768 /// CheckCallReturnType - Checks that a call expression's return type is
7769 /// complete. Returns true on failure. The location passed in is the location
7770 /// that best represents the call.
7771 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
7772 CallExpr *CE, FunctionDecl *FD);
7773
7774 /// Emit a warning for all pending noderef expressions that we recorded.
7776
7777private:
7778 /// Shared logic for building default member initializer which used in a
7779 /// constructor or an aggregate initialization.
7780 ///
7781 ///
7782 /// The caller enters that evaluation context and decides whether the result
7783 /// is finished as a full-expression. \p NestedDefaultChecking and
7784 /// \p NeedRebuild have to be sampled before entering it.
7785 ExprResult BuildCXXDefaultInitInternal(SourceLocation Loc, FieldDecl *Field,
7786 const InitializedEntity &Entity,
7787 bool NestedDefaultChecking,
7788 bool NeedRebuild);
7789
7790public:
7794 const InitializedEntity &MemberEntity);
7795
7796 /// Instantiate or parse a C++ default argument expression as necessary.
7797 /// Return true on error.
7799 ParmVarDecl *Param, Expr *Init = nullptr,
7800 bool SkipImmediateInvocations = true);
7801
7802 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7803 /// the default expr if needed.
7805 ParmVarDecl *Param, Expr *Init = nullptr);
7806
7807 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7808 /// invocation.
7810
7812
7813 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7814 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7815
7816 /// Abstract base class used for diagnosing integer constant
7817 /// expression violations.
7819 public:
7821
7823
7824 virtual SemaDiagnosticBuilder
7825 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7827 SourceLocation Loc) = 0;
7830 };
7831
7832 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7833 /// and reports the appropriate diagnostics. Returns false on success.
7834 /// Can optionally return the value of the expression.
7837 VerifyICEDiagnoser &Diagnoser,
7841 unsigned DiagID,
7844 VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result = nullptr,
7848 AllowFoldKind CanFold = AllowFoldKind::No) {
7849 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7850 }
7851
7852 /// DiagnoseAssignmentAsCondition - Given that an expression is
7853 /// being used as a boolean condition, warn if it's an assignment.
7855
7856 /// Redundant parentheses over an equality comparison can indicate
7857 /// that the user intended an assignment used as condition.
7859
7861 public:
7863 FullExprArg(Sema &actions) : E(nullptr) {}
7864
7865 ExprResult release() { return E; }
7866
7867 Expr *get() const { return E; }
7868
7869 Expr *operator->() { return E; }
7870
7871 private:
7872 // FIXME: No need to make the entire Sema class a friend when it's just
7873 // Sema::MakeFullExpr that needs access to the constructor below.
7874 friend class Sema;
7875
7876 explicit FullExprArg(Expr *expr) : E(expr) {}
7877
7878 Expr *E;
7879 };
7880
7882 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7883 }
7885 return FullExprArg(
7886 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7887 }
7889 ExprResult FE =
7890 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7891 /*DiscardedValue*/ true);
7892 return FullExprArg(FE.get());
7893 }
7894
7895 class ConditionResult {
7896 Decl *ConditionVar;
7897 ExprResult Condition;
7898 bool Invalid;
7899 std::optional<bool> KnownValue;
7900
7901 friend class Sema;
7902 ConditionResult(Sema &S, Decl *ConditionVar, ExprResult Condition,
7903 bool IsConstexpr)
7904 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7905 if (IsConstexpr && Condition.get()) {
7906 if (std::optional<llvm::APSInt> Val =
7907 Condition.get()->getIntegerConstantExpr(S.Context)) {
7908 KnownValue = !!(*Val);
7909 }
7910 }
7911 }
7912 explicit ConditionResult(bool Invalid)
7913 : ConditionVar(nullptr), Condition(Invalid), Invalid(Invalid),
7914 KnownValue(std::nullopt) {}
7915
7916 public:
7917 ConditionResult() : ConditionResult(false) {}
7918 bool isInvalid() const { return Invalid; }
7919 std::pair<VarDecl *, Expr *> get() const {
7920 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7921 Condition.get());
7922 }
7923 std::optional<bool> getKnownValue() const { return KnownValue; }
7924 };
7926
7927 /// CheckBooleanCondition - Diagnose problems involving the use of
7928 /// the given expression as a boolean condition (e.g. in an if
7929 /// statement). Also performs the standard function and array
7930 /// decays, possibly changing the input variable.
7931 ///
7932 /// \param Loc - A location associated with the condition, e.g. the
7933 /// 'if' keyword.
7934 /// \return true iff there were any errors
7936 bool IsConstexpr = false);
7937
7938 enum class ConditionKind {
7939 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7940 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7941 Switch ///< An integral condition for a 'switch' statement.
7942 };
7943
7944 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7945 ConditionKind CK, bool MissingOK = false);
7946
7947 QualType CheckConditionalOperands( // C99 6.5.15
7948 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
7949 ExprObjectKind &OK, SourceLocation QuestionLoc);
7950
7951 /// Emit a specialized diagnostic when one expression is a null pointer
7952 /// constant and the other is not a pointer. Returns true if a diagnostic is
7953 /// emitted.
7954 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7955 SourceLocation QuestionLoc);
7956
7957 /// type checking for vector binary operators.
7959 SourceLocation Loc, bool IsCompAssign,
7960 bool AllowBothBool, bool AllowBoolConversion,
7961 bool AllowBoolOperation);
7962
7963 /// Return a signed ext_vector_type that is of identical size and number of
7964 /// elements. For floating point vectors, return an integer type of identical
7965 /// size and number of elements. In the non ext_vector_type case, search from
7966 /// the largest type to the smallest type to avoid cases where long long ==
7967 /// long, where long gets picked over long long.
7970
7971 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7972 /// operates on extended vector types. Instead of producing an IntTy result,
7973 /// like a scalar comparison, a vector comparison produces a vector of integer
7974 /// types.
7976 SourceLocation Loc,
7977 BinaryOperatorKind Opc);
7979 SourceLocation Loc,
7980 BinaryOperatorKind Opc);
7982 SourceLocation Loc,
7983 BinaryOperatorKind Opc);
7985 SourceLocation Loc,
7986 BinaryOperatorKind Opc);
7988 SourceLocation Loc,
7989 BinaryOperatorKind Opc);
7990 // type checking for sizeless vector binary operators.
7992 SourceLocation Loc, bool IsCompAssign,
7993 ArithConvKind OperationKind);
7994
7995 /// Type checking for matrix binary operators.
7997 SourceLocation Loc,
7998 bool IsCompAssign);
8000 SourceLocation Loc, bool IsCompAssign);
8001
8002 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
8003 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
8004 /// VLST) allowed?
8005 ///
8006 /// This will also return false if the two given types do not make sense from
8007 /// the perspective of SVE bitcasts.
8008 bool isValidSveBitcast(QualType srcType, QualType destType);
8009
8010 /// Are the two types matrix types and do they have the same dimensions i.e.
8011 /// do they have the same number of rows and the same number of columns?
8013
8014 bool areVectorTypesSameSize(QualType srcType, QualType destType);
8015
8016 /// Are the two types lax-compatible vector types? That is, given
8017 /// that one of them is a vector, do they have equal storage sizes,
8018 /// where the storage size is the number of elements times the element
8019 /// size?
8020 ///
8021 /// This will also return false if either of the types is neither a
8022 /// vector nor a real type.
8023 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
8024
8025 /// Is this a legal conversion between two types, one of which is
8026 /// known to be a vector type?
8027 bool isLaxVectorConversion(QualType srcType, QualType destType);
8028
8029 // This returns true if at least one of the types is an altivec vector.
8030 bool anyAltivecTypes(QualType srcType, QualType destType);
8031
8032 // type checking C++ declaration initializers (C++ [dcl.init]).
8033
8034 /// Check a cast of an unknown-any type. We intentionally only
8035 /// trigger this for C-style casts.
8038 ExprValueKind &VK, CXXCastPath &Path);
8039
8040 /// Force an expression with unknown-type to an expression of the
8041 /// given type.
8043
8044 /// Type-check an expression that's being passed to an
8045 /// __unknown_anytype parameter.
8047 QualType &paramType);
8048
8049 // CheckMatrixCast - Check type constraints for matrix casts.
8050 // We allow casting between matrixes of the same dimensions i.e. when they
8051 // have the same number of rows and column. Returns true if the cast is
8052 // invalid.
8053 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
8054 CastKind &Kind);
8055
8056 // CheckVectorCast - check type constraints for vectors.
8057 // Since vectors are an extension, there are no C standard reference for this.
8058 // We allow casting between vectors and integer datatypes of the same size.
8059 // returns true if the cast is invalid
8060 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
8061 CastKind &Kind);
8062
8063 /// Prepare `SplattedExpr` for a vector splat operation, adding
8064 /// implicit casts if necessary.
8065 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
8066
8067 /// Prepare `SplattedExpr` for a matrix splat operation, adding
8068 /// implicit casts if necessary.
8069 ExprResult prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr);
8070
8071 // CheckExtVectorCast - check type constraints for extended vectors.
8072 // Since vectors are an extension, there are no C standard reference for this.
8073 // We allow casting between vectors and integer datatypes of the same size,
8074 // or vectors and the element type of that vector.
8075 // returns the cast expr
8077 CastKind &Kind);
8078
8080 return K == ConditionKind::Switch ? Context.IntTy : Context.BoolTy;
8081 }
8082
8083 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2), converts
8084 // functions and arrays to their respective pointers (C99 6.3.2.1), and
8085 // promotes floating-piont types according to the language semantics.
8087
8088 // UsualUnaryFPConversions - promotes floating-point types according to the
8089 // current language semantics.
8091
8092 /// CallExprUnaryConversions - a special case of an unary conversion
8093 /// performed on a function designator of a call expression.
8095
8096 // DefaultFunctionArrayConversion - converts functions and arrays
8097 // to their respective pointers (C99 6.3.2.1).
8099
8100 // DefaultFunctionArrayLvalueConversion - converts functions and
8101 // arrays to their respective pointers and performs the
8102 // lvalue-to-rvalue conversion.
8104 bool Diagnose = true);
8105
8106 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
8107 // the operand. This function is a no-op if the operand has a function type
8108 // or an array type.
8110
8111 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
8112 // do not have a prototype. Integer promotions are performed on each
8113 // argument, and arguments that have type float are promoted to double.
8115
8117 const FunctionProtoType *Proto,
8118 Expr *Fn);
8119
8120 /// Determine the degree of POD-ness for an expression.
8121 /// Incomplete types are considered POD, since this check can be performed
8122 /// when we're in an unevaluated context.
8124
8125 /// Check to see if the given expression is a valid argument to a variadic
8126 /// function, issuing a diagnostic if not.
8127 void checkVariadicArgument(const Expr *E, VariadicCallType CT);
8128
8129 /// GatherArgumentsForCall - Collector argument expressions for various
8130 /// form of call prototypes.
8132 SourceLocation CallLoc, FunctionDecl *FDecl,
8133 const FunctionProtoType *Proto, unsigned FirstParam,
8136 bool AllowExplicit = false, bool IsListInitialization = false);
8137
8138 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
8139 // will create a runtime trap if the resulting type is not a POD type.
8141 FunctionDecl *FDecl);
8142
8143 // Check that the usual arithmetic conversions can be performed on this pair
8144 // of expressions that might be of enumeration type.
8146 ArithConvKind ACK);
8147
8148 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
8149 // operands and then handles various conversions that are common to binary
8150 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
8151 // routine returns the first non-arithmetic type found. The client is
8152 // responsible for emitting appropriate error diagnostics.
8154 SourceLocation Loc, ArithConvKind ACK);
8155
8157 switch (ConvTy) {
8158 default:
8159 return false;
8163 return true;
8164 }
8165 llvm_unreachable("impossible");
8166 }
8167
8168 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
8169 /// assignment conversion type specified by ConvTy. This returns true if the
8170 /// conversion was invalid or false if the conversion was accepted.
8172 QualType DstType, QualType SrcType,
8173 Expr *SrcExpr, AssignmentAction Action,
8174 bool *Complained = nullptr);
8175
8176 /// CheckAssignmentConstraints - Perform type checking for assignment,
8177 /// argument passing, variable initialization, and function return values.
8178 /// C99 6.5.16.
8180 QualType LHSType,
8181 QualType RHSType);
8182
8183 /// Check assignment constraints and optionally prepare for a conversion of
8184 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
8185 /// is true.
8187 ExprResult &RHS, CastKind &Kind,
8188 bool ConvertRHS = true);
8189
8190 /// Check assignment constraints for an assignment of RHS to LHSType.
8191 ///
8192 /// \param LHSType The destination type for the assignment.
8193 /// \param RHS The source expression for the assignment.
8194 /// \param Diagnose If \c true, diagnostics may be produced when checking
8195 /// for assignability. If a diagnostic is produced, \p RHS will be
8196 /// set to ExprError(). Note that this function may still return
8197 /// without producing a diagnostic, even for an invalid assignment.
8198 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
8199 /// in an audited Core Foundation API and does not need to be checked
8200 /// for ARC retain issues.
8201 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
8202 /// conversions necessary to perform the assignment. If \c false,
8203 /// \p Diagnose must also be \c false.
8205 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
8206 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
8207
8208 // If the lhs type is a transparent union, check whether we
8209 // can initialize the transparent union with the given expression.
8211 ExprResult &RHS);
8212
8213 /// the following "Check" methods will return a valid/converted QualType
8214 /// or a null QualType (indicating an error diagnostic was issued).
8215
8216 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
8218 ExprResult &RHS);
8219
8220 /// Diagnose cases where a scalar was implicitly converted to a vector and
8221 /// diagnose the underlying types. Otherwise, diagnose the error
8222 /// as invalid vector logical operands for non-C++ cases.
8224 ExprResult &RHS);
8225
8227 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8228 BinaryOperatorKind Opc);
8229 QualType CheckRemainderOperands( // C99 6.5.5
8230 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8231 bool IsCompAssign = false);
8232 QualType CheckAdditionOperands( // C99 6.5.6
8233 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8234 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8236 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8237 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8238 QualType CheckShiftOperands( // C99 6.5.7
8239 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8240 BinaryOperatorKind Opc, bool IsCompAssign = false);
8242 QualType CheckCompareOperands( // C99 6.5.8/9
8243 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8244 BinaryOperatorKind Opc);
8245 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
8246 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8247 BinaryOperatorKind Opc);
8248 QualType CheckLogicalOperands( // C99 6.5.[13,14]
8249 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8250 BinaryOperatorKind Opc);
8251 // CheckAssignmentOperands is used for both simple and compound assignment.
8252 // For simple assignment, pass both expressions and a null converted type.
8253 // For compound assignment, pass both expressions and the converted type.
8254 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
8255 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
8256 BinaryOperatorKind Opc);
8257
8258 /// To be used for checking whether the arguments being passed to
8259 /// function exceeds the number of parameters expected for it.
8260 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
8261 bool PartialOverloading = false) {
8262 // We check whether we're just after a comma in code-completion.
8263 if (NumArgs > 0 && PartialOverloading)
8264 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
8265 return NumArgs > NumParams;
8266 }
8267
8268 /// Whether the AST is currently being rebuilt to correct immediate
8269 /// invocations. Immediate invocation candidates and references to consteval
8270 /// functions aren't tracked when this is set.
8272
8278
8279 /// Determines whether we are currently in a context that
8280 /// is not evaluated as per C++ [expr] p5.
8283 }
8284
8288
8292
8296
8303
8304 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8306 assert(!ExprEvalContexts.empty() &&
8307 "Must be in an expression evaluation context");
8308 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8310 Ctx.DelayedDefaultInitializationContext)
8311 return Ctx.DelayedDefaultInitializationContext;
8312 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8313 Ctx.isUnevaluated())
8314 break;
8315 }
8316 return std::nullopt;
8317 }
8318
8319 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8321 assert(!ExprEvalContexts.empty() &&
8322 "Must be in an expression evaluation context");
8323 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
8324 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8326 !Ctx.DelayedDefaultInitializationContext && Res)
8327 break;
8328 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8329 Ctx.isUnevaluated())
8330 break;
8331 Res = Ctx.DelayedDefaultInitializationContext;
8332 }
8333 return Res;
8334 }
8335
8336 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
8337 /// SelfAssigned when inside a CXXMethodDecl.
8338 const FieldDecl *
8340
8342
8343 template <typename... Ts>
8345 const Ts &...Args) {
8346 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8347 return RequireCompleteType(Loc, T, CompleteTypeKind::Normal, Diagnoser);
8348 }
8349
8350 template <typename... Ts>
8351 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
8352 const Ts &...Args) {
8353 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8355 }
8356
8357 /// Abstract class used to diagnose incomplete types.
8360
8361 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
8362 virtual ~TypeDiagnoser() {}
8363 };
8364
8365 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
8366 protected:
8367 unsigned DiagID;
8368 std::tuple<const Ts &...> Args;
8369
8370 template <std::size_t... Is>
8372 std::index_sequence<Is...>) const {
8373 // Apply all tuple elements to the builder in order.
8374 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
8375 (void)Dummy;
8376 }
8377
8378 public:
8379 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8380 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
8381 assert(DiagID != 0 && "no diagnostic for type diagnoser");
8382 }
8383
8384 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8385 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
8386 emit(DB, std::index_sequence_for<Ts...>());
8387 DB << T;
8388 }
8389 };
8390
8391 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
8392 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
8393 /// For example, a diagnostic with no other parameters would generally have
8394 /// the form "...%select{incomplete|sizeless}0 type %1...".
8395 template <typename... Ts>
8397 public:
8398 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8399 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
8400
8401 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8402 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
8403 this->emit(DB, std::index_sequence_for<Ts...>());
8404 DB << T->isSizelessType() << T;
8405 }
8406 };
8407
8408 /// Check an argument list for placeholders that we won't try to
8409 /// handle later.
8411
8412 /// The C++ "std::source_location::__impl" struct, defined in
8413 /// <source_location>.
8415
8416 /// A stack of expression evaluation contexts.
8418
8419 // Set of failed immediate invocations to avoid double diagnosing.
8421
8422 /// List of SourceLocations where 'self' is implicitly retained inside a
8423 /// block.
8426
8427 /// Do an explicit extend of the given block pointer if we're in ARC.
8429
8430 std::vector<std::pair<QualType, unsigned>> ExcessPrecisionNotSatisfied;
8433
8434private:
8435 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
8436
8437 /// Methods for marking which expressions involve dereferencing a pointer
8438 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
8439 /// they are parsed, meaning that a noderef pointer may not be accessed. For
8440 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
8441 /// `*p`, but need to check that `address of` is called on it. This requires
8442 /// keeping a container of all pending expressions and checking if the address
8443 /// of them are eventually taken.
8444 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
8445 void CheckAddressOfNoDeref(const Expr *E);
8446
8447 ///@}
8448
8449 //
8450 //
8451 // -------------------------------------------------------------------------
8452 //
8453 //
8454
8455 /// \name C++ Expressions
8456 /// Implementations are in SemaExprCXX.cpp
8457 ///@{
8458
8459public:
8460 /// The C++ "std::bad_alloc" class, which is defined by the C++
8461 /// standard library.
8463
8464 /// The C++ "std::align_val_t" enum class, which is defined by the C++
8465 /// standard library.
8467
8468 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
8470
8471 /// A flag to remember whether the implicit forms of operator new and delete
8472 /// have been declared.
8474
8475 /// Delete-expressions to be analyzed at the end of translation unit
8476 ///
8477 /// This list contains class members, and locations of delete-expressions
8478 /// that could not be proven as to whether they mismatch with new-expression
8479 /// used in initializer of the field.
8480 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
8481
8482 /// Handle the result of the special case name lookup for inheriting
8483 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
8484 /// constructor names in member using declarations, even if 'X' is not the
8485 /// name of the corresponding type.
8487 SourceLocation NameLoc,
8488 const IdentifierInfo &Name);
8489
8491 SourceLocation NameLoc, Scope *S,
8492 CXXScopeSpec &SS, bool EnteringContext);
8494 Scope *S, CXXScopeSpec &SS,
8495 ParsedType ObjectType, bool EnteringContext);
8496
8498 ParsedType ObjectType);
8499
8500 /// Build a C++ typeid expression with a type operand.
8501 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8502 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8503
8504 /// Build a C++ typeid expression with an expression operand.
8505 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8506 Expr *Operand, SourceLocation RParenLoc);
8507
8508 /// ActOnCXXTypeid - Parse typeid( something ).
8510 bool isType, void *TyOrExpr,
8511 SourceLocation RParenLoc);
8512
8513 /// Build a Microsoft __uuidof expression with a type operand.
8514 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8515 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8516
8517 /// Build a Microsoft __uuidof expression with an expression operand.
8518 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8519 Expr *Operand, SourceLocation RParenLoc);
8520
8521 /// ActOnCXXUuidof - Parse __uuidof( something ).
8523 bool isType, void *TyOrExpr,
8524 SourceLocation RParenLoc);
8525
8526 //// ActOnCXXThis - Parse 'this' pointer.
8528
8529 /// Check whether the type of 'this' is valid in the current context.
8531
8532 /// Build a CXXThisExpr and mark it referenced in the current context.
8533 Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
8535
8536 /// Try to retrieve the type of the 'this' pointer.
8537 ///
8538 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8540
8541 /// When non-NULL, the C++ 'this' expression is allowed despite the
8542 /// current context not being a non-static member function. In such cases,
8543 /// this provides the type used for 'this'.
8545
8546 /// RAII object used to temporarily allow the C++ 'this' expression
8547 /// to be used, with the given qualifiers on the current class type.
8549 Sema &S;
8550 QualType OldCXXThisTypeOverride;
8551 bool Enabled;
8552
8553 public:
8554 /// Introduce a new scope where 'this' may be allowed (when enabled),
8555 /// using the given declaration (which is either a class template or a
8556 /// class) along with the given qualifiers.
8557 /// along with the qualifiers placed on '*this'.
8558 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8559 bool Enabled = true);
8560
8564 };
8565
8566 /// Make sure the value of 'this' is actually available in the current
8567 /// context, if it is a potentially evaluated context.
8568 ///
8569 /// \param Loc The location at which the capture of 'this' occurs.
8570 ///
8571 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8572 /// capture list.
8573 ///
8574 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8575 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8576 /// This is useful when enclosing lambdas must speculatively capture
8577 /// 'this' that may or may not be used in certain specializations of
8578 /// a nested generic lambda (depending on whether the name resolves to
8579 /// a non-static member function or a static function).
8580 /// \return returns 'true' if failed, 'false' if success.
8582 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8583 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8584 bool ByCopy = false);
8585
8586 /// Determine whether the given type is the type of *this that is used
8587 /// outside of the body of a member function for a type that is currently
8588 /// being defined.
8590
8591 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8593
8594 /// Build a boolean-typed literal expression.
8596
8597 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8599
8600 //// ActOnCXXThrow - Parse throw expressions.
8603 bool IsThrownVarInScope);
8604
8605 /// CheckCXXThrowOperand - Validate the operand of a throw.
8606 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8607
8608 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8609 /// Can be interpreted either as function-style casting ("int(x)")
8610 /// or class type construction ("ClassType(x,y,z)")
8611 /// or creation of a value-initialized type ("int()").
8613 SourceLocation LParenOrBraceLoc,
8614 MultiExprArg Exprs,
8615 SourceLocation RParenOrBraceLoc,
8616 bool ListInitialization);
8617
8619 SourceLocation LParenLoc,
8620 MultiExprArg Exprs,
8621 SourceLocation RParenLoc,
8622 bool ListInitialization);
8623
8624 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8625 ///
8626 /// E.g.:
8627 /// @code new (memory) int[size][4] @endcode
8628 /// or
8629 /// @code ::new Foo(23, "hello") @endcode
8630 ///
8631 /// \param StartLoc The first location of the expression.
8632 /// \param UseGlobal True if 'new' was prefixed with '::'.
8633 /// \param PlacementLParen Opening paren of the placement arguments.
8634 /// \param PlacementArgs Placement new arguments.
8635 /// \param PlacementRParen Closing paren of the placement arguments.
8636 /// \param TypeIdParens If the type is in parens, the source range.
8637 /// \param D The type to be allocated, as well as array dimensions.
8638 /// \param Initializer The initializing expression or initializer-list, or
8639 /// null if there is none.
8640 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8641 SourceLocation PlacementLParen,
8642 MultiExprArg PlacementArgs,
8643 SourceLocation PlacementRParen,
8644 SourceRange TypeIdParens, Declarator &D,
8645 Expr *Initializer);
8647 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8648 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8649 SourceRange TypeIdParens, QualType AllocType,
8650 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8651 SourceRange DirectInitRange, Expr *Initializer);
8652
8653 /// Determine whether \p FD is an aligned allocation or deallocation
8654 /// function that is unavailable.
8656
8657 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8658 /// function that is unavailable.
8660 SourceLocation Loc);
8661
8662 /// Checks that a type is suitable as the allocated type
8663 /// in a new-expression.
8664 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
8665 SourceRange R);
8666
8667 /// Finds the overloads of operator new and delete that are appropriate
8668 /// for the allocation.
8669 std::optional<ResolvedAllocation> FindAllocationFunctions(
8670 SourceLocation StartLoc, SourceRange Range,
8672 QualType AllocType, bool IsArray, const ImplicitAllocationParameters &IAP,
8673 MultiExprArg PlaceArgs, bool Diagnose = true);
8674
8675 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8676 /// delete. These are:
8677 /// @code
8678 /// // C++03:
8679 /// void* operator new(std::size_t) throw(std::bad_alloc);
8680 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8681 /// void operator delete(void *) throw();
8682 /// void operator delete[](void *) throw();
8683 /// // C++11:
8684 /// void* operator new(std::size_t);
8685 /// void* operator new[](std::size_t);
8686 /// void operator delete(void *) noexcept;
8687 /// void operator delete[](void *) noexcept;
8688 /// // C++1y:
8689 /// void* operator new(std::size_t);
8690 /// void* operator new[](std::size_t);
8691 /// void operator delete(void *) noexcept;
8692 /// void operator delete[](void *) noexcept;
8693 /// void operator delete(void *, std::size_t) noexcept;
8694 /// void operator delete[](void *, std::size_t) noexcept;
8695 /// @endcode
8696 /// Note that the placement and nothrow forms of new are *not* implicitly
8697 /// declared. Their use requires including <new>.
8700 ArrayRef<QualType> Params);
8701
8703 DeclarationName Name, FunctionDecl *&Operator,
8705 bool Diagnose = true);
8708 DeclarationName Name,
8709 bool Diagnose = true);
8711 CXXRecordDecl *RD,
8712 bool Diagnose,
8713 bool LookForGlobal,
8714 DeclarationName Name);
8715
8716 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8717 /// @code ::delete ptr; @endcode
8718 /// or
8719 /// @code delete [] ptr; @endcode
8720 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8721 bool ArrayForm, Expr *Operand);
8723 bool IsDelete, bool CallCanBeVirtual,
8724 bool WarnOnNonAbstractTypes,
8725 SourceLocation DtorLoc);
8726
8728 Expr *Operand, SourceLocation RParen);
8730 SourceLocation RParen);
8731
8733 SourceLocation OpLoc,
8734 tok::TokenKind OpKind,
8735 ParsedType &ObjectType,
8736 bool &MayBePseudoDestructor);
8737
8739 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8740 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8741 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8742
8744 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8745 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8746 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8747
8749 SourceLocation OpLoc,
8750 tok::TokenKind OpKind,
8751 SourceLocation TildeLoc,
8752 const DeclSpec &DS);
8753
8754 /// MaybeCreateExprWithCleanups - If the current full-expression
8755 /// requires any cleanups, surround it with a ExprWithCleanups node.
8756 /// Otherwise, just returns the passed-in expression.
8760
8761 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8762 return ActOnFinishFullExpr(
8763 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8764 }
8766 bool DiscardedValue, bool IsConstexpr = false,
8767 bool IsTemplateArgument = false);
8769
8770 /// Process the expression contained within a decltype. For such expressions,
8771 /// certain semantic checks on temporaries are delayed until this point, and
8772 /// are omitted for the 'topmost' call in the decltype expression. If the
8773 /// topmost call bound a temporary, strip that temporary off the expression.
8775
8776 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8777 bool IsUDSuffix);
8778
8780
8781 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8782 SourceLocation StmtLoc,
8783 ConditionKind CK);
8784
8785 /// Check the use of the given variable as a C++ condition in an if,
8786 /// while, do-while, or switch statement.
8788 SourceLocation StmtLoc, ConditionKind CK);
8789
8790 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8791 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8792
8793 /// Helper function to determine whether this is the (deprecated) C++
8794 /// conversion from a string literal to a pointer to non-const char or
8795 /// non-const wchar_t (for narrow and wide string literals,
8796 /// respectively).
8798
8799 /// PerformImplicitConversion - Perform an implicit conversion of the
8800 /// expression From to the type ToType using the pre-computed implicit
8801 /// conversion sequence ICS. Returns the converted
8802 /// expression. Action is the kind of conversion we're performing,
8803 /// used in the error message.
8805 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8806 AssignmentAction Action,
8808
8809 /// PerformImplicitConversion - Perform an implicit conversion of the
8810 /// expression From to the type ToType by following the standard
8811 /// conversion sequence SCS. Returns the converted
8812 /// expression. Flavor is the context in which we're performing this
8813 /// conversion, for use in error messages.
8815 const StandardConversionSequence &SCS,
8816 AssignmentAction Action,
8818
8819 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8820
8821 /// Parsed one of the type trait support pseudo-functions.
8822 ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
8824 SourceLocation RParenLoc);
8825 ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc,
8827 SourceLocation RParenLoc);
8828
8829 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8830 /// pseudo-functions.
8831 ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc,
8832 ParsedType LhsTy, Expr *DimExpr,
8833 SourceLocation RParen);
8834
8835 ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc,
8836 TypeSourceInfo *TSInfo, Expr *DimExpr,
8837 SourceLocation RParen);
8838
8839 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8840 /// pseudo-functions.
8841 ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc,
8842 Expr *Queried, SourceLocation RParen);
8843
8844 ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc,
8845 Expr *Queried, SourceLocation RParen);
8846
8849 bool isIndirect);
8851 ExprResult &RHS,
8852 SourceLocation QuestionLoc);
8853
8854 //// Determines if a type is trivially relocatable
8855 /// according to the C++26 rules.
8856 // FIXME: This is in Sema because it requires
8857 // overload resolution, can we move to ASTContext?
8860
8861 /// Check the operands of ?: under C++ semantics.
8862 ///
8863 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8864 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8865 ///
8866 /// This function also implements GCC's vector extension and the
8867 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8868 /// permit the use of a?b:c where the type of a is that of a integer vector
8869 /// with the same number of elements and size as the vectors of b and c. If
8870 /// one of either b or c is a scalar it is implicitly converted to match the
8871 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8872 /// c are scalars, then b and c are checked and converted to the type of a if
8873 /// possible.
8874 ///
8875 /// The expressions are evaluated differently for GCC's and OpenCL's
8876 /// extensions. For the GCC extension, the ?: operator is evaluated as
8877 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8878 /// For the OpenCL extensions, the ?: operator is evaluated as
8879 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8880 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8882 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8883 ExprObjectKind &OK, SourceLocation questionLoc);
8884
8885 /// Find a merged pointer type and convert the two expressions to it.
8886 ///
8887 /// This finds the composite pointer type for \p E1 and \p E2 according to
8888 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8889 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8890 /// ConvertArgs is \c true).
8891 ///
8892 /// \param Loc The location of the operator requiring these two expressions to
8893 /// be converted to the composite pointer type.
8894 ///
8895 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8896 /// type.
8898 bool ConvertArgs = true);
8900 ExprResult &E2, bool ConvertArgs = true) {
8901 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8902 QualType Composite =
8903 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8904 E1 = E1Tmp;
8905 E2 = E2Tmp;
8906 return Composite;
8907 }
8908
8909 /// MaybeBindToTemporary - If the passed in expression has a record type with
8910 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8911 /// it simply returns the passed in expression.
8913
8914 /// IgnoredValueConversions - Given that an expression's result is
8915 /// syntactically ignored, perform any conversions that are
8916 /// required.
8918
8920
8923 const DeclarationNameInfo &TargetNameInfo);
8924
8926 SourceLocation KeywordLoc,
8927 bool IsIfExists, CXXScopeSpec &SS,
8928 UnqualifiedId &Name);
8929
8932 ArrayRef<ParmVarDecl *> LocalParameters,
8933 Scope *BodyScope);
8937 CXXScopeSpec &SS,
8938 SourceLocation NameLoc,
8939 const IdentifierInfo *TypeName,
8940 TemplateIdAnnotation *TemplateId);
8942 SourceLocation NoexceptLoc);
8944 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8945 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8948 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8952 bool IsSatisfied, SourceLocation NoexceptLoc,
8959 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8960 const ASTConstraintSatisfaction &Satisfaction);
8963 SourceLocation LParenLoc,
8964 ArrayRef<ParmVarDecl *> LocalParameters,
8965 SourceLocation RParenLoc,
8967 SourceLocation ClosingBraceLoc);
8968
8969private:
8970 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8971 bool IsDelete);
8972
8973 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8974 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8975 bool DeleteWasArrayForm);
8976
8977 std::optional<AllocationArgumentSet>
8978 resolveAllocationArguments(LookupResult &R,
8980 ArrayRef<Expr *> PlacementArguments);
8981
8982 // Attempts to construct the type identity argument for the call to a
8983 // type aware operator new. Returns null on failure.
8984 Expr *tryGetTypeIdentityArgument(QualType Type, SourceLocation);
8985
8986 Expr *AllocationSizeExpr = nullptr;
8987 Expr *AllocationAlignmentExpr = nullptr;
8988 llvm::DenseMap<QualType, Expr *> AllocationTypeIdentityArguments;
8989
8990 ///@}
8991
8992 //
8993 //
8994 // -------------------------------------------------------------------------
8995 //
8996 //
8997
8998 /// \name Member Access Expressions
8999 /// Implementations are in SemaExprMember.cpp
9000 ///@{
9001
9002public:
9003 /// Check whether an expression might be an implicit class member access.
9005 bool IsAddressOfOperand);
9006
9007 /// Builds an expression which might be an implicit member expression.
9009 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
9010 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
9011
9012 /// Builds an implicit member access expression. The current context
9013 /// is known to be an instance method, and the given unqualified lookup
9014 /// set is known to contain only instance members, at least one of which
9015 /// is from an appropriate type.
9017 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9018 LookupResult &R,
9019 const TemplateArgumentListInfo *TemplateArgs,
9020 bool IsDefiniteInstance, const Scope *S);
9021
9023 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
9024 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9025 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
9026 const TemplateArgumentListInfo *TemplateArgs);
9027
9028 /// The main callback when the parser finds something like
9029 /// expression . [nested-name-specifier] identifier
9030 /// expression -> [nested-name-specifier] identifier
9031 /// where 'identifier' encompasses a fairly broad spectrum of
9032 /// possibilities, including destructor and operator references.
9033 ///
9034 /// \param OpKind either tok::arrow or tok::period
9035 /// \param ObjCImpDecl the current Objective-C \@implementation
9036 /// decl; this is an ugly hack around the fact that Objective-C
9037 /// \@implementations aren't properly put in the context chain
9039 tok::TokenKind OpKind, CXXScopeSpec &SS,
9040 SourceLocation TemplateKWLoc,
9041 UnqualifiedId &Member, Decl *ObjCImpDecl);
9042
9043 MemberExpr *
9044 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
9045 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
9046 ValueDecl *Member, DeclAccessPair FoundDecl,
9047 bool HadMultipleCandidates,
9048 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
9050 const TemplateArgumentListInfo *TemplateArgs = nullptr);
9051
9052 // Check whether the declarations we found through a nested-name
9053 // specifier in a member expression are actually members of the base
9054 // type. The restriction here is:
9055 //
9056 // C++ [expr.ref]p2:
9057 // ... In these cases, the id-expression shall name a
9058 // member of the class or of one of its base classes.
9059 //
9060 // So it's perfectly legitimate for the nested-name specifier to name
9061 // an unrelated class, and for us to find an overload set including
9062 // decls from classes which are not superclasses, as long as the decl
9063 // we actually pick through overload resolution is from a superclass.
9064 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
9065 const CXXScopeSpec &SS,
9066 const LookupResult &R);
9067
9068 // This struct is for use by ActOnMemberAccess to allow
9069 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
9070 // changing the access operator from a '.' to a '->' (to see if that is the
9071 // change needed to fix an error about an unknown member, e.g. when the class
9072 // defines a custom operator->).
9078
9080 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
9081 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
9082 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
9083 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
9084 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
9085
9088 bool IsArrow, const CXXScopeSpec &SS,
9089 SourceLocation TemplateKWLoc,
9090 NamedDecl *FirstQualifierInScope, LookupResult &R,
9091 const TemplateArgumentListInfo *TemplateArgs,
9092 const Scope *S, bool SuppressQualifierCheck = false,
9093 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
9094
9095 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
9096 SourceLocation OpLoc,
9097 const CXXScopeSpec &SS, FieldDecl *Field,
9098 DeclAccessPair FoundDecl,
9099 const DeclarationNameInfo &MemberNameInfo);
9100
9101 /// Perform conversions on the LHS of a member access expression.
9103
9105 const CXXScopeSpec &SS, SourceLocation nameLoc,
9106 IndirectFieldDecl *indirectField,
9107 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
9108 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
9109
9110private:
9111 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
9112
9113 ///@}
9114
9115 //
9116 //
9117 // -------------------------------------------------------------------------
9118 //
9119 //
9120
9121 /// \name Initializers
9122 /// Implementations are in SemaInit.cpp
9123 ///@{
9124
9125public:
9126 /// Stack of types that correspond to the parameter entities that are
9127 /// currently being copy-initialized. Can be empty.
9129
9130 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
9132
9133 bool IsStringInit(Expr *Init, const ArrayType *AT);
9134
9135 /// Determine whether we can perform aggregate initialization for the purposes
9136 /// of overload resolution.
9138 const InitializedEntity &Entity, InitListExpr *From);
9139
9141 SourceLocation EqualOrColonLoc,
9142 bool GNUSyntax, ExprResult Init);
9143
9144 /// Check that the lifetime of the initializer (and its subobjects) is
9145 /// sufficient for initializing the entity, and perform lifetime extension
9146 /// (when permitted) if not.
9148
9151 bool BoundToLvalueReference);
9152
9153 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
9154 /// it as an xvalue. In C++98, the result will still be a prvalue, because
9155 /// we don't have xvalues there.
9157
9161
9165 SourceLocation EqualLoc, ExprResult Init,
9166 bool TopLevelOfInitList = false,
9167 bool AllowExplicit = false);
9168
9170 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
9171 const InitializationKind &Kind, MultiExprArg Init);
9172
9173 ///@}
9174
9175 //
9176 //
9177 // -------------------------------------------------------------------------
9178 //
9179 //
9180
9181 /// \name C++ Lambda Expressions
9182 /// Implementations are in SemaLambda.cpp
9183 ///@{
9184
9185public:
9186 /// Create a new lambda closure type.
9188 TypeSourceInfo *Info,
9189 unsigned LambdaDependencyKind,
9190 LambdaCaptureDefault CaptureDefault);
9191
9192 /// Number lambda for linkage purposes if necessary.
9194 std::optional<CXXRecordDecl::LambdaNumbering>
9195 NumberingOverride = std::nullopt);
9196
9197 /// Endow the lambda scope info with the relevant properties.
9198 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
9199 SourceRange IntroducerRange,
9200 LambdaCaptureDefault CaptureDefault,
9201 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
9202 bool Mutable);
9203
9206
9208 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
9209 TemplateParameterList *TemplateParams);
9210
9211 void
9213 SourceLocation CallOperatorLoc,
9214 const AssociatedConstraint &TrailingRequiresClause,
9215 TypeSourceInfo *MethodTyInfo,
9216 ConstexprSpecKind ConstexprKind, StorageClass SC,
9218 bool HasExplicitResultType);
9219
9220 /// Returns true if the explicit object parameter was invalid.
9222 SourceLocation CallLoc);
9223
9224 /// Perform initialization analysis of the init-capture and perform
9225 /// any implicit conversions such as an lvalue-to-rvalue conversion if
9226 /// not being used to initialize a reference.
9228 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
9229 IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init) {
9231 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
9233 }
9235 SourceLocation EllipsisLoc,
9236 UnsignedOrNone NumExpansions,
9237 IdentifierInfo *Id,
9238 bool DirectInit, Expr *&Init);
9239
9240 /// Create a dummy variable within the declcontext of the lambda's
9241 /// call operator, for name lookup purposes for a lambda init capture.
9242 ///
9243 /// CodeGen handles emission of lambda captures, ignoring these dummy
9244 /// variables appropriately.
9246 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
9247 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
9248
9249 /// Add an init-capture to a lambda scope.
9250 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
9251
9252 /// Note that we have finished the explicit captures for the
9253 /// given lambda.
9255
9256 /// Deduce a block or lambda's return type based on the return
9257 /// statements present in the body.
9259
9260 /// Once the Lambdas capture are known, we can start to create the closure,
9261 /// call operator method, and keep track of the captures.
9262 /// We do the capture lookup here, but they are not actually captured until
9263 /// after we know what the qualifiers of the call operator are.
9265 Scope *CurContext);
9266
9267 /// This is called after parsing the explicit template parameter list
9268 /// on a lambda (if it exists) in C++2a.
9270 SourceLocation LAngleLoc,
9271 ArrayRef<NamedDecl *> TParams,
9272 SourceLocation RAngleLoc,
9273 ExprResult RequiresClause);
9274
9276 SourceLocation MutableLoc);
9277
9279 Scope *LambdaScope,
9281
9282 /// ActOnStartOfLambdaDefinition - This is called just before we start
9283 /// parsing the body of a lambda; it analyzes the explicit captures and
9284 /// arguments, and sets up various data-structures for the body of the
9285 /// lambda.
9287 Declarator &ParamInfo, const DeclSpec &DS);
9288
9289 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
9290 /// is invoked to pop the information about the lambda.
9291 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
9292 bool IsInstantiation = false);
9293
9294 /// ActOnLambdaExpr - This is called when the body of a lambda expression
9295 /// was successfully completed.
9297
9298 /// Does copying/destroying the captured variable have side effects?
9299 bool CaptureHasSideEffects(const sema::Capture &From);
9300
9301 /// Diagnose if an explicit lambda capture is unused. Returns true if a
9302 /// diagnostic is emitted.
9303 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
9304 SourceRange FixItRange,
9305 const sema::Capture &From);
9306
9307 /// Build a FieldDecl suitable to hold the given capture.
9309 bool IsOpenMP = false);
9310
9311 /// Initialize the given capture with a suitable expression.
9313 SourceLocation ImplicitCaptureLoc,
9314 bool IsOpenMPMapping = false);
9315
9316 /// Complete a lambda-expression having processed and attached the
9317 /// lambda body.
9319
9320 /// Get the return type to use for a lambda's conversion function(s) to
9321 /// function pointer type, given the type of the call operator.
9322 QualType
9324 CallingConv CC);
9325
9327 SourceLocation ConvLocation,
9328 CXXConversionDecl *Conv, Expr *Src);
9329
9331 : private FunctionScopeRAII {
9332 public:
9334 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
9336 bool ShouldAddDeclsFromParentScope = true);
9337 };
9338
9339 /// Compute the mangling number context for a lambda expression or
9340 /// block literal. Also return the extra mangling decl if any.
9341 ///
9342 /// \param DC - The DeclContext containing the lambda expression or
9343 /// block literal.
9344 std::tuple<MangleNumberingContext *, Decl *>
9346
9347 ///@}
9348
9349 //
9350 //
9351 // -------------------------------------------------------------------------
9352 //
9353 //
9354
9355 /// \name Name Lookup
9356 ///
9357 /// These routines provide name lookup that is used during semantic
9358 /// analysis to resolve the various kinds of names (identifiers,
9359 /// overloaded operator names, constructor names, etc.) into zero or
9360 /// more declarations within a particular scope. The major entry
9361 /// points are LookupName, which performs unqualified name lookup,
9362 /// and LookupQualifiedName, which performs qualified name lookup.
9363 ///
9364 /// All name lookup is performed based on some specific criteria,
9365 /// which specify what names will be visible to name lookup and how
9366 /// far name lookup should work. These criteria are important both
9367 /// for capturing language semantics (certain lookups will ignore
9368 /// certain names, for example) and for performance, since name
9369 /// lookup is often a bottleneck in the compilation of C++. Name
9370 /// lookup criteria is specified via the LookupCriteria enumeration.
9371 ///
9372 /// The results of name lookup can vary based on the kind of name
9373 /// lookup performed, the current language, and the translation
9374 /// unit. In C, for example, name lookup will either return nothing
9375 /// (no entity found) or a single declaration. In C++, name lookup
9376 /// can additionally refer to a set of overloaded functions or
9377 /// result in an ambiguity. All of the possible results of name
9378 /// lookup are captured by the LookupResult class, which provides
9379 /// the ability to distinguish among them.
9380 ///
9381 /// Implementations are in SemaLookup.cpp
9382 ///@{
9383
9384public:
9385 /// Tracks whether we are in a context where typo correction is
9386 /// disabled.
9388
9389 /// The number of typos corrected by CorrectTypo.
9391
9392 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
9393 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
9394
9395 /// A cache containing identifiers for which typo correction failed and
9396 /// their locations, so that repeated attempts to correct an identifier in a
9397 /// given location are ignored if typo correction already failed for it.
9399
9400 /// SpecialMemberOverloadResult - The overloading result for a special member
9401 /// function.
9402 ///
9403 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
9404 /// integer are used to determine whether overload resolution succeeded.
9406 public:
9408
9409 private:
9410 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
9411
9412 public:
9415 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
9416
9417 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
9418 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
9419
9420 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
9421 void setKind(Kind K) { Pair.setInt(K); }
9422 };
9423
9424 using SpecialMemberCacheKey = std::pair<const CXXRecordDecl *, unsigned>;
9425
9426 /// A cache of special member function overload resolution results
9427 /// for C++ records.
9428 llvm::DenseMap<SpecialMemberCacheKey, SpecialMemberOverloadResult>
9430
9432
9433 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
9434 // TODO: make this is a typesafe union.
9437
9438 /// Describes the kind of name lookup to perform.
9440 /// Ordinary name lookup, which finds ordinary names (functions,
9441 /// variables, typedefs, etc.) in C and most kinds of names
9442 /// (functions, variables, members, types, etc.) in C++.
9444 /// Tag name lookup, which finds the names of enums, classes,
9445 /// structs, and unions.
9447 /// Label name lookup.
9449 /// Member name lookup, which finds the names of
9450 /// class/struct/union members.
9452 /// Look up of an operator name (e.g., operator+) for use with
9453 /// operator overloading. This lookup is similar to ordinary name
9454 /// lookup, but will ignore any declarations that are class members.
9456 /// Look up a name following ~ in a destructor name. This is an ordinary
9457 /// lookup, but prefers tags to typedefs.
9459 /// Look up of a name that precedes the '::' scope resolution
9460 /// operator in C++. This lookup completely ignores operator, object,
9461 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9463 /// Look up a namespace name within a C++ using directive or
9464 /// namespace alias definition, ignoring non-namespace names (C++
9465 /// [basic.lookup.udir]p1).
9467 /// Look up all declarations in a scope with the given name,
9468 /// including resolved using declarations. This is appropriate
9469 /// for checking redeclarations for a using declaration.
9471 /// Look up an ordinary name that is going to be redeclared as a
9472 /// name with linkage. This lookup ignores any declarations that
9473 /// are outside of the current scope unless they have linkage. See
9474 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9476 /// Look up a friend of a local class. This lookup does not look
9477 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9479 /// Look up the name of an Objective-C protocol.
9481 /// Look up implicit 'self' parameter of an objective-c method.
9483 /// Look up the name of an OpenMP user-defined reduction operation.
9485 /// Look up the name of an OpenMP user-defined mapper.
9487 /// Look up any declaration with any name.
9489 };
9490
9491 /// The possible outcomes of name lookup for a literal operator.
9493 /// The lookup resulted in an error.
9495 /// The lookup found no match but no diagnostic was issued.
9497 /// The lookup found a single 'cooked' literal operator, which
9498 /// expects a normal literal to be built and passed to it.
9500 /// The lookup found a single 'raw' literal operator, which expects
9501 /// a string literal containing the spelling of the literal token.
9503 /// The lookup found an overload set of literal operator templates,
9504 /// which expect the characters of the spelling of the literal token to be
9505 /// passed as a non-type template argument pack.
9507 /// The lookup found an overload set of literal operator templates,
9508 /// which expect the character type and characters of the spelling of the
9509 /// string literal token to be passed as template arguments.
9511 };
9512
9513 SpecialMemberOverloadResult
9515 bool VolatileArg, bool RValueThis, bool ConstThis,
9516 bool VolatileThis);
9517
9519
9520 /// Look up a name, looking for a single declaration. Return
9521 /// null if the results were absent, ambiguous, or overloaded.
9522 ///
9523 /// It is preferable to use the elaborated form and explicitly handle
9524 /// ambiguity and overloaded.
9526 Scope *S, DeclarationName Name, SourceLocation Loc,
9527 LookupNameKind NameKind,
9529
9530 /// Lookup a builtin function, when name lookup would otherwise
9531 /// fail.
9532 bool LookupBuiltin(LookupResult &R);
9533 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9534
9535 /// Perform unqualified name lookup starting from a given
9536 /// scope.
9537 ///
9538 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9539 /// used to find names within the current scope. For example, 'x' in
9540 /// @code
9541 /// int x;
9542 /// int f() {
9543 /// return x; // unqualified name look finds 'x' in the global scope
9544 /// }
9545 /// @endcode
9546 ///
9547 /// Different lookup criteria can find different names. For example, a
9548 /// particular scope can have both a struct and a function of the same
9549 /// name, and each can be found by certain lookup criteria. For more
9550 /// information about lookup criteria, see the documentation for the
9551 /// class LookupCriteria.
9552 ///
9553 /// @param S The scope from which unqualified name lookup will
9554 /// begin. If the lookup criteria permits, name lookup may also search
9555 /// in the parent scopes.
9556 ///
9557 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9558 /// look up and the lookup kind), and is updated with the results of lookup
9559 /// including zero or more declarations and possibly additional information
9560 /// used to diagnose ambiguities.
9561 ///
9562 /// @returns \c true if lookup succeeded and false otherwise.
9563 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9564 bool ForceNoCPlusPlus = false);
9565
9566 /// Perform qualified name lookup into a given context.
9567 ///
9568 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9569 /// names when the context of those names is explicit specified, e.g.,
9570 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9571 ///
9572 /// Different lookup criteria can find different names. For example, a
9573 /// particular scope can have both a struct and a function of the same
9574 /// name, and each can be found by certain lookup criteria. For more
9575 /// information about lookup criteria, see the documentation for the
9576 /// class LookupCriteria.
9577 ///
9578 /// \param R captures both the lookup criteria and any lookup results found.
9579 ///
9580 /// \param LookupCtx The context in which qualified name lookup will
9581 /// search. If the lookup criteria permits, name lookup may also search
9582 /// in the parent contexts or (for C++ classes) base classes.
9583 ///
9584 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9585 /// occurs as part of unqualified name lookup.
9586 ///
9587 /// \returns true if lookup succeeded, false if it failed.
9588 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9589 bool InUnqualifiedLookup = false);
9590
9591 /// Performs qualified name lookup or special type of lookup for
9592 /// "__super::" scope specifier.
9593 ///
9594 /// This routine is a convenience overload meant to be called from contexts
9595 /// that need to perform a qualified name lookup with an optional C++ scope
9596 /// specifier that might require special kind of lookup.
9597 ///
9598 /// \param R captures both the lookup criteria and any lookup results found.
9599 ///
9600 /// \param LookupCtx The context in which qualified name lookup will
9601 /// search.
9602 ///
9603 /// \param SS An optional C++ scope-specifier.
9604 ///
9605 /// \returns true if lookup succeeded, false if it failed.
9606 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9607 CXXScopeSpec &SS);
9608
9609 /// Performs name lookup for a name that was parsed in the
9610 /// source code, and may contain a C++ scope specifier.
9611 ///
9612 /// This routine is a convenience routine meant to be called from
9613 /// contexts that receive a name and an optional C++ scope specifier
9614 /// (e.g., "N::M::x"). It will then perform either qualified or
9615 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9616 /// respectively) on the given name and return those results. It will
9617 /// perform a special type of lookup for "__super::" scope specifier.
9618 ///
9619 /// @param S The scope from which unqualified name lookup will
9620 /// begin.
9621 ///
9622 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9623 ///
9624 /// @param EnteringContext Indicates whether we are going to enter the
9625 /// context of the scope-specifier SS (if present).
9626 ///
9627 /// @returns True if any decls were found (but possibly ambiguous)
9629 QualType ObjectType, bool AllowBuiltinCreation = false,
9630 bool EnteringContext = false);
9631
9632 /// Perform qualified name lookup into all base classes of the given
9633 /// class.
9634 ///
9635 /// \param R captures both the lookup criteria and any lookup results found.
9636 ///
9637 /// \param Class The context in which qualified name lookup will
9638 /// search. Name lookup will search in all base classes merging the results.
9639 ///
9640 /// @returns True if any decls were found (but possibly ambiguous)
9642
9644 UnresolvedSetImpl &Functions);
9645
9646 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9647 /// If GnuLabelLoc is a valid source location, then this is a definition
9648 /// of an __label__ label name, otherwise it is a normal label definition
9649 /// or use. If IsLabelStmt is true, then this is the label of a
9650 /// labeled-statement.
9652 SourceLocation GnuLabelLoc = SourceLocation(),
9653 bool IsLabelStmt = false);
9654
9655 /// Perform a name lookup for a label with the specified name; this does not
9656 /// create a new label if the lookup fails.
9658
9659 /// Look up the constructors for the given class.
9661
9662 /// Look up the default constructor for the given class.
9664
9665 /// Look up the copying constructor for the given class.
9667 unsigned Quals);
9668
9669 /// Look up the copying assignment operator for the given class.
9671 bool RValueThis, unsigned ThisQuals);
9672
9673 /// Look up the moving constructor for the given class.
9675 unsigned Quals);
9676
9677 /// Look up the moving assignment operator for the given class.
9679 bool RValueThis, unsigned ThisQuals);
9680
9681 /// Look for the destructor of the given class.
9682 ///
9683 /// During semantic analysis, this routine should be used in lieu of
9684 /// CXXRecordDecl::getDestructor().
9685 ///
9686 /// \returns The destructor for this class.
9688
9689 /// Force the declaration of any implicitly-declared members of this
9690 /// class.
9692
9693 /// Make a merged definition of an existing hidden definition \p ND
9694 /// visible at the specified location.
9696
9697 /// Check ODR hashes for C/ObjC when merging types from modules.
9698 /// Differently from C++, actually parse the body and reject in case
9699 /// of a mismatch.
9700 template <typename T,
9701 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9703 if (Duplicate->getODRHash() != Previous->getODRHash())
9704 return false;
9705
9706 // Make the previous decl visible.
9708 return true;
9709 }
9710
9711 /// Get the set of additional modules that should be checked during
9712 /// name lookup. A module and its imports become visible when instanting a
9713 /// template defined within it.
9714 llvm::DenseSet<Module *> &getLookupModules();
9715
9716 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9718
9719 /// Determine if the template parameter \p D has a visible default argument.
9720 bool
9722 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9723 /// Determine if the template parameter \p D has a reachable default argument.
9725 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9726 /// Determine if the template parameter \p D has a reachable default argument.
9730
9731 /// Determine if there is a visible declaration of \p D that is an explicit
9732 /// specialization declaration for a specialization of a template. (For a
9733 /// member specialization, use hasVisibleMemberSpecialization.)
9735 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9736 /// Determine if there is a reachable declaration of \p D that is an explicit
9737 /// specialization declaration for a specialization of a template. (For a
9738 /// member specialization, use hasReachableMemberSpecialization.)
9740 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9741
9742 /// Determine if there is a visible declaration of \p D that is a member
9743 /// specialization declaration (as opposed to an instantiated declaration).
9745 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9746 /// Determine if there is a reachable declaration of \p D that is a member
9747 /// specialization declaration (as opposed to an instantiated declaration).
9749 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9750
9751 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9752
9753 /// Determine whether any declaration of an entity is visible.
9754 bool
9756 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9757 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9758 }
9759
9762 /// Determine whether any declaration of an entity is reachable.
9763 bool
9765 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9766 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9767 }
9769 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9770
9771 void diagnoseTypo(const TypoCorrection &Correction,
9772 const PartialDiagnostic &TypoDiag,
9773 bool ErrorRecovery = true);
9774
9775 /// Diagnose a successfully-corrected typo. Separated from the correction
9776 /// itself to allow external validation of the result, etc.
9777 ///
9778 /// \param Correction The result of performing typo correction.
9779 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9780 /// string added to it (and usually also a fixit).
9781 /// \param PrevNote A note to use when indicating the location of the entity
9782 /// to which we are correcting. Will have the correction string added
9783 /// to it.
9784 /// \param ErrorRecovery If \c true (the default), the caller is going to
9785 /// recover from the typo as if the corrected string had been typed.
9786 /// In this case, \c PDiag must be an error, and we will attach a fixit
9787 /// to it.
9788 void diagnoseTypo(const TypoCorrection &Correction,
9789 const PartialDiagnostic &TypoDiag,
9790 const PartialDiagnostic &PrevNote,
9791 bool ErrorRecovery = true);
9792
9793 /// Find the associated classes and namespaces for
9794 /// argument-dependent lookup for a call with the given set of
9795 /// arguments.
9796 ///
9797 /// This routine computes the sets of associated classes and associated
9798 /// namespaces searched by argument-dependent lookup
9799 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9801 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9802 AssociatedNamespaceSet &AssociatedNamespaces,
9803 AssociatedClassSet &AssociatedClasses);
9804
9805 /// Produce a diagnostic describing the ambiguity that resulted
9806 /// from name lookup.
9807 ///
9808 /// \param Result The result of the ambiguous lookup to be diagnosed.
9810
9811 /// LookupLiteralOperator - Determine which literal operator should be used
9812 /// for a user-defined literal, per C++11 [lex.ext].
9813 ///
9814 /// Normal overload resolution is not used to select which literal operator to
9815 /// call for a user-defined literal. Look up the provided literal operator
9816 /// name, and filter the results to the appropriate set for the given argument
9817 /// types.
9820 bool AllowRaw, bool AllowTemplate,
9821 bool AllowStringTemplate, bool DiagnoseMissing,
9822 StringLiteral *StringLit = nullptr);
9823
9825 ArrayRef<Expr *> Args, ADLResult &Functions);
9826
9827 void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
9829 bool IncludeGlobalScope = true,
9830 bool LoadExternal = true);
9831 void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
9833 bool IncludeGlobalScope = true,
9834 bool IncludeDependentBases = false,
9835 bool LoadExternal = true);
9836
9837 /// Try to "correct" a typo in the source code by finding
9838 /// visible declarations whose names are similar to the name that was
9839 /// present in the source code.
9840 ///
9841 /// \param TypoName the \c DeclarationNameInfo structure that contains
9842 /// the name that was present in the source code along with its location.
9843 ///
9844 /// \param LookupKind the name-lookup criteria used to search for the name.
9845 ///
9846 /// \param S the scope in which name lookup occurs.
9847 ///
9848 /// \param SS the nested-name-specifier that precedes the name we're
9849 /// looking for, if present.
9850 ///
9851 /// \param CCC A CorrectionCandidateCallback object that provides further
9852 /// validation of typo correction candidates. It also provides flags for
9853 /// determining the set of keywords permitted.
9854 ///
9855 /// \param MemberContext if non-NULL, the context in which to look for
9856 /// a member access expression.
9857 ///
9858 /// \param EnteringContext whether we're entering the context described by
9859 /// the nested-name-specifier SS.
9860 ///
9861 /// \param OPT when non-NULL, the search for visible declarations will
9862 /// also walk the protocols in the qualified interfaces of \p OPT.
9863 ///
9864 /// \returns a \c TypoCorrection containing the corrected name if the typo
9865 /// along with information such as the \c NamedDecl where the corrected name
9866 /// was declared, and any additional \c NestedNameSpecifier needed to access
9867 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9869 Sema::LookupNameKind LookupKind, Scope *S,
9871 CorrectTypoKind Mode,
9872 DeclContext *MemberContext = nullptr,
9873 bool EnteringContext = false,
9874 const ObjCObjectPointerType *OPT = nullptr,
9875 bool RecordFailure = true);
9876
9877 /// Kinds of missing import. Note, the values of these enumerators correspond
9878 /// to %select values in diagnostics.
9886
9887 /// Diagnose that the specified declaration needs to be visible but
9888 /// isn't, and suggest a module import that would resolve the problem.
9890 MissingImportKind MIK, bool Recover = true);
9892 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9893 MissingImportKind MIK, bool Recover);
9894
9895 /// Called on #pragma clang __debug dump II
9897
9898 /// Called on #pragma clang __debug dump E
9899 void ActOnPragmaDump(Expr *E);
9900
9901private:
9902 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9903 //
9904 // The boolean value will be true to indicate that the namespace was loaded
9905 // from an AST/PCH file, or false otherwise.
9906 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9907
9908 /// Whether we have already loaded known namespaces from an extenal
9909 /// source.
9910 bool LoadedExternalKnownNamespaces;
9911
9912 bool CppLookupName(LookupResult &R, Scope *S);
9913
9914 /// Determine if we could use all the declarations in the module.
9915 bool isUsableModule(const Module *M);
9916
9917 /// Helper for CorrectTypo used to create and populate a new
9918 /// TypoCorrectionConsumer. Returns nullptr if typo correction should be
9919 /// skipped entirely.
9920 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9921 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9923 DeclContext *MemberContext, bool EnteringContext,
9924 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9925
9926 /// Cache for module units which is usable for current module.
9927 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9928
9929 /// Record the typo correction failure and return an empty correction.
9930 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9931 bool RecordFailure = true) {
9932 if (RecordFailure)
9933 TypoCorrectionFailures[Typo].insert(TypoLoc);
9934 return TypoCorrection();
9935 }
9936
9937 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9938
9939 /// Determine whether two declarations should be linked together, given that
9940 /// the old declaration might not be visible and the new declaration might
9941 /// not have external linkage.
9942 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9943 const NamedDecl *New) {
9944 if (isVisible(Old))
9945 return true;
9946 // See comment in below overload for why it's safe to compute the linkage
9947 // of the new declaration here.
9948 if (New->isExternallyDeclarable()) {
9949 assert(Old->isExternallyDeclarable() &&
9950 "should not have found a non-externally-declarable previous decl");
9951 return true;
9952 }
9953 return false;
9954 }
9955 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9956
9957 ///@}
9958
9959 //
9960 //
9961 // -------------------------------------------------------------------------
9962 //
9963 //
9964
9965 /// \name Modules
9966 /// Implementations are in SemaModule.cpp
9967 ///@{
9968
9969public:
9970 /// Get the module unit whose scope we are currently within.
9972 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9973 }
9974
9975 /// Is the module scope we are an implementation unit?
9977 if (ModuleScopes.empty())
9978 return false;
9979 const Module *M = ModuleScopes.back().Module;
9981 }
9982
9983 // When loading a non-modular PCH files, this is used to restore module
9984 // visibility.
9986 VisibleModules.setVisible(Mod, ImportLoc);
9987 }
9988
9989 enum class ModuleDeclKind {
9990 Interface, ///< 'export module X;'
9991 Implementation, ///< 'module X;'
9992 PartitionInterface, ///< 'export module X:Y;'
9993 PartitionImplementation, ///< 'module X:Y;'
9994 };
9995
9996 /// An enumeration to represent the transition of states in parsing module
9997 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9998 /// an error in state transition, the state is set to NotACXX20Module.
10000 FirstDecl, ///< Parsing the first decl in a TU.
10001 GlobalFragment, ///< after 'module;' but before 'module X;'
10002 ImportAllowed, ///< after 'module X;' but before any non-import decl.
10003 ImportFinished, ///< after any non-import decl.
10004 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
10005 ///< non-import decl.
10006 PrivateFragmentImportFinished, ///< after 'module :private;' but a
10007 ///< non-import decl has already been seen.
10008 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
10009 };
10010
10011 /// The parser has processed a module-declaration that begins the definition
10012 /// of a module interface or implementation.
10014 SourceLocation ModuleLoc, ModuleDeclKind MDK,
10015 ModuleIdPath Path, ModuleIdPath Partition,
10016 ModuleImportState &ImportState,
10017 bool SeenNoTrivialPPDirective);
10018
10019 /// The parser has processed a global-module-fragment declaration that begins
10020 /// the definition of the global module fragment of the current module unit.
10021 /// \param ModuleLoc The location of the 'module' keyword.
10023
10024 /// The parser has processed a private-module-fragment declaration that begins
10025 /// the definition of the private module fragment of the current module unit.
10026 /// \param ModuleLoc The location of the 'module' keyword.
10027 /// \param PrivateLoc The location of the 'private' keyword.
10029 SourceLocation PrivateLoc);
10030
10031 /// The parser has processed a module import declaration.
10032 ///
10033 /// \param StartLoc The location of the first token in the declaration. This
10034 /// could be the location of an '@', 'export', or 'import'.
10035 /// \param ExportLoc The location of the 'export' keyword, if any.
10036 /// \param ImportLoc The location of the 'import' keyword.
10037 /// \param Path The module toplevel name as an access path.
10038 /// \param IsPartition If the name is for a partition.
10040 SourceLocation ExportLoc,
10041 SourceLocation ImportLoc, ModuleIdPath Path,
10042 bool IsPartition = false);
10044 SourceLocation ExportLoc,
10045 SourceLocation ImportLoc, Module *M,
10046 ModuleIdPath Path = {});
10047
10048 /// The parser has processed a module import translated from a
10049 /// #include or similar preprocessing directive.
10050 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
10051 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
10052
10053 /// The parsed has entered a submodule.
10054 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
10055 /// The parser has left a submodule.
10056 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
10057
10058 /// Create an implicit import of the given module at the given
10059 /// source location, for error recovery, if possible.
10060 ///
10061 /// This routine is typically used when an entity found by name lookup
10062 /// is actually hidden within a module that we know about but the user
10063 /// has forgotten to import.
10064 void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
10065 Module *Mod);
10066
10067 /// We have parsed the start of an export declaration, including the '{'
10068 /// (if present).
10069 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
10070 SourceLocation LBraceLoc);
10071
10072 /// Complete the definition of an export declaration.
10073 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
10074 SourceLocation RBraceLoc);
10075
10076private:
10077 /// The parser has begun a translation unit to be compiled as a C++20
10078 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
10079 void HandleStartOfHeaderUnit();
10080
10081 struct ModuleScope {
10082 SourceLocation BeginLoc;
10083 clang::Module *Module = nullptr;
10084 VisibleModuleSet OuterVisibleModules;
10085 };
10086 /// The modules we're currently parsing.
10087 llvm::SmallVector<ModuleScope, 16> ModuleScopes;
10088
10089 /// For an interface unit, this is the implicitly imported interface unit.
10090 clang::Module *ThePrimaryInterface = nullptr;
10091
10092 /// The explicit global module fragment of the current translation unit.
10093 /// The explicit Global Module Fragment, as specified in C++
10094 /// [module.global.frag].
10095 clang::Module *TheGlobalModuleFragment = nullptr;
10096
10097 /// The implicit global module fragments of the current translation unit.
10098 ///
10099 /// The contents in the implicit global module fragment can't be discarded.
10100 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
10101
10102 /// Namespace definitions that we will export when they finish.
10103 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
10104
10105 /// In a C++ standard module, inline declarations require a definition to be
10106 /// present at the end of a definition domain. This set holds the decls to
10107 /// be checked at the end of the TU.
10108 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
10109
10110 /// Helper function to judge if we are in module purview.
10111 /// Return false if we are not in a module.
10112 bool isCurrentModulePurview() const;
10113
10114 /// Enter the scope of the explicit global module fragment.
10115 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
10116 /// Leave the scope of the explicit global module fragment.
10117 void PopGlobalModuleFragment();
10118
10119 /// Enter the scope of an implicit global module fragment.
10120 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
10121 /// Leave the scope of an implicit global module fragment.
10122 void PopImplicitGlobalModuleFragment();
10123
10124 VisibleModuleSet VisibleModules;
10125
10126 /// Whether we had imported any named modules.
10127 bool HadImportedNamedModules = false;
10128 /// The set of instantiations we need to check if they references TU-local
10129 /// entity from TUs. This only makes sense if we imported any named modules.
10130 llvm::SmallVector<std::pair<FunctionDecl *, SourceLocation>>
10131 PendingCheckReferenceForTULocal;
10132 /// Implement [basic.link]p18, which requires that we can't use TU-local
10133 /// entities from other TUs (ignoring header units).
10134 void checkReferenceToTULocalFromOtherTU(FunctionDecl *FD,
10135 SourceLocation PointOfInstantiation);
10136 /// Implement [basic.link]p17, which diagnose for non TU local exposure in
10137 /// module interface or module partition.
10138 void checkExposure(const TranslationUnitDecl *TU);
10139
10140 ///@}
10141
10142 //
10143 //
10144 // -------------------------------------------------------------------------
10145 //
10146 //
10147
10148 /// \name C++ Overloading
10149 /// Implementations are in SemaOverload.cpp
10150 ///@{
10151
10152public:
10153 /// Whether deferrable diagnostics should be deferred.
10154 bool DeferDiags = false;
10155
10156 /// RAII class to control scope of DeferDiags.
10158 Sema &S;
10159 bool SavedDeferDiags = false;
10160
10161 public:
10163 : S(S), SavedDeferDiags(S.DeferDiags) {
10164 S.DeferDiags = SavedDeferDiags || DeferDiags;
10165 }
10166 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
10169 };
10170
10171 /// Flag indicating if Sema is building a recovery call expression.
10172 ///
10173 /// This flag is used to avoid building recovery call expressions
10174 /// if Sema is already doing so, which would cause infinite recursions.
10176
10177 /// Determine whether the given New declaration is an overload of the
10178 /// declarations in Old. This routine returns OverloadKind::Match or
10179 /// OverloadKind::NonFunction if New and Old cannot be overloaded, e.g., if
10180 /// New has the same signature as some function in Old (C++ 1.3.10) or if the
10181 /// Old declarations aren't functions (or function templates) at all. When it
10182 /// does return OverloadKind::Match or OverloadKind::NonFunction, MatchedDecl
10183 /// will point to the decl that New cannot be overloaded with. This decl may
10184 /// be a UsingShadowDecl on top of the underlying declaration.
10185 ///
10186 /// Example: Given the following input:
10187 ///
10188 /// void f(int, float); // #1
10189 /// void f(int, int); // #2
10190 /// int f(int, int); // #3
10191 ///
10192 /// When we process #1, there is no previous declaration of "f", so IsOverload
10193 /// will not be used.
10194 ///
10195 /// When we process #2, Old contains only the FunctionDecl for #1. By
10196 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
10197 /// they have different signatures), so this routine returns
10198 /// OverloadKind::Overload; MatchedDecl is unchanged.
10199 ///
10200 /// When we process #3, Old is an overload set containing #1 and #2. We
10201 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
10202 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
10203 /// types of functions are not part of the signature), IsOverload returns
10204 /// OverloadKind::Match and MatchedDecl will be set to point to the
10205 /// FunctionDecl for #2.
10206 ///
10207 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
10208 /// class by a using declaration. The rules for whether to hide shadow
10209 /// declarations ignore some properties which otherwise figure into a function
10210 /// template's signature.
10212 const LookupResult &OldDecls, NamedDecl *&OldDecl,
10213 bool UseMemberUsingDeclRules);
10215 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10216
10217 // Checks whether MD constitutes an override the base class method BaseMD.
10218 // When checking for overrides, the object object members are ignored.
10219 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
10220 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10221
10222 enum class AllowedExplicit {
10223 /// Allow no explicit functions to be used.
10225 /// Allow explicit conversion functions but not explicit constructors.
10227 /// Allow both explicit conversion functions and explicit constructors.
10229 };
10230
10232 Expr *From, QualType ToType, bool SuppressUserConversions,
10233 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
10234 bool AllowObjCWritebackConversion);
10235
10236 /// PerformImplicitConversion - Perform an implicit conversion of the
10237 /// expression From to the type ToType. Returns the
10238 /// converted expression. Flavor is the kind of conversion we're
10239 /// performing, used in the error message. If @p AllowExplicit,
10240 /// explicit user-defined conversions are permitted.
10242 AssignmentAction Action,
10243 bool AllowExplicit = false);
10244
10245 /// IsIntegralPromotion - Determines whether the conversion from the
10246 /// expression From (whose potentially-adjusted type is FromType) to
10247 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
10248 /// sets PromotedType to the promoted type.
10249 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
10250
10251 /// IsFloatingPointPromotion - Determines whether the conversion from
10252 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
10253 /// returns true and sets PromotedType to the promoted type.
10254 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
10255
10256 /// Determine if a conversion is a complex promotion.
10257 ///
10258 /// A complex promotion is defined as a complex -> complex conversion
10259 /// where the conversion between the underlying real types is a
10260 /// floating-point or integral promotion.
10261 bool IsComplexPromotion(QualType FromType, QualType ToType);
10262
10263 /// IsOverflowBehaviorTypePromotion - Determines whether the conversion from
10264 /// FromType to ToType involves an OverflowBehaviorType FromType being
10265 /// promoted to an OverflowBehaviorType ToType which has a larger bitwidth.
10266 /// If so, returns true and sets FromType to ToType.
10267 bool IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType);
10268
10269 /// IsOverflowBehaviorTypeConversion - Determines whether the conversion from
10270 /// FromType to ToType necessarily involves both an OverflowBehaviorType and
10271 /// a non-OverflowBehaviorType. If so, returns true and sets FromType to
10272 /// ToType.
10273 bool IsOverflowBehaviorTypeConversion(QualType FromType, QualType ToType);
10274
10275 /// IsPointerConversion - Determines whether the conversion of the
10276 /// expression From, which has the (possibly adjusted) type FromType,
10277 /// can be converted to the type ToType via a pointer conversion (C++
10278 /// 4.10). If so, returns true and places the converted type (that
10279 /// might differ from ToType in its cv-qualifiers at some level) into
10280 /// ConvertedType.
10281 ///
10282 /// This routine also supports conversions to and from block pointers
10283 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
10284 /// pointers to interfaces. FIXME: Once we've determined the
10285 /// appropriate overloading rules for Objective-C, we may want to
10286 /// split the Objective-C checks into a different routine; however,
10287 /// GCC seems to consider all of these conversions to be pointer
10288 /// conversions, so for now they live here. IncompatibleObjC will be
10289 /// set if the conversion is an allowed Objective-C conversion that
10290 /// should result in a warning.
10291 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
10292 bool InOverloadResolution, QualType &ConvertedType,
10293 bool &IncompatibleObjC);
10294
10295 /// isObjCPointerConversion - Determines whether this is an
10296 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
10297 /// with the same arguments and return values.
10298 bool isObjCPointerConversion(QualType FromType, QualType ToType,
10299 QualType &ConvertedType, bool &IncompatibleObjC);
10300 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
10301 QualType &ConvertedType);
10302
10303 /// FunctionParamTypesAreEqual - This routine checks two function proto types
10304 /// for equality of their parameter types. Caller has already checked that
10305 /// they have same number of parameters. If the parameters are different,
10306 /// ArgPos will have the parameter index of the first different parameter.
10307 /// If `Reversed` is true, the parameters of `NewType` will be compared in
10308 /// reverse order. That's useful if one of the functions is being used as a
10309 /// C++20 synthesized operator overload with a reversed parameter order.
10312 unsigned *ArgPos = nullptr,
10313 bool Reversed = false);
10314
10316 const FunctionProtoType *NewType,
10317 unsigned *ArgPos = nullptr,
10318 bool Reversed = false);
10319
10320 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
10321 const FunctionDecl *NewFunction,
10322 unsigned *ArgPos = nullptr,
10323 bool Reversed = false);
10324
10325 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
10326 /// function types. Catches different number of parameter, mismatch in
10327 /// parameter types, and different return types.
10329 QualType ToType);
10330
10331 /// CheckPointerConversion - Check the pointer conversion from the
10332 /// expression From to the type ToType. This routine checks for
10333 /// ambiguous or inaccessible derived-to-base pointer
10334 /// conversions for which IsPointerConversion has already returned
10335 /// true. It returns true and produces a diagnostic if there was an
10336 /// error, or returns false otherwise.
10337 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
10338 CXXCastPath &BasePath, bool IgnoreBaseAccess,
10339 bool Diagnose = true);
10340
10341 /// IsMemberPointerConversion - Determines whether the conversion of the
10342 /// expression From, which has the (possibly adjusted) type FromType, can be
10343 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
10344 /// If so, returns true and places the converted type (that might differ from
10345 /// ToType in its cv-qualifiers at some level) into ConvertedType.
10346 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
10347 bool InOverloadResolution,
10348 QualType &ConvertedType);
10349
10359 /// CheckMemberPointerConversion - Check the member pointer conversion from
10360 /// the expression From to the type ToType. This routine checks for ambiguous
10361 /// or virtual or inaccessible base-to-derived member pointer conversions for
10362 /// which IsMemberPointerConversion has already returned true. It produces a
10363 // diagnostic if there was an error.
10365 QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind,
10366 CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange,
10367 bool IgnoreBaseAccess, MemberPointerConversionDirection Direction);
10368
10369 /// IsQualificationConversion - Determines whether the conversion from
10370 /// an rvalue of type FromType to ToType is a qualification conversion
10371 /// (C++ 4.4).
10372 ///
10373 /// \param ObjCLifetimeConversion Output parameter that will be set to
10374 /// indicate when the qualification conversion involves a change in the
10375 /// Objective-C object lifetime.
10376 bool IsQualificationConversion(QualType FromType, QualType ToType,
10377 bool CStyle, bool &ObjCLifetimeConversion);
10378
10379 /// Determine whether the conversion from FromType to ToType is a valid
10380 /// conversion of ExtInfo/ExtProtoInfo on the nested function type.
10381 /// More precisely, this method checks whether FromType can be transformed
10382 /// into an exact match for ToType, by transforming its extended function
10383 /// type information in legal manner (e.g. by strictly stripping "noreturn"
10384 /// or "noexcept", or by stripping "noescape" for arguments).
10385 bool IsFunctionConversion(QualType FromType, QualType ToType) const;
10386
10387 /// Same as `IsFunctionConversion`, but if this would return true, it sets
10388 /// `ResultTy` to `ToType`.
10389 bool TryFunctionConversion(QualType FromType, QualType ToType,
10390 QualType &ResultTy) const;
10391
10394 DeclarationName Name,
10395 OverloadCandidateSet &CandidateSet,
10396 FunctionDecl *Fn, MultiExprArg Args,
10397 bool IsMember = false);
10398
10400 FunctionDecl *Fun);
10402 Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl,
10404
10405 /// PerformContextuallyConvertToBool - Perform a contextual conversion
10406 /// of the expression From to bool (C++0x [conv]p3).
10408
10409 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
10410 /// conversion of the expression From to an Objective-C pointer type.
10411 /// Returns a valid but null ExprResult if no conversion sequence exists.
10413
10415 CCEKind CCE,
10416 NamedDecl *Dest = nullptr);
10417
10419 llvm::APSInt &Value, CCEKind CCE);
10421 APValue &Value, CCEKind CCE,
10422 NamedDecl *Dest = nullptr);
10423
10424 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10425 /// That is a converted constant expression
10426 /// (which was built with BuildConvertedConstantExpression)
10429 CCEKind CCE, bool RequireInt,
10430 const APValue &PreNarrowingValue);
10431
10432 /// Abstract base class used to perform a contextual implicit
10433 /// conversion from an expression to any type passing a filter.
10435 public:
10438
10442
10443 /// Determine whether the specified type is a valid destination type
10444 /// for this conversion.
10445 virtual bool match(QualType T) = 0;
10446
10447 /// Emits a diagnostic complaining that the expression does not have
10448 /// integral or enumeration type.
10450 QualType T) = 0;
10451
10452 /// Emits a diagnostic when the expression has incomplete class type.
10453 virtual SemaDiagnosticBuilder
10455
10456 /// Emits a diagnostic when the only matching conversion function
10457 /// is explicit.
10459 SourceLocation Loc,
10460 QualType T,
10461 QualType ConvTy) = 0;
10462
10463 /// Emits a note for the explicit conversion function.
10464 virtual SemaDiagnosticBuilder
10466
10467 /// Emits a diagnostic when there are multiple possible conversion
10468 /// functions.
10470 QualType T) = 0;
10471
10472 /// Emits a note for one of the candidate conversions.
10473 virtual SemaDiagnosticBuilder
10475
10476 /// Emits a diagnostic when we picked a conversion function
10477 /// (for cases when we are not allowed to pick a conversion function).
10479 SourceLocation Loc,
10480 QualType T,
10481 QualType ConvTy) = 0;
10482
10484 };
10485
10487 bool AllowScopedEnumerations;
10488
10489 public:
10490 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10491 bool SuppressConversion)
10493 AllowScopedEnumerations(AllowScopedEnumerations) {}
10494
10495 /// Match an integral or (possibly scoped) enumeration type.
10496 bool match(QualType T) override;
10497
10499 QualType T) override {
10500 return diagnoseNotInt(S, Loc, T);
10501 }
10502
10503 /// Emits a diagnostic complaining that the expression does not have
10504 /// integral or enumeration type.
10506 QualType T) = 0;
10507 };
10508
10509 /// Perform a contextual implicit conversion.
10512 ContextualImplicitConverter &Converter);
10513
10514 /// ReferenceCompareResult - Expresses the result of comparing two
10515 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10516 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10518 /// Ref_Incompatible - The two types are incompatible, so direct
10519 /// reference binding is not possible.
10521 /// Ref_Related - The two types are reference-related, which means
10522 /// that their unqualified forms (T1 and T2) are either the same
10523 /// or T1 is a base class of T2.
10525 /// Ref_Compatible - The two types are reference-compatible.
10527 };
10528
10529 // Fake up a scoped enumeration that still contextually converts to bool.
10531 /// The conversions that would be performed on an lvalue of type T2 when
10532 /// binding a reference of type T1 to it, as determined when evaluating
10533 /// whether T1 is reference-compatible with T2.
10539 ObjC = 0x10,
10541
10542 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
10543 };
10544 };
10546
10547 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10548 /// determine whether they are reference-compatible,
10549 /// reference-related, or incompatible, for use in C++ initialization by
10550 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10551 /// type, and the first type (T1) is the pointee type of the reference
10552 /// type being initialized.
10555 ReferenceConversions *Conv = nullptr);
10556
10557 /// AddOverloadCandidate - Adds the given function to the set of
10558 /// candidate functions, using the given function call arguments. If
10559 /// @p SuppressUserConversions, then don't allow user-defined
10560 /// conversions via constructors or conversion operators.
10561 ///
10562 /// \param PartialOverloading true if we are performing "partial" overloading
10563 /// based on an incomplete set of function arguments. This feature is used by
10564 /// code completion.
10567 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10568 bool PartialOverloading = false, bool AllowExplicit = true,
10569 bool AllowExplicitConversion = false,
10570 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10571 ConversionSequenceList EarlyConversions = {},
10573 bool AggregateCandidateDeduction = false, bool StrictPackMatch = false);
10574
10575 /// Add all of the function declarations in the given function set to
10576 /// the overload candidate set.
10578 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10579 OverloadCandidateSet &CandidateSet,
10580 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10581 bool SuppressUserConversions = false, bool PartialOverloading = false,
10582 bool FirstArgumentIsBase = false);
10583
10584 /// AddMethodCandidate - Adds a named decl (which is some kind of
10585 /// method) as a method candidate to the given overload set.
10586 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10587 Expr::Classification ObjectClassification,
10588 ArrayRef<Expr *> Args,
10589 OverloadCandidateSet &CandidateSet,
10590 bool SuppressUserConversion = false,
10591 OverloadCandidateParamOrder PO = {});
10592
10593 /// AddMethodCandidate - Adds the given C++ member function to the set
10594 /// of candidate functions, using the given function call arguments
10595 /// and the object argument (@c Object). For example, in a call
10596 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10597 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10598 /// allow user-defined conversions via constructors or conversion
10599 /// operators.
10600 void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10601 CXXRecordDecl *ActingContext, QualType ObjectType,
10602 Expr::Classification ObjectClassification,
10603 ArrayRef<Expr *> Args,
10604 OverloadCandidateSet &CandidateSet,
10605 bool SuppressUserConversions = false,
10606 bool PartialOverloading = false,
10607 ConversionSequenceList EarlyConversions = {},
10609 bool StrictPackMatch = false);
10610
10611 /// Add a C++ member function template as a candidate to the candidate
10612 /// set, using template argument deduction to produce an appropriate member
10613 /// function template specialization.
10615 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10616 CXXRecordDecl *ActingContext,
10617 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10618 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10619 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10620 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10621
10622 /// Add a C++ function template specialization as a candidate
10623 /// in the candidate set, using template argument deduction to produce
10624 /// an appropriate function template specialization.
10626 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10627 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10628 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10629 bool PartialOverloading = false, bool AllowExplicit = true,
10630 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10632 bool AggregateCandidateDeduction = false);
10633
10635 /// Do not consider any user-defined conversions when constructing the
10636 /// initializing sequence.
10638
10639 /// Before constructing the initializing sequence, we check whether the
10640 /// parameter type and argument type contain any user defined conversions.
10641 /// If so, do not initialize them. This effectively bypasses some undesired
10642 /// instantiation before checking constaints, which might otherwise result
10643 /// in non-SFINAE errors e.g. recursive constraints.
10645
10652 };
10653
10654 /// Check that implicit conversion sequences can be formed for each argument
10655 /// whose corresponding parameter has a non-dependent type, per DR1391's
10656 /// [temp.deduct.call]p10.
10659 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10661 CheckNonDependentConversionsFlag UserConversionFlag,
10662 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10663 Expr::Classification ObjectClassification = {},
10664 OverloadCandidateParamOrder PO = {});
10665
10666 /// AddConversionCandidate - Add a C++ conversion function as a
10667 /// candidate in the candidate set (C++ [over.match.conv],
10668 /// C++ [over.match.copy]). From is the expression we're converting from,
10669 /// and ToType is the type that we're eventually trying to convert to
10670 /// (which may or may not be the same type as the type that the
10671 /// conversion function produces).
10673 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10674 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10675 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10676 bool AllowExplicit, bool AllowResultConversion = true,
10677 bool StrictPackMatch = false);
10678
10679 /// Adds a conversion function template specialization
10680 /// candidate to the overload set, using template argument deduction
10681 /// to deduce the template arguments of the conversion function
10682 /// template from the type that we are converting to (C++
10683 /// [temp.deduct.conv]).
10685 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10686 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10687 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10688 bool AllowExplicit, bool AllowResultConversion = true);
10689
10690 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10691 /// converts the given @c Object to a function pointer via the
10692 /// conversion function @c Conversion, and then attempts to call it
10693 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10694 /// the type of function that we'll eventually be calling.
10695 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10696 DeclAccessPair FoundDecl,
10697 CXXRecordDecl *ActingContext,
10698 const FunctionProtoType *Proto, Expr *Object,
10699 ArrayRef<Expr *> Args,
10700 OverloadCandidateSet &CandidateSet);
10701
10702 /// Add all of the non-member operator function declarations in the given
10703 /// function set to the overload candidate set.
10705 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10706 OverloadCandidateSet &CandidateSet,
10707 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10708
10709 /// Add overload candidates for overloaded operators that are
10710 /// member functions.
10711 ///
10712 /// Add the overloaded operator candidates that are member functions
10713 /// for the operator Op that was used in an operator expression such
10714 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10715 /// CandidateSet will store the added overload candidates. (C++
10716 /// [over.match.oper]).
10718 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10719 OverloadCandidateSet &CandidateSet,
10721
10722 /// AddBuiltinCandidate - Add a candidate for a built-in
10723 /// operator. ResultTy and ParamTys are the result and parameter types
10724 /// of the built-in candidate, respectively. Args and NumArgs are the
10725 /// arguments being passed to the candidate. IsAssignmentOperator
10726 /// should be true when this built-in candidate is an assignment
10727 /// operator. NumContextualBoolArguments is the number of arguments
10728 /// (at the beginning of the argument list) that will be contextually
10729 /// converted to bool.
10730 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10731 OverloadCandidateSet &CandidateSet,
10732 bool IsAssignmentOperator = false,
10733 unsigned NumContextualBoolArguments = 0);
10734
10735 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10736 /// operator overloads to the candidate set (C++ [over.built]), based
10737 /// on the operator @p Op and the arguments given. For example, if the
10738 /// operator is a binary '+', this routine might add "int
10739 /// operator+(int, int)" to cover integer addition.
10741 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10742 OverloadCandidateSet &CandidateSet);
10743
10744 /// Add function candidates found via argument-dependent lookup
10745 /// to the set of overloading candidates.
10746 ///
10747 /// This routine performs argument-dependent name lookup based on the
10748 /// given function name (which may also be an operator name) and adds
10749 /// all of the overload candidates found by ADL to the overload
10750 /// candidate set (C++ [basic.lookup.argdep]).
10752 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10753 TemplateArgumentListInfo *ExplicitTemplateArgs,
10754 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10755
10756 /// Check the enable_if expressions on the given function. Returns the first
10757 /// failing attribute, or NULL if they were all successful.
10758 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10759 ArrayRef<Expr *> Args,
10760 bool MissingImplicitThis = false);
10761
10762 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10763 /// non-ArgDependent DiagnoseIfAttrs.
10764 ///
10765 /// Argument-dependent diagnose_if attributes should be checked each time a
10766 /// function is used as a direct callee of a function call.
10767 ///
10768 /// Returns true if any errors were emitted.
10769 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10770 const Expr *ThisArg,
10771 ArrayRef<const Expr *> Args,
10772 SourceLocation Loc);
10773
10774 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10775 /// ArgDependent DiagnoseIfAttrs.
10776 ///
10777 /// Argument-independent diagnose_if attributes should be checked on every use
10778 /// of a function.
10779 ///
10780 /// Returns true if any errors were emitted.
10781 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10782 SourceLocation Loc);
10783
10784 /// Determine if \p A and \p B are equivalent internal linkage declarations
10785 /// from different modules, and thus an ambiguity error can be downgraded to
10786 /// an extension warning.
10787 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10788 const NamedDecl *B);
10790 SourceLocation Loc, const NamedDecl *D,
10791 ArrayRef<const NamedDecl *> Equiv);
10792
10793 // Emit as a 'note' the specific overload candidate
10795 const NamedDecl *Found, const FunctionDecl *Fn,
10797 QualType DestType = QualType(), bool TakingAddress = false);
10798
10799 // Emit as a series of 'note's all template and non-templates identified by
10800 // the expression Expr
10801 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10802 bool TakingAddress = false);
10803
10804 /// Returns whether the given function's address can be taken or not,
10805 /// optionally emitting a diagnostic if the address can't be taken.
10806 ///
10807 /// Returns false if taking the address of the function is illegal.
10808 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10809 bool Complain = false,
10810 SourceLocation Loc = SourceLocation());
10811
10812 // [PossiblyAFunctionType] --> [Return]
10813 // NonFunctionType --> NonFunctionType
10814 // R (A) --> R(A)
10815 // R (*)(A) --> R (A)
10816 // R (&)(A) --> R (A)
10817 // R (S::*)(A) --> R (A)
10818 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10819
10820 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10821 /// an overloaded function (C++ [over.over]), where @p From is an
10822 /// expression with overloaded function type and @p ToType is the type
10823 /// we're trying to resolve to. For example:
10824 ///
10825 /// @code
10826 /// int f(double);
10827 /// int f(int);
10828 ///
10829 /// int (*pfd)(double) = f; // selects f(double)
10830 /// @endcode
10831 ///
10832 /// This routine returns the resulting FunctionDecl if it could be
10833 /// resolved, and NULL otherwise. When @p Complain is true, this
10834 /// routine will emit diagnostics if there is an error.
10835 FunctionDecl *
10836 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10837 bool Complain, DeclAccessPair &Found,
10838 bool *pHadMultipleCandidates = nullptr);
10839
10840 /// Given an expression that refers to an overloaded function, try to
10841 /// resolve that function to a single function that can have its address
10842 /// taken. This will modify `Pair` iff it returns non-null.
10843 ///
10844 /// This routine can only succeed if from all of the candidates in the
10845 /// overload set for SrcExpr that can have their addresses taken, there is one
10846 /// candidate that is more constrained than the rest.
10847 FunctionDecl *
10848 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10849
10850 /// Given an overloaded function, tries to turn it into a non-overloaded
10851 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10852 /// will perform access checks, diagnose the use of the resultant decl, and,
10853 /// if requested, potentially perform a function-to-pointer decay.
10854 ///
10855 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10856 /// Otherwise, returns true. This may emit diagnostics and return true.
10858 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10859
10860 /// Given an expression that refers to an overloaded function, try to
10861 /// resolve that overloaded function expression down to a single function.
10862 ///
10863 /// This routine can only resolve template-ids that refer to a single function
10864 /// template, where that template-id refers to a single template whose
10865 /// template arguments are either provided by the template-id or have
10866 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10867 ///
10868 /// If no template-ids are found, no diagnostics are emitted and NULL is
10869 /// returned.
10871 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10872 TemplateSpecCandidateSet *FailedTSC = nullptr,
10873 bool ForTypeDeduction = false);
10874
10875 // Resolve and fix an overloaded expression that can be resolved
10876 // because it identifies a single function template specialization.
10877 //
10878 // Last three arguments should only be supplied if Complain = true
10879 //
10880 // Return true if it was logically possible to so resolve the
10881 // expression, regardless of whether or not it succeeded. Always
10882 // returns true if 'complain' is set.
10884 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10885 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10886 QualType DestTypeForComplaining = QualType(),
10887 unsigned DiagIDForComplaining = 0);
10888
10889 /// Add the overload candidates named by callee and/or found by argument
10890 /// dependent lookup to the given overload set.
10891 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10892 ArrayRef<Expr *> Args,
10893 OverloadCandidateSet &CandidateSet,
10894 bool PartialOverloading = false);
10895
10896 /// Add the call candidates from the given set of lookup results to the given
10897 /// overload set. Non-function lookup results are ignored.
10899 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10900 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10901
10902 // An enum used to represent the different possible results of building a
10903 // range-based for loop.
10909
10910 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10911 /// given LookupResult is non-empty, it is assumed to describe a member which
10912 /// will be invoked. Otherwise, the function will be found via argument
10913 /// dependent lookup.
10914 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10915 /// otherwise CallExpr is set to ExprError() and some non-success value
10916 /// is returned.
10918 SourceLocation RangeLoc,
10919 const DeclarationNameInfo &NameInfo,
10920 LookupResult &MemberLookup,
10921 OverloadCandidateSet *CandidateSet,
10922 Expr *Range, ExprResult *CallExpr);
10923
10924 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10925 /// (which eventually refers to the declaration Func) and the call
10926 /// arguments Args/NumArgs, attempt to resolve the function call down
10927 /// to a specific function. If overload resolution succeeds, returns
10928 /// the call expression produced by overload resolution.
10929 /// Otherwise, emits diagnostics and returns ExprError.
10931 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10932 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10933 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10934
10935 /// Constructs and populates an OverloadedCandidateSet from
10936 /// the given function.
10937 /// \returns true when an the ExprResult output parameter has been set.
10939 MultiExprArg Args, SourceLocation RParenLoc,
10940 OverloadCandidateSet *CandidateSet,
10942
10946 const UnresolvedSetImpl &Fns,
10947 bool PerformADL = true);
10948
10949 /// Perform lookup for an overloaded unary operator.
10952 const UnresolvedSetImpl &Fns,
10953 ArrayRef<Expr *> Args, bool RequiresADL = true);
10954
10955 /// Create a unary operation that may resolve to an overloaded
10956 /// operator.
10957 ///
10958 /// \param OpLoc The location of the operator itself (e.g., '*').
10959 ///
10960 /// \param Opc The UnaryOperatorKind that describes this operator.
10961 ///
10962 /// \param Fns The set of non-member functions that will be
10963 /// considered by overload resolution. The caller needs to build this
10964 /// set based on the context using, e.g.,
10965 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10966 /// set should not contain any member functions; those will be added
10967 /// by CreateOverloadedUnaryOp().
10968 ///
10969 /// \param Input The input argument.
10972 const UnresolvedSetImpl &Fns, Expr *input,
10973 bool RequiresADL = true);
10974
10975 /// Perform lookup for an overloaded binary operator.
10978 const UnresolvedSetImpl &Fns,
10979 ArrayRef<Expr *> Args, bool RequiresADL = true);
10980
10981 /// Create a binary operation that may resolve to an overloaded
10982 /// operator.
10983 ///
10984 /// \param OpLoc The location of the operator itself (e.g., '+').
10985 ///
10986 /// \param Opc The BinaryOperatorKind that describes this operator.
10987 ///
10988 /// \param Fns The set of non-member functions that will be
10989 /// considered by overload resolution. The caller needs to build this
10990 /// set based on the context using, e.g.,
10991 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10992 /// set should not contain any member functions; those will be added
10993 /// by CreateOverloadedBinOp().
10994 ///
10995 /// \param LHS Left-hand argument.
10996 /// \param RHS Right-hand argument.
10997 /// \param PerformADL Whether to consider operator candidates found by ADL.
10998 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10999 /// C++20 operator rewrites.
11000 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
11001 /// the function in question. Such a function is never a candidate in
11002 /// our overload resolution. This also enables synthesizing a three-way
11003 /// comparison from < and == as described in C++20 [class.spaceship]p1.
11005 const UnresolvedSetImpl &Fns, Expr *LHS,
11006 Expr *RHS, bool RequiresADL = true,
11007 bool AllowRewrittenCandidates = true,
11008 FunctionDecl *DefaultedFn = nullptr);
11010 const UnresolvedSetImpl &Fns,
11011 Expr *LHS, Expr *RHS,
11012 FunctionDecl *DefaultedFn);
11013
11015 SourceLocation RLoc, Expr *Base,
11016 MultiExprArg Args);
11017
11018 /// BuildCallToMemberFunction - Build a call to a member
11019 /// function. MemExpr is the expression that refers to the member
11020 /// function (and includes the object parameter), Args/NumArgs are the
11021 /// arguments to the function call (not including the object
11022 /// parameter). The caller needs to validate that the member
11023 /// expression refers to a non-static member function or an overloaded
11024 /// member function.
11026 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
11027 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
11028 bool IsExecConfig = false, bool AllowRecovery = false);
11029
11030 /// BuildCallToObjectOfClassType - Build a call to an object of class
11031 /// type (C++ [over.call.object]), which can end up invoking an
11032 /// overloaded function call operator (@c operator()) or performing a
11033 /// user-defined conversion on the object argument.
11035 SourceLocation LParenLoc,
11036 MultiExprArg Args,
11037 SourceLocation RParenLoc);
11038
11039 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
11040 /// (if one exists), where @c Base is an expression of class type and
11041 /// @c Member is the name of the member we're trying to find.
11043 SourceLocation OpLoc,
11044 bool *NoArrowOperatorFound = nullptr);
11045
11048 bool HadMultipleCandidates);
11049
11050 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
11051 /// to a literal operator described by the provided lookup results.
11054 SourceLocation LitEndLoc,
11055 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
11056
11057 /// FixOverloadedFunctionReference - E is an expression that refers to
11058 /// a C++ overloaded function (possibly with some parentheses and
11059 /// perhaps a '&' around it). We have resolved the overloaded function
11060 /// to the function declaration Fn, so patch up the expression E to
11061 /// refer (possibly indirectly) to Fn. Returns the new expr.
11063 FunctionDecl *Fn);
11065 DeclAccessPair FoundDecl,
11066 FunctionDecl *Fn);
11067
11068 /// - Returns a selector which best matches given argument list or
11069 /// nullptr if none could be found
11071 bool IsInstance,
11073
11074 ///@}
11075
11076 //
11077 //
11078 // -------------------------------------------------------------------------
11079 //
11080 //
11081
11082 /// \name Statements
11083 /// Implementations are in SemaStmt.cpp
11084 ///@{
11085
11086public:
11087 /// Stack of active SEH __finally scopes. Can be empty.
11089
11090 /// Stack of '_Defer' statements that are currently being parsed, as well
11091 /// as the locations of their '_Defer' keywords. Can be empty.
11093
11094 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
11096
11098 bool HasLeadingEmptyMacro = false);
11099
11101 SourceLocation EndLoc);
11103
11104 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
11105 /// whose result is unused, warn.
11106 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
11107
11108 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
11112 ArrayRef<Stmt *> Elts, bool isStmtExpr);
11113
11115
11118 SourceLocation DotDotDotLoc, ExprResult RHS,
11119 SourceLocation ColonLoc);
11120
11121 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
11122 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
11123
11125 SourceLocation ColonLoc, Stmt *SubStmt,
11126 Scope *CurScope);
11128 SourceLocation ColonLoc, Stmt *SubStmt);
11129
11131 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
11133 Stmt *SubStmt);
11134
11135 /// Check whether the given statement can have musttail applied to it,
11136 /// issuing a diagnostic and returning false if not. In the success case,
11137 /// the statement is rewritten to remove implicit nodes from the return
11138 /// value.
11139 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
11140
11142 SourceLocation LParenLoc, Stmt *InitStmt,
11143 ConditionResult Cond, SourceLocation RParenLoc,
11144 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
11146 SourceLocation LParenLoc, Stmt *InitStmt,
11147 ConditionResult Cond, SourceLocation RParenLoc,
11148 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
11149
11151
11153 SourceLocation LParenLoc, Stmt *InitStmt,
11154 ConditionResult Cond,
11155 SourceLocation RParenLoc);
11157 Stmt *Body);
11158
11159 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
11160 /// integer not in the range of enum values.
11161 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
11162 Expr *SrcExpr);
11163
11165 ConditionResult Cond, SourceLocation RParenLoc,
11166 Stmt *Body);
11168 SourceLocation WhileLoc, SourceLocation CondLParen,
11169 Expr *Cond, SourceLocation CondRParen);
11170
11172 Stmt *First, ConditionResult Second,
11173 FullExprArg Third, SourceLocation RParenLoc,
11174 Stmt *Body);
11175
11176 /// In an Objective C collection iteration statement:
11177 /// for (x in y)
11178 /// x can be an arbitrary l-value expression. Bind it up as a
11179 /// full-expression.
11181
11183 /// Initial building of a for-range statement.
11185 /// Instantiation or recovery rebuild of a for-range statement. Don't
11186 /// attempt any typo-correction.
11188 /// Determining whether a for-range statement could be built. Avoid any
11189 /// unnecessary or irreversible actions.
11191 };
11192
11193 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
11194 ///
11195 /// C++11 [stmt.ranged]:
11196 /// A range-based for statement is equivalent to
11197 ///
11198 /// {
11199 /// auto && __range = range-init;
11200 /// for ( auto __begin = begin-expr,
11201 /// __end = end-expr;
11202 /// __begin != __end;
11203 /// ++__begin ) {
11204 /// for-range-declaration = *__begin;
11205 /// statement
11206 /// }
11207 /// }
11208 ///
11209 /// The body of the loop is not available yet, since it cannot be analysed
11210 /// until we have determined the type of the for-range-declaration.
11212 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
11213 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
11214 SourceLocation RParenLoc, BuildForRangeKind Kind,
11215 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11216
11217 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
11218 StmtResult BuildCXXForRangeStmt(
11219 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
11220 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
11221 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
11222 BuildForRangeKind Kind,
11223 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11224
11225 /// Set the type of a for-range declaration whose for-range or expansion
11226 /// initialiser is dependent.
11227 void ActOnDependentForRangeInitializer(VarDecl *LoopVar,
11228 BuildForRangeKind BFRK);
11229
11230 /// Holds the 'begin' and 'end' variables of a range-based for loop or
11231 /// expansion statement; begin-expr and end-expr are also provided; the
11232 /// latter are used in some diagnostics.
11234 VarDecl *BeginVar = nullptr;
11235 VarDecl *EndVar = nullptr;
11236 Expr *BeginExpr = nullptr;
11237 Expr *EndExpr = nullptr;
11238 bool isValid() const { return BeginVar != nullptr && EndVar != nullptr; }
11239 };
11240
11241 /// Determine begin-expr and end-expr and build variable declarations for
11242 /// them as per [stmt.ranged].
11243 ForRangeBeginEndInfo BuildCXXForRangeBeginEndVars(
11244 Scope *S, VarDecl *RangeVar, SourceLocation ColonLoc,
11245 SourceLocation CoawaitLoc,
11246 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps,
11247 BuildForRangeKind Kind, bool IsConstexpr,
11248 StmtResult *RebuildResult = nullptr,
11249 llvm::function_ref<StmtResult()> RebuildWithDereference = {},
11250 IdentifierInfo *BeginName = nullptr, IdentifierInfo *EndName = nullptr);
11251
11252 /// Helper used by the expansion statements and for-range code to build
11253 /// a variable declaration for e.g. 'begin' and 'end'.
11254 VarDecl *BuildForRangeVarDecl(SourceLocation Loc, QualType Type,
11255 IdentifierInfo *Name, bool IsConstexpr);
11256
11257 /// Build the range variable of a range-based for loop or iterating
11258 /// expansion statement and return its DeclStmt.
11259 StmtResult BuildCXXForRangeRangeVar(Scope *S, Expr *Range, QualType Type,
11260 bool IsConstexpr = false);
11261
11262 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
11263 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
11264 /// body cannot be performed until after the type of the range variable is
11265 /// determined.
11266 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
11267
11268 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
11269 LabelDecl *TheDecl);
11270 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
11271 SourceLocation StarLoc, Expr *DestExp);
11272 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope,
11273 LabelDecl *Label, SourceLocation LabelLoc);
11274 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope,
11275 LabelDecl *Label, SourceLocation LabelLoc);
11276
11277 void ActOnStartOfDeferStmt(SourceLocation DeferLoc, Scope *CurScope);
11278 void ActOnDeferStmtError(Scope *CurScope);
11279 StmtResult ActOnEndOfDeferStmt(Stmt *Body, Scope *CurScope);
11280
11283
11286
11287 bool isMoveEligible() const { return S != None; };
11289 };
11291
11292 /// Determine whether the given expression might be move-eligible or
11293 /// copy-elidable in either a (co_)return statement or throw expression,
11294 /// without considering function return type, if applicable.
11295 ///
11296 /// \param E The expression being returned from the function or block,
11297 /// being thrown, or being co_returned from a coroutine. This expression
11298 /// might be modified by the implementation.
11299 ///
11300 /// \param Mode Overrides detection of current language mode
11301 /// and uses the rules for C++23.
11302 ///
11303 /// \returns An aggregate which contains the Candidate and isMoveEligible
11304 /// and isCopyElidable methods. If Candidate is non-null, it means
11305 /// isMoveEligible() would be true under the most permissive language
11306 /// standard.
11307 NamedReturnInfo getNamedReturnInfo(
11309
11310 /// Determine whether the given NRVO candidate variable is move-eligible or
11311 /// copy-elidable, without considering function return type.
11312 ///
11313 /// \param VD The NRVO candidate variable.
11314 ///
11315 /// \returns An aggregate which contains the Candidate and isMoveEligible
11316 /// and isCopyElidable methods. If Candidate is non-null, it means
11317 /// isMoveEligible() would be true under the most permissive language
11318 /// standard.
11319 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
11320
11321 /// Updates given NamedReturnInfo's move-eligible and
11322 /// copy-elidable statuses, considering the function
11323 /// return type criteria as applicable to return statements.
11324 ///
11325 /// \param Info The NamedReturnInfo object to update.
11326 ///
11327 /// \param ReturnType This is the return type of the function.
11328 /// \returns The copy elision candidate, in case the initial return expression
11329 /// was copy elidable, or nullptr otherwise.
11330 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
11331 QualType ReturnType);
11332
11333 /// Perform the initialization of a potentially-movable value, which
11334 /// is the result of return value.
11335 ///
11336 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
11337 /// treat returned lvalues as rvalues in certain cases (to prefer move
11338 /// construction), then falls back to treating them as lvalues if that failed.
11341 const NamedReturnInfo &NRInfo, Expr *Value,
11342 bool SupressSimplerImplicitMoves = false);
11343
11345
11346 /// Deduce the return type for a function from a returned expression, per
11347 /// C++1y [dcl.spec.auto]p6.
11349 SourceLocation ReturnLoc, Expr *RetExpr,
11350 const AutoType *AT);
11351
11352 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11353 Scope *CurScope);
11354 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11355 bool AllowRecovery = false);
11356
11357 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
11358 /// for capturing scopes.
11360 NamedReturnInfo &NRInfo,
11361 bool SupressSimplerImplicitMoves);
11362
11363 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
11364 /// and creates a proper catch handler from them.
11366 Stmt *HandlerBlock);
11367
11368 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
11369 /// handlers and creates a try statement from them.
11371 ArrayRef<Stmt *> Handlers);
11372
11373 void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry);
11374
11375 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
11376 SourceLocation TryLoc, Stmt *TryBlock,
11377 Stmt *Handler);
11379 Stmt *Block);
11384
11386 bool IsIfExists,
11387 NestedNameSpecifierLoc QualifierLoc,
11388 DeclarationNameInfo NameInfo,
11389 Stmt *Nested);
11391 bool IsIfExists, CXXScopeSpec &SS,
11392 UnqualifiedId &Name, Stmt *Nested);
11393
11394 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11395 CapturedRegionKind Kind, unsigned NumParams);
11396 typedef std::pair<StringRef, QualType> CapturedParamNameType;
11397 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11398 CapturedRegionKind Kind,
11400 unsigned OpenMPCaptureLevel = 0);
11404 SourceLocation Loc,
11405 unsigned NumParams);
11406
11408 VarDecl *RangeVar, ArrayRef<MaterializeTemporaryExpr *> Temporaries);
11409
11410private:
11411 /// Check whether the given statement can have musttail applied to it,
11412 /// issuing a diagnostic and returning false if not.
11413 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
11414
11415 ///@}
11416
11417 //
11418 //
11419 // -------------------------------------------------------------------------
11420 //
11421 //
11422
11423 /// \name `inline asm` Statement
11424 /// Implementations are in SemaStmtAsm.cpp
11425 ///@{
11426
11427public:
11428 ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel);
11429 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
11430 bool IsVolatile, unsigned NumOutputs,
11431 unsigned NumInputs, IdentifierInfo **Names,
11432 MultiExprArg Constraints, MultiExprArg Exprs,
11433 Expr *AsmString, MultiExprArg Clobbers,
11434 unsigned NumLabels, SourceLocation RParenLoc);
11435
11437 llvm::InlineAsmIdentifierInfo &Info);
11439 SourceLocation TemplateKWLoc,
11440 UnqualifiedId &Id,
11441 bool IsUnevaluatedContext);
11442 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
11443 SourceLocation AsmLoc);
11445 SourceLocation AsmLoc);
11447 ArrayRef<Token> AsmToks, StringRef AsmString,
11448 unsigned NumOutputs, unsigned NumInputs,
11449 ArrayRef<StringRef> Constraints,
11450 ArrayRef<StringRef> Clobbers,
11451 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
11452 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
11453 SourceLocation Location, bool AlwaysCreate);
11454
11455 ///@}
11456
11457 //
11458 //
11459 // -------------------------------------------------------------------------
11460 //
11461 //
11462
11463 /// \name Statement Attribute Handling
11464 /// Implementations are in SemaStmtAttr.cpp
11465 ///@{
11466
11467public:
11468 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11469 const AttributeCommonInfo &A);
11470 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11471 const AttributeCommonInfo &A);
11472
11473 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11475
11476 /// Process the attributes before creating an attributed statement. Returns
11477 /// the semantic attributes that have been processed.
11478 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11480
11482 SourceRange Range);
11484 const IdentifierInfo *AttrName,
11485 SourceRange Range);
11486
11487 ///@}
11488
11489 //
11490 //
11491 // -------------------------------------------------------------------------
11492 //
11493 //
11494
11495 /// \name C++ Templates
11496 /// Implementations are in SemaTemplate.cpp
11497 ///@{
11498
11499public:
11500 // Saves the current floating-point pragma stack and clear it in this Sema.
11502 public:
11504 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11505 S.FpPragmaStack.Stack.clear();
11506 }
11507 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11510
11511 private:
11512 Sema &S;
11514 };
11515
11517 CurFPFeatures = FPO;
11518 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11519 }
11520
11526
11531
11532 typedef llvm::MapVector<const FunctionDecl *,
11533 std::unique_ptr<LateParsedTemplate>>
11536
11537 /// Determine the number of levels of enclosing template parameters. This is
11538 /// only usable while parsing. Note that this does not include dependent
11539 /// contexts in which no template parameters have yet been declared, such as
11540 /// in a terse function template or generic lambda before the first 'auto' is
11541 /// encountered.
11542 unsigned getTemplateDepth(Scope *S) const;
11543
11545 bool AllowFunctionTemplates = true,
11546 bool AllowDependent = true);
11548 bool AllowFunctionTemplates = true,
11549 bool AllowDependent = true,
11550 bool AllowNonTemplateFunctions = false);
11551 /// Try to interpret the lookup result D as a template-name.
11552 ///
11553 /// \param D A declaration found by name lookup.
11554 /// \param AllowFunctionTemplates Whether function templates should be
11555 /// considered valid results.
11556 /// \param AllowDependent Whether unresolved using declarations (that might
11557 /// name templates) should be considered valid results.
11559 bool AllowFunctionTemplates = true,
11560 bool AllowDependent = true);
11561
11563 /// Whether and why a template name is required in this lookup.
11565 public:
11566 /// Template name is required if TemplateKWLoc is valid.
11568 : TemplateKW(TemplateKWLoc) {}
11569 /// Template name is unconditionally required.
11571
11573 return TemplateKW.value_or(SourceLocation());
11574 }
11575 bool hasTemplateKeyword() const {
11576 return getTemplateKeywordLoc().isValid();
11577 }
11578 bool isRequired() const { return TemplateKW != SourceLocation(); }
11579 explicit operator bool() const { return isRequired(); }
11580
11581 private:
11582 std::optional<SourceLocation> TemplateKW;
11583 };
11584
11586 /// This is not assumed to be a template name.
11588 /// This is assumed to be a template name because lookup found nothing.
11590 /// This is assumed to be a template name because lookup found one or more
11591 /// functions (but no function templates).
11593 };
11594
11595 bool
11597 QualType ObjectType, bool EnteringContext,
11598 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11599 AssumedTemplateKind *ATK = nullptr,
11600 bool AllowTypoCorrection = true);
11601
11603 bool hasTemplateKeyword,
11604 const UnqualifiedId &Name,
11605 ParsedType ObjectType, bool EnteringContext,
11607 bool &MemberOfUnknownSpecialization,
11608 bool AllowTypoCorrection = true);
11609
11610 /// Try to resolve an undeclared template name as a type template.
11611 ///
11612 /// Sets II to the identifier corresponding to the template name, and updates
11613 /// Name to a corresponding (typo-corrected) type template name and TNK to
11614 /// the corresponding kind, if possible.
11616 TemplateNameKind &TNK,
11617 SourceLocation NameLoc,
11618 IdentifierInfo *&II);
11619
11620 /// Determine whether a particular identifier might be the name in a C++1z
11621 /// deduction-guide declaration.
11622 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11623 SourceLocation NameLoc, CXXScopeSpec &SS,
11624 ParsedTemplateTy *Template = nullptr);
11625
11627 SourceLocation IILoc, Scope *S,
11628 const CXXScopeSpec *SS,
11629 TemplateTy &SuggestedTemplate,
11630 TemplateNameKind &SuggestedKind);
11631
11632 /// Determine whether we would be unable to instantiate this template (because
11633 /// it either has no definition, or is in the process of being instantiated).
11635 SourceLocation PointOfInstantiation, NamedDecl *Instantiation,
11636 bool InstantiatedFromMember, const NamedDecl *Pattern,
11637 const NamedDecl *PatternDef, TemplateSpecializationKind TSK,
11638 bool Complain = true, bool *Unreachable = nullptr);
11639
11640 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11641 /// that the template parameter 'PrevDecl' is being shadowed by a new
11642 /// declaration at location Loc. Returns true to indicate that this is
11643 /// an error, and false otherwise.
11644 ///
11645 /// \param Loc The location of the declaration that shadows a template
11646 /// parameter.
11647 ///
11648 /// \param PrevDecl The template parameter that the declaration shadows.
11649 ///
11650 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11651 /// a warning for compatibility with older versions of clang.
11652 /// Ignored when MSVC compatibility is enabled.
11654 bool SupportedForCompatibility = false);
11655
11656 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11657 /// the parameter D to reference the templated declaration and return a
11658 /// pointer to the template declaration. Otherwise, do nothing to D and return
11659 /// null.
11661
11662 /// ActOnTypeParameter - Called when a C++ template type parameter
11663 /// (e.g., "typename T") has been parsed. Typename specifies whether
11664 /// the keyword "typename" was used to declare the type parameter
11665 /// (otherwise, "class" was used), and KeyLoc is the location of the
11666 /// "class" or "typename" keyword. ParamName is the name of the
11667 /// parameter (NULL indicates an unnamed template parameter) and
11668 /// ParamNameLoc is the location of the parameter name (if any).
11669 /// If the type parameter has a default argument, it will be added
11670 /// later via ActOnTypeParameterDefault.
11672 SourceLocation EllipsisLoc,
11673 SourceLocation KeyLoc,
11674 IdentifierInfo *ParamName,
11675 SourceLocation ParamNameLoc, unsigned Depth,
11676 unsigned Position, SourceLocation EqualLoc,
11677 ParsedType DefaultArg, bool HasTypeConstraint);
11678
11680
11681 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11683 TemplateTypeParmDecl *ConstrainedParameter,
11684 SourceLocation EllipsisLoc);
11685 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11687 TemplateTypeParmDecl *ConstrainedParameter,
11688 SourceLocation EllipsisLoc,
11689 bool AllowUnexpandedPack);
11690
11691 /// Attach a type-constraint to a template parameter.
11692 /// \returns true if an error occurred. This can happen if the
11693 /// immediately-declared constraint could not be formed (e.g. incorrect number
11694 /// of arguments for the named concept).
11696 DeclarationNameInfo NameInfo,
11697 TemplateName NamedConcept, NamedDecl *FoundDecl,
11698 const TemplateArgumentListInfo *TemplateArgs,
11699 TemplateTypeParmDecl *ConstrainedParameter,
11700 SourceLocation EllipsisLoc);
11701
11703 NonTypeTemplateParmDecl *NewConstrainedParm,
11704 NonTypeTemplateParmDecl *OrigConstrainedParm,
11705 SourceLocation EllipsisLoc);
11706
11707 /// Require the given type to be a structural type, and diagnose if it is not.
11708 ///
11709 /// \return \c true if an error was produced.
11711
11712 /// Check that the type of a non-type template parameter is
11713 /// well-formed.
11714 ///
11715 /// \returns the (possibly-promoted) parameter type if valid;
11716 /// otherwise, produces a diagnostic and returns a NULL type.
11718 SourceLocation Loc);
11720
11722 unsigned Depth, unsigned Position,
11723 SourceLocation EqualLoc,
11724 Expr *DefaultArg);
11725
11726 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11727 /// parameter (e.g. T in template <template <typename> class T> class array)
11728 /// has been parsed. S is the current scope.
11730 Scope *S, SourceLocation TmpLoc, TemplateNameKind Kind,
11731 bool TypenameKeyword, TemplateParameterList *Params,
11732 SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11733 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11734 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11735
11736 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11737 /// constrained by RequiresClause, that contains the template parameters in
11738 /// Params.
11740 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11741 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11742 SourceLocation RAngleLoc, Expr *RequiresClause);
11743
11744 /// The context in which we are checking a template parameter list.
11746 // For this context, Class, Variable, TypeAlias, and non-pack Template
11747 // Template Parameters are treated uniformly.
11749
11756 };
11757
11758 /// Checks the validity of a template parameter list, possibly
11759 /// considering the template parameter list from a previous
11760 /// declaration.
11761 ///
11762 /// If an "old" template parameter list is provided, it must be
11763 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11764 /// template parameter list.
11765 ///
11766 /// \param NewParams Template parameter list for a new template
11767 /// declaration. This template parameter list will be updated with any
11768 /// default arguments that are carried through from the previous
11769 /// template parameter list.
11770 ///
11771 /// \param OldParams If provided, template parameter list from a
11772 /// previous declaration of the same template. Default template
11773 /// arguments will be merged from the old template parameter list to
11774 /// the new template parameter list.
11775 ///
11776 /// \param TPC Describes the context in which we are checking the given
11777 /// template parameter list.
11778 ///
11779 /// \param SkipBody If we might have already made a prior merged definition
11780 /// of this template visible, the corresponding body-skipping information.
11781 /// Default argument redefinition is not an error when skipping such a body,
11782 /// because (under the ODR) we can assume the default arguments are the same
11783 /// as the prior merged definition.
11784 ///
11785 /// \returns true if an error occurred, false otherwise.
11787 TemplateParameterList *OldParams,
11789 SkipBodyInfo *SkipBody = nullptr);
11790
11791 /// Match the given template parameter lists to the given scope
11792 /// specifier, returning the template parameter list that applies to the
11793 /// name.
11794 ///
11795 /// \param DeclStartLoc the start of the declaration that has a scope
11796 /// specifier or a template parameter list.
11797 ///
11798 /// \param DeclLoc The location of the declaration itself.
11799 ///
11800 /// \param SS the scope specifier that will be matched to the given template
11801 /// parameter lists. This scope specifier precedes a qualified name that is
11802 /// being declared.
11803 ///
11804 /// \param TemplateId The template-id following the scope specifier, if there
11805 /// is one. Used to check for a missing 'template<>'.
11806 ///
11807 /// \param ParamLists the template parameter lists, from the outermost to the
11808 /// innermost template parameter lists.
11809 ///
11810 /// \param IsFriend Whether to apply the slightly different rules for
11811 /// matching template parameters to scope specifiers in friend
11812 /// declarations.
11813 ///
11814 /// \param IsMemberSpecialization will be set true if the scope specifier
11815 /// denotes a fully-specialized type, and therefore this is a declaration of
11816 /// a member specialization.
11817 ///
11818 /// \returns the template parameter list, if any, that corresponds to the
11819 /// name that is preceded by the scope specifier @p SS. This template
11820 /// parameter list may have template parameters (if we're declaring a
11821 /// template) or may have no template parameters (if we're declaring a
11822 /// template specialization), or may be NULL (if what we're declaring isn't
11823 /// itself a template).
11825 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11826 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11827 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11828 bool &IsMemberSpecialization, bool &Invalid,
11829 bool SuppressDiagnostic = false);
11830
11831 /// Returns the template parameter list with all default template argument
11832 /// information.
11834
11836 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11837 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11838 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11839 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11840 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11841 TemplateParameterList **OuterTemplateParamLists,
11842 bool IsMemberSpecialization, SkipBodyInfo *SkipBody = nullptr);
11843
11844 /// Translates template arguments as provided by the parser
11845 /// into template arguments used by semantic analysis.
11848
11849 /// Convert a parsed type into a parsed template argument. This is mostly
11850 /// trivial, except that we may have parsed a C++17 deduced class template
11851 /// specialization type, in which case we should form a template template
11852 /// argument instead of a type template argument.
11854
11856
11859 SourceLocation TemplateLoc,
11860 TemplateArgumentListInfo &TemplateArgs,
11861 Scope *Scope, bool ForNestedNameSpecifier);
11862
11864 ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword,
11865 SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS,
11866 SourceLocation TemplateKWLoc, TemplateTy Template,
11867 const IdentifierInfo *TemplateII,
11868 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11869 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11870 bool IsCtorOrDtorName = false, bool IsClassName = false,
11871 ImplicitTypenameContext AllowImplicitTypename =
11873
11874 /// Parsed an elaborated-type-specifier that refers to a template-id,
11875 /// such as \c class T::template apply<U>.
11877 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11878 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11879 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11880 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11881
11884 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11886
11887 /// Get the specialization of the given variable template corresponding to
11888 /// the specified argument list, or a null-but-valid result if the arguments
11889 /// are dependent.
11891 SourceLocation TemplateLoc,
11892 SourceLocation TemplateNameLoc,
11893 const TemplateArgumentListInfo &TemplateArgs,
11894 bool SetWrittenArgs);
11895
11896 /// Form a reference to the specialization of the given variable template
11897 /// corresponding to the specified argument list, or a null-but-valid result
11898 /// if the arguments are dependent.
11900 const DeclarationNameInfo &NameInfo,
11902 SourceLocation TemplateLoc,
11903 const TemplateArgumentListInfo *TemplateArgs);
11904
11906 const DeclarationNameInfo &NameInfo, TemplateName Template,
11907 const TemplateArgumentListInfo *TemplateArgs);
11908
11910 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11911 const DeclarationNameInfo &ConceptNameInfo,
11912 NamedDecl *FoundDecl, TemplateDecl *NamedConcept,
11913 const TemplateArgumentListInfo *TemplateArgs,
11914 bool DoCheckConstraintSatisfaction = true);
11915
11918 bool TemplateKeyword, TemplateDecl *TD,
11919 SourceLocation Loc);
11920
11922 SourceLocation TemplateKWLoc, LookupResult &R,
11923 bool RequiresADL,
11924 const TemplateArgumentListInfo *TemplateArgs);
11925
11926 // We actually only call this from template instantiation.
11929 const DeclarationNameInfo &NameInfo,
11930 const TemplateArgumentListInfo *TemplateArgs,
11931 bool IsAddressOfOperand);
11932
11934 return Pack.pack_size() - 1 - *ArgPackSubstIndex;
11935 }
11936
11939 Arg = Arg.pack_elements()[*ArgPackSubstIndex];
11940 if (Arg.isPackExpansion())
11941 Arg = Arg.getPackExpansionPattern();
11942 return Arg;
11943 }
11944
11946 BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index,
11947 QualType ParamType, SourceLocation loc,
11948 TemplateArgument Replacement,
11949 UnsignedOrNone PackIndex, bool Final);
11950
11951 /// Form a template name from a name that is syntactically required to name a
11952 /// template, either due to use of the 'template' keyword or because a name in
11953 /// this syntactic context is assumed to name a template (C++
11954 /// [temp.names]p2-4).
11955 ///
11956 /// This action forms a template name given the name of the template and its
11957 /// optional scope specifier. This is used when the 'template' keyword is used
11958 /// or when the parsing context unambiguously treats a following '<' as
11959 /// introducing a template argument list. Note that this may produce a
11960 /// non-dependent template name if we can perform the lookup now and identify
11961 /// the named template.
11962 ///
11963 /// For example, given "x.MetaFun::template apply", the scope specifier
11964 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11965 /// of the "template" keyword, and "apply" is the \p Name.
11967 SourceLocation TemplateKWLoc,
11968 const UnqualifiedId &Name,
11969 ParsedType ObjectType,
11970 bool EnteringContext, TemplateTy &Template,
11971 bool AllowInjectedClassName = false);
11972
11974 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11975 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11977 MultiTemplateParamsArg TemplateParameterLists,
11978 SkipBodyInfo *SkipBody = nullptr);
11979
11980 /// Check the non-type template arguments of a class template
11981 /// partial specialization according to C++ [temp.class.spec]p9.
11982 ///
11983 /// \param TemplateNameLoc the location of the template name.
11984 /// \param PrimaryTemplate the template parameters of the primary class
11985 /// template.
11986 /// \param NumExplicit the number of explicitly-specified template arguments.
11987 /// \param TemplateArgs the template arguments of the class template
11988 /// partial specialization.
11989 ///
11990 /// \returns \c true if there was an error, \c false otherwise.
11992 TemplateDecl *PrimaryTemplate,
11993 unsigned NumExplicitArgs,
11999
12001 MultiTemplateParamsArg TemplateParameterLists,
12002 Declarator &D);
12003
12004 /// Diagnose cases where we have an explicit template specialization
12005 /// before/after an explicit template instantiation, producing diagnostics
12006 /// for those cases where they are required and determining whether the
12007 /// new specialization/instantiation will have any effect.
12008 ///
12009 /// \param NewLoc the location of the new explicit specialization or
12010 /// instantiation.
12011 ///
12012 /// \param NewTSK the kind of the new explicit specialization or
12013 /// instantiation.
12014 ///
12015 /// \param PrevDecl the previous declaration of the entity.
12016 ///
12017 /// \param PrevTSK the kind of the old explicit specialization or
12018 /// instantiatin.
12019 ///
12020 /// \param PrevPointOfInstantiation if valid, indicates where the previous
12021 /// declaration was instantiated (either implicitly or explicitly).
12022 ///
12023 /// \param HasNoEffect will be set to true to indicate that the new
12024 /// specialization or instantiation has no effect and should be ignored.
12025 ///
12026 /// \returns true if there was an error that should prevent the introduction
12027 /// of the new declaration into the AST, false otherwise.
12029 SourceLocation NewLoc,
12030 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
12031 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
12032 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
12033
12034 /// Perform semantic analysis for the given dependent function
12035 /// template specialization.
12036 ///
12037 /// The only possible way to get a dependent function template specialization
12038 /// is with a friend declaration, like so:
12039 ///
12040 /// \code
12041 /// template <class T> void foo(T);
12042 /// template <class T> class A {
12043 /// friend void foo<>(T);
12044 /// };
12045 /// \endcode
12046 ///
12047 /// There really isn't any useful analysis we can do here, so we
12048 /// just store the information.
12050 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
12052
12053 /// Perform semantic analysis for the given function template
12054 /// specialization.
12055 ///
12056 /// This routine performs all of the semantic analysis required for an
12057 /// explicit function template specialization. On successful completion,
12058 /// the function declaration \p FD will become a function template
12059 /// specialization.
12060 ///
12061 /// \param FD the function declaration, which will be updated to become a
12062 /// function template specialization.
12063 ///
12064 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
12065 /// if any. Note that this may be valid info even when 0 arguments are
12066 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
12067 /// as it anyway contains info on the angle brackets locations.
12068 ///
12069 /// \param Previous the set of declarations that may be specialized by
12070 /// this function specialization.
12071 ///
12072 /// \param QualifiedFriend whether this is a lookup for a qualified friend
12073 /// declaration with no explicit template argument list that might be
12074 /// befriending a function template specialization.
12076 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
12077 LookupResult &Previous, bool QualifiedFriend = false);
12078
12079 /// Perform semantic analysis for the given non-template member
12080 /// specialization.
12081 ///
12082 /// This routine performs all of the semantic analysis required for an
12083 /// explicit member function specialization. On successful completion,
12084 /// the function declaration \p FD will become a member function
12085 /// specialization.
12086 ///
12087 /// \param Member the member declaration, which will be updated to become a
12088 /// specialization.
12089 ///
12090 /// \param Previous the set of declarations, one of which may be specialized
12091 /// by this function specialization; the set will be modified to contain the
12092 /// redeclared member.
12095
12096 // Explicit instantiation of a class template specialization
12098 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
12099 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
12100 TemplateTy Template, SourceLocation TemplateNameLoc,
12101 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
12102 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
12103
12104 // Explicit instantiation of a member class of a class template.
12106 SourceLocation TemplateLoc,
12107 unsigned TagSpec, SourceLocation KWLoc,
12108 CXXScopeSpec &SS, IdentifierInfo *Name,
12109 SourceLocation NameLoc,
12110 const ParsedAttributesView &Attr);
12111
12113 SourceLocation TemplateLoc,
12114 Declarator &D);
12115
12116 /// If the given template parameter has a default template
12117 /// argument, substitute into that default template argument and
12118 /// return the corresponding template argument.
12120 TemplateDecl *Template, SourceLocation TemplateKWLoc,
12121 SourceLocation TemplateNameLoc, SourceLocation RAngleLoc, Decl *Param,
12122 ArrayRef<TemplateArgument> SugaredConverted,
12123 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
12124
12125 /// Returns the top most location responsible for the definition of \p N.
12126 /// If \p N is a a template specialization, this is the location
12127 /// of the top of the instantiation stack.
12128 /// Otherwise, the location of \p N is returned.
12130
12131 /// Specifies the context in which a particular template
12132 /// argument is being checked.
12134 /// The template argument was specified in the code or was
12135 /// instantiated with some deduced template arguments.
12137
12138 /// The template argument was deduced via template argument
12139 /// deduction.
12141
12142 /// The template argument was deduced from an array bound
12143 /// via template argument deduction.
12145 };
12146
12154
12155 /// The checked, converted argument will be added to the
12156 /// end of these vectors.
12158
12159 /// The check is being performed in the context of partial ordering.
12161
12162 /// If true, assume these template arguments are
12163 /// the injected template arguments for a template template parameter.
12164 /// This will relax the requirement that all its possible uses are valid:
12165 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
12166 /// during instantiation.
12168
12169 /// Is set to true when, in the context of TTP matching, a pack parameter
12170 /// matches non-pack arguments.
12171 bool StrictPackMatch = false;
12172 };
12173
12174 /// Check that the given template argument corresponds to the given
12175 /// template parameter.
12176 ///
12177 /// \param Param The template parameter against which the argument will be
12178 /// checked.
12179 ///
12180 /// \param Arg The template argument, which may be updated due to conversions.
12181 ///
12182 /// \param Template The template in which the template argument resides.
12183 ///
12184 /// \param TemplateLoc The location of the template name for the template
12185 /// whose argument list we're matching.
12186 ///
12187 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
12188 /// the template argument list.
12189 ///
12190 /// \param ArgumentPackIndex The index into the argument pack where this
12191 /// argument will be placed. Only valid if the parameter is a parameter pack.
12192 ///
12193 /// \param CTAK Describes how we arrived at this particular template argument:
12194 /// explicitly written, deduced, etc.
12195 ///
12196 /// \returns true on error, false otherwise.
12198 NamedDecl *Template, SourceLocation TemplateLoc,
12199 SourceLocation RAngleLoc,
12200 unsigned ArgumentPackIndex,
12203
12204 /// Check that the given template arguments can be provided to
12205 /// the given template, converting the arguments along the way.
12206 ///
12207 /// \param Template The template to which the template arguments are being
12208 /// provided.
12209 ///
12210 /// \param TemplateLoc The location of the template name in the source.
12211 ///
12212 /// \param TemplateArgs The list of template arguments. If the template is
12213 /// a template template parameter, this function may extend the set of
12214 /// template arguments to also include substituted, defaulted template
12215 /// arguments.
12216 ///
12217 /// \param PartialTemplateArgs True if the list of template arguments is
12218 /// intentionally partial, e.g., because we're checking just the initial
12219 /// set of template arguments.
12220 ///
12221 /// \param Converted Will receive the converted, canonicalized template
12222 /// arguments.
12223 ///
12224 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
12225 /// contain the converted forms of the template arguments as written.
12226 /// Otherwise, \p TemplateArgs will not be modified.
12227 ///
12228 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
12229 /// receive true if the cause for the error is the associated constraints of
12230 /// the template not being satisfied by the template arguments.
12231 ///
12232 /// \param DefaultArgs any default arguments from template specialization
12233 /// deduction.
12234 ///
12235 /// \returns true if an error occurred, false otherwise.
12237 SourceLocation TemplateLoc,
12238 TemplateArgumentListInfo &TemplateArgs,
12239 const DefaultArguments &DefaultArgs,
12240 bool PartialTemplateArgs,
12242 bool UpdateArgsWithConversions = true,
12243 bool *ConstraintsNotSatisfied = nullptr);
12244
12247 SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs,
12248 const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
12249 CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions = true,
12250 bool *ConstraintsNotSatisfied = nullptr);
12251
12254 SmallVectorImpl<TemplateArgument> &SugaredConverted,
12255 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
12256
12257 /// Check a template argument against its corresponding
12258 /// template type parameter.
12259 ///
12260 /// This routine implements the semantics of C++ [temp.arg.type]. It
12261 /// returns true if an error occurred, and false otherwise.
12263
12264 /// Check a template argument against its corresponding
12265 /// non-type template parameter.
12266 ///
12267 /// This routine implements the semantics of C++ [temp.arg.nontype].
12268 /// If an error occurred, it returns ExprError(); otherwise, it
12269 /// returns the converted template argument. \p ParamType is the
12270 /// type of the non-type template parameter after it has been instantiated.
12272 QualType InstantiatedParamType, Expr *Arg,
12273 TemplateArgument &SugaredConverted,
12274 TemplateArgument &CanonicalConverted,
12275 bool StrictCheck,
12277
12278 /// Check a template argument against its corresponding
12279 /// template template parameter.
12280 ///
12281 /// This routine implements the semantics of C++ [temp.arg.template].
12282 /// It returns true if an error occurred, and false otherwise.
12284 TemplateParameterList *Params,
12286 bool PartialOrdering,
12287 bool *StrictPackMatch);
12288
12291 const TemplateArgumentLoc &Arg);
12292
12294 std::optional<SourceRange> ParamRange = {});
12296
12297 /// Given a non-type template argument that refers to a
12298 /// declaration and the type of its corresponding non-type template
12299 /// parameter, produce an expression that properly refers to that
12300 /// declaration.
12301 /// FIXME: This is used in some contexts where the resulting expression
12302 /// doesn't need to live too long. It would be useful if this function
12303 /// could return a temporary expression.
12305 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc);
12308 SourceLocation Loc);
12309
12310 /// Enumeration describing how template parameter lists are compared
12311 /// for equality.
12313 /// We are matching the template parameter lists of two templates
12314 /// that might be redeclarations.
12315 ///
12316 /// \code
12317 /// template<typename T> struct X;
12318 /// template<typename T> struct X;
12319 /// \endcode
12321
12322 /// We are matching the template parameter lists of two template
12323 /// template parameters as part of matching the template parameter lists
12324 /// of two templates that might be redeclarations.
12325 ///
12326 /// \code
12327 /// template<template<int I> class TT> struct X;
12328 /// template<template<int Value> class Other> struct X;
12329 /// \endcode
12331
12332 /// We are determining whether the template-parameters are equivalent
12333 /// according to C++ [temp.over.link]/6. This comparison does not consider
12334 /// constraints.
12335 ///
12336 /// \code
12337 /// template<C1 T> void f(T);
12338 /// template<C2 T> void f(T);
12339 /// \endcode
12341 };
12342
12343 // A struct to represent the 'new' declaration, which is either itself just
12344 // the named decl, or the important information we need about it in order to
12345 // do constraint comparisons.
12347 const NamedDecl *ND = nullptr;
12348 const DeclContext *DC = nullptr;
12349 const DeclContext *LexicalDC = nullptr;
12350 SourceLocation Loc;
12351
12352 public:
12355 const DeclContext *LexicalDeclCtx,
12356 SourceLocation Loc)
12357
12358 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
12359 assert(DC && LexicalDC &&
12360 "Constructor only for cases where we have the information to put "
12361 "in here");
12362 }
12363
12364 // If this was constructed with no information, we cannot do substitution
12365 // for constraint comparison, so make sure we can check that.
12366 bool isInvalid() const { return !ND && !DC; }
12367
12368 const NamedDecl *getDecl() const { return ND; }
12369
12370 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
12371
12373 return ND ? ND->getLexicalDeclContext() : LexicalDC;
12374 }
12375
12377 return ND ? ND->getDeclContext() : DC;
12378 }
12379
12380 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
12381 };
12382
12383 /// Determine whether the given template parameter lists are
12384 /// equivalent.
12385 ///
12386 /// \param New The new template parameter list, typically written in the
12387 /// source code as part of a new template declaration.
12388 ///
12389 /// \param Old The old template parameter list, typically found via
12390 /// name lookup of the template declared with this template parameter
12391 /// list.
12392 ///
12393 /// \param Complain If true, this routine will produce a diagnostic if
12394 /// the template parameter lists are not equivalent.
12395 ///
12396 /// \param Kind describes how we are to match the template parameter lists.
12397 ///
12398 /// \param TemplateArgLoc If this source location is valid, then we
12399 /// are actually checking the template parameter list of a template
12400 /// argument (New) against the template parameter list of its
12401 /// corresponding template template parameter (Old). We produce
12402 /// slightly different diagnostics in this scenario.
12403 ///
12404 /// \returns True if the template parameter lists are equal, false
12405 /// otherwise.
12407 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
12408 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
12410 SourceLocation TemplateArgLoc = SourceLocation());
12411
12413 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
12415 SourceLocation TemplateArgLoc = SourceLocation()) {
12416 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
12417 Kind, TemplateArgLoc);
12418 }
12419
12420 /// Check whether a template can be declared within this scope.
12421 ///
12422 /// If the template declaration is valid in this scope, returns
12423 /// false. Otherwise, issues a diagnostic and returns true.
12424 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
12425
12426 /// Called when the parser has parsed a C++ typename
12427 /// specifier, e.g., "typename T::type".
12428 ///
12429 /// \param S The scope in which this typename type occurs.
12430 /// \param TypenameLoc the location of the 'typename' keyword
12431 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12432 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
12433 /// \param IdLoc the location of the identifier.
12434 /// \param IsImplicitTypename context where T::type refers to a type.
12436 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
12437 const IdentifierInfo &II, SourceLocation IdLoc,
12439
12440 /// Called when the parser has parsed a C++ typename
12441 /// specifier that ends in a template-id, e.g.,
12442 /// "typename MetaFun::template apply<T1, T2>".
12443 ///
12444 /// \param S The scope in which this typename type occurs.
12445 /// \param TypenameLoc the location of the 'typename' keyword
12446 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12447 /// \param TemplateLoc the location of the 'template' keyword, if any.
12448 /// \param TemplateName The template name.
12449 /// \param TemplateII The identifier used to name the template.
12450 /// \param TemplateIILoc The location of the template name.
12451 /// \param LAngleLoc The location of the opening angle bracket ('<').
12452 /// \param TemplateArgs The template arguments.
12453 /// \param RAngleLoc The location of the closing angle bracket ('>').
12455 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
12456 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
12457 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
12458 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
12459 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
12460
12462 SourceLocation KeywordLoc,
12463 NestedNameSpecifierLoc QualifierLoc,
12464 const IdentifierInfo &II, SourceLocation IILoc,
12465 TypeSourceInfo **TSI, bool DeducedTSTContext);
12466
12468 SourceLocation KeywordLoc,
12469 NestedNameSpecifierLoc QualifierLoc,
12470 const IdentifierInfo &II, SourceLocation IILoc,
12471 bool DeducedTSTContext = true);
12472
12473 /// Rebuilds a type within the context of the current instantiation.
12474 ///
12475 /// The type \p T is part of the type of an out-of-line member definition of
12476 /// a class template (or class template partial specialization) that was
12477 /// parsed and constructed before we entered the scope of the class template
12478 /// (or partial specialization thereof). This routine will rebuild that type
12479 /// now that we have entered the declarator's scope, which may produce
12480 /// different canonical types, e.g.,
12481 ///
12482 /// \code
12483 /// template<typename T>
12484 /// struct X {
12485 /// typedef T* pointer;
12486 /// pointer data();
12487 /// };
12488 ///
12489 /// template<typename T>
12490 /// typename X<T>::pointer X<T>::data() { ... }
12491 /// \endcode
12492 ///
12493 /// Here, the type "typename X<T>::pointer" will be created as a
12494 /// DependentNameType, since we do not know that we can look into X<T> when we
12495 /// parsed the type. This function will rebuild the type, performing the
12496 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
12497 /// canonical type is the same as the canonical type of T*, allowing the
12498 /// return types of the out-of-line definition and the declaration to match.
12500 SourceLocation Loc,
12501 DeclarationName Name);
12503
12505
12506 /// Rebuild the template parameters now that we know we're in a current
12507 /// instantiation.
12508 bool
12510
12511 /// Produces a formatted string that describes the binding of
12512 /// template parameters to template arguments.
12513 std::string
12515 const TemplateArgumentList &Args);
12516
12517 std::string
12519 const TemplateArgument *Args,
12520 unsigned NumArgs);
12521
12525
12526 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12527 /// was just parsed. This is only possible with an explicit scope
12528 /// specifier naming a dependent type.
12530 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12531 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12532 const TemplateArgumentListInfo *TemplateArgs);
12533
12536 SourceLocation TemplateKWLoc,
12537 const DeclarationNameInfo &NameInfo,
12538 const TemplateArgumentListInfo *TemplateArgs);
12539
12540 // Calculates whether the expression Constraint depends on an enclosing
12541 // template, for the purposes of [temp.friend] p9.
12542 // TemplateDepth is the 'depth' of the friend function, which is used to
12543 // compare whether a declaration reference is referring to a containing
12544 // template, or just the current friend function. A 'lower' TemplateDepth in
12545 // the AST refers to a 'containing' template. As the constraint is
12546 // uninstantiated, this is relative to the 'top' of the TU.
12547 bool
12549 unsigned TemplateDepth,
12550 const Expr *Constraint);
12551
12552 /// Find the failed Boolean condition within a given Boolean
12553 /// constant expression, and describe it with a string.
12554 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12555
12557
12559 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12560 const IdentifierInfo *Name, SourceLocation NameLoc);
12561
12563 Expr *ConstraintExpr,
12564 const ParsedAttributesView &Attrs);
12565
12567 bool &AddToScope);
12569
12570 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12571 const CXXScopeSpec &SS,
12572 const IdentifierInfo *Name,
12573 SourceLocation TagLoc, SourceLocation NameLoc);
12574
12576 CachedTokens &Toks);
12579
12580 /// We've found a use of a templated declaration that would trigger an
12581 /// implicit instantiation. Check that any relevant explicit specializations
12582 /// and partial specializations are visible/reachable, and diagnose if not.
12585
12586 ///@}
12587
12588 //
12589 //
12590 // -------------------------------------------------------------------------
12591 //
12592 //
12593
12594 /// \name C++ Template Argument Deduction
12595 /// Implementations are in SemaTemplateDeduction.cpp
12596 ///@{
12597
12598public:
12599 class SFINAETrap;
12600
12603 : S(S), Prev(std::exchange(S.CurrentSFINAEContext, Cur)) {}
12604
12605 protected:
12607 ~SFINAEContextBase() { S.CurrentSFINAEContext = Prev; }
12610
12611 private:
12612 SFINAETrap *Prev;
12613 };
12614
12618
12619 /// RAII class used to determine whether SFINAE has
12620 /// trapped any errors that occur during template argument
12621 /// deduction.
12622 class SFINAETrap : SFINAEContextBase {
12623 bool HasErrorOcurred = false;
12624 bool WithAccessChecking = false;
12625 bool PrevLastDiagnosticIgnored =
12626 S.getDiagnostics().isLastDiagnosticIgnored();
12627 sema::TemplateDeductionInfo *DeductionInfo = nullptr;
12628
12629 SFINAETrap(Sema &S, sema::TemplateDeductionInfo *Info,
12630 bool WithAccessChecking)
12631 : SFINAEContextBase(S, this), WithAccessChecking(WithAccessChecking),
12632 DeductionInfo(Info) {}
12633
12634 public:
12635 /// \param WithAccessChecking If true, discard all diagnostics (from the
12636 /// immediate context) instead of adding them to the currently active
12637 /// \ref TemplateDeductionInfo.
12638 explicit SFINAETrap(Sema &S, bool WithAccessChecking = false)
12639 : SFINAETrap(S, /*Info=*/nullptr, WithAccessChecking) {}
12640
12642 : SFINAETrap(S, &Info, /*WithAccessChecking=*/false) {}
12643
12645 S.getDiagnostics().setLastDiagnosticIgnored(PrevLastDiagnosticIgnored);
12646 }
12647
12648 SFINAETrap(const SFINAETrap &) = delete;
12649 SFINAETrap &operator=(const SFINAETrap &) = delete;
12650
12652 return DeductionInfo;
12653 }
12654
12655 /// Determine whether any SFINAE errors have been trapped.
12656 bool hasErrorOccurred() const { return HasErrorOcurred; }
12657 void setErrorOccurred() { HasErrorOcurred = true; }
12658
12659 bool withAccessChecking() const { return WithAccessChecking; }
12660 };
12661
12662 /// RAII class used to indicate that we are performing provisional
12663 /// semantic analysis to determine the validity of a construct, so
12664 /// typo-correction and diagnostics in the immediate context (not within
12665 /// implicitly-instantiated templates) should be suppressed.
12667 Sema &SemaRef;
12668 // FIXME: Using a SFINAETrap for this is a hack.
12669 SFINAETrap Trap;
12670 bool PrevDisableTypoCorrection;
12671
12672 public:
12673 explicit TentativeAnalysisScope(Sema &SemaRef)
12674 : SemaRef(SemaRef), Trap(SemaRef, /*ForValidityCheck=*/true),
12675 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12676 SemaRef.DisableTypoCorrection = true;
12677 }
12679 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12680 }
12681
12684 };
12685
12686 /// For each declaration that involved template argument deduction, the
12687 /// set of diagnostics that were suppressed during that template argument
12688 /// deduction.
12689 ///
12690 /// FIXME: Serialize this structure to the AST file.
12691 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12694
12695 /// Compare types for equality with respect to possibly compatible
12696 /// function types (noreturn adjustment, implicit calling conventions). If any
12697 /// of parameter and argument is not a function, just perform type comparison.
12698 ///
12699 /// \param P the template parameter type.
12700 ///
12701 /// \param A the argument type.
12703
12704 /// Allocate a TemplateArgumentLoc where all locations have
12705 /// been initialized to the given location.
12706 ///
12707 /// \param Arg The template argument we are producing template argument
12708 /// location information for.
12709 ///
12710 /// \param NTTPType For a declaration template argument, the type of
12711 /// the non-type template parameter that corresponds to this template
12712 /// argument. Can be null if no type sugar is available to add to the
12713 /// type from the template argument.
12714 ///
12715 /// \param Loc The source location to use for the resulting template
12716 /// argument.
12718 QualType NTTPType,
12719 SourceLocation Loc);
12720
12721 /// Get a template argument mapping the given template parameter to itself,
12722 /// e.g. for X in \c template<int X>, this would return an expression template
12723 /// argument referencing X.
12725 SourceLocation Location);
12726
12727 /// Adjust the type \p ArgFunctionType to match the calling convention,
12728 /// noreturn, and optionally the exception specification of \p FunctionType.
12729 /// Deduction often wants to ignore these properties when matching function
12730 /// types.
12732 bool AdjustExceptionSpec = false);
12733
12736 ArrayRef<TemplateArgument> TemplateArgs,
12738
12741 ArrayRef<TemplateArgument> TemplateArgs,
12743
12744 /// Deduce the template arguments of the given template from \p FromType.
12745 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12746 /// [over.match.class.deduct]p4.
12747 ///
12748 /// It only supports class or type alias templates.
12752
12757 bool NumberOfArgumentsMustMatch);
12758
12759 /// Substitute the explicitly-provided template arguments into the
12760 /// given function template according to C++ [temp.arg.explicit].
12761 ///
12762 /// \param FunctionTemplate the function template into which the explicit
12763 /// template arguments will be substituted.
12764 ///
12765 /// \param ExplicitTemplateArgs the explicitly-specified template
12766 /// arguments.
12767 ///
12768 /// \param Deduced the deduced template arguments, which will be populated
12769 /// with the converted and checked explicit template arguments.
12770 ///
12771 /// \param ParamTypes will be populated with the instantiated function
12772 /// parameters.
12773 ///
12774 /// \param FunctionType if non-NULL, the result type of the function template
12775 /// will also be instantiated and the pointed-to value will be updated with
12776 /// the instantiated function type.
12777 ///
12778 /// \param Info if substitution fails for any reason, this object will be
12779 /// populated with more information about the failure.
12780 ///
12781 /// \returns TemplateDeductionResult::Success if substitution was successful,
12782 /// or some failure condition.
12785 TemplateArgumentListInfo &ExplicitTemplateArgs,
12789
12790 /// brief A function argument from which we performed template argument
12791 // deduction for a call.
12804
12805 /// Finish template argument deduction for a function template,
12806 /// checking the deduced template arguments for completeness and forming
12807 /// the function template specialization.
12808 ///
12809 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12810 /// which the deduced argument types should be compared.
12811 /// \param CheckNonDependent Callback before substituting into the declaration
12812 /// with the deduced template arguments.
12813 /// \param OnlyInitializeNonUserDefinedConversions is used as a workaround for
12814 /// some breakages introduced by CWG2369, where non-user-defined conversions
12815 /// are checked first before the constraints.
12819 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12821 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12822 bool PartialOverloading, bool PartialOrdering,
12823 bool ForOverloadSetAddressResolution,
12824 llvm::function_ref<bool(bool)> CheckNonDependent =
12825 [](bool /*OnlyInitializeNonUserDefinedConversions*/) {
12826 return false;
12827 });
12828
12829 /// Perform [temp.friend] p5 template argument deduction for a dependent
12830 /// friend declaration and a candidate class template specialization.
12832 ClassTemplateDecl *PatternCTD,
12833 ClassTemplateDecl *CandidateCTD,
12835 ArrayRef<TemplateArgument> PatternArgs,
12836 ArrayRef<TemplateArgument> CandidateArgs,
12837 SourceLocation Loc,
12838 TemplateSpecCandidateSet *FailedTSC,
12839 MultiLevelTemplateArgumentList &DeducedArgs);
12840
12841 /// Perform template argument deduction from a function call
12842 /// (C++ [temp.deduct.call]).
12843 ///
12844 /// \param FunctionTemplate the function template for which we are performing
12845 /// template argument deduction.
12846 ///
12847 /// \param ExplicitTemplateArgs the explicit template arguments provided
12848 /// for this call.
12849 ///
12850 /// \param Args the function call arguments
12851 ///
12852 /// \param Specialization if template argument deduction was successful,
12853 /// this will be set to the function template specialization produced by
12854 /// template argument deduction.
12855 ///
12856 /// \param Info the argument will be updated to provide additional information
12857 /// about template argument deduction.
12858 ///
12859 /// \param CheckNonDependent A callback to invoke to check conversions for
12860 /// non-dependent parameters, between deduction and substitution, per DR1391.
12861 /// If this returns true, substitution will be skipped and we return
12862 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12863 /// passed the parameter types (after substituting explicit template
12864 /// arguments).
12865 ///
12866 /// \returns the result of template argument deduction.
12869 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12871 bool PartialOverloading, bool AggregateDeductionCandidate,
12872 bool PartialOrdering, QualType ObjectType,
12873 Expr::Classification ObjectClassification,
12874 bool ForOverloadSetAddressResolution,
12875 llvm::function_ref<bool(ArrayRef<QualType>, bool)> CheckNonDependent);
12876
12877 /// Deduce template arguments when taking the address of a function
12878 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12879 /// a template.
12880 ///
12881 /// \param FunctionTemplate the function template for which we are performing
12882 /// template argument deduction.
12883 ///
12884 /// \param ExplicitTemplateArgs the explicitly-specified template
12885 /// arguments.
12886 ///
12887 /// \param ArgFunctionType the function type that will be used as the
12888 /// "argument" type (A) when performing template argument deduction from the
12889 /// function template's function type. This type may be NULL, if there is no
12890 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12891 ///
12892 /// \param Specialization if template argument deduction was successful,
12893 /// this will be set to the function template specialization produced by
12894 /// template argument deduction.
12895 ///
12896 /// \param Info the argument will be updated to provide additional information
12897 /// about template argument deduction.
12898 ///
12899 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12900 /// the address of a function template per [temp.deduct.funcaddr] and
12901 /// [over.over]. If \c false, we are looking up a function template
12902 /// specialization based on its signature, per [temp.deduct.decl].
12903 ///
12904 /// \returns the result of template argument deduction.
12907 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12909 bool IsAddressOfFunction = false);
12910
12911 /// Deduce template arguments for a templated conversion
12912 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12913 /// conversion function template specialization.
12916 Expr::Classification ObjectClassification, QualType ToType,
12918
12919 /// Deduce template arguments for a function template when there is
12920 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12921 ///
12922 /// \param FunctionTemplate the function template for which we are performing
12923 /// template argument deduction.
12924 ///
12925 /// \param ExplicitTemplateArgs the explicitly-specified template
12926 /// arguments.
12927 ///
12928 /// \param Specialization if template argument deduction was successful,
12929 /// this will be set to the function template specialization produced by
12930 /// template argument deduction.
12931 ///
12932 /// \param Info the argument will be updated to provide additional information
12933 /// about template argument deduction.
12934 ///
12935 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12936 /// the address of a function template in a context where we do not have a
12937 /// target type, per [over.over]. If \c false, we are looking up a function
12938 /// template specialization based on its signature, which only happens when
12939 /// deducing a function parameter type from an argument that is a template-id
12940 /// naming a function template specialization.
12941 ///
12942 /// \returns the result of template argument deduction.
12945 TemplateArgumentListInfo *ExplicitTemplateArgs,
12948 bool IsAddressOfFunction = false);
12949
12950 /// Substitute Replacement for \p auto in \p TypeWithAuto
12951 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12952 /// Substitute Replacement for auto in TypeWithAuto
12954 QualType Replacement);
12955
12956 // Substitute auto in TypeWithAuto for a Dependent auto type
12958
12959 // Substitute auto in TypeWithAuto for a Dependent auto type
12962
12963 /// Completely replace the \c auto in \p TypeWithAuto by
12964 /// \p Replacement. This does not retain any \c auto type sugar.
12965 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12967 QualType Replacement);
12968
12969 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12970 ///
12971 /// Note that this is done even if the initializer is dependent. (This is
12972 /// necessary to support partial ordering of templates using 'auto'.)
12973 /// A dependent type will be produced when deducing from a dependent type.
12974 ///
12975 /// \param Type the type pattern using the auto type-specifier.
12976 /// \param Init the initializer for the variable whose type is to be deduced.
12977 /// \param Result if type deduction was successful, this will be set to the
12978 /// deduced type.
12979 /// \param Info the argument will be updated to provide additional information
12980 /// about template argument deduction.
12981 /// \param DependentDeduction Set if we should permit deduction in
12982 /// dependent cases. This is necessary for template partial ordering
12983 /// with 'auto' template parameters. The template parameter depth to be
12984 /// used should be specified in the 'Info' parameter.
12985 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12986 /// does not satisfy the type-constraint in the auto
12987 /// type.
12991 bool DependentDeduction = false,
12992 bool IgnoreConstraints = false,
12993 TemplateSpecCandidateSet *FailedTSC = nullptr);
12994 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12996 bool Diagnose = true);
12997
12999 SourceLocation Loc);
13000
13001 /// Returns the more specialized class template partial specialization
13002 /// according to the rules of partial ordering of class template partial
13003 /// specializations (C++ [temp.class.order]).
13004 ///
13005 /// \param PS1 the first class template partial specialization
13006 ///
13007 /// \param PS2 the second class template partial specialization
13008 ///
13009 /// \returns the more specialized class template partial specialization. If
13010 /// neither partial specialization is more specialized, returns NULL.
13015
13018
13022
13025
13027 TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
13028 const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
13029 bool PartialOrdering, bool *StrictPackMatch);
13030
13031 /// Mark which template parameters are used in a given expression.
13032 ///
13033 /// \param E the expression from which template parameters will be deduced.
13034 ///
13035 /// \param Used a bit vector whose elements will be set to \c true
13036 /// to indicate when the corresponding template parameter will be
13037 /// deduced.
13038 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
13039 unsigned Depth, llvm::SmallBitVector &Used);
13040
13041 /// Mark which template parameters are named in a given expression.
13042 ///
13043 /// Unlike MarkUsedTemplateParameters, this excludes parameter that
13044 /// are used but not directly named by an expression - i.e. it excludes
13045 /// any template parameter that denotes the type of a referenced NTTP.
13046 ///
13047 /// \param Used a bit vector whose elements will be set to \c true
13048 /// to indicate when the corresponding template parameter will be
13049 /// deduced.
13051 const Expr *E, unsigned Depth, llvm::SmallBitVector &Used);
13052
13053 /// Mark which template parameters can be deduced from a given
13054 /// template argument list.
13055 ///
13056 /// \param TemplateArgs the template argument list from which template
13057 /// parameters will be deduced.
13058 ///
13059 /// \param Used a bit vector whose elements will be set to \c true
13060 /// to indicate when the corresponding template parameter will be
13061 /// deduced.
13062 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
13063 bool OnlyDeduced, unsigned Depth,
13064 llvm::SmallBitVector &Used);
13065
13067 bool OnlyDeduced, unsigned Depth,
13068 llvm::SmallBitVector &Used);
13069
13071 unsigned Depth, llvm::SmallBitVector &Used);
13072
13073 void
13078
13079 /// Marks all of the template parameters that will be deduced by a
13080 /// call to the given function template.
13081 static void
13084 llvm::SmallBitVector &Deduced);
13085
13086 /// Returns the more specialized function template according
13087 /// to the rules of function template partial ordering (C++
13088 /// [temp.func.order]).
13089 ///
13090 /// \param FT1 the first function template
13091 ///
13092 /// \param FT2 the second function template
13093 ///
13094 /// \param TPOC the context in which we are performing partial ordering of
13095 /// function templates.
13096 ///
13097 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
13098 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
13099 /// when calling a member function.
13100 ///
13101 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
13102 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
13103 /// template from a member function
13104 ///
13105 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
13106 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
13107 /// template from a member function
13108 ///
13109 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
13110 /// candidate with a reversed parameter order. In this case, the corresponding
13111 /// P/A pairs between FT1 and FT2 are reversed.
13112 ///
13113 /// \returns the more specialized function template. If neither
13114 /// template is more specialized, returns NULL.
13117 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
13118 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false,
13119 bool PartialOverloading = false);
13120
13121 /// Retrieve the most specialized of the given function template
13122 /// specializations.
13123 ///
13124 /// \param SpecBegin the start iterator of the function template
13125 /// specializations that we will be comparing.
13126 ///
13127 /// \param SpecEnd the end iterator of the function template
13128 /// specializations, paired with \p SpecBegin.
13129 ///
13130 /// \param Loc the location where the ambiguity or no-specializations
13131 /// diagnostic should occur.
13132 ///
13133 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
13134 /// no matching candidates.
13135 ///
13136 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
13137 /// occurs.
13138 ///
13139 /// \param CandidateDiag partial diagnostic used for each function template
13140 /// specialization that is a candidate in the ambiguous ordering. One
13141 /// parameter in this diagnostic should be unbound, which will correspond to
13142 /// the string describing the template arguments for the function template
13143 /// specialization.
13144 ///
13145 /// \returns the most specialized function template specialization, if
13146 /// found. Otherwise, returns SpecEnd.
13147 UnresolvedSetIterator
13148 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
13149 TemplateSpecCandidateSet &FailedCandidates,
13150 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
13151 const PartialDiagnostic &AmbigDiag,
13152 const PartialDiagnostic &CandidateDiag,
13153 bool Complain = true, QualType TargetType = QualType());
13154
13155 /// Returns the more constrained function according to the rules of
13156 /// partial ordering by constraints (C++ [temp.constr.order]).
13157 ///
13158 /// \param FD1 the first function
13159 ///
13160 /// \param FD2 the second function
13161 ///
13162 /// \returns the more constrained function. If neither function is
13163 /// more constrained, returns NULL.
13164 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
13165 FunctionDecl *FD2);
13166
13167 ///@}
13168
13169 //
13170 //
13171 // -------------------------------------------------------------------------
13172 //
13173 //
13174
13175 /// \name C++ Template Deduction Guide
13176 /// Implementations are in SemaTemplateDeductionGuide.cpp
13177 ///@{
13178
13179 /// Declare implicit deduction guides for a class template if we've
13180 /// not already done so.
13181 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
13182 SourceLocation Loc);
13183
13184 CXXDeductionGuideDecl *DeclareAggregateDeductionGuideFromInitList(
13185 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
13186 SourceLocation Loc);
13187
13188 ///@}
13189
13190 //
13191 //
13192 // -------------------------------------------------------------------------
13193 //
13194 //
13195
13196 /// \name C++ Template Instantiation
13197 /// Implementations are in SemaTemplateInstantiate.cpp
13198 ///@{
13199
13200public:
13201 /// A helper class for building up ExtParameterInfos.
13204 bool HasInteresting = false;
13205
13206 public:
13207 /// Set the ExtParameterInfo for the parameter at the given index,
13208 ///
13210 assert(Infos.size() <= index);
13211 Infos.resize(index);
13212 Infos.push_back(info);
13213
13214 if (!HasInteresting)
13215 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
13216 }
13217
13218 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
13219 /// ExtParameterInfo array we've built up.
13221 getPointerOrNull(unsigned numParams) {
13222 if (!HasInteresting)
13223 return nullptr;
13224 Infos.resize(numParams);
13225 return Infos.data();
13226 }
13227 };
13228
13229 /// The current instantiation scope used to store local
13230 /// variables.
13232
13233 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
13235
13236 /// A mapping from parameters with unparsed default arguments to the
13237 /// set of instantiations of each parameter.
13238 ///
13239 /// This mapping is a temporary data structure used when parsing
13240 /// nested class templates or nested classes of class templates,
13241 /// where we might end up instantiating an inner class before the
13242 /// default arguments of its methods have been parsed.
13244
13245 using InstantiatingSpecializationsKey = llvm::PointerIntPair<Decl *, 2>;
13246
13253
13255 : S(S), Key(D->getCanonicalDecl(), unsigned(Kind)) {
13256 auto [_, Created] = S.InstantiatingSpecializations.insert(Key);
13257 if (!Created)
13258 Key = {};
13259 }
13260
13262 if (Key.getOpaqueValue()) {
13263 [[maybe_unused]] bool Erased =
13264 S.InstantiatingSpecializations.erase(Key);
13265 assert(Erased);
13266 }
13267 }
13268
13271
13272 operator bool() const { return Key.getOpaqueValue() == nullptr; }
13273
13274 private:
13275 Sema &S;
13277 };
13278
13279 /// A context in which code is being synthesized (where a source location
13280 /// alone is not sufficient to identify the context). This covers template
13281 /// instantiation and various forms of implicitly-generated functions.
13283 /// The kind of template instantiation we are performing
13285 /// We are instantiating a template declaration. The entity is
13286 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
13288
13289 /// We are instantiating a default argument for a template
13290 /// parameter. The Entity is the template parameter whose argument is
13291 /// being instantiated, the Template is the template, and the
13292 /// TemplateArgs/NumTemplateArguments provide the template arguments as
13293 /// specified.
13295
13296 /// We are instantiating a default argument for a function.
13297 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
13298 /// provides the template arguments as specified.
13300
13301 /// We are substituting explicit template arguments provided for
13302 /// a function template. The entity is a FunctionTemplateDecl.
13304
13305 /// We are substituting template argument determined as part of
13306 /// template argument deduction for either a class template
13307 /// partial specialization or a function template. The
13308 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
13309 /// a TemplateDecl.
13311
13312 /// We are substituting into a lambda expression.
13314
13315 /// We are substituting prior template arguments into a new
13316 /// template parameter. The template parameter itself is either a
13317 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
13319
13320 /// We are checking the validity of a default template argument that
13321 /// has been used when naming a template-id.
13323
13324 /// We are computing the exception specification for a defaulted special
13325 /// member function.
13327
13328 /// We are instantiating the exception specification for a function
13329 /// template which was deferred until it was needed.
13331
13332 /// We are instantiating a requirement of a requires expression.
13334
13335 /// We are checking the satisfaction of a nested requirement of a requires
13336 /// expression.
13338
13339 /// We are declaring an implicit special member function.
13341
13342 /// We are declaring an implicit 'operator==' for a defaulted
13343 /// 'operator<=>'.
13345
13346 /// We are defining a synthesized function (such as a defaulted special
13347 /// member).
13349
13350 // We are checking the constraints associated with a constrained entity or
13351 // the constraint expression of a concept. This includes the checks that
13352 // atomic constraints have the type 'bool' and that they can be constant
13353 // evaluated.
13355
13356 // We are substituting template arguments into a constraint expression.
13358
13359 // Instantiating a Requires Expression parameter clause.
13361
13362 // We are substituting into the parameter mapping of an atomic constraint
13363 // during normalization.
13365
13366 /// We are rewriting a comparison operator in terms of an operator<=>.
13368
13369 /// We are initializing a structured binding.
13371
13372 /// We are marking a class as __dllexport.
13374
13375 /// We are building an implied call from __builtin_dump_struct. The
13376 /// arguments are in CallArgs.
13378
13379 /// Added for Template instantiation observation.
13380 /// Memoization means we are _not_ instantiating a template because
13381 /// it is already instantiated (but we entered a context where we
13382 /// would have had to if it was not already instantiated).
13384
13385 /// We are building deduction guides for a class.
13387
13388 /// We are instantiating a type alias template declaration.
13390
13391 /// We are performing partial ordering for template template parameters.
13393
13394 /// We are performing name lookup for a function template or variable
13395 /// template named 'sycl_kernel_launch'.
13397
13398 /// We are performing overload resolution for a call to a function
13399 /// template or variable template named 'sycl_kernel_launch'.
13401
13402 /// We are instantiating an expansion statement.
13404 } Kind;
13405
13406 /// Whether we're substituting into constraints.
13408
13409 /// Whether we're substituting into the parameter mapping of a constraint.
13411
13412 /// The point of instantiation or synthesis within the source code.
13414
13415 /// The entity that is being synthesized.
13417
13418 /// The template (or partial specialization) in which we are
13419 /// performing the instantiation, for substitutions of prior template
13420 /// arguments.
13422
13423 union {
13424 /// The list of template arguments we are substituting, if they
13425 /// are not part of the entity.
13427
13428 /// The list of argument expressions in a synthesized call.
13429 const Expr *const *CallArgs;
13430 };
13431
13432 // FIXME: Wrap this union around more members, or perhaps store the
13433 // kind-specific members in the RAII object owning the context.
13434 union {
13435 /// The number of template arguments in TemplateArgs.
13437
13438 /// The number of expressions in CallArgs.
13439 unsigned NumCallArgs;
13440
13441 /// The special member being declared or defined.
13443 };
13444
13449
13450 /// The source range that covers the construct that cause
13451 /// the instantiation, e.g., the template-id that causes a class
13452 /// template instantiation.
13454
13459
13460 /// Determines whether this template is an actual instantiation
13461 /// that should be counted toward the maximum instantiation depth.
13462 bool isInstantiationRecord() const;
13463 };
13464
13465 /// A stack object to be created when performing template
13466 /// instantiation.
13467 ///
13468 /// Construction of an object of type \c InstantiatingTemplate
13469 /// pushes the current instantiation onto the stack of active
13470 /// instantiations. If the size of this stack exceeds the maximum
13471 /// number of recursive template instantiations, construction
13472 /// produces an error and evaluates true.
13473 ///
13474 /// Destruction of this object will pop the named instantiation off
13475 /// the stack.
13477 /// Note that we are instantiating a class template,
13478 /// function template, variable template, alias template,
13479 /// or a member thereof.
13480 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13481 Decl *Entity,
13482 SourceRange InstantiationRange = SourceRange());
13483
13485 /// Note that we are instantiating an exception specification
13486 /// of a function template.
13487 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13489 SourceRange InstantiationRange = SourceRange());
13490
13491 /// Note that we are instantiating a type alias template declaration.
13492 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13493 TypeAliasTemplateDecl *Entity,
13494 ArrayRef<TemplateArgument> TemplateArgs,
13495 SourceRange InstantiationRange = SourceRange());
13496
13497 /// Note that we are instantiating a default argument in a
13498 /// template-id.
13499 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13501 ArrayRef<TemplateArgument> TemplateArgs,
13502 SourceRange InstantiationRange = SourceRange());
13503
13504 /// Note that we are substituting either explicitly-specified or
13505 /// deduced template arguments during function template argument deduction.
13506 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13508 ArrayRef<TemplateArgument> TemplateArgs,
13510 SourceRange InstantiationRange = SourceRange());
13511
13512 /// Note that we are instantiating as part of template
13513 /// argument deduction for a class template declaration.
13514 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13516 ArrayRef<TemplateArgument> TemplateArgs,
13517 SourceRange InstantiationRange = SourceRange());
13518
13519 /// Note that we are instantiating as part of template
13520 /// argument deduction for a class template partial
13521 /// specialization.
13522 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13524 ArrayRef<TemplateArgument> TemplateArgs,
13525 SourceRange InstantiationRange = SourceRange());
13526
13527 /// Note that we are instantiating as part of template
13528 /// argument deduction for a variable template partial
13529 /// specialization.
13530 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13532 ArrayRef<TemplateArgument> TemplateArgs,
13533 SourceRange InstantiationRange = SourceRange());
13534
13535 /// Note that we are instantiating a default argument for a function
13536 /// parameter.
13537 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13538 ParmVarDecl *Param,
13539 ArrayRef<TemplateArgument> TemplateArgs,
13540 SourceRange InstantiationRange = SourceRange());
13541
13542 /// Note that we are substituting prior template arguments into a
13543 /// non-type parameter.
13544 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13546 ArrayRef<TemplateArgument> TemplateArgs,
13547 SourceRange InstantiationRange);
13548
13549 /// Note that we are substituting prior template arguments into a
13550 /// template template parameter.
13551 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13553 ArrayRef<TemplateArgument> TemplateArgs,
13554 SourceRange InstantiationRange);
13555
13556 /// Note that we are checking the default template argument
13557 /// against the template parameter for a given template-id.
13558 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13560 ArrayRef<TemplateArgument> TemplateArgs,
13561 SourceRange InstantiationRange);
13562
13564 /// \brief Note that we are checking the constraints associated with some
13565 /// constrained entity (a concept declaration or a template with associated
13566 /// constraints).
13567 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13569 ArrayRef<TemplateArgument> TemplateArgs,
13570 SourceRange InstantiationRange);
13571
13573 /// \brief Note that we are checking a constraint expression associated
13574 /// with a template declaration or as part of the satisfaction check of a
13575 /// concept.
13576 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13578 SourceRange InstantiationRange);
13579
13581 /// \brief Note that we are subtituting into the parameter mapping of an
13582 /// atomic constraint during constraint normalization.
13583 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13585 SourceRange InstantiationRange);
13586
13587 /// \brief Note that we are substituting template arguments into a part of
13588 /// a requirement of a requires expression.
13589 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13591 SourceRange InstantiationRange = SourceRange());
13592
13593 /// \brief Note that we are substituting the body of an expansion statement.
13594 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13595 CXXExpansionStmtPattern *ExpansionStmt,
13597 SourceRange InstantiationRange);
13598
13599 /// \brief Note that we are checking the satisfaction of the constraint
13600 /// expression inside of a nested requirement.
13601 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13603 SourceRange InstantiationRange = SourceRange());
13604
13605 /// \brief Note that we are checking a requires clause.
13606 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13607 const RequiresExpr *E,
13608 SourceRange InstantiationRange);
13609
13611 /// \brief Note that we are building deduction guides.
13612 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13614 SourceRange InstantiationRange = SourceRange());
13615
13617 /// \brief Note that we are partial ordering template template parameters.
13618 InstantiatingTemplate(Sema &SemaRef, SourceLocation ArgLoc,
13620 SourceRange InstantiationRange = SourceRange());
13621
13622 /// Note that we have finished instantiating this template.
13623 void Clear();
13624
13626
13627 /// Determines whether we have exceeded the maximum
13628 /// recursive template instantiations.
13629 bool isInvalid() const { return Invalid; }
13630
13631 private:
13632 Sema &SemaRef;
13633 bool Invalid;
13634
13637 SourceLocation PointOfInstantiation,
13638 SourceRange InstantiationRange, Decl *Entity,
13639 NamedDecl *Template = nullptr,
13640 ArrayRef<TemplateArgument> TemplateArgs = {});
13641
13643
13644 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13645 };
13646
13647 bool SubstTemplateArgument(const TemplateArgumentLoc &Input,
13648 const MultiLevelTemplateArgumentList &TemplateArgs,
13649 TemplateArgumentLoc &Output,
13650 SourceLocation Loc = {},
13651 const DeclarationName &Entity = {});
13652 bool
13653 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13654 const MultiLevelTemplateArgumentList &TemplateArgs,
13655 TemplateArgumentListInfo &Outputs);
13656
13657 /// Substitute concept template arguments in the constraint expression
13658 /// of a concept-id. This is used to implement [temp.constr.normal].
13660 SubstConceptTemplateArguments(const ConceptSpecializationExpr *CSE,
13661 const Expr *ConstraintExpr,
13662 const MultiLevelTemplateArgumentList &MLTAL);
13663
13665 ArrayRef<TemplateArgumentLoc> Args, SourceLocation BaseLoc,
13666 const MultiLevelTemplateArgumentList &TemplateArgs,
13667 TemplateArgumentListInfo &Out);
13668
13669 /// Retrieve the template argument list(s) that should be used to
13670 /// instantiate the definition of the given declaration.
13671 ///
13672 /// \param ND the declaration for which we are computing template
13673 /// instantiation arguments.
13674 ///
13675 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13676 /// the decl context where it will be created. In this case, the `Innermost`
13677 /// should likely be provided. If ND is non-null, this is ignored.
13678 ///
13679 /// \param Innermost if non-NULL, specifies a template argument list for the
13680 /// template declaration passed as ND.
13681 ///
13682 /// \param RelativeToPrimary true if we should get the template
13683 /// arguments relative to the primary template, even when we're
13684 /// dealing with a specialization. This is only relevant for function
13685 /// template specializations.
13686 ///
13687 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13688 /// instantiating the definition of the given declaration, \p ND. This is
13689 /// used to determine the proper set of template instantiation arguments for
13690 /// friend function template specializations.
13691 ///
13692 /// \param ForConstraintInstantiation when collecting arguments,
13693 /// ForConstraintInstantiation indicates we should continue looking when
13694 /// encountering a lambda generic call operator, and continue looking for
13695 /// arguments on an enclosing class template.
13696 ///
13697 /// \param SkipForSpecialization when specified, any template specializations
13698 /// in a traversal would be ignored.
13699 ///
13700 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13701 /// when encountering a specialized member function template, rather than
13702 /// returning immediately.
13703 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13704 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13705 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13706 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13707 bool ForConstraintInstantiation = false,
13708 bool SkipForSpecialization = false,
13709 bool ForDefaultArgumentSubstitution = false);
13710
13711 /// RAII object to handle the state changes required to synthesize
13712 /// a function body.
13714 Sema &S;
13715 Sema::ContextRAII SavedContext;
13716 bool PushedCodeSynthesisContext = false;
13717
13718 public:
13720 : S(S), SavedContext(S, DC) {
13721 auto *FD = dyn_cast<FunctionDecl>(DC);
13722 S.PushFunctionScope();
13723 S.PushExpressionEvaluationContextForFunction(
13725 if (FD)
13726 FD->setWillHaveBody(true);
13727 else
13728 assert(isa<ObjCMethodDecl>(DC));
13729 }
13730
13732 assert(!PushedCodeSynthesisContext);
13733
13736 Ctx.PointOfInstantiation = UseLoc;
13737 Ctx.Entity = cast<Decl>(S.CurContext);
13738 S.pushCodeSynthesisContext(Ctx);
13739
13740 PushedCodeSynthesisContext = true;
13741 }
13742
13744 if (PushedCodeSynthesisContext)
13745 S.popCodeSynthesisContext();
13746 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13747 FD->setWillHaveBody(false);
13748 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13749 }
13750 S.PopExpressionEvaluationContext();
13751 S.PopFunctionScopeInfo();
13752 }
13753
13757 };
13758
13759 /// RAII object to ensure that a code synthesis context is popped on scope
13760 /// exit.
13762 Sema &S;
13763
13764 public:
13766 : S(S) {
13767 S.pushCodeSynthesisContext(Ctx);
13768 }
13769
13770 ~ScopedCodeSynthesisContext() { S.popCodeSynthesisContext(); }
13774 };
13775
13776 /// List of active code synthesis contexts.
13777 ///
13778 /// This vector is treated as a stack. As synthesis of one entity requires
13779 /// synthesis of another, additional contexts are pushed onto the stack.
13781
13782 /// Specializations whose definitions are currently being instantiated.
13783 llvm::DenseSet<InstantiatingSpecializationsKey> InstantiatingSpecializations;
13784
13785 /// Non-dependent types used in templates that have already been instantiated
13786 /// by some template instantiation.
13787 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13788
13789 /// Extra modules inspected when performing a lookup during a template
13790 /// instantiation. Computed lazily.
13792
13793 /// Cache of additional modules that should be used for name lookup
13794 /// within the current template instantiation. Computed lazily; use
13795 /// getLookupModules() to get a complete set.
13796 llvm::DenseSet<Module *> LookupModulesCache;
13797
13798 /// Map from the most recent declaration of a namespace to the most
13799 /// recent visible declaration of that namespace.
13800 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13801
13803
13804 /// The number of \p CodeSynthesisContexts that are not template
13805 /// instantiations and, therefore, should not be counted as part of the
13806 /// instantiation depth.
13807 ///
13808 /// When the instantiation depth reaches the user-configurable limit
13809 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13810 // FIXME: Should we have a similar limit for other forms of synthesis?
13812
13813 /// The depth of the context stack at the point when the most recent
13814 /// error or warning was produced.
13815 ///
13816 /// This value is used to suppress printing of redundant context stacks
13817 /// when there are multiple errors or warnings in the same instantiation.
13818 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13820
13821 /// The current index into pack expansion arguments that will be
13822 /// used for substitution of parameter packs.
13823 ///
13824 /// The pack expansion index will be none to indicate that parameter packs
13825 /// should be instantiated as themselves. Otherwise, the index specifies
13826 /// which argument within the parameter pack will be used for substitution.
13828
13829 /// RAII object used to change the argument pack substitution index
13830 /// within a \c Sema object.
13831 ///
13832 /// See \c ArgPackSubstIndex for more information.
13834 Sema &Self;
13835 UnsignedOrNone OldSubstIndex;
13836
13837 public:
13839 : Self(Self),
13840 OldSubstIndex(std::exchange(Self.ArgPackSubstIndex, NewSubstIndex)) {}
13841
13842 ~ArgPackSubstIndexRAII() { Self.ArgPackSubstIndex = OldSubstIndex; }
13845 };
13846
13849
13860 /// Prints the current instantiation stack through a series of
13861 /// notes.
13866
13867 /// Returns a pointer to the current SFINAE context, if any.
13868 [[nodiscard]] SFINAETrap *getSFINAEContext() const {
13869 return CurrentSFINAEContext;
13870 }
13871 [[nodiscard]] bool isSFINAEContext() const {
13872 return CurrentSFINAEContext != nullptr;
13873 }
13874
13875 /// Perform substitution on the type T with a given set of template
13876 /// arguments.
13877 ///
13878 /// This routine substitutes the given template arguments into the
13879 /// type T and produces the instantiated type.
13880 ///
13881 /// \param T the type into which the template arguments will be
13882 /// substituted. If this type is not dependent, it will be returned
13883 /// immediately.
13884 ///
13885 /// \param Args the template arguments that will be
13886 /// substituted for the top-level template parameters within T.
13887 ///
13888 /// \param Loc the location in the source code where this substitution
13889 /// is being performed. It will typically be the location of the
13890 /// declarator (if we're instantiating the type of some declaration)
13891 /// or the location of the type in the source code (if, e.g., we're
13892 /// instantiating the type of a cast expression).
13893 ///
13894 /// \param Entity the name of the entity associated with a declaration
13895 /// being instantiated (if any). May be empty to indicate that there
13896 /// is no such entity (if, e.g., this is a type that occurs as part of
13897 /// a cast expression) or that the entity has no name (e.g., an
13898 /// unnamed function parameter).
13899 ///
13900 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13901 /// acceptable as the top level type of the result.
13902 ///
13903 /// \param IsIncompleteSubstitution If provided, the pointee will be set
13904 /// whenever substitution would perform a replacement with a null or
13905 /// non-existent template argument.
13906 ///
13907 /// \returns If the instantiation succeeds, the instantiated
13908 /// type. Otherwise, produces diagnostics and returns a NULL type.
13910 const MultiLevelTemplateArgumentList &TemplateArgs,
13911 SourceLocation Loc, DeclarationName Entity,
13912 bool AllowDeducedTST = false);
13913
13915 const MultiLevelTemplateArgumentList &TemplateArgs,
13916 SourceLocation Loc, DeclarationName Entity,
13917 bool *IsIncompleteSubstitution = nullptr);
13918
13920 const MultiLevelTemplateArgumentList &TemplateArgs,
13921 SourceLocation Loc, DeclarationName Entity);
13922
13925 const MultiLevelTemplateArgumentList &TemplateArgs,
13926 SourceLocation Loc, DeclarationName Entity);
13927
13928 /// A form of SubstType intended specifically for instantiating the
13929 /// type of a FunctionDecl. Its purpose is solely to force the
13930 /// instantiation of default-argument expressions and to avoid
13931 /// instantiating an exception-specification.
13933 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13934 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13935 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13937 const MultiLevelTemplateArgumentList &Args);
13940 SmallVectorImpl<QualType> &ExceptionStorage,
13941 const MultiLevelTemplateArgumentList &Args);
13942 ParmVarDecl *
13944 const MultiLevelTemplateArgumentList &TemplateArgs,
13945 int indexAdjustment, UnsignedOrNone NumExpansions,
13946 bool ExpectParameterPack, bool EvaluateConstraints = true);
13947
13948 /// Substitute the given template arguments into the given set of
13949 /// parameters, producing the set of parameter types that would be generated
13950 /// from such a substitution.
13952 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13953 const MultiLevelTemplateArgumentList &TemplateArgs,
13954 SmallVectorImpl<QualType> &ParamTypes,
13956 ExtParameterInfoBuilder &ParamInfos);
13957
13958 /// Substitute the given template arguments into the default argument.
13960 const MultiLevelTemplateArgumentList &TemplateArgs,
13961 bool ForCallExpr = false);
13963 const MultiLevelTemplateArgumentList &TemplateArgs);
13964 /// Substitute an expression as if it is a address-of-operand, which makes it
13965 /// act like a CXXIdExpression rather than an attempt to call.
13967 const MultiLevelTemplateArgumentList &TemplateArgs);
13968
13969 // Must be used instead of SubstExpr at 'constraint checking' time.
13972 const MultiLevelTemplateArgumentList &TemplateArgs);
13973 // Unlike the above, this does not evaluate constraints.
13975 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13976
13977 /// Substitute the given template arguments into a list of
13978 /// expressions, expanding pack expansions if required.
13979 ///
13980 /// \param Exprs The list of expressions to substitute into.
13981 ///
13982 /// \param IsCall Whether this is some form of call, in which case
13983 /// default arguments will be dropped.
13984 ///
13985 /// \param TemplateArgs The set of template arguments to substitute.
13986 ///
13987 /// \param Outputs Will receive all of the substituted arguments.
13988 ///
13989 /// \returns true if an error occurred, false otherwise.
13990 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13991 const MultiLevelTemplateArgumentList &TemplateArgs,
13992 SmallVectorImpl<Expr *> &Outputs);
13993
13995 const MultiLevelTemplateArgumentList &TemplateArgs);
13996
13999 bool CXXDirectInit);
14000
14001 /// Perform substitution on the base class specifiers of the
14002 /// given class template specialization.
14003 ///
14004 /// Produces a diagnostic and returns true on error, returns false and
14005 /// attaches the instantiated base classes to the class template
14006 /// specialization if successful.
14007 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
14008 const MultiLevelTemplateArgumentList &TemplateArgs);
14009
14010 /// Instantiate the definition of a class from a given pattern.
14011 ///
14012 /// \param PointOfInstantiation The point of instantiation within the
14013 /// source code.
14014 ///
14015 /// \param Instantiation is the declaration whose definition is being
14016 /// instantiated. This will be either a class template specialization
14017 /// or a member class of a class template specialization.
14018 ///
14019 /// \param Pattern is the pattern from which the instantiation
14020 /// occurs. This will be either the declaration of a class template or
14021 /// the declaration of a member class of a class template.
14022 ///
14023 /// \param TemplateArgs The template arguments to be substituted into
14024 /// the pattern.
14025 ///
14026 /// \param TSK the kind of implicit or explicit instantiation to perform.
14027 ///
14028 /// \param Complain whether to complain if the class cannot be instantiated
14029 /// due to the lack of a definition.
14030 ///
14031 /// \returns true if an error occurred, false otherwise.
14032 bool InstantiateClass(SourceLocation PointOfInstantiation,
14033 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
14034 const MultiLevelTemplateArgumentList &TemplateArgs,
14035 TemplateSpecializationKind TSK, bool Complain = true);
14036
14037private:
14038 bool InstantiateClassImpl(SourceLocation PointOfInstantiation,
14039 CXXRecordDecl *Instantiation,
14040 CXXRecordDecl *Pattern,
14041 const MultiLevelTemplateArgumentList &TemplateArgs,
14042 TemplateSpecializationKind TSK, bool Complain);
14043
14044public:
14045 /// Instantiate the definition of an enum from a given pattern.
14046 ///
14047 /// \param PointOfInstantiation The point of instantiation within the
14048 /// source code.
14049 /// \param Instantiation is the declaration whose definition is being
14050 /// instantiated. This will be a member enumeration of a class
14051 /// temploid specialization, or a local enumeration within a
14052 /// function temploid specialization.
14053 /// \param Pattern The templated declaration from which the instantiation
14054 /// occurs.
14055 /// \param TemplateArgs The template arguments to be substituted into
14056 /// the pattern.
14057 /// \param TSK The kind of implicit or explicit instantiation to perform.
14058 ///
14059 /// \return \c true if an error occurred, \c false otherwise.
14060 bool InstantiateEnum(SourceLocation PointOfInstantiation,
14061 EnumDecl *Instantiation, EnumDecl *Pattern,
14062 const MultiLevelTemplateArgumentList &TemplateArgs,
14064
14065 /// Instantiate the definition of a field from the given pattern.
14066 ///
14067 /// \param PointOfInstantiation The point of instantiation within the
14068 /// source code.
14069 /// \param Instantiation is the declaration whose definition is being
14070 /// instantiated. This will be a class of a class temploid
14071 /// specialization, or a local enumeration within a function temploid
14072 /// specialization.
14073 /// \param Pattern The templated declaration from which the instantiation
14074 /// occurs.
14075 /// \param TemplateArgs The template arguments to be substituted into
14076 /// the pattern.
14077 ///
14078 /// \return \c true if an error occurred, \c false otherwise.
14080 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
14081 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
14082
14084 SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
14085
14087 SourceLocation PointOfInstantiation,
14088 ClassTemplateSpecializationDecl *ClassTemplateSpec,
14089 TemplateSpecializationKind TSK, bool Complain,
14090 bool PrimaryStrictPackMatch);
14091
14092 /// Instantiates the definitions of all of the member
14093 /// of the given class, which is an instantiation of a class template
14094 /// or a member class of a template.
14095 void
14096 InstantiateClassMembers(SourceLocation PointOfInstantiation,
14097 CXXRecordDecl *Instantiation,
14098 const MultiLevelTemplateArgumentList &TemplateArgs,
14100
14101 /// Instantiate the definitions of all of the members of the
14102 /// given class template specialization, which was named as part of an
14103 /// explicit instantiation.
14105 SourceLocation PointOfInstantiation,
14106 ClassTemplateSpecializationDecl *ClassTemplateSpec,
14108
14111 const MultiLevelTemplateArgumentList &TemplateArgs);
14112
14113 /// Do template substitution on declaration name info.
14116 const MultiLevelTemplateArgumentList &TemplateArgs);
14118 SubstTemplateName(SourceLocation TemplateKWLoc,
14119 NestedNameSpecifierLoc &QualifierLoc, TemplateName Name,
14120 SourceLocation NameLoc,
14121 const MultiLevelTemplateArgumentList &TemplateArgs);
14122
14124 const MultiLevelTemplateArgumentList &TemplateArgs,
14125 bool EvaluateConstraint);
14126
14127 /// Determine whether we are currently performing template instantiation.
14130 }
14131
14132 /// Determine whether we are currently performing constraint substitution.
14134 return !CodeSynthesisContexts.empty() &&
14135 CodeSynthesisContexts.back().InConstraintSubstitution;
14136 }
14137
14139 return !CodeSynthesisContexts.empty() &&
14140 CodeSynthesisContexts.back().InParameterMappingSubstitution &&
14142 }
14143
14144 using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
14145
14146 /// \brief create a Requirement::SubstitutionDiagnostic with only a
14147 /// SubstitutedEntity and DiagLoc using ASTContext's allocator.
14150
14151 ///@}
14152
14153 //
14154 //
14155 // -------------------------------------------------------------------------
14156 //
14157 //
14158
14159 /// \name C++ Template Declaration Instantiation
14160 /// Implementations are in SemaTemplateInstantiateDecl.cpp
14161 ///@{
14162
14163public:
14164 /// An entity for which implicit template instantiation is required.
14165 ///
14166 /// The source location associated with the declaration is the first place in
14167 /// the source code where the declaration was "used". It is not necessarily
14168 /// the point of instantiation (which will be either before or after the
14169 /// namespace-scope declaration that triggered this implicit instantiation),
14170 /// However, it is the location that diagnostics should generally refer to,
14171 /// because users will need to know what code triggered the instantiation.
14172 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
14173
14174 /// The queue of implicit template instantiations that are required
14175 /// but have not yet been performed.
14176 std::deque<PendingImplicitInstantiation> PendingInstantiations;
14177
14178 /// Queue of implicit template instantiations that cannot be performed
14179 /// eagerly.
14181
14185
14186 /// The queue of implicit template instantiations that are required
14187 /// and must be performed within the current local scope.
14188 ///
14189 /// This queue is only used for member functions of local classes in
14190 /// templates, which must be instantiated in the same scope as their
14191 /// enclosing function, so that they can reference function-local
14192 /// types, static variables, enumerators, etc.
14193 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
14194
14196 public:
14198 : S(S), AtEndOfTU(AtEndOfTU) {
14199 SavedPendingLocalImplicitInstantiations.swap(
14200 S.PendingLocalImplicitInstantiations);
14201 }
14202
14203 void perform() {
14204 S.PerformPendingInstantiations(/*LocalOnly=*/true,
14205 /*AtEndOfTU=*/AtEndOfTU);
14206 }
14207
14209 assert(S.PendingLocalImplicitInstantiations.empty() &&
14210 "there shouldn't be any pending local implicit instantiations");
14211 SavedPendingLocalImplicitInstantiations.swap(
14212 S.PendingLocalImplicitInstantiations);
14213 }
14214
14218
14219 private:
14220 Sema &S;
14221 bool AtEndOfTU;
14222 std::deque<PendingImplicitInstantiation>
14223 SavedPendingLocalImplicitInstantiations;
14224 };
14225
14226 /// Records and restores the CurFPFeatures state on entry/exit of compound
14227 /// statements.
14229 public:
14234 FPOptionsOverride getOverrides() { return OldOverrides; }
14235
14236 private:
14237 Sema &S;
14238 FPOptions OldFPFeaturesState;
14239 FPOptionsOverride OldOverrides;
14240 LangOptions::FPEvalMethodKind OldEvalMethod;
14241 SourceLocation OldFPPragmaLocation;
14242 };
14243
14245 public:
14246 GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
14247 : S(S), Enabled(Enabled), AtEndOfTU(AtEndOfTU) {
14248 if (!Enabled)
14249 return;
14250
14251 S.SavedPendingInstantiations.emplace_back();
14252 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
14253
14254 S.SavedVTableUses.emplace_back();
14255 S.SavedVTableUses.back().swap(S.VTableUses);
14256 }
14257
14258 void perform() {
14259 if (Enabled) {
14260 S.DefineUsedVTables();
14261 S.PerformPendingInstantiations(/*LocalOnly=*/false,
14262 /*AtEndOfTU=*/AtEndOfTU);
14263 }
14264 }
14265
14267 if (!Enabled)
14268 return;
14269
14270 // Restore the set of pending vtables.
14271 assert(S.VTableUses.empty() &&
14272 "VTableUses should be empty before it is discarded.");
14273 S.VTableUses.swap(S.SavedVTableUses.back());
14274 S.SavedVTableUses.pop_back();
14275
14276 // Restore the set of pending implicit instantiations.
14277 if ((S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) &&
14278 AtEndOfTU) {
14279 assert(S.PendingInstantiations.empty() &&
14280 "PendingInstantiations should be empty before it is discarded.");
14281 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
14282 S.SavedPendingInstantiations.pop_back();
14283 } else {
14284 // Template instantiations in the PCH may be delayed until the TU.
14285 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
14286 S.PendingInstantiations.insert(
14287 S.PendingInstantiations.end(),
14288 S.SavedPendingInstantiations.back().begin(),
14289 S.SavedPendingInstantiations.back().end());
14290 S.SavedPendingInstantiations.pop_back();
14291 }
14292 }
14293
14295 delete;
14298
14299 private:
14300 Sema &S;
14301 bool Enabled;
14302 bool AtEndOfTU;
14303 };
14304
14306 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
14307
14318
14319 /// Recheck instantiated thread-safety attributes that could not be validated
14320 /// on the dependent pattern declaration.
14321 bool checkInstantiatedThreadSafetyAttrs(const Decl *D, const Attr *A);
14322
14323 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
14324 const Decl *Pattern, Decl *Inst,
14325 LateInstantiatedAttrVec *LateAttrs = nullptr,
14326 LocalInstantiationScope *OuterMostScope = nullptr);
14327
14328 /// Update instantiation attributes after template was late parsed.
14329 ///
14330 /// Some attributes are evaluated based on the body of template. If it is
14331 /// late parsed, such attributes cannot be evaluated when declaration is
14332 /// instantiated. This function is used to update instantiation attributes
14333 /// when template definition is ready.
14334 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
14335
14336 void
14338 const Decl *Pattern, Decl *Inst,
14339 LateInstantiatedAttrVec *LateAttrs = nullptr,
14340 LocalInstantiationScope *OuterMostScope = nullptr);
14341
14343 bool IsCopy = false);
14344
14346 ParmVarDecl *Param);
14347 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
14349
14350 /// Instantiate (or find existing instantiation of) a function template with a
14351 /// given set of template arguments.
14352 ///
14353 /// Usually this should not be used, and template argument deduction should be
14354 /// used in its place.
14357 SourceLocation Loc,
14360
14361 /// Instantiate the definition of the given function from its
14362 /// template.
14363 ///
14364 /// \param PointOfInstantiation the point at which the instantiation was
14365 /// required. Note that this is not precisely a "point of instantiation"
14366 /// for the function, but it's close.
14367 ///
14368 /// \param Function the already-instantiated declaration of a
14369 /// function template specialization or member function of a class template
14370 /// specialization.
14371 ///
14372 /// \param Recursive if true, recursively instantiates any functions that
14373 /// are required by this instantiation.
14374 ///
14375 /// \param DefinitionRequired if true, then we are performing an explicit
14376 /// instantiation where the body of the function is required. Complain if
14377 /// there is no such body.
14378 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
14380 bool Recursive = false,
14381 bool DefinitionRequired = false,
14382 bool AtEndOfTU = false);
14385 const TemplateArgumentList *PartialSpecArgs,
14387 SourceLocation PointOfInstantiation,
14388 LateInstantiatedAttrVec *LateAttrs = nullptr,
14389 LocalInstantiationScope *StartingScope = nullptr);
14390
14391 /// Instantiates a variable template specialization by completing it
14392 /// with appropriate type information and initializer.
14394 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
14395 const MultiLevelTemplateArgumentList &TemplateArgs);
14396
14397 /// BuildVariableInstantiation - Used after a new variable has been created.
14398 /// Sets basic variable data and decides whether to postpone the
14399 /// variable instantiation.
14400 void
14402 const MultiLevelTemplateArgumentList &TemplateArgs,
14403 LateInstantiatedAttrVec *LateAttrs,
14404 DeclContext *Owner,
14405 LocalInstantiationScope *StartingScope,
14406 bool InstantiatingVarTemplate = false,
14407 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
14408
14409 /// Instantiate the initializer of a variable.
14411 VarDecl *Var, VarDecl *OldVar,
14412 const MultiLevelTemplateArgumentList &TemplateArgs);
14413
14414 /// Instantiate the definition of the given variable from its
14415 /// template.
14416 ///
14417 /// \param PointOfInstantiation the point at which the instantiation was
14418 /// required. Note that this is not precisely a "point of instantiation"
14419 /// for the variable, but it's close.
14420 ///
14421 /// \param Var the already-instantiated declaration of a templated variable.
14422 ///
14423 /// \param Recursive if true, recursively instantiates any functions that
14424 /// are required by this instantiation.
14425 ///
14426 /// \param DefinitionRequired if true, then we are performing an explicit
14427 /// instantiation where a definition of the variable is required. Complain
14428 /// if there is no such definition.
14429 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
14430 VarDecl *Var, bool Recursive = false,
14431 bool DefinitionRequired = false,
14432 bool AtEndOfTU = false);
14433
14436 const MultiLevelTemplateArgumentList &TemplateArgs);
14437
14438 /// Find the instantiation of the given declaration within the
14439 /// current instantiation.
14440 ///
14441 /// This routine is intended to be used when \p D is a declaration
14442 /// referenced from within a template, that needs to mapped into the
14443 /// corresponding declaration within an instantiation. For example,
14444 /// given:
14445 ///
14446 /// \code
14447 /// template<typename T>
14448 /// struct X {
14449 /// enum Kind {
14450 /// KnownValue = sizeof(T)
14451 /// };
14452 ///
14453 /// bool getKind() const { return KnownValue; }
14454 /// };
14455 ///
14456 /// template struct X<int>;
14457 /// \endcode
14458 ///
14459 /// In the instantiation of X<int>::getKind(), we need to map the \p
14460 /// EnumConstantDecl for \p KnownValue (which refers to
14461 /// X<T>::<Kind>::KnownValue) to its instantiation
14462 /// (X<int>::<Kind>::KnownValue).
14463 /// \p FindInstantiatedDecl performs this mapping from within the
14464 /// instantiation of X<int>.
14465 NamedDecl *
14467 const MultiLevelTemplateArgumentList &TemplateArgs,
14468 bool FindingInstantiatedContext = false);
14469
14470 /// Finds the instantiation of the given declaration context
14471 /// within the current instantiation.
14472 ///
14473 /// \returns NULL if there was an error
14474 DeclContext *
14476 const MultiLevelTemplateArgumentList &TemplateArgs);
14477
14478 Decl *SubstDecl(Decl *D, DeclContext *Owner,
14479 const MultiLevelTemplateArgumentList &TemplateArgs);
14480
14481 /// Substitute the name and return type of a defaulted 'operator<=>' to form
14482 /// an implicit 'operator=='.
14484 FunctionDecl *Spaceship);
14485
14486 /// Performs template instantiation for all implicit template
14487 /// instantiations we have seen until this point.
14488 void PerformPendingInstantiations(bool LocalOnly = false,
14489 bool AtEndOfTU = true);
14490
14493 const MultiLevelTemplateArgumentList &TemplateArgs,
14494 bool EvaluateConstraints = true);
14495
14497 const DeclContext *Pattern,
14498 const MultiLevelTemplateArgumentList &TemplateArgs);
14499
14500private:
14501 /// Introduce the instantiated local variables into the local
14502 /// instantiation scope.
14503 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
14504 const FunctionDecl *PatternDecl,
14506 /// Introduce the instantiated function parameters into the local
14507 /// instantiation scope, and set the parameter names to those used
14508 /// in the template.
14509 bool addInstantiatedParametersToScope(
14510 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14512 const MultiLevelTemplateArgumentList &TemplateArgs);
14513
14514 /// Introduce the instantiated captures of the lambda into the local
14515 /// instantiation scope.
14516 bool addInstantiatedCapturesToScope(
14517 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14519 const MultiLevelTemplateArgumentList &TemplateArgs);
14520
14521 int ParsingClassDepth = 0;
14522
14523 class SavePendingParsedClassStateRAII {
14524 public:
14525 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
14526
14527 ~SavePendingParsedClassStateRAII() {
14528 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
14529 "there shouldn't be any pending delayed exception spec checks");
14530 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
14531 "there shouldn't be any pending delayed exception spec checks");
14532 swapSavedState();
14533 }
14534
14535 SavePendingParsedClassStateRAII(const SavePendingParsedClassStateRAII &) =
14536 delete;
14537 SavePendingParsedClassStateRAII &
14538 operator=(const SavePendingParsedClassStateRAII &) = delete;
14539
14540 private:
14541 Sema &S;
14543 SavedOverridingExceptionSpecChecks;
14545 SavedEquivalentExceptionSpecChecks;
14546
14547 void swapSavedState() {
14548 SavedOverridingExceptionSpecChecks.swap(
14549 S.DelayedOverridingExceptionSpecChecks);
14550 SavedEquivalentExceptionSpecChecks.swap(
14551 S.DelayedEquivalentExceptionSpecChecks);
14552 }
14553 };
14554
14555 ///@}
14556
14557 //
14558 //
14559 // -------------------------------------------------------------------------
14560 //
14561 //
14562
14563 /// \name C++ Variadic Templates
14564 /// Implementations are in SemaTemplateVariadic.cpp
14565 ///@{
14566
14567public:
14568 /// Determine whether an unexpanded parameter pack might be permitted in this
14569 /// location. Useful for error recovery.
14571
14572 /// The context in which an unexpanded parameter pack is
14573 /// being diagnosed.
14574 ///
14575 /// Note that the values of this enumeration line up with the first
14576 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
14578 /// An arbitrary expression.
14580
14581 /// The base type of a class type.
14583
14584 /// The type of an arbitrary declaration.
14586
14587 /// The type of a data member.
14589
14590 /// The size of a bit-field.
14592
14593 /// The expression in a static assertion.
14595
14596 /// The fixed underlying type of an enumeration.
14598
14599 /// The enumerator value.
14601
14602 /// A using declaration.
14604
14605 /// A friend declaration.
14607
14608 /// A declaration qualifier.
14610
14611 /// An initializer.
14613
14614 /// A default argument.
14616
14617 /// The type of a non-type template parameter.
14619
14620 /// The type of an exception.
14622
14623 /// Explicit specialization.
14625
14626 /// Partial specialization.
14628
14629 /// Microsoft __if_exists.
14631
14632 /// Microsoft __if_not_exists.
14634
14635 /// Lambda expression.
14637
14638 /// Block expression.
14640
14641 /// A type constraint.
14643
14644 // A requirement in a requires-expression.
14646
14647 // A requires-clause.
14649 };
14650
14651 /// Diagnose unexpanded parameter packs.
14652 ///
14653 /// \param Loc The location at which we should emit the diagnostic.
14654 ///
14655 /// \param UPPC The context in which we are diagnosing unexpanded
14656 /// parameter packs.
14657 ///
14658 /// \param Unexpanded the set of unexpanded parameter packs.
14659 ///
14660 /// \returns true if an error occurred, false otherwise.
14664
14665 /// If the given type contains an unexpanded parameter pack,
14666 /// diagnose the error.
14667 ///
14668 /// \param Loc The source location where a diagnostc should be emitted.
14669 ///
14670 /// \param T The type that is being checked for unexpanded parameter
14671 /// packs.
14672 ///
14673 /// \returns true if an error occurred, false otherwise.
14676
14677 /// If the given expression contains an unexpanded parameter
14678 /// pack, diagnose the error.
14679 ///
14680 /// \param E The expression that is being checked for unexpanded
14681 /// parameter packs.
14682 ///
14683 /// \returns true if an error occurred, false otherwise.
14686
14687 /// If the given requirees-expression contains an unexpanded reference to one
14688 /// of its own parameter packs, diagnose the error.
14689 ///
14690 /// \param RE The requiress-expression that is being checked for unexpanded
14691 /// parameter packs.
14692 ///
14693 /// \returns true if an error occurred, false otherwise.
14695
14696 /// If the given nested-name-specifier contains an unexpanded
14697 /// parameter pack, diagnose the error.
14698 ///
14699 /// \param SS The nested-name-specifier that is being checked for
14700 /// unexpanded parameter packs.
14701 ///
14702 /// \returns true if an error occurred, false otherwise.
14705
14706 /// If the given name contains an unexpanded parameter pack,
14707 /// diagnose the error.
14708 ///
14709 /// \param NameInfo The name (with source location information) that
14710 /// is being checked for unexpanded parameter packs.
14711 ///
14712 /// \returns true if an error occurred, false otherwise.
14715
14716 /// If the given template name contains an unexpanded parameter pack,
14717 /// diagnose the error.
14718 ///
14719 /// \param Loc The location of the template name.
14720 ///
14721 /// \param Template The template name that is being checked for unexpanded
14722 /// parameter packs.
14723 ///
14724 /// \returns true if an error occurred, false otherwise.
14728
14729 /// If the given template argument contains an unexpanded parameter
14730 /// pack, diagnose the error.
14731 ///
14732 /// \param Arg The template argument that is being checked for unexpanded
14733 /// parameter packs.
14734 ///
14735 /// \returns true if an error occurred, false otherwise.
14738
14739 /// Collect the set of unexpanded parameter packs within the given
14740 /// template argument.
14741 ///
14742 /// \param Arg The template argument that will be traversed to find
14743 /// unexpanded parameter packs.
14745 TemplateArgument Arg,
14747
14748 /// Collect the set of unexpanded parameter packs within the given
14749 /// template argument.
14750 ///
14751 /// \param Arg The template argument that will be traversed to find
14752 /// unexpanded parameter packs.
14756
14757 /// Collect the set of unexpanded parameter packs within the given
14758 /// type.
14759 ///
14760 /// \param T The type that will be traversed to find
14761 /// unexpanded parameter packs.
14764
14765 /// Collect the set of unexpanded parameter packs within the given
14766 /// template name.
14767 ///
14768 /// \param Template The template name that will be traversed to find
14769 /// unexpanded parameter packs.
14773
14774 /// Collect the set of unexpanded parameter packs within the given
14775 /// type.
14776 ///
14777 /// \param TL The type that will be traversed to find
14778 /// unexpanded parameter packs.
14781
14782 /// Collect the set of unexpanded parameter packs within the given
14783 /// nested-name-specifier.
14784 ///
14785 /// \param NNS The nested-name-specifier that will be traversed to find
14786 /// unexpanded parameter packs.
14790
14791 /// Collect the set of unexpanded parameter packs within the given
14792 /// name.
14793 ///
14794 /// \param NameInfo The name that will be traversed to find
14795 /// unexpanded parameter packs.
14797 const DeclarationNameInfo &NameInfo,
14799
14800 /// Collect the set of unexpanded parameter packs within the given
14801 /// expression.
14804
14805 /// Invoked when parsing a template argument.
14806 ///
14807 /// \param Arg the template argument, which may already be invalid.
14808 ///
14809 /// If it is followed by ellipsis, this function is called before
14810 /// `ActOnPackExpansion`.
14813
14814 /// Invoked when parsing a template argument followed by an
14815 /// ellipsis, which creates a pack expansion.
14816 ///
14817 /// \param Arg The template argument preceding the ellipsis, which
14818 /// may already be invalid.
14819 ///
14820 /// \param EllipsisLoc The location of the ellipsis.
14822 SourceLocation EllipsisLoc);
14823
14824 /// Invoked when parsing a type followed by an ellipsis, which
14825 /// creates a pack expansion.
14826 ///
14827 /// \param Type The type preceding the ellipsis, which will become
14828 /// the pattern of the pack expansion.
14829 ///
14830 /// \param EllipsisLoc The location of the ellipsis.
14832
14833 /// Construct a pack expansion type from the pattern of the pack
14834 /// expansion.
14836 SourceLocation EllipsisLoc,
14837 UnsignedOrNone NumExpansions);
14838
14839 /// Construct a pack expansion type from the pattern of the pack
14840 /// expansion.
14841 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14842 SourceLocation EllipsisLoc,
14843 UnsignedOrNone NumExpansions);
14844
14845 /// Invoked when parsing an expression followed by an ellipsis, which
14846 /// creates a pack expansion.
14847 ///
14848 /// \param Pattern The expression preceding the ellipsis, which will become
14849 /// the pattern of the pack expansion.
14850 ///
14851 /// \param EllipsisLoc The location of the ellipsis.
14852 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14853
14854 /// Invoked when parsing an expression followed by an ellipsis, which
14855 /// creates a pack expansion.
14856 ///
14857 /// \param Pattern The expression preceding the ellipsis, which will become
14858 /// the pattern of the pack expansion.
14859 ///
14860 /// \param EllipsisLoc The location of the ellipsis.
14861 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14862 UnsignedOrNone NumExpansions);
14863
14864 /// Determine whether we could expand a pack expansion with the
14865 /// given set of parameter packs into separate arguments by repeatedly
14866 /// transforming the pattern.
14867 ///
14868 /// \param EllipsisLoc The location of the ellipsis that identifies the
14869 /// pack expansion.
14870 ///
14871 /// \param PatternRange The source range that covers the entire pattern of
14872 /// the pack expansion.
14873 ///
14874 /// \param Unexpanded The set of unexpanded parameter packs within the
14875 /// pattern.
14876 ///
14877 /// \param ShouldExpand Will be set to \c true if the transformer should
14878 /// expand the corresponding pack expansions into separate arguments. When
14879 /// set, \c NumExpansions must also be set.
14880 ///
14881 /// \param RetainExpansion Whether the caller should add an unexpanded
14882 /// pack expansion after all of the expanded arguments. This is used
14883 /// when extending explicitly-specified template argument packs per
14884 /// C++0x [temp.arg.explicit]p9.
14885 ///
14886 /// \param NumExpansions The number of separate arguments that will be in
14887 /// the expanded form of the corresponding pack expansion. This is both an
14888 /// input and an output parameter, which can be set by the caller if the
14889 /// number of expansions is known a priori (e.g., due to a prior substitution)
14890 /// and will be set by the callee when the number of expansions is known.
14891 /// The callee must set this value when \c ShouldExpand is \c true; it may
14892 /// set this value in other cases.
14893 ///
14894 /// \returns true if an error occurred (e.g., because the parameter packs
14895 /// are to be instantiated with arguments of different lengths), false
14896 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14897 /// must be set.
14899 SourceLocation EllipsisLoc, SourceRange PatternRange,
14901 const MultiLevelTemplateArgumentList &TemplateArgs,
14902 bool FailOnPackProducingTemplates, bool &ShouldExpand,
14903 bool &RetainExpansion, UnsignedOrNone &NumExpansions,
14904 bool Diagnose = true);
14905
14906 /// Determine the number of arguments in the given pack expansion
14907 /// type.
14908 ///
14909 /// This routine assumes that the number of arguments in the expansion is
14910 /// consistent across all of the unexpanded parameter packs in its pattern.
14911 ///
14912 /// Returns an empty Optional if the type can't be expanded.
14914 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14915
14918 const MultiLevelTemplateArgumentList &TemplateArgs);
14919
14920 /// Determine whether the given declarator contains any unexpanded
14921 /// parameter packs.
14922 ///
14923 /// This routine is used by the parser to disambiguate function declarators
14924 /// with an ellipsis prior to the ')', e.g.,
14925 ///
14926 /// \code
14927 /// void f(T...);
14928 /// \endcode
14929 ///
14930 /// To determine whether we have an (unnamed) function parameter pack or
14931 /// a variadic function.
14932 ///
14933 /// \returns true if the declarator contains any unexpanded parameter packs,
14934 /// false otherwise.
14936
14937 /// Returns the pattern of the pack expansion for a template argument.
14938 ///
14939 /// \param OrigLoc The template argument to expand.
14940 ///
14941 /// \param Ellipsis Will be set to the location of the ellipsis.
14942 ///
14943 /// \param NumExpansions Will be set to the number of expansions that will
14944 /// be generated from this pack expansion, if known a priori.
14947 SourceLocation &Ellipsis,
14948 UnsignedOrNone &NumExpansions) const;
14949
14950 /// Given a template argument that contains an unexpanded parameter pack, but
14951 /// which has already been substituted, attempt to determine the number of
14952 /// elements that will be produced once this argument is fully-expanded.
14953 ///
14954 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14955 /// avoid actually expanding the pack where possible.
14957
14958 /// Called when an expression computing the size of a parameter pack
14959 /// is parsed.
14960 ///
14961 /// \code
14962 /// template<typename ...Types> struct count {
14963 /// static const unsigned value = sizeof...(Types);
14964 /// };
14965 /// \endcode
14966 ///
14967 //
14968 /// \param OpLoc The location of the "sizeof" keyword.
14969 /// \param Name The name of the parameter pack whose size will be determined.
14970 /// \param NameLoc The source location of the name of the parameter pack.
14971 /// \param RParenLoc The location of the closing parentheses.
14973 IdentifierInfo &Name,
14974 SourceLocation NameLoc,
14975 SourceLocation RParenLoc);
14976
14977 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14978 SourceLocation EllipsisLoc,
14979 SourceLocation LSquareLoc, Expr *IndexExpr,
14980 SourceLocation RSquareLoc);
14981
14982 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14983 SourceLocation EllipsisLoc, Expr *IndexExpr,
14984 SourceLocation RSquareLoc,
14985 ArrayRef<Expr *> ExpandedExprs = {},
14986 bool FullySubstituted = false);
14987
14989 SourceLocation NameLoc,
14990 Expr *IndexExpr);
14991
14993 BuildPackIndexingTemplateName(TemplateName Pattern, Expr *IndexExpr,
14994 bool FullySubstituted = false,
14995 ArrayRef<TemplateName> Expansions = {});
14996
14999 SourceLocation NameLoc);
15000
15001 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
15002 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
15003 tok::TokenKind Operator,
15004 SourceLocation EllipsisLoc, Expr *RHS,
15005 SourceLocation RParenLoc);
15006 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
15007 SourceLocation LParenLoc, Expr *LHS,
15008 BinaryOperatorKind Operator,
15009 SourceLocation EllipsisLoc, Expr *RHS,
15010 SourceLocation RParenLoc,
15011 UnsignedOrNone NumExpansions);
15012 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
15013 BinaryOperatorKind Operator);
15014
15015 ///@}
15016
15017 //
15018 //
15019 // -------------------------------------------------------------------------
15020 //
15021 //
15022
15023 /// \name Constraints and Concepts
15024 /// Implementations are in SemaConcept.cpp
15025 ///@{
15026
15027public:
15028 ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, TypeSourceInfo *TSI);
15029
15030 ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc,
15031 TypeSourceInfo *TSI);
15032
15033public:
15035 const llvm::FoldingSetNodeID &ID) {
15036 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
15037 SatisfactionStack.emplace_back(Can, ID);
15038 }
15039
15040 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
15041
15043 const llvm::FoldingSetNodeID &ID) const {
15044 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
15045 return llvm::is_contained(SatisfactionStack,
15046 SatisfactionStackEntryTy{Can, ID});
15047 }
15048
15050 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
15051
15052 // Resets the current SatisfactionStack for cases where we are instantiating
15053 // constraints as a 'side effect' of normal instantiation in a way that is not
15054 // indicative of recursive definition.
15057 Sema &SemaRef;
15058
15059 public:
15061 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
15062 }
15063
15065 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
15066 }
15067
15071 };
15072
15075 SatisfactionStack.swap(NewSS);
15076 }
15077
15079 llvm::PointerUnion<const NamedDecl *,
15081
15082 /// Check whether the given expression is a valid constraint expression.
15083 /// A diagnostic is emitted if it is not, false is returned, and
15084 /// PossibleNonPrimary will be set to true if the failure might be due to a
15085 /// non-primary expression being used as an atomic constraint.
15086 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
15087 bool *PossibleNonPrimary = nullptr,
15088 bool IsTrailingRequiresClause = false);
15089
15090 /// \brief Check whether the given list of constraint expressions are
15091 /// satisfied (as if in a 'conjunction') given template arguments.
15092 /// \param Template the template-like entity that triggered the constraints
15093 /// check (either a concept or a constrained entity).
15094 /// \param ConstraintExprs a list of constraint expressions, treated as if
15095 /// they were 'AND'ed together.
15096 /// \param TemplateArgLists the list of template arguments to substitute into
15097 /// the constraint expression.
15098 /// \param TemplateIDRange The source range of the template id that
15099 /// caused the constraints check.
15100 /// \param Satisfaction if true is returned, will contain details of the
15101 /// satisfaction, with enough information to diagnose an unsatisfied
15102 /// expression.
15103 /// \returns true if an error occurred and satisfaction could not be checked,
15104 /// false otherwise.
15107 ArrayRef<AssociatedConstraint> AssociatedConstraints,
15108 const MultiLevelTemplateArgumentList &TemplateArgLists,
15109 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction,
15110 const ConceptReference *TopLevelConceptId = nullptr,
15111 Expr **ConvertedExpr = nullptr);
15112
15113 /// Check whether the given function decl's trailing requires clause is
15114 /// satisfied, if any. Returns false and updates Satisfaction with the
15115 /// satisfaction verdict if successful, emits a diagnostic and returns true if
15116 /// an error occurred and satisfaction could not be determined.
15117 ///
15118 /// \returns true if an error occurred, false otherwise.
15120 ConstraintSatisfaction &Satisfaction,
15121 SourceLocation UsageLoc = SourceLocation(),
15122 bool ForOverloadResolution = false);
15123
15124 // Calculates whether two constraint expressions are equal irrespective of a
15125 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
15126 // 'New', which are the "source" of the constraint, since this is necessary
15127 // for figuring out the relative 'depth' of the constraint. The depth of the
15128 // 'primary template' and the 'instantiated from' templates aren't necessarily
15129 // the same, such as a case when one is a 'friend' defined in a class.
15131 const Expr *OldConstr,
15133 const Expr *NewConstr);
15134
15135 // Calculates whether the friend function depends on an enclosing template for
15136 // the purposes of [temp.friend] p9.
15138
15139 /// \brief Ensure that the given template arguments satisfy the constraints
15140 /// associated with the given template, emitting a diagnostic if they do not.
15141 ///
15142 /// \param Template The template to which the template arguments are being
15143 /// provided.
15144 ///
15145 /// \param TemplateArgs The converted, canonicalized template arguments.
15146 ///
15147 /// \param TemplateIDRange The source range of the template id that
15148 /// caused the constraints check.
15149 ///
15150 /// \returns true if the constrains are not satisfied or could not be checked
15151 /// for satisfaction, false if the constraints are satisfied.
15154 const MultiLevelTemplateArgumentList &TemplateArgs,
15155 SourceRange TemplateIDRange);
15156
15157 bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation,
15159 ArrayRef<TemplateArgument> TemplateArgs,
15160 ConstraintSatisfaction &Satisfaction);
15161
15162 /// \brief Emit diagnostics explaining why a constraint expression was deemed
15163 /// unsatisfied.
15164 /// \param First whether this is the first time an unsatisfied constraint is
15165 /// diagnosed for this error.
15167 SourceLocation Loc = {},
15168 bool First = true);
15169
15170 /// \brief Emit diagnostics explaining why a constraint expression was deemed
15171 /// unsatisfied.
15172 void
15174 bool First = true);
15175
15177 bool First = true);
15178
15181 ArrayRef<AssociatedConstraint> AssociatedConstraints);
15182
15183 /// \brief Check whether the given declaration's associated constraints are
15184 /// at least as constrained than another declaration's according to the
15185 /// partial ordering of constraints.
15186 ///
15187 /// \param Result If no error occurred, receives the result of true if D1 is
15188 /// at least constrained than D2, and false otherwise.
15189 ///
15190 /// \returns true if an error occurred, false otherwise.
15191 bool IsAtLeastAsConstrained(const NamedDecl *D1,
15193 const NamedDecl *D2,
15195 bool &Result);
15196
15197 /// If D1 was not at least as constrained as D2, but would've been if a pair
15198 /// of atomic constraints involved had been declared in a concept and not
15199 /// repeated in two separate places in code.
15200 /// \returns true if such a diagnostic was emitted, false otherwise.
15204
15205private:
15208
15209 UnsignedOrNone EvaluateFoldExpandedConstraintSize(
15210 const Expr *Pattern, const MultiLevelTemplateArgumentList &MLTAL);
15211
15212 /// Cache the satisfaction of an atomic constraint.
15213 /// The key is based on the unsubstituted expression and the parameter
15214 /// mapping. This lets us not substituting the mapping more than once,
15215 /// which is (very!) expensive.
15216 llvm::DenseMap<llvm::FoldingSetNodeID,
15218 UnsubstitutedConstraintSatisfactionCache;
15219
15220 /// Cache the instantiation results of template parameter mappings within
15221 /// concepts. Substituting into normalized concepts can be extremely expensive
15222 /// due to the redundancy of template parameters. This cache is intended for
15223 /// use by TemplateInstantiator to avoid redundant semantic checking.
15224 llvm::DenseMap<llvm::FoldingSetNodeID, TemplateArgumentLoc>
15225 *CurrentCachedTemplateArgs = nullptr;
15226
15227 /// Caches pairs of template-like decls whose associated constraints were
15228 /// checked for subsumption and whether or not the first's constraints did in
15229 /// fact subsume the second's.
15230 llvm::DenseMap<std::pair<const NamedDecl *, const NamedDecl *>, bool>
15231 SubsumptionCache;
15232 /// Caches the normal form of constraint expressions (and their pack
15233 /// substitution index). These are shared by e.g. the members of all
15234 /// specializations of a class template. If an error occurred while
15235 /// normalizing an expression, nullptr will be cached here.
15236 llvm::DenseMap<std::pair<const Expr *, unsigned>, NormalizedConstraint *>
15237 NormalizedConstraintExprCache;
15238
15239 /// Cache whether the associated constraint of a declaration
15240 /// is satisfied.
15241 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
15242 SatisfactionCache;
15243
15244 // The current stack of constraint satisfactions, so we can exit-early.
15246
15247 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to set up the
15248 /// LocalInstantiationScope of the current non-lambda function. For lambdas,
15249 /// use LambdaScopeForCallOperatorInstantiationRAII.
15250 bool
15251 SetupConstraintScope(FunctionDecl *FD,
15252 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
15253 const MultiLevelTemplateArgumentList &MLTAL,
15255
15256 /// Used during constraint checking, sets up the constraint template argument
15257 /// lists, and calls SetupConstraintScope to set up the
15258 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
15259 std::optional<MultiLevelTemplateArgumentList>
15260 SetupConstraintCheckingTemplateArgumentsAndScope(
15261 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
15263
15264 ///@}
15265
15266 //
15267 //
15268 // -------------------------------------------------------------------------
15269 //
15270 //
15271
15272 /// \name Types
15273 /// Implementations are in SemaType.cpp
15274 ///@{
15275
15276public:
15277 /// A mapping that describes the nullability we've seen in each header file.
15279
15280 static int getPrintable(int I) { return I; }
15281 static unsigned getPrintable(unsigned I) { return I; }
15282 static bool getPrintable(bool B) { return B; }
15283 static const char *getPrintable(const char *S) { return S; }
15284 static StringRef getPrintable(StringRef S) { return S; }
15285 static const std::string &getPrintable(const std::string &S) { return S; }
15286 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
15287 return II;
15288 }
15290 static QualType getPrintable(QualType T) { return T; }
15291 static SourceRange getPrintable(SourceRange R) { return R; }
15293 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
15295
15296 enum class CompleteTypeKind {
15297 /// Apply the normal rules for complete types. In particular,
15298 /// treat all sizeless types as incomplete.
15300
15301 /// Relax the normal rules for complete types so that they include
15302 /// sizeless built-in types.
15304
15305 // FIXME: Eventually we should flip the default to Normal and opt in
15306 // to AcceptSizeless rather than opt out of it.
15308 };
15309
15311 const DeclSpec *DS = nullptr);
15313 const DeclSpec *DS = nullptr);
15314
15315 /// Build a pointer type.
15316 ///
15317 /// \param T The type to which we'll be building a pointer.
15318 ///
15319 /// \param Loc The location of the entity whose type involves this
15320 /// pointer type or, if there is no such entity, the location of the
15321 /// type that will have pointer type.
15322 ///
15323 /// \param Entity The name of the entity that involves the pointer
15324 /// type, if known.
15325 ///
15326 /// \returns A suitable pointer type, if there are no
15327 /// errors. Otherwise, returns a NULL type.
15329 DeclarationName Entity);
15330
15331 /// Build a reference type.
15332 ///
15333 /// \param T The type to which we'll be building a reference.
15334 ///
15335 /// \param Loc The location of the entity whose type involves this
15336 /// reference type or, if there is no such entity, the location of the
15337 /// type that will have reference type.
15338 ///
15339 /// \param Entity The name of the entity that involves the reference
15340 /// type, if known.
15341 ///
15342 /// \returns A suitable reference type, if there are no
15343 /// errors. Otherwise, returns a NULL type.
15345 DeclarationName Entity);
15346
15347 /// Build an array type.
15348 ///
15349 /// \param T The type of each element in the array.
15350 ///
15351 /// \param ASM C99 array size modifier (e.g., '*', 'static').
15352 ///
15353 /// \param ArraySize Expression describing the size of the array.
15354 ///
15355 /// \param Brackets The range from the opening '[' to the closing ']'.
15356 ///
15357 /// \param Entity The name of the entity that involves the array
15358 /// type, if known.
15359 ///
15360 /// \returns A suitable array type, if there are no errors. Otherwise,
15361 /// returns a NULL type.
15363 unsigned Quals, SourceRange Brackets,
15364 DeclarationName Entity);
15365
15366 /// Diagnose an array of \p NumElements elements of type \p ElementType
15367 /// that is too large. Returns true if a diagnostic was emitted.
15368 bool checkArrayTooLarge(QualType ElementType, const llvm::APSInt &NumElements,
15369 SourceLocation Loc,
15370 SourceRange Range = SourceRange());
15372
15373 /// Build an ext-vector type.
15374 ///
15375 /// Run the required checks for the extended vector type.
15377 SourceLocation AttrLoc);
15378 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
15379 SourceLocation AttrLoc);
15380
15382 Expr *CountExpr,
15383 bool CountInBytes,
15384 bool OrNull);
15385
15386 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
15387 /// expression is uninstantiated. If instantiated it will apply the
15388 /// appropriate address space to the type. This function allows dependent
15389 /// template variables to be used in conjunction with the address_space
15390 /// attribute
15391 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
15392 SourceLocation AttrLoc);
15393
15394 /// Same as above, but constructs the AddressSpace index if not provided.
15396 SourceLocation AttrLoc);
15397
15399
15401
15402 /// Build a function type.
15403 ///
15404 /// This routine checks the function type according to C++ rules and
15405 /// under the assumption that the result type and parameter types have
15406 /// just been instantiated from a template. It therefore duplicates
15407 /// some of the behavior of GetTypeForDeclarator, but in a much
15408 /// simpler form that is only suitable for this narrow use case.
15409 ///
15410 /// \param T The return type of the function.
15411 ///
15412 /// \param ParamTypes The parameter types of the function. This array
15413 /// will be modified to account for adjustments to the types of the
15414 /// function parameters.
15415 ///
15416 /// \param Loc The location of the entity whose type involves this
15417 /// function type or, if there is no such entity, the location of the
15418 /// type that will have function type.
15419 ///
15420 /// \param Entity The name of the entity that involves the function
15421 /// type, if known.
15422 ///
15423 /// \param EPI Extra information about the function type. Usually this will
15424 /// be taken from an existing function with the same prototype.
15425 ///
15426 /// \returns A suitable function type, if there are no errors. The
15427 /// unqualified type will always be a FunctionProtoType.
15428 /// Otherwise, returns a NULL type.
15430 SourceLocation Loc, DeclarationName Entity,
15432
15433 /// Build a member pointer type \c T Class::*.
15434 ///
15435 /// \param T the type to which the member pointer refers.
15436 /// \param Class the class type into which the member pointer points.
15437 /// \param Loc the location where this type begins
15438 /// \param Entity the name of the entity that will have this member pointer
15439 /// type
15440 ///
15441 /// \returns a member pointer type, if successful, or a NULL type if there was
15442 /// an error.
15444 CXXRecordDecl *Cls, SourceLocation Loc,
15445 DeclarationName Entity);
15446
15447 /// Build a block pointer type.
15448 ///
15449 /// \param T The type to which we'll be building a block pointer.
15450 ///
15451 /// \param Loc The source location, used for diagnostics.
15452 ///
15453 /// \param Entity The name of the entity that involves the block pointer
15454 /// type, if known.
15455 ///
15456 /// \returns A suitable block pointer type, if there are no
15457 /// errors. Otherwise, returns a NULL type.
15459 DeclarationName Entity);
15460
15461 /// Build a paren type including \p T.
15464
15465 /// Build a Read-only Pipe type.
15466 ///
15467 /// \param T The type to which we'll be building a Pipe.
15468 ///
15469 /// \param Loc We do not use it for now.
15470 ///
15471 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15472 /// a NULL type.
15474
15475 /// Build a Write-only Pipe type.
15476 ///
15477 /// \param T The type to which we'll be building a Pipe.
15478 ///
15479 /// \param Loc We do not use it for now.
15480 ///
15481 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15482 /// a NULL type.
15484
15485 /// Build a bit-precise integer type.
15486 ///
15487 /// \param IsUnsigned Boolean representing the signedness of the type.
15488 ///
15489 /// \param BitWidth Size of this int type in bits, or an expression
15490 /// representing that.
15491 ///
15492 /// \param Loc Location of the keyword.
15493 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
15494
15495 /// GetTypeForDeclarator - Convert the type for the specified
15496 /// declarator to Type instances.
15497 ///
15498 /// The result of this call will never be null, but the associated
15499 /// type may be a null type if there's an unrecoverable error.
15502
15503 /// Package the given type and TSI into a ParsedType.
15506 TypeSourceInfo **TInfo = nullptr);
15507
15509
15510 // Check whether the size of array element of type \p EltTy is a multiple of
15511 // its alignment and return false if it isn't.
15513
15514 void
15515 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
15516 SourceLocation FallbackLoc,
15517 SourceLocation ConstQualLoc = SourceLocation(),
15518 SourceLocation VolatileQualLoc = SourceLocation(),
15519 SourceLocation RestrictQualLoc = SourceLocation(),
15520 SourceLocation AtomicQualLoc = SourceLocation(),
15521 SourceLocation UnalignedQualLoc = SourceLocation());
15522
15523 /// Retrieve the keyword associated
15525
15526 /// Adjust the calling convention of a method to be the ABI default if it
15527 /// wasn't specified explicitly. This handles method types formed from
15528 /// function type typedefs and typename template arguments.
15529 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
15530 bool IsCtorOrDtor, SourceLocation Loc);
15531
15532 // Check if there is an explicit attribute, but only look through parens.
15533 // The intent is to look for an attribute on the current declarator, but not
15534 // one that came from a typedef.
15536
15537 /// Check whether a nullability type specifier can be added to the given
15538 /// type through some means not written in source (e.g. API notes).
15539 ///
15540 /// \param Type The type to which the nullability specifier will be
15541 /// added. On success, this type will be updated appropriately.
15542 ///
15543 /// \param Nullability The nullability specifier to add.
15544 ///
15545 /// \param DiagLoc The location to use for diagnostics.
15546 ///
15547 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
15548 /// array type (e.g., because it will decay to a pointer).
15549 ///
15550 /// \param OverrideExisting Whether to override an existing, locally-specified
15551 /// nullability specifier rather than complaining about the conflict.
15552 ///
15553 /// \returns true if nullability cannot be applied, false otherwise.
15555 NullabilityKind Nullability,
15556 SourceLocation DiagLoc,
15557 bool AllowArrayTypes,
15558 bool OverrideExisting);
15559
15560 /// Check whether the given variable declaration has a size that fits within
15561 /// the address space it is declared in. This issues a diagnostic if not.
15562 ///
15563 /// \param VD The variable declaration to check the size of.
15564 ///
15565 /// \param AS The address space to check the size of \p VD against.
15566 ///
15567 /// \returns true if the variable's size fits within the address space, false
15568 /// otherwise.
15569 bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS);
15570
15571 /// Get the type of expression E, triggering instantiation to complete the
15572 /// type if necessary -- that is, if the expression refers to a templated
15573 /// static data member of incomplete array type.
15574 ///
15575 /// May still return an incomplete type if instantiation was not possible or
15576 /// if the type is incomplete for a different reason. Use
15577 /// RequireCompleteExprType instead if a diagnostic is expected for an
15578 /// incomplete expression type.
15580
15582
15583 /// Ensure that the type of the given expression is complete.
15584 ///
15585 /// This routine checks whether the expression \p E has a complete type. If
15586 /// the expression refers to an instantiable construct, that instantiation is
15587 /// performed as needed to complete its type. Furthermore
15588 /// Sema::RequireCompleteType is called for the expression's type (or in the
15589 /// case of a reference type, the referred-to type).
15590 ///
15591 /// \param E The expression whose type is required to be complete.
15592 /// \param Kind Selects which completeness rules should be applied.
15593 /// \param Diagnoser The object that will emit a diagnostic if the type is
15594 /// incomplete.
15595 ///
15596 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
15597 /// otherwise.
15599 TypeDiagnoser &Diagnoser);
15600 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
15601
15602 template <typename... Ts>
15603 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
15604 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15606 }
15607
15608 // Returns the underlying type of a decltype with the given expression.
15610
15612 /// If AsUnevaluated is false, E is treated as though it were an evaluated
15613 /// context, such as when building a type for decltype(auto).
15614 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
15615
15616 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
15617 SourceLocation Loc,
15618 SourceLocation EllipsisLoc);
15619 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
15620 SourceLocation Loc, SourceLocation EllipsisLoc,
15621 bool FullySubstituted = false,
15622 ArrayRef<QualType> Expansions = {});
15623
15624 using UTTKind = UnaryTransformType::UTTKind;
15626 SourceLocation Loc);
15632 SourceLocation Loc);
15634 SourceLocation Loc);
15636 SourceLocation Loc);
15637
15639 return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc);
15640 }
15641
15643 SourceLocation Loc);
15645 SourceLocation Loc);
15646
15647 bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);
15648
15649 /// Ensure that the type T is a literal type.
15650 ///
15651 /// This routine checks whether the type @p T is a literal type. If @p T is an
15652 /// incomplete type, an attempt is made to complete it. If @p T is a literal
15653 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
15654 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
15655 /// it the type @p T), along with notes explaining why the type is not a
15656 /// literal type, and returns true.
15657 ///
15658 /// @param Loc The location in the source that the non-literal type
15659 /// diagnostic should refer to.
15660 ///
15661 /// @param T The type that this routine is examining for literalness.
15662 ///
15663 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
15664 ///
15665 /// @returns @c true if @p T is not a literal type and a diagnostic was
15666 /// emitted, @c false otherwise.
15668 TypeDiagnoser &Diagnoser);
15669 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
15670
15671 template <typename... Ts>
15672 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
15673 const Ts &...Args) {
15674 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15675 return RequireLiteralType(Loc, T, Diagnoser);
15676 }
15677
15680 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
15681 }
15682
15683 /// Ensure that the type T is a complete type.
15684 ///
15685 /// This routine checks whether the type @p T is complete in any
15686 /// context where a complete type is required. If @p T is a complete
15687 /// type, returns false. If @p T is a class template specialization,
15688 /// this routine then attempts to perform class template
15689 /// instantiation. If instantiation fails, or if @p T is incomplete
15690 /// and cannot be completed, issues the diagnostic @p diag (giving it
15691 /// the type @p T) and returns true.
15692 ///
15693 /// @param Loc The location in the source that the incomplete type
15694 /// diagnostic should refer to.
15695 ///
15696 /// @param T The type that this routine is examining for completeness.
15697 ///
15698 /// @param Kind Selects which completeness rules should be applied.
15699 ///
15700 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
15701 /// @c false otherwise.
15703 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
15705 CompleteTypeKind Kind, unsigned DiagID);
15706
15708 TypeDiagnoser &Diagnoser) {
15709 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, Diagnoser);
15710 }
15711 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID) {
15712 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, DiagID);
15713 }
15714
15715 template <typename... Ts>
15716 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
15717 const Ts &...Args) {
15718 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15719 return RequireCompleteType(Loc, T, Diagnoser);
15720 }
15721
15722 /// Determine whether a declaration is visible to name lookup.
15723 bool isVisible(const NamedDecl *D) {
15724 return D->isUnconditionallyVisible() ||
15725 isAcceptableSlow(D, AcceptableKind::Visible);
15726 }
15727
15728 /// Determine whether a declaration is reachable.
15729 bool isReachable(const NamedDecl *D) {
15730 // All visible declarations are reachable.
15731 return D->isUnconditionallyVisible() ||
15732 isAcceptableSlow(D, AcceptableKind::Reachable);
15733 }
15734
15735 /// Determine whether a declaration is acceptable (visible/reachable).
15737 return Kind == AcceptableKind::Visible ? isVisible(D) : isReachable(D);
15738 }
15739
15740 /// Determine if \p D and \p Suggested have a structurally compatible
15741 /// layout as described in C11 6.2.7/1.
15742 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15743
15744 /// Determine if \p D has a visible definition. If not, suggest a declaration
15745 /// that should be made visible to expose the definition.
15746 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15747 bool OnlyNeedComplete = false);
15749 NamedDecl *Hidden;
15750 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15751 }
15752 /// Determine if \p D has a definition which allows we redefine it in current
15753 /// TU. \p Suggested is the definition that should be made visible to expose
15754 /// the definition.
15755 bool isRedefinitionAllowedFor(NamedDecl *D, SourceLocation NewDefinitionLoc,
15756 NamedDecl **Suggested, bool &Visible);
15758 bool &Visible) {
15759 NamedDecl *Hidden;
15760 return isRedefinitionAllowedFor(const_cast<NamedDecl *>(D), NewLoc, &Hidden,
15761 Visible);
15762 }
15763
15764 /// Determine if \p D has a reachable definition. If not, suggest a
15765 /// declaration that should be made reachable to expose the definition.
15766 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15767 bool OnlyNeedComplete = false);
15769 NamedDecl *Hidden;
15770 return hasReachableDefinition(D, &Hidden);
15771 }
15772
15773 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15774 AcceptableKind Kind,
15775 bool OnlyNeedComplete = false);
15777 NamedDecl *Hidden;
15778 return hasAcceptableDefinition(D, &Hidden, Kind);
15779 }
15780
15781 /// Determine if a definition at \p NewLoc coincides with \p PrevD.
15782 ///
15783 /// Including the same header as a non-modular and a modular allows to process
15784 /// its content twice despite guards against multiple inclusions. To handle
15785 /// such cases this method allows to detect if a currently-parsed decl is at
15786 /// the same location as an existing decl imported from a module.
15787 bool isFromSameSingleIncludeHeader(const Decl *PrevD, SourceLocation NewLoc);
15788
15789 /// Try to parse the conditional expression attached to an effect attribute
15790 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
15791 /// optional on error.
15792 std::optional<FunctionEffectMode>
15793 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
15794
15795 void ActOnCleanupAttr(Decl *D, const Attr *A);
15796 void ActOnInitPriorityAttr(Decl *D, const Attr *A);
15797
15798private:
15799 /// The implementation of RequireCompleteType
15800 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15801 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15802
15803 /// Nullability type specifiers.
15804 IdentifierInfo *Ident__Nonnull = nullptr;
15805 IdentifierInfo *Ident__Nullable = nullptr;
15806 IdentifierInfo *Ident__Nullable_result = nullptr;
15807 IdentifierInfo *Ident__Null_unspecified = nullptr;
15808
15809 ///@}
15810
15811 //
15812 //
15813 // -------------------------------------------------------------------------
15814 //
15815 //
15816
15817 /// \name FixIt Helpers
15818 /// Implementations are in SemaFixItUtils.cpp
15819 ///@{
15820
15821public:
15822 /// Get a string to suggest for zero-initialization of a type.
15824 SourceLocation Loc) const;
15825 std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
15826
15827 ///@}
15828
15829 //
15830 //
15831 // -------------------------------------------------------------------------
15832 //
15833 //
15834
15835 /// \name Function Effects
15836 /// Implementations are in SemaFunctionEffects.cpp
15837 ///@{
15838public:
15841
15844 std::optional<FunctionEffectWithCondition>
15845 Old; // Invalid when 'Kind' is 'Added'.
15846 std::optional<FunctionEffectWithCondition>
15847 New; // Invalid when 'Kind' is 'Removed'.
15848
15849 StringRef effectName() const {
15850 if (Old)
15851 return Old.value().Effect.name();
15852 return New.value().Effect.name();
15853 }
15854
15855 /// Describes the result of effects differing between a base class's virtual
15856 /// method and an overriding method in a subclass.
15857 enum class OverrideResult {
15860 Merge // Merge missing effect from base to derived.
15861 };
15862
15863 /// Return true if adding or removing the effect as part of a type
15864 /// conversion should generate a diagnostic.
15866 const FunctionEffectsRef &SrcFX,
15867 QualType DstType,
15868 const FunctionEffectsRef &DstFX) const;
15869
15870 /// Return true if adding or removing the effect in a redeclaration should
15871 /// generate a diagnostic.
15872 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
15873 const FunctionEffectsRef &OldFX,
15874 const FunctionDecl &NewFunction,
15875 const FunctionEffectsRef &NewFX) const;
15876
15877 /// Return true if adding or removing the effect in a C++ virtual method
15878 /// override should generate a diagnostic.
15880 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
15881 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
15882 };
15883
15884 struct FunctionEffectDiffVector : public SmallVector<FunctionEffectDiff> {
15885 /// Caller should short-circuit by checking for equality first.
15887 const FunctionEffectsRef &New);
15888 };
15889
15890 /// All functions/lambdas/blocks which have bodies and which have a non-empty
15891 /// FunctionEffectsRef to be verified.
15893
15894 /// The union of all effects present on DeclsWithEffectsToVerify. Conditions
15895 /// are all null.
15897
15898public:
15899 /// Warn and return true if adding a function effect to a set would create a
15900 /// conflict.
15903 SourceLocation NewAttrLoc);
15904
15905 // Report a failure to merge function effects between declarations due to a
15906 // conflict.
15907 void
15909 SourceLocation NewLoc,
15910 SourceLocation OldLoc);
15911
15912 /// Inline checks from the start of maybeAddDeclWithEffects, to
15913 /// minimize performance impact on code not using effects.
15914 template <class FuncOrBlockDecl>
15915 void maybeAddDeclWithEffects(FuncOrBlockDecl *D) {
15916 if (Context.hasAnyFunctionEffects())
15917 if (FunctionEffectsRef FX = D->getFunctionEffects(); !FX.empty())
15919 }
15920
15921 /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify.
15922 void maybeAddDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15923
15924 /// Unconditionally add a Decl to DeclsWithEfffectsToVerify.
15925 void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15926
15928
15929 ///@}
15930
15931 //
15932 //
15933 // -------------------------------------------------------------------------
15934 //
15935 //
15936
15937 /// \name Expansion Statements
15938 /// Implementations are in SemaExpand.cpp
15939 ///@{
15940public:
15941 CXXExpansionStmtDecl *ActOnCXXExpansionStmtDecl(unsigned TemplateDepth,
15942 SourceLocation TemplateKWLoc);
15943
15947
15949 SourceLocation LBraceLoc,
15950 SourceLocation RBraceLoc);
15951
15953 CXXExpansionStmtDecl *ESD, Stmt *Init, Stmt *ExpansionVarStmt,
15954 Expr *ExpansionInitializer, SourceLocation LParenLoc,
15955 SourceLocation ColonLoc, SourceLocation RParenLoc,
15956 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps);
15957
15958 StmtResult FinishCXXExpansionStmt(Stmt *Expansion, Stmt *Body);
15959
15961 Stmt *ExpansionVar,
15962 SourceLocation LParenLoc,
15963 SourceLocation ColonLoc,
15964 SourceLocation RParenLoc);
15965
15967 CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVarStmt,
15968 Expr *ExpansionInitializer, SourceLocation LParenLoc,
15969 SourceLocation ColonLoc, SourceLocation RParenLoc,
15970 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
15971
15972 ExprResult BuildCXXExpansionSelectExpr(InitListExpr *Range, Expr *Idx);
15973
15974 std::optional<uint64_t>
15975 ComputeExpansionSize(CXXExpansionStmtPattern *Expansion);
15976 ///@}
15977};
15978
15982
15983/// Contains a late templated function.
15984/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15987 /// The template function declaration to be late parsed.
15989 /// Floating-point options in the point of definition.
15991};
15992
15993template <>
15995 PragmaMsStackAction Action,
15996 llvm::StringRef StackSlotLabel,
15998
15999} // end namespace clang
16000
16001#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:50
static void CheckFormatString(Sema &S, const FormatStringLiteral *FExpr, const StringLiteral *ReferenceFormatString, const Expr *OrigFormatExpr, ArrayRef< const Expr * > Args, Sema::FormatArgumentPassingKind APK, unsigned format_idx, unsigned firstDataArg, FormatStringType Type, bool inFunctionCall, VariadicCallType CallType, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg, bool IgnoreStringsWithoutSpecifiers)
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
Sema::AllowedExplicit AllowedExplicit
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:3299
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
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:2769
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3820
Attr - This represents one attribute.
Definition Attr.h:46
Represents a C++ declaration that introduces decls from somewhere else.
Definition DeclCXX.h:3526
A binding in a decomposition declaration.
Definition DeclCXX.h:4215
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4814
[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:2642
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2977
Represents a C++ base or member initializer.
Definition DeclCXX.h:2407
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:2907
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:2150
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:76
Represents the this expression in C++.
Definition ExprCXX.h: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:2991
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:5086
CaseStmt - Represent a case statement.
Definition Stmt.h:1932
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3724
This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
Abstract interface for a consumer of code-completion information.
Declaration of a C++20 concept.
A reference to a concept and its template args, as it appears in the code.
Definition ASTConcept.h:130
Represents the specialization of a concept - evaluates to a prvalue of type bool.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:47
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition DeclCXX.h:3707
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:1399
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1466
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1294
Captures information about "declaration specifiers".
Definition DeclSpec.h:220
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1643
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:871
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition DeclBase.h:854
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:995
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:781
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1955
A decomposition declaration.
Definition DeclCXX.h:4279
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:241
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3562
Represents an enum.
Definition Decl.h:4150
Store information needed for an explicit specifier.
Definition DeclCXX.h:1949
The return type of classify().
Definition Expr.h:340
This represents one expression.
Definition Expr.h:113
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:195
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:826
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:3299
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:2059
A mutable set of FunctionEffect::Kind.
Definition TypeBase.h:5270
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5384
Kind
Identifies the particular effect.
Definition TypeBase.h:5032
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition TypeBase.h:5216
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:5416
Declaration of a template function.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4638
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4612
One of these records is kept for each identifier that is lexed.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Definition Overload.h:626
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3606
Describes an C or C++ initializer list.
Definition Expr.h:5356
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:525
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:4451
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4397
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:3412
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:275
Represent a C++ namespace.
Definition Decl.h:593
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:8087
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:1164
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Definition Attr.h:279
static constexpr unsigned IdxBitWidth
Definition Attr.h:281
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2230
Represents a parameter to a function.
Definition Decl.h:1820
ParsedAttr - Represents a syntactic attribute.
Definition ParsedAttr.h:119
ParsedAttributes - A collection of parsed attributes.
Definition ParsedAttr.h:950
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:4464
Represents the body of a requires-expression.
Definition DeclCXX.h:2119
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:41
Smart pointer class that efficiently represents Objective-C method names.
A generic diagnostic builder for errors which may or may not be deferred.
Definition SemaBase.h:111
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition SemaBase.cpp:33
SemaBase(Sema &S)
Definition SemaBase.cpp:7
Sema & SemaRef
Definition SemaBase.h:40
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
Definition Sema.h:1903
bool operator==(const AlignPackInfo &Info) const
Definition Sema.h:1963
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition Sema.h:1935
unsigned getPackNumber() const
Definition Sema.h:1953
bool IsXLStack() const
Definition Sema.h:1961
bool IsPackSet() const
Definition Sema.h:1955
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition Sema.h:1909
bool IsAlignAttr() const
Definition Sema.h:1949
bool IsPackAttr() const
Definition Sema.h:1947
bool operator!=(const AlignPackInfo &Info) const
Definition Sema.h:1969
AlignPackInfo(bool IsXL)
Definition Sema.h:1913
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition Sema.h:1920
Mode getAlignMode() const
Definition Sema.h:1951
ArgPackSubstIndexRAII(Sema &Self, UnsignedOrNone NewSubstIndex)
Definition Sema.h:13838
ArgPackSubstIndexRAII & operator=(const ArgPackSubstIndexRAII &)=delete
ArgPackSubstIndexRAII(const ArgPackSubstIndexRAII &)=delete
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8379
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8384
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition Sema.h:8371
std::tuple< const Ts &... > Args
Definition Sema.h:8368
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:1343
CompoundScopeRAII(const CompoundScopeRAII &)=delete
std::pair< VarDecl *, Expr * > get() const
Definition Sema.h:7919
std::optional< bool > getKnownValue() const
Definition Sema.h:7923
A RAII object to temporarily push a declaration context.
Definition Sema.h:3584
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition Sema.h:3594
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:10434
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:10439
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:10162
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:1412
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition Sema.h:1431
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition Sema.h:1455
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition Sema.h:1424
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition Sema.h:1427
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:1441
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition Sema.h:1447
A helper class for building up ExtParameterInfos.
Definition Sema.h:13202
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:13221
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:13209
FPFeaturesStateRAII(const FPFeaturesStateRAII &)=delete
FPOptionsOverride getOverrides()
Definition Sema.h:14234
FPFeaturesStateRAII & operator=(const FPFeaturesStateRAII &)=delete
FpPragmaStackSaveRAII(const FpPragmaStackSaveRAII &)=delete
FpPragmaStackSaveRAII & operator=(const FpPragmaStackSaveRAII &)=delete
FullExprArg(Sema &actions)
Definition Sema.h:7863
ExprResult release()
Definition Sema.h:7865
friend class Sema
Definition Sema.h:7874
Expr * get() const
Definition Sema.h:7867
GlobalEagerInstantiationScope(const GlobalEagerInstantiationScope &)=delete
GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
Definition Sema.h:14246
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:10498
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:10490
unsigned size() const
The number of exceptions in the exception specification.
Definition Sema.h:5648
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition Sema.h:5641
const QualType * data() const
The set of exceptions in the exception specification.
Definition Sema.h:5651
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:5657
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition Sema.h:5664
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:14197
LocalEagerInstantiationScope(const LocalEagerInstantiationScope &)=delete
static NameClassification DependentNonType()
Definition Sema.h:3810
static NameClassification VarTemplate(TemplateName Name)
Definition Sema.h:3820
ExprResult getExpression() const
Definition Sema.h:3846
NameClassification(const IdentifierInfo *Keyword)
Definition Sema.h:3783
static NameClassification Unknown()
Definition Sema.h:3790
static NameClassification OverloadSet(ExprResult E)
Definition Sema.h:3794
NameClassificationKind getKind() const
Definition Sema.h:3844
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition Sema.h:3838
static NameClassification FunctionTemplate(TemplateName Name)
Definition Sema.h:3826
NamedDecl * getNonTypeDecl() const
Definition Sema.h:3856
NameClassification(ParsedType Type)
Definition Sema.h:3780
TemplateName getTemplateName() const
Definition Sema.h:3861
ParsedType getType() const
Definition Sema.h:3851
TemplateNameKind getTemplateNameKind() const
Definition Sema.h:3870
static NameClassification NonType(NamedDecl *D)
Definition Sema.h:3800
static NameClassification Concept(TemplateName Name)
Definition Sema.h:3832
static NameClassification UndeclaredNonType()
Definition Sema.h:3806
static NameClassification TypeTemplate(TemplateName Name)
Definition Sema.h:3814
static NameClassification Error()
Definition Sema.h:3786
void operator()(sema::FunctionScopeInfo *Scope) const
Definition Sema.cpp:2629
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:11570
SourceLocation getTemplateKeywordLoc() const
Definition Sema.h:11572
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition Sema.h:11567
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition Sema.h:12622
SFINAETrap & operator=(const SFINAETrap &)=delete
SFINAETrap(const SFINAETrap &)=delete
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition Sema.h:12656
SFINAETrap(Sema &S, bool WithAccessChecking=false)
Definition Sema.h:12638
bool withAccessChecking() const
Definition Sema.h:12659
sema::TemplateDeductionInfo * getDeductionInfo() const
Definition Sema.h:12651
SFINAETrap(Sema &S, sema::TemplateDeductionInfo &Info)
Definition Sema.h:12641
SatisfactionStackResetRAII(const SatisfactionStackResetRAII &)=delete
SatisfactionStackResetRAII & operator=(const SatisfactionStackResetRAII &)=delete
ScopedCodeSynthesisContext(Sema &S, const CodeSynthesisContext &Ctx)
Definition Sema.h:13765
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:8396
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8401
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8398
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition Sema.h:9414
CXXMethodDecl * getMethod() const
Definition Sema.h:9417
void setMethod(CXXMethodDecl *MD)
Definition Sema.h:9418
void addContextNote(SourceLocation UseLoc)
Definition Sema.h:13731
SynthesizedFunctionScope(const SynthesizedFunctionScope &)=delete
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition Sema.h:13719
SynthesizedFunctionScope & operator=(const SynthesizedFunctionScope &)=delete
SourceLocation getLocation() const
Definition Sema.h:12380
bool ContainsDecl(const NamedDecl *ND) const
Definition Sema.h:12370
const DeclContext * getDeclContext() const
Definition Sema.h:12376
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition Sema.h:12354
const NamedDecl * getDecl() const
Definition Sema.h:12368
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition Sema.h:12353
const DeclContext * getLexicalDeclContext() const
Definition Sema.h:12372
TentativeAnalysisScope(Sema &SemaRef)
Definition Sema.h:12673
TentativeAnalysisScope & operator=(const TentativeAnalysisScope &)=delete
TentativeAnalysisScope(const TentativeAnalysisScope &)=delete
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition Sema.h:7822
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:1474
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 ActOnLatePar...
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:3688
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:13796
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:8305
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:13780
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:11088
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition Sema.h:13231
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
Definition Sema.cpp:2702
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:1165
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:1617
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:14182
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
void PopParsingClass(ParsingClassState state)
Definition Sema.h:6646
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:10175
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition Sema.cpp:1103
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:6635
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:8351
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:8273
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:971
bool isAttrContext() const
Definition Sema.h:7042
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:8344
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition Sema.cpp:2871
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:9439
@ LookupLabel
Label name lookup.
Definition Sema.h:9448
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition Sema.h:9443
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition Sema.h:9470
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition Sema.h:9462
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition Sema.h:9484
@ LookupLocalFriendName
Look up a friend of a local class.
Definition Sema.h:9478
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition Sema.h:9480
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition Sema.h:9475
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition Sema.h:9455
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition Sema.h:9482
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition Sema.h:9466
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9451
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition Sema.h:9458
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9446
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition Sema.h:9486
@ LookupAnyName
Look up any declaration with any name.
Definition Sema.h:9488
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:418
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition Sema.h:9393
UnaryTransformType::UTTKind UTTKind
Definition Sema.h:15624
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:6387
SemaM68k & M68k()
Definition Sema.h:1524
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:13850
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:9424
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:1407
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:2171
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:9879
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:4969
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:5198
OpaquePtr< QualType > TypeTy
Definition Sema.h:1325
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:169
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:13859
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:697
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings={})
SemaOpenMP & OpenMP()
Definition Sema.h:1559
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition Sema.h:9392
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:2346
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition Sema.h:6425
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition Sema.h:9755
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:1395
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:3639
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:15286
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:1286
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:4871
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:1875
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:15748
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:6608
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:5297
void emitAndClearUnusedLocalTypedefWarnings()
Definition Sema.cpp:1217
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:6589
bool areDocumentationDiagsEnabled(SourceLocation Loc)
Returns true if any of the documentation warnings is enabled at Loc.
Definition Sema.cpp:2789
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
Definition SemaStmt.cpp:86
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:1275
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true)
ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
ActOnExpressionTrait - Parsed one of the unary type trait support pseudo-functions.
SemaCUDA & CUDA()
Definition Sema.h:1499
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:7939
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7941
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7940
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition Sema.h:1376
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:15707
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition Sema.h:15292
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:8293
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:9993
@ Interface
'export module X;'
Definition Sema.h:9990
@ Implementation
'module X;'
Definition Sema.h:9991
@ PartitionInterface
'export module X:Y;'
Definition Sema.h:9992
SourceLocation LocationOfExcessPrecisionNotSatisfied
Definition Sema.h:8431
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition Sema.h:1268
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:9702
void clearDocumentationDiagsCache()
Discard the areDocumentationDiagsEnabled() cache, for when a #pragma clang diagnostic has changed dia...
Definition Sema.cpp:2784
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition Sema.h:10517
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition Sema.h:10520
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition Sema.h:10526
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition Sema.h:10524
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:1833
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
@ AR_dependent
Definition Sema.h:1718
@ AR_accessible
Definition Sema.h:1716
@ AR_inaccessible
Definition Sema.h:1717
@ AR_delayed
Definition Sema.h:1719
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:15299
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
Definition Sema.h:15303
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:726
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:7020
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition Sema.cpp:2474
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope, LabelDecl *Label, SourceLocation LabelLoc)
QualType GetSignedSizelessVectorType(QualType V)
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
void ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, Scope *CurContext)
Once the Lambdas capture are known, we can start to create the closure, call operator method,...
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:439
void AddTemplateParametersToLambdaCallOperator(CXXMethodDecl *CallOperator, CXXRecordDecl *Class, TemplateParameterList *TemplateParams)
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
Annotation attributes are the only attributes allowed after an access specifier.
FunctionDecl * getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2)
Returns the more constrained function according to the rules of partial ordering by constraints (C++ ...
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
llvm::SmallPtrSet< ConstantExpr *, 4 > FailedImmediateInvocations
Definition Sema.h:8420
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition Sema.h:2106
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...
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition Sema.h:15293
PragmaStack< StringLiteral * > CodeSegStack
Definition Sema.h:2100
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, Scope *CurScope)
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
void referenceDLLExportedClassMethods()
StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit=false)
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
void MarkCaptureUsedInEnclosingContext(ValueDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member function overrides a virtual...
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates.
void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX)
Unconditionally add a Decl to DeclsWithEfffectsToVerify.
FunctionEffectKindSet AllEffectsToVerify
The union of all effects present on DeclsWithEffectsToVerify.
Definition Sema.h:15896
void setFunctionHasBranchIntoScope()
Definition Sema.cpp:2655
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:5029
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition SemaStmt.cpp:526
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimizeoff". If this location is invalid,...
Definition Sema.h:2180
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:6849
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:2095
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:11290
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
Definition SemaAttr.cpp:54
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
bool CheckFormatStringsCompatible(FormatStringType FST, const StringLiteral *AuthoritativeFormatString, const StringLiteral *TestedFormatString, const Expr *FunctionCallArg=nullptr)
Verify that two format strings (as understood by attribute(format) and attribute(format_matches) are ...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver)
If VD is set but not otherwise used, diagnose, for a parameter or a variable.
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext)
void ActOnComment(SourceRange Comment)
Definition Sema.cpp:2824
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:4265
@ Default
= default ;
Definition Sema.h:4267
@ Delete
deleted-function-body
Definition Sema.h:4273
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:14144
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
Definition SemaStmt.cpp:49
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:1298
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:2107
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:1514
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:1584
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:3098
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:7032
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:1769
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:847
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition Sema.h:11535
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:12133
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition Sema.h:12144
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition Sema.h:12136
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition Sema.h:12140
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:688
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:9387
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:1604
void markLateParsedBoundsTypeRejected(const BoundsAttributedType *BATy)
Definition Sema.h:2552
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:13800
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:1332
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:8260
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:702
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:9398
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition Sema.h:7884
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:228
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc)
ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Definition SemaAttr.cpp:976
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:2388
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)
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.
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:4491
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15672
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:11516
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition Sema.h:15776
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:9976
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:15282
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
SemaObjC & ObjC()
Definition Sema.h:1544
bool InOverflowBehaviorAssignmentContext
Track if we're currently analyzing overflow behavior types in assignment context.
Definition Sema.h:1399
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:3053
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:1469
TemplateName ActOnPackIndexingTemplateName(TemplateName Pattern, SourceLocation NameLoc, Expr *IndexExpr)
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition SemaDecl.cpp:80
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool FullySubstituted=false)
void InstantiateMemInitializers(CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, const MultiLevelTemplateArgumentList &TemplateArgs)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
void ActOnPragmaMSAllocText(SourceLocation PragmaLocation, StringRef Section, const SmallVector< std::tuple< IdentifierInfo *, SourceLocation > > &Functions)
Called on well-formed #pragma alloc_text().
Definition SemaAttr.cpp:940
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition Sema.h:3257
bool captureSwiftVersionIndependentAPINotes()
Whether APINotes should be gathered for all applicable Swift language versions, without being applied...
Definition Sema.h:1699
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:2103
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void PrintInstantiationStack()
Definition Sema.h:13863
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:3678
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:768
bool isImmediateFunctionContext() const
Definition Sema.h:8285
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:677
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition SemaExpr.cpp:778
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:6615
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:1461
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:6699
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
void PopExpressionEvaluationContext()
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N)
PragmaStack< StringLiteral * > ConstSegStack
Definition Sema.h:2099
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:778
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:897
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:712
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition Sema.h:2689
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:6642
@ FRS_Success
Definition Sema.h:10905
@ FRS_DiagnosticIssued
Definition Sema.h:10907
@ FRS_NoViableFunction
Definition Sema.h:10906
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
void ActOnPragmaCXLimitedRange(SourceLocation Loc, LangOptions::ComplexRangeKind Range)
ActOnPragmaCXLimitedRange - Called on well formed #pragma STDC CX_LIMITED_RANGE.
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
TemplateParameterList * GetTemplateParameterList(TemplateDecl *TD)
Returns the template parameter list with all default template argument information.
void ActOnPragmaFPExceptions(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called on well formed '#pragma clang fp' that has option 'exceptions'.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord)
Add gsl::Pointer attribute to std::container::iterator.
Definition SemaAttr.cpp:112
SmallVector< LateInstantiatedAttribute, 1 > LateInstantiatedAttrVec
Definition Sema.h:14317
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
void mergeVisibilityType(Decl *D, SourceLocation Loc, VisibilityAttr::VisibilityType Type)
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition Sema.h:9436
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:9390
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:15207
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized.
Definition Sema.h:9128
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:15892
@ Conversions
Allow explicit conversion functions but not explicit constructors.
Definition Sema.h:10226
@ All
Allow both explicit conversion functions and explicit constructors.
Definition Sema.h:10228
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:1258
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition Sema.h:6630
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:1236
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:15078
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:3701
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:1774
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:2745
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition Sema.h:3581
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:2665
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:12312
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition Sema.h:12330
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition Sema.h:12320
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition Sema.h:12340
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:5020
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:1788
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:8462
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:11585
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
Definition Sema.h:11592
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
Definition Sema.h:11589
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:2796
void PushFunctionScope()
Enter a new function scope.
Definition Sema.cpp:2493
ExprResult ActOnNameClassifiedAsNonType(Scope *S, const CXXScopeSpec &SS, NamedDecl *Found, SourceLocation NameLoc, const Token &NextToken)
Act on the result of classifying a name as a specific non-type declaration.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:427
SourceRange getExprRange(Expr *E) const
Definition SemaExpr.cpp:515
bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS)
The parser has parsed a global nested-name-specifier '::'.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
NamedReturnInfo getNamedReturnInfo(Expr *&E, SimplerImplicitMoveMode Mode=SimplerImplicitMoveMode::Normal)
Determine whether the given expression might be move-eligible or copy-elidable in either a (co_)retur...
void setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called to set exception behavior for floating point operations.
bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
The parser has parsed a nested-name-specifier 'identifier::'.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
Definition Sema.h:11521
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:8320
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:15289
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition Sema.h:4709
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:1615
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:406
FPOptions & getCurFPFeatures()
Definition Sema.h:930
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition Sema.h:8414
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:2511
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:2644
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15716
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:14577
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition Sema.h:14597
@ UPPC_RequiresClause
Definition Sema.h:14648
@ UPPC_UsingDeclaration
A using declaration.
Definition Sema.h:14603
@ UPPC_IfExists
Microsoft __if_exists.
Definition Sema.h:14630
@ UPPC_Requirement
Definition Sema.h:14645
@ UPPC_ExceptionType
The type of an exception.
Definition Sema.h:14621
@ UPPC_EnumeratorValue
The enumerator value.
Definition Sema.h:14600
@ UPPC_Lambda
Lambda expression.
Definition Sema.h:14636
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition Sema.h:14633
@ UPPC_PartialSpecialization
Partial specialization.
Definition Sema.h:14627
@ UPPC_Initializer
An initializer.
Definition Sema.h:14612
@ UPPC_BaseType
The base type of a class type.
Definition Sema.h:14582
@ UPPC_FriendDeclaration
A friend declaration.
Definition Sema.h:14606
@ UPPC_DefaultArgument
A default argument.
Definition Sema.h:14615
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition Sema.h:14585
@ UPPC_Expression
An arbitrary expression.
Definition Sema.h:14579
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition Sema.h:14624
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition Sema.h:14609
@ UPPC_DataMemberType
The type of a data member.
Definition Sema.h:14588
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition Sema.h:14594
@ UPPC_Block
Block expression.
Definition Sema.h:14639
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition Sema.h:14591
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition Sema.h:14618
@ UPPC_TypeConstraint
A type constraint.
Definition Sema.h:14642
api_notes::APINotesManager APINotes
Definition Sema.h:1336
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:12692
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:13245
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:6017
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:2605
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
SourceLocation CurInitSegLoc
Definition Sema.h:2142
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:2556
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition SemaAttr.cpp:767
SemaCodeCompletion & CodeCompletion()
Definition Sema.h:1494
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:3695
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:1549
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition Sema.h:15073
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
ReuseLambdaContextDecl_t
Definition Sema.h:7111
@ ReuseLambdaContextDecl
Definition Sema.h:7111
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:1489
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:1378
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false)
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr)
Diagnose an empty lookup.
Preprocessor & PP
Definition Sema.h:1331
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:2189
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:1373
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition Sema.h:2167
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:2280
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:1504
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition Sema.h:6591
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:1534
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:1616
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:1330
void InstantiateClassMembers(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiates the definitions of all of the member of the given class, which is an instantiation of a ...
NamedDecl * FindFirstQualifierInScope(Scope *S, NestedNameSpecifier NNS)
If the given nested-name-specifier begins with a bare identifier (e.g., Base::), perform name lookup ...
bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
ExprResult PerformQualificationConversion(Expr *E, QualType Ty, ExprValueKind VK=VK_PRValue, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
void PushExpressionEvaluationContextForFunction(ExpressionEvaluationContext NewContext, FunctionDecl *FD)
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From,...
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition Sema.h:1264
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition Sema.cpp:2720
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:1259
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition Sema.h:9131
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:966
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition SemaStmt.cpp:417
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition Sema.h:15729
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:6593
SemaHLSL & HLSL()
Definition Sema.h:1509
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:11534
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition Sema.h:1262
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition Sema.h:9435
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:1238
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:7026
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:2753
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:1876
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
static StringRef GetFormatStringTypeName(FormatStringType FST)
SemaMIPS & MIPS()
Definition Sema.h:1529
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:1574
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:15915
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition Sema.h:1865
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:6023
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:217
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:5391
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
Definition Sema.h:5394
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
Definition Sema.h:5398
@ Builtin
A builtin needed 'std::strong_ordering' (eg. '__builtin_type_order').
Definition Sema.h:5400
MemberPointerConversionDirection
Definition Sema.h:10358
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition Sema.h:14180
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition Sema.h:6586
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:79
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:2862
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:15284
SemaSwift & Swift()
Definition Sema.h:1589
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:2088
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:6691
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition Sema.h:7056
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition Sema.h:6623
StmtResult ActOnExprStmtError()
Definition SemaStmt.cpp:66
PragmaStack< StringLiteral * > BSSSegStack
Definition Sema.h:2098
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:1169
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition Sema.h:1387
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:2145
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:1781
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:911
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
Definition SemaStmt.cpp:71
OpenCLOptions OpenCLFeatures
Definition Sema.h:1327
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:11938
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
Definition Sema.h:14184
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:2192
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
bool isRedefinitionAllowedFor(const NamedDecl *D, SourceLocation NewLoc, bool &Visible)
Definition Sema.h:15757
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:885
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:4886
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:10545
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition Sema.h:15278
ProcessingContextState ParsingClassState
Definition Sema.h:6641
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:1367
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:2639
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:3142
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:3947
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition Sema.h:2769
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:15638
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:7053
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)
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:2457
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:11933
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:13243
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:4980
bool SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams, ExtParameterInfoBuilder &ParamInfos)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body, unsigned DiagID)
Emit DiagID if statement located on StmtLoc has a suspicious null statement as a Body,...
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
Definition Sema.h:6013
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:648
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:15723
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition Sema.h:8289
llvm::MapVector< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition Sema.h:3661
StringLiteral * CurInitSeg
Last section used with pragma init_seg.
Definition Sema.h:2141
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:2550
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition Sema.h:9971
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:5024
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:2624
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:8156
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:2675
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:7068
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:6600
void CheckTCBEnforcement(const SourceLocation CallExprLoc, const NamedDecl *Callee)
Enforce the bounds of a TCB CheckTCBEnforcement - Enforces that every function in a named TCB only di...
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
FunctionDecl * resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition Sema.h:1472
auto getDefaultDiagFunc()
Definition Sema.h:2348
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:315
DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc, SourceLocation PrivateLoc)
The parser has processed a private-module-fragment declaration that begins the definition of the priv...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition Sema.h:12693
ClassTemplateDecl * StdTypeIdentity
The C++ "std::type_identity" template, which is defined in <type_traits>.
Definition Sema.h:6619
SemaOpenCL & OpenCL()
Definition Sema.h:1554
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:14193
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, SourceLocation Loc={}, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams, SourceLocation EllipsisLoc)
Handle a friend type declaration.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
Definition SemaAttr.cpp:659
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition Sema.h:2272
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression, SourceLocation EllipsisLoc, SourceLocation LSquareLoc, Expr *IndexExpr, SourceLocation RSquareLoc)
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, StringLiteral *SegmentName)
Called on well-formed #pragma init_seg().
Definition SemaAttr.cpp:931
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:15294
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:2699
@ FAPK_Elsewhere
Definition Sema.h:2703
@ FAPK_Fixed
Definition Sema.h:2700
@ FAPK_Variadic
Definition Sema.h:2701
@ FAPK_VAList
Definition Sema.h:2702
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:8281
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition Sema.h:13234
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition Sema.cpp:1748
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:3674
Stmt * MaybeCreateStmtWithCleanups(Stmt *SubStmt)
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
Parsed a C++ 'new' expression (C++ 5.3.4).
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
StmtResult ActOnCapturedRegionEnd(Stmt *S)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen)
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind ActOnExplicitInstantiationNewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
bool isAcceptable(const NamedDecl *D, AcceptableKind Kind)
Determine whether a declaration is acceptable (visible/reachable).
Definition Sema.h:15736
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:15049
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:8473
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:3692
ExprResult CheckVarOrConceptTemplateTemplateId(const DeclarationNameInfo &NameInfo, TemplateName Template, const TemplateArgumentListInfo *TemplateArgs)
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition Sema.h:6852
ExprResult BuildSubstNonTypeTemplateParmExpr(Decl *AssociatedDecl, unsigned Index, QualType ParamType, SourceLocation loc, TemplateArgument Replacement, UnsignedOrNone PackIndex, bool Final)
bool MSStructPragmaOn
Definition Sema.h:1862
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
ExprResult TransformToPotentiallyEvaluated(Expr *E)
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
void deduceHLSLAddressSpace(VarDecl *decl)
unsigned ActOnReenterTemplateScope(Decl *Template, llvm::function_ref< Scope *()> EnterScope)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore,...
Definition Sema.h:13811
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:14128
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition Sema.h:15711
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:8544
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:4958
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:652
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:3635
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:988
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:718
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:12412
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:2360
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition SemaAttr.cpp:593
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
bool ActOnCXXNestedNameSpecifierIndexedPack(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc, QualType Type)
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount, unsigned MaxArgCount)
Checks that a call expression's argument count is in the desired range.
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
bool inConstraintSubstitution() const
Determine whether we are currently performing constraint substitution.
Definition Sema.h:14133
CanThrowResult canThrow(const Stmt *E)
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
bool isThisOutsideMemberFunctionBody(QualType BaseType)
Determine whether the given type is the type of *this that is used outside of the body of a member fu...
bool ValidateFormatString(FormatStringType FST, const StringLiteral *Str)
Verify that one format string (as understood by attribute(format)) is self-consistent; for instance,...
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
StringEvaluationContext
Definition Sema.h:6133
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:1877
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:7565
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:4204
@ NTCUK_Destruct
Definition Sema.h:4206
@ NTCUK_Init
Definition Sema.h:4205
@ NTCUK_Copy
Definition Sema.h:4207
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:1408
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:8430
PragmaClangSection PragmaClangDataSection
Definition Sema.h:1874
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.
LazyVector< VarDecl *, &ExternalSemaSource::ReadTentativeDefinitions, 2, 2 > TentativeDefinitionsType
Definition Sema.h:3682
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:9227
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:2505
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:2087
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:6850
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:1272
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition Sema.h:2148
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool isSFINAEContext() const
Definition Sema.h:13871
FunctionDecl * BuildTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl, QualType AllocType, SourceLocation)
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition Sema.h:8899
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:15291
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:13827
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name, TemplateNameKind &TNK, SourceLocation NameLoc, IdentifierInfo *&II)
Try to resolve an undeclared template name as a type template.
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, const IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations.
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over....
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e....
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
void DiagnoseUnknownAttribute(const ParsedAttr &AL)
void PushSatisfactionStackEntry(const NamedDecl *D, const llvm::FoldingSetNodeID &ID)
Definition Sema.h:15034
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:15678
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition Sema.h:1175
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:3104
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:2145
void setFunctionHasMustTail()
Definition Sema.cpp:2670
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:8469
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:15040
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:2660
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition Sema.h:15768
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:2691
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition Sema.h:6611
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:640
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:1232
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:1613
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:11396
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:275
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:1610
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:1333
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:4772
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
PragmaAlignPackDiagnoseKind
Definition Sema.h:2250
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:7060
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition SemaExpr.cpp:127
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition Sema.h:1372
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:1895
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition Sema.h:14176
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:9999
@ PrivateFragmentImportFinished
after 'module :private;' but a non-import decl has already been seen.
Definition Sema.h:10006
@ ImportFinished
after any non-import decl.
Definition Sema.h:10003
@ PrivateFragmentImportAllowed
after 'module :private;' but before any non-import decl.
Definition Sema.h:10004
@ FirstDecl
Parsing the first decl in a TU.
Definition Sema.h:10000
@ GlobalFragment
after 'module;' but before 'module X;'
Definition Sema.h:10001
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
Definition Sema.h:10008
@ ImportAllowed
after 'module X;' but before any non-import decl.
Definition Sema.h:10002
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:15290
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:1293
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:6794
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
Definition Sema.h:6816
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
Definition Sema.h:6806
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
Definition Sema.h:6821
@ DiscardedStatement
The current expression occurs within a discarded statement.
Definition Sema.h:6811
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6831
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6800
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6826
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
Definition Sema.h:6841
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:13819
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:4934
@ AP_InferredFromAnyAppleOS
The availability attribute was inferred from an 'anyAppleOS' availability attribute.
Definition Sema.h:4948
@ AP_PragmaClangAttribute
The availability attribute was applied using 'pragma clang attribute'.
Definition Sema.h:4940
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition Sema.h:4944
@ AP_PragmaClangAttribute_InferredFromAnyAppleOS
The availability attribute was inferred from an 'anyAppleOS' availability attribute that was applied ...
Definition Sema.h:4953
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition Sema.h:4937
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:14138
SemaPPC & PPC()
Definition Sema.h:1564
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:2518
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:421
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:76
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition Sema.h:5017
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:1291
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:15042
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:1377
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:8480
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:3685
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:10154
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:8271
SemaSystemZ & SystemZ()
Definition Sema.h:1594
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition Sema.cpp:124
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:3126
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:3665
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8417
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:10350
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
void makeModuleVisible(Module *Mod, SourceLocation ImportLoc)
Definition Sema.h:9985
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:714
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:6604
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition Sema.h:1335
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:11562
@ TemplateNameIsRequired
Definition Sema.h:11562
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:797
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:1334
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
void DiagnoseUnterminatedPragmaAlignPack()
Definition SemaAttr.cpp:632
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition Sema.h:7888
OpenCLOptions & getOpenCLOptions()
Definition Sema.h:929
FPOptions CurFPFeatures
Definition Sema.h:1328
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:1380
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition Sema.h:6595
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
bool IsAtLeastAsConstrained(const NamedDecl *D1, MutableArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, MutableArrayRef< AssociatedConstraint > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
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:1113
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:524
PragmaStack< StringLiteral * > DataSegStack
Definition Sema.h:2097
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:15206
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:3165
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:1338
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:11745
@ TPC_TemplateTemplateParameterPack
Definition Sema.h:11755
@ TPC_FriendFunctionTemplate
Definition Sema.h:11753
@ TPC_ClassTemplateMember
Definition Sema.h:11751
@ TPC_FunctionTemplate
Definition Sema.h:11750
@ TPC_FriendClassTemplate
Definition Sema.h:11752
@ TPC_FriendFunctionTemplateDefinition
Definition Sema.h:11754
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:1484
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
friend class InitializationSequence
Definition Sema.h:1614
bool GloballyUniqueObjectMightBeAccidentallyDuplicated(const VarDecl *Dcl)
Certain globally-unique variables might be accidentally duplicated if built into multiple shared libr...
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition,...
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition Sema.h:2176
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:980
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:7847
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:6627
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition Sema.h:13791
void PrintStats() const
Print out statistics about the semantic analysis.
Definition Sema.cpp:692
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:15281
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:1860
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:1277
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:11182
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition Sema.h:11190
@ BFRK_Build
Initial building of a for-range statement.
Definition Sema.h:11184
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition Sema.h:11187
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
SemaNVPTX & NVPTX()
Definition Sema.h:1539
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().
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc)
void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction, const Expr *ThisArg, ArrayRef< const Expr * > Args)
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:626
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:2117
@ PSK_ConstSeg
Definition Sema.h:2120
@ PSK_DataSeg
Definition Sema.h:2118
@ PSK_CodeSeg
Definition Sema.h:2121
@ PSK_BSSSeg
Definition Sema.h:2119
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:647
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
bool CheckSpanLikeType(const AttributeCommonInfo &CI, const QualType &Ty)
Check that the type is a plain record with one field being a pointer type and the other field being a...
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition SemaCast.cpp:338
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition Sema.h:6424
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:3654
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition Sema.cpp:2263
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:1873
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:1391
QualType CheckMatrixLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel)
AbstractDiagSelID
Definition Sema.h:6370
@ AbstractSynthesizedIvarType
Definition Sema.h:6377
@ AbstractVariableType
Definition Sema.h:6374
@ AbstractReturnType
Definition Sema.h:6372
@ AbstractNone
Definition Sema.h:6371
@ AbstractFieldType
Definition Sema.h:6375
@ AbstractArrayType
Definition Sema.h:6378
@ AbstractParamType
Definition Sema.h:6373
@ AbstractIvarType
Definition Sema.h:6376
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:1579
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:8466
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:1204
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:9429
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:8079
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:9492
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition Sema.h:9496
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition Sema.h:9502
@ LOLR_Error
The lookup resulted in an error.
Definition Sema.h:9494
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition Sema.h:9499
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition Sema.h:9510
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition Sema.h:9506
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:2690
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition Sema.h:7038
SemaLoongArch & LoongArch()
Definition Sema.h:1519
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:6506
@ CheckValid
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
Definition Sema.h:6511
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
Definition Sema.h:6508
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:14172
void CheckVariableDeclarationType(VarDecl *NewVD)
sema::CompoundScopeInfo & getCurCompoundScope() const
Definition SemaStmt.cpp:453
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:3118
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1324
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:730
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:3631
void ActOnFinishOfCompoundStmt()
Definition SemaStmt.cpp:429
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:1794
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:15603
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:7925
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:457
void NoteTemplateParameterLocation(const NamedDecl &Decl)
SemaWasm & Wasm()
Definition Sema.h:1599
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:3577
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:13787
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:1569
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:2651
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition SemaStmt.cpp:654
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition Sema.h:11527
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:7881
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:731
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:148
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:8425
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition Sema.h:1323
static int getPrintable(int I)
Definition Sema.h:15280
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:9764
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition Sema.h:13074
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:631
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:3933
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:15285
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:592
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:8297
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:13802
SemaARM & ARM()
Definition Sema.h:1479
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:13783
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:15283
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:11092
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:673
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
PragmaMsStackAction
Definition Sema.h:1879
@ PSK_Push_Set
Definition Sema.h:1885
@ PSK_Reset
Definition Sema.h:1880
@ PSK_Pop_Set
Definition Sema.h:1886
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:8761
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, bool EvaluateConstraints=true)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
SFINAETrap * getSFINAEContext() const
Returns a pointer to the current SFINAE context, if any.
Definition Sema.h:13868
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:1823
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3856
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:4774
The top declaration context.
Definition Decl.h:106
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:227
Represents a declaration of a type.
Definition Decl.h:3652
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:8417
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:3806
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3701
Simple class containing the result of Sema::CorrectTypo.
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:1042
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:3621
Represents C++ using-directive.
Definition DeclCXX.h:3126
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3429
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:713
Represents a variable declaration or definition.
Definition Decl.h:933
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:4273
Represents a C++11 virt-specifier-seq.
Definition DeclSpec.h:2835
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:1938
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:933
@ 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:2879
@ CopyInit
[a = b], [a = {b}]
Definition DeclSpec.h:2881
@ 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:6039
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:2030
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:2019
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
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
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:1259
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:5061
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:6014
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6025
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6028
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:6032
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:2037
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_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t uint32_t uint32_t 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.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:91
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A structure used to record information about a failed template argument deduction,...
Describes whether we've seen any nullability information for the given file.
Definition Sema.h: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:5153
Holds information about the various types of exception specification.
Definition TypeBase.h:5473
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5475
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5478
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5481
Extra information about a function prototype.
Definition TypeBase.h:5501
Represents a complete lambda introducer.
Definition DeclSpec.h:2887
Contains a late templated function.
Definition Sema.h:15985
FPOptions FPO
Floating-point options in the point of definition.
Definition Sema.h:15990
Decl * D
The template function declaration to be late parsed.
Definition Sema.h:15988
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:937
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation CurrentPragmaLocation
Definition Sema.h:2092
bool SuppressUserConversions
Do not consider any user-defined conversions when constructing the initializing sequence.
Definition Sema.h:10637
bool OnlyInitializeNonUserDefinedConversions
Before constructing the initializing sequence, we check whether the parameter type and argument type ...
Definition Sema.h:10644
CheckNonDependentConversionsFlag(bool SuppressUserConversions, bool OnlyInitializeNonUserDefinedConversions)
Definition Sema.h:10646
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
Definition Sema.h:12171
bool MatchingTTP
If true, assume these template arguments are the injected template arguments for a template template ...
Definition Sema.h:12167
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &)=delete
CheckTemplateArgumentInfo(bool PartialOrdering=false, bool MatchingTTP=false)
Definition Sema.h:12148
bool PartialOrdering
The check is being performed in the context of partial ordering.
Definition Sema.h:12160
SmallVector< TemplateArgument, 4 > SugaredConverted
The checked, converted argument will be added to the end of these vectors.
Definition Sema.h:12157
SmallVector< TemplateArgument, 4 > CanonicalConverted
Definition Sema.h:12157
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:13282
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition Sema.h:13453
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool InParameterMappingSubstitution
Whether we're substituting into the parameter mapping of a constraint.
Definition Sema.h:13410
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition Sema.h:13426
ArrayRef< TemplateArgument > template_arguments() const
Definition Sema.h:13445
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition Sema.h:13421
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition Sema.h:13413
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition Sema.h:13439
bool InConstraintSubstitution
Whether we're substituting into constraints.
Definition Sema.h:13407
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition Sema.h:13429
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition Sema.h:13436
SynthesisKind
The kind of template instantiation we are performing.
Definition Sema.h:13284
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition Sema.h:13373
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition Sema.h:13294
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition Sema.h:13303
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition Sema.h:13322
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition Sema.h:13370
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition Sema.h:13330
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition Sema.h:13337
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition Sema.h:13377
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition Sema.h:13348
@ Memoization
Added for Template instantiation observation.
Definition Sema.h:13383
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:13313
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition Sema.h:13389
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition Sema.h:13386
@ PartialOrderingTTP
We are performing partial ordering for template template parameters.
Definition Sema.h:13392
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition Sema.h:13310
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition Sema.h:13318
@ SYCLKernelLaunchOverloadResolution
We are performing overload resolution for a call to a function template or variable template named 's...
Definition Sema.h:13400
@ ExpansionStmtInstantiation
We are instantiating an expansion statement.
Definition Sema.h:13403
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition Sema.h:13326
@ TemplateInstantiation
We are instantiating a template declaration.
Definition Sema.h:13287
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition Sema.h:13340
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition Sema.h:13344
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition Sema.h:13299
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition Sema.h:13367
@ SYCLKernelLaunchLookup
We are performing name lookup for a function template or variable template named 'sycl_kernel_launch'...
Definition Sema.h:13396
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition Sema.h:13333
Decl * Entity
The entity that is being synthesized.
Definition Sema.h:13416
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition Sema.h:13442
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:6955
Data structure used to record current or nested expression evaluation contexts.
Definition Sema.h:6856
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:6889
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition Sema.h:6891
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition Sema.h:6942
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition Sema.h:6876
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:6885
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition Sema.h:6896
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:6904
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition Sema.h:6900
bool IsCaseExpr
Whether evaluating an expression for a switch case label.
Definition Sema.h:6945
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition Sema.h:6910
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:6871
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition Sema.h:6918
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition Sema.h:6948
SmallVector< MisalignedMember, 4 > MisalignedMembers
Small set of gathered accesses to potentially misaligned members due to the packed attribute.
Definition Sema.h:6914
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition Sema.h:6861
VarDecl * DeclForInitializer
Declaration for initializer if one is currently being parsed.
Definition Sema.h:6881
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition Sema.h:6965
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition Sema.h:6967
ExpressionEvaluationContext Context
The expression evaluation context.
Definition Sema.h:6858
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition Sema.h:6865
Holds the 'begin' and 'end' variables of a range-based for loop or expansion statement; begin-expr an...
Definition Sema.h:11233
FormatArgumentPassingKind ArgPassingKind
Definition Sema.h:2711
FunctionEffectDiffVector(const FunctionEffectsRef &Old, const FunctionEffectsRef &New)
Caller should short-circuit by checking for equality first.
std::optional< FunctionEffectWithCondition > Old
Definition Sema.h:15845
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:15849
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:15857
std::optional< FunctionEffectWithCondition > New
Definition Sema.h:15847
FunctionEffect::Kind EffectKind
Definition Sema.h:15842
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition Sema.h:13629
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:14310
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition Sema.h:14313
bool isMoveEligible() const
Definition Sema.h:11287
bool isCopyElidable() const
Definition Sema.h:11288
const VarDecl * Candidate
Definition Sema.h:11282
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition Sema.h:3390
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition Sema.h:3399
SourceLocation IdentifierLoc
The location of the identifier.
Definition Sema.h:3393
SourceLocation CCLoc
The location of the '::'.
Definition Sema.h:3396
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition Sema.h:3387
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition Sema.h:3405
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition Sema.h:12793
Information from a C++ pragma export, for a symbol that we haven't seen the declaration for yet.
Definition Sema.h:2383
This an attribute introduced by #pragma clang attribute.
Definition Sema.h:2151
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition Sema.h:2154
A push'd group of PragmaAttributeEntries.
Definition Sema.h:2159
SourceLocation Loc
The location of the push attribute.
Definition Sema.h:2161
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition Sema.h:2164
const IdentifierInfo * Namespace
The namespace of this push group.
Definition Sema.h:2163
SourceLocation PragmaLocation
Definition Sema.h:1870
PragmaMsStackAction Action
Definition Sema.h:1890
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition Sema.h:2003
llvm::StringRef StackSlotLabel
Definition Sema.h:1999
SourceLocation PragmaLocation
Definition Sema.h:2001
SourceLocation PragmaPushLocation
Definition Sema.h:2002
ValueType CurrentValue
Definition Sema.h:2073
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition Sema.h:2059
bool hasValue() const
Definition Sema.h:2069
SmallVector< Slot, 2 > Stack
Definition Sema.h:2071
ValueType DefaultValue
Definition Sema.h:2072
SourceLocation CurrentPragmaLocation
Definition Sema.h:2074
PragmaStack(const ValueType &Default)
Definition Sema.h:2066
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition Sema.h:2010
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition Sema.h:5232
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition Sema.h:5226
RecursiveInstGuard(Sema &S, Decl *D, Kind Kind)
Definition Sema.h:13254
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:10534
SFINAEContextBase & operator=(const SFINAEContextBase &)=delete
SFINAEContextBase(Sema &S, SFINAETrap *Cur)
Definition Sema.h:12602
SFINAEContextBase(const SFINAEContextBase &)=delete
Abstract class used to diagnose incomplete types.
Definition Sema.h:8358
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition Sema.h:2753
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition Sema.h:2762
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.