Thanks to visit codestin.com
Credit goes to clang.llvm.org

clang 22.0.0git
Sema.h
Go to the documentation of this file.
1//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the Sema class, which performs semantic analysis and
10// builds ASTs.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SEMA_SEMA_H
15#define LLVM_CLANG_SEMA_SEMA_H
16
18#include "clang/AST/ASTFwd.h"
19#include "clang/AST/ASTLambda.h"
20#include "clang/AST/Attr.h"
22#include "clang/AST/CharUnits.h"
23#include "clang/AST/DeclBase.h"
24#include "clang/AST/DeclCXX.h"
27#include "clang/AST/Expr.h"
28#include "clang/AST/ExprCXX.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/Type.h"
35#include "clang/AST/TypeLoc.h"
39#include "clang/Basic/Cuda.h"
43#include "clang/Basic/LLVM.h"
44#include "clang/Basic/Lambda.h"
46#include "clang/Basic/Module.h"
58#include "clang/Sema/Attr.h"
60#include "clang/Sema/DeclSpec.h"
66#include "clang/Sema/Scope.h"
67#include "clang/Sema/SemaBase.h"
69#include "clang/Sema/Weak.h"
70#include "llvm/ADT/APInt.h"
71#include "llvm/ADT/ArrayRef.h"
72#include "llvm/ADT/BitmaskEnum.h"
73#include "llvm/ADT/DenseMap.h"
74#include "llvm/ADT/DenseSet.h"
75#include "llvm/ADT/FloatingPointMode.h"
76#include "llvm/ADT/FoldingSet.h"
77#include "llvm/ADT/MapVector.h"
78#include "llvm/ADT/PointerIntPair.h"
79#include "llvm/ADT/PointerUnion.h"
80#include "llvm/ADT/STLExtras.h"
81#include "llvm/ADT/STLForwardCompat.h"
82#include "llvm/ADT/STLFunctionalExtras.h"
83#include "llvm/ADT/SetVector.h"
84#include "llvm/ADT/SmallBitVector.h"
85#include "llvm/ADT/SmallPtrSet.h"
86#include "llvm/ADT/SmallSet.h"
87#include "llvm/ADT/SmallVector.h"
88#include "llvm/ADT/StringExtras.h"
89#include "llvm/ADT/StringMap.h"
90#include "llvm/ADT/TinyPtrVector.h"
91#include "llvm/Support/Allocator.h"
92#include "llvm/Support/Compiler.h"
93#include "llvm/Support/Error.h"
94#include "llvm/Support/ErrorHandling.h"
95#include <cassert>
96#include <climits>
97#include <cstddef>
98#include <cstdint>
99#include <deque>
100#include <functional>
101#include <iterator>
102#include <memory>
103#include <optional>
104#include <string>
105#include <tuple>
106#include <type_traits>
107#include <utility>
108#include <vector>
109
110namespace llvm {
111struct InlineAsmIdentifierInfo;
112} // namespace llvm
113
114namespace clang {
115class ADLResult;
116class APValue;
118class ASTConsumer;
119class ASTContext;
120class ASTDeclReader;
122class ASTReader;
123class ASTWriter;
124class CXXBasePath;
125class CXXBasePaths;
128enum class ComparisonCategoryType : unsigned char;
130class DarwinSDKInfo;
131class DeclGroupRef;
135class Designation;
136class IdentifierInfo;
142enum class LangAS : unsigned int;
144class LookupResult;
147class ModuleLoader;
151class ObjCMethodDecl;
152struct OverloadCandidate;
153enum class OverloadCandidateParamOrder : char;
154enum OverloadCandidateRewriteKind : unsigned;
156class Preprocessor;
157class SemaAMDGPU;
158class SemaARM;
159class SemaAVR;
160class SemaBPF;
162class SemaCUDA;
163class SemaDirectX;
164class SemaHLSL;
165class SemaHexagon;
166class SemaLoongArch;
167class SemaM68k;
168class SemaMIPS;
169class SemaMSP430;
170class SemaNVPTX;
171class SemaObjC;
172class SemaOpenACC;
173class SemaOpenCL;
174class SemaOpenMP;
175class SemaPPC;
176class SemaPseudoObject;
177class SemaRISCV;
178class SemaSPIRV;
179class SemaSYCL;
180class SemaSwift;
181class SemaSystemZ;
182class SemaWasm;
183class SemaX86;
185class TemplateArgument;
190class Token;
191class TypeConstraint;
196
197namespace sema {
198class BlockScopeInfo;
199class Capture;
206class LambdaScopeInfo;
207class SemaPPCallbacks;
209} // namespace sema
210
211// AssignmentAction - This is used by all the assignment diagnostic functions
212// to represent what is actually causing the operation
223
224namespace threadSafety {
225class BeforeSet;
226void threadSafetyCleanup(BeforeSet *Cache);
227} // namespace threadSafety
228
229// FIXME: No way to easily map from TemplateTypeParmTypes to
230// TemplateTypeParmDecls, so we have this horrible PointerUnion.
231typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *,
232 const TemplateSpecializationType *,
233 const SubstBuiltinTemplatePackType *>,
236
237/// Describes whether we've seen any nullability information for the given
238/// file.
240 /// The first pointer declarator (of any pointer kind) in the file that does
241 /// not have a corresponding nullability annotation.
243
244 /// The end location for the first pointer declarator in the file. Used for
245 /// placing fix-its.
247
248 /// Which kind of pointer declarator we saw.
249 uint8_t PointerKind;
250
251 /// Whether we saw any type nullability annotations in the given file.
252 bool SawTypeNullability = false;
253};
254
255/// A mapping from file IDs to a record of whether we've seen nullability
256/// information in that file.
258 /// A mapping from file IDs to the nullability information for each file ID.
259 llvm::DenseMap<FileID, FileNullability> Map;
260
261 /// A single-element cache based on the file ID.
262 struct {
265 } Cache;
266
267public:
269 // Check the single-element cache.
270 if (file == Cache.File)
271 return Cache.Nullability;
272
273 // It's not in the single-element cache; flush the cache if we have one.
274 if (!Cache.File.isInvalid()) {
275 Map[Cache.File] = Cache.Nullability;
276 }
277
278 // Pull this entry into the cache.
279 Cache.File = file;
280 Cache.Nullability = Map[file];
281 return Cache.Nullability;
282 }
283};
284
285/// Tracks expected type during expression parsing, for use in code completion.
286/// The type is tied to a particular token, all functions that update or consume
287/// the type take a start location of the token they are looking at as a
288/// parameter. This avoids updating the type on hot paths in the parser.
290public:
292 : Ctx(Ctx), Enabled(Enabled) {}
293
297 /// Handles e.g. BaseType{ .D = Tok...
299 const Designation &D);
300 /// Computing a type for the function argument may require running
301 /// overloading, so we postpone its computation until it is actually needed.
302 ///
303 /// Clients should be very careful when using this function, as it stores a
304 /// function_ref, clients should make sure all calls to get() with the same
305 /// location happen while function_ref is alive.
306 ///
307 /// The callback should also emit signature help as a side-effect, but only
308 /// if the completion point has been reached.
310 llvm::function_ref<QualType()> ComputeType);
311
314 SourceLocation OpLoc);
317 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
318 /// Handles all type casts, including C-style cast, C++ casts, etc.
320
321 /// Get the expected type associated with this location, if any.
322 ///
323 /// If the location is a function argument, determining the expected type
324 /// involves considering all function overloads and the arguments so far.
325 /// In this case, signature help for these function overloads will be reported
326 /// as a side-effect (only if the completion point has been reached).
328 if (!Enabled || Tok != ExpectedLoc)
329 return QualType();
330 if (!Type.isNull())
331 return Type;
332 if (ComputeType)
333 return ComputeType();
334 return QualType();
335 }
336
337private:
338 ASTContext *Ctx;
339 bool Enabled;
340 /// Start position of a token for which we store expected type.
341 SourceLocation ExpectedLoc;
342 /// Expected type for a token starting at ExpectedLoc.
344 /// A function to compute expected type at ExpectedLoc. It is only considered
345 /// if Type is null.
346 llvm::function_ref<QualType()> ComputeType;
347};
348
350 SkipBodyInfo() = default;
351 bool ShouldSkip = false;
353 NamedDecl *Previous = nullptr;
354 NamedDecl *New = nullptr;
355};
356
357/// Describes the result of template argument deduction.
358///
359/// The TemplateDeductionResult enumeration describes the result of
360/// template argument deduction, as returned from
361/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
362/// structure provides additional information about the results of
363/// template argument deduction, e.g., the deduced template argument
364/// list (if successful) or the specific template parameters or
365/// deduced arguments that were involved in the failure.
367 /// Template argument deduction was successful.
369 /// The declaration was invalid; do nothing.
371 /// Template argument deduction exceeded the maximum template
372 /// instantiation depth (which has already been diagnosed).
374 /// Template argument deduction did not deduce a value
375 /// for every template parameter.
377 /// Template argument deduction did not deduce a value for every
378 /// expansion of an expanded template parameter pack.
380 /// Template argument deduction produced inconsistent
381 /// deduced values for the given template parameter.
383 /// Template argument deduction failed due to inconsistent
384 /// cv-qualifiers on a template parameter type that would
385 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
386 /// but were given a non-const "X".
388 /// Substitution of the deduced template argument values
389 /// resulted in an error.
391 /// After substituting deduced template arguments, a dependent
392 /// parameter type did not match the corresponding argument.
394 /// After substituting deduced template arguments, an element of
395 /// a dependent parameter type did not match the corresponding element
396 /// of the corresponding argument (when deducing from an initializer list).
398 /// A non-depnedent component of the parameter did not match the
399 /// corresponding component of the argument.
401 /// When performing template argument deduction for a function
402 /// template, there were too many call arguments.
404 /// When performing template argument deduction for a function
405 /// template, there were too few call arguments.
407 /// The explicitly-specified template arguments were not valid
408 /// template arguments for the given template.
410 /// Checking non-dependent argument conversions failed.
412 /// The deduced arguments did not satisfy the constraints associated
413 /// with the template.
415 /// Deduction failed; that's all we know.
417 /// CUDA Target attributes do not match.
419 /// Some error which was already diagnosed.
421};
422
423/// Kinds of C++ special members.
433
434/// The kind of conversion being performed.
436 /// An implicit conversion.
438 /// A C-style cast.
440 /// A functional-style cast.
442 /// A cast other than a C-style cast.
444 /// A conversion for an operand of a builtin overloaded operator.
446};
447
448enum class TagUseKind {
449 Reference, // Reference to a tag: 'struct foo *X;'
450 Declaration, // Fwd decl of a tag: 'struct foo;'
451 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
452 Friend // Friend declaration: 'friend struct foo;'
453};
454
455/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
456enum class FunctionEffectMode : uint8_t {
457 None, // effect is not present.
458 False, // effect(false).
459 True, // effect(true).
460 Dependent // effect(expr) where expr is dependent.
461};
462
463/// pragma clang section kind
466 BSS = 1,
467 Data = 2,
469 Text = 4,
471};
472
473enum class PragmaClangSectionAction { Set = 0, Clear = 1 };
474
476 Native, // #pragma options align=native
477 Natural, // #pragma options align=natural
478 Packed, // #pragma options align=packed
479 Power, // #pragma options align=power
480 Mac68k, // #pragma options align=mac68k
481 Reset // #pragma options align=reset
482};
483
484enum class TUFragmentKind {
485 /// The global module fragment, between 'module;' and a module-declaration.
487 /// A normal translation unit fragment. For a non-module unit, this is the
488 /// entire translation unit. Otherwise, it runs from the module-declaration
489 /// to the private-module-fragment (if any) or the end of the TU (if not).
491 /// The private module fragment, between 'module :private;' and the end of
492 /// the translation unit.
494};
495
508
509// Used for emitting the right warning by DefaultVariadicArgumentPromotion
517
526
527// Contexts where using non-trivial C union types can be disallowed. This is
528// passed to err_non_trivial_c_union_in_invalid_context.
530 // Function parameter.
532 // Function return.
534 // Default-initialized object.
536 // Variable with automatic storage duration.
538 // Initializer expression that might copy from another object.
540 // Assignment.
542 // Compound literal.
544 // Block capture.
546 // lvalue-to-rvalue conversion of volatile type.
548};
549
550/// Describes the result of the name lookup and resolution performed
551/// by \c Sema::ClassifyName().
553 /// This name is not a type or template in this context, but might be
554 /// something else.
556 /// Classification failed; an error has been produced.
558 /// The name has been typo-corrected to a keyword.
560 /// The name was classified as a type.
562 /// The name was classified as a specific non-type, non-template
563 /// declaration. ActOnNameClassifiedAsNonType should be called to
564 /// convert the declaration to an expression.
566 /// The name was classified as an ADL-only function name.
567 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
568 /// result to an expression.
570 /// The name denotes a member of a dependent type that could not be
571 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
572 /// convert the result to an expression.
574 /// The name was classified as an overload set, and an expression
575 /// representing that overload set has been formed.
576 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
577 /// expression referencing the overload set.
579 /// The name was classified as a template whose specializations are types.
581 /// The name was classified as a variable template name.
583 /// The name was classified as a function template name.
585 /// The name was classified as an ADL-only function template name.
587 /// The name was classified as a concept name.
589};
590
592 // Address discrimination argument of __ptrauth.
594
595 // Extra discriminator argument of __ptrauth.
597};
598
599/// Common ways to introduce type names without a tag for use in diagnostics.
600/// Keep in sync with err_tag_reference_non_tag.
612
613enum class OffsetOfKind {
614 // Not parsing a type within __builtin_offsetof.
616 // Parsing a type within __builtin_offsetof.
618 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
619 // To improve our diagnostic message.
621};
622
623/// Describes the kind of merge to perform for availability
624/// attributes (including "deprecated", "unavailable", and "availability").
626 /// Don't merge availability attributes at all.
628 /// Merge availability attributes for a redeclaration, which requires
629 /// an exact match.
631 /// Merge availability attributes for an override, which requires
632 /// an exact match or a weakening of constraints.
634 /// Merge availability attributes for an implementation of
635 /// a protocol requirement.
637 /// Merge availability attributes for an implementation of
638 /// an optional protocol requirement.
640};
641
643 /// The triviality of a method unaffected by "trivial_abi".
645
646 /// The triviality of a method affected by "trivial_abi".
648};
649
651
652enum class AllowFoldKind {
655};
656
657/// Context in which we're performing a usual arithmetic conversion.
658enum class ArithConvKind {
659 /// An arithmetic operation.
661 /// A bitwise operation.
663 /// A comparison.
665 /// A conditional (?:) operator.
667 /// A compound assignment expression.
669};
670
671// Used for determining in which context a type is allowed to be passed to a
672// vararg function.
680
681/// AssignConvertType - All of the 'assignment' semantic checks return this
682/// enum to indicate whether the assignment was allowed. These checks are
683/// done for simple assignments, as well as initialization, return from
684/// function, argument passing, etc. The query is phrased in terms of a
685/// source and destination type.
687 /// Compatible - the types are compatible according to the standard.
689
690 /// CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because
691 /// a void * can implicitly convert to another pointer type, which we
692 /// differentiate for better diagnostic behavior.
694
695 /// PointerToInt - The assignment converts a pointer to an int, which we
696 /// accept as an extension.
698
699 /// IntToPointer - The assignment converts an int to a pointer, which we
700 /// accept as an extension.
702
703 /// FunctionVoidPointer - The assignment is between a function pointer and
704 /// void*, which the standard doesn't allow, but we accept as an extension.
706
707 /// IncompatiblePointer - The assignment is between two pointers types that
708 /// are not compatible, but we accept them as an extension.
710
711 /// IncompatibleFunctionPointer - The assignment is between two function
712 /// pointers types that are not compatible, but we accept them as an
713 /// extension.
715
716 /// IncompatibleFunctionPointerStrict - The assignment is between two
717 /// function pointer types that are not identical, but are compatible,
718 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
719 /// may trip an indirect call runtime check.
721
722 /// IncompatiblePointerSign - The assignment is between two pointers types
723 /// which point to integers which have a different sign, but are otherwise
724 /// identical. This is a subset of the above, but broken out because it's by
725 /// far the most common case of incompatible pointers.
727
728 /// CompatiblePointerDiscardsQualifiers - The assignment discards
729 /// c/v/r qualifiers, which we accept as an extension.
731
732 /// IncompatiblePointerDiscardsQualifiers - The assignment
733 /// discards qualifiers that we don't permit to be discarded,
734 /// like address spaces.
736
737 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
738 /// changes address spaces in nested pointer types which is not allowed.
739 /// For instance, converting __private int ** to __generic int ** is
740 /// illegal even though __private could be converted to __generic.
742
743 /// IncompatibleNestedPointerQualifiers - The assignment is between two
744 /// nested pointer types, and the qualifiers other than the first two
745 /// levels differ e.g. char ** -> const char **, but we accept them as an
746 /// extension.
748
749 /// IncompatibleVectors - The assignment is between two vector types that
750 /// have the same size, which we accept as an extension.
752
753 /// IntToBlockPointer - The assignment converts an int to a block
754 /// pointer. We disallow this.
756
757 /// IncompatibleBlockPointer - The assignment is between two block
758 /// pointers types that are not compatible.
760
761 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
762 /// id type and something else (that is incompatible with it). For example,
763 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
765
766 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
767 /// object with __weak qualifier.
769
770 /// Incompatible - We reject this conversion outright, it is invalid to
771 /// represent it in the AST.
773};
774
775/// The scope in which to find allocation functions.
777 /// Only look for allocation functions in the global scope.
779 /// Only look for allocation functions in the scope of the
780 /// allocated class.
782 /// Look for allocation functions in both the global scope
783 /// and in the scope of the allocated class.
785};
786
787/// Describes the result of an "if-exists" condition check.
788enum class IfExistsResult {
789 /// The symbol exists.
791
792 /// The symbol does not exist.
794
795 /// The name is a dependent name, so the results will differ
796 /// from one instantiation to the next.
798
799 /// An error occurred.
801};
802
803enum class CorrectTypoKind {
804 NonError, // CorrectTypo used in a non error recovery situation.
805 ErrorRecovery // CorrectTypo used in normal error recovery.
806};
807
808enum class OverloadKind {
809 /// This is a legitimate overload: the existing declarations are
810 /// functions or function templates with different signatures.
812
813 /// This is not an overload because the signature exactly matches
814 /// an existing declaration.
816
817 /// This is not an overload because the lookup results contain a
818 /// non-function.
820};
821
822/// Contexts in which a converted constant expression is required.
823enum class CCEKind {
824 CaseValue, ///< Expression in a case label.
825 Enumerator, ///< Enumerator value with fixed underlying type.
826 TemplateArg, ///< Value of a non-type template parameter.
827 TempArgStrict, ///< As above, but applies strict template checking
828 ///< rules.
829 ArrayBound, ///< Array bound in array declarator or new-expression.
830 ExplicitBool, ///< Condition in an explicit(bool) specifier.
831 Noexcept, ///< Condition in a noexcept(bool) specifier.
832 StaticAssertMessageSize, ///< Call to size() in a static assert
833 ///< message.
834 StaticAssertMessageData, ///< Call to data() in a static assert
835 ///< message.
836};
837
838/// Enums for the diagnostics of target, target_version and target_clones.
839namespace DiagAttrParams {
843} // end namespace DiagAttrParams
844
845void inferNoReturnAttr(Sema &S, const Decl *D);
846
847#ifdef __GNUC__
848#pragma GCC diagnostic push
849#pragma GCC diagnostic ignored "-Wattributes"
850#endif
851/// Sema - This implements semantic analysis and AST building for C.
852/// \nosubgrouping
853class Sema final : public SemaBase {
854#ifdef __GNUC__
855#pragma GCC diagnostic pop
856#endif
857 // Table of Contents
858 // -----------------
859 // 1. Semantic Analysis (Sema.cpp)
860 // 2. API Notes (SemaAPINotes.cpp)
861 // 3. C++ Access Control (SemaAccess.cpp)
862 // 4. Attributes (SemaAttr.cpp)
863 // 5. Availability Attribute Handling (SemaAvailability.cpp)
864 // 6. Bounds Safety (SemaBoundsSafety.cpp)
865 // 7. Casts (SemaCast.cpp)
866 // 8. Extra Semantic Checking (SemaChecking.cpp)
867 // 9. C++ Coroutines (SemaCoroutine.cpp)
868 // 10. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
869 // 11. Declarations (SemaDecl.cpp)
870 // 12. Declaration Attribute Handling (SemaDeclAttr.cpp)
871 // 13. C++ Declarations (SemaDeclCXX.cpp)
872 // 14. C++ Exception Specifications (SemaExceptionSpec.cpp)
873 // 15. Expressions (SemaExpr.cpp)
874 // 16. C++ Expressions (SemaExprCXX.cpp)
875 // 17. Member Access Expressions (SemaExprMember.cpp)
876 // 18. Initializers (SemaInit.cpp)
877 // 19. C++ Lambda Expressions (SemaLambda.cpp)
878 // 20. Name Lookup (SemaLookup.cpp)
879 // 21. Modules (SemaModule.cpp)
880 // 22. C++ Overloading (SemaOverload.cpp)
881 // 23. Statements (SemaStmt.cpp)
882 // 24. `inline asm` Statement (SemaStmtAsm.cpp)
883 // 25. Statement Attribute Handling (SemaStmtAttr.cpp)
884 // 26. C++ Templates (SemaTemplate.cpp)
885 // 27. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
886 // 28. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
887 // 29. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
888 // 30. C++ Template Declaration Instantiation
889 // (SemaTemplateInstantiateDecl.cpp)
890 // 31. C++ Variadic Templates (SemaTemplateVariadic.cpp)
891 // 32. Constraints and Concepts (SemaConcept.cpp)
892 // 33. Types (SemaType.cpp)
893 // 34. FixIt Helpers (SemaFixItUtils.cpp)
894 // 35. Function Effects (SemaFunctionEffects.cpp)
895
896 /// \name Semantic Analysis
897 /// Implementations are in Sema.cpp
898 ///@{
899
900public:
901 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
903 CodeCompleteConsumer *CompletionConsumer = nullptr);
904 ~Sema();
905
906 /// Perform initialization that occurs after the parser has been
907 /// initialized but before it parses anything.
908 void Initialize();
909
910 /// This virtual key function only exists to limit the emission of debug info
911 /// describing the Sema class. GCC and Clang only emit debug info for a class
912 /// with a vtable when the vtable is emitted. Sema is final and not
913 /// polymorphic, but the debug info size savings are so significant that it is
914 /// worth adding a vtable just to take advantage of this optimization.
916
917 const LangOptions &getLangOpts() const { return LangOpts; }
920
923 Preprocessor &getPreprocessor() const { return PP; }
924 ASTContext &getASTContext() const { return Context; }
928
930 StringRef Platform);
932
933 /// Registers an external source. If an external source already exists,
934 /// creates a multiplex external source and appends to it.
935 ///
936 ///\param[in] E - A non-null external sema source.
937 ///
939
940 /// Print out statistics about the semantic analysis.
941 void PrintStats() const;
942
943 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
944 /// guaranteed). Produces a warning if we're low on stack space and allocates
945 /// more in that case. Use this in code that may recurse deeply (for example,
946 /// in template instantiation) to avoid stack overflow.
948 llvm::function_ref<void()> Fn);
949
950 /// Returns default addr space for method qualifiers.
952
953 /// Load weak undeclared identifiers from the external source.
955
956 /// Determine if VD, which must be a variable or function, is an external
957 /// symbol that nonetheless can't be referenced from outside this translation
958 /// unit because its type has no linkage and it's not extern "C".
959 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
960
961 /// Obtain a sorted list of functions that are undefined but ODR-used.
963 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
964
965 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
967 /// Retrieves list of suspicious delete-expressions that will be checked at
968 /// the end of translation unit.
969 const llvm::MapVector<FieldDecl *, DeleteLocs> &
971
972 /// Cause the built diagnostic to be emitted on the DiagosticsEngine.
973 /// This is closely coupled to the SemaDiagnosticBuilder class and
974 /// should not be used elsewhere.
975 void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB);
976
977 void addImplicitTypedef(StringRef Name, QualType T);
978
979 /// Whether uncompilable error has occurred. This includes error happens
980 /// in deferred diagnostics.
981 bool hasUncompilableErrorOccurred() const;
982
983 /// Looks through the macro-expansion chain for the given
984 /// location, looking for a macro expansion with the given name.
985 /// If one is found, returns true and sets the location to that
986 /// expansion loc.
987 bool findMacroSpelling(SourceLocation &loc, StringRef name);
988
989 /// Calls \c Lexer::getLocForEndOfToken()
990 SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0);
991
992 /// Calls \c Lexer::findNextToken() to find the next token, and if the
993 /// locations of both ends of the token can be resolved it return that
994 /// range; Otherwise it returns an invalid SourceRange.
996 SourceLocation Loc, bool IncludeMacros, bool IncludeComments,
997 std::optional<tok::TokenKind> ExpectedToken = std::nullopt);
998
999 /// Retrieve the module loader associated with the preprocessor.
1001
1002 /// Invent a new identifier for parameters of abbreviated templates.
1005 unsigned Index);
1006
1008
1009 // Emit all deferred diagnostics.
1010 void emitDeferredDiags();
1011
1012 /// This is called before the very first declaration in the translation unit
1013 /// is parsed. Note that the ASTContext may have already injected some
1014 /// declarations.
1016 /// ActOnEndOfTranslationUnit - This is called at the very end of the
1017 /// translation unit when EOF is reached and all but the top-level scope is
1018 /// popped.
1021
1022 /// Determines the active Scope associated with the given declaration
1023 /// context.
1024 ///
1025 /// This routine maps a declaration context to the active Scope object that
1026 /// represents that declaration context in the parser. It is typically used
1027 /// from "scope-less" code (e.g., template instantiation, lazy creation of
1028 /// declarations) that injects a name for name-lookup purposes and, therefore,
1029 /// must update the Scope.
1030 ///
1031 /// \returns The scope corresponding to the given declaraion context, or NULL
1032 /// if no such scope is open.
1034
1035 void PushFunctionScope();
1036 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
1038
1039 /// This is used to inform Sema what the current TemplateParameterDepth
1040 /// is during Parsing. Currently it is used to pass on the depth
1041 /// when parsing generic lambda 'auto' parameters.
1042 void RecordParsingTemplateParameterDepth(unsigned Depth);
1043
1044 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
1046 unsigned OpenMPCaptureLevel = 0);
1047
1048 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
1049 /// time after they've been popped.
1051 Sema *Self;
1052
1053 public:
1054 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
1056 };
1057
1059 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
1060
1061 /// Pop a function (or block or lambda or captured region) scope from the
1062 /// stack.
1063 ///
1064 /// \param WP The warning policy to use for CFG-based warnings, or null if
1065 /// such warnings should not be produced.
1066 /// \param D The declaration corresponding to this function scope, if
1067 /// producing CFG-based warnings.
1068 /// \param BlockType The type of the block expression, if D is a BlockDecl.
1071 const Decl *D = nullptr,
1072 QualType BlockType = QualType());
1073
1075
1080
1081 void PushCompoundScope(bool IsStmtExpr);
1082 void PopCompoundScope();
1083
1084 /// Determine whether any errors occurred within this function/method/
1085 /// block.
1087
1088 /// Retrieve the current block, if any.
1090
1091 /// Get the innermost lambda or block enclosing the current location, if any.
1092 /// This looks through intervening non-lambda, non-block scopes such as local
1093 /// functions.
1095
1096 /// Retrieve the current lambda scope info, if any.
1097 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
1098 /// lambda scope info ignoring all inner capturing scopes that are not
1099 /// lambda scopes.
1101 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
1102
1103 /// Retrieve the current generic lambda info, if any.
1105
1106 /// Retrieve the current captured region, if any.
1108
1109 void ActOnComment(SourceRange Comment);
1110
1111 /// Retrieve the parser's current scope.
1112 ///
1113 /// This routine must only be used when it is certain that semantic analysis
1114 /// and the parser are in precisely the same context, which is not the case
1115 /// when, e.g., we are performing any kind of template instantiation.
1116 /// Therefore, the only safe places to use this scope are in the parser
1117 /// itself and in routines directly invoked from the parser and *never* from
1118 /// template substitution or instantiation.
1119 Scope *getCurScope() const { return CurScope; }
1120
1122
1126
1127 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
1128 const FunctionDecl *FD = nullptr);
1130 const PartialDiagnostic &PD,
1131 const FunctionDecl *FD = nullptr) {
1132 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
1133 }
1134
1135 /// Check if the type is allowed to be used for the current target.
1137 ValueDecl *D = nullptr);
1138
1139 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
1140 /// cast. If there is already an implicit cast, merge into the existing one.
1141 /// If isLvalue, the result of the cast is an lvalue.
1144 const CXXCastPath *BasePath = nullptr,
1146
1147 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
1148 /// to the conversion from scalar type ScalarTy to the Boolean type.
1150
1151 /// If \p AllowLambda is true, treat lambda as function.
1152 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
1153
1154 /// Returns a pointer to the innermost enclosing function, or nullptr if the
1155 /// current context is not inside a function. If \p AllowLambda is true,
1156 /// this can return the call operator of an enclosing lambda, otherwise
1157 /// lambdas are skipped when looking for an enclosing function.
1158 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
1159
1160 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
1161 /// the method decl for the method being parsed. If we're currently
1162 /// in a 'block', this returns the containing context.
1164
1165 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
1166 /// or C function we're in, otherwise return null. If we're currently
1167 /// in a 'block', this returns the containing context.
1169
1170 /// Warn if we're implicitly casting from a _Nullable pointer type to a
1171 /// _Nonnull one.
1173 SourceLocation Loc);
1174
1175 /// Warn when implicitly casting 0 to nullptr.
1176 void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
1177
1178 /// Warn when implicitly changing function effects.
1180 SourceLocation Loc);
1181
1182 /// makeUnavailableInSystemHeader - There is an error in the current
1183 /// context. If we're still in a system header, and we can plausibly
1184 /// make the relevant declaration unavailable instead of erroring, do
1185 /// so and return true.
1187 UnavailableAttr::ImplicitReason reason);
1188
1189 /// Retrieve a suitable printing policy for diagnostics.
1193
1194 /// Retrieve a suitable printing policy for diagnostics.
1196 const Preprocessor &PP);
1197
1198 /// Scope actions.
1200
1201 /// Determine whether \param D is function like (function or function
1202 /// template) for parsing.
1204
1205 /// The maximum alignment, same as in llvm::Value. We duplicate them here
1206 /// because that allows us not to duplicate the constants in clang code,
1207 /// which we must to since we can't directly use the llvm constants.
1208 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
1209 ///
1210 /// This is the greatest alignment value supported by load, store, and alloca
1211 /// instructions, and global values.
1212 static const unsigned MaxAlignmentExponent = 32;
1213 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
1214
1215 /// Flag indicating whether or not to collect detailed statistics.
1217
1218 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
1219
1220 /// Stack containing information about each of the nested
1221 /// function, block, and method scopes that are currently active.
1223
1224 /// The index of the first FunctionScope that corresponds to the current
1225 /// context.
1227
1228 /// Track the number of currently active capturing scopes.
1230
1231 llvm::BumpPtrAllocator BumpAlloc;
1232
1233 /// The kind of translation unit we are processing.
1234 ///
1235 /// When we're processing a complete translation unit, Sema will perform
1236 /// end-of-translation-unit semantic tasks (such as creating
1237 /// initializers for tentative definitions in C) once parsing has
1238 /// completed. Modules and precompiled headers perform different kinds of
1239 /// checks.
1241
1242 /// Translation Unit Scope - useful to Objective-C actions that need
1243 /// to lookup file scope declarations in the "ordinary" C decl namespace.
1244 /// For example, user-defined classes, built-in "id" type, etc.
1246
1248 return CurScope->incrementMSManglingNumber();
1249 }
1250
1251 /// Try to recover by turning the given expression into a
1252 /// call. Returns true if recovery was attempted or an error was
1253 /// emitted; this may also leave the ExprResult invalid.
1255 bool ForceComplain = false,
1256 bool (*IsPlausibleResult)(QualType) = nullptr);
1257
1258 /// Figure out if an expression could be turned into a call.
1259 ///
1260 /// Use this when trying to recover from an error where the programmer may
1261 /// have written just the name of a function instead of actually calling it.
1262 ///
1263 /// \param E - The expression to examine.
1264 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
1265 /// with no arguments, this parameter is set to the type returned by such a
1266 /// call; otherwise, it is set to an empty QualType.
1267 /// \param OverloadSet - If the expression is an overloaded function
1268 /// name, this parameter is populated with the decls of the various
1269 /// overloads.
1270 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
1271 UnresolvedSetImpl &NonTemplateOverloads);
1272
1276
1279
1287
1288 /// A RAII object to enter scope of a compound statement.
1290 public:
1291 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
1292 S.ActOnStartOfCompoundStmt(IsStmtExpr);
1293 }
1294
1295 ~CompoundScopeRAII() { S.ActOnFinishOfCompoundStmt(); }
1296
1297 private:
1298 Sema &S;
1299 };
1300
1301 /// An RAII helper that pops function a function scope on exit.
1307 if (Active)
1308 S.PopFunctionScopeInfo();
1309 }
1310 void disable() { Active = false; }
1311 };
1312
1314 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
1315 }
1316
1317 /// Worker object for performing CFG-based warnings.
1320
1321 /// Callback to the parser to parse templated functions when needed.
1322 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
1323 typedef void LateTemplateParserCleanupCB(void *P);
1327
1329 LateTemplateParserCleanupCB *LTPCleanup, void *P) {
1330 LateTemplateParser = LTP;
1331 LateTemplateParserCleanup = LTPCleanup;
1332 OpaqueParser = P;
1333 }
1334
1335 /// Callback to the parser to parse a type expressed as a string.
1336 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
1338
1339 /// VAListTagName - The declaration name corresponding to __va_list_tag.
1340 /// This is used as part of a hack to omit that class from ADL results.
1342
1343 /// Is the last error level diagnostic immediate. This is used to determined
1344 /// whether the next info diagnostic should be immediate.
1346
1347 class DelayedDiagnostics;
1348
1350 sema::DelayedDiagnosticPool *SavedPool = nullptr;
1352 };
1355
1356 /// A class which encapsulates the logic for delaying diagnostics
1357 /// during parsing and other processing.
1359 /// The current pool of diagnostics into which delayed
1360 /// diagnostics should go.
1361 sema::DelayedDiagnosticPool *CurPool = nullptr;
1362
1363 public:
1365
1366 /// Adds a delayed diagnostic.
1367 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
1368
1369 /// Determines whether diagnostics should be delayed.
1370 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
1371
1372 /// Returns the current delayed-diagnostics pool.
1373 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1374
1375 /// Enter a new scope. Access and deprecation diagnostics will be
1376 /// collected in this pool.
1379 state.SavedPool = CurPool;
1380 CurPool = &pool;
1381 return state;
1382 }
1383
1384 /// Leave a delayed-diagnostic state that was previously pushed.
1385 /// Do not emit any of the diagnostics. This is performed as part
1386 /// of the bookkeeping of popping a pool "properly".
1388 CurPool = state.SavedPool;
1389 }
1390
1391 /// Enter a new scope where access and deprecation diagnostics are
1392 /// not delayed.
1395 state.SavedPool = CurPool;
1396 CurPool = nullptr;
1397 return state;
1398 }
1399
1400 /// Undo a previous pushUndelayed().
1402 assert(CurPool == nullptr);
1403 CurPool = state.SavedPool;
1404 }
1406
1410
1411 /// Diagnostics that are emitted only if we discover that the given function
1412 /// must be codegen'ed. Because handling these correctly adds overhead to
1413 /// compilation, this is currently only enabled for CUDA compilations.
1414 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1415
1416 /// CurContext - This is the current declaration context of parsing.
1418
1420 assert(AMDGPUPtr);
1421 return *AMDGPUPtr;
1422 }
1423
1425 assert(ARMPtr);
1426 return *ARMPtr;
1427 }
1428
1430 assert(AVRPtr);
1431 return *AVRPtr;
1432 }
1433
1435 assert(BPFPtr);
1436 return *BPFPtr;
1437 }
1438
1440 assert(CodeCompletionPtr);
1441 return *CodeCompletionPtr;
1442 }
1443
1445 assert(CUDAPtr);
1446 return *CUDAPtr;
1447 }
1448
1450 assert(DirectXPtr);
1451 return *DirectXPtr;
1452 }
1453
1455 assert(HLSLPtr);
1456 return *HLSLPtr;
1457 }
1458
1460 assert(HexagonPtr);
1461 return *HexagonPtr;
1462 }
1463
1465 assert(LoongArchPtr);
1466 return *LoongArchPtr;
1467 }
1468
1470 assert(M68kPtr);
1471 return *M68kPtr;
1472 }
1473
1475 assert(MIPSPtr);
1476 return *MIPSPtr;
1477 }
1478
1480 assert(MSP430Ptr);
1481 return *MSP430Ptr;
1482 }
1483
1485 assert(NVPTXPtr);
1486 return *NVPTXPtr;
1487 }
1488
1490 assert(ObjCPtr);
1491 return *ObjCPtr;
1492 }
1493
1495 assert(OpenACCPtr);
1496 return *OpenACCPtr;
1497 }
1498
1500 assert(OpenCLPtr);
1501 return *OpenCLPtr;
1502 }
1503
1505 assert(OpenMPPtr && "SemaOpenMP is dead");
1506 return *OpenMPPtr;
1507 }
1508
1510 assert(PPCPtr);
1511 return *PPCPtr;
1512 }
1513
1515 assert(PseudoObjectPtr);
1516 return *PseudoObjectPtr;
1517 }
1518
1520 assert(RISCVPtr);
1521 return *RISCVPtr;
1522 }
1523
1525 assert(SPIRVPtr);
1526 return *SPIRVPtr;
1527 }
1528
1530 assert(SYCLPtr);
1531 return *SYCLPtr;
1532 }
1533
1535 assert(SwiftPtr);
1536 return *SwiftPtr;
1537 }
1538
1540 assert(SystemZPtr);
1541 return *SystemZPtr;
1542 }
1543
1545 assert(WasmPtr);
1546 return *WasmPtr;
1547 }
1548
1550 assert(X86Ptr);
1551 return *X86Ptr;
1552 }
1553
1554 /// Source of additional semantic information.
1556
1557protected:
1558 friend class Parser;
1560 friend class ASTReader;
1561 friend class ASTDeclReader;
1562 friend class ASTWriter;
1563
1564private:
1565 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1566 bool WarnedDarwinSDKInfoMissing = false;
1567
1568 StackExhaustionHandler StackHandler;
1569
1570 Sema(const Sema &) = delete;
1571 void operator=(const Sema &) = delete;
1572
1573 /// The handler for the FileChanged preprocessor events.
1574 ///
1575 /// Used for diagnostics that implement custom semantic analysis for #include
1576 /// directives, like -Wpragma-pack.
1577 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1578
1579 /// The parser's current scope.
1580 ///
1581 /// The parser maintains this state here.
1582 Scope *CurScope;
1583
1584 mutable IdentifierInfo *Ident_super;
1585
1586 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1587 std::unique_ptr<SemaARM> ARMPtr;
1588 std::unique_ptr<SemaAVR> AVRPtr;
1589 std::unique_ptr<SemaBPF> BPFPtr;
1590 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1591 std::unique_ptr<SemaCUDA> CUDAPtr;
1592 std::unique_ptr<SemaDirectX> DirectXPtr;
1593 std::unique_ptr<SemaHLSL> HLSLPtr;
1594 std::unique_ptr<SemaHexagon> HexagonPtr;
1595 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1596 std::unique_ptr<SemaM68k> M68kPtr;
1597 std::unique_ptr<SemaMIPS> MIPSPtr;
1598 std::unique_ptr<SemaMSP430> MSP430Ptr;
1599 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1600 std::unique_ptr<SemaObjC> ObjCPtr;
1601 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1602 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1603 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1604 std::unique_ptr<SemaPPC> PPCPtr;
1605 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1606 std::unique_ptr<SemaRISCV> RISCVPtr;
1607 std::unique_ptr<SemaSPIRV> SPIRVPtr;
1608 std::unique_ptr<SemaSYCL> SYCLPtr;
1609 std::unique_ptr<SemaSwift> SwiftPtr;
1610 std::unique_ptr<SemaSystemZ> SystemZPtr;
1611 std::unique_ptr<SemaWasm> WasmPtr;
1612 std::unique_ptr<SemaX86> X86Ptr;
1613
1614 ///@}
1615
1616 //
1617 //
1618 // -------------------------------------------------------------------------
1619 //
1620 //
1621
1622 /// \name API Notes
1623 /// Implementations are in SemaAPINotes.cpp
1624 ///@{
1625
1626public:
1627 /// Map any API notes provided for this declaration to attributes on the
1628 /// declaration.
1629 ///
1630 /// Triggered by declaration-attribute processing.
1631 void ProcessAPINotes(Decl *D);
1632 /// Apply the 'Nullability:' annotation to the specified declaration
1633 void ApplyNullability(Decl *D, NullabilityKind Nullability);
1634 /// Apply the 'Type:' annotation to the specified declaration
1635 void ApplyAPINotesType(Decl *D, StringRef TypeString);
1636
1637 /// Whether APINotes should be gathered for all applicable Swift language
1638 /// versions, without being applied. Leaving clients of the current module
1639 /// to select and apply the correct version.
1641 return APINotes.captureVersionIndependentSwift();
1642 }
1643 ///@}
1644
1645 //
1646 //
1647 // -------------------------------------------------------------------------
1648 //
1649 //
1650
1651 /// \name C++ Access Control
1652 /// Implementations are in SemaAccess.cpp
1653 ///@{
1654
1655public:
1662
1663 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1664 /// Returns true on error (when the previous member decl access specifier
1665 /// is different from the new member decl access specifier).
1666 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1667 NamedDecl *PrevMemberDecl,
1668 AccessSpecifier LexicalAS);
1669
1670 /// Perform access-control checking on a previously-unresolved member
1671 /// access which has now been resolved to a member.
1673 DeclAccessPair FoundDecl);
1675 DeclAccessPair FoundDecl);
1676
1677 /// Checks access to an overloaded operator new or delete.
1679 SourceRange PlacementRange,
1680 CXXRecordDecl *NamingClass,
1681 DeclAccessPair FoundDecl,
1682 bool Diagnose = true);
1683
1684 /// Checks access to a constructor.
1686 DeclAccessPair FoundDecl,
1687 const InitializedEntity &Entity,
1688 bool IsCopyBindingRefToTemp = false);
1689
1690 /// Checks access to a constructor.
1692 DeclAccessPair FoundDecl,
1693 const InitializedEntity &Entity,
1694 const PartialDiagnostic &PDiag);
1696 CXXDestructorDecl *Dtor,
1697 const PartialDiagnostic &PDiag,
1698 QualType objectType = QualType());
1699
1700 /// Checks access to the target of a friend declaration.
1702
1703 /// Checks access to a member.
1705 CXXRecordDecl *NamingClass,
1707
1708 /// Checks implicit access to a member in a structured binding.
1711 CXXRecordDecl *DecomposedClass,
1712 DeclAccessPair Field);
1714 const SourceRange &,
1715 DeclAccessPair FoundDecl);
1716
1717 /// Checks access to an overloaded member operator, including
1718 /// conversion operators.
1720 Expr *ArgExpr,
1721 DeclAccessPair FoundDecl);
1723 ArrayRef<Expr *> ArgExprs,
1724 DeclAccessPair FoundDecl);
1726 DeclAccessPair FoundDecl);
1727
1728 /// Checks access for a hierarchy conversion.
1729 ///
1730 /// \param ForceCheck true if this check should be performed even if access
1731 /// control is disabled; some things rely on this for semantics
1732 /// \param ForceUnprivileged true if this check should proceed as if the
1733 /// context had no special privileges
1735 QualType Derived, const CXXBasePath &Path,
1736 unsigned DiagID, bool ForceCheck = false,
1737 bool ForceUnprivileged = false);
1738
1740 SourceLocation AccessLoc, CXXRecordDecl *Base, CXXRecordDecl *Derived,
1741 const CXXBasePath &Path, unsigned DiagID,
1742 llvm::function_ref<void(PartialDiagnostic &PD)> SetupPDiag,
1743 bool ForceCheck = false, bool ForceUnprivileged = false);
1744
1745 /// Checks access to all the declarations in the given result set.
1746 void CheckLookupAccess(const LookupResult &R);
1747
1748 /// Checks access to Target from the given class. The check will take access
1749 /// specifiers into account, but no member access expressions and such.
1750 ///
1751 /// \param Target the declaration to check if it can be accessed
1752 /// \param NamingClass the class in which the lookup was started.
1753 /// \param BaseType type of the left side of member access expression.
1754 /// \p BaseType and \p NamingClass are used for C++ access control.
1755 /// Depending on the lookup case, they should be set to the following:
1756 /// - lhs.target (member access without a qualifier):
1757 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1758 /// - lhs.X::target (member access with a qualifier):
1759 /// BaseType is the type of 'lhs', NamingClass is 'X'
1760 /// - X::target (qualified lookup without member access):
1761 /// BaseType is null, NamingClass is 'X'.
1762 /// - target (unqualified lookup).
1763 /// BaseType is null, NamingClass is the parent class of 'target'.
1764 /// \return true if the Target is accessible from the Class, false otherwise.
1765 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1766 QualType BaseType);
1767
1768 /// Is the given member accessible for the purposes of deciding whether to
1769 /// define a special member function as deleted?
1771 DeclAccessPair Found, QualType ObjectType,
1772 SourceLocation Loc,
1773 const PartialDiagnostic &Diag);
1776 QualType ObjectType) {
1777 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1778 SourceLocation(), PDiag());
1779 }
1780
1782 const DependentDiagnostic &DD,
1783 const MultiLevelTemplateArgumentList &TemplateArgs);
1785
1786 ///@}
1787
1788 //
1789 //
1790 // -------------------------------------------------------------------------
1791 //
1792 //
1793
1794 /// \name Attributes
1795 /// Implementations are in SemaAttr.cpp
1796 ///@{
1797
1798public:
1799 /// Controls member pointer representation format under the MS ABI.
1802
1803 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1804
1805 /// Source location for newly created implicit MSInheritanceAttrs
1807
1813
1819
1821 PSK_Reset = 0x0, // #pragma ()
1822 PSK_Set = 0x1, // #pragma (value)
1823 PSK_Push = 0x2, // #pragma (push[, id])
1824 PSK_Pop = 0x4, // #pragma (pop[, id])
1825 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1826 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1827 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1828 };
1829
1835
1836 // #pragma pack and align.
1838 public:
1839 // `Native` represents default align mode, which may vary based on the
1840 // platform.
1841 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1842
1843 // #pragma pack info constructor
1844 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1845 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1846 assert(Num == PackNumber && "The pack number has been truncated.");
1847 }
1848
1849 // #pragma align info constructor
1851 : PackAttr(false), AlignMode(M),
1852 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1853
1854 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1855
1857
1858 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1859 // integer encoding for it. This should only be passed to
1860 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1861 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1862 std::uint32_t Encoding{};
1863 if (Info.IsXLStack())
1864 Encoding |= IsXLMask;
1865
1866 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1867
1868 if (Info.IsPackAttr())
1869 Encoding |= PackAttrMask;
1870
1871 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1872
1873 return Encoding;
1874 }
1875
1876 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1877 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1879 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1880 int PackNumber = (Encoding & PackNumMask) >> 4;
1881
1882 if (Encoding & PackAttrMask)
1883 return AlignPackInfo(M, PackNumber, IsXL);
1884
1885 return AlignPackInfo(M, IsXL);
1886 }
1887
1888 bool IsPackAttr() const { return PackAttr; }
1889
1890 bool IsAlignAttr() const { return !PackAttr; }
1891
1892 Mode getAlignMode() const { return AlignMode; }
1893
1894 unsigned getPackNumber() const { return PackNumber; }
1895
1896 bool IsPackSet() const {
1897 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1898 // attriute on a decl.
1899 return PackNumber != UninitPackVal && PackNumber != 0;
1900 }
1901
1902 bool IsXLStack() const { return XLStack; }
1903
1904 bool operator==(const AlignPackInfo &Info) const {
1905 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1906 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1907 Info.XLStack);
1908 }
1909
1910 bool operator!=(const AlignPackInfo &Info) const {
1911 return !(*this == Info);
1912 }
1913
1914 private:
1915 /// \brief True if this is a pragma pack attribute,
1916 /// not a pragma align attribute.
1917 bool PackAttr;
1918
1919 /// \brief The alignment mode that is in effect.
1920 Mode AlignMode;
1921
1922 /// \brief The pack number of the stack.
1923 unsigned char PackNumber;
1924
1925 /// \brief True if it is a XL #pragma align/pack stack.
1926 bool XLStack;
1927
1928 /// \brief Uninitialized pack value.
1929 static constexpr unsigned char UninitPackVal = -1;
1930
1931 // Masks to encode and decode an AlignPackInfo.
1932 static constexpr uint32_t IsXLMask{0x0000'0001};
1933 static constexpr uint32_t AlignModeMask{0x0000'0006};
1934 static constexpr uint32_t PackAttrMask{0x00000'0008};
1935 static constexpr uint32_t PackNumMask{0x0000'01F0};
1936 };
1937
1938 template <typename ValueType> struct PragmaStack {
1950
1951 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1952 llvm::StringRef StackSlotLabel, ValueType Value) {
1953 if (Action == PSK_Reset) {
1955 CurrentPragmaLocation = PragmaLocation;
1956 return;
1957 }
1958 if (Action & PSK_Push)
1959 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1960 PragmaLocation);
1961 else if (Action & PSK_Pop) {
1962 if (!StackSlotLabel.empty()) {
1963 // If we've got a label, try to find it and jump there.
1964 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1965 return x.StackSlotLabel == StackSlotLabel;
1966 });
1967 // If we found the label so pop from there.
1968 if (I != Stack.rend()) {
1969 CurrentValue = I->Value;
1970 CurrentPragmaLocation = I->PragmaLocation;
1971 Stack.erase(std::prev(I.base()), Stack.end());
1972 }
1973 } else if (!Stack.empty()) {
1974 // We do not have a label, just pop the last entry.
1975 CurrentValue = Stack.back().Value;
1976 CurrentPragmaLocation = Stack.back().PragmaLocation;
1977 Stack.pop_back();
1978 }
1979 }
1980 if (Action & PSK_Set) {
1982 CurrentPragmaLocation = PragmaLocation;
1983 }
1984 }
1985
1986 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1987 // method body to restore the stacks on exit, so it works like this:
1988 //
1989 // struct S {
1990 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1991 // void Method {}
1992 // #pragma <name>(pop, InternalPragmaSlot)
1993 // };
1994 //
1995 // It works even with #pragma vtordisp, although MSVC doesn't support
1996 // #pragma vtordisp(push [, id], n)
1997 // syntax.
1998 //
1999 // Push / pop a named sentinel slot.
2000 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
2001 assert((Action == PSK_Push || Action == PSK_Pop) &&
2002 "Can only push / pop #pragma stack sentinels!");
2003 Act(CurrentPragmaLocation, Action, Label, CurrentValue);
2004 }
2005
2006 // Constructors.
2007 explicit PragmaStack(const ValueType &Default)
2009
2010 bool hasValue() const { return CurrentValue != DefaultValue; }
2011
2013 ValueType DefaultValue; // Value used for PSK_Reset action.
2014 ValueType CurrentValue;
2016 };
2017 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
2018 // we shouldn't do so if they're in a module).
2019
2020 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
2021 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
2022 ///
2023 /// 0: Suppress all vtordisps
2024 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
2025 /// structors
2026 /// 2: Always insert vtordisps to support RTTI on partially constructed
2027 /// objects
2030 // The current #pragma align/pack values and locations at each #include.
2037 // Segment #pragmas.
2042
2043 // #pragma strict_gs_check.
2045
2046 // This stack tracks the current state of Sema.CurFPFeatures.
2049 FPOptionsOverride result;
2050 if (!FpPragmaStack.hasValue()) {
2051 result = FPOptionsOverride();
2052 } else {
2053 result = FpPragmaStack.CurrentValue;
2054 }
2055 return result;
2056 }
2057
2064
2065 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
2066 // Actions should be performed only if we enter / exit a C++ method body.
2068 public:
2069 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
2071
2072 private:
2073 Sema &S;
2074 StringRef SlotLabel;
2075 bool ShouldAct;
2076 };
2077
2078 /// Last section used with #pragma init_seg.
2081
2082 /// Sections used with #pragma alloc_text.
2083 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
2084
2085 /// VisContext - Manages the stack for \#pragma GCC visibility.
2086 void *VisContext; // Really a "PragmaVisStack*"
2087
2088 /// This an attribute introduced by \#pragma clang attribute.
2095
2096 /// A push'd group of PragmaAttributeEntries.
2098 /// The location of the push attribute.
2100 /// The namespace of this push group.
2103 };
2104
2106
2107 /// The declaration that is currently receiving an attribute from the
2108 /// #pragma attribute stack.
2110
2111 /// This represents the last location of a "#pragma clang optimize off"
2112 /// directive if such a directive has not been closed by an "on" yet. If
2113 /// optimizations are currently "on", this is set to an invalid location.
2115
2116 /// Get the location for the currently active "\#pragma clang optimize
2117 /// off". If this location is invalid, then the state of the pragma is "on".
2121
2122 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
2123 /// whether the optimizations in the list passed to the pragma should be
2124 /// turned off or on. This boolean is true by default because command line
2125 /// options are honored when `#pragma optimize("", on)`.
2126 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
2128
2129 /// Set of no-builtin functions listed by \#pragma function.
2131
2132 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
2133 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
2135
2136 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
2138
2139 /// Add gsl::Pointer attribute to std::container::iterator
2140 /// \param ND The declaration that introduces the name
2141 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
2142 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
2143
2144 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
2146
2147 /// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
2149
2150 /// Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
2152
2153 /// Add [[gsl::Pointer]] attributes for std:: types.
2155
2156 LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
2157 StringRef ParamName);
2158 // Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'
2159 // can be the name of a function parameter, we need to parse the function
2160 // declaration and rest of the parameters before processesing 'X'. Therefore
2161 // do this lazily instead of processing while parsing the annotation itself.
2163
2164 /// Add _Nullable attributes for std:: types.
2166
2167 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
2170 PragmaClangSectionKind SecKind,
2171 StringRef SecName);
2172
2173 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
2175 SourceLocation PragmaLoc);
2176
2177 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
2178 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
2179 StringRef SlotLabel, Expr *Alignment);
2180
2181 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
2182 /// (unless they are value dependent or type dependent). Returns false
2183 /// and emits a diagnostic if one or more of the arguments could not be
2184 /// folded into a constant.
2187
2192
2194 SourceLocation IncludeLoc);
2196
2197 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
2199
2200 /// ActOnPragmaMSComment - Called on well formed
2201 /// \#pragma comment(kind, "arg").
2203 StringRef Arg);
2204
2205 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
2206 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
2207 StringRef Value);
2208
2209 /// Are precise floating point semantics currently enabled?
2211 return !CurFPFeatures.getAllowFPReassociate() &&
2212 !CurFPFeatures.getNoSignedZero() &&
2213 !CurFPFeatures.getAllowReciprocal() &&
2214 !CurFPFeatures.getAllowApproxFunc();
2215 }
2216
2219
2220 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
2221 void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action,
2223
2224 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
2225 /// pointers_to_members(representation method[, general purpose
2226 /// representation]).
2229 SourceLocation PragmaLoc);
2230
2231 /// Called on well formed \#pragma vtordisp().
2232 void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
2234
2235 bool UnifySection(StringRef SectionName, int SectionFlags,
2236 NamedDecl *TheDecl);
2237 bool UnifySection(StringRef SectionName, int SectionFlags,
2238 SourceLocation PragmaSectionLocation);
2239
2240 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
2241 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
2242 PragmaMsStackAction Action,
2243 llvm::StringRef StackSlotLabel,
2244 StringLiteral *SegmentName, llvm::StringRef PragmaName);
2245
2246 /// Called on well formed \#pragma section().
2247 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
2248 StringLiteral *SegmentName);
2249
2250 /// Called on well-formed \#pragma init_seg().
2251 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
2252 StringLiteral *SegmentName);
2253
2254 /// Called on well-formed \#pragma alloc_text().
2256 SourceLocation PragmaLocation, StringRef Section,
2257 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
2258 &Functions);
2259
2260 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
2261 /// strict_gs_check.
2263 PragmaMsStackAction Action,
2264 bool Value);
2265
2266 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
2267 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
2268 SourceLocation PragmaLoc);
2269
2271 SourceLocation PragmaLoc,
2274 const IdentifierInfo *Namespace);
2275
2276 /// Called on well-formed '\#pragma clang attribute pop'.
2278 const IdentifierInfo *Namespace);
2279
2280 /// Adds the attributes that have been specified using the
2281 /// '\#pragma clang attribute push' directives to the given declaration.
2282 void AddPragmaAttributes(Scope *S, Decl *D);
2283
2285 llvm::function_ref<void(SourceLocation, PartialDiagnostic)>;
2287 return [this](SourceLocation Loc, PartialDiagnostic PD) {
2288 // This bypasses a lot of the filters in the diag engine, as it's
2289 // to be used to attach notes to diagnostics which have already
2290 // been filtered through.
2291 DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
2292 PD.Emit(Builder);
2293 };
2294 }
2295
2301
2303
2304 /// Called on well formed \#pragma clang optimize.
2305 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
2306
2307 /// #pragma optimize("[optimization-list]", on | off).
2308 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
2309
2310 /// Call on well formed \#pragma function.
2311 void
2313 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
2314
2315 /// Only called on function definitions; if there is a pragma in scope
2316 /// with the effect of a range-based optnone, consider marking the function
2317 /// with attribute optnone.
2319
2320 /// Only called on function definitions; if there is a `#pragma alloc_text`
2321 /// that decides which code section the function should be in, add
2322 /// attribute section to the function.
2324
2325 /// Adds the 'optnone' attribute to the function declaration if there
2326 /// are no conflicts; Loc represents the location causing the 'optnone'
2327 /// attribute to be added (usually because of a pragma).
2329
2330 /// Only called on function definitions; if there is a MSVC #pragma optimize
2331 /// in scope, consider changing the function's attributes based on the
2332 /// optimization list passed to the pragma.
2334
2335 /// Only called on function definitions; if there is a pragma in scope
2336 /// with the effect of a range-based no_builtin, consider marking the function
2337 /// with attribute no_builtin.
2339
2340 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
2341 /// add an appropriate visibility attribute.
2343
2344 /// FreeVisContext - Deallocate and null out VisContext.
2345 void FreeVisContext();
2346
2347 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
2348 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
2349 SourceLocation PragmaLoc);
2350
2351 /// ActOnPragmaFPContract - Called on well formed
2352 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
2353 /// \#pragma clang fp contract
2355
2356 /// Called on well formed
2357 /// \#pragma clang fp reassociate
2358 /// or
2359 /// \#pragma clang fp reciprocal
2361 bool IsEnabled);
2362
2363 /// ActOnPragmaFenvAccess - Called on well formed
2364 /// \#pragma STDC FENV_ACCESS
2365 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
2366
2367 /// ActOnPragmaCXLimitedRange - Called on well formed
2368 /// \#pragma STDC CX_LIMITED_RANGE
2371
2372 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
2375
2376 /// Called to set constant rounding mode for floating point operations.
2377 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
2378
2379 /// Called to set exception behavior for floating point operations.
2381
2382 /// PushNamespaceVisibilityAttr - Note that we've entered a
2383 /// namespace with a visibility attribute.
2384 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
2385 SourceLocation Loc);
2386
2387 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
2388 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2389 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2390
2391 /// Handles semantic checking for features that are common to all attributes,
2392 /// such as checking whether a parameter was properly specified, or the
2393 /// correct number of arguments were passed, etc. Returns true if the
2394 /// attribute has been diagnosed.
2395 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2396 bool SkipArgCountCheck = false);
2397 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2398 bool SkipArgCountCheck = false);
2399
2400 ///@}
2401
2402 //
2403 //
2404 // -------------------------------------------------------------------------
2405 //
2406 //
2407
2408 /// \name Availability Attribute Handling
2409 /// Implementations are in SemaAvailability.cpp
2410 ///@{
2411
2412public:
2413 /// Issue any -Wunguarded-availability warnings in \c FD
2415
2417
2418 /// Retrieve the current function, if any, that should be analyzed for
2419 /// potential availability violations.
2421
2423 const ObjCInterfaceDecl *UnknownObjCClass,
2424 bool ObjCPropertyAccess,
2425 bool AvoidPartialAvailabilityChecks,
2426 ObjCInterfaceDecl *ClassReceiver);
2427
2429
2430 std::pair<AvailabilityResult, const NamedDecl *>
2431 ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message,
2432 ObjCInterfaceDecl *ClassReceiver);
2433 ///@}
2434
2435 //
2436 //
2437 // -------------------------------------------------------------------------
2438 //
2439 //
2440
2441 /// \name Bounds Safety
2442 /// Implementations are in SemaBoundsSafety.cpp
2443 ///@{
2444public:
2445 /// Check if applying the specified attribute variant from the "counted by"
2446 /// family of attributes to FieldDecl \p FD is semantically valid. If
2447 /// semantically invalid diagnostics will be emitted explaining the problems.
2448 ///
2449 /// \param FD The FieldDecl to apply the attribute to
2450 /// \param E The count expression on the attribute
2451 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2452 /// attributes. If the false the attribute is from
2453 /// "counted_by" family of attributes.
2454 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2455 /// of attributes. If false the attribute does not have the
2456 /// suffix.
2457 ///
2458 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2459 /// \p CountInBytes and \p OrNull both being true indicates the
2460 /// `counted_by_or_null` attribute.
2461 ///
2462 /// \returns false iff semantically valid.
2463 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2464 bool OrNull);
2465
2466 /// Perform Bounds Safety Semantic checks for assigning to a `__counted_by` or
2467 /// `__counted_by_or_null` pointer type \param LHSTy.
2468 ///
2469 /// \param LHSTy The type being assigned to. Checks will only be performed if
2470 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2471 /// \param RHSExpr The expression being assigned from.
2472 /// \param Action The type assignment being performed
2473 /// \param Loc The SourceLocation to use for error diagnostics
2474 /// \param Assignee The ValueDecl being assigned. This is used to compute
2475 /// the name of the assignee. If the assignee isn't known this can
2476 /// be set to nullptr.
2477 /// \param ShowFullyQualifiedAssigneeName If set to true when using \p
2478 /// Assignee to compute the name of the assignee use the fully
2479 /// qualified name, otherwise use the unqualified name.
2480 ///
2481 /// \returns True iff no diagnostic where emitted, false otherwise.
2483 QualType LHSTy, Expr *RHSExpr, AssignmentAction Action,
2484 SourceLocation Loc, const ValueDecl *Assignee,
2485 bool ShowFullyQualifiedAssigneeName);
2486
2487 /// Perform Bounds Safety Semantic checks for initializing a Bounds Safety
2488 /// pointer.
2489 ///
2490 /// \param Entity The entity being initialized
2491 /// \param Kind The kind of initialization being performed
2492 /// \param Action The type assignment being performed
2493 /// \param LHSTy The type being assigned to. Checks will only be performed if
2494 /// the type is a `counted_by` or `counted_by_or_null ` pointer.
2495 /// \param RHSExpr The expression being used for initialization.
2496 ///
2497 /// \returns True iff no diagnostic where emitted, false otherwise.
2499 const InitializationKind &Kind,
2500 AssignmentAction Action,
2501 QualType LHSType, Expr *RHSExpr);
2502
2503 /// Perform Bounds Safety semantic checks for uses of invalid uses counted_by
2504 /// or counted_by_or_null pointers in \param E.
2505 ///
2506 /// \param E the expression to check
2507 ///
2508 /// \returns True iff no diagnostic where emitted, false otherwise.
2510 ///@}
2511
2512 //
2513 //
2514 // -------------------------------------------------------------------------
2515 //
2516 //
2517
2518 /// \name Casts
2519 /// Implementations are in SemaCast.cpp
2520 ///@{
2521
2522public:
2528
2529 /// ActOnCXXNamedCast - Parse
2530 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2532 SourceLocation LAngleBracketLoc, Declarator &D,
2533 SourceLocation RAngleBracketLoc,
2534 SourceLocation LParenLoc, Expr *E,
2535 SourceLocation RParenLoc);
2536
2538 TypeSourceInfo *Ty, Expr *E,
2539 SourceRange AngleBrackets, SourceRange Parens);
2540
2542 ExprResult Operand,
2543 SourceLocation RParenLoc);
2544
2546 Expr *Operand, SourceLocation RParenLoc);
2547
2548 // Checks that reinterpret casts don't have undefined behavior.
2549 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2550 bool IsDereference, SourceRange Range);
2551
2552 // Checks that the vector type should be initialized from a scalar
2553 // by splatting the value rather than populating a single element.
2554 // This is the case for AltiVecVector types as well as with
2555 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2556 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2557
2558 // Checks if the -faltivec-src-compat=gcc option is specified.
2559 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2560 // treated the same way as they are when trying to initialize
2561 // these vectors on gcc (an error is emitted).
2563 QualType SrcTy);
2564
2566 SourceLocation RParenLoc, Expr *Op);
2567
2569 SourceLocation LParenLoc,
2570 Expr *CastExpr,
2571 SourceLocation RParenLoc);
2572
2573 ///@}
2574
2575 //
2576 //
2577 // -------------------------------------------------------------------------
2578 //
2579 //
2580
2581 /// \name Extra Semantic Checking
2582 /// Implementations are in SemaChecking.cpp
2583 ///@{
2584
2585public:
2586 /// Used to change context to isConstantEvaluated without pushing a heavy
2587 /// ExpressionEvaluationContextRecord object.
2589
2594
2596 unsigned ByteNo) const;
2597
2599 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2600 FAPK_Variadic, // values to format are passed as variadic arguments
2601 FAPK_VAList, // values to format are passed in a va_list
2602 FAPK_Elsewhere, // values to format are not passed to this function
2603 };
2604
2605 // Used to grab the relevant information from a FormatAttr and a
2606 // FunctionDeclaration.
2612
2613 /// Given a function and its FormatAttr or FormatMatchesAttr info, attempts to
2614 /// populate the FomatStringInfo parameter with the attribute's correct
2615 /// format_idx and firstDataArg. Returns true when the format fits the
2616 /// function and the FormatStringInfo has been populated.
2617 static bool getFormatStringInfo(const Decl *Function, unsigned FormatIdx,
2618 unsigned FirstArg, FormatStringInfo *FSI);
2619 static bool getFormatStringInfo(unsigned FormatIdx, unsigned FirstArg,
2620 bool IsCXXMember, bool IsVariadic,
2621 FormatStringInfo *FSI);
2622
2623 // Used by C++ template instantiation.
2625
2626 /// ConvertVectorExpr - Handle __builtin_convertvector
2628 SourceLocation BuiltinLoc,
2629 SourceLocation RParenLoc);
2630
2631 static StringRef GetFormatStringTypeName(FormatStringType FST);
2632 static FormatStringType GetFormatStringType(StringRef FormatFlavor);
2633 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2634 static FormatStringType GetFormatStringType(const FormatMatchesAttr *Format);
2635
2636 bool FormatStringHasSArg(const StringLiteral *FExpr);
2637
2638 /// Check for comparisons of floating-point values using == and !=. Issue a
2639 /// warning if the comparison is not likely to do what the programmer
2640 /// intended.
2641 void CheckFloatComparison(SourceLocation Loc, const Expr *LHS,
2642 const Expr *RHS, BinaryOperatorKind Opcode);
2643
2644 /// Register a magic integral constant to be used as a type tag.
2645 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2646 uint64_t MagicValue, QualType Type,
2647 bool LayoutCompatible, bool MustBeNull);
2648
2651
2655
2657
2658 /// If true, \c Type should be compared with other expression's types for
2659 /// layout-compatibility.
2660 LLVM_PREFERRED_TYPE(bool)
2662 LLVM_PREFERRED_TYPE(bool)
2663 unsigned MustBeNull : 1;
2664 };
2665
2666 /// A pair of ArgumentKind identifier and magic value. This uniquely
2667 /// identifies the magic value.
2668 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2669
2670 /// Diagnoses the current set of gathered accesses. This happens at the end of
2671 /// each expression evaluation context. Diagnostics are emitted only for
2672 /// accesses gathered in the current evaluation context.
2674
2675 /// This function checks if the expression is in the sef of potentially
2676 /// misaligned members and it is converted to some pointer type T with lower
2677 /// or equal alignment requirements. If so it removes it. This is used when
2678 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2679 /// void*).
2680 void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
2681
2682 /// Returns true if `From` is a function or pointer to a function with the
2683 /// `cfi_unchecked_callee` attribute but `To` is a function or pointer to
2684 /// function without this attribute.
2685 bool DiscardingCFIUncheckedCallee(QualType From, QualType To) const;
2686
2687 /// Returns true if `From` is a function or pointer to a function without the
2688 /// `cfi_unchecked_callee` attribute but `To` is a function or pointer to
2689 /// function with this attribute.
2690 bool AddingCFIUncheckedCallee(QualType From, QualType To) const;
2691
2692 /// This function calls Action when it determines that E designates a
2693 /// misaligned member due to the packed attribute. This is used to emit
2694 /// local diagnostics like in reference binding.
2696 Expr *E,
2697 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2698 Action);
2699
2700 enum class AtomicArgumentOrder { API, AST };
2702 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2703 SourceLocation RParenLoc, MultiExprArg Args,
2706
2707 /// Check to see if a given expression could have '.c_str()' called on it.
2708 bool hasCStrMethod(const Expr *E);
2709
2710 /// Diagnose pointers that are always non-null.
2711 /// \param E the expression containing the pointer
2712 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2713 /// compared to a null pointer
2714 /// \param IsEqual True when the comparison is equal to a null pointer
2715 /// \param Range Extra SourceRange to highlight in the diagnostic
2718 bool IsEqual, SourceRange Range);
2719
2720 /// CheckParmsForFunctionDef - Check that the parameters of the given
2721 /// function are appropriate for the definition of a function. This
2722 /// takes care of any checks that cannot be performed on the
2723 /// declaration itself, e.g., that the types of each of the function
2724 /// parameters are complete.
2726 bool CheckParameterNames);
2727
2728 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2729 /// pointer cast increases the alignment requirements.
2730 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2731
2732 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2733 /// to weak/__unsafe_unretained type.
2734 bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS);
2735
2736 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2737 /// to weak/__unsafe_unretained expression.
2738 void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS);
2739
2740 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2741 /// statement as a \p Body, and it is located on the same line.
2742 ///
2743 /// This helps prevent bugs due to typos, such as:
2744 /// if (condition);
2745 /// do_stuff();
2746 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2747 unsigned DiagID);
2748
2749 /// Warn if a for/while loop statement \p S, which is followed by
2750 /// \p PossibleBody, has a suspicious null statement as a body.
2751 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2752
2753 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2754 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2755 SourceLocation OpLoc);
2756
2757 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2759 const TypeSourceInfo *Derived);
2760
2761 /// CheckFunctionCall - Check a direct function call for various correctness
2762 /// and safety properties not strictly enforced by the C type system.
2763 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2764 const FunctionProtoType *Proto);
2765
2772
2773 /// \param FPOnly restricts the arguments to floating-point types.
2774 std::optional<QualType>
2775 BuiltinVectorMath(CallExpr *TheCall,
2778 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2779
2780 void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
2781 const Expr *ThisArg, ArrayRef<const Expr *> Args);
2782
2783 /// Handles the checks for format strings, non-POD arguments to vararg
2784 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2785 /// attributes and AArch64 SME attributes.
2786 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2787 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2788 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2789 VariadicCallType CallType);
2790
2791 /// Verify that two format strings (as understood by attribute(format) and
2792 /// attribute(format_matches) are compatible. If they are incompatible,
2793 /// diagnostics are emitted with the assumption that \c
2794 /// AuthoritativeFormatString is correct and
2795 /// \c TestedFormatString is wrong. If \c FunctionCallArg is provided,
2796 /// diagnostics will point to it and a note will refer to \c
2797 /// TestedFormatString or \c AuthoritativeFormatString as appropriate.
2798 bool
2800 const StringLiteral *AuthoritativeFormatString,
2801 const StringLiteral *TestedFormatString,
2802 const Expr *FunctionCallArg = nullptr);
2803
2804 /// Verify that one format string (as understood by attribute(format)) is
2805 /// self-consistent; for instance, that it doesn't have multiple positional
2806 /// arguments referring to the same argument in incompatible ways. Diagnose
2807 /// if it isn't.
2809
2810 /// \brief Enforce the bounds of a TCB
2811 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2812 /// directly calls other functions in the same TCB as marked by the
2813 /// enforce_tcb and enforce_tcb_leaf attributes.
2814 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2815 const NamedDecl *Callee);
2816
2817 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2818
2819 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2820 /// TheCall is a constant expression.
2821 bool BuiltinConstantArg(CallExpr *TheCall, unsigned ArgNum,
2822 llvm::APSInt &Result);
2823
2824 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2825 /// TheCall is a constant expression in the range [Low, High].
2826 bool BuiltinConstantArgRange(CallExpr *TheCall, unsigned ArgNum, int Low,
2827 int High, bool RangeIsError = true);
2828
2829 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2830 /// TheCall is a constant expression is a multiple of Num..
2831 bool BuiltinConstantArgMultiple(CallExpr *TheCall, unsigned ArgNum,
2832 unsigned Multiple);
2833
2834 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2835 /// constant expression representing a power of 2.
2836 bool BuiltinConstantArgPower2(CallExpr *TheCall, unsigned ArgNum);
2837
2838 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2839 /// a constant expression representing an arbitrary byte value shifted left by
2840 /// a multiple of 8 bits.
2841 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, unsigned ArgNum,
2842 unsigned ArgBits);
2843
2844 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2845 /// TheCall is a constant expression representing either a shifted byte value,
2846 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2847 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2848 /// Arm MVE intrinsics.
2849 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, unsigned ArgNum,
2850 unsigned ArgBits);
2851
2852 /// Checks that a call expression's argument count is at least the desired
2853 /// number. This is useful when doing custom type-checking on a variadic
2854 /// function. Returns true on error.
2855 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2856
2857 /// Checks that a call expression's argument count is at most the desired
2858 /// number. This is useful when doing custom type-checking on a variadic
2859 /// function. Returns true on error.
2860 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2861
2862 /// Checks that a call expression's argument count is in the desired range.
2863 /// This is useful when doing custom type-checking on a variadic function.
2864 /// Returns true on error.
2865 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2866 unsigned MaxArgCount);
2867
2868 /// Checks that a call expression's argument count is the desired number.
2869 /// This is useful when doing custom type-checking. Returns true on error.
2870 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2871
2872 /// Returns true if the argument consists of one contiguous run of 1s with any
2873 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2874 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2875 /// since all 1s are not contiguous.
2876 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2877
2879 bool *ICContext = nullptr,
2880 bool IsListInit = false);
2881
2882 bool
2887 CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr =
2889
2890private:
2891 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2892 const ArraySubscriptExpr *ASE = nullptr,
2893 bool AllowOnePastEnd = true, bool IndexNegated = false);
2894 void CheckArrayAccess(const Expr *E);
2895
2896 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2897 const FunctionProtoType *Proto);
2898
2899 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
2900 /// such as function pointers returned from functions.
2901 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2902
2903 /// CheckConstructorCall - Check a constructor call for correctness and safety
2904 /// properties not enforced by the C type system.
2905 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2907 const FunctionProtoType *Proto, SourceLocation Loc);
2908
2909 /// Warn if a pointer or reference argument passed to a function points to an
2910 /// object that is less aligned than the parameter. This can happen when
2911 /// creating a typedef with a lower alignment than the original type and then
2912 /// calling functions defined in terms of the original type.
2913 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2914 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2915
2916 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2917
2918 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2919 CallExpr *TheCall);
2920
2921 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2922 CallExpr *TheCall);
2923
2924 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2925
2926 /// Check the arguments to '__builtin_va_start', '__builtin_ms_va_start',
2927 /// or '__builtin_c23_va_start' for validity. Emit an error and return true
2928 /// on failure; return false on success.
2929 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2930 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2931
2932 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
2933 /// friends. This is declared to take (...), so we have to check everything.
2934 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2935
2936 /// BuiltinSemaBuiltinFPClassification - Handle functions like
2937 /// __builtin_isnan and friends. This is declared to take (...), so we have
2938 /// to check everything.
2939 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2940 unsigned BuiltinID);
2941
2942 /// Perform semantic analysis for a call to __builtin_complex.
2943 bool BuiltinComplex(CallExpr *TheCall);
2944 bool BuiltinOSLogFormat(CallExpr *TheCall);
2945
2946 /// BuiltinPrefetch - Handle __builtin_prefetch.
2947 /// This is declared to take (const void*, ...) and can take two
2948 /// optional constant int args.
2949 bool BuiltinPrefetch(CallExpr *TheCall);
2950
2951 /// Handle __builtin_alloca_with_align. This is declared
2952 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
2953 /// than 8.
2954 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2955
2956 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
2957 bool BuiltinArithmeticFence(CallExpr *TheCall);
2958
2959 /// BuiltinAssume - Handle __assume (MS Extension).
2960 /// __assume does not evaluate its arguments, and should warn if its argument
2961 /// has side effects.
2962 bool BuiltinAssume(CallExpr *TheCall);
2963
2964 /// Handle __builtin_assume_aligned. This is declared
2965 /// as (const void*, size_t, ...) and can take one optional constant int arg.
2966 bool BuiltinAssumeAligned(CallExpr *TheCall);
2967
2968 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
2969 /// This checks that the target supports __builtin_longjmp and
2970 /// that val is a constant 1.
2971 bool BuiltinLongjmp(CallExpr *TheCall);
2972
2973 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
2974 /// This checks that the target supports __builtin_setjmp.
2975 bool BuiltinSetjmp(CallExpr *TheCall);
2976
2977 /// We have a call to a function like __sync_fetch_and_add, which is an
2978 /// overloaded function based on the pointer type of its first argument.
2979 /// The main BuildCallExpr routines have already promoted the types of
2980 /// arguments because all of these calls are prototyped as void(...).
2981 ///
2982 /// This function goes through and does final semantic checking for these
2983 /// builtins, as well as generating any warnings.
2984 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2985
2986 /// BuiltinNontemporalOverloaded - We have a call to
2987 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
2988 /// overloaded function based on the pointer type of its last argument.
2989 ///
2990 /// This function goes through and does final semantic checking for these
2991 /// builtins.
2992 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2993 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2995
2996 /// \param FPOnly restricts the arguments to floating-point types.
2997 bool BuiltinElementwiseMath(CallExpr *TheCall,
3000 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
3001
3002 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
3003
3004 bool CheckInvalidBuiltinCountedByRef(const Expr *E,
3006 bool BuiltinCountedByRef(CallExpr *TheCall);
3007
3008 // Matrix builtin handling.
3009 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
3010 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
3011 ExprResult CallResult);
3012 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
3013 ExprResult CallResult);
3014
3015 /// CheckFormatArguments - Check calls to printf and scanf (and similar
3016 /// functions) for correct use of format strings.
3017 /// Returns true if a format string has been fully checked.
3018 bool CheckFormatArguments(const FormatAttr *Format,
3019 ArrayRef<const Expr *> Args, bool IsCXXMember,
3020 VariadicCallType CallType, SourceLocation Loc,
3021 SourceRange Range,
3022 llvm::SmallBitVector &CheckedVarArgs);
3023 bool CheckFormatString(const FormatMatchesAttr *Format,
3024 ArrayRef<const Expr *> Args, bool IsCXXMember,
3025 VariadicCallType CallType, SourceLocation Loc,
3026 SourceRange Range,
3027 llvm::SmallBitVector &CheckedVarArgs);
3028 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
3029 FormatArgumentPassingKind FAPK,
3030 const StringLiteral *ReferenceFormatString,
3031 unsigned format_idx, unsigned firstDataArg,
3033 SourceLocation Loc, SourceRange range,
3034 llvm::SmallBitVector &CheckedVarArgs);
3035
3036 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
3037
3038 /// Warn when using the wrong abs() function.
3039 void CheckAbsoluteValueFunction(const CallExpr *Call,
3040 const FunctionDecl *FDecl);
3041
3042 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
3043
3044 /// Check for dangerous or invalid arguments to memset().
3045 ///
3046 /// This issues warnings on known problematic, dangerous or unspecified
3047 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
3048 /// function calls.
3049 ///
3050 /// \param Call The call expression to diagnose.
3051 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
3052 IdentifierInfo *FnName);
3053
3054 // Warn if the user has made the 'size' argument to strlcpy or strlcat
3055 // be the size of the source, instead of the destination.
3056 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
3057
3058 // Warn on anti-patterns as the 'size' argument to strncat.
3059 // The correct size argument should look like following:
3060 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
3061 void CheckStrncatArguments(const CallExpr *Call,
3062 const IdentifierInfo *FnName);
3063
3064 /// Alerts the user that they are attempting to free a non-malloc'd object.
3065 void CheckFreeArguments(const CallExpr *E);
3066
3067 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
3068 SourceLocation ReturnLoc, bool isObjCMethod = false,
3069 const AttrVec *Attrs = nullptr,
3070 const FunctionDecl *FD = nullptr);
3071
3072 /// Diagnoses "dangerous" implicit conversions within the given
3073 /// expression (which is a full expression). Implements -Wconversion
3074 /// and -Wsign-compare.
3075 ///
3076 /// \param CC the "context" location of the implicit conversion, i.e.
3077 /// the most location of the syntactic entity requiring the implicit
3078 /// conversion
3079 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
3080
3081 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
3082 /// Input argument E is a logical expression.
3084
3085 /// Diagnose when expression is an integer constant expression and its
3086 /// evaluation results in integer overflow
3087 void CheckForIntOverflow(const Expr *E);
3088 void CheckUnsequencedOperations(const Expr *E);
3089
3090 /// Perform semantic checks on a completed expression. This will either
3091 /// be a full-expression or a default argument expression.
3092 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
3093 bool IsConstexpr = false);
3094
3095 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
3096 Expr *Init);
3097
3098 /// A map from magic value to type information.
3099 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
3100 TypeTagForDatatypeMagicValues;
3101
3102 /// Peform checks on a call of a function with argument_with_type_tag
3103 /// or pointer_with_type_tag attributes.
3104 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
3105 const ArrayRef<const Expr *> ExprArgs,
3106 SourceLocation CallSiteLoc);
3107
3108 /// Check if we are taking the address of a packed field
3109 /// as this may be a problem if the pointer value is dereferenced.
3110 void CheckAddressOfPackedMember(Expr *rhs);
3111
3112 /// Helper class that collects misaligned member designations and
3113 /// their location info for delayed diagnostics.
3114 struct MisalignedMember {
3115 Expr *E;
3116 RecordDecl *RD;
3117 ValueDecl *MD;
3118 CharUnits Alignment;
3119
3120 MisalignedMember() : E(), RD(), MD() {}
3121 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
3122 CharUnits Alignment)
3123 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
3124 explicit MisalignedMember(Expr *E)
3125 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
3126
3127 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
3128 };
3129
3130 /// Adds an expression to the set of gathered misaligned members.
3131 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
3132 CharUnits Alignment);
3133 ///@}
3134
3135 //
3136 //
3137 // -------------------------------------------------------------------------
3138 //
3139 //
3140
3141 /// \name C++ Coroutines
3142 /// Implementations are in SemaCoroutine.cpp
3143 ///@{
3144
3145public:
3146 /// The C++ "std::coroutine_traits" template, which is defined in
3147 /// <coroutine_traits>
3149
3151 StringRef Keyword);
3155
3158 UnresolvedLookupExpr *Lookup);
3160 Expr *Awaiter, bool IsImplicit = false);
3162 UnresolvedLookupExpr *Lookup);
3165 bool IsImplicit = false);
3170
3171 // As a clang extension, enforces that a non-coroutine function must be marked
3172 // with [[clang::coro_wrapper]] if it returns a type marked with
3173 // [[clang::coro_return_type]].
3174 // Expects that FD is not a coroutine.
3176 /// Lookup 'coroutine_traits' in std namespace and std::experimental
3177 /// namespace. The namespace found is recorded in Namespace.
3179 SourceLocation FuncLoc);
3180 /// Check that the expression co_await promise.final_suspend() shall not be
3181 /// potentially-throwing.
3182 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
3183
3184 ///@}
3185
3186 //
3187 //
3188 // -------------------------------------------------------------------------
3189 //
3190 //
3191
3192 /// \name C++ Scope Specifiers
3193 /// Implementations are in SemaCXXScopeSpec.cpp
3194 ///@{
3195
3196public:
3197 // Marks SS invalid if it represents an incomplete type.
3199 // Complete an enum decl, maybe without a scope spec.
3201 CXXScopeSpec *SS = nullptr);
3202
3203 /// Compute the DeclContext that is associated with the given type.
3204 ///
3205 /// \param T the type for which we are attempting to find a DeclContext.
3206 ///
3207 /// \returns the declaration context represented by the type T,
3208 /// or NULL if the declaration context cannot be computed (e.g., because it is
3209 /// dependent and not the current instantiation).
3211
3212 /// Compute the DeclContext that is associated with the given
3213 /// scope specifier.
3214 ///
3215 /// \param SS the C++ scope specifier as it appears in the source
3216 ///
3217 /// \param EnteringContext when true, we will be entering the context of
3218 /// this scope specifier, so we can retrieve the declaration context of a
3219 /// class template or class template partial specialization even if it is
3220 /// not the current instantiation.
3221 ///
3222 /// \returns the declaration context represented by the scope specifier @p SS,
3223 /// or NULL if the declaration context cannot be computed (e.g., because it is
3224 /// dependent and not the current instantiation).
3226 bool EnteringContext = false);
3228
3229 /// If the given nested name specifier refers to the current
3230 /// instantiation, return the declaration that corresponds to that
3231 /// current instantiation (C++0x [temp.dep.type]p1).
3232 ///
3233 /// \param NNS a dependent nested name specifier.
3235
3236 /// The parser has parsed a global nested-name-specifier '::'.
3237 ///
3238 /// \param CCLoc The location of the '::'.
3239 ///
3240 /// \param SS The nested-name-specifier, which will be updated in-place
3241 /// to reflect the parsed nested-name-specifier.
3242 ///
3243 /// \returns true if an error occurred, false otherwise.
3245
3246 /// The parser has parsed a '__super' nested-name-specifier.
3247 ///
3248 /// \param SuperLoc The location of the '__super' keyword.
3249 ///
3250 /// \param ColonColonLoc The location of the '::'.
3251 ///
3252 /// \param SS The nested-name-specifier, which will be updated in-place
3253 /// to reflect the parsed nested-name-specifier.
3254 ///
3255 /// \returns true if an error occurred, false otherwise.
3257 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
3258
3259 /// Determines whether the given declaration is an valid acceptable
3260 /// result for name lookup of a nested-name-specifier.
3261 /// \param SD Declaration checked for nested-name-specifier.
3262 /// \param IsExtension If not null and the declaration is accepted as an
3263 /// extension, the pointed variable is assigned true.
3265 bool *CanCorrect = nullptr);
3266
3267 /// If the given nested-name-specifier begins with a bare identifier
3268 /// (e.g., Base::), perform name lookup for that identifier as a
3269 /// nested-name-specifier within the given scope, and return the result of
3270 /// that name lookup.
3272
3273 /// Keeps information about an identifier in a nested-name-spec.
3274 ///
3276 /// The type of the object, if we're parsing nested-name-specifier in
3277 /// a member access expression.
3279
3280 /// The identifier preceding the '::'.
3282
3283 /// The location of the identifier.
3285
3286 /// The location of the '::'.
3288
3289 /// Creates info object for the most typical case.
3291 SourceLocation ColonColonLoc,
3294 CCLoc(ColonColonLoc) {}
3295
3297 SourceLocation ColonColonLoc, QualType ObjectType)
3299 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
3300 };
3301
3302 /// Build a new nested-name-specifier for "identifier::", as described
3303 /// by ActOnCXXNestedNameSpecifier.
3304 ///
3305 /// \param S Scope in which the nested-name-specifier occurs.
3306 /// \param IdInfo Parser information about an identifier in the
3307 /// nested-name-spec.
3308 /// \param EnteringContext If true, enter the context specified by the
3309 /// nested-name-specifier.
3310 /// \param SS Optional nested name specifier preceding the identifier.
3311 /// \param ScopeLookupResult Provides the result of name lookup within the
3312 /// scope of the nested-name-specifier that was computed at template
3313 /// definition time.
3314 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
3315 /// error recovery and what kind of recovery is performed.
3316 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
3317 /// are allowed. The bool value pointed by this parameter is set to
3318 /// 'true' if the identifier is treated as if it was followed by ':',
3319 /// not '::'.
3320 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3321 ///
3322 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
3323 /// that it contains an extra parameter \p ScopeLookupResult, which provides
3324 /// the result of name lookup within the scope of the nested-name-specifier
3325 /// that was computed at template definition time.
3326 ///
3327 /// If ErrorRecoveryLookup is true, then this call is used to improve error
3328 /// recovery. This means that it should not emit diagnostics, it should
3329 /// just return true on failure. It also means it should only return a valid
3330 /// scope if it *knows* that the result is correct. It should not return in a
3331 /// dependent context, for example. Nor will it extend \p SS with the scope
3332 /// specifier.
3333 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3334 bool EnteringContext, CXXScopeSpec &SS,
3335 NamedDecl *ScopeLookupResult,
3336 bool ErrorRecoveryLookup,
3337 bool *IsCorrectedToColon = nullptr,
3338 bool OnlyNamespace = false);
3339
3340 /// The parser has parsed a nested-name-specifier 'identifier::'.
3341 ///
3342 /// \param S The scope in which this nested-name-specifier occurs.
3343 ///
3344 /// \param IdInfo Parser information about an identifier in the
3345 /// nested-name-spec.
3346 ///
3347 /// \param EnteringContext Whether we're entering the context nominated by
3348 /// this nested-name-specifier.
3349 ///
3350 /// \param SS The nested-name-specifier, which is both an input
3351 /// parameter (the nested-name-specifier before this type) and an
3352 /// output parameter (containing the full nested-name-specifier,
3353 /// including this new type).
3354 ///
3355 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
3356 /// are allowed. The bool value pointed by this parameter is set to 'true'
3357 /// if the identifier is treated as if it was followed by ':', not '::'.
3358 ///
3359 /// \param OnlyNamespace If true, only considers namespaces in lookup.
3360 ///
3361 /// \returns true if an error occurred, false otherwise.
3362 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
3363 bool EnteringContext, CXXScopeSpec &SS,
3364 bool *IsCorrectedToColon = nullptr,
3365 bool OnlyNamespace = false);
3366
3367 /// The parser has parsed a nested-name-specifier
3368 /// 'template[opt] template-name < template-args >::'.
3369 ///
3370 /// \param S The scope in which this nested-name-specifier occurs.
3371 ///
3372 /// \param SS The nested-name-specifier, which is both an input
3373 /// parameter (the nested-name-specifier before this type) and an
3374 /// output parameter (containing the full nested-name-specifier,
3375 /// including this new type).
3376 ///
3377 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
3378 /// \param TemplateName the template name.
3379 /// \param TemplateNameLoc The location of the template name.
3380 /// \param LAngleLoc The location of the opening angle bracket ('<').
3381 /// \param TemplateArgs The template arguments.
3382 /// \param RAngleLoc The location of the closing angle bracket ('>').
3383 /// \param CCLoc The location of the '::'.
3384 ///
3385 /// \param EnteringContext Whether we're entering the context of the
3386 /// nested-name-specifier.
3387 ///
3388 ///
3389 /// \returns true if an error occurred, false otherwise.
3391 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
3392 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
3393 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
3394 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
3395
3397 SourceLocation ColonColonLoc);
3398
3400 const DeclSpec &DS,
3401 SourceLocation ColonColonLoc,
3402 QualType Type);
3403
3404 /// IsInvalidUnlessNestedName - This method is used for error recovery
3405 /// purposes to determine whether the specified identifier is only valid as
3406 /// a nested name specifier, for example a namespace name. It is
3407 /// conservatively correct to always return false from this method.
3408 ///
3409 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
3411 NestedNameSpecInfo &IdInfo,
3412 bool EnteringContext);
3413
3414 /// Given a C++ nested-name-specifier, produce an annotation value
3415 /// that the parser can use later to reconstruct the given
3416 /// nested-name-specifier.
3417 ///
3418 /// \param SS A nested-name-specifier.
3419 ///
3420 /// \returns A pointer containing all of the information in the
3421 /// nested-name-specifier \p SS.
3423
3424 /// Given an annotation pointer for a nested-name-specifier, restore
3425 /// the nested-name-specifier structure.
3426 ///
3427 /// \param Annotation The annotation pointer, produced by
3428 /// \c SaveNestedNameSpecifierAnnotation().
3429 ///
3430 /// \param AnnotationRange The source range corresponding to the annotation.
3431 ///
3432 /// \param SS The nested-name-specifier that will be updated with the contents
3433 /// of the annotation pointer.
3434 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
3435 SourceRange AnnotationRange,
3436 CXXScopeSpec &SS);
3437
3438 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
3439
3440 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
3441 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
3442 /// After this method is called, according to [C++ 3.4.3p3], names should be
3443 /// looked up in the declarator-id's scope, until the declarator is parsed and
3444 /// ActOnCXXExitDeclaratorScope is called.
3445 /// The 'SS' should be a non-empty valid CXXScopeSpec.
3447
3448 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
3449 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
3450 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
3451 /// Used to indicate that names should revert to being looked up in the
3452 /// defining scope.
3454
3455 ///@}
3456
3457 //
3458 //
3459 // -------------------------------------------------------------------------
3460 //
3461 //
3462
3463 /// \name Declarations
3464 /// Implementations are in SemaDecl.cpp
3465 ///@{
3466
3467public:
3469
3470 /// The index of the first InventedParameterInfo that refers to the current
3471 /// context.
3473
3474 /// A RAII object to temporarily push a declaration context.
3476 private:
3477 Sema &S;
3478 DeclContext *SavedContext;
3479 ProcessingContextState SavedContextState;
3480 QualType SavedCXXThisTypeOverride;
3481 unsigned SavedFunctionScopesStart;
3482 unsigned SavedInventedParameterInfosStart;
3483
3484 public:
3485 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3486 : S(S), SavedContext(S.CurContext),
3487 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3488 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3489 SavedFunctionScopesStart(S.FunctionScopesStart),
3490 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3491 assert(ContextToPush && "pushing null context");
3492 S.CurContext = ContextToPush;
3493 if (NewThisContext)
3494 S.CXXThisTypeOverride = QualType();
3495 // Any saved FunctionScopes do not refer to this context.
3496 S.FunctionScopesStart = S.FunctionScopes.size();
3497 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3498 }
3499
3500 void pop() {
3501 if (!SavedContext)
3502 return;
3503 S.CurContext = SavedContext;
3504 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3505 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3506 S.FunctionScopesStart = SavedFunctionScopesStart;
3507 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3508 SavedContext = nullptr;
3509 }
3510
3512 };
3513
3514 void DiagnoseInvalidJumps(Stmt *Body);
3515
3516 /// The function definitions which were renamed as part of typo-correction
3517 /// to match their respective declarations. We want to keep track of them
3518 /// to ensure that we don't emit a "redefinition" error if we encounter a
3519 /// correctly named definition after the renamed definition.
3521
3522 /// A cache of the flags available in enumerations with the flag_bits
3523 /// attribute.
3524 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3525
3526 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3527 /// declared. Rare. May alias another identifier, declared or undeclared.
3528 ///
3529 /// For aliases, the target identifier is used as a key for eventual
3530 /// processing when the target is declared. For the single-identifier form,
3531 /// the sole identifier is used as the key. Each entry is a `SetVector`
3532 /// (ordered by parse order) of aliases (identified by the alias name) in case
3533 /// of multiple aliases to the same undeclared identifier.
3534 llvm::MapVector<
3536 llvm::SetVector<
3538 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3540
3541 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3542 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3543 /// to define functions that occur in multiple standards to call the version
3544 /// in the currently selected standard.
3545 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
3546
3547 /// Set containing all typedefs that are likely unused.
3550
3554
3555 /// The set of file scoped decls seen so far that have not been used
3556 /// and must warn if not used. Only contains the first declaration.
3558
3562
3563 /// All the tentative definitions encountered in the TU.
3565
3566 /// All the external declarations encoutered and used in the TU.
3568
3569 /// Generally null except when we temporarily switch decl contexts,
3570 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3572
3573 /// Is the module scope we are in a C++ Header Unit?
3575 return ModuleScopes.empty() ? false
3576 : ModuleScopes.back().Module->isHeaderUnit();
3577 }
3578
3579 /// Get the module owning an entity.
3580 Module *getOwningModule(const Decl *Entity) {
3581 return Entity->getOwningModule();
3582 }
3583
3584 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3585
3587 /// Returns the TypeDeclType for the given type declaration,
3588 /// as ASTContext::getTypeDeclType would, but
3589 /// performs the required semantic checks for name lookup of said entity.
3590 void checkTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK, TypeDecl *TD,
3591 SourceLocation NameLoc);
3592
3593 /// If the identifier refers to a type name within this scope,
3594 /// return the declaration of that type.
3595 ///
3596 /// This routine performs ordinary name lookup of the identifier II
3597 /// within the given scope, with optional C++ scope specifier SS, to
3598 /// determine whether the name refers to a type. If so, returns an
3599 /// opaque pointer (actually a QualType) corresponding to that
3600 /// type. Otherwise, returns NULL.
3602 Scope *S, CXXScopeSpec *SS = nullptr,
3603 bool isClassName = false, bool HasTrailingDot = false,
3604 ParsedType ObjectType = nullptr,
3605 bool IsCtorOrDtorName = false,
3606 bool WantNontrivialTypeSourceInfo = false,
3607 bool IsClassTemplateDeductionContext = true,
3608 ImplicitTypenameContext AllowImplicitTypename =
3610 IdentifierInfo **CorrectedII = nullptr);
3611
3612 /// isTagName() - This method is called *for error recovery purposes only*
3613 /// to determine if the specified name is a valid tag name ("struct foo"). If
3614 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3615 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3616 /// diagnose cases in C where the user forgot to specify the tag.
3618
3619 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3620 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3621 /// then downgrade the missing typename error to a warning.
3622 /// This is needed for MSVC compatibility; Example:
3623 /// @code
3624 /// template<class T> class A {
3625 /// public:
3626 /// typedef int TYPE;
3627 /// };
3628 /// template<class T> class B : public A<T> {
3629 /// public:
3630 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3631 /// };
3632 /// @endcode
3633 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3635 Scope *S, CXXScopeSpec *SS,
3636 ParsedType &SuggestedType,
3637 bool IsTemplateName = false);
3638
3639 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3640 /// type name has failed in a dependent context. In these situations, we
3641 /// automatically form a DependentTypeName that will retry lookup in a related
3642 /// scope during instantiation.
3644 SourceLocation NameLoc,
3645 bool IsTemplateTypeArg);
3646
3647 class NameClassification {
3649 union {
3654 };
3655
3656 explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
3657
3658 public:
3661
3664
3665 static NameClassification Error() {
3666 return NameClassification(NameClassificationKind::Error);
3667 }
3668
3669 static NameClassification Unknown() {
3670 return NameClassification(NameClassificationKind::Unknown);
3671 }
3672
3673 static NameClassification OverloadSet(ExprResult E) {
3674 NameClassification Result(NameClassificationKind::OverloadSet);
3675 Result.Expr = E;
3676 return Result;
3677 }
3678
3679 static NameClassification NonType(NamedDecl *D) {
3680 NameClassification Result(NameClassificationKind::NonType);
3681 Result.NonTypeDecl = D;
3682 return Result;
3683 }
3684
3685 static NameClassification UndeclaredNonType() {
3686 return NameClassification(NameClassificationKind::UndeclaredNonType);
3687 }
3688
3689 static NameClassification DependentNonType() {
3690 return NameClassification(NameClassificationKind::DependentNonType);
3691 }
3692
3693 static NameClassification TypeTemplate(TemplateName Name) {
3694 NameClassification Result(NameClassificationKind::TypeTemplate);
3695 Result.Template = Name;
3696 return Result;
3697 }
3698
3699 static NameClassification VarTemplate(TemplateName Name) {
3700 NameClassification Result(NameClassificationKind::VarTemplate);
3701 Result.Template = Name;
3702 return Result;
3703 }
3704
3705 static NameClassification FunctionTemplate(TemplateName Name) {
3707 Result.Template = Name;
3708 return Result;
3709 }
3710
3711 static NameClassification Concept(TemplateName Name) {
3712 NameClassification Result(NameClassificationKind::Concept);
3713 Result.Template = Name;
3714 return Result;
3715 }
3716
3717 static NameClassification UndeclaredTemplate(TemplateName Name) {
3719 Result.Template = Name;
3720 return Result;
3721 }
3722
3723 NameClassificationKind getKind() const { return Kind; }
3724
3727 return Expr;
3728 }
3729
3731 assert(Kind == NameClassificationKind::Type);
3732 return Type;
3733 }
3734
3736 assert(Kind == NameClassificationKind::NonType);
3737 return NonTypeDecl;
3738 }
3739
3748
3750 switch (Kind) {
3752 return TNK_Type_template;
3754 return TNK_Function_template;
3756 return TNK_Var_template;
3758 return TNK_Concept_template;
3761 default:
3762 llvm_unreachable("unsupported name classification.");
3763 }
3764 }
3765 };
3766
3767 /// Perform name lookup on the given name, classifying it based on
3768 /// the results of name lookup and the following token.
3769 ///
3770 /// This routine is used by the parser to resolve identifiers and help direct
3771 /// parsing. When the identifier cannot be found, this routine will attempt
3772 /// to correct the typo and classify based on the resulting name.
3773 ///
3774 /// \param S The scope in which we're performing name lookup.
3775 ///
3776 /// \param SS The nested-name-specifier that precedes the name.
3777 ///
3778 /// \param Name The identifier. If typo correction finds an alternative name,
3779 /// this pointer parameter will be updated accordingly.
3780 ///
3781 /// \param NameLoc The location of the identifier.
3782 ///
3783 /// \param NextToken The token following the identifier. Used to help
3784 /// disambiguate the name.
3785 ///
3786 /// \param CCC The correction callback, if typo correction is desired.
3787 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3788 IdentifierInfo *&Name, SourceLocation NameLoc,
3789 const Token &NextToken,
3790 CorrectionCandidateCallback *CCC = nullptr);
3791
3792 /// Act on the result of classifying a name as an undeclared (ADL-only)
3793 /// non-type declaration.
3795 SourceLocation NameLoc);
3796 /// Act on the result of classifying a name as an undeclared member of a
3797 /// dependent base class.
3799 IdentifierInfo *Name,
3800 SourceLocation NameLoc,
3801 bool IsAddressOfOperand);
3802 /// Act on the result of classifying a name as a specific non-type
3803 /// declaration.
3806 SourceLocation NameLoc,
3807 const Token &NextToken);
3808 /// Act on the result of classifying a name as an overload set.
3810
3811 /// Describes the detailed kind of a template name. Used in diagnostics.
3823
3824 /// Determine whether it's plausible that E was intended to be a
3825 /// template-name.
3827 if (!getLangOpts().CPlusPlus || E.isInvalid())
3828 return false;
3829 Dependent = false;
3830 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3831 return !DRE->hasExplicitTemplateArgs();
3832 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3833 return !ME->hasExplicitTemplateArgs();
3834 Dependent = true;
3835 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3836 return !DSDRE->hasExplicitTemplateArgs();
3837 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3838 return !DSME->hasExplicitTemplateArgs();
3839 // Any additional cases recognized here should also be handled by
3840 // diagnoseExprIntendedAsTemplateName.
3841 return false;
3842 }
3843
3844 void warnOnReservedIdentifier(const NamedDecl *D);
3846
3848
3850 MultiTemplateParamsArg TemplateParameterLists);
3851
3852 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3853 /// true if we were successful.
3855 SourceLocation Loc,
3856 unsigned FailedFoldDiagID);
3857
3858 /// Register the given locally-scoped extern "C" declaration so
3859 /// that it can be found later for redeclarations. We include any extern "C"
3860 /// declaration that is not visible in the translation unit here, not just
3861 /// function-scope declarations.
3863
3864 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3865 /// If T is the name of a class, then each of the following shall have a
3866 /// name different from T:
3867 /// - every static data member of class T;
3868 /// - every member function of class T
3869 /// - every member of class T that is itself a type;
3870 /// \returns true if the declaration name violates these rules.
3872
3873 /// Diagnose a declaration whose declarator-id has the given
3874 /// nested-name-specifier.
3875 ///
3876 /// \param SS The nested-name-specifier of the declarator-id.
3877 ///
3878 /// \param DC The declaration context to which the nested-name-specifier
3879 /// resolves.
3880 ///
3881 /// \param Name The name of the entity being declared.
3882 ///
3883 /// \param Loc The location of the name of the entity being declared.
3884 ///
3885 /// \param IsMemberSpecialization Whether we are declaring a member
3886 /// specialization.
3887 ///
3888 /// \param TemplateId The template-id, if any.
3889 ///
3890 /// \returns true if we cannot safely recover from this error, false
3891 /// otherwise.
3894 TemplateIdAnnotation *TemplateId,
3895 bool IsMemberSpecialization);
3896
3898
3899 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
3900
3902 unsigned &IntVal);
3903
3904 /// Diagnose function specifiers on a declaration of an identifier that
3905 /// does not identify a function.
3906 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
3907
3908 /// Return the declaration shadowed by the given typedef \p D, or null
3909 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3911 const LookupResult &R);
3912
3913 /// Return the declaration shadowed by the given variable \p D, or null
3914 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3916
3917 /// Return the declaration shadowed by the given variable \p D, or null
3918 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3920 const LookupResult &R);
3921 /// Diagnose variable or built-in function shadowing. Implements
3922 /// -Wshadow.
3923 ///
3924 /// This method is called whenever a VarDecl is added to a "useful"
3925 /// scope.
3926 ///
3927 /// \param ShadowedDecl the declaration that is shadowed by the given variable
3928 /// \param R the lookup of the name
3929 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
3930 const LookupResult &R);
3931
3932 /// Check -Wshadow without the advantage of a previous lookup.
3933 void CheckShadow(Scope *S, VarDecl *D);
3934
3935 /// Warn if 'E', which is an expression that is about to be modified, refers
3936 /// to a shadowing declaration.
3938
3939 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
3940 /// when these variables are captured by the lambda.
3942
3943 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
3944 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
3945 TypedefNameDecl *NewTD);
3948 TypeSourceInfo *TInfo,
3950
3951 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
3952 /// declares a typedef-name, either using the 'typedef' type specifier or via
3953 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
3957 TypeSourceInfo *TInfo,
3959 MultiTemplateParamsArg TemplateParamLists,
3960 bool &AddToScope,
3962
3963 /// Perform semantic checking on a newly-created variable
3964 /// declaration.
3965 ///
3966 /// This routine performs all of the type-checking required for a
3967 /// variable declaration once it has been built. It is used both to
3968 /// check variables after they have been parsed and their declarators
3969 /// have been translated into a declaration, and to check variables
3970 /// that have been instantiated from a template.
3971 ///
3972 /// Sets NewVD->isInvalidDecl() if an error was encountered.
3973 ///
3974 /// Returns true if the variable declaration is a redeclaration.
3975 bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
3976 void CheckVariableDeclarationType(VarDecl *NewVD);
3977 void CheckCompleteVariableDeclaration(VarDecl *VD);
3978
3979 NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
3980 TypeSourceInfo *TInfo,
3981 LookupResult &Previous,
3982 MultiTemplateParamsArg TemplateParamLists,
3983 bool &AddToScope);
3984
3985 /// AddOverriddenMethods - See if a method overrides any in the base classes,
3986 /// and if so, check that it's a valid override and remember it.
3987 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
3988
3989 /// Perform semantic checking of a new function declaration.
3990 ///
3991 /// Performs semantic analysis of the new function declaration
3992 /// NewFD. This routine performs all semantic checking that does not
3993 /// require the actual declarator involved in the declaration, and is
3994 /// used both for the declaration of functions as they are parsed
3995 /// (called via ActOnDeclarator) and for the declaration of functions
3996 /// that have been instantiated via C++ template instantiation (called
3997 /// via InstantiateDecl).
3998 ///
3999 /// \param IsMemberSpecialization whether this new function declaration is
4000 /// a member specialization (that replaces any definition provided by the
4001 /// previous declaration).
4002 ///
4003 /// This sets NewFD->isInvalidDecl() to true if there was an error.
4004 ///
4005 /// \returns true if the function declaration is a redeclaration.
4006 bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
4007 LookupResult &Previous,
4008 bool IsMemberSpecialization, bool DeclIsDefn);
4009
4010 /// Checks if the new declaration declared in dependent context must be
4011 /// put in the same redeclaration chain as the specified declaration.
4012 ///
4013 /// \param D Declaration that is checked.
4014 /// \param PrevDecl Previous declaration found with proper lookup method for
4015 /// the same declaration name.
4016 /// \returns True if D must be added to the redeclaration chain which PrevDecl
4017 /// belongs to.
4018 bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
4019
4020 /// Determines if we can perform a correct type check for \p D as a
4021 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
4022 /// best-effort check.
4023 ///
4024 /// \param NewD The new declaration.
4025 /// \param OldD The old declaration.
4026 /// \param NewT The portion of the type of the new declaration to check.
4027 /// \param OldT The portion of the type of the old declaration to check.
4028 bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
4029 QualType NewT, QualType OldT);
4030 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
4031 void CheckMSVCRTEntryPoint(FunctionDecl *FD);
4032
4033 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
4034 /// containing class. Otherwise it will return implicit SectionAttr if the
4035 /// function is a definition and there is an active value on CodeSegStack
4036 /// (from the current #pragma code-seg value).
4037 ///
4038 /// \param FD Function being declared.
4039 /// \param IsDefinition Whether it is a definition or just a declaration.
4040 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
4041 /// nullptr if no attribute should be added.
4042 Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
4043 bool IsDefinition);
4044
4045 /// Common checks for a parameter-declaration that should apply to both
4046 /// function parameters and non-type template parameters.
4047 void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
4048
4049 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
4050 /// to introduce parameters into function prototype scope.
4051 Decl *ActOnParamDeclarator(Scope *S, Declarator &D,
4052 SourceLocation ExplicitThisLoc = {});
4053
4054 /// Synthesizes a variable for a parameter arising from a
4055 /// typedef.
4056 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
4057 QualType T);
4058 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
4059 SourceLocation NameLoc,
4060 const IdentifierInfo *Name, QualType T,
4061 TypeSourceInfo *TSInfo, StorageClass SC);
4062
4063 /// Emit diagnostics if the initializer or any of its explicit or
4064 /// implicitly-generated subexpressions require copying or
4065 /// default-initializing a type that is or contains a C union type that is
4066 /// non-trivial to copy or default-initialize.
4067 void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc);
4068
4069 // These flags are passed to checkNonTrivialCUnion.
4075
4076 /// Emit diagnostics if a non-trivial C union type or a struct that contains
4077 /// a non-trivial C union is used in an invalid context.
4079 NonTrivialCUnionContext UseContext,
4080 unsigned NonTrivialKind);
4081
4082 /// Certain globally-unique variables might be accidentally duplicated if
4083 /// built into multiple shared libraries with hidden visibility. This can
4084 /// cause problems if the variable is mutable, its initialization is
4085 /// effectful, or its address is taken.
4088
4089 /// AddInitializerToDecl - Adds the initializer Init to the
4090 /// declaration dcl. If DirectInit is true, this is C++ direct
4091 /// initialization rather than copy initialization.
4092 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
4093 void ActOnUninitializedDecl(Decl *dcl);
4094
4095 /// ActOnInitializerError - Given that there was an error parsing an
4096 /// initializer for the given declaration, try to at least re-establish
4097 /// invariants such as whether a variable's type is either dependent or
4098 /// complete.
4099 void ActOnInitializerError(Decl *Dcl);
4100
4101 void ActOnCXXForRangeDecl(Decl *D);
4103 IdentifierInfo *Ident,
4104 ParsedAttributes &Attrs);
4105
4106 /// Check if VD needs to be dllexport/dllimport due to being in a
4107 /// dllexport/import function.
4110
4111 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
4112 /// any semantic actions necessary after any initializer has been attached.
4113 void FinalizeDeclaration(Decl *D);
4115 ArrayRef<Decl *> Group);
4116
4117 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
4118 /// group, performing any necessary semantic checking.
4120
4121 /// Should be called on all declarations that might have attached
4122 /// documentation comments.
4123 void ActOnDocumentableDecl(Decl *D);
4125
4126 enum class FnBodyKind {
4127 /// C++26 [dcl.fct.def.general]p1
4128 /// function-body:
4129 /// ctor-initializer[opt] compound-statement
4130 /// function-try-block
4132 /// = default ;
4134 /// deleted-function-body
4135 ///
4136 /// deleted-function-body:
4137 /// = delete ;
4138 /// = delete ( unevaluated-string ) ;
4140 };
4141
4143 SourceLocation LocAfterDecls);
4145 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
4146 SkipBodyInfo *SkipBody = nullptr);
4148 MultiTemplateParamsArg TemplateParamLists,
4149 SkipBodyInfo *SkipBody = nullptr,
4150 FnBodyKind BodyKind = FnBodyKind::Other);
4152 SkipBodyInfo *SkipBody = nullptr,
4153 FnBodyKind BodyKind = FnBodyKind::Other);
4155
4156 /// Determine whether we can delay parsing the body of a function or
4157 /// function template until it is used, assuming we don't care about emitting
4158 /// code for that function.
4159 ///
4160 /// This will be \c false if we may need the body of the function in the
4161 /// middle of parsing an expression (where it's impractical to switch to
4162 /// parsing a different function), for instance, if it's constexpr in C++11
4163 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
4164 bool canDelayFunctionBody(const Declarator &D);
4165
4166 /// Determine whether we can skip parsing the body of a function
4167 /// definition, assuming we don't care about analyzing its body or emitting
4168 /// code for that function.
4169 ///
4170 /// This will be \c false only if we may need the body of the function in
4171 /// order to parse the rest of the program (for instance, if it is
4172 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
4173 bool canSkipFunctionBody(Decl *D);
4174
4175 /// Given the set of return statements within a function body,
4176 /// compute the variables that are subject to the named return value
4177 /// optimization.
4178 ///
4179 /// Each of the variables that is subject to the named return value
4180 /// optimization will be marked as NRVO variables in the AST, and any
4181 /// return statement that has a marked NRVO variable as its NRVO candidate can
4182 /// use the named return value optimization.
4183 ///
4184 /// This function applies a very simplistic algorithm for NRVO: if every
4185 /// return statement in the scope of a variable has the same NRVO candidate,
4186 /// that candidate is an NRVO variable.
4188
4189 /// Performs semantic analysis at the end of a function body.
4190 ///
4191 /// \param RetainFunctionScopeInfo If \c true, the client is responsible for
4192 /// releasing the associated \p FunctionScopeInfo. This is useful when
4193 /// building e.g. LambdaExprs.
4195 bool IsInstantiation = false,
4196 bool RetainFunctionScopeInfo = false);
4199
4200 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
4201 /// attribute for which parsing is delayed.
4203
4204 /// Diagnose any unused parameters in the given sequence of
4205 /// ParmVarDecl pointers.
4207
4208 /// Diagnose whether the size of parameters or return value of a
4209 /// function or obj-c method definition is pass-by-value and larger than a
4210 /// specified threshold.
4211 void
4213 QualType ReturnTy, NamedDecl *D);
4214
4216 SourceLocation RParenLoc);
4217
4220
4221 void ActOnPopScope(SourceLocation Loc, Scope *S);
4222
4223 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4224 /// no declarator (e.g. "struct foo;") is parsed.
4226 const ParsedAttributesView &DeclAttrs,
4227 RecordDecl *&AnonRecord);
4228
4229 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
4230 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
4231 /// parameters to cope with template friend declarations.
4233 const ParsedAttributesView &DeclAttrs,
4234 MultiTemplateParamsArg TemplateParams,
4235 bool IsExplicitInstantiation,
4236 RecordDecl *&AnonRecord,
4237 SourceLocation EllipsisLoc = {});
4238
4239 /// BuildAnonymousStructOrUnion - Handle the declaration of an
4240 /// anonymous structure or union. Anonymous unions are a C++ feature
4241 /// (C++ [class.union]) and a C11 feature; anonymous structures
4242 /// are a C11 feature and GNU C++ extension.
4243 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
4244 RecordDecl *Record,
4245 const PrintingPolicy &Policy);
4246
4247 /// Called once it is known whether
4248 /// a tag declaration is an anonymous union or struct.
4250
4251 /// Emit diagnostic warnings for placeholder members.
4252 /// We can only do that after the class is fully constructed,
4253 /// as anonymous union/structs can insert placeholders
4254 /// in their parent scope (which might be a Record).
4256
4257 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
4258 /// Microsoft C anonymous structure.
4259 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
4260 /// Example:
4261 ///
4262 /// struct A { int a; };
4263 /// struct B { struct A; int b; };
4264 ///
4265 /// void foo() {
4266 /// B var;
4267 /// var.a = 3;
4268 /// }
4269 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
4270 RecordDecl *Record);
4271
4272 /// Given a non-tag type declaration, returns an enum useful for indicating
4273 /// what kind of non-tag type this is.
4274 NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
4275
4276 /// Determine whether a tag with a given kind is acceptable
4277 /// as a redeclaration of the given tag declaration.
4278 ///
4279 /// \returns true if the new tag kind is acceptable, false otherwise.
4281 bool isDefinition, SourceLocation NewTagLoc,
4282 const IdentifierInfo *Name);
4283
4284 /// This is invoked when we see 'struct foo' or 'struct {'. In the
4285 /// former case, Name will be non-null. In the later case, Name will be null.
4286 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
4287 /// a reference/declaration/definition of a tag.
4288 ///
4289 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
4290 /// trailing-type-specifier) other than one in an alias-declaration.
4291 ///
4292 /// \param SkipBody If non-null, will be set to indicate if the caller should
4293 /// skip the definition of this tag and treat it as if it were a declaration.
4294 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
4295 SourceLocation KWLoc, CXXScopeSpec &SS,
4296 IdentifierInfo *Name, SourceLocation NameLoc,
4297 const ParsedAttributesView &Attr, AccessSpecifier AS,
4298 SourceLocation ModulePrivateLoc,
4299 MultiTemplateParamsArg TemplateParameterLists,
4300 bool &OwnedDecl, bool &IsDependent,
4301 SourceLocation ScopedEnumKWLoc,
4302 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
4303 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
4304 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
4305
4306 /// ActOnField - Each field of a C struct/union is passed into this in order
4307 /// to create a FieldDecl object for it.
4308 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
4309 Declarator &D, Expr *BitfieldWidth);
4310
4311 /// HandleField - Analyze a field of a C struct or a C++ data member.
4312 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
4313 Declarator &D, Expr *BitfieldWidth,
4314 InClassInitStyle InitStyle, AccessSpecifier AS);
4315
4316 /// Build a new FieldDecl and check its well-formedness.
4317 ///
4318 /// This routine builds a new FieldDecl given the fields name, type,
4319 /// record, etc. \p PrevDecl should refer to any previous declaration
4320 /// with the same name and in the same scope as the field to be
4321 /// created.
4322 ///
4323 /// \returns a new FieldDecl.
4324 ///
4325 /// \todo The Declarator argument is a hack. It will be removed once
4326 FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
4327 TypeSourceInfo *TInfo, RecordDecl *Record,
4328 SourceLocation Loc, bool Mutable,
4329 Expr *BitfieldWidth, InClassInitStyle InitStyle,
4330 SourceLocation TSSL, AccessSpecifier AS,
4331 NamedDecl *PrevDecl, Declarator *D = nullptr);
4332
4334
4335 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
4336 /// class and class extensions. For every class \@interface and class
4337 /// extension \@interface, if the last ivar is a bitfield of any type,
4338 /// then add an implicit `char :0` ivar to the end of that interface.
4339 void ActOnLastBitfield(SourceLocation DeclStart,
4340 SmallVectorImpl<Decl *> &AllIvarDecls);
4341
4342 // This is used for both record definitions and ObjC interface declarations.
4343 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
4344 ArrayRef<Decl *> Fields, SourceLocation LBrac,
4345 SourceLocation RBrac, const ParsedAttributesView &AttrList);
4346
4347 /// ActOnTagStartDefinition - Invoked when we have entered the
4348 /// scope of a tag's definition (e.g., for an enumeration, class,
4349 /// struct, or union).
4350 void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
4351
4352 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
4353 /// Differently from C++, actually parse the body and reject / error out
4354 /// in case of a structural mismatch.
4355 bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody);
4356
4358
4359 /// Invoked when we enter a tag definition that we're skipping.
4361
4362 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
4363 /// C++ record definition's base-specifiers clause and are starting its
4364 /// member declarations.
4366 SourceLocation FinalLoc,
4367 bool IsFinalSpelledSealed,
4368 bool IsAbstract,
4369 SourceLocation TriviallyRelocatable,
4370 SourceLocation Replaceable,
4371 SourceLocation LBraceLoc);
4372
4373 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
4374 /// the definition of a tag (enumeration, class, struct, or union).
4376 SourceRange BraceRange);
4377
4380
4382
4383 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
4384 /// error parsing the definition of a tag.
4386
4388 EnumConstantDecl *LastEnumConst,
4389 SourceLocation IdLoc, IdentifierInfo *Id,
4390 Expr *val);
4391
4392 /// Check that this is a valid underlying type for an enum declaration.
4394
4395 /// Check whether this is a valid redeclaration of a previous enumeration.
4396 /// \return true if the redeclaration was invalid.
4397 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
4398 QualType EnumUnderlyingTy, bool IsFixed,
4399 const EnumDecl *Prev);
4400
4401 /// Determine whether the body of an anonymous enumeration should be skipped.
4402 /// \param II The name of the first enumerator.
4404 SourceLocation IILoc);
4405
4406 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
4407 SourceLocation IdLoc, IdentifierInfo *Id,
4408 const ParsedAttributesView &Attrs,
4409 SourceLocation EqualLoc, Expr *Val,
4410 SkipBodyInfo *SkipBody = nullptr);
4411 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
4412 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
4413 const ParsedAttributesView &Attr);
4414
4415 /// Set the current declaration context until it gets popped.
4416 void PushDeclContext(Scope *S, DeclContext *DC);
4417 void PopDeclContext();
4418
4419 /// EnterDeclaratorContext - Used when we must lookup names in the context
4420 /// of a declarator's nested name specifier.
4423
4424 /// Enter a template parameter scope, after it's been associated with a
4425 /// particular DeclContext. Causes lookup within the scope to chain through
4426 /// enclosing contexts in the correct order.
4428
4429 /// Push the parameters of D, which must be a function, into scope.
4432
4433 /// Add this decl to the scope shadowed decl chains.
4434 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4435
4436 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4437 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4438 /// true if 'D' belongs to the given declaration context.
4439 ///
4440 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4441 /// enclosing namespace set of the context, rather than contained
4442 /// directly within it.
4443 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4444 bool AllowInlineNamespace = false) const;
4445
4446 /// Finds the scope corresponding to the given decl context, if it
4447 /// happens to be an enclosing scope. Otherwise return NULL.
4449
4450 /// Subroutines of ActOnDeclarator().
4452 TypeSourceInfo *TInfo);
4454
4455 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4457 NamedDecl *New, Decl *Old,
4459
4460 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4461 /// same name and scope as a previous declaration 'Old'. Figure out
4462 /// how to resolve this situation, merging decls or emitting
4463 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4465 LookupResult &OldDecls);
4466
4467 /// CleanupMergedEnum - We have just merged the decl 'New' by making another
4468 /// definition visible.
4469 /// This method performs any necessary cleanup on the parser state to discard
4470 /// child nodes from newly parsed decl we are retiring.
4471 void CleanupMergedEnum(Scope *S, Decl *New);
4472
4473 /// MergeFunctionDecl - We just parsed a function 'New' from
4474 /// declarator D which has the same name and scope as a previous
4475 /// declaration 'Old'. Figure out how to resolve this situation,
4476 /// merging decls or emitting diagnostics as appropriate.
4477 ///
4478 /// In C++, New and Old must be declarations that are not
4479 /// overloaded. Use IsOverload to determine whether New and Old are
4480 /// overloaded, and to select the Old declaration that New should be
4481 /// merged with.
4482 ///
4483 /// Returns true if there was an error, false otherwise.
4485 bool MergeTypeWithOld, bool NewDeclIsDefn);
4486
4487 /// Completes the merge of two function declarations that are
4488 /// known to be compatible.
4489 ///
4490 /// This routine handles the merging of attributes and other
4491 /// properties of function declarations from the old declaration to
4492 /// the new declaration, once we know that New is in fact a
4493 /// redeclaration of Old.
4494 ///
4495 /// \returns false
4497 Scope *S, bool MergeTypeWithOld);
4499
4500 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4501 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4502 /// situation, merging decls or emitting diagnostics as appropriate.
4503 ///
4504 /// Tentative definition rules (C99 6.9.2p2) are checked by
4505 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4506 /// definitions here, since the initializer hasn't been attached.
4508
4509 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4510 /// scope as a previous declaration 'Old'. Figure out how to merge their
4511 /// types, emitting diagnostics as appropriate.
4512 ///
4513 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4514 /// back to here in AddInitializerToDecl. We can't check them before the
4515 /// initializer is attached.
4516 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4517
4518 /// We've just determined that \p Old and \p New both appear to be definitions
4519 /// of the same variable. Either diagnose or fix the problem.
4520 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4522
4523 /// Filters out lookup results that don't fall within the given scope
4524 /// as determined by isDeclInScope.
4526 bool ConsiderLinkage, bool AllowInlineNamespace);
4527
4528 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4529 /// have compatible owning modules.
4531
4532 /// [module.interface]p6:
4533 /// A redeclaration of an entity X is implicitly exported if X was introduced
4534 /// by an exported declaration; otherwise it shall not be exported.
4536
4537 /// A wrapper function for checking the semantic restrictions of
4538 /// a redeclaration within a module.
4540
4541 /// Check the redefinition in C++20 Modules.
4542 ///
4543 /// [basic.def.odr]p14:
4544 /// For any definable item D with definitions in multiple translation units,
4545 /// - if D is a non-inline non-templated function or variable, or
4546 /// - if the definitions in different translation units do not satisfy the
4547 /// following requirements,
4548 /// the program is ill-formed; a diagnostic is required only if the
4549 /// definable item is attached to a named module and a prior definition is
4550 /// reachable at the point where a later definition occurs.
4551 /// - Each such definition shall not be attached to a named module
4552 /// ([module.unit]).
4553 /// - Each such definition shall consist of the same sequence of tokens, ...
4554 /// ...
4555 ///
4556 /// Return true if the redefinition is not allowed. Return false otherwise.
4557 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4558
4560
4561 /// If it's a file scoped decl that must warn if not used, keep track
4562 /// of it.
4564
4565 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4567
4570 DiagReceiverTy DiagReceiver);
4571 void DiagnoseUnusedDecl(const NamedDecl *ND);
4572
4573 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4574 /// unless they are marked attr(unused).
4575 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4576
4577 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4578 /// variable.
4579 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4580
4581 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4582 /// from S, where a non-field would be declared. This routine copes
4583 /// with the difference between C and C++ scoping rules in structs and
4584 /// unions. For example, the following code is well-formed in C but
4585 /// ill-formed in C++:
4586 /// @code
4587 /// struct S6 {
4588 /// enum { BAR } e;
4589 /// };
4590 ///
4591 /// void test_S6() {
4592 /// struct S6 a;
4593 /// a.e = BAR;
4594 /// }
4595 /// @endcode
4596 /// For the declaration of BAR, this routine will return a different
4597 /// scope. The scope S will be the scope of the unnamed enumeration
4598 /// within S6. In C++, this routine will return the scope associated
4599 /// with S6, because the enumeration's scope is a transparent
4600 /// context but structures can contain non-field names. In C, this
4601 /// routine will return the translation unit scope, since the
4602 /// enumeration's scope is a transparent context and structures cannot
4603 /// contain non-field names.
4605
4607 SourceLocation Loc);
4608
4609 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4610 /// file scope. lazily create a decl for it. ForRedeclaration is true
4611 /// if we're creating this built-in in anticipation of redeclaring the
4612 /// built-in.
4613 NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S,
4614 bool ForRedeclaration, SourceLocation Loc);
4615
4616 /// Get the outermost AttributedType node that sets a calling convention.
4617 /// Valid types should not have multiple attributes with different CCs.
4618 const AttributedType *getCallingConvAttributedType(QualType T) const;
4619
4620 /// GetNameForDeclarator - Determine the full declaration name for the
4621 /// given Declarator.
4623
4624 /// Retrieves the declaration name from a parsed unqualified-id.
4626
4627 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4628 /// we are currently parsing the initializer.
4630
4631 /// Look for a locally scoped extern "C" declaration by the given name.
4633
4636
4637 /// Adjust the \c DeclContext for a function or variable that might be a
4638 /// function-local external declaration.
4640
4642
4643 /// Checks if the variant/multiversion functions are compatible.
4645 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4646 const PartialDiagnostic &NoProtoDiagID,
4647 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4648 const PartialDiagnosticAt &NoSupportDiagIDAt,
4649 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4650 bool ConstexprSupported, bool CLinkageMayDiffer);
4651
4652 /// type checking declaration initializers (C99 6.7.8)
4654 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4655
4658 SourceRange Range, bool DirectInit,
4659 Expr *Init);
4660
4662 Expr *Init);
4663
4665
4666 // Heuristically tells if the function is `get_return_object` member of a
4667 // coroutine promise_type by matching the function name.
4668 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4669 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4670
4671 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4672 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4674 Scope *S);
4675
4676 /// If this function is a C++ replaceable global allocation function
4677 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4678 /// adds any function attributes that we know a priori based on the standard.
4679 ///
4680 /// We need to check for duplicate attributes both here and where user-written
4681 /// attributes are applied to declarations.
4683 FunctionDecl *FD);
4684
4685 /// Adds any function attributes that we know a priori based on
4686 /// the declaration of this function.
4687 ///
4688 /// These attributes can apply both to implicitly-declared builtins
4689 /// (like __builtin___printf_chk) or to library-declared functions
4690 /// like NSLog or printf.
4691 ///
4692 /// We need to check for duplicate attributes both here and where user-written
4693 /// attributes are applied to declarations.
4695
4696 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4697 /// the correct width, and that the field type is valid.
4698 /// Returns false on success.
4700 const IdentifierInfo *FieldName, QualType FieldTy,
4701 bool IsMsStruct, Expr *BitWidth);
4702
4703 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4704 /// enum. If AllowMask is true, then we also allow the complement of a valid
4705 /// value, to be used as a mask.
4706 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4707 bool AllowMask) const;
4708
4709 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4710 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4711 SourceLocation WeakNameLoc);
4712
4713 /// ActOnPragmaRedefineExtname - Called on well formed
4714 /// \#pragma redefine_extname oldname newname.
4716 IdentifierInfo *AliasName,
4717 SourceLocation PragmaLoc,
4718 SourceLocation WeakNameLoc,
4719 SourceLocation AliasNameLoc);
4720
4721 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4722 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4723 SourceLocation PragmaLoc,
4724 SourceLocation WeakNameLoc,
4725 SourceLocation AliasNameLoc);
4726
4727 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4730 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4731 OMPDiscarded, // Discarded due to OpenMP hostness
4732 TemplateDiscarded, // Discarded due to uninstantiated templates
4734 };
4735 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4736 bool Final = false);
4737
4738 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4740
4741 /// Function or variable declarations to be checked for whether the deferred
4742 /// diagnostics should be emitted.
4744
4745private:
4746 /// Map of current shadowing declarations to shadowed declarations. Warn if
4747 /// it looks like the user is trying to modify the shadowing declaration.
4748 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4749
4750 // We need this to handle
4751 //
4752 // typedef struct {
4753 // void *foo() { return 0; }
4754 // } A;
4755 //
4756 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4757 // for example. If 'A', foo will have external linkage. If we have '*A',
4758 // foo will have no linkage. Since we can't know until we get to the end
4759 // of the typedef, this function finds out if D might have non-external
4760 // linkage. Callers should verify at the end of the TU if it D has external
4761 // linkage or not.
4762 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4763
4764 ///@}
4765
4766 //
4767 //
4768 // -------------------------------------------------------------------------
4769 //
4770 //
4771
4772 /// \name Declaration Attribute Handling
4773 /// Implementations are in SemaDeclAttr.cpp
4774 ///@{
4775
4776public:
4777 /// Describes the kind of priority given to an availability attribute.
4778 ///
4779 /// The sum of priorities deteremines the final priority of the attribute.
4780 /// The final priority determines how the attribute will be merged.
4781 /// An attribute with a lower priority will always remove higher priority
4782 /// attributes for the specified platform when it is being applied. An
4783 /// attribute with a higher priority will not be applied if the declaration
4784 /// already has an availability attribute with a lower priority for the
4785 /// specified platform. The final prirority values are not expected to match
4786 /// the values in this enumeration, but instead should be treated as a plain
4787 /// integer value. This enumeration just names the priority weights that are
4788 /// used to calculate that final vaue.
4790 /// The availability attribute was specified explicitly next to the
4791 /// declaration.
4793
4794 /// The availability attribute was applied using '#pragma clang attribute'.
4796
4797 /// The availability attribute for a specific platform was inferred from
4798 /// an availability attribute for another platform.
4800 };
4801
4802 /// Describes the reason a calling convention specification was ignored, used
4803 /// for diagnostics.
4810
4811 /// A helper function to provide Attribute Location for the Attr types
4812 /// AND the ParsedAttr.
4813 template <typename AttrInfo>
4814 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4815 getAttrLoc(const AttrInfo &AL) {
4816 return AL.getLocation();
4817 }
4819
4820 /// If Expr is a valid integer constant, get the value of the integer
4821 /// expression and return success or failure. May output an error.
4822 ///
4823 /// Negative argument is implicitly converted to unsigned, unless
4824 /// \p StrictlyUnsigned is true.
4825 template <typename AttrInfo>
4826 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4827 unsigned Idx = UINT_MAX,
4828 bool StrictlyUnsigned = false) {
4829 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4830 if (Expr->isTypeDependent() ||
4832 if (Idx != UINT_MAX)
4833 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4834 << &AI << Idx << AANT_ArgumentIntegerConstant
4835 << Expr->getSourceRange();
4836 else
4837 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4839 return false;
4840 }
4841
4842 if (!I->isIntN(32)) {
4843 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4844 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4845 return false;
4846 }
4847
4848 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
4849 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
4850 << &AI << /*non-negative*/ 1;
4851 return false;
4852 }
4853
4854 Val = (uint32_t)I->getZExtValue();
4855 return true;
4856 }
4857
4858 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
4859 /// \#pragma weak during processing of other Decls.
4860 /// I couldn't figure out a clean way to generate these in-line, so
4861 /// we store them here and handle separately -- which is a hack.
4862 /// It would be best to refactor this.
4864
4865 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
4867
4871
4872 /// ExtVectorDecls - This is a list all the extended vector types. This allows
4873 /// us to associate a raw vector type with one of the ext_vector type names.
4874 /// This is only necessary for issuing pretty diagnostics.
4876
4877 /// Check if the argument \p E is a ASCII string literal. If not emit an error
4878 /// and return false, otherwise set \p Str to the value of the string literal
4879 /// and return true.
4881 const Expr *E, StringRef &Str,
4882 SourceLocation *ArgLocation = nullptr);
4883
4884 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
4885 /// If not emit an error and return false. If the argument is an identifier it
4886 /// will emit an error with a fixit hint and treat it as if it was a string
4887 /// literal.
4888 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
4889 StringRef &Str,
4890 SourceLocation *ArgLocation = nullptr);
4891
4892 /// Determine if type T is a valid subject for a nonnull and similar
4893 /// attributes. Dependent types are considered valid so they can be checked
4894 /// during instantiation time. By default, we look through references (the
4895 /// behavior used by nonnull), but if the second parameter is true, then we
4896 /// treat a reference type as valid.
4897 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
4898
4899 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
4900 /// declaration.
4901 void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4902 Expr *OE);
4903
4904 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
4905 /// declaration.
4906 void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
4907 Expr *ParamExpr);
4908
4909 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
4910 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
4911
4912 AvailabilityAttr *mergeAvailabilityAttr(
4913 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform,
4914 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
4915 VersionTuple Obsoleted, bool IsUnavailable, StringRef Message,
4916 bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK,
4917 int Priority, IdentifierInfo *IIEnvironment);
4918
4919 TypeVisibilityAttr *
4921 TypeVisibilityAttr::VisibilityType Vis);
4922 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
4923 VisibilityAttr::VisibilityType Vis);
4924 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
4925 StringRef Name);
4926
4927 /// Used to implement to perform semantic checking on
4928 /// attribute((section("foo"))) specifiers.
4929 ///
4930 /// In this case, "foo" is passed in to be checked. If the section
4931 /// specifier is invalid, return an Error that indicates the problem.
4932 ///
4933 /// This is a simple quality of implementation feature to catch errors
4934 /// and give good diagnostics in cases when the assembler or code generator
4935 /// would otherwise reject the section specifier.
4936 llvm::Error isValidSectionSpecifier(StringRef Str);
4937 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
4938 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
4939 StringRef Name);
4940
4941 // Check for things we'd like to warn about. Multiversioning issues are
4942 // handled later in the process, once we know how many exist.
4943 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
4944
4945 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
4946 StringRef NewUserDiagnostic);
4947 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
4948 IdentifierInfo *Format, int FormatIdx,
4949 int FirstArg);
4950 FormatMatchesAttr *mergeFormatMatchesAttr(Decl *D,
4951 const AttributeCommonInfo &CI,
4952 IdentifierInfo *Format,
4953 int FormatIdx,
4954 StringLiteral *FormatStr);
4955
4956 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4957 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4958 bool IsPackExpansion);
4960 bool IsPackExpansion);
4961
4962 /// AddAlignValueAttr - Adds an align_value attribute to a particular
4963 /// declaration.
4964 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
4965
4966 /// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
4967 Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
4970
4972 bool BestCase,
4973 MSInheritanceModel SemanticSpelling);
4974
4976
4977 /// AddModeAttr - Adds a mode attribute to a particular declaration.
4978 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
4979 bool InInstantiation = false);
4980 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
4981 const AttributeCommonInfo &CI,
4982 const IdentifierInfo *Ident);
4983 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
4984 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
4985 const AttributeCommonInfo &CI);
4986 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
4987 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
4988 const InternalLinkageAttr &AL);
4989
4990 /// Check validaty of calling convention attribute \p attr. If \p FD
4991 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
4992 /// target. Otherwise, it is specified by \p CFT.
4994 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
4996
4997 /// Checks a regparm attribute, returning true if it is ill-formed and
4998 /// otherwise setting numParams to the appropriate value.
4999 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
5000
5001 /// Create an CUDALaunchBoundsAttr attribute.
5002 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
5003 Expr *MaxThreads,
5004 Expr *MinBlocks,
5005 Expr *MaxBlocks);
5006
5007 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
5008 /// declaration.
5009 void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
5010 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
5011
5012 enum class RetainOwnershipKind { NS, CF, OS };
5013
5014 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
5015 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
5016
5017 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
5018
5019 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
5020 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
5021 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
5022 const AttributeCommonInfo &CI,
5023 bool BestCase,
5024 MSInheritanceModel Model);
5025
5026 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
5027 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
5028 const EnforceTCBLeafAttr &AL);
5029
5030 /// Helper for delayed processing TransparentUnion or
5031 /// BPFPreserveAccessIndexAttr attribute.
5033 const ParsedAttributesView &AttrList);
5034
5035 // Options for ProcessDeclAttributeList().
5039
5042 Result.IncludeCXX11Attributes = Val;
5043 return Result;
5044 }
5045
5048 Result.IgnoreTypeAttributes = Val;
5049 return Result;
5050 }
5051
5052 // Should C++11 attributes be processed?
5054
5055 // Should any type attributes encountered be ignored?
5056 // If this option is false, a diagnostic will be emitted for any type
5057 // attributes of a kind that does not "slide" from the declaration to
5058 // the decl-specifier-seq.
5060 };
5061
5062 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
5063 /// attribute list to the specified decl, ignoring any type attributes.
5065 const ParsedAttributesView &AttrList,
5066 const ProcessDeclAttributeOptions &Options =
5068
5069 /// Annotation attributes are the only attributes allowed after an access
5070 /// specifier.
5072 const ParsedAttributesView &AttrList);
5073
5074 /// checkUnusedDeclAttributes - Given a declarator which is not being
5075 /// used to build a declaration, complain about any decl attributes
5076 /// which might be lying around on it.
5078
5079 void DiagnoseUnknownAttribute(const ParsedAttr &AL);
5080
5081 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
5082 /// \#pragma weak needs a non-definition decl and source may not have one.
5084 SourceLocation Loc);
5085
5086 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
5087 /// applied to it, possibly with an alias.
5088 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
5089
5090 void ProcessPragmaWeak(Scope *S, Decl *D);
5091 // Decl attributes - this routine is the top level dispatcher.
5092 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
5093
5095
5096 /// Given a set of delayed diagnostics, re-emit them as if they had
5097 /// been delayed in the current context instead of in the given pool.
5098 /// Essentially, this just moves them to the current pool.
5100
5101 /// Check if IdxExpr is a valid parameter index for a function or
5102 /// instance method D. May output an error.
5103 ///
5104 /// \returns true if IdxExpr is a valid index.
5105 template <typename AttrInfo>
5107 const Decl *D, const AttrInfo &AI, unsigned AttrArgNum,
5108 const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis = false,
5109 bool CanIndexVariadicArguments = false) {
5111
5112 // In C++ the implicit 'this' function parameter also counts.
5113 // Parameters are counted from one.
5114 bool HP = hasFunctionProto(D);
5115 bool HasImplicitThisParam = isInstanceMethod(D);
5116 bool IV = HP && isFunctionOrMethodVariadic(D);
5117 unsigned NumParams =
5118 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
5119
5120 std::optional<llvm::APSInt> IdxInt;
5121 if (IdxExpr->isTypeDependent() ||
5122 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
5123 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
5124 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
5125 << IdxExpr->getSourceRange();
5126 return false;
5127 }
5128
5129 unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX);
5130 if (IdxSource < 1 ||
5131 ((!IV || !CanIndexVariadicArguments) && IdxSource > NumParams)) {
5132 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
5133 << &AI << AttrArgNum << IdxExpr->getSourceRange();
5134 return false;
5135 }
5136 if (HasImplicitThisParam && !CanIndexImplicitThis) {
5137 if (IdxSource == 1) {
5138 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
5139 << &AI << IdxExpr->getSourceRange();
5140 return false;
5141 }
5142 }
5143
5144 Idx = ParamIdx(IdxSource, D);
5145 return true;
5146 }
5147
5148 ///@}
5149
5150 //
5151 //
5152 // -------------------------------------------------------------------------
5153 //
5154 //
5155
5156 /// \name C++ Declarations
5157 /// Implementations are in SemaDeclCXX.cpp
5158 ///@{
5159
5160public:
5162
5163 /// Called before parsing a function declarator belonging to a function
5164 /// declaration.
5166 unsigned TemplateParameterDepth);
5167
5168 /// Called after parsing a function declarator belonging to a function
5169 /// declaration.
5171
5172 // Act on C++ namespaces
5174 SourceLocation NamespaceLoc,
5175 SourceLocation IdentLoc, IdentifierInfo *Ident,
5176 SourceLocation LBrace,
5177 const ParsedAttributesView &AttrList,
5178 UsingDirectiveDecl *&UsingDecl, bool IsNested);
5179
5180 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
5181 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
5182 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
5183
5185
5186 /// Retrieve the special "std" namespace, which may require us to
5187 /// implicitly define the namespace.
5189
5191 EnumDecl *getStdAlignValT() const;
5192
5195 QualType AllocType, SourceLocation);
5196
5198 const IdentifierInfo *MemberOrBase);
5199
5201 /// The '<=>' operator was used in an expression and a builtin operator
5202 /// was selected.
5204 /// A defaulted 'operator<=>' needed the comparison category. This
5205 /// typically only applies to 'std::strong_ordering', due to the implicit
5206 /// fallback return value.
5208 };
5209
5210 /// Lookup the specified comparison category types in the standard
5211 /// library, an check the VarDecls possibly returned by the operator<=>
5212 /// builtins for that type.
5213 ///
5214 /// \return The type of the comparison category type corresponding to the
5215 /// specified Kind, or a null type if an error occurs
5217 SourceLocation Loc,
5219
5220 /// Tests whether Ty is an instance of std::initializer_list and, if
5221 /// it is and Element is not NULL, assigns the element type to Element.
5222 bool isStdInitializerList(QualType Ty, QualType *Element);
5223
5224 /// Tests whether Ty is an instance of std::type_identity and, if
5225 /// it is and TypeArgument is not NULL, assigns the element type to Element.
5226 /// If MalformedDecl is not null, and type_identity was ruled out due to being
5227 /// incorrectly structured despite having the correct name, the faulty Decl
5228 /// will be assigned to MalformedDecl.
5229 bool isStdTypeIdentity(QualType Ty, QualType *TypeArgument,
5230 const Decl **MalformedDecl = nullptr);
5231
5232 /// Looks for the std::initializer_list template and instantiates it
5233 /// with Element, or emits an error if it's not found.
5234 ///
5235 /// \returns The instantiated template, or null on error.
5237
5238 /// Looks for the std::type_identity template and instantiates it
5239 /// with Type, or returns a null type if type_identity has not been declared
5240 ///
5241 /// \returns The instantiated template, or null if std::type_identity is not
5242 /// declared
5244
5245 /// Determine whether Ctor is an initializer-list constructor, as
5246 /// defined in [dcl.init.list]p2.
5247 bool isInitListConstructor(const FunctionDecl *Ctor);
5248
5249 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
5250 SourceLocation NamespcLoc, CXXScopeSpec &SS,
5251 SourceLocation IdentLoc,
5252 IdentifierInfo *NamespcName,
5253 const ParsedAttributesView &AttrList);
5254
5256
5257 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
5258 SourceLocation AliasLoc, IdentifierInfo *Alias,
5259 CXXScopeSpec &SS, SourceLocation IdentLoc,
5260 IdentifierInfo *Ident);
5261
5262 /// Remove decls we can't actually see from a lookup being used to declare
5263 /// shadow using decls.
5264 ///
5265 /// \param S - The scope of the potential shadow decl
5266 /// \param Previous - The lookup of a potential shadow decl's name.
5267 void FilterUsingLookup(Scope *S, LookupResult &lookup);
5268
5269 /// Hides a using shadow declaration. This is required by the current
5270 /// using-decl implementation when a resolvable using declaration in a
5271 /// class is followed by a declaration which would hide or override
5272 /// one or more of the using decl's targets; for example:
5273 ///
5274 /// struct Base { void foo(int); };
5275 /// struct Derived : Base {
5276 /// using Base::foo;
5277 /// void foo(int);
5278 /// };
5279 ///
5280 /// The governing language is C++03 [namespace.udecl]p12:
5281 ///
5282 /// When a using-declaration brings names from a base class into a
5283 /// derived class scope, member functions in the derived class
5284 /// override and/or hide member functions with the same name and
5285 /// parameter types in a base class (rather than conflicting).
5286 ///
5287 /// There are two ways to implement this:
5288 /// (1) optimistically create shadow decls when they're not hidden
5289 /// by existing declarations, or
5290 /// (2) don't create any shadow decls (or at least don't make them
5291 /// visible) until we've fully parsed/instantiated the class.
5292 /// The problem with (1) is that we might have to retroactively remove
5293 /// a shadow decl, which requires several O(n) operations because the
5294 /// decl structures are (very reasonably) not designed for removal.
5295 /// (2) avoids this but is very fiddly and phase-dependent.
5296 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
5297
5298 /// Determines whether to create a using shadow decl for a particular
5299 /// decl, given the set of decls existing prior to this using lookup.
5301 const LookupResult &PreviousDecls,
5302 UsingShadowDecl *&PrevShadow);
5303
5304 /// Builds a shadow declaration corresponding to a 'using' declaration.
5307 UsingShadowDecl *PrevDecl);
5308
5309 /// Checks that the given using declaration is not an invalid
5310 /// redeclaration. Note that this is checking only for the using decl
5311 /// itself, not for any ill-formedness among the UsingShadowDecls.
5313 bool HasTypenameKeyword,
5314 const CXXScopeSpec &SS,
5315 SourceLocation NameLoc,
5316 const LookupResult &Previous);
5317
5318 /// Checks that the given nested-name qualifier used in a using decl
5319 /// in the current context is appropriately related to the current
5320 /// scope. If an error is found, diagnoses it and returns true.
5321 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
5322 /// the result of that lookup. UD is likewise nullptr, except when we have an
5323 /// already-populated UsingDecl whose shadow decls contain the same
5324 /// information (i.e. we're instantiating a UsingDecl with non-dependent
5325 /// scope).
5326 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
5327 const CXXScopeSpec &SS,
5328 const DeclarationNameInfo &NameInfo,
5329 SourceLocation NameLoc,
5330 const LookupResult *R = nullptr,
5331 const UsingDecl *UD = nullptr);
5332
5333 /// Builds a using declaration.
5334 ///
5335 /// \param IsInstantiation - Whether this call arises from an
5336 /// instantiation of an unresolved using declaration. We treat
5337 /// the lookup differently for these declarations.
5339 SourceLocation UsingLoc,
5340 bool HasTypenameKeyword,
5341 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5342 DeclarationNameInfo NameInfo,
5343 SourceLocation EllipsisLoc,
5344 const ParsedAttributesView &AttrList,
5345 bool IsInstantiation, bool IsUsingIfExists);
5347 SourceLocation UsingLoc,
5348 SourceLocation EnumLoc,
5349 SourceLocation NameLoc,
5350 TypeSourceInfo *EnumType, EnumDecl *ED);
5351 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
5352 ArrayRef<NamedDecl *> Expansions);
5353
5354 /// Additional checks for a using declaration referring to a constructor name.
5356
5357 /// Given a derived-class using shadow declaration for a constructor and the
5358 /// correspnding base class constructor, find or create the implicit
5359 /// synthesized derived class constructor to use for this initialization.
5362 ConstructorUsingShadowDecl *DerivedShadow);
5363
5365 SourceLocation UsingLoc,
5366 SourceLocation TypenameLoc, CXXScopeSpec &SS,
5367 UnqualifiedId &Name, SourceLocation EllipsisLoc,
5368 const ParsedAttributesView &AttrList);
5370 SourceLocation UsingLoc,
5371 SourceLocation EnumLoc, SourceRange TyLoc,
5372 const IdentifierInfo &II, ParsedType Ty,
5373 const CXXScopeSpec &SS);
5375 MultiTemplateParamsArg TemplateParams,
5376 SourceLocation UsingLoc, UnqualifiedId &Name,
5377 const ParsedAttributesView &AttrList,
5378 TypeResult Type, Decl *DeclFromDeclSpec);
5379
5380 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
5381 /// including handling of its default argument expressions.
5382 ///
5383 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
5385 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5387 bool HadMultipleCandidates, bool IsListInitialization,
5388 bool IsStdInitListInitialization, bool RequiresZeroInit,
5389 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5390
5391 /// Build a CXXConstructExpr whose constructor has already been resolved if
5392 /// it denotes an inherited constructor.
5394 SourceLocation ConstructLoc, QualType DeclInitType,
5395 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5396 bool HadMultipleCandidates, bool IsListInitialization,
5397 bool IsStdInitListInitialization, bool RequiresZeroInit,
5398 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5399
5400 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
5401 // the constructor can be elidable?
5403 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
5404 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
5405 bool HadMultipleCandidates, bool IsListInitialization,
5406 bool IsStdInitListInitialization, bool RequiresZeroInit,
5407 CXXConstructionKind ConstructKind, SourceRange ParenRange);
5408
5410 SourceLocation InitLoc);
5411
5412 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
5413 /// constructed variable.
5414 void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit);
5415
5416 /// Helper class that collects exception specifications for
5417 /// implicitly-declared special member functions.
5419 // Pointer to allow copying
5420 Sema *Self;
5421 // We order exception specifications thus:
5422 // noexcept is the most restrictive, but is only used in C++11.
5423 // throw() comes next.
5424 // Then a throw(collected exceptions)
5425 // Finally no specification, which is expressed as noexcept(false).
5426 // throw(...) is used instead if any called function uses it.
5427 ExceptionSpecificationType ComputedEST;
5428 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5429 SmallVector<QualType, 4> Exceptions;
5430
5431 void ClearExceptions() {
5432 ExceptionsSeen.clear();
5433 Exceptions.clear();
5434 }
5435
5436 public:
5438 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5439 if (!Self.getLangOpts().CPlusPlus11)
5440 ComputedEST = EST_DynamicNone;
5441 }
5442
5443 /// Get the computed exception specification type.
5445 assert(!isComputedNoexcept(ComputedEST) &&
5446 "noexcept(expr) should not be a possible result");
5447 return ComputedEST;
5448 }
5449
5450 /// The number of exceptions in the exception specification.
5451 unsigned size() const { return Exceptions.size(); }
5452
5453 /// The set of exceptions in the exception specification.
5454 const QualType *data() const { return Exceptions.data(); }
5455
5456 /// Integrate another called method into the collected data.
5457 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5458
5459 /// Integrate an invoked expression into the collected data.
5460 void CalledExpr(Expr *E) { CalledStmt(E); }
5461
5462 /// Integrate an invoked statement into the collected data.
5463 void CalledStmt(Stmt *S);
5464
5465 /// Overwrite an EPI's exception specification with this
5466 /// computed exception specification.
5469 ESI.Type = getExceptionSpecType();
5470 if (ESI.Type == EST_Dynamic) {
5471 ESI.Exceptions = Exceptions;
5472 } else if (ESI.Type == EST_None) {
5473 /// C++11 [except.spec]p14:
5474 /// The exception-specification is noexcept(false) if the set of
5475 /// potential exceptions of the special member function contains "any"
5476 ESI.Type = EST_NoexceptFalse;
5477 ESI.NoexceptExpr =
5478 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5479 }
5480 return ESI;
5481 }
5482 };
5483
5484 /// Evaluate the implicit exception specification for a defaulted
5485 /// special member function.
5487
5488 /// Check the given exception-specification and update the
5489 /// exception specification information with the results.
5490 void checkExceptionSpecification(bool IsTopLevel,
5492 ArrayRef<ParsedType> DynamicExceptions,
5493 ArrayRef<SourceRange> DynamicExceptionRanges,
5494 Expr *NoexceptExpr,
5495 SmallVectorImpl<QualType> &Exceptions,
5497
5498 /// Add an exception-specification to the given member or friend function
5499 /// (or function template). The exception-specification was parsed
5500 /// after the function itself was declared.
5502 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5503 ArrayRef<ParsedType> DynamicExceptions,
5504 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5505
5506 class InheritedConstructorInfo;
5507
5508 /// Determine if a special member function should have a deleted
5509 /// definition when it is defaulted.
5511 InheritedConstructorInfo *ICI = nullptr,
5512 bool Diagnose = false);
5513
5514 /// Produce notes explaining why a defaulted function was defined as deleted.
5516
5517 /// Declare the implicit default constructor for the given class.
5518 ///
5519 /// \param ClassDecl The class declaration into which the implicit
5520 /// default constructor will be added.
5521 ///
5522 /// \returns The implicitly-declared default constructor.
5525
5526 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5527 /// defining this constructor as the default constructor.
5530
5531 /// Declare the implicit destructor for the given class.
5532 ///
5533 /// \param ClassDecl The class declaration into which the implicit
5534 /// destructor will be added.
5535 ///
5536 /// \returns The implicitly-declared destructor.
5538
5539 /// DefineImplicitDestructor - Checks for feasibility of
5540 /// defining this destructor as the default destructor.
5541 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5543
5544 /// Build an exception spec for destructors that don't have one.
5545 ///
5546 /// C++11 says that user-defined destructors with no exception spec get one
5547 /// that looks as if the destructor was implicitly declared.
5549
5550 /// Define the specified inheriting constructor.
5553
5554 /// Declare the implicit copy constructor for the given class.
5555 ///
5556 /// \param ClassDecl The class declaration into which the implicit
5557 /// copy constructor will be added.
5558 ///
5559 /// \returns The implicitly-declared copy constructor.
5561
5562 /// DefineImplicitCopyConstructor - Checks for feasibility of
5563 /// defining this constructor as the copy constructor.
5564 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5566
5567 /// Declare the implicit move constructor for the given class.
5568 ///
5569 /// \param ClassDecl The Class declaration into which the implicit
5570 /// move constructor will be added.
5571 ///
5572 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5573 /// declared.
5575
5576 /// DefineImplicitMoveConstructor - Checks for feasibility of
5577 /// defining this constructor as the move constructor.
5578 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5580
5581 /// Declare the implicit copy assignment operator for the given class.
5582 ///
5583 /// \param ClassDecl The class declaration into which the implicit
5584 /// copy assignment operator will be added.
5585 ///
5586 /// \returns The implicitly-declared copy assignment operator.
5588
5589 /// Defines an implicitly-declared copy assignment operator.
5590 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5591 CXXMethodDecl *MethodDecl);
5592
5593 /// Declare the implicit move assignment operator for the given class.
5594 ///
5595 /// \param ClassDecl The Class declaration into which the implicit
5596 /// move assignment operator will be added.
5597 ///
5598 /// \returns The implicitly-declared move assignment operator, or NULL if it
5599 /// wasn't declared.
5601
5602 /// Defines an implicitly-declared move assignment operator.
5603 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5604 CXXMethodDecl *MethodDecl);
5605
5606 /// Check a completed declaration of an implicit special member.
5608
5609 /// Determine whether the given function is an implicitly-deleted
5610 /// special member function.
5612
5613 /// Check whether 'this' shows up in the type of a static member
5614 /// function after the (naturally empty) cv-qualifier-seq would be.
5615 ///
5616 /// \returns true if an error occurred.
5618
5619 /// Whether this' shows up in the exception specification of a static
5620 /// member function.
5622
5623 /// Check whether 'this' shows up in the attributes of the given
5624 /// static member function.
5625 ///
5626 /// \returns true if an error occurred.
5628
5630 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5631
5633
5634 /// Given a constructor and the set of arguments provided for the
5635 /// constructor, convert the arguments and add any required default arguments
5636 /// to form a proper call to this constructor.
5637 ///
5638 /// \returns true if an error occurred, false otherwise.
5640 QualType DeclInitType, MultiExprArg ArgsPtr,
5641 SourceLocation Loc,
5642 SmallVectorImpl<Expr *> &ConvertedArgs,
5643 bool AllowExplicit = false,
5644 bool IsListInitialization = false);
5645
5646 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5647 /// initializer for the declaration 'Dcl'.
5648 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5649 /// static data member of class X, names should be looked up in the scope of
5650 /// class X.
5652
5653 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5654 /// initializer for the declaration 'Dcl'.
5655 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5656
5657 /// Define the "body" of the conversion from a lambda object to a
5658 /// function pointer.
5659 ///
5660 /// This routine doesn't actually define a sensible body; rather, it fills
5661 /// in the initialization expression needed to copy the lambda object into
5662 /// the block, and IR generation actually generates the real body of the
5663 /// block pointer conversion.
5664 void
5666 CXXConversionDecl *Conv);
5667
5668 /// Define the "body" of the conversion from a lambda object to a
5669 /// block pointer.
5670 ///
5671 /// This routine doesn't actually define a sensible body; rather, it fills
5672 /// in the initialization expression needed to copy the lambda object into
5673 /// the block, and IR generation actually generates the real body of the
5674 /// block pointer conversion.
5676 CXXConversionDecl *Conv);
5677
5678 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5679 /// linkage specification, including the language and (if present)
5680 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5681 /// language string literal. LBraceLoc, if valid, provides the location of
5682 /// the '{' brace. Otherwise, this linkage specification does not
5683 /// have any braces.
5685 Expr *LangStr, SourceLocation LBraceLoc);
5686
5687 /// ActOnFinishLinkageSpecification - Complete the definition of
5688 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5689 /// valid, it's the position of the closing '}' brace in a linkage
5690 /// specification that uses braces.
5692 SourceLocation RBraceLoc);
5693
5694 //===--------------------------------------------------------------------===//
5695 // C++ Classes
5696 //
5697
5698 /// Get the class that is directly named by the current context. This is the
5699 /// class for which an unqualified-id in this scope could name a constructor
5700 /// or destructor.
5701 ///
5702 /// If the scope specifier denotes a class, this will be that class.
5703 /// If the scope specifier is empty, this will be the class whose
5704 /// member-specification we are currently within. Otherwise, there
5705 /// is no such class.
5707
5708 /// isCurrentClassName - Determine whether the identifier II is the
5709 /// name of the class type currently being defined. In the case of
5710 /// nested classes, this will only return true if II is the name of
5711 /// the innermost class.
5712 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5713 const CXXScopeSpec *SS = nullptr);
5714
5715 /// Determine whether the identifier II is a typo for the name of
5716 /// the class type currently being defined. If so, update it to the identifier
5717 /// that should have been used.
5719
5720 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5722 SourceLocation ColonLoc,
5723 const ParsedAttributesView &Attrs);
5724
5725 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5726 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5727 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5728 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5729 /// present (but parsing it has been deferred).
5730 NamedDecl *
5732 MultiTemplateParamsArg TemplateParameterLists,
5733 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5734 InClassInitStyle InitStyle);
5735
5736 /// Enter a new C++ default initializer scope. After calling this, the
5737 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5738 /// parsing or instantiating the initializer failed.
5740
5741 /// This is invoked after parsing an in-class initializer for a
5742 /// non-static C++ class member, and after instantiating an in-class
5743 /// initializer in a class template. Such actions are deferred until the class
5744 /// is complete.
5746 SourceLocation EqualLoc,
5748
5749 /// Handle a C++ member initializer using parentheses syntax.
5751 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5752 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5753 const DeclSpec &DS, SourceLocation IdLoc,
5754 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5755 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5756
5757 /// Handle a C++ member initializer using braced-init-list syntax.
5758 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5759 CXXScopeSpec &SS,
5760 IdentifierInfo *MemberOrBase,
5761 ParsedType TemplateTypeTy,
5762 const DeclSpec &DS, SourceLocation IdLoc,
5763 Expr *InitList, SourceLocation EllipsisLoc);
5764
5765 /// Handle a C++ member initializer.
5766 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5767 CXXScopeSpec &SS,
5768 IdentifierInfo *MemberOrBase,
5769 ParsedType TemplateTypeTy,
5770 const DeclSpec &DS, SourceLocation IdLoc,
5771 Expr *Init, SourceLocation EllipsisLoc);
5772
5774 SourceLocation IdLoc);
5775
5777 TypeSourceInfo *BaseTInfo, Expr *Init,
5778 CXXRecordDecl *ClassDecl,
5779 SourceLocation EllipsisLoc);
5780
5782 CXXRecordDecl *ClassDecl);
5783
5786
5788 ArrayRef<CXXCtorInitializer *> Initializers = {});
5789
5790 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5791 /// mark all the non-trivial destructors of its members and bases as
5792 /// referenced.
5793 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
5794 CXXRecordDecl *Record);
5795
5796 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5797 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5798 /// class. In the Microsoft C++ ABI, this is done any time a class's
5799 /// destructor is referenced.
5801 SourceLocation Location, CXXRecordDecl *ClassDecl,
5802 llvm::SmallPtrSetImpl<const CXXRecordDecl *> *DirectVirtualBases =
5803 nullptr);
5804
5805 /// Do semantic checks to allow the complete destructor variant to be emitted
5806 /// when the destructor is defined in another translation unit. In the Itanium
5807 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
5808 /// can be emitted in separate TUs. To emit the complete variant, run a subset
5809 /// of the checks performed when emitting a regular destructor.
5810 void CheckCompleteDestructorVariant(SourceLocation CurrentLocation,
5811 CXXDestructorDecl *Dtor);
5812
5813 /// The list of classes whose vtables have been used within
5814 /// this translation unit, and the source locations at which the
5815 /// first use occurred.
5816 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
5817
5818 /// The list of vtables that are required but have not yet been
5819 /// materialized.
5821
5822 /// The set of classes whose vtables have been used within
5823 /// this translation unit, and a bit that will be true if the vtable is
5824 /// required to be emitted (otherwise, it should be emitted only if needed
5825 /// by code generation).
5826 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5827
5828 /// Load any externally-stored vtable uses.
5830
5831 /// Note that the vtable for the given class was used at the
5832 /// given location.
5834 bool DefinitionRequired = false);
5835
5836 /// Mark the exception specifications of all virtual member functions
5837 /// in the given class as needed.
5839 const CXXRecordDecl *RD);
5840
5841 /// MarkVirtualMembersReferenced - Will mark all members of the given
5842 /// CXXRecordDecl referenced.
5844 bool ConstexprOnly = false);
5845
5846 /// Define all of the vtables that have been used in this
5847 /// translation unit and reference any virtual members used by those
5848 /// vtables.
5849 ///
5850 /// \returns true if any work was done, false otherwise.
5851 bool DefineUsedVTables();
5852
5853 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
5854 /// special functions, such as the default constructor, copy
5855 /// constructor, or destructor, to the given C++ class (C++
5856 /// [special]p1). This routine can only be executed just before the
5857 /// definition of the class is complete.
5859
5860 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5861 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
5863 bool AnyErrors);
5864
5865 /// Check class-level dllimport/dllexport attribute. The caller must
5866 /// ensure that referenceDLLExportedClassMethods is called some point later
5867 /// when all outer classes of Class are complete.
5870
5872
5873 /// Perform propagation of DLL attributes from a derived class to a
5874 /// templated base class for MS compatibility.
5876 CXXRecordDecl *Class, Attr *ClassAttr,
5877 ClassTemplateSpecializationDecl *BaseTemplateSpec,
5878 SourceLocation BaseLoc);
5879
5880 /// Perform semantic checks on a class definition that has been
5881 /// completing, introducing implicitly-declared members, checking for
5882 /// abstract types, etc.
5883 ///
5884 /// \param S The scope in which the class was parsed. Null if we didn't just
5885 /// parse a class definition.
5886 /// \param Record The completed class.
5888
5889 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
5890 /// conditions that are needed for the attribute to have an effect.
5892
5893 /// Check that VTable Pointer authentication is only being set on the first
5894 /// first instantiation of the vtable
5896
5898 Decl *TagDecl, SourceLocation LBrac,
5899 SourceLocation RBrac,
5900 const ParsedAttributesView &AttrList);
5901
5902 /// Perform any semantic analysis which needs to be delayed until all
5903 /// pending class member declarations have been parsed.
5906
5907 /// This is used to implement the constant expression evaluation part of the
5908 /// attribute enable_if extension. There is nothing in standard C++ which
5909 /// would require reentering parameters.
5912 llvm::function_ref<Scope *()> EnterScope);
5914
5915 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
5916 /// parsing a top-level (non-nested) C++ class, and we are now
5917 /// parsing those parts of the given Method declaration that could
5918 /// not be parsed earlier (C++ [class.mem]p2), such as default
5919 /// arguments. This action should enter the scope of the given
5920 /// Method declaration as if we had just parsed the qualified method
5921 /// name. However, it should not bring the parameters into scope;
5922 /// that will be performed by ActOnDelayedCXXMethodParameter.
5924 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
5926
5927 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
5928 /// processing the delayed method declaration for Method. The method
5929 /// declaration is now considered finished. There may be a separate
5930 /// ActOnStartOfFunctionDef action later (not necessarily
5931 /// immediately!) for this method, if it was also defined inside the
5932 /// class body.
5935
5937
5938 bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx,
5939 StringEvaluationContext EvalContext,
5940 bool ErrorOnInvalidMessage);
5941 bool EvaluateAsString(Expr *Message, std::string &Result, ASTContext &Ctx,
5942 StringEvaluationContext EvalContext,
5943 bool ErrorOnInvalidMessage);
5944
5946 Expr *AssertExpr, Expr *AssertMessageExpr,
5947 SourceLocation RParenLoc);
5949 Expr *AssertExpr, Expr *AssertMessageExpr,
5950 SourceLocation RParenLoc, bool Failed);
5951
5952 /// Try to print more useful information about a failed static_assert
5953 /// with expression \E
5954 void DiagnoseStaticAssertDetails(const Expr *E);
5955
5956 /// If E represents a built-in type trait, or a known standard type trait,
5957 /// try to print more information about why the type type-trait failed.
5958 /// This assumes we already evaluated the expression to a false boolean value.
5959 void DiagnoseTypeTraitDetails(const Expr *E);
5960
5961 /// Handle a friend type declaration. This works in tandem with
5962 /// ActOnTag.
5963 ///
5964 /// Notes on friend class templates:
5965 ///
5966 /// We generally treat friend class declarations as if they were
5967 /// declaring a class. So, for example, the elaborated type specifier
5968 /// in a friend declaration is required to obey the restrictions of a
5969 /// class-head (i.e. no typedefs in the scope chain), template
5970 /// parameters are required to match up with simple template-ids, &c.
5971 /// However, unlike when declaring a template specialization, it's
5972 /// okay to refer to a template specialization without an empty
5973 /// template parameter declaration, e.g.
5974 /// friend class A<T>::B<unsigned>;
5975 /// We permit this as a special case; if there are any template
5976 /// parameters present at all, require proper matching, i.e.
5977 /// template <> template <class T> friend class A<int>::B;
5978 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
5979 MultiTemplateParamsArg TemplateParams,
5980 SourceLocation EllipsisLoc);
5982 MultiTemplateParamsArg TemplateParams);
5983
5984 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
5985 /// the well-formedness of the constructor declarator @p D with type @p
5986 /// R. If there are any errors in the declarator, this routine will
5987 /// emit diagnostics and set the invalid bit to true. In any case, the type
5988 /// will be updated to reflect a well-formed type for the constructor and
5989 /// returned.
5991 StorageClass &SC);
5992
5993 /// CheckConstructor - Checks a fully-formed constructor for
5994 /// well-formedness, issuing any diagnostics required. Returns true if
5995 /// the constructor declarator is invalid.
5997
5998 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
5999 /// the well-formednes of the destructor declarator @p D with type @p
6000 /// R. If there are any errors in the declarator, this routine will
6001 /// emit diagnostics and set the declarator to invalid. Even if this happens,
6002 /// will be updated to reflect a well-formed type for the destructor and
6003 /// returned.
6005 StorageClass &SC);
6006
6007 /// CheckDestructor - Checks a fully-formed destructor definition for
6008 /// well-formedness, issuing any diagnostics required. Returns true
6009 /// on error.
6011
6012 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
6013 /// well-formednes of the conversion function declarator @p D with
6014 /// type @p R. If there are any errors in the declarator, this routine
6015 /// will emit diagnostics and return true. Otherwise, it will return
6016 /// false. Either way, the type @p R will be updated to reflect a
6017 /// well-formed type for the conversion operator.
6019
6020 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
6021 /// the declaration of the given C++ conversion function. This routine
6022 /// is responsible for recording the conversion function in the C++
6023 /// class, if possible.
6025
6026 /// Check the validity of a declarator that we parsed for a deduction-guide.
6027 /// These aren't actually declarators in the grammar, so we need to check that
6028 /// the user didn't specify any pieces that are not part of the
6029 /// deduction-guide grammar. Return true on invalid deduction-guide.
6031 StorageClass &SC);
6032
6034
6037 SourceLocation DefaultLoc);
6039
6040 /// Kinds of defaulted comparison operator functions.
6041 enum class DefaultedComparisonKind : unsigned char {
6042 /// This is not a defaultable comparison operator.
6044 /// This is an operator== that should be implemented as a series of
6045 /// subobject comparisons.
6047 /// This is an operator<=> that should be implemented as a series of
6048 /// subobject comparisons.
6050 /// This is an operator!= that should be implemented as a rewrite in terms
6051 /// of a == comparison.
6053 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
6054 /// terms of a <=> comparison.
6056 };
6057
6061 FunctionDecl *Spaceship);
6064
6066 QualType R, bool IsLambda,
6067 DeclContext *DC = nullptr);
6069 DeclarationName Name, QualType R);
6071
6072 //===--------------------------------------------------------------------===//
6073 // C++ Derived Classes
6074 //
6075
6076 /// Check the validity of a C++ base class specifier.
6077 ///
6078 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
6079 /// and returns NULL otherwise.
6081 SourceRange SpecifierRange, bool Virtual,
6082 AccessSpecifier Access,
6083 TypeSourceInfo *TInfo,
6084 SourceLocation EllipsisLoc);
6085
6086 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
6087 /// one entry in the base class list of a class specifier, for
6088 /// example:
6089 /// class foo : public bar, virtual private baz {
6090 /// 'public bar' and 'virtual private baz' are each base-specifiers.
6091 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
6092 const ParsedAttributesView &Attrs, bool Virtual,
6093 AccessSpecifier Access, ParsedType basetype,
6094 SourceLocation BaseLoc,
6095 SourceLocation EllipsisLoc);
6096
6097 /// Performs the actual work of attaching the given base class
6098 /// specifiers to a C++ class.
6101
6102 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
6103 /// class, after checking whether there are any duplicate base
6104 /// classes.
6105 void ActOnBaseSpecifiers(Decl *ClassDecl,
6107
6108 /// Determine whether the type \p Derived is a C++ class that is
6109 /// derived from the type \p Base.
6110 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6112 bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
6116 CXXBasePaths &Paths);
6117
6118 // FIXME: I don't like this name.
6119 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
6120
6122 SourceLocation Loc, SourceRange Range,
6123 CXXCastPath *BasePath = nullptr,
6124 bool IgnoreAccess = false);
6125
6126 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
6127 /// conversion (where Derived and Base are class types) is
6128 /// well-formed, meaning that the conversion is unambiguous (and
6129 /// that all of the base classes are accessible). Returns true
6130 /// and emits a diagnostic if the code is ill-formed, returns false
6131 /// otherwise. Loc is the location where this routine should point to
6132 /// if there is an error, and Range is the source range to highlight
6133 /// if there is an error.
6134 ///
6135 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
6136 /// diagnostic for the respective type of error will be suppressed, but the
6137 /// check for ill-formed code will still be performed.
6139 unsigned InaccessibleBaseID,
6140 unsigned AmbiguousBaseConvID,
6141 SourceLocation Loc, SourceRange Range,
6142 DeclarationName Name, CXXCastPath *BasePath,
6143 bool IgnoreAccess = false);
6144
6145 /// Builds a string representing ambiguous paths from a
6146 /// specific derived class to different subobjects of the same base
6147 /// class.
6148 ///
6149 /// This function builds a string that can be used in error messages
6150 /// to show the different paths that one can take through the
6151 /// inheritance hierarchy to go from the derived class to different
6152 /// subobjects of a base class. The result looks something like this:
6153 /// @code
6154 /// struct D -> struct B -> struct A
6155 /// struct D -> struct C -> struct A
6156 /// @endcode
6157 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
6158
6160 const CXXMethodDecl *Old);
6161
6162 /// CheckOverridingFunctionReturnType - Checks whether the return types are
6163 /// covariant, according to C++ [class.virtual]p5.
6165 const CXXMethodDecl *Old);
6166
6167 // Check that the overriding method has no explicit object parameter.
6169 const CXXMethodDecl *Old);
6170
6171 /// Mark the given method pure.
6172 ///
6173 /// \param Method the method to be marked pure.
6174 ///
6175 /// \param InitRange the source range that covers the "0" initializer.
6177
6178 /// CheckOverrideControl - Check C++11 override control semantics.
6180
6181 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
6182 /// not used in the declaration of an overriding method.
6184
6185 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
6186 /// function overrides a virtual member function marked 'final', according to
6187 /// C++11 [class.virtual]p4.
6189 const CXXMethodDecl *Old);
6190
6201
6202 struct TypeDiagnoser;
6203
6206 TypeDiagnoser &Diagnoser);
6207 template <typename... Ts>
6209 const Ts &...Args) {
6210 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
6211 return RequireNonAbstractType(Loc, T, Diagnoser);
6212 }
6213
6214 void DiagnoseAbstractType(const CXXRecordDecl *RD);
6215
6216 //===--------------------------------------------------------------------===//
6217 // C++ Overloaded Operators [C++ 13.5]
6218 //
6219
6220 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
6221 /// of this overloaded operator is well-formed. If so, returns false;
6222 /// otherwise, emits appropriate diagnostics and returns true.
6224
6225 /// CheckLiteralOperatorDeclaration - Check whether the declaration
6226 /// of this literal operator function is well-formed. If so, returns
6227 /// false; otherwise, emits appropriate diagnostics and returns true.
6229
6230 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
6231 /// found in an explicit(bool) specifier.
6233
6234 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
6235 /// Returns true if the explicit specifier is now resolved.
6237
6238 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
6239 /// C++ if/switch/while/for statement.
6240 /// e.g: "if (int x = f()) {...}"
6242
6243 // Emitting members of dllexported classes is delayed until the class
6244 // (including field initializers) is fully parsed.
6247
6248 /// Merge the exception specifications of two variable declarations.
6249 ///
6250 /// This is called when there's a redeclaration of a VarDecl. The function
6251 /// checks if the redeclaration might have an exception specification and
6252 /// validates compatibility and merges the specs if necessary.
6254
6255 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
6256 /// function, once we already know that they have the same
6257 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
6258 /// error, false otherwise.
6260
6261 /// Helpers for dealing with blocks and functions.
6263
6264 /// CheckExtraCXXDefaultArguments - Check for any extra default
6265 /// arguments in the declarator, which is not a function declaration
6266 /// or definition and therefore is not permitted to have default
6267 /// arguments. This routine should be invoked for every declarator
6268 /// that is not a function declaration or definition.
6270
6274
6275 /// Perform semantic analysis for the variable declaration that
6276 /// occurs within a C++ catch clause, returning the newly-created
6277 /// variable.
6279 SourceLocation StartLoc,
6280 SourceLocation IdLoc,
6281 const IdentifierInfo *Id);
6282
6283 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
6284 /// handler.
6286
6288
6289 /// Handle a friend tag declaration where the scope specifier was
6290 /// templated.
6292 unsigned TagSpec, SourceLocation TagLoc,
6293 CXXScopeSpec &SS, IdentifierInfo *Name,
6294 SourceLocation NameLoc,
6295 SourceLocation EllipsisLoc,
6297 MultiTemplateParamsArg TempParamLists);
6298
6300 SourceLocation DeclStart, Declarator &D,
6301 Expr *BitfieldWidth,
6302 InClassInitStyle InitStyle,
6303 AccessSpecifier AS,
6304 const ParsedAttr &MSPropertyAttr);
6305
6306 /// Diagnose why the specified class does not have a trivial special member of
6307 /// the given kind.
6310
6311 /// Determine whether a defaulted or deleted special member function is
6312 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
6313 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
6317 bool Diagnose = false);
6318
6319 /// For a defaulted function, the kind of defaulted function that it is.
6321 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
6322 unsigned SpecialMember : 8;
6323 unsigned Comparison : 8;
6324
6325 public:
6327 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
6328 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
6330 : SpecialMember(llvm::to_underlying(CSM)),
6331 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
6333 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
6334 Comparison(llvm::to_underlying(Comp)) {}
6335
6336 bool isSpecialMember() const {
6337 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
6339 }
6340 bool isComparison() const {
6341 return static_cast<DefaultedComparisonKind>(Comparison) !=
6343 }
6344
6345 explicit operator bool() const {
6346 return isSpecialMember() || isComparison();
6347 }
6348
6350 return static_cast<CXXSpecialMemberKind>(SpecialMember);
6351 }
6353 return static_cast<DefaultedComparisonKind>(Comparison);
6354 }
6355
6356 /// Get the index of this function kind for use in diagnostics.
6357 unsigned getDiagnosticIndex() const {
6358 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
6359 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
6360 "invalid should have highest index");
6361 static_assert((unsigned)DefaultedComparisonKind::None == 0,
6362 "none should be equal to zero");
6363 return SpecialMember + Comparison;
6364 }
6365 };
6366
6367 /// Determine the kind of defaulting that would be done for a given function.
6368 ///
6369 /// If the function is both a default constructor and a copy / move
6370 /// constructor (due to having a default argument for the first parameter),
6371 /// this picks CXXSpecialMemberKind::DefaultConstructor.
6372 ///
6373 /// FIXME: Check that case is properly handled by all callers.
6374 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
6375
6376 /// Handle a C++11 empty-declaration and attribute-declaration.
6378 SourceLocation SemiLoc);
6379
6381 /// Diagnose issues that are non-constant or that are extensions.
6383 /// Identify whether this function satisfies the formal rules for constexpr
6384 /// functions in the current lanugage mode (with no extensions).
6386 };
6387
6388 // Check whether a function declaration satisfies the requirements of a
6389 // constexpr function definition or a constexpr constructor definition. If so,
6390 // return true. If not, produce appropriate diagnostics (unless asked not to
6391 // by Kind) and return false.
6392 //
6393 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
6395 CheckConstexprKind Kind);
6396
6397 /// Diagnose methods which overload virtual methods in a base class
6398 /// without overriding any.
6400
6401 /// Check if a method overloads virtual methods in a base class without
6402 /// overriding any.
6403 void
6405 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6406 void
6408 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
6409
6410 /// ActOnParamDefaultArgument - Check whether the default argument
6411 /// provided for a function parameter is well-formed. If so, attach it
6412 /// to the parameter declaration.
6413 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
6414 Expr *defarg);
6415
6416 /// ActOnParamUnparsedDefaultArgument - We've seen a default
6417 /// argument for a function parameter, but we can't parse it yet
6418 /// because we're inside a class definition. Note that this default
6419 /// argument will be parsed later.
6421 SourceLocation ArgLoc);
6422
6423 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
6424 /// the default argument for the parameter param failed.
6426 Expr *DefaultArg);
6428 SourceLocation EqualLoc);
6429 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
6430 SourceLocation EqualLoc);
6431
6432 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
6433 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
6434 StringLiteral *Message = nullptr);
6435 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6436
6437 void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind,
6438 StringLiteral *DeletedMessage = nullptr);
6442
6443 NamedDecl *
6445 MultiTemplateParamsArg TemplateParamLists);
6448 RecordDecl *ClassDecl,
6449 const IdentifierInfo *Name);
6450
6452 SourceLocation Loc);
6454
6455 /// Stack containing information needed when in C++2a an 'auto' is encountered
6456 /// in a function declaration parameter type specifier in order to invent a
6457 /// corresponding template parameter in the enclosing abbreviated function
6458 /// template. This information is also present in LambdaScopeInfo, stored in
6459 /// the FunctionScopes stack.
6461
6462 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6463 std::unique_ptr<CXXFieldCollector> FieldCollector;
6464
6466 /// Set containing all declared private fields that are not used.
6468
6470
6471 /// PureVirtualClassDiagSet - a set of class declarations which we have
6472 /// emitted a list of pure virtual functions. Used to prevent emitting the
6473 /// same list more than once.
6474 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6475
6479
6480 /// All the delegating constructors seen so far in the file, used for
6481 /// cycle detection at the end of the TU.
6483
6484 /// The C++ "std" namespace, where the standard library resides.
6486
6487 /// The C++ "std::initializer_list" template, which is defined in
6488 /// <initializer_list>.
6490
6491 /// The C++ "std::type_identity" template, which is defined in
6492 /// <type_traits>.
6494
6495 // Contains the locations of the beginning of unparsed default
6496 // argument locations.
6497 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6498
6499 /// UndefinedInternals - all the used, undefined objects which require a
6500 /// definition in this translation unit.
6501 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6502
6503 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6505
6506 /// The C++ special members which we are currently in the process of
6507 /// declaring. If this process recursively triggers the declaration of the
6508 /// same special member, we should act as if it is not yet declared.
6510
6512
6513 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6514
6517 ParsingClassDepth++;
6519 }
6521 ParsingClassDepth--;
6523 }
6524
6526 CXXScopeSpec &SS,
6527 ParsedType TemplateTypeTy,
6528 IdentifierInfo *MemberOrBase);
6529
6530private:
6531 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6532 QualType ResultTy,
6533 ArrayRef<QualType> Args);
6534 // Helper for ActOnFields to check for all function pointer members.
6535 bool EntirelyFunctionPointers(const RecordDecl *Record);
6536
6537 // A cache representing if we've fully checked the various comparison category
6538 // types stored in ASTContext. The bit-index corresponds to the integer value
6539 // of a ComparisonCategoryType enumerator.
6540 llvm::SmallBitVector FullyCheckedComparisonCategories;
6541
6542 /// Check if there is a field shadowing.
6543 void CheckShadowInheritedFields(const SourceLocation &Loc,
6544 DeclarationName FieldName,
6545 const CXXRecordDecl *RD,
6546 bool DeclIsField = true);
6547
6548 ///@}
6549
6550 //
6551 //
6552 // -------------------------------------------------------------------------
6553 //
6554 //
6555
6556 /// \name C++ Exception Specifications
6557 /// Implementations are in SemaExceptionSpec.cpp
6558 ///@{
6559
6560public:
6561 /// All the overriding functions seen during a class definition
6562 /// that had their exception spec checks delayed, plus the overridden
6563 /// function.
6566
6567 /// All the function redeclarations seen during a class definition that had
6568 /// their exception spec checks delayed, plus the prior declaration they
6569 /// should be checked against. Except during error recovery, the new decl
6570 /// should always be a friend declaration, as that's the only valid way to
6571 /// redeclare a special member before its class is complete.
6574
6575 /// Determine if we're in a case where we need to (incorrectly) eagerly
6576 /// parse an exception specification to work around a libstdc++ bug.
6578
6579 /// Check the given noexcept-specifier, convert its expression, and compute
6580 /// the appropriate ExceptionSpecificationType.
6581 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6583
6584 CanThrowResult canThrow(const Stmt *E);
6585 /// Determine whether the callee of a particular function call can throw.
6586 /// E, D and Loc are all optional.
6587 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6590 const FunctionProtoType *FPT);
6593
6594 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6595 /// exception specification. Incomplete types, or pointers to incomplete types
6596 /// other than void are not allowed.
6597 ///
6598 /// \param[in,out] T The exception type. This will be decayed to a pointer
6599 /// type
6600 /// when the input is an array or a function type.
6602
6603 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6604 /// pointer to member to a function with an exception specification. This
6605 /// means that it is invalid to add another level of indirection.
6608
6609 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6610 /// exception specifications. Exception specifications are equivalent if
6611 /// they allow exactly the same set of exception types. It does not matter how
6612 /// that is achieved. See C++ [except.spec]p2.
6614 SourceLocation OldLoc,
6615 const FunctionProtoType *New,
6616 SourceLocation NewLoc);
6618 const PartialDiagnostic &NoteID,
6619 const FunctionProtoType *Old,
6620 SourceLocation OldLoc,
6621 const FunctionProtoType *New,
6622 SourceLocation NewLoc);
6623 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6624
6625 /// CheckExceptionSpecSubset - Check whether the second function type's
6626 /// exception specification is a subset (or equivalent) of the first function
6627 /// type. This is used by override and pointer assignment checks.
6629 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6630 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6631 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6632 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6633 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6634
6635 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6636 /// two functions have equivalent exception specs. This is part of the
6637 /// assignment and override compatibility check. We do not check the
6638 /// parameters of parameter function pointers recursively, as no sane
6639 /// programmer would even be able to write such a function type.
6641 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6642 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6643 SourceLocation TargetLoc, const FunctionProtoType *Source,
6644 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6645
6646 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6647
6648 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6649 /// spec is a subset of base spec.
6651 const CXXMethodDecl *Old);
6652
6653 ///@}
6654
6655 //
6656 //
6657 // -------------------------------------------------------------------------
6658 //
6659 //
6660
6661 /// \name Expressions
6662 /// Implementations are in SemaExpr.cpp
6663 ///@{
6664
6665public:
6666 /// Describes how the expressions currently being parsed are
6667 /// evaluated at run-time, if at all.
6669 /// The current expression and its subexpressions occur within an
6670 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6671 /// \c sizeof, where the type of the expression may be significant but
6672 /// no code will be generated to evaluate the value of the expression at
6673 /// run time.
6675
6676 /// The current expression occurs within a braced-init-list within
6677 /// an unevaluated operand. This is mostly like a regular unevaluated
6678 /// context, except that we still instantiate constexpr functions that are
6679 /// referenced here so that we can perform narrowing checks correctly.
6681
6682 /// The current expression occurs within a discarded statement.
6683 /// This behaves largely similarly to an unevaluated operand in preventing
6684 /// definitions from being required, but not in other ways.
6686
6687 /// The current expression occurs within an unevaluated
6688 /// operand that unconditionally permits abstract references to
6689 /// fields, such as a SIZE operator in MS-style inline assembly.
6691
6692 /// The current context is "potentially evaluated" in C++11 terms,
6693 /// but the expression is evaluated at compile-time (like the values of
6694 /// cases in a switch statement).
6696
6697 /// In addition of being constant evaluated, the current expression
6698 /// occurs in an immediate function context - either a consteval function
6699 /// or a consteval if statement.
6701
6702 /// The current expression is potentially evaluated at run time,
6703 /// which means that code may be generated to evaluate the value of the
6704 /// expression at run time.
6706
6707 /// The current expression is potentially evaluated, but any
6708 /// declarations referenced inside that expression are only used if
6709 /// in fact the current expression is used.
6710 ///
6711 /// This value is used when parsing default function arguments, for which
6712 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6713 /// through varargs) but do not want to mark declarations as "referenced"
6714 /// until the default argument is used.
6716 };
6717
6718 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6719 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6720 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6721 /// have been applied to all subexpressions of the enclosing full expression.
6722 /// This is cleared at the end of each full expression.
6725
6726 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6727
6728 /// Data structure used to record current or nested
6729 /// expression evaluation contexts.
6731 /// The expression evaluation context.
6733
6734 /// Whether the enclosing context needed a cleanup.
6736
6737 /// The number of active cleanup objects when we entered
6738 /// this expression evaluation context.
6740
6742
6743 /// The lambdas that are present within this context, if it
6744 /// is indeed an unevaluated context.
6746
6747 /// The declaration that provides context for lambda expressions
6748 /// and block literals if the normal declaration context does not
6749 /// suffice, e.g., in a default function argument.
6751
6752 /// If we are processing a decltype type, a set of call expressions
6753 /// for which we have deferred checking the completeness of the return type.
6755
6756 /// If we are processing a decltype type, a set of temporary binding
6757 /// expressions for which we have deferred checking the destructor.
6759
6761
6762 /// Expressions appearing as the LHS of a volatile assignment in this
6763 /// context. We produce a warning for these when popping the context if
6764 /// they are not discarded-value expressions nor unevaluated operands.
6766
6767 /// Set of candidates for starting an immediate invocation.
6770
6771 /// Set of DeclRefExprs referencing a consteval function when used in a
6772 /// context not already known to be immediately invoked.
6774
6775 /// P2718R0 - Lifetime extension in range-based for loops.
6776 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6777 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6778 /// InLifetimeExtendingContext is true.
6780
6781 /// Small set of gathered accesses to potentially misaligned members
6782 /// due to the packed attribute.
6784
6785 /// \brief Describes whether we are in an expression constext which we have
6786 /// to handle differently.
6794
6795 // A context can be nested in both a discarded statement context and
6796 // an immediate function context, so they need to be tracked independently.
6800
6802
6803 // We are in a constant context, but we also allow
6804 // non constant expressions, for example for array bounds (which may be
6805 // VLAs).
6807
6808 /// Whether we are currently in a context in which all temporaries must be
6809 /// lifetime-extended, even if they're not bound to a reference (for
6810 /// example, in a for-range initializer).
6812
6813 /// Whether evaluating an expression for a switch case label.
6814 bool IsCaseExpr = false;
6815
6816 /// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
6818
6819 // When evaluating immediate functions in the initializer of a default
6820 // argument or default member initializer, this is the declaration whose
6821 // default initializer is being evaluated and the location of the call
6822 // or constructor definition.
6826 : Loc(Loc), Decl(Decl), Context(Context) {
6827 assert(Decl && Context && "invalid initialization context");
6828 }
6829
6831 ValueDecl *Decl = nullptr;
6833 };
6834 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6835
6846
6852
6859
6864
6869 // C++23 [expr.const]p14:
6870 // An expression or conversion is in an immediate function
6871 // context if it is potentially evaluated and either:
6872 // * its innermost enclosing non-block scope is a function
6873 // parameter scope of an immediate function, or
6874 // * its enclosing statement is enclosed by the compound-
6875 // statement of a consteval if statement.
6878 }
6879
6887 };
6888
6890 assert(!ExprEvalContexts.empty() &&
6891 "Must be in an expression evaluation context");
6892 return ExprEvalContexts.back();
6893 }
6894
6896 assert(!ExprEvalContexts.empty() &&
6897 "Must be in an expression evaluation context");
6898 return ExprEvalContexts.back();
6899 }
6900
6902 assert(ExprEvalContexts.size() >= 2 &&
6903 "Must be in an expression evaluation context");
6904 return ExprEvalContexts[ExprEvalContexts.size() - 2];
6905 }
6906
6908 return const_cast<Sema *>(this)->parentEvaluationContext();
6909 }
6910
6915
6916 /// Increment when we find a reference; decrement when we find an ignored
6917 /// assignment. Ultimately the value is 0 if every reference is an ignored
6918 /// assignment.
6919 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
6920
6921 /// Used to control the generation of ExprWithCleanups.
6923
6924 /// ExprCleanupObjects - This is the stack of objects requiring
6925 /// cleanup that are created by the current full expression.
6927
6928 /// Determine whether the use of this declaration is valid, without
6929 /// emitting diagnostics.
6930 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
6931 // A version of DiagnoseUseOfDecl that should be used if overload resolution
6932 // has been used to find this declaration, which means we don't have to bother
6933 // checking the trailing requires clause.
6935 return DiagnoseUseOfDecl(
6936 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
6937 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
6938 /*SkipTrailingRequiresClause=*/true);
6939 }
6940
6941 /// Determine whether the use of this declaration is valid, and
6942 /// emit any corresponding diagnostics.
6943 ///
6944 /// This routine diagnoses various problems with referencing
6945 /// declarations that can occur when using a declaration. For example,
6946 /// it might warn if a deprecated or unavailable declaration is being
6947 /// used, or produce an error (and return true) if a C++0x deleted
6948 /// function is being used.
6949 ///
6950 /// \returns true if there was an error (this declaration cannot be
6951 /// referenced), false otherwise.
6953 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
6954 bool ObjCPropertyAccess = false,
6955 bool AvoidPartialAvailabilityChecks = false,
6956 ObjCInterfaceDecl *ClassReciever = nullptr,
6957 bool SkipTrailingRequiresClause = false);
6958
6959 /// Emit a note explaining that this function is deleted.
6961
6962 /// DiagnoseSentinelCalls - This routine checks whether a call or
6963 /// message-send is to a declaration with the sentinel attribute, and
6964 /// if so, it checks that the requirements of the sentinel are
6965 /// satisfied.
6967 ArrayRef<Expr *> Args);
6968
6970 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
6973
6975 ExpressionEvaluationContext NewContext, FunctionDecl *FD);
6976
6979 ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
6983
6985
6989
6990 /// Check whether E, which is either a discarded-value expression or an
6991 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
6992 /// lvalue, and if so, remove it from the list of volatile-qualified
6993 /// assignments that we are going to warn are deprecated.
6995
6997
6998 // Functions for marking a declaration referenced. These functions also
6999 // contain the relevant logic for marking if a reference to a function or
7000 // variable is an odr-use (in the C++11 sense). There are separate variants
7001 // for expressions referring to a decl; these exist because odr-use marking
7002 // needs to be delayed for some constant variables when we build one of the
7003 // named expressions.
7004 //
7005 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
7006 // should usually be true. This only needs to be set to false if the lack of
7007 // odr-use cannot be determined from the current context (for instance,
7008 // because the name denotes a virtual function and was written without an
7009 // explicit nested-name-specifier).
7010 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
7011
7012 /// Mark a function referenced, and check whether it is odr-used
7013 /// (C++ [basic.def.odr]p2, C99 6.9p3)
7015 bool MightBeOdrUse = true);
7016
7017 /// Mark a variable referenced, and check whether it is odr-used
7018 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
7019 /// used directly for normal expressions referring to VarDecl.
7021
7022 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
7023 ///
7024 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
7025 /// be handled with care if the DeclRefExpr is not newly-created.
7026 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
7027
7028 /// Perform reference-marking and odr-use handling for a MemberExpr.
7030
7031 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
7034 unsigned CapturingScopeIndex);
7035
7037 void CleanupVarDeclMarking();
7038
7039 /// Try to capture the given variable.
7040 ///
7041 /// \param Var The variable to capture.
7042 ///
7043 /// \param Loc The location at which the capture occurs.
7044 ///
7045 /// \param Kind The kind of capture, which may be implicit (for either a
7046 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
7047 ///
7048 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
7049 /// an explicit lambda capture.
7050 ///
7051 /// \param BuildAndDiagnose Whether we are actually supposed to add the
7052 /// captures or diagnose errors. If false, this routine merely check whether
7053 /// the capture can occur without performing the capture itself or complaining
7054 /// if the variable cannot be captured.
7055 ///
7056 /// \param CaptureType Will be set to the type of the field used to capture
7057 /// this variable in the innermost block or lambda. Only valid when the
7058 /// variable can be captured.
7059 ///
7060 /// \param DeclRefType Will be set to the type of a reference to the capture
7061 /// from within the current scope. Only valid when the variable can be
7062 /// captured.
7063 ///
7064 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
7065 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
7066 /// This is useful when enclosing lambdas must speculatively capture
7067 /// variables that may or may not be used in certain specializations of
7068 /// a nested generic lambda.
7069 ///
7070 /// \returns true if an error occurred (i.e., the variable cannot be
7071 /// captured) and false if the capture succeeded.
7073 TryCaptureKind Kind, SourceLocation EllipsisLoc,
7074 bool BuildAndDiagnose, QualType &CaptureType,
7075 QualType &DeclRefType,
7076 const unsigned *const FunctionScopeIndexToStopAt);
7077
7078 /// Try to capture the given variable.
7081 SourceLocation EllipsisLoc = SourceLocation());
7082
7083 /// Checks if the variable must be captured.
7085
7086 /// Given a variable, determine the type that a reference to that
7087 /// variable will have in the given scope.
7089
7090 /// Mark all of the declarations referenced within a particular AST node as
7091 /// referenced. Used when template instantiation instantiates a non-dependent
7092 /// type -- entities referenced by the type are now referenced.
7094
7095 /// Mark any declarations that appear within this expression or any
7096 /// potentially-evaluated subexpressions as "referenced".
7097 ///
7098 /// \param SkipLocalVariables If true, don't mark local variables as
7099 /// 'referenced'.
7100 /// \param StopAt Subexpressions that we shouldn't recurse into.
7102 bool SkipLocalVariables = false,
7103 ArrayRef<const Expr *> StopAt = {});
7104
7105 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
7106 /// conversion.
7107 ExprResult tryConvertExprToType(Expr *E, QualType Ty);
7108
7109 /// Conditionally issue a diagnostic based on the statements's reachability
7110 /// analysis.
7111 ///
7112 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
7113 /// the function body is parsed, and then do a basic reachability analysis to
7114 /// determine if the statement is reachable. If it is unreachable, the
7115 /// diagnostic will not be emitted.
7116 bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7117 const PartialDiagnostic &PD);
7118
7119 /// Conditionally issue a diagnostic based on the current
7120 /// evaluation context.
7121 ///
7122 /// \param Statement If Statement is non-null, delay reporting the
7123 /// diagnostic until the function body is parsed, and then do a basic
7124 /// reachability analysis to determine if the statement is reachable.
7125 /// If it is unreachable, the diagnostic will not be emitted.
7126 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
7127 const PartialDiagnostic &PD);
7128 /// Similar, but diagnostic is only produced if all the specified statements
7129 /// are reachable.
7130 bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
7131 const PartialDiagnostic &PD);
7132
7133 // Primary Expressions.
7134 SourceRange getExprRange(Expr *E) const;
7135
7136 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
7137 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
7138 bool HasTrailingLParen, bool IsAddressOfOperand,
7139 CorrectionCandidateCallback *CCC = nullptr,
7140 bool IsInlineAsmIdentifier = false,
7141 Token *KeywordReplacement = nullptr);
7142
7143 /// Decomposes the given name into a DeclarationNameInfo, its location, and
7144 /// possibly a list of template arguments.
7145 ///
7146 /// If this produces template arguments, it is permitted to call
7147 /// DecomposeTemplateName.
7148 ///
7149 /// This actually loses a lot of source location information for
7150 /// non-standard name kinds; we should consider preserving that in
7151 /// some way.
7152 void DecomposeUnqualifiedId(const UnqualifiedId &Id,
7153 TemplateArgumentListInfo &Buffer,
7154 DeclarationNameInfo &NameInfo,
7155 const TemplateArgumentListInfo *&TemplateArgs);
7156
7157 /// Diagnose a lookup that found results in an enclosing class during error
7158 /// recovery. This usually indicates that the results were found in a
7159 /// dependent base class that could not be searched as part of a template
7160 /// definition. Always issues a diagnostic (though this may be only a warning
7161 /// in MS compatibility mode).
7162 ///
7163 /// Return \c true if the error is unrecoverable, or \c false if the caller
7164 /// should attempt to recover using these lookup results.
7165 bool DiagnoseDependentMemberLookup(const LookupResult &R);
7166
7167 /// Diagnose an empty lookup.
7168 ///
7169 /// \return false if new lookup candidates were found
7170 bool
7171 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
7172 CorrectionCandidateCallback &CCC,
7173 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
7174 ArrayRef<Expr *> Args = {},
7175 DeclContext *LookupCtx = nullptr);
7176
7177 /// If \p D cannot be odr-used in the current expression evaluation context,
7178 /// return a reason explaining why. Otherwise, return NOUR_None.
7180
7181 DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7182 SourceLocation Loc,
7183 const CXXScopeSpec *SS = nullptr);
7184 DeclRefExpr *
7185 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7186 const DeclarationNameInfo &NameInfo,
7187 const CXXScopeSpec *SS = nullptr,
7188 NamedDecl *FoundD = nullptr,
7189 SourceLocation TemplateKWLoc = SourceLocation(),
7190 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7191
7192 /// BuildDeclRefExpr - Build an expression that references a
7193 /// declaration that does not require a closure capture.
7194 DeclRefExpr *
7195 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
7196 const DeclarationNameInfo &NameInfo,
7197 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
7198 SourceLocation TemplateKWLoc = SourceLocation(),
7199 const TemplateArgumentListInfo *TemplateArgs = nullptr);
7200
7201 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
7202 bool HasTrailingLParen);
7203
7204 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
7205 /// declaration name, generally during template instantiation.
7206 /// There's a large number of things which don't need to be done along
7207 /// this path.
7209 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
7210 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
7211
7212 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
7213 bool NeedsADL,
7214 bool AcceptInvalidDecl = false);
7215
7216 /// Complete semantic analysis for a reference to the given declaration.
7218 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
7219 NamedDecl *FoundD = nullptr,
7220 const TemplateArgumentListInfo *TemplateArgs = nullptr,
7221 bool AcceptInvalidDecl = false);
7222
7223 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
7224 // where Tokens representing function local predefined macros (such as
7225 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
7226 std::vector<Token> ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks);
7227
7228 ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK);
7229 ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
7230 ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
7231
7232 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
7233
7234 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
7236 Scope *UDLScope = nullptr);
7237 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
7238 ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
7239 MultiExprArg Val);
7240 ExprResult ActOnCXXParenListInitExpr(ArrayRef<Expr *> Args, QualType T,
7241 unsigned NumUserSpecifiedExprs,
7242 SourceLocation InitLoc,
7243 SourceLocation LParenLoc,
7244 SourceLocation RParenLoc);
7245
7246 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
7247 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
7248 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
7249 /// from multiple tokens. However, the common case is that StringToks points
7250 /// to one string.
7251 ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
7252 Scope *UDLScope = nullptr);
7253
7254 ExprResult ActOnUnevaluatedStringLiteral(ArrayRef<Token> StringToks);
7255
7256 /// ControllingExprOrType is either an opaque pointer coming out of a
7257 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
7258 /// into two so we don't take a void *, but that's awkward because one of
7259 /// the operands is either a ParsedType or an Expr *, which doesn't lend
7260 /// itself to generic code very well.
7261 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
7262 SourceLocation DefaultLoc,
7263 SourceLocation RParenLoc,
7264 bool PredicateIsExpr,
7265 void *ControllingExprOrType,
7266 ArrayRef<ParsedType> ArgTypes,
7267 ArrayRef<Expr *> ArgExprs);
7268 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
7269 /// it'd be better to split this interface into two so we don't take a
7270 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
7271 /// isn't a trivial change.
7272 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
7273 SourceLocation DefaultLoc,
7274 SourceLocation RParenLoc,
7275 bool PredicateIsExpr,
7276 void *ControllingExprOrType,
7277 ArrayRef<TypeSourceInfo *> Types,
7278 ArrayRef<Expr *> Exprs);
7279
7280 // Binary/Unary Operators. 'Tok' is the token for the operator.
7281 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
7282 Expr *InputExpr, bool IsAfterAmp = false);
7283 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc,
7284 Expr *Input, bool IsAfterAmp = false);
7285
7286 /// Unary Operators. 'Tok' is the token for the operator.
7287 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op,
7288 Expr *Input, bool IsAfterAmp = false);
7289
7290 /// Determine whether the given expression is a qualified member
7291 /// access expression, of a form that could be turned into a pointer to member
7292 /// with the address-of operator.
7293 bool isQualifiedMemberAccess(Expr *E);
7294 bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
7295 const Expr *Op,
7296 const CXXMethodDecl *MD);
7297
7298 /// CheckAddressOfOperand - The operand of & must be either a function
7299 /// designator or an lvalue designating an object. If it is an lvalue, the
7300 /// object cannot be declared with storage class register or be a bit field.
7301 /// Note: The usual conversions are *not* applied to the operand of the &
7302 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
7303 /// In C++, the operand might be an overloaded function name, in which case
7304 /// we allow the '&' but retain the overloaded-function type.
7305 QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
7306
7307 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
7308 /// _Alignas(type-name) .
7309 /// [dcl.align] An alignment-specifier of the form
7310 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
7311 ///
7312 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
7313 /// _Alignas(_Alignof(type-name)).
7314 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
7315 SourceLocation OpLoc, SourceRange R);
7316 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
7317 SourceLocation OpLoc, SourceRange R);
7318
7319 /// Build a sizeof or alignof expression given a type operand.
7320 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
7321 SourceLocation OpLoc,
7322 UnaryExprOrTypeTrait ExprKind,
7323 SourceRange R);
7324
7325 /// Build a sizeof or alignof expression given an expression
7326 /// operand.
7327 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
7328 UnaryExprOrTypeTrait ExprKind);
7329
7330 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
7331 /// expr and the same for @c alignof and @c __alignof
7332 /// Note that the ArgRange is invalid if isType is false.
7333 ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
7334 UnaryExprOrTypeTrait ExprKind,
7335 bool IsType, void *TyOrEx,
7336 SourceRange ArgRange);
7337
7338 /// Check for operands with placeholder types and complain if found.
7339 /// Returns ExprError() if there was an error and no recovery was possible.
7341 bool CheckVecStepExpr(Expr *E);
7342
7343 /// Check the constraints on expression operands to unary type expression
7344 /// and type traits.
7345 ///
7346 /// Completes any types necessary and validates the constraints on the operand
7347 /// expression. The logic mostly mirrors the type-based overload, but may
7348 /// modify the expression as it completes the type for that expression through
7349 /// template instantiation, etc.
7351
7352 /// Check the constraints on operands to unary expression and type
7353 /// traits.
7354 ///
7355 /// This will complete any types necessary, and validate the various
7356 /// constraints on those operands.
7357 ///
7358 /// The UsualUnaryConversions() function is *not* called by this routine.
7359 /// C99 6.3.2.1p[2-4] all state:
7360 /// Except when it is the operand of the sizeof operator ...
7361 ///
7362 /// C++ [expr.sizeof]p4
7363 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
7364 /// standard conversions are not applied to the operand of sizeof.
7365 ///
7366 /// This policy is followed for all of the unary trait expressions.
7367 bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
7368 SourceRange ExprRange,
7369 UnaryExprOrTypeTrait ExprKind,
7370 StringRef KWName);
7371
7372 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
7373 tok::TokenKind Kind, Expr *Input);
7374
7375 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
7376 MultiExprArg ArgExprs,
7377 SourceLocation RLoc);
7378 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
7379 Expr *Idx, SourceLocation RLoc);
7380
7381 ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx,
7382 Expr *ColumnIdx,
7383 SourceLocation RBLoc);
7384
7385 /// ConvertArgumentsForCall - Converts the arguments specified in
7386 /// Args/NumArgs to the parameter types of the function FDecl with
7387 /// function prototype Proto. Call is the call expression itself, and
7388 /// Fn is the function expression. For a C++ member function, this
7389 /// routine does not attempt to convert the object argument. Returns
7390 /// true if the call is ill-formed.
7391 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl,
7392 const FunctionProtoType *Proto,
7393 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
7394 bool ExecConfig = false);
7395
7396 /// CheckStaticArrayArgument - If the given argument corresponds to a static
7397 /// array parameter, check that it is non-null, and that if it is formed by
7398 /// array-to-pointer decay, the underlying array is sufficiently large.
7399 ///
7400 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
7401 /// the array type derivation, then for each call to the function, the value
7402 /// of the corresponding actual argument shall provide access to the first
7403 /// element of an array with at least as many elements as specified by the
7404 /// size expression.
7405 void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
7406 const Expr *ArgExpr);
7407
7408 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
7409 /// This provides the location of the left/right parens and a list of comma
7410 /// locations.
7411 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7412 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7413 Expr *ExecConfig = nullptr);
7414
7415 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
7416 /// This provides the location of the left/right parens and a list of comma
7417 /// locations.
7418 ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
7419 MultiExprArg ArgExprs, SourceLocation RParenLoc,
7420 Expr *ExecConfig = nullptr,
7421 bool IsExecConfig = false,
7422 bool AllowRecovery = false);
7423
7424 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
7425 // with the specified CallArgs
7426 Expr *BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id,
7427 MultiExprArg CallArgs);
7428
7430
7431 /// BuildResolvedCallExpr - Build a call to a resolved expression,
7432 /// i.e. an expression not of \p OverloadTy. The expression should
7433 /// unary-convert to an expression of function-pointer or
7434 /// block-pointer type.
7435 ///
7436 /// \param NDecl the declaration being called, if available
7438 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
7439 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
7440 Expr *Config = nullptr, bool IsExecConfig = false,
7441 ADLCallKind UsesADL = ADLCallKind::NotADL);
7442
7444 ParsedType &Ty, SourceLocation RParenLoc,
7445 Expr *CastExpr);
7446
7447 /// Prepares for a scalar cast, performing all the necessary stages
7448 /// except the final cast and returning the kind required.
7450
7451 /// Build an altivec or OpenCL literal.
7453 SourceLocation RParenLoc, Expr *E,
7454 TypeSourceInfo *TInfo);
7455
7456 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7457 /// the ParenListExpr into a sequence of comma binary operators.
7459
7461 SourceLocation RParenLoc, Expr *InitExpr);
7462
7464 TypeSourceInfo *TInfo,
7465 SourceLocation RParenLoc,
7466 Expr *LiteralExpr);
7467
7468 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7469 SourceLocation RBraceLoc);
7470
7471 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7472 SourceLocation RBraceLoc);
7473
7474 /// Binary Operators. 'Tok' is the token for the operator.
7476 Expr *LHSExpr, Expr *RHSExpr);
7478 Expr *LHSExpr, Expr *RHSExpr,
7479 bool ForFoldExpression = false);
7480
7481 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7482 /// operator @p Opc at location @c TokLoc. This routine only supports
7483 /// built-in operations; ActOnBinOp handles overloaded operators.
7485 Expr *LHSExpr, Expr *RHSExpr,
7486 bool ForFoldExpression = false);
7488 UnresolvedSetImpl &Functions);
7489
7490 /// Look for instances where it is likely the comma operator is confused with
7491 /// another operator. There is an explicit list of acceptable expressions for
7492 /// the left hand side of the comma operator, otherwise emit a warning.
7493 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7494
7495 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7496 /// in the case of a the GNU conditional expr extension.
7498 SourceLocation ColonLoc, Expr *CondExpr,
7499 Expr *LHSExpr, Expr *RHSExpr);
7500
7501 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7503 LabelDecl *TheDecl);
7504
7505 void ActOnStartStmtExpr();
7506 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7507 SourceLocation RPLoc);
7509 SourceLocation RPLoc, unsigned TemplateDepth);
7510 // Handle the final expression in a statement expression.
7512 void ActOnStmtExprError();
7513
7514 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
7517 bool isBrackets; // true if [expr], false if .ident
7518 union {
7521 } U;
7522 };
7523
7524 /// __builtin_offsetof(type, a.b[123][456].c)
7526 TypeSourceInfo *TInfo,
7527 ArrayRef<OffsetOfComponent> Components,
7528 SourceLocation RParenLoc);
7531 ParsedType ParsedArgTy,
7532 ArrayRef<OffsetOfComponent> Components,
7533 SourceLocation RParenLoc);
7534
7535 // __builtin_choose_expr(constExpr, expr1, expr2)
7536 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7537 Expr *LHSExpr, Expr *RHSExpr,
7538 SourceLocation RPLoc);
7539
7540 // __builtin_va_arg(expr, type)
7542 SourceLocation RPLoc);
7544 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7545
7546 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7547 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7549 SourceLocation BuiltinLoc,
7550 SourceLocation RPLoc);
7551
7552 // #embed
7554 StringLiteral *BinaryData, StringRef FileName);
7555
7556 // Build a potentially resolved SourceLocExpr.
7558 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7559 DeclContext *ParentContext);
7560
7561 // __null
7563
7564 bool CheckCaseExpression(Expr *E);
7565
7566 //===------------------------- "Block" Extension ------------------------===//
7567
7568 /// ActOnBlockStart - This callback is invoked when a block literal is
7569 /// started.
7570 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7571
7572 /// ActOnBlockArguments - This callback allows processing of block arguments.
7573 /// If there are no arguments, this is still invoked.
7574 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7575 Scope *CurScope);
7576
7577 /// ActOnBlockError - If there is an error parsing a block, this callback
7578 /// is invoked to pop the information about the block from the action impl.
7579 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7580
7581 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7582 /// literal was successfully completed. ^(int x){...}
7584 Scope *CurScope);
7585
7586 //===---------------------------- Clang Extensions ----------------------===//
7587
7588 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7589 /// provided arguments.
7590 ///
7591 /// __builtin_convertvector( value, dst type )
7592 ///
7594 SourceLocation BuiltinLoc,
7595 SourceLocation RParenLoc);
7596
7597 //===---------------------------- OpenCL Features -----------------------===//
7598
7599 /// Parse a __builtin_astype expression.
7600 ///
7601 /// __builtin_astype( value, dst type )
7602 ///
7603 ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy,
7604 SourceLocation BuiltinLoc,
7605 SourceLocation RParenLoc);
7606
7607 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7609 SourceLocation BuiltinLoc,
7610 SourceLocation RParenLoc);
7611
7612 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7614 ArrayRef<Expr *> SubExprs,
7615 QualType T = QualType());
7616
7617 /// Cast a base object to a member's actual type.
7618 ///
7619 /// There are two relevant checks:
7620 ///
7621 /// C++ [class.access.base]p7:
7622 ///
7623 /// If a class member access operator [...] is used to access a non-static
7624 /// data member or non-static member function, the reference is ill-formed
7625 /// if the left operand [...] cannot be implicitly converted to a pointer to
7626 /// the naming class of the right operand.
7627 ///
7628 /// C++ [expr.ref]p7:
7629 ///
7630 /// If E2 is a non-static data member or a non-static member function, the
7631 /// program is ill-formed if the class of which E2 is directly a member is
7632 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7633 ///
7634 /// Note that the latter check does not consider access; the access of the
7635 /// "real" base class is checked as appropriate when checking the access of
7636 /// the member name.
7638 NestedNameSpecifier Qualifier,
7639 NamedDecl *FoundDecl,
7640 NamedDecl *Member);
7641
7642 /// CheckCallReturnType - Checks that a call expression's return type is
7643 /// complete. Returns true on failure. The location passed in is the location
7644 /// that best represents the call.
7645 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
7646 CallExpr *CE, FunctionDecl *FD);
7647
7648 /// Emit a warning for all pending noderef expressions that we recorded.
7649 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
7650
7652
7653 /// Instantiate or parse a C++ default argument expression as necessary.
7654 /// Return true on error.
7656 ParmVarDecl *Param, Expr *Init = nullptr,
7657 bool SkipImmediateInvocations = true);
7658
7659 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7660 /// the default expr if needed.
7662 ParmVarDecl *Param, Expr *Init = nullptr);
7663
7664 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7665 /// invocation.
7667
7669
7670 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7671 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7672
7673 /// Abstract base class used for diagnosing integer constant
7674 /// expression violations.
7676 public:
7678
7680
7681 virtual SemaDiagnosticBuilder
7682 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7684 SourceLocation Loc) = 0;
7687 };
7688
7689 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7690 /// and reports the appropriate diagnostics. Returns false on success.
7691 /// Can optionally return the value of the expression.
7694 VerifyICEDiagnoser &Diagnoser,
7698 unsigned DiagID,
7701 VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result = nullptr,
7705 AllowFoldKind CanFold = AllowFoldKind::No) {
7706 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7707 }
7708
7709 /// DiagnoseAssignmentAsCondition - Given that an expression is
7710 /// being used as a boolean condition, warn if it's an assignment.
7712
7713 /// Redundant parentheses over an equality comparison can indicate
7714 /// that the user intended an assignment used as condition.
7716
7718 public:
7720 FullExprArg(Sema &actions) : E(nullptr) {}
7721
7722 ExprResult release() { return E; }
7723
7724 Expr *get() const { return E; }
7725
7726 Expr *operator->() { return E; }
7727
7728 private:
7729 // FIXME: No need to make the entire Sema class a friend when it's just
7730 // Sema::MakeFullExpr that needs access to the constructor below.
7731 friend class Sema;
7732
7733 explicit FullExprArg(Expr *expr) : E(expr) {}
7734
7735 Expr *E;
7736 };
7737
7739 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7740 }
7742 return FullExprArg(
7743 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7744 }
7746 ExprResult FE =
7747 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7748 /*DiscardedValue*/ true);
7749 return FullExprArg(FE.get());
7750 }
7751
7752 class ConditionResult {
7753 Decl *ConditionVar;
7754 ExprResult Condition;
7755 bool Invalid;
7756 std::optional<bool> KnownValue;
7757
7758 friend class Sema;
7759 ConditionResult(Sema &S, Decl *ConditionVar, ExprResult Condition,
7760 bool IsConstexpr)
7761 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7762 if (IsConstexpr && Condition.get()) {
7763 if (std::optional<llvm::APSInt> Val =
7764 Condition.get()->getIntegerConstantExpr(S.Context)) {
7765 KnownValue = !!(*Val);
7766 }
7767 }
7768 }
7769 explicit ConditionResult(bool Invalid)
7770 : ConditionVar(nullptr), Condition(Invalid), Invalid(Invalid),
7771 KnownValue(std::nullopt) {}
7772
7773 public:
7774 ConditionResult() : ConditionResult(false) {}
7775 bool isInvalid() const { return Invalid; }
7776 std::pair<VarDecl *, Expr *> get() const {
7777 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7778 Condition.get());
7779 }
7780 std::optional<bool> getKnownValue() const { return KnownValue; }
7781 };
7783
7784 /// CheckBooleanCondition - Diagnose problems involving the use of
7785 /// the given expression as a boolean condition (e.g. in an if
7786 /// statement). Also performs the standard function and array
7787 /// decays, possibly changing the input variable.
7788 ///
7789 /// \param Loc - A location associated with the condition, e.g. the
7790 /// 'if' keyword.
7791 /// \return true iff there were any errors
7793 bool IsConstexpr = false);
7794
7795 enum class ConditionKind {
7796 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7797 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7798 Switch ///< An integral condition for a 'switch' statement.
7799 };
7800
7801 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7802 ConditionKind CK, bool MissingOK = false);
7803
7804 QualType CheckConditionalOperands( // C99 6.5.15
7806 ExprObjectKind &OK, SourceLocation QuestionLoc);
7807
7808 /// Emit a specialized diagnostic when one expression is a null pointer
7809 /// constant and the other is not a pointer. Returns true if a diagnostic is
7810 /// emitted.
7811 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7812 SourceLocation QuestionLoc);
7813
7814 /// type checking for vector binary operators.
7816 SourceLocation Loc, bool IsCompAssign,
7817 bool AllowBothBool, bool AllowBoolConversion,
7818 bool AllowBoolOperation, bool ReportInvalid);
7819
7820 /// Return a signed ext_vector_type that is of identical size and number of
7821 /// elements. For floating point vectors, return an integer type of identical
7822 /// size and number of elements. In the non ext_vector_type case, search from
7823 /// the largest type to the smallest type to avoid cases where long long ==
7824 /// long, where long gets picked over long long.
7827
7828 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7829 /// operates on extended vector types. Instead of producing an IntTy result,
7830 /// like a scalar comparison, a vector comparison produces a vector of integer
7831 /// types.
7833 SourceLocation Loc,
7834 BinaryOperatorKind Opc);
7836 SourceLocation Loc,
7837 BinaryOperatorKind Opc);
7839 SourceLocation Loc,
7840 BinaryOperatorKind Opc);
7841
7842 // type checking for sizeless vector binary operators.
7844 SourceLocation Loc, bool IsCompAssign,
7845 ArithConvKind OperationKind);
7846
7847 /// Type checking for matrix binary operators.
7849 SourceLocation Loc,
7850 bool IsCompAssign);
7852 SourceLocation Loc, bool IsCompAssign);
7853
7854 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
7855 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
7856 /// VLST) allowed?
7857 ///
7858 /// This will also return false if the two given types do not make sense from
7859 /// the perspective of SVE bitcasts.
7860 bool isValidSveBitcast(QualType srcType, QualType destType);
7861
7862 /// Are the two types matrix types and do they have the same dimensions i.e.
7863 /// do they have the same number of rows and the same number of columns?
7865
7866 bool areVectorTypesSameSize(QualType srcType, QualType destType);
7867
7868 /// Are the two types lax-compatible vector types? That is, given
7869 /// that one of them is a vector, do they have equal storage sizes,
7870 /// where the storage size is the number of elements times the element
7871 /// size?
7872 ///
7873 /// This will also return false if either of the types is neither a
7874 /// vector nor a real type.
7875 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
7876
7877 /// Is this a legal conversion between two types, one of which is
7878 /// known to be a vector type?
7879 bool isLaxVectorConversion(QualType srcType, QualType destType);
7880
7881 // This returns true if at least one of the types is an altivec vector.
7882 bool anyAltivecTypes(QualType srcType, QualType destType);
7883
7884 // type checking C++ declaration initializers (C++ [dcl.init]).
7885
7886 /// Check a cast of an unknown-any type. We intentionally only
7887 /// trigger this for C-style casts.
7890 ExprValueKind &VK, CXXCastPath &Path);
7891
7892 /// Force an expression with unknown-type to an expression of the
7893 /// given type.
7895
7896 /// Type-check an expression that's being passed to an
7897 /// __unknown_anytype parameter.
7899 QualType &paramType);
7900
7901 // CheckMatrixCast - Check type constraints for matrix casts.
7902 // We allow casting between matrixes of the same dimensions i.e. when they
7903 // have the same number of rows and column. Returns true if the cast is
7904 // invalid.
7905 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
7906 CastKind &Kind);
7907
7908 // CheckVectorCast - check type constraints for vectors.
7909 // Since vectors are an extension, there are no C standard reference for this.
7910 // We allow casting between vectors and integer datatypes of the same size.
7911 // returns true if the cast is invalid
7912 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
7913 CastKind &Kind);
7914
7915 /// Prepare `SplattedExpr` for a vector splat operation, adding
7916 /// implicit casts if necessary.
7917 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
7918
7919 // CheckExtVectorCast - check type constraints for extended vectors.
7920 // Since vectors are an extension, there are no C standard reference for this.
7921 // We allow casting between vectors and integer datatypes of the same size,
7922 // or vectors and the element type of that vector.
7923 // returns the cast expr
7925 CastKind &Kind);
7926
7928 return K == ConditionKind::Switch ? Context.IntTy : Context.BoolTy;
7929 }
7930
7931 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2), converts
7932 // functions and arrays to their respective pointers (C99 6.3.2.1), and
7933 // promotes floating-piont types according to the language semantics.
7935
7936 // UsualUnaryFPConversions - promotes floating-point types according to the
7937 // current language semantics.
7939
7940 /// CallExprUnaryConversions - a special case of an unary conversion
7941 /// performed on a function designator of a call expression.
7943
7944 // DefaultFunctionArrayConversion - converts functions and arrays
7945 // to their respective pointers (C99 6.3.2.1).
7947
7948 // DefaultFunctionArrayLvalueConversion - converts functions and
7949 // arrays to their respective pointers and performs the
7950 // lvalue-to-rvalue conversion.
7952 bool Diagnose = true);
7953
7954 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
7955 // the operand. This function is a no-op if the operand has a function type
7956 // or an array type.
7958
7959 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
7960 // do not have a prototype. Integer promotions are performed on each
7961 // argument, and arguments that have type float are promoted to double.
7963
7965 const FunctionProtoType *Proto,
7966 Expr *Fn);
7967
7968 /// Determine the degree of POD-ness for an expression.
7969 /// Incomplete types are considered POD, since this check can be performed
7970 /// when we're in an unevaluated context.
7972
7973 /// Check to see if the given expression is a valid argument to a variadic
7974 /// function, issuing a diagnostic if not.
7975 void checkVariadicArgument(const Expr *E, VariadicCallType CT);
7976
7977 /// GatherArgumentsForCall - Collector argument expressions for various
7978 /// form of call prototypes.
7980 SourceLocation CallLoc, FunctionDecl *FDecl,
7981 const FunctionProtoType *Proto, unsigned FirstParam,
7984 bool AllowExplicit = false, bool IsListInitialization = false);
7985
7986 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
7987 // will create a runtime trap if the resulting type is not a POD type.
7989 FunctionDecl *FDecl);
7990
7991 // Check that the usual arithmetic conversions can be performed on this pair
7992 // of expressions that might be of enumeration type.
7994 ArithConvKind ACK);
7995
7996 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
7997 // operands and then handles various conversions that are common to binary
7998 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
7999 // routine returns the first non-arithmetic type found. The client is
8000 // responsible for emitting appropriate error diagnostics.
8002 SourceLocation Loc, ArithConvKind ACK);
8003
8005 switch (ConvTy) {
8006 default:
8007 return false;
8011 return true;
8012 }
8013 llvm_unreachable("impossible");
8014 }
8015
8016 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
8017 /// assignment conversion type specified by ConvTy. This returns true if the
8018 /// conversion was invalid or false if the conversion was accepted.
8020 QualType DstType, QualType SrcType,
8021 Expr *SrcExpr, AssignmentAction Action,
8022 bool *Complained = nullptr);
8023
8024 /// CheckAssignmentConstraints - Perform type checking for assignment,
8025 /// argument passing, variable initialization, and function return values.
8026 /// C99 6.5.16.
8028 QualType LHSType,
8029 QualType RHSType);
8030
8031 /// Check assignment constraints and optionally prepare for a conversion of
8032 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
8033 /// is true.
8035 ExprResult &RHS, CastKind &Kind,
8036 bool ConvertRHS = true);
8037
8038 /// Check assignment constraints for an assignment of RHS to LHSType.
8039 ///
8040 /// \param LHSType The destination type for the assignment.
8041 /// \param RHS The source expression for the assignment.
8042 /// \param Diagnose If \c true, diagnostics may be produced when checking
8043 /// for assignability. If a diagnostic is produced, \p RHS will be
8044 /// set to ExprError(). Note that this function may still return
8045 /// without producing a diagnostic, even for an invalid assignment.
8046 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
8047 /// in an audited Core Foundation API and does not need to be checked
8048 /// for ARC retain issues.
8049 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
8050 /// conversions necessary to perform the assignment. If \c false,
8051 /// \p Diagnose must also be \c false.
8053 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
8054 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
8055
8056 // If the lhs type is a transparent union, check whether we
8057 // can initialize the transparent union with the given expression.
8059 ExprResult &RHS);
8060
8061 /// the following "Check" methods will return a valid/converted QualType
8062 /// or a null QualType (indicating an error diagnostic was issued).
8063
8064 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
8066 ExprResult &RHS);
8067
8068 /// Diagnose cases where a scalar was implicitly converted to a vector and
8069 /// diagnose the underlying types. Otherwise, diagnose the error
8070 /// as invalid vector logical operands for non-C++ cases.
8072 ExprResult &RHS);
8073
8075 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8076 BinaryOperatorKind Opc);
8077 QualType CheckRemainderOperands( // C99 6.5.5
8078 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8079 bool IsCompAssign = false);
8080 QualType CheckAdditionOperands( // C99 6.5.6
8081 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8082 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8084 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8085 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
8086 QualType CheckShiftOperands( // C99 6.5.7
8087 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8088 BinaryOperatorKind Opc, bool IsCompAssign = false);
8090 QualType CheckCompareOperands( // C99 6.5.8/9
8091 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8092 BinaryOperatorKind Opc);
8093 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
8094 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8095 BinaryOperatorKind Opc);
8096 QualType CheckLogicalOperands( // C99 6.5.[13,14]
8097 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
8098 BinaryOperatorKind Opc);
8099 // CheckAssignmentOperands is used for both simple and compound assignment.
8100 // For simple assignment, pass both expressions and a null converted type.
8101 // For compound assignment, pass both expressions and the converted type.
8102 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
8103 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
8104 BinaryOperatorKind Opc);
8105
8106 /// To be used for checking whether the arguments being passed to
8107 /// function exceeds the number of parameters expected for it.
8108 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
8109 bool PartialOverloading = false) {
8110 // We check whether we're just after a comma in code-completion.
8111 if (NumArgs > 0 && PartialOverloading)
8112 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
8113 return NumArgs > NumParams;
8114 }
8115
8116 /// Whether the AST is currently being rebuilt to correct immediate
8117 /// invocations. Immediate invocation candidates and references to consteval
8118 /// functions aren't tracked when this is set.
8120
8126
8127 /// Determines whether we are currently in a context that
8128 /// is not evaluated as per C++ [expr] p5.
8131 }
8132
8136
8140
8144
8151
8152 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8154 assert(!ExprEvalContexts.empty() &&
8155 "Must be in an expression evaluation context");
8156 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8158 Ctx.DelayedDefaultInitializationContext)
8159 return Ctx.DelayedDefaultInitializationContext;
8160 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8161 Ctx.isUnevaluated())
8162 break;
8163 }
8164 return std::nullopt;
8165 }
8166
8167 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
8169 assert(!ExprEvalContexts.empty() &&
8170 "Must be in an expression evaluation context");
8171 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
8172 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
8174 !Ctx.DelayedDefaultInitializationContext && Res)
8175 break;
8176 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
8177 Ctx.isUnevaluated())
8178 break;
8179 Res = Ctx.DelayedDefaultInitializationContext;
8180 }
8181 return Res;
8182 }
8183
8187
8188 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
8189 /// SelfAssigned when inside a CXXMethodDecl.
8190 const FieldDecl *
8192
8194
8195 template <typename... Ts>
8197 const Ts &...Args) {
8198 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8199 return RequireCompleteType(Loc, T, CompleteTypeKind::Normal, Diagnoser);
8200 }
8201
8202 template <typename... Ts>
8203 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
8204 const Ts &...Args) {
8205 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
8207 }
8208
8209 /// Abstract class used to diagnose incomplete types.
8212
8213 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
8214 virtual ~TypeDiagnoser() {}
8215 };
8216
8217 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
8218 protected:
8219 unsigned DiagID;
8220 std::tuple<const Ts &...> Args;
8221
8222 template <std::size_t... Is>
8224 std::index_sequence<Is...>) const {
8225 // Apply all tuple elements to the builder in order.
8226 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
8227 (void)Dummy;
8228 }
8229
8230 public:
8231 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8232 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
8233 assert(DiagID != 0 && "no diagnostic for type diagnoser");
8234 }
8235
8236 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8237 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
8238 emit(DB, std::index_sequence_for<Ts...>());
8239 DB << T;
8240 }
8241 };
8242
8243 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
8244 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
8245 /// For example, a diagnostic with no other parameters would generally have
8246 /// the form "...%select{incomplete|sizeless}0 type %1...".
8247 template <typename... Ts>
8249 public:
8250 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
8251 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
8252
8253 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
8254 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
8255 this->emit(DB, std::index_sequence_for<Ts...>());
8256 DB << T->isSizelessType() << T;
8257 }
8258 };
8259
8260 /// Check an argument list for placeholders that we won't try to
8261 /// handle later.
8263
8264 /// The C++ "std::source_location::__impl" struct, defined in
8265 /// <source_location>.
8267
8268 /// A stack of expression evaluation contexts.
8270
8271 // Set of failed immediate invocations to avoid double diagnosing.
8273
8274 /// List of SourceLocations where 'self' is implicitly retained inside a
8275 /// block.
8278
8279 /// Do an explicit extend of the given block pointer if we're in ARC.
8281
8282 std::vector<std::pair<QualType, unsigned>> ExcessPrecisionNotSatisfied;
8285
8286private:
8287 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
8288
8289 /// Methods for marking which expressions involve dereferencing a pointer
8290 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
8291 /// they are parsed, meaning that a noderef pointer may not be accessed. For
8292 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
8293 /// `*p`, but need to check that `address of` is called on it. This requires
8294 /// keeping a container of all pending expressions and checking if the address
8295 /// of them are eventually taken.
8296 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
8297 void CheckAddressOfNoDeref(const Expr *E);
8298
8299 ///@}
8300
8301 //
8302 //
8303 // -------------------------------------------------------------------------
8304 //
8305 //
8306
8307 /// \name C++ Expressions
8308 /// Implementations are in SemaExprCXX.cpp
8309 ///@{
8310
8311public:
8312 /// The C++ "std::bad_alloc" class, which is defined by the C++
8313 /// standard library.
8315
8316 /// The C++ "std::align_val_t" enum class, which is defined by the C++
8317 /// standard library.
8319
8320 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
8322
8323 /// A flag to remember whether the implicit forms of operator new and delete
8324 /// have been declared.
8326
8327 /// Delete-expressions to be analyzed at the end of translation unit
8328 ///
8329 /// This list contains class members, and locations of delete-expressions
8330 /// that could not be proven as to whether they mismatch with new-expression
8331 /// used in initializer of the field.
8332 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
8333
8334 /// Handle the result of the special case name lookup for inheriting
8335 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
8336 /// constructor names in member using declarations, even if 'X' is not the
8337 /// name of the corresponding type.
8339 SourceLocation NameLoc,
8340 const IdentifierInfo &Name);
8341
8343 SourceLocation NameLoc, Scope *S,
8344 CXXScopeSpec &SS, bool EnteringContext);
8346 Scope *S, CXXScopeSpec &SS,
8347 ParsedType ObjectType, bool EnteringContext);
8348
8350 ParsedType ObjectType);
8351
8352 /// Build a C++ typeid expression with a type operand.
8353 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8354 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8355
8356 /// Build a C++ typeid expression with an expression operand.
8357 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8358 Expr *Operand, SourceLocation RParenLoc);
8359
8360 /// ActOnCXXTypeid - Parse typeid( something ).
8362 bool isType, void *TyOrExpr,
8363 SourceLocation RParenLoc);
8364
8365 /// Build a Microsoft __uuidof expression with a type operand.
8366 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8367 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8368
8369 /// Build a Microsoft __uuidof expression with an expression operand.
8370 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8371 Expr *Operand, SourceLocation RParenLoc);
8372
8373 /// ActOnCXXUuidof - Parse __uuidof( something ).
8375 bool isType, void *TyOrExpr,
8376 SourceLocation RParenLoc);
8377
8378 //// ActOnCXXThis - Parse 'this' pointer.
8380
8381 /// Check whether the type of 'this' is valid in the current context.
8383
8384 /// Build a CXXThisExpr and mark it referenced in the current context.
8385 Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);
8387
8388 /// Try to retrieve the type of the 'this' pointer.
8389 ///
8390 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8392
8393 /// When non-NULL, the C++ 'this' expression is allowed despite the
8394 /// current context not being a non-static member function. In such cases,
8395 /// this provides the type used for 'this'.
8397
8398 /// RAII object used to temporarily allow the C++ 'this' expression
8399 /// to be used, with the given qualifiers on the current class type.
8401 Sema &S;
8402 QualType OldCXXThisTypeOverride;
8403 bool Enabled;
8404
8405 public:
8406 /// Introduce a new scope where 'this' may be allowed (when enabled),
8407 /// using the given declaration (which is either a class template or a
8408 /// class) along with the given qualifiers.
8409 /// along with the qualifiers placed on '*this'.
8410 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8411 bool Enabled = true);
8412
8414 };
8415
8416 /// Make sure the value of 'this' is actually available in the current
8417 /// context, if it is a potentially evaluated context.
8418 ///
8419 /// \param Loc The location at which the capture of 'this' occurs.
8420 ///
8421 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8422 /// capture list.
8423 ///
8424 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8425 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8426 /// This is useful when enclosing lambdas must speculatively capture
8427 /// 'this' that may or may not be used in certain specializations of
8428 /// a nested generic lambda (depending on whether the name resolves to
8429 /// a non-static member function or a static function).
8430 /// \return returns 'true' if failed, 'false' if success.
8432 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8433 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8434 bool ByCopy = false);
8435
8436 /// Determine whether the given type is the type of *this that is used
8437 /// outside of the body of a member function for a type that is currently
8438 /// being defined.
8440
8441 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8443
8444 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8446
8447 //// ActOnCXXThrow - Parse throw expressions.
8450 bool IsThrownVarInScope);
8451
8452 /// CheckCXXThrowOperand - Validate the operand of a throw.
8453 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8454
8455 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8456 /// Can be interpreted either as function-style casting ("int(x)")
8457 /// or class type construction ("ClassType(x,y,z)")
8458 /// or creation of a value-initialized type ("int()").
8460 SourceLocation LParenOrBraceLoc,
8461 MultiExprArg Exprs,
8462 SourceLocation RParenOrBraceLoc,
8463 bool ListInitialization);
8464
8466 SourceLocation LParenLoc,
8467 MultiExprArg Exprs,
8468 SourceLocation RParenLoc,
8469 bool ListInitialization);
8470
8471 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8472 ///
8473 /// E.g.:
8474 /// @code new (memory) int[size][4] @endcode
8475 /// or
8476 /// @code ::new Foo(23, "hello") @endcode
8477 ///
8478 /// \param StartLoc The first location of the expression.
8479 /// \param UseGlobal True if 'new' was prefixed with '::'.
8480 /// \param PlacementLParen Opening paren of the placement arguments.
8481 /// \param PlacementArgs Placement new arguments.
8482 /// \param PlacementRParen Closing paren of the placement arguments.
8483 /// \param TypeIdParens If the type is in parens, the source range.
8484 /// \param D The type to be allocated, as well as array dimensions.
8485 /// \param Initializer The initializing expression or initializer-list, or
8486 /// null if there is none.
8487 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8488 SourceLocation PlacementLParen,
8489 MultiExprArg PlacementArgs,
8490 SourceLocation PlacementRParen,
8491 SourceRange TypeIdParens, Declarator &D,
8492 Expr *Initializer);
8494 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8495 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8496 SourceRange TypeIdParens, QualType AllocType,
8497 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8498 SourceRange DirectInitRange, Expr *Initializer);
8499
8500 /// Determine whether \p FD is an aligned allocation or deallocation
8501 /// function that is unavailable.
8503
8504 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8505 /// function that is unavailable.
8507 SourceLocation Loc);
8508
8509 /// Checks that a type is suitable as the allocated type
8510 /// in a new-expression.
8511 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
8512 SourceRange R);
8513
8514 /// Finds the overloads of operator new and delete that are appropriate
8515 /// for the allocation.
8517 SourceLocation StartLoc, SourceRange Range,
8519 QualType AllocType, bool IsArray, ImplicitAllocationParameters &IAP,
8520 MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew,
8521 FunctionDecl *&OperatorDelete, bool Diagnose = true);
8522
8523 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8524 /// delete. These are:
8525 /// @code
8526 /// // C++03:
8527 /// void* operator new(std::size_t) throw(std::bad_alloc);
8528 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8529 /// void operator delete(void *) throw();
8530 /// void operator delete[](void *) throw();
8531 /// // C++11:
8532 /// void* operator new(std::size_t);
8533 /// void* operator new[](std::size_t);
8534 /// void operator delete(void *) noexcept;
8535 /// void operator delete[](void *) noexcept;
8536 /// // C++1y:
8537 /// void* operator new(std::size_t);
8538 /// void* operator new[](std::size_t);
8539 /// void operator delete(void *) noexcept;
8540 /// void operator delete[](void *) noexcept;
8541 /// void operator delete(void *, std::size_t) noexcept;
8542 /// void operator delete[](void *, std::size_t) noexcept;
8543 /// @endcode
8544 /// Note that the placement and nothrow forms of new are *not* implicitly
8545 /// declared. Their use requires including <new>.
8548 ArrayRef<QualType> Params);
8549
8551 DeclarationName Name, FunctionDecl *&Operator,
8553 bool Diagnose = true);
8556 DeclarationName Name,
8557 bool Diagnose = true);
8559 CXXRecordDecl *RD,
8560 bool Diagnose,
8561 bool LookForGlobal);
8562
8563 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8564 /// @code ::delete ptr; @endcode
8565 /// or
8566 /// @code delete [] ptr; @endcode
8567 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8568 bool ArrayForm, Expr *Operand);
8570 bool IsDelete, bool CallCanBeVirtual,
8571 bool WarnOnNonAbstractTypes,
8572 SourceLocation DtorLoc);
8573
8575 Expr *Operand, SourceLocation RParen);
8577 SourceLocation RParen);
8578
8580 SourceLocation OpLoc,
8581 tok::TokenKind OpKind,
8582 ParsedType &ObjectType,
8583 bool &MayBePseudoDestructor);
8584
8586 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8587 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8588 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8589
8591 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8592 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8593 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8594
8596 SourceLocation OpLoc,
8597 tok::TokenKind OpKind,
8598 SourceLocation TildeLoc,
8599 const DeclSpec &DS);
8600
8601 /// MaybeCreateExprWithCleanups - If the current full-expression
8602 /// requires any cleanups, surround it with a ExprWithCleanups node.
8603 /// Otherwise, just returns the passed-in expression.
8607
8608 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8609 return ActOnFinishFullExpr(
8610 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8611 }
8613 bool DiscardedValue, bool IsConstexpr = false,
8614 bool IsTemplateArgument = false);
8616
8617 /// Process the expression contained within a decltype. For such expressions,
8618 /// certain semantic checks on temporaries are delayed until this point, and
8619 /// are omitted for the 'topmost' call in the decltype expression. If the
8620 /// topmost call bound a temporary, strip that temporary off the expression.
8622
8623 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8624 bool IsUDSuffix);
8625
8627
8628 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8629 SourceLocation StmtLoc,
8630 ConditionKind CK);
8631
8632 /// Check the use of the given variable as a C++ condition in an if,
8633 /// while, do-while, or switch statement.
8635 SourceLocation StmtLoc, ConditionKind CK);
8636
8637 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8638 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8639
8640 /// Helper function to determine whether this is the (deprecated) C++
8641 /// conversion from a string literal to a pointer to non-const char or
8642 /// non-const wchar_t (for narrow and wide string literals,
8643 /// respectively).
8645
8646 /// PerformImplicitConversion - Perform an implicit conversion of the
8647 /// expression From to the type ToType using the pre-computed implicit
8648 /// conversion sequence ICS. Returns the converted
8649 /// expression. Action is the kind of conversion we're performing,
8650 /// used in the error message.
8652 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8653 AssignmentAction Action,
8655
8656 /// PerformImplicitConversion - Perform an implicit conversion of the
8657 /// expression From to the type ToType by following the standard
8658 /// conversion sequence SCS. Returns the converted
8659 /// expression. Flavor is the context in which we're performing this
8660 /// conversion, for use in error messages.
8662 const StandardConversionSequence &SCS,
8663 AssignmentAction Action,
8665
8666 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8667
8668 /// Parsed one of the type trait support pseudo-functions.
8671 SourceLocation RParenLoc);
8674 SourceLocation RParenLoc);
8675
8676 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8677 /// pseudo-functions.
8679 ParsedType LhsTy, Expr *DimExpr,
8680 SourceLocation RParen);
8681
8683 TypeSourceInfo *TSInfo, Expr *DimExpr,
8684 SourceLocation RParen);
8685
8686 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8687 /// pseudo-functions.
8689 Expr *Queried, SourceLocation RParen);
8690
8692 Expr *Queried, SourceLocation RParen);
8693
8696 bool isIndirect);
8698 ExprResult &RHS,
8699 SourceLocation QuestionLoc);
8700
8702 ExprResult &LHS, ExprResult &RHS,
8703 SourceLocation QuestionLoc);
8704
8705 //// Determines if a type is trivially relocatable
8706 /// according to the C++26 rules.
8707 // FIXME: This is in Sema because it requires
8708 // overload resolution, can we move to ASTContext?
8711
8712 //// Determines if a type is replaceable
8713 /// according to the C++26 rules.
8714 // FIXME: This is in Sema because it requires
8715 // overload resolution, can we move to ASTContext?
8717
8718 /// Check the operands of ?: under C++ semantics.
8719 ///
8720 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8721 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8722 ///
8723 /// This function also implements GCC's vector extension and the
8724 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8725 /// permit the use of a?b:c where the type of a is that of a integer vector
8726 /// with the same number of elements and size as the vectors of b and c. If
8727 /// one of either b or c is a scalar it is implicitly converted to match the
8728 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8729 /// c are scalars, then b and c are checked and converted to the type of a if
8730 /// possible.
8731 ///
8732 /// The expressions are evaluated differently for GCC's and OpenCL's
8733 /// extensions. For the GCC extension, the ?: operator is evaluated as
8734 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8735 /// For the OpenCL extensions, the ?: operator is evaluated as
8736 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8737 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8739 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8740 ExprObjectKind &OK, SourceLocation questionLoc);
8741
8742 /// Find a merged pointer type and convert the two expressions to it.
8743 ///
8744 /// This finds the composite pointer type for \p E1 and \p E2 according to
8745 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8746 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8747 /// ConvertArgs is \c true).
8748 ///
8749 /// \param Loc The location of the operator requiring these two expressions to
8750 /// be converted to the composite pointer type.
8751 ///
8752 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8753 /// type.
8755 bool ConvertArgs = true);
8757 ExprResult &E2, bool ConvertArgs = true) {
8758 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8759 QualType Composite =
8760 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8761 E1 = E1Tmp;
8762 E2 = E2Tmp;
8763 return Composite;
8764 }
8765
8766 /// MaybeBindToTemporary - If the passed in expression has a record type with
8767 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8768 /// it simply returns the passed in expression.
8770
8771 /// IgnoredValueConversions - Given that an expression's result is
8772 /// syntactically ignored, perform any conversions that are
8773 /// required.
8775
8777
8780 const DeclarationNameInfo &TargetNameInfo);
8781
8783 SourceLocation KeywordLoc,
8784 bool IsIfExists, CXXScopeSpec &SS,
8785 UnqualifiedId &Name);
8786
8789 ArrayRef<ParmVarDecl *> LocalParameters,
8790 Scope *BodyScope);
8794 CXXScopeSpec &SS,
8795 SourceLocation NameLoc,
8796 const IdentifierInfo *TypeName,
8797 TemplateIdAnnotation *TemplateId);
8799 SourceLocation NoexceptLoc);
8801 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8802 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8805 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8809 bool IsSatisfied, SourceLocation NoexceptLoc,
8816 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8817 const ASTConstraintSatisfaction &Satisfaction);
8820 SourceLocation LParenLoc,
8821 ArrayRef<ParmVarDecl *> LocalParameters,
8822 SourceLocation RParenLoc,
8824 SourceLocation ClosingBraceLoc);
8825
8826private:
8827 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8828 bool IsDelete);
8829
8830 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8831 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8832 bool DeleteWasArrayForm);
8833
8834 ///@}
8835
8836 //
8837 //
8838 // -------------------------------------------------------------------------
8839 //
8840 //
8841
8842 /// \name Member Access Expressions
8843 /// Implementations are in SemaExprMember.cpp
8844 ///@{
8845
8846public:
8847 /// Check whether an expression might be an implicit class member access.
8849 bool IsAddressOfOperand);
8850
8851 /// Builds an expression which might be an implicit member expression.
8853 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
8854 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
8855
8856 /// Builds an implicit member access expression. The current context
8857 /// is known to be an instance method, and the given unqualified lookup
8858 /// set is known to contain only instance members, at least one of which
8859 /// is from an appropriate type.
8861 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8862 LookupResult &R,
8863 const TemplateArgumentListInfo *TemplateArgs,
8864 bool IsDefiniteInstance, const Scope *S);
8865
8867 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
8868 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8869 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8870 const TemplateArgumentListInfo *TemplateArgs);
8871
8872 /// The main callback when the parser finds something like
8873 /// expression . [nested-name-specifier] identifier
8874 /// expression -> [nested-name-specifier] identifier
8875 /// where 'identifier' encompasses a fairly broad spectrum of
8876 /// possibilities, including destructor and operator references.
8877 ///
8878 /// \param OpKind either tok::arrow or tok::period
8879 /// \param ObjCImpDecl the current Objective-C \@implementation
8880 /// decl; this is an ugly hack around the fact that Objective-C
8881 /// \@implementations aren't properly put in the context chain
8883 tok::TokenKind OpKind, CXXScopeSpec &SS,
8884 SourceLocation TemplateKWLoc,
8885 UnqualifiedId &Member, Decl *ObjCImpDecl);
8886
8887 MemberExpr *
8888 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
8889 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
8890 ValueDecl *Member, DeclAccessPair FoundDecl,
8891 bool HadMultipleCandidates,
8892 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
8894 const TemplateArgumentListInfo *TemplateArgs = nullptr);
8895
8896 // Check whether the declarations we found through a nested-name
8897 // specifier in a member expression are actually members of the base
8898 // type. The restriction here is:
8899 //
8900 // C++ [expr.ref]p2:
8901 // ... In these cases, the id-expression shall name a
8902 // member of the class or of one of its base classes.
8903 //
8904 // So it's perfectly legitimate for the nested-name specifier to name
8905 // an unrelated class, and for us to find an overload set including
8906 // decls from classes which are not superclasses, as long as the decl
8907 // we actually pick through overload resolution is from a superclass.
8908 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
8909 const CXXScopeSpec &SS,
8910 const LookupResult &R);
8911
8912 // This struct is for use by ActOnMemberAccess to allow
8913 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
8914 // changing the access operator from a '.' to a '->' (to see if that is the
8915 // change needed to fix an error about an unknown member, e.g. when the class
8916 // defines a custom operator->).
8922
8924 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
8925 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8926 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8927 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
8928 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8929
8932 bool IsArrow, const CXXScopeSpec &SS,
8933 SourceLocation TemplateKWLoc,
8934 NamedDecl *FirstQualifierInScope, LookupResult &R,
8935 const TemplateArgumentListInfo *TemplateArgs,
8936 const Scope *S, bool SuppressQualifierCheck = false,
8937 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8938
8939 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
8940 SourceLocation OpLoc,
8941 const CXXScopeSpec &SS, FieldDecl *Field,
8942 DeclAccessPair FoundDecl,
8943 const DeclarationNameInfo &MemberNameInfo);
8944
8945 /// Perform conversions on the LHS of a member access expression.
8947
8949 const CXXScopeSpec &SS, SourceLocation nameLoc,
8950 IndirectFieldDecl *indirectField,
8951 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
8952 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
8953
8954private:
8955 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
8956
8957 ///@}
8958
8959 //
8960 //
8961 // -------------------------------------------------------------------------
8962 //
8963 //
8964
8965 /// \name Initializers
8966 /// Implementations are in SemaInit.cpp
8967 ///@{
8968
8969public:
8970 /// Stack of types that correspond to the parameter entities that are
8971 /// currently being copy-initialized. Can be empty.
8973
8974 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
8976
8977 bool IsStringInit(Expr *Init, const ArrayType *AT);
8978
8979 /// Determine whether we can perform aggregate initialization for the purposes
8980 /// of overload resolution.
8982 const InitializedEntity &Entity, InitListExpr *From);
8983
8985 SourceLocation EqualOrColonLoc,
8986 bool GNUSyntax, ExprResult Init);
8987
8988 /// Check that the lifetime of the initializer (and its subobjects) is
8989 /// sufficient for initializing the entity, and perform lifetime extension
8990 /// (when permitted) if not.
8992
8995 bool BoundToLvalueReference);
8996
8997 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
8998 /// it as an xvalue. In C++98, the result will still be a prvalue, because
8999 /// we don't have xvalues there.
9001
9005
9009 SourceLocation EqualLoc, ExprResult Init,
9010 bool TopLevelOfInitList = false,
9011 bool AllowExplicit = false);
9012
9014 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
9015 const InitializationKind &Kind, MultiExprArg Init);
9016
9017 ///@}
9018
9019 //
9020 //
9021 // -------------------------------------------------------------------------
9022 //
9023 //
9024
9025 /// \name C++ Lambda Expressions
9026 /// Implementations are in SemaLambda.cpp
9027 ///@{
9028
9029public:
9030 /// Create a new lambda closure type.
9032 TypeSourceInfo *Info,
9033 unsigned LambdaDependencyKind,
9034 LambdaCaptureDefault CaptureDefault);
9035
9036 /// Number lambda for linkage purposes if necessary.
9038 std::optional<CXXRecordDecl::LambdaNumbering>
9039 NumberingOverride = std::nullopt);
9040
9041 /// Endow the lambda scope info with the relevant properties.
9042 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
9043 SourceRange IntroducerRange,
9044 LambdaCaptureDefault CaptureDefault,
9045 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
9046 bool Mutable);
9047
9050
9052 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
9053 TemplateParameterList *TemplateParams);
9054
9055 void
9057 SourceLocation CallOperatorLoc,
9058 const AssociatedConstraint &TrailingRequiresClause,
9059 TypeSourceInfo *MethodTyInfo,
9060 ConstexprSpecKind ConstexprKind, StorageClass SC,
9062 bool HasExplicitResultType);
9063
9064 /// Returns true if the explicit object parameter was invalid.
9066 SourceLocation CallLoc);
9067
9068 /// Perform initialization analysis of the init-capture and perform
9069 /// any implicit conversions such as an lvalue-to-rvalue conversion if
9070 /// not being used to initialize a reference.
9072 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
9073 IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init) {
9075 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
9077 }
9079 SourceLocation EllipsisLoc,
9080 UnsignedOrNone NumExpansions,
9081 IdentifierInfo *Id,
9082 bool DirectInit, Expr *&Init);
9083
9084 /// Create a dummy variable within the declcontext of the lambda's
9085 /// call operator, for name lookup purposes for a lambda init capture.
9086 ///
9087 /// CodeGen handles emission of lambda captures, ignoring these dummy
9088 /// variables appropriately.
9090 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
9091 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
9092
9093 /// Add an init-capture to a lambda scope.
9094 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
9095
9096 /// Note that we have finished the explicit captures for the
9097 /// given lambda.
9099
9100 /// Deduce a block or lambda's return type based on the return
9101 /// statements present in the body.
9103
9104 /// Once the Lambdas capture are known, we can start to create the closure,
9105 /// call operator method, and keep track of the captures.
9106 /// We do the capture lookup here, but they are not actually captured until
9107 /// after we know what the qualifiers of the call operator are.
9109 Scope *CurContext);
9110
9111 /// This is called after parsing the explicit template parameter list
9112 /// on a lambda (if it exists) in C++2a.
9114 SourceLocation LAngleLoc,
9115 ArrayRef<NamedDecl *> TParams,
9116 SourceLocation RAngleLoc,
9117 ExprResult RequiresClause);
9118
9120 SourceLocation MutableLoc);
9121
9123 Scope *LambdaScope,
9125
9126 /// ActOnStartOfLambdaDefinition - This is called just before we start
9127 /// parsing the body of a lambda; it analyzes the explicit captures and
9128 /// arguments, and sets up various data-structures for the body of the
9129 /// lambda.
9131 Declarator &ParamInfo, const DeclSpec &DS);
9132
9133 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
9134 /// is invoked to pop the information about the lambda.
9135 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
9136 bool IsInstantiation = false);
9137
9138 /// ActOnLambdaExpr - This is called when the body of a lambda expression
9139 /// was successfully completed.
9141
9142 /// Does copying/destroying the captured variable have side effects?
9143 bool CaptureHasSideEffects(const sema::Capture &From);
9144
9145 /// Diagnose if an explicit lambda capture is unused. Returns true if a
9146 /// diagnostic is emitted.
9147 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
9148 SourceRange FixItRange,
9149 const sema::Capture &From);
9150
9151 /// Build a FieldDecl suitable to hold the given capture.
9153
9154 /// Initialize the given capture with a suitable expression.
9156 SourceLocation ImplicitCaptureLoc,
9157 bool IsOpenMPMapping = false);
9158
9159 /// Complete a lambda-expression having processed and attached the
9160 /// lambda body.
9162
9163 /// Get the return type to use for a lambda's conversion function(s) to
9164 /// function pointer type, given the type of the call operator.
9165 QualType
9167 CallingConv CC);
9168
9170 SourceLocation ConvLocation,
9171 CXXConversionDecl *Conv, Expr *Src);
9172
9174 : private FunctionScopeRAII {
9175 public:
9177 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
9179 bool ShouldAddDeclsFromParentScope = true);
9180 };
9181
9182 /// Compute the mangling number context for a lambda expression or
9183 /// block literal. Also return the extra mangling decl if any.
9184 ///
9185 /// \param DC - The DeclContext containing the lambda expression or
9186 /// block literal.
9187 std::tuple<MangleNumberingContext *, Decl *>
9189
9190 ///@}
9191
9192 //
9193 //
9194 // -------------------------------------------------------------------------
9195 //
9196 //
9197
9198 /// \name Name Lookup
9199 ///
9200 /// These routines provide name lookup that is used during semantic
9201 /// analysis to resolve the various kinds of names (identifiers,
9202 /// overloaded operator names, constructor names, etc.) into zero or
9203 /// more declarations within a particular scope. The major entry
9204 /// points are LookupName, which performs unqualified name lookup,
9205 /// and LookupQualifiedName, which performs qualified name lookup.
9206 ///
9207 /// All name lookup is performed based on some specific criteria,
9208 /// which specify what names will be visible to name lookup and how
9209 /// far name lookup should work. These criteria are important both
9210 /// for capturing language semantics (certain lookups will ignore
9211 /// certain names, for example) and for performance, since name
9212 /// lookup is often a bottleneck in the compilation of C++. Name
9213 /// lookup criteria is specified via the LookupCriteria enumeration.
9214 ///
9215 /// The results of name lookup can vary based on the kind of name
9216 /// lookup performed, the current language, and the translation
9217 /// unit. In C, for example, name lookup will either return nothing
9218 /// (no entity found) or a single declaration. In C++, name lookup
9219 /// can additionally refer to a set of overloaded functions or
9220 /// result in an ambiguity. All of the possible results of name
9221 /// lookup are captured by the LookupResult class, which provides
9222 /// the ability to distinguish among them.
9223 ///
9224 /// Implementations are in SemaLookup.cpp
9225 ///@{
9226
9227public:
9228 /// Tracks whether we are in a context where typo correction is
9229 /// disabled.
9231
9232 /// The number of typos corrected by CorrectTypo.
9234
9235 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
9236 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
9237
9238 /// A cache containing identifiers for which typo correction failed and
9239 /// their locations, so that repeated attempts to correct an identifier in a
9240 /// given location are ignored if typo correction already failed for it.
9242
9243 /// SpecialMemberOverloadResult - The overloading result for a special member
9244 /// function.
9245 ///
9246 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
9247 /// integer are used to determine whether overload resolution succeeded.
9249 public:
9251
9252 private:
9253 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
9254
9255 public:
9258 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
9259
9260 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
9261 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
9262
9263 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
9264 void setKind(Kind K) { Pair.setInt(K); }
9265 };
9266
9267 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
9269 public:
9270 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
9271 : FastFoldingSetNode(ID) {}
9272 };
9273
9274 /// A cache of special member function overload resolution results
9275 /// for C++ records.
9276 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
9277
9279
9280 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
9281 // TODO: make this is a typesafe union.
9284
9285 /// Describes the kind of name lookup to perform.
9287 /// Ordinary name lookup, which finds ordinary names (functions,
9288 /// variables, typedefs, etc.) in C and most kinds of names
9289 /// (functions, variables, members, types, etc.) in C++.
9291 /// Tag name lookup, which finds the names of enums, classes,
9292 /// structs, and unions.
9294 /// Label name lookup.
9296 /// Member name lookup, which finds the names of
9297 /// class/struct/union members.
9299 /// Look up of an operator name (e.g., operator+) for use with
9300 /// operator overloading. This lookup is similar to ordinary name
9301 /// lookup, but will ignore any declarations that are class members.
9303 /// Look up a name following ~ in a destructor name. This is an ordinary
9304 /// lookup, but prefers tags to typedefs.
9306 /// Look up of a name that precedes the '::' scope resolution
9307 /// operator in C++. This lookup completely ignores operator, object,
9308 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9310 /// Look up a namespace name within a C++ using directive or
9311 /// namespace alias definition, ignoring non-namespace names (C++
9312 /// [basic.lookup.udir]p1).
9314 /// Look up all declarations in a scope with the given name,
9315 /// including resolved using declarations. This is appropriate
9316 /// for checking redeclarations for a using declaration.
9318 /// Look up an ordinary name that is going to be redeclared as a
9319 /// name with linkage. This lookup ignores any declarations that
9320 /// are outside of the current scope unless they have linkage. See
9321 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9323 /// Look up a friend of a local class. This lookup does not look
9324 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9326 /// Look up the name of an Objective-C protocol.
9328 /// Look up implicit 'self' parameter of an objective-c method.
9330 /// Look up the name of an OpenMP user-defined reduction operation.
9332 /// Look up the name of an OpenMP user-defined mapper.
9334 /// Look up any declaration with any name.
9336 };
9337
9338 /// The possible outcomes of name lookup for a literal operator.
9340 /// The lookup resulted in an error.
9342 /// The lookup found no match but no diagnostic was issued.
9344 /// The lookup found a single 'cooked' literal operator, which
9345 /// expects a normal literal to be built and passed to it.
9347 /// The lookup found a single 'raw' literal operator, which expects
9348 /// a string literal containing the spelling of the literal token.
9350 /// The lookup found an overload set of literal operator templates,
9351 /// which expect the characters of the spelling of the literal token to be
9352 /// passed as a non-type template argument pack.
9354 /// The lookup found an overload set of literal operator templates,
9355 /// which expect the character type and characters of the spelling of the
9356 /// string literal token to be passed as template arguments.
9358 };
9359
9360 SpecialMemberOverloadResult
9362 bool VolatileArg, bool RValueThis, bool ConstThis,
9363 bool VolatileThis);
9364
9366
9367 /// Look up a name, looking for a single declaration. Return
9368 /// null if the results were absent, ambiguous, or overloaded.
9369 ///
9370 /// It is preferable to use the elaborated form and explicitly handle
9371 /// ambiguity and overloaded.
9373 Scope *S, DeclarationName Name, SourceLocation Loc,
9374 LookupNameKind NameKind,
9376
9377 /// Lookup a builtin function, when name lookup would otherwise
9378 /// fail.
9379 bool LookupBuiltin(LookupResult &R);
9380 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9381
9382 /// Perform unqualified name lookup starting from a given
9383 /// scope.
9384 ///
9385 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9386 /// used to find names within the current scope. For example, 'x' in
9387 /// @code
9388 /// int x;
9389 /// int f() {
9390 /// return x; // unqualified name look finds 'x' in the global scope
9391 /// }
9392 /// @endcode
9393 ///
9394 /// Different lookup criteria can find different names. For example, a
9395 /// particular scope can have both a struct and a function of the same
9396 /// name, and each can be found by certain lookup criteria. For more
9397 /// information about lookup criteria, see the documentation for the
9398 /// class LookupCriteria.
9399 ///
9400 /// @param S The scope from which unqualified name lookup will
9401 /// begin. If the lookup criteria permits, name lookup may also search
9402 /// in the parent scopes.
9403 ///
9404 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9405 /// look up and the lookup kind), and is updated with the results of lookup
9406 /// including zero or more declarations and possibly additional information
9407 /// used to diagnose ambiguities.
9408 ///
9409 /// @returns \c true if lookup succeeded and false otherwise.
9410 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9411 bool ForceNoCPlusPlus = false);
9412
9413 /// Perform qualified name lookup into a given context.
9414 ///
9415 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9416 /// names when the context of those names is explicit specified, e.g.,
9417 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9418 ///
9419 /// Different lookup criteria can find different names. For example, a
9420 /// particular scope can have both a struct and a function of the same
9421 /// name, and each can be found by certain lookup criteria. For more
9422 /// information about lookup criteria, see the documentation for the
9423 /// class LookupCriteria.
9424 ///
9425 /// \param R captures both the lookup criteria and any lookup results found.
9426 ///
9427 /// \param LookupCtx The context in which qualified name lookup will
9428 /// search. If the lookup criteria permits, name lookup may also search
9429 /// in the parent contexts or (for C++ classes) base classes.
9430 ///
9431 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9432 /// occurs as part of unqualified name lookup.
9433 ///
9434 /// \returns true if lookup succeeded, false if it failed.
9435 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9436 bool InUnqualifiedLookup = false);
9437
9438 /// Performs qualified name lookup or special type of lookup for
9439 /// "__super::" scope specifier.
9440 ///
9441 /// This routine is a convenience overload meant to be called from contexts
9442 /// that need to perform a qualified name lookup with an optional C++ scope
9443 /// specifier that might require special kind of lookup.
9444 ///
9445 /// \param R captures both the lookup criteria and any lookup results found.
9446 ///
9447 /// \param LookupCtx The context in which qualified name lookup will
9448 /// search.
9449 ///
9450 /// \param SS An optional C++ scope-specifier.
9451 ///
9452 /// \returns true if lookup succeeded, false if it failed.
9453 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9454 CXXScopeSpec &SS);
9455
9456 /// Performs name lookup for a name that was parsed in the
9457 /// source code, and may contain a C++ scope specifier.
9458 ///
9459 /// This routine is a convenience routine meant to be called from
9460 /// contexts that receive a name and an optional C++ scope specifier
9461 /// (e.g., "N::M::x"). It will then perform either qualified or
9462 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9463 /// respectively) on the given name and return those results. It will
9464 /// perform a special type of lookup for "__super::" scope specifier.
9465 ///
9466 /// @param S The scope from which unqualified name lookup will
9467 /// begin.
9468 ///
9469 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9470 ///
9471 /// @param EnteringContext Indicates whether we are going to enter the
9472 /// context of the scope-specifier SS (if present).
9473 ///
9474 /// @returns True if any decls were found (but possibly ambiguous)
9476 QualType ObjectType, bool AllowBuiltinCreation = false,
9477 bool EnteringContext = false);
9478
9479 /// Perform qualified name lookup into all base classes of the given
9480 /// class.
9481 ///
9482 /// \param R captures both the lookup criteria and any lookup results found.
9483 ///
9484 /// \param Class The context in which qualified name lookup will
9485 /// search. Name lookup will search in all base classes merging the results.
9486 ///
9487 /// @returns True if any decls were found (but possibly ambiguous)
9489
9491 UnresolvedSetImpl &Functions);
9492
9493 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9494 /// If GnuLabelLoc is a valid source location, then this is a definition
9495 /// of an __label__ label name, otherwise it is a normal label definition
9496 /// or use.
9498 SourceLocation GnuLabelLoc = SourceLocation());
9499
9500 /// Perform a name lookup for a label with the specified name; this does not
9501 /// create a new label if the lookup fails.
9503
9504 /// Look up the constructors for the given class.
9506
9507 /// Look up the default constructor for the given class.
9509
9510 /// Look up the copying constructor for the given class.
9512 unsigned Quals);
9513
9514 /// Look up the copying assignment operator for the given class.
9516 bool RValueThis, unsigned ThisQuals);
9517
9518 /// Look up the moving constructor for the given class.
9520 unsigned Quals);
9521
9522 /// Look up the moving assignment operator for the given class.
9524 bool RValueThis, unsigned ThisQuals);
9525
9526 /// Look for the destructor of the given class.
9527 ///
9528 /// During semantic analysis, this routine should be used in lieu of
9529 /// CXXRecordDecl::getDestructor().
9530 ///
9531 /// \returns The destructor for this class.
9533
9534 /// Force the declaration of any implicitly-declared members of this
9535 /// class.
9537
9538 /// Make a merged definition of an existing hidden definition \p ND
9539 /// visible at the specified location.
9541
9542 /// Check ODR hashes for C/ObjC when merging types from modules.
9543 /// Differently from C++, actually parse the body and reject in case
9544 /// of a mismatch.
9545 template <typename T,
9546 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9548 if (Duplicate->getODRHash() != Previous->getODRHash())
9549 return false;
9550
9551 // Make the previous decl visible.
9553 return true;
9554 }
9555
9556 /// Get the set of additional modules that should be checked during
9557 /// name lookup. A module and its imports become visible when instanting a
9558 /// template defined within it.
9559 llvm::DenseSet<Module *> &getLookupModules();
9560
9561 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9563
9564 /// Determine if the template parameter \p D has a visible default argument.
9565 bool
9567 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9568 /// Determine if the template parameter \p D has a reachable default argument.
9570 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9571 /// Determine if the template parameter \p D has a reachable default argument.
9575
9576 /// Determine if there is a visible declaration of \p D that is an explicit
9577 /// specialization declaration for a specialization of a template. (For a
9578 /// member specialization, use hasVisibleMemberSpecialization.)
9580 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9581 /// Determine if there is a reachable declaration of \p D that is an explicit
9582 /// specialization declaration for a specialization of a template. (For a
9583 /// member specialization, use hasReachableMemberSpecialization.)
9585 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9586
9587 /// Determine if there is a visible declaration of \p D that is a member
9588 /// specialization declaration (as opposed to an instantiated declaration).
9590 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9591 /// Determine if there is a reachable declaration of \p D that is a member
9592 /// specialization declaration (as opposed to an instantiated declaration).
9594 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9595
9596 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9597
9598 /// Determine whether any declaration of an entity is visible.
9599 bool
9601 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9602 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9603 }
9604
9607 /// Determine whether any declaration of an entity is reachable.
9608 bool
9610 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9611 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9612 }
9614 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9615
9616 void diagnoseTypo(const TypoCorrection &Correction,
9617 const PartialDiagnostic &TypoDiag,
9618 bool ErrorRecovery = true);
9619
9620 /// Diagnose a successfully-corrected typo. Separated from the correction
9621 /// itself to allow external validation of the result, etc.
9622 ///
9623 /// \param Correction The result of performing typo correction.
9624 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9625 /// string added to it (and usually also a fixit).
9626 /// \param PrevNote A note to use when indicating the location of the entity
9627 /// to which we are correcting. Will have the correction string added
9628 /// to it.
9629 /// \param ErrorRecovery If \c true (the default), the caller is going to
9630 /// recover from the typo as if the corrected string had been typed.
9631 /// In this case, \c PDiag must be an error, and we will attach a fixit
9632 /// to it.
9633 void diagnoseTypo(const TypoCorrection &Correction,
9634 const PartialDiagnostic &TypoDiag,
9635 const PartialDiagnostic &PrevNote,
9636 bool ErrorRecovery = true);
9637
9638 /// Find the associated classes and namespaces for
9639 /// argument-dependent lookup for a call with the given set of
9640 /// arguments.
9641 ///
9642 /// This routine computes the sets of associated classes and associated
9643 /// namespaces searched by argument-dependent lookup
9644 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9646 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9647 AssociatedNamespaceSet &AssociatedNamespaces,
9648 AssociatedClassSet &AssociatedClasses);
9649
9650 /// Produce a diagnostic describing the ambiguity that resulted
9651 /// from name lookup.
9652 ///
9653 /// \param Result The result of the ambiguous lookup to be diagnosed.
9655
9656 /// LookupLiteralOperator - Determine which literal operator should be used
9657 /// for a user-defined literal, per C++11 [lex.ext].
9658 ///
9659 /// Normal overload resolution is not used to select which literal operator to
9660 /// call for a user-defined literal. Look up the provided literal operator
9661 /// name, and filter the results to the appropriate set for the given argument
9662 /// types.
9665 bool AllowRaw, bool AllowTemplate,
9666 bool AllowStringTemplate, bool DiagnoseMissing,
9667 StringLiteral *StringLit = nullptr);
9668
9670 ArrayRef<Expr *> Args, ADLResult &Functions);
9671
9672 void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
9674 bool IncludeGlobalScope = true,
9675 bool LoadExternal = true);
9676 void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
9678 bool IncludeGlobalScope = true,
9679 bool IncludeDependentBases = false,
9680 bool LoadExternal = true);
9681
9682 /// Try to "correct" a typo in the source code by finding
9683 /// visible declarations whose names are similar to the name that was
9684 /// present in the source code.
9685 ///
9686 /// \param TypoName the \c DeclarationNameInfo structure that contains
9687 /// the name that was present in the source code along with its location.
9688 ///
9689 /// \param LookupKind the name-lookup criteria used to search for the name.
9690 ///
9691 /// \param S the scope in which name lookup occurs.
9692 ///
9693 /// \param SS the nested-name-specifier that precedes the name we're
9694 /// looking for, if present.
9695 ///
9696 /// \param CCC A CorrectionCandidateCallback object that provides further
9697 /// validation of typo correction candidates. It also provides flags for
9698 /// determining the set of keywords permitted.
9699 ///
9700 /// \param MemberContext if non-NULL, the context in which to look for
9701 /// a member access expression.
9702 ///
9703 /// \param EnteringContext whether we're entering the context described by
9704 /// the nested-name-specifier SS.
9705 ///
9706 /// \param OPT when non-NULL, the search for visible declarations will
9707 /// also walk the protocols in the qualified interfaces of \p OPT.
9708 ///
9709 /// \returns a \c TypoCorrection containing the corrected name if the typo
9710 /// along with information such as the \c NamedDecl where the corrected name
9711 /// was declared, and any additional \c NestedNameSpecifier needed to access
9712 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9714 Sema::LookupNameKind LookupKind, Scope *S,
9716 CorrectTypoKind Mode,
9717 DeclContext *MemberContext = nullptr,
9718 bool EnteringContext = false,
9719 const ObjCObjectPointerType *OPT = nullptr,
9720 bool RecordFailure = true);
9721
9722 /// Kinds of missing import. Note, the values of these enumerators correspond
9723 /// to %select values in diagnostics.
9731
9732 /// Diagnose that the specified declaration needs to be visible but
9733 /// isn't, and suggest a module import that would resolve the problem.
9735 MissingImportKind MIK, bool Recover = true);
9737 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9738 MissingImportKind MIK, bool Recover);
9739
9740 /// Called on #pragma clang __debug dump II
9742
9743 /// Called on #pragma clang __debug dump E
9744 void ActOnPragmaDump(Expr *E);
9745
9746private:
9747 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9748 //
9749 // The boolean value will be true to indicate that the namespace was loaded
9750 // from an AST/PCH file, or false otherwise.
9751 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9752
9753 /// Whether we have already loaded known namespaces from an extenal
9754 /// source.
9755 bool LoadedExternalKnownNamespaces;
9756
9757 bool CppLookupName(LookupResult &R, Scope *S);
9758
9759 /// Determine if we could use all the declarations in the module.
9760 bool isUsableModule(const Module *M);
9761
9762 /// Helper for CorrectTypo used to create and populate a new
9763 /// TypoCorrectionConsumer. Returns nullptr if typo correction should be
9764 /// skipped entirely.
9765 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9766 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9768 DeclContext *MemberContext, bool EnteringContext,
9769 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9770
9771 /// Cache for module units which is usable for current module.
9772 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9773
9774 /// Record the typo correction failure and return an empty correction.
9775 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9776 bool RecordFailure = true) {
9777 if (RecordFailure)
9778 TypoCorrectionFailures[Typo].insert(TypoLoc);
9779 return TypoCorrection();
9780 }
9781
9782 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9783
9784 /// Determine whether two declarations should be linked together, given that
9785 /// the old declaration might not be visible and the new declaration might
9786 /// not have external linkage.
9787 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9788 const NamedDecl *New) {
9789 if (isVisible(Old))
9790 return true;
9791 // See comment in below overload for why it's safe to compute the linkage
9792 // of the new declaration here.
9793 if (New->isExternallyDeclarable()) {
9794 assert(Old->isExternallyDeclarable() &&
9795 "should not have found a non-externally-declarable previous decl");
9796 return true;
9797 }
9798 return false;
9799 }
9800 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9801
9802 ///@}
9803
9804 //
9805 //
9806 // -------------------------------------------------------------------------
9807 //
9808 //
9809
9810 /// \name Modules
9811 /// Implementations are in SemaModule.cpp
9812 ///@{
9813
9814public:
9815 /// Get the module unit whose scope we are currently within.
9817 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9818 }
9819
9820 /// Is the module scope we are an implementation unit?
9822 return ModuleScopes.empty()
9823 ? false
9824 : ModuleScopes.back().Module->isModuleImplementation();
9825 }
9826
9827 // When loading a non-modular PCH files, this is used to restore module
9828 // visibility.
9830 VisibleModules.setVisible(Mod, ImportLoc);
9831 }
9832
9833 enum class ModuleDeclKind {
9834 Interface, ///< 'export module X;'
9835 Implementation, ///< 'module X;'
9836 PartitionInterface, ///< 'export module X:Y;'
9837 PartitionImplementation, ///< 'module X:Y;'
9838 };
9839
9840 /// An enumeration to represent the transition of states in parsing module
9841 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9842 /// an error in state transition, the state is set to NotACXX20Module.
9844 FirstDecl, ///< Parsing the first decl in a TU.
9845 GlobalFragment, ///< after 'module;' but before 'module X;'
9846 ImportAllowed, ///< after 'module X;' but before any non-import decl.
9847 ImportFinished, ///< after any non-import decl.
9848 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
9849 ///< non-import decl.
9850 PrivateFragmentImportFinished, ///< after 'module :private;' but a
9851 ///< non-import decl has already been seen.
9852 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
9853 };
9854
9855 /// The parser has processed a module-declaration that begins the definition
9856 /// of a module interface or implementation.
9858 SourceLocation ModuleLoc, ModuleDeclKind MDK,
9859 ModuleIdPath Path, ModuleIdPath Partition,
9860 ModuleImportState &ImportState,
9861 bool SeenNoTrivialPPDirective);
9862
9863 /// The parser has processed a global-module-fragment declaration that begins
9864 /// the definition of the global module fragment of the current module unit.
9865 /// \param ModuleLoc The location of the 'module' keyword.
9867
9868 /// The parser has processed a private-module-fragment declaration that begins
9869 /// the definition of the private module fragment of the current module unit.
9870 /// \param ModuleLoc The location of the 'module' keyword.
9871 /// \param PrivateLoc The location of the 'private' keyword.
9873 SourceLocation PrivateLoc);
9874
9875 /// The parser has processed a module import declaration.
9876 ///
9877 /// \param StartLoc The location of the first token in the declaration. This
9878 /// could be the location of an '@', 'export', or 'import'.
9879 /// \param ExportLoc The location of the 'export' keyword, if any.
9880 /// \param ImportLoc The location of the 'import' keyword.
9881 /// \param Path The module toplevel name as an access path.
9882 /// \param IsPartition If the name is for a partition.
9884 SourceLocation ExportLoc,
9885 SourceLocation ImportLoc, ModuleIdPath Path,
9886 bool IsPartition = false);
9888 SourceLocation ExportLoc,
9889 SourceLocation ImportLoc, Module *M,
9890 ModuleIdPath Path = {});
9891
9892 /// The parser has processed a module import translated from a
9893 /// #include or similar preprocessing directive.
9894 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9895 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9896
9897 /// The parsed has entered a submodule.
9898 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
9899 /// The parser has left a submodule.
9900 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
9901
9902 /// Create an implicit import of the given module at the given
9903 /// source location, for error recovery, if possible.
9904 ///
9905 /// This routine is typically used when an entity found by name lookup
9906 /// is actually hidden within a module that we know about but the user
9907 /// has forgotten to import.
9908 void createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
9909 Module *Mod);
9910
9911 /// We have parsed the start of an export declaration, including the '{'
9912 /// (if present).
9913 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
9914 SourceLocation LBraceLoc);
9915
9916 /// Complete the definition of an export declaration.
9917 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
9918 SourceLocation RBraceLoc);
9919
9920private:
9921 /// The parser has begun a translation unit to be compiled as a C++20
9922 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
9923 void HandleStartOfHeaderUnit();
9924
9925 struct ModuleScope {
9926 SourceLocation BeginLoc;
9927 clang::Module *Module = nullptr;
9928 VisibleModuleSet OuterVisibleModules;
9929 };
9930 /// The modules we're currently parsing.
9931 llvm::SmallVector<ModuleScope, 16> ModuleScopes;
9932
9933 /// For an interface unit, this is the implicitly imported interface unit.
9934 clang::Module *ThePrimaryInterface = nullptr;
9935
9936 /// The explicit global module fragment of the current translation unit.
9937 /// The explicit Global Module Fragment, as specified in C++
9938 /// [module.global.frag].
9939 clang::Module *TheGlobalModuleFragment = nullptr;
9940
9941 /// The implicit global module fragments of the current translation unit.
9942 ///
9943 /// The contents in the implicit global module fragment can't be discarded.
9944 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
9945
9946 /// Namespace definitions that we will export when they finish.
9947 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
9948
9949 /// In a C++ standard module, inline declarations require a definition to be
9950 /// present at the end of a definition domain. This set holds the decls to
9951 /// be checked at the end of the TU.
9952 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
9953
9954 /// Helper function to judge if we are in module purview.
9955 /// Return false if we are not in a module.
9956 bool isCurrentModulePurview() const;
9957
9958 /// Enter the scope of the explicit global module fragment.
9959 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
9960 /// Leave the scope of the explicit global module fragment.
9961 void PopGlobalModuleFragment();
9962
9963 /// Enter the scope of an implicit global module fragment.
9964 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
9965 /// Leave the scope of an implicit global module fragment.
9966 void PopImplicitGlobalModuleFragment();
9967
9968 VisibleModuleSet VisibleModules;
9969
9970 /// Whether we had imported any named modules.
9971 bool HadImportedNamedModules = false;
9972 /// The set of instantiations we need to check if they references TU-local
9973 /// entity from TUs. This only makes sense if we imported any named modules.
9974 llvm::SmallVector<std::pair<FunctionDecl *, SourceLocation>>
9975 PendingCheckReferenceForTULocal;
9976 /// Implement [basic.link]p18, which requires that we can't use TU-local
9977 /// entities from other TUs (ignoring header units).
9978 void checkReferenceToTULocalFromOtherTU(FunctionDecl *FD,
9979 SourceLocation PointOfInstantiation);
9980 /// Implement [basic.link]p17, which diagnose for non TU local exposure in
9981 /// module interface or module partition.
9982 void checkExposure(const TranslationUnitDecl *TU);
9983
9984 ///@}
9985
9986 //
9987 //
9988 // -------------------------------------------------------------------------
9989 //
9990 //
9991
9992 /// \name C++ Overloading
9993 /// Implementations are in SemaOverload.cpp
9994 ///@{
9995
9996public:
9997 /// Whether deferrable diagnostics should be deferred.
9998 bool DeferDiags = false;
9999
10000 /// RAII class to control scope of DeferDiags.
10002 Sema &S;
10003 bool SavedDeferDiags = false;
10004
10005 public:
10007 : S(S), SavedDeferDiags(S.DeferDiags) {
10008 S.DeferDiags = DeferDiags;
10009 }
10010 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
10011 };
10012
10013 /// Flag indicating if Sema is building a recovery call expression.
10014 ///
10015 /// This flag is used to avoid building recovery call expressions
10016 /// if Sema is already doing so, which would cause infinite recursions.
10018
10019 /// Determine whether the given New declaration is an overload of the
10020 /// declarations in Old. This routine returns OverloadKind::Match or
10021 /// OverloadKind::NonFunction if New and Old cannot be overloaded, e.g., if
10022 /// New has the same signature as some function in Old (C++ 1.3.10) or if the
10023 /// Old declarations aren't functions (or function templates) at all. When it
10024 /// does return OverloadKind::Match or OverloadKind::NonFunction, MatchedDecl
10025 /// will point to the decl that New cannot be overloaded with. This decl may
10026 /// be a UsingShadowDecl on top of the underlying declaration.
10027 ///
10028 /// Example: Given the following input:
10029 ///
10030 /// void f(int, float); // #1
10031 /// void f(int, int); // #2
10032 /// int f(int, int); // #3
10033 ///
10034 /// When we process #1, there is no previous declaration of "f", so IsOverload
10035 /// will not be used.
10036 ///
10037 /// When we process #2, Old contains only the FunctionDecl for #1. By
10038 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
10039 /// they have different signatures), so this routine returns
10040 /// OverloadKind::Overload; MatchedDecl is unchanged.
10041 ///
10042 /// When we process #3, Old is an overload set containing #1 and #2. We
10043 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
10044 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
10045 /// types of functions are not part of the signature), IsOverload returns
10046 /// OverloadKind::Match and MatchedDecl will be set to point to the
10047 /// FunctionDecl for #2.
10048 ///
10049 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
10050 /// class by a using declaration. The rules for whether to hide shadow
10051 /// declarations ignore some properties which otherwise figure into a function
10052 /// template's signature.
10054 const LookupResult &OldDecls, NamedDecl *&OldDecl,
10055 bool UseMemberUsingDeclRules);
10057 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10058
10059 // Checks whether MD constitutes an override the base class method BaseMD.
10060 // When checking for overrides, the object object members are ignored.
10061 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
10062 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
10063
10064 enum class AllowedExplicit {
10065 /// Allow no explicit functions to be used.
10067 /// Allow explicit conversion functions but not explicit constructors.
10069 /// Allow both explicit conversion functions and explicit constructors.
10071 };
10072
10074 Expr *From, QualType ToType, bool SuppressUserConversions,
10075 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
10076 bool AllowObjCWritebackConversion);
10077
10078 /// PerformImplicitConversion - Perform an implicit conversion of the
10079 /// expression From to the type ToType. Returns the
10080 /// converted expression. Flavor is the kind of conversion we're
10081 /// performing, used in the error message. If @p AllowExplicit,
10082 /// explicit user-defined conversions are permitted.
10084 AssignmentAction Action,
10085 bool AllowExplicit = false);
10086
10087 /// IsIntegralPromotion - Determines whether the conversion from the
10088 /// expression From (whose potentially-adjusted type is FromType) to
10089 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
10090 /// sets PromotedType to the promoted type.
10091 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
10092
10093 /// IsFloatingPointPromotion - Determines whether the conversion from
10094 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
10095 /// returns true and sets PromotedType to the promoted type.
10096 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
10097
10098 /// Determine if a conversion is a complex promotion.
10099 ///
10100 /// A complex promotion is defined as a complex -> complex conversion
10101 /// where the conversion between the underlying real types is a
10102 /// floating-point or integral promotion.
10103 bool IsComplexPromotion(QualType FromType, QualType ToType);
10104
10105 /// IsPointerConversion - Determines whether the conversion of the
10106 /// expression From, which has the (possibly adjusted) type FromType,
10107 /// can be converted to the type ToType via a pointer conversion (C++
10108 /// 4.10). If so, returns true and places the converted type (that
10109 /// might differ from ToType in its cv-qualifiers at some level) into
10110 /// ConvertedType.
10111 ///
10112 /// This routine also supports conversions to and from block pointers
10113 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
10114 /// pointers to interfaces. FIXME: Once we've determined the
10115 /// appropriate overloading rules for Objective-C, we may want to
10116 /// split the Objective-C checks into a different routine; however,
10117 /// GCC seems to consider all of these conversions to be pointer
10118 /// conversions, so for now they live here. IncompatibleObjC will be
10119 /// set if the conversion is an allowed Objective-C conversion that
10120 /// should result in a warning.
10121 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
10122 bool InOverloadResolution, QualType &ConvertedType,
10123 bool &IncompatibleObjC);
10124
10125 /// isObjCPointerConversion - Determines whether this is an
10126 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
10127 /// with the same arguments and return values.
10128 bool isObjCPointerConversion(QualType FromType, QualType ToType,
10129 QualType &ConvertedType, bool &IncompatibleObjC);
10130 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
10131 QualType &ConvertedType);
10132
10133 /// FunctionParamTypesAreEqual - This routine checks two function proto types
10134 /// for equality of their parameter types. Caller has already checked that
10135 /// they have same number of parameters. If the parameters are different,
10136 /// ArgPos will have the parameter index of the first different parameter.
10137 /// If `Reversed` is true, the parameters of `NewType` will be compared in
10138 /// reverse order. That's useful if one of the functions is being used as a
10139 /// C++20 synthesized operator overload with a reversed parameter order.
10142 unsigned *ArgPos = nullptr,
10143 bool Reversed = false);
10144
10146 const FunctionProtoType *NewType,
10147 unsigned *ArgPos = nullptr,
10148 bool Reversed = false);
10149
10150 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
10151 const FunctionDecl *NewFunction,
10152 unsigned *ArgPos = nullptr,
10153 bool Reversed = false);
10154
10155 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
10156 /// function types. Catches different number of parameter, mismatch in
10157 /// parameter types, and different return types.
10159 QualType ToType);
10160
10161 /// CheckPointerConversion - Check the pointer conversion from the
10162 /// expression From to the type ToType. This routine checks for
10163 /// ambiguous or inaccessible derived-to-base pointer
10164 /// conversions for which IsPointerConversion has already returned
10165 /// true. It returns true and produces a diagnostic if there was an
10166 /// error, or returns false otherwise.
10167 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
10168 CXXCastPath &BasePath, bool IgnoreBaseAccess,
10169 bool Diagnose = true);
10170
10171 /// IsMemberPointerConversion - Determines whether the conversion of the
10172 /// expression From, which has the (possibly adjusted) type FromType, can be
10173 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
10174 /// If so, returns true and places the converted type (that might differ from
10175 /// ToType in its cv-qualifiers at some level) into ConvertedType.
10176 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
10177 bool InOverloadResolution,
10178 QualType &ConvertedType);
10179
10189 /// CheckMemberPointerConversion - Check the member pointer conversion from
10190 /// the expression From to the type ToType. This routine checks for ambiguous
10191 /// or virtual or inaccessible base-to-derived member pointer conversions for
10192 /// which IsMemberPointerConversion has already returned true. It produces a
10193 // diagnostic if there was an error.
10195 QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind,
10196 CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange,
10197 bool IgnoreBaseAccess, MemberPointerConversionDirection Direction);
10198
10199 /// IsQualificationConversion - Determines whether the conversion from
10200 /// an rvalue of type FromType to ToType is a qualification conversion
10201 /// (C++ 4.4).
10202 ///
10203 /// \param ObjCLifetimeConversion Output parameter that will be set to
10204 /// indicate when the qualification conversion involves a change in the
10205 /// Objective-C object lifetime.
10206 bool IsQualificationConversion(QualType FromType, QualType ToType,
10207 bool CStyle, bool &ObjCLifetimeConversion);
10208
10209 /// Determine whether the conversion from FromType to ToType is a valid
10210 /// conversion that strips "noexcept" or "noreturn" or "cfi_unchecked_callee"
10211 /// off the nested function type. This also checks if "cfi_unchecked_callee"
10212 /// was added to the function type. If "cfi_unchecked_callee" is added and
10213 /// `AddingCFIUncheckedCallee` is provided, it will be set to true. The same
10214 /// thing applies for `DiscardingCFIUncheckedCallee` if the attribute is
10215 /// discarded.
10216 bool IsFunctionConversion(QualType FromType, QualType ToType,
10217 bool *DiscardingCFIUncheckedCallee = nullptr,
10218 bool *AddingCFIUncheckedCallee = nullptr) const;
10219
10220 /// Same as `IsFunctionConversion`, but if this would return true, it sets
10221 /// `ResultTy` to `ToType`.
10222 bool TryFunctionConversion(QualType FromType, QualType ToType,
10223 QualType &ResultTy) const;
10224
10227 DeclarationName Name,
10228 OverloadCandidateSet &CandidateSet,
10229 FunctionDecl *Fn, MultiExprArg Args,
10230 bool IsMember = false);
10231
10233 FunctionDecl *Fun);
10235 Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl,
10237
10238 /// PerformContextuallyConvertToBool - Perform a contextual conversion
10239 /// of the expression From to bool (C++0x [conv]p3).
10241
10242 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
10243 /// conversion of the expression From to an Objective-C pointer type.
10244 /// Returns a valid but null ExprResult if no conversion sequence exists.
10246
10248 CCEKind CCE,
10249 NamedDecl *Dest = nullptr);
10250
10252 llvm::APSInt &Value, CCEKind CCE);
10254 APValue &Value, CCEKind CCE,
10255 NamedDecl *Dest = nullptr);
10256
10257 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10258 /// That is a converted constant expression
10259 /// (which was built with BuildConvertedConstantExpression)
10262 CCEKind CCE, bool RequireInt,
10263 const APValue &PreNarrowingValue);
10264
10265 /// Abstract base class used to perform a contextual implicit
10266 /// conversion from an expression to any type passing a filter.
10268 public:
10271
10275
10276 /// Determine whether the specified type is a valid destination type
10277 /// for this conversion.
10278 virtual bool match(QualType T) = 0;
10279
10280 /// Emits a diagnostic complaining that the expression does not have
10281 /// integral or enumeration type.
10283 QualType T) = 0;
10284
10285 /// Emits a diagnostic when the expression has incomplete class type.
10286 virtual SemaDiagnosticBuilder
10288
10289 /// Emits a diagnostic when the only matching conversion function
10290 /// is explicit.
10292 SourceLocation Loc,
10293 QualType T,
10294 QualType ConvTy) = 0;
10295
10296 /// Emits a note for the explicit conversion function.
10297 virtual SemaDiagnosticBuilder
10299
10300 /// Emits a diagnostic when there are multiple possible conversion
10301 /// functions.
10303 QualType T) = 0;
10304
10305 /// Emits a note for one of the candidate conversions.
10306 virtual SemaDiagnosticBuilder
10308
10309 /// Emits a diagnostic when we picked a conversion function
10310 /// (for cases when we are not allowed to pick a conversion function).
10312 SourceLocation Loc,
10313 QualType T,
10314 QualType ConvTy) = 0;
10315
10317 };
10318
10320 bool AllowScopedEnumerations;
10321
10322 public:
10323 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10324 bool SuppressConversion)
10326 AllowScopedEnumerations(AllowScopedEnumerations) {}
10327
10328 /// Match an integral or (possibly scoped) enumeration type.
10329 bool match(QualType T) override;
10330
10332 QualType T) override {
10333 return diagnoseNotInt(S, Loc, T);
10334 }
10335
10336 /// Emits a diagnostic complaining that the expression does not have
10337 /// integral or enumeration type.
10339 QualType T) = 0;
10340 };
10341
10342 /// Perform a contextual implicit conversion.
10345 ContextualImplicitConverter &Converter);
10346
10347 /// ReferenceCompareResult - Expresses the result of comparing two
10348 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10349 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10351 /// Ref_Incompatible - The two types are incompatible, so direct
10352 /// reference binding is not possible.
10354 /// Ref_Related - The two types are reference-related, which means
10355 /// that their unqualified forms (T1 and T2) are either the same
10356 /// or T1 is a base class of T2.
10358 /// Ref_Compatible - The two types are reference-compatible.
10360 };
10361
10362 // Fake up a scoped enumeration that still contextually converts to bool.
10364 /// The conversions that would be performed on an lvalue of type T2 when
10365 /// binding a reference of type T1 to it, as determined when evaluating
10366 /// whether T1 is reference-compatible with T2.
10377 };
10379
10380 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10381 /// determine whether they are reference-compatible,
10382 /// reference-related, or incompatible, for use in C++ initialization by
10383 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10384 /// type, and the first type (T1) is the pointee type of the reference
10385 /// type being initialized.
10388 ReferenceConversions *Conv = nullptr);
10389
10390 /// AddOverloadCandidate - Adds the given function to the set of
10391 /// candidate functions, using the given function call arguments. If
10392 /// @p SuppressUserConversions, then don't allow user-defined
10393 /// conversions via constructors or conversion operators.
10394 ///
10395 /// \param PartialOverloading true if we are performing "partial" overloading
10396 /// based on an incomplete set of function arguments. This feature is used by
10397 /// code completion.
10400 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10401 bool PartialOverloading = false, bool AllowExplicit = true,
10402 bool AllowExplicitConversion = false,
10403 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10404 ConversionSequenceList EarlyConversions = {},
10406 bool AggregateCandidateDeduction = false, bool StrictPackMatch = false);
10407
10408 /// Add all of the function declarations in the given function set to
10409 /// the overload candidate set.
10411 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10412 OverloadCandidateSet &CandidateSet,
10413 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10414 bool SuppressUserConversions = false, bool PartialOverloading = false,
10415 bool FirstArgumentIsBase = false);
10416
10417 /// AddMethodCandidate - Adds a named decl (which is some kind of
10418 /// method) as a method candidate to the given overload set.
10419 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10420 Expr::Classification ObjectClassification,
10421 ArrayRef<Expr *> Args,
10422 OverloadCandidateSet &CandidateSet,
10423 bool SuppressUserConversion = false,
10424 OverloadCandidateParamOrder PO = {});
10425
10426 /// AddMethodCandidate - Adds the given C++ member function to the set
10427 /// of candidate functions, using the given function call arguments
10428 /// and the object argument (@c Object). For example, in a call
10429 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10430 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10431 /// allow user-defined conversions via constructors or conversion
10432 /// operators.
10433 void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10434 CXXRecordDecl *ActingContext, QualType ObjectType,
10435 Expr::Classification ObjectClassification,
10436 ArrayRef<Expr *> Args,
10437 OverloadCandidateSet &CandidateSet,
10438 bool SuppressUserConversions = false,
10439 bool PartialOverloading = false,
10440 ConversionSequenceList EarlyConversions = {},
10442 bool StrictPackMatch = false);
10443
10444 /// Add a C++ member function template as a candidate to the candidate
10445 /// set, using template argument deduction to produce an appropriate member
10446 /// function template specialization.
10448 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10449 CXXRecordDecl *ActingContext,
10450 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10451 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10452 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10453 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10454
10455 /// Add a C++ function template specialization as a candidate
10456 /// in the candidate set, using template argument deduction to produce
10457 /// an appropriate function template specialization.
10459 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10460 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10461 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10462 bool PartialOverloading = false, bool AllowExplicit = true,
10463 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10465 bool AggregateCandidateDeduction = false);
10466
10468 /// Do not consider any user-defined conversions when constructing the
10469 /// initializing sequence.
10471
10472 /// Before constructing the initializing sequence, we check whether the
10473 /// parameter type and argument type contain any user defined conversions.
10474 /// If so, do not initialize them. This effectively bypasses some undesired
10475 /// instantiation before checking constaints, which might otherwise result
10476 /// in non-SFINAE errors e.g. recursive constraints.
10478
10485 };
10486
10487 /// Check that implicit conversion sequences can be formed for each argument
10488 /// whose corresponding parameter has a non-dependent type, per DR1391's
10489 /// [temp.deduct.call]p10.
10492 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10494 CheckNonDependentConversionsFlag UserConversionFlag,
10495 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10496 Expr::Classification ObjectClassification = {},
10497 OverloadCandidateParamOrder PO = {});
10498
10499 /// AddConversionCandidate - Add a C++ conversion function as a
10500 /// candidate in the candidate set (C++ [over.match.conv],
10501 /// C++ [over.match.copy]). From is the expression we're converting from,
10502 /// and ToType is the type that we're eventually trying to convert to
10503 /// (which may or may not be the same type as the type that the
10504 /// conversion function produces).
10506 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10507 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10508 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10509 bool AllowExplicit, bool AllowResultConversion = true,
10510 bool StrictPackMatch = false);
10511
10512 /// Adds a conversion function template specialization
10513 /// candidate to the overload set, using template argument deduction
10514 /// to deduce the template arguments of the conversion function
10515 /// template from the type that we are converting to (C++
10516 /// [temp.deduct.conv]).
10518 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10519 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10520 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10521 bool AllowExplicit, bool AllowResultConversion = true);
10522
10523 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10524 /// converts the given @c Object to a function pointer via the
10525 /// conversion function @c Conversion, and then attempts to call it
10526 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10527 /// the type of function that we'll eventually be calling.
10528 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10529 DeclAccessPair FoundDecl,
10530 CXXRecordDecl *ActingContext,
10531 const FunctionProtoType *Proto, Expr *Object,
10532 ArrayRef<Expr *> Args,
10533 OverloadCandidateSet &CandidateSet);
10534
10535 /// Add all of the non-member operator function declarations in the given
10536 /// function set to the overload candidate set.
10538 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10539 OverloadCandidateSet &CandidateSet,
10540 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10541
10542 /// Add overload candidates for overloaded operators that are
10543 /// member functions.
10544 ///
10545 /// Add the overloaded operator candidates that are member functions
10546 /// for the operator Op that was used in an operator expression such
10547 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10548 /// CandidateSet will store the added overload candidates. (C++
10549 /// [over.match.oper]).
10551 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10552 OverloadCandidateSet &CandidateSet,
10554
10555 /// AddBuiltinCandidate - Add a candidate for a built-in
10556 /// operator. ResultTy and ParamTys are the result and parameter types
10557 /// of the built-in candidate, respectively. Args and NumArgs are the
10558 /// arguments being passed to the candidate. IsAssignmentOperator
10559 /// should be true when this built-in candidate is an assignment
10560 /// operator. NumContextualBoolArguments is the number of arguments
10561 /// (at the beginning of the argument list) that will be contextually
10562 /// converted to bool.
10563 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10564 OverloadCandidateSet &CandidateSet,
10565 bool IsAssignmentOperator = false,
10566 unsigned NumContextualBoolArguments = 0);
10567
10568 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10569 /// operator overloads to the candidate set (C++ [over.built]), based
10570 /// on the operator @p Op and the arguments given. For example, if the
10571 /// operator is a binary '+', this routine might add "int
10572 /// operator+(int, int)" to cover integer addition.
10574 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10575 OverloadCandidateSet &CandidateSet);
10576
10577 /// Add function candidates found via argument-dependent lookup
10578 /// to the set of overloading candidates.
10579 ///
10580 /// This routine performs argument-dependent name lookup based on the
10581 /// given function name (which may also be an operator name) and adds
10582 /// all of the overload candidates found by ADL to the overload
10583 /// candidate set (C++ [basic.lookup.argdep]).
10585 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10586 TemplateArgumentListInfo *ExplicitTemplateArgs,
10587 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10588
10589 /// Check the enable_if expressions on the given function. Returns the first
10590 /// failing attribute, or NULL if they were all successful.
10591 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10592 ArrayRef<Expr *> Args,
10593 bool MissingImplicitThis = false);
10594
10595 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10596 /// non-ArgDependent DiagnoseIfAttrs.
10597 ///
10598 /// Argument-dependent diagnose_if attributes should be checked each time a
10599 /// function is used as a direct callee of a function call.
10600 ///
10601 /// Returns true if any errors were emitted.
10602 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10603 const Expr *ThisArg,
10604 ArrayRef<const Expr *> Args,
10605 SourceLocation Loc);
10606
10607 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10608 /// ArgDependent DiagnoseIfAttrs.
10609 ///
10610 /// Argument-independent diagnose_if attributes should be checked on every use
10611 /// of a function.
10612 ///
10613 /// Returns true if any errors were emitted.
10614 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10615 SourceLocation Loc);
10616
10617 /// Determine if \p A and \p B are equivalent internal linkage declarations
10618 /// from different modules, and thus an ambiguity error can be downgraded to
10619 /// an extension warning.
10620 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10621 const NamedDecl *B);
10623 SourceLocation Loc, const NamedDecl *D,
10624 ArrayRef<const NamedDecl *> Equiv);
10625
10626 // Emit as a 'note' the specific overload candidate
10628 const NamedDecl *Found, const FunctionDecl *Fn,
10630 QualType DestType = QualType(), bool TakingAddress = false);
10631
10632 // Emit as a series of 'note's all template and non-templates identified by
10633 // the expression Expr
10634 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10635 bool TakingAddress = false);
10636
10637 /// Returns whether the given function's address can be taken or not,
10638 /// optionally emitting a diagnostic if the address can't be taken.
10639 ///
10640 /// Returns false if taking the address of the function is illegal.
10641 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10642 bool Complain = false,
10643 SourceLocation Loc = SourceLocation());
10644
10645 // [PossiblyAFunctionType] --> [Return]
10646 // NonFunctionType --> NonFunctionType
10647 // R (A) --> R(A)
10648 // R (*)(A) --> R (A)
10649 // R (&)(A) --> R (A)
10650 // R (S::*)(A) --> R (A)
10651 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10652
10653 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10654 /// an overloaded function (C++ [over.over]), where @p From is an
10655 /// expression with overloaded function type and @p ToType is the type
10656 /// we're trying to resolve to. For example:
10657 ///
10658 /// @code
10659 /// int f(double);
10660 /// int f(int);
10661 ///
10662 /// int (*pfd)(double) = f; // selects f(double)
10663 /// @endcode
10664 ///
10665 /// This routine returns the resulting FunctionDecl if it could be
10666 /// resolved, and NULL otherwise. When @p Complain is true, this
10667 /// routine will emit diagnostics if there is an error.
10668 FunctionDecl *
10669 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10670 bool Complain, DeclAccessPair &Found,
10671 bool *pHadMultipleCandidates = nullptr);
10672
10673 /// Given an expression that refers to an overloaded function, try to
10674 /// resolve that function to a single function that can have its address
10675 /// taken. This will modify `Pair` iff it returns non-null.
10676 ///
10677 /// This routine can only succeed if from all of the candidates in the
10678 /// overload set for SrcExpr that can have their addresses taken, there is one
10679 /// candidate that is more constrained than the rest.
10680 FunctionDecl *
10681 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10682
10683 /// Given an overloaded function, tries to turn it into a non-overloaded
10684 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10685 /// will perform access checks, diagnose the use of the resultant decl, and,
10686 /// if requested, potentially perform a function-to-pointer decay.
10687 ///
10688 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10689 /// Otherwise, returns true. This may emit diagnostics and return true.
10691 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10692
10693 /// Given an expression that refers to an overloaded function, try to
10694 /// resolve that overloaded function expression down to a single function.
10695 ///
10696 /// This routine can only resolve template-ids that refer to a single function
10697 /// template, where that template-id refers to a single template whose
10698 /// template arguments are either provided by the template-id or have
10699 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10700 ///
10701 /// If no template-ids are found, no diagnostics are emitted and NULL is
10702 /// returned.
10704 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10705 TemplateSpecCandidateSet *FailedTSC = nullptr,
10706 bool ForTypeDeduction = false);
10707
10708 // Resolve and fix an overloaded expression that can be resolved
10709 // because it identifies a single function template specialization.
10710 //
10711 // Last three arguments should only be supplied if Complain = true
10712 //
10713 // Return true if it was logically possible to so resolve the
10714 // expression, regardless of whether or not it succeeded. Always
10715 // returns true if 'complain' is set.
10717 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10718 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10719 QualType DestTypeForComplaining = QualType(),
10720 unsigned DiagIDForComplaining = 0);
10721
10722 /// Add the overload candidates named by callee and/or found by argument
10723 /// dependent lookup to the given overload set.
10724 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10725 ArrayRef<Expr *> Args,
10726 OverloadCandidateSet &CandidateSet,
10727 bool PartialOverloading = false);
10728
10729 /// Add the call candidates from the given set of lookup results to the given
10730 /// overload set. Non-function lookup results are ignored.
10732 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10733 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10734
10735 // An enum used to represent the different possible results of building a
10736 // range-based for loop.
10742
10743 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10744 /// given LookupResult is non-empty, it is assumed to describe a member which
10745 /// will be invoked. Otherwise, the function will be found via argument
10746 /// dependent lookup.
10747 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10748 /// otherwise CallExpr is set to ExprError() and some non-success value
10749 /// is returned.
10751 SourceLocation RangeLoc,
10752 const DeclarationNameInfo &NameInfo,
10753 LookupResult &MemberLookup,
10754 OverloadCandidateSet *CandidateSet,
10755 Expr *Range, ExprResult *CallExpr);
10756
10757 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10758 /// (which eventually refers to the declaration Func) and the call
10759 /// arguments Args/NumArgs, attempt to resolve the function call down
10760 /// to a specific function. If overload resolution succeeds, returns
10761 /// the call expression produced by overload resolution.
10762 /// Otherwise, emits diagnostics and returns ExprError.
10764 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10765 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10766 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10767
10768 /// Constructs and populates an OverloadedCandidateSet from
10769 /// the given function.
10770 /// \returns true when an the ExprResult output parameter has been set.
10772 MultiExprArg Args, SourceLocation RParenLoc,
10773 OverloadCandidateSet *CandidateSet,
10775
10779 const UnresolvedSetImpl &Fns,
10780 bool PerformADL = true);
10781
10782 /// Create a unary operation that may resolve to an overloaded
10783 /// operator.
10784 ///
10785 /// \param OpLoc The location of the operator itself (e.g., '*').
10786 ///
10787 /// \param Opc The UnaryOperatorKind that describes this operator.
10788 ///
10789 /// \param Fns The set of non-member functions that will be
10790 /// considered by overload resolution. The caller needs to build this
10791 /// set based on the context using, e.g.,
10792 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10793 /// set should not contain any member functions; those will be added
10794 /// by CreateOverloadedUnaryOp().
10795 ///
10796 /// \param Input The input argument.
10799 const UnresolvedSetImpl &Fns, Expr *input,
10800 bool RequiresADL = true);
10801
10802 /// Perform lookup for an overloaded binary operator.
10805 const UnresolvedSetImpl &Fns,
10806 ArrayRef<Expr *> Args, bool RequiresADL = true);
10807
10808 /// Create a binary operation that may resolve to an overloaded
10809 /// operator.
10810 ///
10811 /// \param OpLoc The location of the operator itself (e.g., '+').
10812 ///
10813 /// \param Opc The BinaryOperatorKind that describes this operator.
10814 ///
10815 /// \param Fns The set of non-member functions that will be
10816 /// considered by overload resolution. The caller needs to build this
10817 /// set based on the context using, e.g.,
10818 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10819 /// set should not contain any member functions; those will be added
10820 /// by CreateOverloadedBinOp().
10821 ///
10822 /// \param LHS Left-hand argument.
10823 /// \param RHS Right-hand argument.
10824 /// \param PerformADL Whether to consider operator candidates found by ADL.
10825 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10826 /// C++20 operator rewrites.
10827 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
10828 /// the function in question. Such a function is never a candidate in
10829 /// our overload resolution. This also enables synthesizing a three-way
10830 /// comparison from < and == as described in C++20 [class.spaceship]p1.
10832 const UnresolvedSetImpl &Fns, Expr *LHS,
10833 Expr *RHS, bool RequiresADL = true,
10834 bool AllowRewrittenCandidates = true,
10835 FunctionDecl *DefaultedFn = nullptr);
10837 const UnresolvedSetImpl &Fns,
10838 Expr *LHS, Expr *RHS,
10839 FunctionDecl *DefaultedFn);
10840
10842 SourceLocation RLoc, Expr *Base,
10843 MultiExprArg Args);
10844
10845 /// BuildCallToMemberFunction - Build a call to a member
10846 /// function. MemExpr is the expression that refers to the member
10847 /// function (and includes the object parameter), Args/NumArgs are the
10848 /// arguments to the function call (not including the object
10849 /// parameter). The caller needs to validate that the member
10850 /// expression refers to a non-static member function or an overloaded
10851 /// member function.
10853 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
10854 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
10855 bool IsExecConfig = false, bool AllowRecovery = false);
10856
10857 /// BuildCallToObjectOfClassType - Build a call to an object of class
10858 /// type (C++ [over.call.object]), which can end up invoking an
10859 /// overloaded function call operator (@c operator()) or performing a
10860 /// user-defined conversion on the object argument.
10862 SourceLocation LParenLoc,
10863 MultiExprArg Args,
10864 SourceLocation RParenLoc);
10865
10866 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
10867 /// (if one exists), where @c Base is an expression of class type and
10868 /// @c Member is the name of the member we're trying to find.
10870 SourceLocation OpLoc,
10871 bool *NoArrowOperatorFound = nullptr);
10872
10875 bool HadMultipleCandidates);
10876
10877 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
10878 /// to a literal operator described by the provided lookup results.
10881 SourceLocation LitEndLoc,
10882 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10883
10884 /// FixOverloadedFunctionReference - E is an expression that refers to
10885 /// a C++ overloaded function (possibly with some parentheses and
10886 /// perhaps a '&' around it). We have resolved the overloaded function
10887 /// to the function declaration Fn, so patch up the expression E to
10888 /// refer (possibly indirectly) to Fn. Returns the new expr.
10890 FunctionDecl *Fn);
10892 DeclAccessPair FoundDecl,
10893 FunctionDecl *Fn);
10894
10895 /// - Returns a selector which best matches given argument list or
10896 /// nullptr if none could be found
10898 bool IsInstance,
10900
10901 ///@}
10902
10903 //
10904 //
10905 // -------------------------------------------------------------------------
10906 //
10907 //
10908
10909 /// \name Statements
10910 /// Implementations are in SemaStmt.cpp
10911 ///@{
10912
10913public:
10914 /// Stack of active SEH __finally scopes. Can be empty.
10916
10917 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
10919
10921 bool HasLeadingEmptyMacro = false);
10922
10924 SourceLocation EndLoc);
10926
10927 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
10928 /// whose result is unused, warn.
10929 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
10930
10931 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
10935 ArrayRef<Stmt *> Elts, bool isStmtExpr);
10936
10938
10941 SourceLocation DotDotDotLoc, ExprResult RHS,
10942 SourceLocation ColonLoc);
10943
10944 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
10945 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
10946
10948 SourceLocation ColonLoc, Stmt *SubStmt,
10949 Scope *CurScope);
10951 SourceLocation ColonLoc, Stmt *SubStmt);
10952
10954 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
10956 Stmt *SubStmt);
10957
10958 /// Check whether the given statement can have musttail applied to it,
10959 /// issuing a diagnostic and returning false if not. In the success case,
10960 /// the statement is rewritten to remove implicit nodes from the return
10961 /// value.
10962 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
10963
10965 SourceLocation LParenLoc, Stmt *InitStmt,
10967 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10969 SourceLocation LParenLoc, Stmt *InitStmt,
10971 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10972
10974
10976 SourceLocation LParenLoc, Stmt *InitStmt,
10978 SourceLocation RParenLoc);
10980 Stmt *Body);
10981
10982 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
10983 /// integer not in the range of enum values.
10984 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
10985 Expr *SrcExpr);
10986
10989 Stmt *Body);
10991 SourceLocation WhileLoc, SourceLocation CondLParen,
10992 Expr *Cond, SourceLocation CondRParen);
10993
10995 Stmt *First, ConditionResult Second,
10996 FullExprArg Third, SourceLocation RParenLoc,
10997 Stmt *Body);
10998
10999 /// In an Objective C collection iteration statement:
11000 /// for (x in y)
11001 /// x can be an arbitrary l-value expression. Bind it up as a
11002 /// full-expression.
11004
11006 /// Initial building of a for-range statement.
11008 /// Instantiation or recovery rebuild of a for-range statement. Don't
11009 /// attempt any typo-correction.
11011 /// Determining whether a for-range statement could be built. Avoid any
11012 /// unnecessary or irreversible actions.
11014 };
11015
11016 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
11017 ///
11018 /// C++11 [stmt.ranged]:
11019 /// A range-based for statement is equivalent to
11020 ///
11021 /// {
11022 /// auto && __range = range-init;
11023 /// for ( auto __begin = begin-expr,
11024 /// __end = end-expr;
11025 /// __begin != __end;
11026 /// ++__begin ) {
11027 /// for-range-declaration = *__begin;
11028 /// statement
11029 /// }
11030 /// }
11031 ///
11032 /// The body of the loop is not available yet, since it cannot be analysed
11033 /// until we have determined the type of the for-range-declaration.
11035 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
11036 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
11037 SourceLocation RParenLoc, BuildForRangeKind Kind,
11038 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11039
11040 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
11041 StmtResult BuildCXXForRangeStmt(
11042 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
11043 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
11044 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
11045 BuildForRangeKind Kind,
11046 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
11047
11048 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
11049 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
11050 /// body cannot be performed until after the type of the range variable is
11051 /// determined.
11052 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
11053
11054 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
11055 LabelDecl *TheDecl);
11056 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
11057 SourceLocation StarLoc, Expr *DestExp);
11058 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope,
11059 LabelDecl *Label, SourceLocation LabelLoc);
11060 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope,
11061 LabelDecl *Label, SourceLocation LabelLoc);
11062
11065
11068
11069 bool isMoveEligible() const { return S != None; };
11071 };
11073
11074 /// Determine whether the given expression might be move-eligible or
11075 /// copy-elidable in either a (co_)return statement or throw expression,
11076 /// without considering function return type, if applicable.
11077 ///
11078 /// \param E The expression being returned from the function or block,
11079 /// being thrown, or being co_returned from a coroutine. This expression
11080 /// might be modified by the implementation.
11081 ///
11082 /// \param Mode Overrides detection of current language mode
11083 /// and uses the rules for C++23.
11084 ///
11085 /// \returns An aggregate which contains the Candidate and isMoveEligible
11086 /// and isCopyElidable methods. If Candidate is non-null, it means
11087 /// isMoveEligible() would be true under the most permissive language
11088 /// standard.
11089 NamedReturnInfo getNamedReturnInfo(
11091
11092 /// Determine whether the given NRVO candidate variable is move-eligible or
11093 /// copy-elidable, without considering function return type.
11094 ///
11095 /// \param VD The NRVO candidate variable.
11096 ///
11097 /// \returns An aggregate which contains the Candidate and isMoveEligible
11098 /// and isCopyElidable methods. If Candidate is non-null, it means
11099 /// isMoveEligible() would be true under the most permissive language
11100 /// standard.
11101 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
11102
11103 /// Updates given NamedReturnInfo's move-eligible and
11104 /// copy-elidable statuses, considering the function
11105 /// return type criteria as applicable to return statements.
11106 ///
11107 /// \param Info The NamedReturnInfo object to update.
11108 ///
11109 /// \param ReturnType This is the return type of the function.
11110 /// \returns The copy elision candidate, in case the initial return expression
11111 /// was copy elidable, or nullptr otherwise.
11112 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
11113 QualType ReturnType);
11114
11115 /// Perform the initialization of a potentially-movable value, which
11116 /// is the result of return value.
11117 ///
11118 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
11119 /// treat returned lvalues as rvalues in certain cases (to prefer move
11120 /// construction), then falls back to treating them as lvalues if that failed.
11123 const NamedReturnInfo &NRInfo, Expr *Value,
11124 bool SupressSimplerImplicitMoves = false);
11125
11127
11128 /// Deduce the return type for a function from a returned expression, per
11129 /// C++1y [dcl.spec.auto]p6.
11131 SourceLocation ReturnLoc, Expr *RetExpr,
11132 const AutoType *AT);
11133
11134 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11135 Scope *CurScope);
11136 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
11137 bool AllowRecovery = false);
11138
11139 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
11140 /// for capturing scopes.
11142 NamedReturnInfo &NRInfo,
11143 bool SupressSimplerImplicitMoves);
11144
11145 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
11146 /// and creates a proper catch handler from them.
11148 Stmt *HandlerBlock);
11149
11150 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
11151 /// handlers and creates a try statement from them.
11153 ArrayRef<Stmt *> Handlers);
11154
11155 void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry);
11156
11157 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
11158 SourceLocation TryLoc, Stmt *TryBlock,
11159 Stmt *Handler);
11161 Stmt *Block);
11166
11168 bool IsIfExists,
11169 NestedNameSpecifierLoc QualifierLoc,
11170 DeclarationNameInfo NameInfo,
11171 Stmt *Nested);
11173 bool IsIfExists, CXXScopeSpec &SS,
11174 UnqualifiedId &Name, Stmt *Nested);
11175
11176 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11177 CapturedRegionKind Kind, unsigned NumParams);
11178 typedef std::pair<StringRef, QualType> CapturedParamNameType;
11179 void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
11180 CapturedRegionKind Kind,
11182 unsigned OpenMPCaptureLevel = 0);
11186 SourceLocation Loc,
11187 unsigned NumParams);
11188
11189private:
11190 /// Check whether the given statement can have musttail applied to it,
11191 /// issuing a diagnostic and returning false if not.
11192 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
11193
11194 /// Check if the given expression contains 'break' or 'continue'
11195 /// statement that produces control flow different from GCC.
11196 void CheckBreakContinueBinding(Expr *E);
11197
11198 ///@}
11199
11200 //
11201 //
11202 // -------------------------------------------------------------------------
11203 //
11204 //
11205
11206 /// \name `inline asm` Statement
11207 /// Implementations are in SemaStmtAsm.cpp
11208 ///@{
11209
11210public:
11211 ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel);
11212 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
11213 bool IsVolatile, unsigned NumOutputs,
11214 unsigned NumInputs, IdentifierInfo **Names,
11215 MultiExprArg Constraints, MultiExprArg Exprs,
11216 Expr *AsmString, MultiExprArg Clobbers,
11217 unsigned NumLabels, SourceLocation RParenLoc);
11218
11220 llvm::InlineAsmIdentifierInfo &Info);
11222 SourceLocation TemplateKWLoc,
11223 UnqualifiedId &Id,
11224 bool IsUnevaluatedContext);
11225 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
11226 SourceLocation AsmLoc);
11228 SourceLocation AsmLoc);
11230 ArrayRef<Token> AsmToks, StringRef AsmString,
11231 unsigned NumOutputs, unsigned NumInputs,
11232 ArrayRef<StringRef> Constraints,
11233 ArrayRef<StringRef> Clobbers,
11234 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
11235 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
11236 SourceLocation Location, bool AlwaysCreate);
11237
11238 ///@}
11239
11240 //
11241 //
11242 // -------------------------------------------------------------------------
11243 //
11244 //
11245
11246 /// \name Statement Attribute Handling
11247 /// Implementations are in SemaStmtAttr.cpp
11248 ///@{
11249
11250public:
11251 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11252 const AttributeCommonInfo &A);
11253 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11254 const AttributeCommonInfo &A);
11255
11256 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11258
11259 /// Process the attributes before creating an attributed statement. Returns
11260 /// the semantic attributes that have been processed.
11261 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11263
11265 SourceRange Range);
11267 const IdentifierInfo *AttrName,
11268 SourceRange Range);
11269
11270 ///@}
11271
11272 //
11273 //
11274 // -------------------------------------------------------------------------
11275 //
11276 //
11277
11278 /// \name C++ Templates
11279 /// Implementations are in SemaTemplate.cpp
11280 ///@{
11281
11282public:
11283 // Saves the current floating-point pragma stack and clear it in this Sema.
11285 public:
11287 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11288 S.FpPragmaStack.Stack.clear();
11289 }
11290 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11291
11292 private:
11293 Sema &S;
11295 };
11296
11298 CurFPFeatures = FPO;
11299 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11300 }
11301
11307
11308 /// The number of SFINAE diagnostics that have been trapped.
11310
11315
11316 typedef llvm::MapVector<const FunctionDecl *,
11317 std::unique_ptr<LateParsedTemplate>>
11320
11321 /// Determine the number of levels of enclosing template parameters. This is
11322 /// only usable while parsing. Note that this does not include dependent
11323 /// contexts in which no template parameters have yet been declared, such as
11324 /// in a terse function template or generic lambda before the first 'auto' is
11325 /// encountered.
11326 unsigned getTemplateDepth(Scope *S) const;
11327
11329 bool AllowFunctionTemplates = true,
11330 bool AllowDependent = true);
11332 bool AllowFunctionTemplates = true,
11333 bool AllowDependent = true,
11334 bool AllowNonTemplateFunctions = false);
11335 /// Try to interpret the lookup result D as a template-name.
11336 ///
11337 /// \param D A declaration found by name lookup.
11338 /// \param AllowFunctionTemplates Whether function templates should be
11339 /// considered valid results.
11340 /// \param AllowDependent Whether unresolved using declarations (that might
11341 /// name templates) should be considered valid results.
11343 bool AllowFunctionTemplates = true,
11344 bool AllowDependent = true);
11345
11347 /// Whether and why a template name is required in this lookup.
11349 public:
11350 /// Template name is required if TemplateKWLoc is valid.
11352 : TemplateKW(TemplateKWLoc) {}
11353 /// Template name is unconditionally required.
11355
11357 return TemplateKW.value_or(SourceLocation());
11358 }
11359 bool hasTemplateKeyword() const {
11360 return getTemplateKeywordLoc().isValid();
11361 }
11362 bool isRequired() const { return TemplateKW != SourceLocation(); }
11363 explicit operator bool() const { return isRequired(); }
11364
11365 private:
11366 std::optional<SourceLocation> TemplateKW;
11367 };
11368
11370 /// This is not assumed to be a template name.
11372 /// This is assumed to be a template name because lookup found nothing.
11374 /// This is assumed to be a template name because lookup found one or more
11375 /// functions (but no function templates).
11377 };
11378
11379 bool
11381 QualType ObjectType, bool EnteringContext,
11382 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11383 AssumedTemplateKind *ATK = nullptr,
11384 bool AllowTypoCorrection = true);
11385
11387 bool hasTemplateKeyword,
11388 const UnqualifiedId &Name,
11389 ParsedType ObjectType, bool EnteringContext,
11391 bool &MemberOfUnknownSpecialization,
11392 bool Disambiguation = false);
11393
11394 /// Try to resolve an undeclared template name as a type template.
11395 ///
11396 /// Sets II to the identifier corresponding to the template name, and updates
11397 /// Name to a corresponding (typo-corrected) type template name and TNK to
11398 /// the corresponding kind, if possible.
11400 TemplateNameKind &TNK,
11401 SourceLocation NameLoc,
11402 IdentifierInfo *&II);
11403
11404 /// Determine whether a particular identifier might be the name in a C++1z
11405 /// deduction-guide declaration.
11406 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11407 SourceLocation NameLoc, CXXScopeSpec &SS,
11408 ParsedTemplateTy *Template = nullptr);
11409
11411 SourceLocation IILoc, Scope *S,
11412 const CXXScopeSpec *SS,
11413 TemplateTy &SuggestedTemplate,
11414 TemplateNameKind &SuggestedKind);
11415
11416 /// Determine whether we would be unable to instantiate this template (because
11417 /// it either has no definition, or is in the process of being instantiated).
11419 SourceLocation PointOfInstantiation, NamedDecl *Instantiation,
11420 bool InstantiatedFromMember, const NamedDecl *Pattern,
11421 const NamedDecl *PatternDef, TemplateSpecializationKind TSK,
11422 bool Complain = true, bool *Unreachable = nullptr);
11423
11424 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11425 /// that the template parameter 'PrevDecl' is being shadowed by a new
11426 /// declaration at location Loc. Returns true to indicate that this is
11427 /// an error, and false otherwise.
11428 ///
11429 /// \param Loc The location of the declaration that shadows a template
11430 /// parameter.
11431 ///
11432 /// \param PrevDecl The template parameter that the declaration shadows.
11433 ///
11434 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11435 /// a warning for compatibility with older versions of clang.
11436 /// Ignored when MSVC compatibility is enabled.
11438 bool SupportedForCompatibility = false);
11439
11440 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11441 /// the parameter D to reference the templated declaration and return a
11442 /// pointer to the template declaration. Otherwise, do nothing to D and return
11443 /// null.
11445
11446 /// ActOnTypeParameter - Called when a C++ template type parameter
11447 /// (e.g., "typename T") has been parsed. Typename specifies whether
11448 /// the keyword "typename" was used to declare the type parameter
11449 /// (otherwise, "class" was used), and KeyLoc is the location of the
11450 /// "class" or "typename" keyword. ParamName is the name of the
11451 /// parameter (NULL indicates an unnamed template parameter) and
11452 /// ParamNameLoc is the location of the parameter name (if any).
11453 /// If the type parameter has a default argument, it will be added
11454 /// later via ActOnTypeParameterDefault.
11456 SourceLocation EllipsisLoc,
11457 SourceLocation KeyLoc,
11458 IdentifierInfo *ParamName,
11459 SourceLocation ParamNameLoc, unsigned Depth,
11460 unsigned Position, SourceLocation EqualLoc,
11461 ParsedType DefaultArg, bool HasTypeConstraint);
11462
11464
11465 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11467 TemplateTypeParmDecl *ConstrainedParameter,
11468 SourceLocation EllipsisLoc);
11469 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11471 TemplateTypeParmDecl *ConstrainedParameter,
11472 SourceLocation EllipsisLoc,
11473 bool AllowUnexpandedPack);
11474
11475 /// Attach a type-constraint to a template parameter.
11476 /// \returns true if an error occurred. This can happen if the
11477 /// immediately-declared constraint could not be formed (e.g. incorrect number
11478 /// of arguments for the named concept).
11480 DeclarationNameInfo NameInfo,
11481 TemplateDecl *NamedConcept, NamedDecl *FoundDecl,
11482 const TemplateArgumentListInfo *TemplateArgs,
11483 TemplateTypeParmDecl *ConstrainedParameter,
11484 SourceLocation EllipsisLoc);
11485
11487 NonTypeTemplateParmDecl *NewConstrainedParm,
11488 NonTypeTemplateParmDecl *OrigConstrainedParm,
11489 SourceLocation EllipsisLoc);
11490
11491 /// Require the given type to be a structural type, and diagnose if it is not.
11492 ///
11493 /// \return \c true if an error was produced.
11495
11496 /// Check that the type of a non-type template parameter is
11497 /// well-formed.
11498 ///
11499 /// \returns the (possibly-promoted) parameter type if valid;
11500 /// otherwise, produces a diagnostic and returns a NULL type.
11502 SourceLocation Loc);
11504
11506 unsigned Depth, unsigned Position,
11507 SourceLocation EqualLoc,
11508 Expr *DefaultArg);
11509
11510 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11511 /// parameter (e.g. T in template <template <typename> class T> class array)
11512 /// has been parsed. S is the current scope.
11514 Scope *S, SourceLocation TmpLoc, TemplateNameKind Kind,
11515 bool TypenameKeyword, TemplateParameterList *Params,
11516 SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11517 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11518 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11519
11520 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11521 /// constrained by RequiresClause, that contains the template parameters in
11522 /// Params.
11524 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11525 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11526 SourceLocation RAngleLoc, Expr *RequiresClause);
11527
11528 /// The context in which we are checking a template parameter list.
11530 // For this context, Class, Variable, TypeAlias, and non-pack Template
11531 // Template Parameters are treated uniformly.
11533
11540 };
11541
11542 /// Checks the validity of a template parameter list, possibly
11543 /// considering the template parameter list from a previous
11544 /// declaration.
11545 ///
11546 /// If an "old" template parameter list is provided, it must be
11547 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11548 /// template parameter list.
11549 ///
11550 /// \param NewParams Template parameter list for a new template
11551 /// declaration. This template parameter list will be updated with any
11552 /// default arguments that are carried through from the previous
11553 /// template parameter list.
11554 ///
11555 /// \param OldParams If provided, template parameter list from a
11556 /// previous declaration of the same template. Default template
11557 /// arguments will be merged from the old template parameter list to
11558 /// the new template parameter list.
11559 ///
11560 /// \param TPC Describes the context in which we are checking the given
11561 /// template parameter list.
11562 ///
11563 /// \param SkipBody If we might have already made a prior merged definition
11564 /// of this template visible, the corresponding body-skipping information.
11565 /// Default argument redefinition is not an error when skipping such a body,
11566 /// because (under the ODR) we can assume the default arguments are the same
11567 /// as the prior merged definition.
11568 ///
11569 /// \returns true if an error occurred, false otherwise.
11571 TemplateParameterList *OldParams,
11573 SkipBodyInfo *SkipBody = nullptr);
11574
11575 /// Match the given template parameter lists to the given scope
11576 /// specifier, returning the template parameter list that applies to the
11577 /// name.
11578 ///
11579 /// \param DeclStartLoc the start of the declaration that has a scope
11580 /// specifier or a template parameter list.
11581 ///
11582 /// \param DeclLoc The location of the declaration itself.
11583 ///
11584 /// \param SS the scope specifier that will be matched to the given template
11585 /// parameter lists. This scope specifier precedes a qualified name that is
11586 /// being declared.
11587 ///
11588 /// \param TemplateId The template-id following the scope specifier, if there
11589 /// is one. Used to check for a missing 'template<>'.
11590 ///
11591 /// \param ParamLists the template parameter lists, from the outermost to the
11592 /// innermost template parameter lists.
11593 ///
11594 /// \param IsFriend Whether to apply the slightly different rules for
11595 /// matching template parameters to scope specifiers in friend
11596 /// declarations.
11597 ///
11598 /// \param IsMemberSpecialization will be set true if the scope specifier
11599 /// denotes a fully-specialized type, and therefore this is a declaration of
11600 /// a member specialization.
11601 ///
11602 /// \returns the template parameter list, if any, that corresponds to the
11603 /// name that is preceded by the scope specifier @p SS. This template
11604 /// parameter list may have template parameters (if we're declaring a
11605 /// template) or may have no template parameters (if we're declaring a
11606 /// template specialization), or may be NULL (if what we're declaring isn't
11607 /// itself a template).
11609 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11610 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11611 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11612 bool &IsMemberSpecialization, bool &Invalid,
11613 bool SuppressDiagnostic = false);
11614
11615 /// Returns the template parameter list with all default template argument
11616 /// information.
11618
11620 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11621 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11622 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11623 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11624 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11625 TemplateParameterList **OuterTemplateParamLists,
11626 SkipBodyInfo *SkipBody = nullptr);
11627
11628 /// Translates template arguments as provided by the parser
11629 /// into template arguments used by semantic analysis.
11632
11633 /// Convert a parsed type into a parsed template argument. This is mostly
11634 /// trivial, except that we may have parsed a C++17 deduced class template
11635 /// specialization type, in which case we should form a template template
11636 /// argument instead of a type template argument.
11638
11640
11643 SourceLocation TemplateLoc,
11644 TemplateArgumentListInfo &TemplateArgs,
11645 Scope *Scope, bool ForNestedNameSpecifier);
11646
11648 ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword,
11649 SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS,
11650 SourceLocation TemplateKWLoc, TemplateTy Template,
11651 const IdentifierInfo *TemplateII,
11652 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11653 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11654 bool IsCtorOrDtorName = false, bool IsClassName = false,
11655 ImplicitTypenameContext AllowImplicitTypename =
11657
11658 /// Parsed an elaborated-type-specifier that refers to a template-id,
11659 /// such as \c class T::template apply<U>.
11661 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11662 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11663 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11664 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11665
11668 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11670
11671 /// Get the specialization of the given variable template corresponding to
11672 /// the specified argument list, or a null-but-valid result if the arguments
11673 /// are dependent.
11675 SourceLocation TemplateLoc,
11676 SourceLocation TemplateNameLoc,
11677 const TemplateArgumentListInfo &TemplateArgs,
11678 bool SetWrittenArgs);
11679
11680 /// Form a reference to the specialization of the given variable template
11681 /// corresponding to the specified argument list, or a null-but-valid result
11682 /// if the arguments are dependent.
11684 const DeclarationNameInfo &NameInfo,
11686 SourceLocation TemplateLoc,
11687 const TemplateArgumentListInfo *TemplateArgs);
11688
11690 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
11692 const TemplateArgumentListInfo *TemplateArgs);
11693
11695 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11696 const DeclarationNameInfo &ConceptNameInfo,
11697 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
11698 const TemplateArgumentListInfo *TemplateArgs);
11699
11702 bool TemplateKeyword, TemplateDecl *TD,
11703 SourceLocation Loc);
11704
11706 SourceLocation TemplateKWLoc, LookupResult &R,
11707 bool RequiresADL,
11708 const TemplateArgumentListInfo *TemplateArgs);
11709
11710 // We actually only call this from template instantiation.
11713 const DeclarationNameInfo &NameInfo,
11714 const TemplateArgumentListInfo *TemplateArgs,
11715 bool IsAddressOfOperand);
11716
11717 /// Form a template name from a name that is syntactically required to name a
11718 /// template, either due to use of the 'template' keyword or because a name in
11719 /// this syntactic context is assumed to name a template (C++
11720 /// [temp.names]p2-4).
11721 ///
11722 /// This action forms a template name given the name of the template and its
11723 /// optional scope specifier. This is used when the 'template' keyword is used
11724 /// or when the parsing context unambiguously treats a following '<' as
11725 /// introducing a template argument list. Note that this may produce a
11726 /// non-dependent template name if we can perform the lookup now and identify
11727 /// the named template.
11728 ///
11729 /// For example, given "x.MetaFun::template apply", the scope specifier
11730 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11731 /// of the "template" keyword, and "apply" is the \p Name.
11733 SourceLocation TemplateKWLoc,
11734 const UnqualifiedId &Name,
11735 ParsedType ObjectType,
11736 bool EnteringContext, TemplateTy &Template,
11737 bool AllowInjectedClassName = false);
11738
11740 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11741 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11743 MultiTemplateParamsArg TemplateParameterLists,
11744 SkipBodyInfo *SkipBody = nullptr);
11745
11746 /// Check the non-type template arguments of a class template
11747 /// partial specialization according to C++ [temp.class.spec]p9.
11748 ///
11749 /// \param TemplateNameLoc the location of the template name.
11750 /// \param PrimaryTemplate the template parameters of the primary class
11751 /// template.
11752 /// \param NumExplicit the number of explicitly-specified template arguments.
11753 /// \param TemplateArgs the template arguments of the class template
11754 /// partial specialization.
11755 ///
11756 /// \returns \c true if there was an error, \c false otherwise.
11758 TemplateDecl *PrimaryTemplate,
11759 unsigned NumExplicitArgs,
11765
11767 MultiTemplateParamsArg TemplateParameterLists,
11768 Declarator &D);
11769
11770 /// Diagnose cases where we have an explicit template specialization
11771 /// before/after an explicit template instantiation, producing diagnostics
11772 /// for those cases where they are required and determining whether the
11773 /// new specialization/instantiation will have any effect.
11774 ///
11775 /// \param NewLoc the location of the new explicit specialization or
11776 /// instantiation.
11777 ///
11778 /// \param NewTSK the kind of the new explicit specialization or
11779 /// instantiation.
11780 ///
11781 /// \param PrevDecl the previous declaration of the entity.
11782 ///
11783 /// \param PrevTSK the kind of the old explicit specialization or
11784 /// instantiatin.
11785 ///
11786 /// \param PrevPointOfInstantiation if valid, indicates where the previous
11787 /// declaration was instantiated (either implicitly or explicitly).
11788 ///
11789 /// \param HasNoEffect will be set to true to indicate that the new
11790 /// specialization or instantiation has no effect and should be ignored.
11791 ///
11792 /// \returns true if there was an error that should prevent the introduction
11793 /// of the new declaration into the AST, false otherwise.
11795 SourceLocation NewLoc,
11796 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
11797 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
11798 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
11799
11800 /// Perform semantic analysis for the given dependent function
11801 /// template specialization.
11802 ///
11803 /// The only possible way to get a dependent function template specialization
11804 /// is with a friend declaration, like so:
11805 ///
11806 /// \code
11807 /// template <class T> void foo(T);
11808 /// template <class T> class A {
11809 /// friend void foo<>(T);
11810 /// };
11811 /// \endcode
11812 ///
11813 /// There really isn't any useful analysis we can do here, so we
11814 /// just store the information.
11816 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
11818
11819 /// Perform semantic analysis for the given function template
11820 /// specialization.
11821 ///
11822 /// This routine performs all of the semantic analysis required for an
11823 /// explicit function template specialization. On successful completion,
11824 /// the function declaration \p FD will become a function template
11825 /// specialization.
11826 ///
11827 /// \param FD the function declaration, which will be updated to become a
11828 /// function template specialization.
11829 ///
11830 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
11831 /// if any. Note that this may be valid info even when 0 arguments are
11832 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
11833 /// as it anyway contains info on the angle brackets locations.
11834 ///
11835 /// \param Previous the set of declarations that may be specialized by
11836 /// this function specialization.
11837 ///
11838 /// \param QualifiedFriend whether this is a lookup for a qualified friend
11839 /// declaration with no explicit template argument list that might be
11840 /// befriending a function template specialization.
11842 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
11843 LookupResult &Previous, bool QualifiedFriend = false);
11844
11845 /// Perform semantic analysis for the given non-template member
11846 /// specialization.
11847 ///
11848 /// This routine performs all of the semantic analysis required for an
11849 /// explicit member function specialization. On successful completion,
11850 /// the function declaration \p FD will become a member function
11851 /// specialization.
11852 ///
11853 /// \param Member the member declaration, which will be updated to become a
11854 /// specialization.
11855 ///
11856 /// \param Previous the set of declarations, one of which may be specialized
11857 /// by this function specialization; the set will be modified to contain the
11858 /// redeclared member.
11861
11862 // Explicit instantiation of a class template specialization
11864 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
11865 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
11866 TemplateTy Template, SourceLocation TemplateNameLoc,
11867 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
11868 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
11869
11870 // Explicit instantiation of a member class of a class template.
11872 SourceLocation TemplateLoc,
11873 unsigned TagSpec, SourceLocation KWLoc,
11874 CXXScopeSpec &SS, IdentifierInfo *Name,
11875 SourceLocation NameLoc,
11876 const ParsedAttributesView &Attr);
11877
11879 SourceLocation TemplateLoc,
11880 Declarator &D);
11881
11882 /// If the given template parameter has a default template
11883 /// argument, substitute into that default template argument and
11884 /// return the corresponding template argument.
11886 TemplateDecl *Template, SourceLocation TemplateKWLoc,
11887 SourceLocation TemplateNameLoc, SourceLocation RAngleLoc, Decl *Param,
11888 ArrayRef<TemplateArgument> SugaredConverted,
11889 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
11890
11891 /// Returns the top most location responsible for the definition of \p N.
11892 /// If \p N is a a template specialization, this is the location
11893 /// of the top of the instantiation stack.
11894 /// Otherwise, the location of \p N is returned.
11896
11897 /// Specifies the context in which a particular template
11898 /// argument is being checked.
11900 /// The template argument was specified in the code or was
11901 /// instantiated with some deduced template arguments.
11903
11904 /// The template argument was deduced via template argument
11905 /// deduction.
11907
11908 /// The template argument was deduced from an array bound
11909 /// via template argument deduction.
11911 };
11912
11920
11921 /// The checked, converted argument will be added to the
11922 /// end of these vectors.
11924
11925 /// The check is being performed in the context of partial ordering.
11927
11928 /// If true, assume these template arguments are
11929 /// the injected template arguments for a template template parameter.
11930 /// This will relax the requirement that all its possible uses are valid:
11931 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11932 /// during instantiation.
11934
11935 /// Is set to true when, in the context of TTP matching, a pack parameter
11936 /// matches non-pack arguments.
11937 bool StrictPackMatch = false;
11938 };
11939
11940 /// Check that the given template argument corresponds to the given
11941 /// template parameter.
11942 ///
11943 /// \param Param The template parameter against which the argument will be
11944 /// checked.
11945 ///
11946 /// \param Arg The template argument, which may be updated due to conversions.
11947 ///
11948 /// \param Template The template in which the template argument resides.
11949 ///
11950 /// \param TemplateLoc The location of the template name for the template
11951 /// whose argument list we're matching.
11952 ///
11953 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
11954 /// the template argument list.
11955 ///
11956 /// \param ArgumentPackIndex The index into the argument pack where this
11957 /// argument will be placed. Only valid if the parameter is a parameter pack.
11958 ///
11959 /// \param CTAK Describes how we arrived at this particular template argument:
11960 /// explicitly written, deduced, etc.
11961 ///
11962 /// \returns true on error, false otherwise.
11964 NamedDecl *Template, SourceLocation TemplateLoc,
11965 SourceLocation RAngleLoc,
11966 unsigned ArgumentPackIndex,
11969
11970 /// Check that the given template arguments can be provided to
11971 /// the given template, converting the arguments along the way.
11972 ///
11973 /// \param Template The template to which the template arguments are being
11974 /// provided.
11975 ///
11976 /// \param TemplateLoc The location of the template name in the source.
11977 ///
11978 /// \param TemplateArgs The list of template arguments. If the template is
11979 /// a template template parameter, this function may extend the set of
11980 /// template arguments to also include substituted, defaulted template
11981 /// arguments.
11982 ///
11983 /// \param PartialTemplateArgs True if the list of template arguments is
11984 /// intentionally partial, e.g., because we're checking just the initial
11985 /// set of template arguments.
11986 ///
11987 /// \param Converted Will receive the converted, canonicalized template
11988 /// arguments.
11989 ///
11990 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
11991 /// contain the converted forms of the template arguments as written.
11992 /// Otherwise, \p TemplateArgs will not be modified.
11993 ///
11994 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
11995 /// receive true if the cause for the error is the associated constraints of
11996 /// the template not being satisfied by the template arguments.
11997 ///
11998 /// \param DefaultArgs any default arguments from template specialization
11999 /// deduction.
12000 ///
12001 /// \returns true if an error occurred, false otherwise.
12003 SourceLocation TemplateLoc,
12004 TemplateArgumentListInfo &TemplateArgs,
12005 const DefaultArguments &DefaultArgs,
12006 bool PartialTemplateArgs,
12008 bool UpdateArgsWithConversions = true,
12009 bool *ConstraintsNotSatisfied = nullptr);
12010
12013 SmallVectorImpl<TemplateArgument> &SugaredConverted,
12014 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
12015
12016 /// Check a template argument against its corresponding
12017 /// template type parameter.
12018 ///
12019 /// This routine implements the semantics of C++ [temp.arg.type]. It
12020 /// returns true if an error occurred, and false otherwise.
12022
12023 /// Check a template argument against its corresponding
12024 /// non-type template parameter.
12025 ///
12026 /// This routine implements the semantics of C++ [temp.arg.nontype].
12027 /// If an error occurred, it returns ExprError(); otherwise, it
12028 /// returns the converted template argument. \p ParamType is the
12029 /// type of the non-type template parameter after it has been instantiated.
12031 QualType InstantiatedParamType, Expr *Arg,
12032 TemplateArgument &SugaredConverted,
12033 TemplateArgument &CanonicalConverted,
12034 bool StrictCheck,
12036
12037 /// Check a template argument against its corresponding
12038 /// template template parameter.
12039 ///
12040 /// This routine implements the semantics of C++ [temp.arg.template].
12041 /// It returns true if an error occurred, and false otherwise.
12043 TemplateParameterList *Params,
12045 bool PartialOrdering,
12046 bool *StrictPackMatch);
12047
12050 const TemplateArgumentLoc &Arg);
12051
12053 std::optional<SourceRange> ParamRange = {});
12055
12056 /// Given a non-type template argument that refers to a
12057 /// declaration and the type of its corresponding non-type template
12058 /// parameter, produce an expression that properly refers to that
12059 /// declaration.
12060 /// FIXME: This is used in some contexts where the resulting expression
12061 /// doesn't need to live too long. It would be useful if this function
12062 /// could return a temporary expression.
12064 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
12065 NamedDecl *TemplateParam = nullptr);
12068 SourceLocation Loc);
12069
12070 /// Enumeration describing how template parameter lists are compared
12071 /// for equality.
12073 /// We are matching the template parameter lists of two templates
12074 /// that might be redeclarations.
12075 ///
12076 /// \code
12077 /// template<typename T> struct X;
12078 /// template<typename T> struct X;
12079 /// \endcode
12081
12082 /// We are matching the template parameter lists of two template
12083 /// template parameters as part of matching the template parameter lists
12084 /// of two templates that might be redeclarations.
12085 ///
12086 /// \code
12087 /// template<template<int I> class TT> struct X;
12088 /// template<template<int Value> class Other> struct X;
12089 /// \endcode
12091
12092 /// We are determining whether the template-parameters are equivalent
12093 /// according to C++ [temp.over.link]/6. This comparison does not consider
12094 /// constraints.
12095 ///
12096 /// \code
12097 /// template<C1 T> void f(T);
12098 /// template<C2 T> void f(T);
12099 /// \endcode
12101 };
12102
12103 // A struct to represent the 'new' declaration, which is either itself just
12104 // the named decl, or the important information we need about it in order to
12105 // do constraint comparisons.
12107 const NamedDecl *ND = nullptr;
12108 const DeclContext *DC = nullptr;
12109 const DeclContext *LexicalDC = nullptr;
12110 SourceLocation Loc;
12111
12112 public:
12115 const DeclContext *LexicalDeclCtx,
12116 SourceLocation Loc)
12117
12118 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
12119 assert(DC && LexicalDC &&
12120 "Constructor only for cases where we have the information to put "
12121 "in here");
12122 }
12123
12124 // If this was constructed with no information, we cannot do substitution
12125 // for constraint comparison, so make sure we can check that.
12126 bool isInvalid() const { return !ND && !DC; }
12127
12128 const NamedDecl *getDecl() const { return ND; }
12129
12130 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
12131
12133 return ND ? ND->getLexicalDeclContext() : LexicalDC;
12134 }
12135
12137 return ND ? ND->getDeclContext() : DC;
12138 }
12139
12140 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
12141 };
12142
12143 /// Determine whether the given template parameter lists are
12144 /// equivalent.
12145 ///
12146 /// \param New The new template parameter list, typically written in the
12147 /// source code as part of a new template declaration.
12148 ///
12149 /// \param Old The old template parameter list, typically found via
12150 /// name lookup of the template declared with this template parameter
12151 /// list.
12152 ///
12153 /// \param Complain If true, this routine will produce a diagnostic if
12154 /// the template parameter lists are not equivalent.
12155 ///
12156 /// \param Kind describes how we are to match the template parameter lists.
12157 ///
12158 /// \param TemplateArgLoc If this source location is valid, then we
12159 /// are actually checking the template parameter list of a template
12160 /// argument (New) against the template parameter list of its
12161 /// corresponding template template parameter (Old). We produce
12162 /// slightly different diagnostics in this scenario.
12163 ///
12164 /// \returns True if the template parameter lists are equal, false
12165 /// otherwise.
12167 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
12168 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
12170 SourceLocation TemplateArgLoc = SourceLocation());
12171
12173 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
12175 SourceLocation TemplateArgLoc = SourceLocation()) {
12176 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
12177 Kind, TemplateArgLoc);
12178 }
12179
12180 /// Check whether a template can be declared within this scope.
12181 ///
12182 /// If the template declaration is valid in this scope, returns
12183 /// false. Otherwise, issues a diagnostic and returns true.
12184 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
12185
12186 /// Called when the parser has parsed a C++ typename
12187 /// specifier, e.g., "typename T::type".
12188 ///
12189 /// \param S The scope in which this typename type occurs.
12190 /// \param TypenameLoc the location of the 'typename' keyword
12191 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12192 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
12193 /// \param IdLoc the location of the identifier.
12194 /// \param IsImplicitTypename context where T::type refers to a type.
12196 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
12197 const IdentifierInfo &II, SourceLocation IdLoc,
12199
12200 /// Called when the parser has parsed a C++ typename
12201 /// specifier that ends in a template-id, e.g.,
12202 /// "typename MetaFun::template apply<T1, T2>".
12203 ///
12204 /// \param S The scope in which this typename type occurs.
12205 /// \param TypenameLoc the location of the 'typename' keyword
12206 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
12207 /// \param TemplateLoc the location of the 'template' keyword, if any.
12208 /// \param TemplateName The template name.
12209 /// \param TemplateII The identifier used to name the template.
12210 /// \param TemplateIILoc The location of the template name.
12211 /// \param LAngleLoc The location of the opening angle bracket ('<').
12212 /// \param TemplateArgs The template arguments.
12213 /// \param RAngleLoc The location of the closing angle bracket ('>').
12215 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
12216 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
12217 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
12218 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
12219 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
12220
12222 SourceLocation KeywordLoc,
12223 NestedNameSpecifierLoc QualifierLoc,
12224 const IdentifierInfo &II, SourceLocation IILoc,
12225 TypeSourceInfo **TSI, bool DeducedTSTContext);
12226
12228 SourceLocation KeywordLoc,
12229 NestedNameSpecifierLoc QualifierLoc,
12230 const IdentifierInfo &II, SourceLocation IILoc,
12231 bool DeducedTSTContext = true);
12232
12233 /// Rebuilds a type within the context of the current instantiation.
12234 ///
12235 /// The type \p T is part of the type of an out-of-line member definition of
12236 /// a class template (or class template partial specialization) that was
12237 /// parsed and constructed before we entered the scope of the class template
12238 /// (or partial specialization thereof). This routine will rebuild that type
12239 /// now that we have entered the declarator's scope, which may produce
12240 /// different canonical types, e.g.,
12241 ///
12242 /// \code
12243 /// template<typename T>
12244 /// struct X {
12245 /// typedef T* pointer;
12246 /// pointer data();
12247 /// };
12248 ///
12249 /// template<typename T>
12250 /// typename X<T>::pointer X<T>::data() { ... }
12251 /// \endcode
12252 ///
12253 /// Here, the type "typename X<T>::pointer" will be created as a
12254 /// DependentNameType, since we do not know that we can look into X<T> when we
12255 /// parsed the type. This function will rebuild the type, performing the
12256 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
12257 /// canonical type is the same as the canonical type of T*, allowing the
12258 /// return types of the out-of-line definition and the declaration to match.
12260 SourceLocation Loc,
12261 DeclarationName Name);
12263
12265
12266 /// Rebuild the template parameters now that we know we're in a current
12267 /// instantiation.
12268 bool
12270
12271 /// Produces a formatted string that describes the binding of
12272 /// template parameters to template arguments.
12273 std::string
12275 const TemplateArgumentList &Args);
12276
12277 std::string
12279 const TemplateArgument *Args,
12280 unsigned NumArgs);
12281
12285
12286 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12287 /// was just parsed. This is only possible with an explicit scope
12288 /// specifier naming a dependent type.
12290 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12291 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12292 const TemplateArgumentListInfo *TemplateArgs);
12293
12296 SourceLocation TemplateKWLoc,
12297 const DeclarationNameInfo &NameInfo,
12298 const TemplateArgumentListInfo *TemplateArgs);
12299
12300 // Calculates whether the expression Constraint depends on an enclosing
12301 // template, for the purposes of [temp.friend] p9.
12302 // TemplateDepth is the 'depth' of the friend function, which is used to
12303 // compare whether a declaration reference is referring to a containing
12304 // template, or just the current friend function. A 'lower' TemplateDepth in
12305 // the AST refers to a 'containing' template. As the constraint is
12306 // uninstantiated, this is relative to the 'top' of the TU.
12307 bool
12309 unsigned TemplateDepth,
12310 const Expr *Constraint);
12311
12312 /// Find the failed Boolean condition within a given Boolean
12313 /// constant expression, and describe it with a string.
12314 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12315
12317
12319 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12320 const IdentifierInfo *Name, SourceLocation NameLoc);
12321
12323 Expr *ConstraintExpr,
12324 const ParsedAttributesView &Attrs);
12325
12327 bool &AddToScope);
12329
12330 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12331 const CXXScopeSpec &SS,
12332 const IdentifierInfo *Name,
12333 SourceLocation TagLoc, SourceLocation NameLoc);
12334
12336 CachedTokens &Toks);
12339
12340 /// We've found a use of a templated declaration that would trigger an
12341 /// implicit instantiation. Check that any relevant explicit specializations
12342 /// and partial specializations are visible/reachable, and diagnose if not.
12345
12346 ///@}
12347
12348 //
12349 //
12350 // -------------------------------------------------------------------------
12351 //
12352 //
12353
12354 /// \name C++ Template Argument Deduction
12355 /// Implementations are in SemaTemplateDeduction.cpp
12356 ///@{
12357
12358public:
12359 /// When true, access checking violations are treated as SFINAE
12360 /// failures rather than hard errors.
12362
12363 /// RAII class used to determine whether SFINAE has
12364 /// trapped any errors that occur during template argument
12365 /// deduction.
12367 Sema &SemaRef;
12368 unsigned PrevSFINAEErrors;
12369 bool PrevInNonInstantiationSFINAEContext;
12370 bool PrevAccessCheckingSFINAE;
12371 bool PrevLastDiagnosticIgnored;
12372
12373 public:
12374 /// \param ForValidityCheck If true, discard all diagnostics (from the
12375 /// immediate context) instead of adding them to the currently active
12376 /// \ref TemplateDeductionInfo (as returned by \ref isSFINAEContext).
12377 explicit SFINAETrap(Sema &SemaRef, bool ForValidityCheck = false)
12378 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
12379 PrevInNonInstantiationSFINAEContext(
12381 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
12382 PrevLastDiagnosticIgnored(
12383 SemaRef.getDiagnostics().isLastDiagnosticIgnored()) {
12384 if (ForValidityCheck || !SemaRef.isSFINAEContext())
12385 SemaRef.InNonInstantiationSFINAEContext = true;
12386 SemaRef.AccessCheckingSFINAE = ForValidityCheck;
12387 }
12388
12390 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
12391 SemaRef.InNonInstantiationSFINAEContext =
12392 PrevInNonInstantiationSFINAEContext;
12393 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
12394 SemaRef.getDiagnostics().setLastDiagnosticIgnored(
12395 PrevLastDiagnosticIgnored);
12396 }
12397
12398 /// Determine whether any SFINAE errors have been trapped.
12399 bool hasErrorOccurred() const {
12400 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
12401 }
12402 };
12403
12404 /// RAII class used to indicate that we are performing provisional
12405 /// semantic analysis to determine the validity of a construct, so
12406 /// typo-correction and diagnostics in the immediate context (not within
12407 /// implicitly-instantiated templates) should be suppressed.
12409 Sema &SemaRef;
12410 // FIXME: Using a SFINAETrap for this is a hack.
12411 SFINAETrap Trap;
12412 bool PrevDisableTypoCorrection;
12413
12414 public:
12415 explicit TentativeAnalysisScope(Sema &SemaRef)
12416 : SemaRef(SemaRef), Trap(SemaRef, /*ForValidityCheck=*/true),
12417 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12418 SemaRef.DisableTypoCorrection = true;
12419 }
12421 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12422 }
12423 };
12424
12425 /// For each declaration that involved template argument deduction, the
12426 /// set of diagnostics that were suppressed during that template argument
12427 /// deduction.
12428 ///
12429 /// FIXME: Serialize this structure to the AST file.
12430 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12433
12434 /// Compare types for equality with respect to possibly compatible
12435 /// function types (noreturn adjustment, implicit calling conventions). If any
12436 /// of parameter and argument is not a function, just perform type comparison.
12437 ///
12438 /// \param P the template parameter type.
12439 ///
12440 /// \param A the argument type.
12442
12443 /// Allocate a TemplateArgumentLoc where all locations have
12444 /// been initialized to the given location.
12445 ///
12446 /// \param Arg The template argument we are producing template argument
12447 /// location information for.
12448 ///
12449 /// \param NTTPType For a declaration template argument, the type of
12450 /// the non-type template parameter that corresponds to this template
12451 /// argument. Can be null if no type sugar is available to add to the
12452 /// type from the template argument.
12453 ///
12454 /// \param Loc The source location to use for the resulting template
12455 /// argument.
12458 SourceLocation Loc,
12459 NamedDecl *TemplateParam = nullptr);
12460
12461 /// Get a template argument mapping the given template parameter to itself,
12462 /// e.g. for X in \c template<int X>, this would return an expression template
12463 /// argument referencing X.
12465 SourceLocation Location);
12466
12467 /// Adjust the type \p ArgFunctionType to match the calling convention,
12468 /// noreturn, and optionally the exception specification of \p FunctionType.
12469 /// Deduction often wants to ignore these properties when matching function
12470 /// types.
12472 bool AdjustExceptionSpec = false);
12473
12476 ArrayRef<TemplateArgument> TemplateArgs,
12478
12481 ArrayRef<TemplateArgument> TemplateArgs,
12483
12484 /// Deduce the template arguments of the given template from \p FromType.
12485 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12486 /// [over.match.class.deduct]p4.
12487 ///
12488 /// It only supports class or type alias templates.
12492
12497 bool NumberOfArgumentsMustMatch);
12498
12499 /// Substitute the explicitly-provided template arguments into the
12500 /// given function template according to C++ [temp.arg.explicit].
12501 ///
12502 /// \param FunctionTemplate the function template into which the explicit
12503 /// template arguments will be substituted.
12504 ///
12505 /// \param ExplicitTemplateArgs the explicitly-specified template
12506 /// arguments.
12507 ///
12508 /// \param Deduced the deduced template arguments, which will be populated
12509 /// with the converted and checked explicit template arguments.
12510 ///
12511 /// \param ParamTypes will be populated with the instantiated function
12512 /// parameters.
12513 ///
12514 /// \param FunctionType if non-NULL, the result type of the function template
12515 /// will also be instantiated and the pointed-to value will be updated with
12516 /// the instantiated function type.
12517 ///
12518 /// \param Info if substitution fails for any reason, this object will be
12519 /// populated with more information about the failure.
12520 ///
12521 /// \returns TemplateDeductionResult::Success if substitution was successful,
12522 /// or some failure condition.
12525 TemplateArgumentListInfo &ExplicitTemplateArgs,
12529
12530 /// brief A function argument from which we performed template argument
12531 // deduction for a call.
12544
12545 /// Finish template argument deduction for a function template,
12546 /// checking the deduced template arguments for completeness and forming
12547 /// the function template specialization.
12548 ///
12549 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12550 /// which the deduced argument types should be compared.
12551 /// \param CheckNonDependent Callback before substituting into the declaration
12552 /// with the deduced template arguments.
12553 /// \param OnlyInitializeNonUserDefinedConversions is used as a workaround for
12554 /// some breakages introduced by CWG2369, where non-user-defined conversions
12555 /// are checked first before the constraints.
12559 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12561 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12562 bool PartialOverloading, bool PartialOrdering,
12563 bool ForOverloadSetAddressResolution,
12564 llvm::function_ref<bool(bool)> CheckNonDependent =
12565 [](bool /*OnlyInitializeNonUserDefinedConversions*/) {
12566 return false;
12567 });
12568
12569 /// Perform template argument deduction from a function call
12570 /// (C++ [temp.deduct.call]).
12571 ///
12572 /// \param FunctionTemplate the function template for which we are performing
12573 /// template argument deduction.
12574 ///
12575 /// \param ExplicitTemplateArgs the explicit template arguments provided
12576 /// for this call.
12577 ///
12578 /// \param Args the function call arguments
12579 ///
12580 /// \param Specialization if template argument deduction was successful,
12581 /// this will be set to the function template specialization produced by
12582 /// template argument deduction.
12583 ///
12584 /// \param Info the argument will be updated to provide additional information
12585 /// about template argument deduction.
12586 ///
12587 /// \param CheckNonDependent A callback to invoke to check conversions for
12588 /// non-dependent parameters, between deduction and substitution, per DR1391.
12589 /// If this returns true, substitution will be skipped and we return
12590 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12591 /// passed the parameter types (after substituting explicit template
12592 /// arguments).
12593 ///
12594 /// \returns the result of template argument deduction.
12597 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12599 bool PartialOverloading, bool AggregateDeductionCandidate,
12600 bool PartialOrdering, QualType ObjectType,
12601 Expr::Classification ObjectClassification,
12602 bool ForOverloadSetAddressResolution,
12603 llvm::function_ref<bool(ArrayRef<QualType>, bool)> CheckNonDependent);
12604
12605 /// Deduce template arguments when taking the address of a function
12606 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12607 /// a template.
12608 ///
12609 /// \param FunctionTemplate the function template for which we are performing
12610 /// template argument deduction.
12611 ///
12612 /// \param ExplicitTemplateArgs the explicitly-specified template
12613 /// arguments.
12614 ///
12615 /// \param ArgFunctionType the function type that will be used as the
12616 /// "argument" type (A) when performing template argument deduction from the
12617 /// function template's function type. This type may be NULL, if there is no
12618 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12619 ///
12620 /// \param Specialization if template argument deduction was successful,
12621 /// this will be set to the function template specialization produced by
12622 /// template argument deduction.
12623 ///
12624 /// \param Info the argument will be updated to provide additional information
12625 /// about template argument deduction.
12626 ///
12627 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12628 /// the address of a function template per [temp.deduct.funcaddr] and
12629 /// [over.over]. If \c false, we are looking up a function template
12630 /// specialization based on its signature, per [temp.deduct.decl].
12631 ///
12632 /// \returns the result of template argument deduction.
12635 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12637 bool IsAddressOfFunction = false);
12638
12639 /// Deduce template arguments for a templated conversion
12640 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12641 /// conversion function template specialization.
12644 Expr::Classification ObjectClassification, QualType ToType,
12646
12647 /// Deduce template arguments for a function template when there is
12648 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12649 ///
12650 /// \param FunctionTemplate the function template for which we are performing
12651 /// template argument deduction.
12652 ///
12653 /// \param ExplicitTemplateArgs the explicitly-specified template
12654 /// arguments.
12655 ///
12656 /// \param Specialization if template argument deduction was successful,
12657 /// this will be set to the function template specialization produced by
12658 /// template argument deduction.
12659 ///
12660 /// \param Info the argument will be updated to provide additional information
12661 /// about template argument deduction.
12662 ///
12663 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12664 /// the address of a function template in a context where we do not have a
12665 /// target type, per [over.over]. If \c false, we are looking up a function
12666 /// template specialization based on its signature, which only happens when
12667 /// deducing a function parameter type from an argument that is a template-id
12668 /// naming a function template specialization.
12669 ///
12670 /// \returns the result of template argument deduction.
12673 TemplateArgumentListInfo *ExplicitTemplateArgs,
12676 bool IsAddressOfFunction = false);
12677
12678 /// Substitute Replacement for \p auto in \p TypeWithAuto
12679 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12680 /// Substitute Replacement for auto in TypeWithAuto
12682 QualType Replacement);
12683
12684 // Substitute auto in TypeWithAuto for a Dependent auto type
12686
12687 // Substitute auto in TypeWithAuto for a Dependent auto type
12690
12691 /// Completely replace the \c auto in \p TypeWithAuto by
12692 /// \p Replacement. This does not retain any \c auto type sugar.
12693 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12695 QualType Replacement);
12696
12697 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12698 ///
12699 /// Note that this is done even if the initializer is dependent. (This is
12700 /// necessary to support partial ordering of templates using 'auto'.)
12701 /// A dependent type will be produced when deducing from a dependent type.
12702 ///
12703 /// \param Type the type pattern using the auto type-specifier.
12704 /// \param Init the initializer for the variable whose type is to be deduced.
12705 /// \param Result if type deduction was successful, this will be set to the
12706 /// deduced type.
12707 /// \param Info the argument will be updated to provide additional information
12708 /// about template argument deduction.
12709 /// \param DependentDeduction Set if we should permit deduction in
12710 /// dependent cases. This is necessary for template partial ordering
12711 /// with 'auto' template parameters. The template parameter depth to be
12712 /// used should be specified in the 'Info' parameter.
12713 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12714 /// does not satisfy the type-constraint in the auto
12715 /// type.
12719 bool DependentDeduction = false,
12720 bool IgnoreConstraints = false,
12721 TemplateSpecCandidateSet *FailedTSC = nullptr);
12722 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12724 bool Diagnose = true);
12725
12727 SourceLocation Loc);
12728
12729 /// Returns the more specialized class template partial specialization
12730 /// according to the rules of partial ordering of class template partial
12731 /// specializations (C++ [temp.class.order]).
12732 ///
12733 /// \param PS1 the first class template partial specialization
12734 ///
12735 /// \param PS2 the second class template partial specialization
12736 ///
12737 /// \returns the more specialized class template partial specialization. If
12738 /// neither partial specialization is more specialized, returns NULL.
12743
12746
12750
12753
12755 TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
12756 const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
12757 bool PartialOrdering, bool *StrictPackMatch);
12758
12759 /// Mark which template parameters are used in a given expression.
12760 ///
12761 /// \param E the expression from which template parameters will be deduced.
12762 ///
12763 /// \param Used a bit vector whose elements will be set to \c true
12764 /// to indicate when the corresponding template parameter will be
12765 /// deduced.
12766 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12767 unsigned Depth, llvm::SmallBitVector &Used);
12768
12769 /// Mark which template parameters can be deduced from a given
12770 /// template argument list.
12771 ///
12772 /// \param TemplateArgs the template argument list from which template
12773 /// parameters will be deduced.
12774 ///
12775 /// \param Used a bit vector whose elements will be set to \c true
12776 /// to indicate when the corresponding template parameter will be
12777 /// deduced.
12778 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
12779 bool OnlyDeduced, unsigned Depth,
12780 llvm::SmallBitVector &Used);
12781
12783 unsigned Depth, llvm::SmallBitVector &Used);
12784
12785 void
12787 llvm::SmallBitVector &Deduced) {
12789 }
12790
12791 /// Marks all of the template parameters that will be deduced by a
12792 /// call to the given function template.
12793 static void
12796 llvm::SmallBitVector &Deduced);
12797
12798 /// Returns the more specialized function template according
12799 /// to the rules of function template partial ordering (C++
12800 /// [temp.func.order]).
12801 ///
12802 /// \param FT1 the first function template
12803 ///
12804 /// \param FT2 the second function template
12805 ///
12806 /// \param TPOC the context in which we are performing partial ordering of
12807 /// function templates.
12808 ///
12809 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
12810 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
12811 /// when calling a member function.
12812 ///
12813 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
12814 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
12815 /// template from a member function
12816 ///
12817 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
12818 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
12819 /// template from a member function
12820 ///
12821 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
12822 /// candidate with a reversed parameter order. In this case, the corresponding
12823 /// P/A pairs between FT1 and FT2 are reversed.
12824 ///
12825 /// \returns the more specialized function template. If neither
12826 /// template is more specialized, returns NULL.
12829 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
12830 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false,
12831 bool PartialOverloading = false);
12832
12833 /// Retrieve the most specialized of the given function template
12834 /// specializations.
12835 ///
12836 /// \param SpecBegin the start iterator of the function template
12837 /// specializations that we will be comparing.
12838 ///
12839 /// \param SpecEnd the end iterator of the function template
12840 /// specializations, paired with \p SpecBegin.
12841 ///
12842 /// \param Loc the location where the ambiguity or no-specializations
12843 /// diagnostic should occur.
12844 ///
12845 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
12846 /// no matching candidates.
12847 ///
12848 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
12849 /// occurs.
12850 ///
12851 /// \param CandidateDiag partial diagnostic used for each function template
12852 /// specialization that is a candidate in the ambiguous ordering. One
12853 /// parameter in this diagnostic should be unbound, which will correspond to
12854 /// the string describing the template arguments for the function template
12855 /// specialization.
12856 ///
12857 /// \returns the most specialized function template specialization, if
12858 /// found. Otherwise, returns SpecEnd.
12859 UnresolvedSetIterator
12860 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
12861 TemplateSpecCandidateSet &FailedCandidates,
12862 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
12863 const PartialDiagnostic &AmbigDiag,
12864 const PartialDiagnostic &CandidateDiag,
12865 bool Complain = true, QualType TargetType = QualType());
12866
12867 /// Returns the more constrained function according to the rules of
12868 /// partial ordering by constraints (C++ [temp.constr.order]).
12869 ///
12870 /// \param FD1 the first function
12871 ///
12872 /// \param FD2 the second function
12873 ///
12874 /// \returns the more constrained function. If neither function is
12875 /// more constrained, returns NULL.
12876 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
12877 FunctionDecl *FD2);
12878
12879 ///@}
12880
12881 //
12882 //
12883 // -------------------------------------------------------------------------
12884 //
12885 //
12886
12887 /// \name C++ Template Deduction Guide
12888 /// Implementations are in SemaTemplateDeductionGuide.cpp
12889 ///@{
12890
12891 /// Declare implicit deduction guides for a class template if we've
12892 /// not already done so.
12893 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12894 SourceLocation Loc);
12895
12896 FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12897 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12898 SourceLocation Loc);
12899
12900 ///@}
12901
12902 //
12903 //
12904 // -------------------------------------------------------------------------
12905 //
12906 //
12907
12908 /// \name C++ Template Instantiation
12909 /// Implementations are in SemaTemplateInstantiate.cpp
12910 ///@{
12911
12912public:
12913 /// A helper class for building up ExtParameterInfos.
12916 bool HasInteresting = false;
12917
12918 public:
12919 /// Set the ExtParameterInfo for the parameter at the given index,
12920 ///
12922 assert(Infos.size() <= index);
12923 Infos.resize(index);
12924 Infos.push_back(info);
12925
12926 if (!HasInteresting)
12927 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
12928 }
12929
12930 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
12931 /// ExtParameterInfo array we've built up.
12933 getPointerOrNull(unsigned numParams) {
12934 if (!HasInteresting)
12935 return nullptr;
12936 Infos.resize(numParams);
12937 return Infos.data();
12938 }
12939 };
12940
12941 /// The current instantiation scope used to store local
12942 /// variables.
12944
12945 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
12947
12948 /// A mapping from parameters with unparsed default arguments to the
12949 /// set of instantiations of each parameter.
12950 ///
12951 /// This mapping is a temporary data structure used when parsing
12952 /// nested class templates or nested classes of class templates,
12953 /// where we might end up instantiating an inner class before the
12954 /// default arguments of its methods have been parsed.
12956
12957 /// A context in which code is being synthesized (where a source location
12958 /// alone is not sufficient to identify the context). This covers template
12959 /// instantiation and various forms of implicitly-generated functions.
12961 /// The kind of template instantiation we are performing
12963 /// We are instantiating a template declaration. The entity is
12964 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
12966
12967 /// We are instantiating a default argument for a template
12968 /// parameter. The Entity is the template parameter whose argument is
12969 /// being instantiated, the Template is the template, and the
12970 /// TemplateArgs/NumTemplateArguments provide the template arguments as
12971 /// specified.
12973
12974 /// We are instantiating a default argument for a function.
12975 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
12976 /// provides the template arguments as specified.
12978
12979 /// We are substituting explicit template arguments provided for
12980 /// a function template. The entity is a FunctionTemplateDecl.
12982
12983 /// We are substituting template argument determined as part of
12984 /// template argument deduction for either a class template
12985 /// partial specialization or a function template. The
12986 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
12987 /// a TemplateDecl.
12989
12990 /// We are substituting into a lambda expression.
12992
12993 /// We are substituting prior template arguments into a new
12994 /// template parameter. The template parameter itself is either a
12995 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
12997
12998 /// We are checking the validity of a default template argument that
12999 /// has been used when naming a template-id.
13001
13002 /// We are computing the exception specification for a defaulted special
13003 /// member function.
13005
13006 /// We are instantiating the exception specification for a function
13007 /// template which was deferred until it was needed.
13009
13010 /// We are instantiating a requirement of a requires expression.
13012
13013 /// We are checking the satisfaction of a nested requirement of a requires
13014 /// expression.
13016
13017 /// We are declaring an implicit special member function.
13019
13020 /// We are declaring an implicit 'operator==' for a defaulted
13021 /// 'operator<=>'.
13023
13024 /// We are defining a synthesized function (such as a defaulted special
13025 /// member).
13027
13028 // We are checking the constraints associated with a constrained entity or
13029 // the constraint expression of a concept. This includes the checks that
13030 // atomic constraints have the type 'bool' and that they can be constant
13031 // evaluated.
13033
13034 // We are substituting template arguments into a constraint expression.
13036
13037 // We are normalizing a constraint expression.
13039
13040 // Instantiating a Requires Expression parameter clause.
13042
13043 // We are substituting into the parameter mapping of an atomic constraint
13044 // during normalization.
13046
13047 /// We are rewriting a comparison operator in terms of an operator<=>.
13049
13050 /// We are initializing a structured binding.
13052
13053 /// We are marking a class as __dllexport.
13055
13056 /// We are building an implied call from __builtin_dump_struct. The
13057 /// arguments are in CallArgs.
13059
13060 /// Added for Template instantiation observation.
13061 /// Memoization means we are _not_ instantiating a template because
13062 /// it is already instantiated (but we entered a context where we
13063 /// would have had to if it was not already instantiated).
13065
13066 /// We are building deduction guides for a class.
13068
13069 /// We are instantiating a type alias template declaration.
13071
13072 /// We are performing partial ordering for template template parameters.
13074 } Kind;
13075
13076 /// Was the enclosing context a non-instantiation SFINAE context?
13078
13079 /// Whether we're substituting into constraints.
13081
13082 /// The point of instantiation or synthesis within the source code.
13084
13085 /// The entity that is being synthesized.
13087
13088 /// The template (or partial specialization) in which we are
13089 /// performing the instantiation, for substitutions of prior template
13090 /// arguments.
13092
13093 union {
13094 /// The list of template arguments we are substituting, if they
13095 /// are not part of the entity.
13097
13098 /// The list of argument expressions in a synthesized call.
13099 const Expr *const *CallArgs;
13100 };
13101
13102 // FIXME: Wrap this union around more members, or perhaps store the
13103 // kind-specific members in the RAII object owning the context.
13104 union {
13105 /// The number of template arguments in TemplateArgs.
13107
13108 /// The number of expressions in CallArgs.
13109 unsigned NumCallArgs;
13110
13111 /// The special member being declared or defined.
13113 };
13114
13119
13120 /// The template deduction info object associated with the
13121 /// substitution or checking of explicit or deduced template arguments.
13123
13124 /// The source range that covers the construct that cause
13125 /// the instantiation, e.g., the template-id that causes a class
13126 /// template instantiation.
13128
13134
13135 /// Determines whether this template is an actual instantiation
13136 /// that should be counted toward the maximum instantiation depth.
13137 bool isInstantiationRecord() const;
13138 };
13139
13140 /// A stack object to be created when performing template
13141 /// instantiation.
13142 ///
13143 /// Construction of an object of type \c InstantiatingTemplate
13144 /// pushes the current instantiation onto the stack of active
13145 /// instantiations. If the size of this stack exceeds the maximum
13146 /// number of recursive template instantiations, construction
13147 /// produces an error and evaluates true.
13148 ///
13149 /// Destruction of this object will pop the named instantiation off
13150 /// the stack.
13152 /// Note that we are instantiating a class template,
13153 /// function template, variable template, alias template,
13154 /// or a member thereof.
13155 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13156 Decl *Entity,
13157 SourceRange InstantiationRange = SourceRange());
13158
13160 /// Note that we are instantiating an exception specification
13161 /// of a function template.
13162 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13164 SourceRange InstantiationRange = SourceRange());
13165
13166 /// Note that we are instantiating a type alias template declaration.
13167 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13168 TypeAliasTemplateDecl *Entity,
13169 ArrayRef<TemplateArgument> TemplateArgs,
13170 SourceRange InstantiationRange = SourceRange());
13171
13172 /// Note that we are instantiating a default argument in a
13173 /// template-id.
13174 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13176 ArrayRef<TemplateArgument> TemplateArgs,
13177 SourceRange InstantiationRange = SourceRange());
13178
13179 /// Note that we are substituting either explicitly-specified or
13180 /// deduced template arguments during function template argument deduction.
13181 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13183 ArrayRef<TemplateArgument> TemplateArgs,
13185 sema::TemplateDeductionInfo &DeductionInfo,
13186 SourceRange InstantiationRange = SourceRange());
13187
13188 /// Note that we are instantiating as part of template
13189 /// argument deduction for a class template declaration.
13190 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13192 ArrayRef<TemplateArgument> TemplateArgs,
13193 sema::TemplateDeductionInfo &DeductionInfo,
13194 SourceRange InstantiationRange = SourceRange());
13195
13196 /// Note that we are instantiating as part of template
13197 /// argument deduction for a class template partial
13198 /// specialization.
13199 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13201 ArrayRef<TemplateArgument> TemplateArgs,
13202 sema::TemplateDeductionInfo &DeductionInfo,
13203 SourceRange InstantiationRange = SourceRange());
13204
13205 /// Note that we are instantiating as part of template
13206 /// argument deduction for a variable template partial
13207 /// specialization.
13208 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13210 ArrayRef<TemplateArgument> TemplateArgs,
13211 sema::TemplateDeductionInfo &DeductionInfo,
13212 SourceRange InstantiationRange = SourceRange());
13213
13214 /// Note that we are instantiating a default argument for a function
13215 /// parameter.
13216 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13217 ParmVarDecl *Param,
13218 ArrayRef<TemplateArgument> TemplateArgs,
13219 SourceRange InstantiationRange = SourceRange());
13220
13221 /// Note that we are substituting prior template arguments into a
13222 /// non-type parameter.
13223 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13225 ArrayRef<TemplateArgument> TemplateArgs,
13226 SourceRange InstantiationRange);
13227
13228 /// Note that we are substituting prior template arguments into a
13229 /// template template parameter.
13230 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13232 ArrayRef<TemplateArgument> TemplateArgs,
13233 SourceRange InstantiationRange);
13234
13235 /// Note that we are checking the default template argument
13236 /// against the template parameter for a given template-id.
13237 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13239 ArrayRef<TemplateArgument> TemplateArgs,
13240 SourceRange InstantiationRange);
13241
13243 /// \brief Note that we are checking the constraints associated with some
13244 /// constrained entity (a concept declaration or a template with associated
13245 /// constraints).
13246 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13248 ArrayRef<TemplateArgument> TemplateArgs,
13249 SourceRange InstantiationRange);
13250
13252 /// \brief Note that we are checking a constraint expression associated
13253 /// with a template declaration or as part of the satisfaction check of a
13254 /// concept.
13255 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13257 sema::TemplateDeductionInfo &DeductionInfo,
13258 SourceRange InstantiationRange);
13259
13261 /// \brief Note that we are normalizing a constraint expression.
13262 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13264 SourceRange InstantiationRange);
13265
13267 /// \brief Note that we are subtituting into the parameter mapping of an
13268 /// atomic constraint during constraint normalization.
13269 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13271 SourceRange InstantiationRange);
13272
13273 /// \brief Note that we are substituting template arguments into a part of
13274 /// a requirement of a requires expression.
13275 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13277 sema::TemplateDeductionInfo &DeductionInfo,
13278 SourceRange InstantiationRange = SourceRange());
13279
13280 /// \brief Note that we are checking the satisfaction of the constraint
13281 /// expression inside of a nested requirement.
13282 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13284 SourceRange InstantiationRange = SourceRange());
13285
13286 /// \brief Note that we are checking a requires clause.
13287 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13288 const RequiresExpr *E,
13289 sema::TemplateDeductionInfo &DeductionInfo,
13290 SourceRange InstantiationRange);
13291
13293 /// \brief Note that we are building deduction guides.
13294 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13296 SourceRange InstantiationRange = SourceRange());
13297
13299 /// \brief Note that we are partial ordering template template parameters.
13300 InstantiatingTemplate(Sema &SemaRef, SourceLocation ArgLoc,
13302 SourceRange InstantiationRange = SourceRange());
13303
13304 /// Note that we have finished instantiating this template.
13305 void Clear();
13306
13308
13309 /// Determines whether we have exceeded the maximum
13310 /// recursive template instantiations.
13311 bool isInvalid() const { return Invalid; }
13312
13313 /// Determine whether we are already instantiating this
13314 /// specialization in some surrounding active instantiation.
13315 bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
13316
13317 private:
13318 Sema &SemaRef;
13319 bool Invalid;
13320 bool AlreadyInstantiating;
13321 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
13322 SourceRange InstantiationRange);
13323
13326 SourceLocation PointOfInstantiation,
13327 SourceRange InstantiationRange, Decl *Entity,
13328 NamedDecl *Template = nullptr,
13329 ArrayRef<TemplateArgument> TemplateArgs = {},
13330 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
13331
13333
13334 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13335 };
13336
13337 bool SubstTemplateArgument(const TemplateArgumentLoc &Input,
13338 const MultiLevelTemplateArgumentList &TemplateArgs,
13339 TemplateArgumentLoc &Output,
13340 SourceLocation Loc = {},
13341 const DeclarationName &Entity = {});
13342 bool
13343 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13344 const MultiLevelTemplateArgumentList &TemplateArgs,
13345 TemplateArgumentListInfo &Outputs);
13346
13347 /// Retrieve the template argument list(s) that should be used to
13348 /// instantiate the definition of the given declaration.
13349 ///
13350 /// \param ND the declaration for which we are computing template
13351 /// instantiation arguments.
13352 ///
13353 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13354 /// the decl context where it will be created. In this case, the `Innermost`
13355 /// should likely be provided. If ND is non-null, this is ignored.
13356 ///
13357 /// \param Innermost if non-NULL, specifies a template argument list for the
13358 /// template declaration passed as ND.
13359 ///
13360 /// \param RelativeToPrimary true if we should get the template
13361 /// arguments relative to the primary template, even when we're
13362 /// dealing with a specialization. This is only relevant for function
13363 /// template specializations.
13364 ///
13365 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13366 /// instantiating the definition of the given declaration, \p ND. This is
13367 /// used to determine the proper set of template instantiation arguments for
13368 /// friend function template specializations.
13369 ///
13370 /// \param ForConstraintInstantiation when collecting arguments,
13371 /// ForConstraintInstantiation indicates we should continue looking when
13372 /// encountering a lambda generic call operator, and continue looking for
13373 /// arguments on an enclosing class template.
13374 ///
13375 /// \param SkipForSpecialization when specified, any template specializations
13376 /// in a traversal would be ignored.
13377 ///
13378 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13379 /// when encountering a specialized member function template, rather than
13380 /// returning immediately.
13381 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13382 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13383 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13384 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13385 bool ForConstraintInstantiation = false,
13386 bool SkipForSpecialization = false,
13387 bool ForDefaultArgumentSubstitution = false);
13388
13389 /// RAII object to handle the state changes required to synthesize
13390 /// a function body.
13392 Sema &S;
13393 Sema::ContextRAII SavedContext;
13394 bool PushedCodeSynthesisContext = false;
13395
13396 public:
13398 : S(S), SavedContext(S, DC) {
13399 auto *FD = dyn_cast<FunctionDecl>(DC);
13400 S.PushFunctionScope();
13401 S.PushExpressionEvaluationContextForFunction(
13403 if (FD)
13404 FD->setWillHaveBody(true);
13405 else
13406 assert(isa<ObjCMethodDecl>(DC));
13407 }
13408
13410 assert(!PushedCodeSynthesisContext);
13411
13414 Ctx.PointOfInstantiation = UseLoc;
13415 Ctx.Entity = cast<Decl>(S.CurContext);
13416 S.pushCodeSynthesisContext(Ctx);
13417
13418 PushedCodeSynthesisContext = true;
13419 }
13420
13422 if (PushedCodeSynthesisContext)
13423 S.popCodeSynthesisContext();
13424 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13425 FD->setWillHaveBody(false);
13426 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13427 }
13428 S.PopExpressionEvaluationContext();
13429 S.PopFunctionScopeInfo();
13430 }
13431 };
13432
13433 /// List of active code synthesis contexts.
13434 ///
13435 /// This vector is treated as a stack. As synthesis of one entity requires
13436 /// synthesis of another, additional contexts are pushed onto the stack.
13438
13439 /// Specializations whose definitions are currently being instantiated.
13440 llvm::DenseSet<std::pair<Decl *, unsigned>> InstantiatingSpecializations;
13441
13442 /// Non-dependent types used in templates that have already been instantiated
13443 /// by some template instantiation.
13444 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13445
13446 /// Extra modules inspected when performing a lookup during a template
13447 /// instantiation. Computed lazily.
13449
13450 /// Cache of additional modules that should be used for name lookup
13451 /// within the current template instantiation. Computed lazily; use
13452 /// getLookupModules() to get a complete set.
13453 llvm::DenseSet<Module *> LookupModulesCache;
13454
13455 /// Map from the most recent declaration of a namespace to the most
13456 /// recent visible declaration of that namespace.
13457 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13458
13459 /// Whether we are in a SFINAE context that is not associated with
13460 /// template instantiation.
13461 ///
13462 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
13463 /// of a template instantiation or template argument deduction.
13465
13466 /// The number of \p CodeSynthesisContexts that are not template
13467 /// instantiations and, therefore, should not be counted as part of the
13468 /// instantiation depth.
13469 ///
13470 /// When the instantiation depth reaches the user-configurable limit
13471 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13472 // FIXME: Should we have a similar limit for other forms of synthesis?
13474
13475 /// The depth of the context stack at the point when the most recent
13476 /// error or warning was produced.
13477 ///
13478 /// This value is used to suppress printing of redundant context stacks
13479 /// when there are multiple errors or warnings in the same instantiation.
13480 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13482
13483 /// The template instantiation callbacks to trace or track
13484 /// instantiations (objects can be chained).
13485 ///
13486 /// This callbacks is used to print, trace or track template
13487 /// instantiations as they are being constructed.
13488 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
13490
13491 /// The current index into pack expansion arguments that will be
13492 /// used for substitution of parameter packs.
13493 ///
13494 /// The pack expansion index will be none to indicate that parameter packs
13495 /// should be instantiated as themselves. Otherwise, the index specifies
13496 /// which argument within the parameter pack will be used for substitution.
13498
13499 /// RAII object used to change the argument pack substitution index
13500 /// within a \c Sema object.
13501 ///
13502 /// See \c ArgPackSubstIndex for more information.
13504 Sema &Self;
13505 UnsignedOrNone OldSubstIndex;
13506
13507 public:
13509 : Self(Self),
13510 OldSubstIndex(std::exchange(Self.ArgPackSubstIndex, NewSubstIndex)) {}
13511
13512 ~ArgPackSubstIndexRAII() { Self.ArgPackSubstIndex = OldSubstIndex; }
13513 };
13514
13515 void pushCodeSynthesisContext(CodeSynthesisContext Ctx);
13517
13528 /// Prints the current instantiation stack through a series of
13529 /// notes.
13534
13535 /// Determines whether we are currently in a context where
13536 /// template argument substitution failures are not considered
13537 /// errors.
13538 ///
13539 /// \returns An empty \c Optional if we're not in a SFINAE context.
13540 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
13541 /// template-deduction context object, which can be used to capture
13542 /// diagnostics that will be suppressed.
13543 std::optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
13544
13545 /// Perform substitution on the type T with a given set of template
13546 /// arguments.
13547 ///
13548 /// This routine substitutes the given template arguments into the
13549 /// type T and produces the instantiated type.
13550 ///
13551 /// \param T the type into which the template arguments will be
13552 /// substituted. If this type is not dependent, it will be returned
13553 /// immediately.
13554 ///
13555 /// \param Args the template arguments that will be
13556 /// substituted for the top-level template parameters within T.
13557 ///
13558 /// \param Loc the location in the source code where this substitution
13559 /// is being performed. It will typically be the location of the
13560 /// declarator (if we're instantiating the type of some declaration)
13561 /// or the location of the type in the source code (if, e.g., we're
13562 /// instantiating the type of a cast expression).
13563 ///
13564 /// \param Entity the name of the entity associated with a declaration
13565 /// being instantiated (if any). May be empty to indicate that there
13566 /// is no such entity (if, e.g., this is a type that occurs as part of
13567 /// a cast expression) or that the entity has no name (e.g., an
13568 /// unnamed function parameter).
13569 ///
13570 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13571 /// acceptable as the top level type of the result.
13572 ///
13573 /// \param IsIncompleteSubstitution If provided, the pointee will be set
13574 /// whenever substitution would perform a replacement with a null or
13575 /// non-existent template argument.
13576 ///
13577 /// \returns If the instantiation succeeds, the instantiated
13578 /// type. Otherwise, produces diagnostics and returns a NULL type.
13580 const MultiLevelTemplateArgumentList &TemplateArgs,
13581 SourceLocation Loc, DeclarationName Entity,
13582 bool AllowDeducedTST = false);
13583
13585 const MultiLevelTemplateArgumentList &TemplateArgs,
13586 SourceLocation Loc, DeclarationName Entity,
13587 bool *IsIncompleteSubstitution = nullptr);
13588
13590 const MultiLevelTemplateArgumentList &TemplateArgs,
13591 SourceLocation Loc, DeclarationName Entity);
13592
13593 /// A form of SubstType intended specifically for instantiating the
13594 /// type of a FunctionDecl. Its purpose is solely to force the
13595 /// instantiation of default-argument expressions and to avoid
13596 /// instantiating an exception-specification.
13598 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13599 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13600 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13602 const MultiLevelTemplateArgumentList &Args);
13605 SmallVectorImpl<QualType> &ExceptionStorage,
13606 const MultiLevelTemplateArgumentList &Args);
13607 ParmVarDecl *
13609 const MultiLevelTemplateArgumentList &TemplateArgs,
13610 int indexAdjustment, UnsignedOrNone NumExpansions,
13611 bool ExpectParameterPack, bool EvaluateConstraints = true);
13612
13613 /// Substitute the given template arguments into the given set of
13614 /// parameters, producing the set of parameter types that would be generated
13615 /// from such a substitution.
13617 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13618 const MultiLevelTemplateArgumentList &TemplateArgs,
13619 SmallVectorImpl<QualType> &ParamTypes,
13621 ExtParameterInfoBuilder &ParamInfos);
13622
13623 /// Substitute the given template arguments into the default argument.
13625 const MultiLevelTemplateArgumentList &TemplateArgs,
13626 bool ForCallExpr = false);
13628 const MultiLevelTemplateArgumentList &TemplateArgs);
13629 /// Substitute an expression as if it is a address-of-operand, which makes it
13630 /// act like a CXXIdExpression rather than an attempt to call.
13632 const MultiLevelTemplateArgumentList &TemplateArgs);
13633
13634 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
13635 // to disable constraint evaluation, then restore the state.
13636 template <typename InstTy> struct ConstraintEvalRAII {
13637 InstTy &TI;
13639
13641 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
13642 TI.setEvaluateConstraints(false);
13643 }
13644 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
13645 };
13646
13647 // Must be used instead of SubstExpr at 'constraint checking' time.
13650 const MultiLevelTemplateArgumentList &TemplateArgs);
13651 // Unlike the above, this does not evaluate constraints.
13653 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13654
13655 /// Substitute the given template arguments into a list of
13656 /// expressions, expanding pack expansions if required.
13657 ///
13658 /// \param Exprs The list of expressions to substitute into.
13659 ///
13660 /// \param IsCall Whether this is some form of call, in which case
13661 /// default arguments will be dropped.
13662 ///
13663 /// \param TemplateArgs The set of template arguments to substitute.
13664 ///
13665 /// \param Outputs Will receive all of the substituted arguments.
13666 ///
13667 /// \returns true if an error occurred, false otherwise.
13668 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13669 const MultiLevelTemplateArgumentList &TemplateArgs,
13670 SmallVectorImpl<Expr *> &Outputs);
13671
13673 const MultiLevelTemplateArgumentList &TemplateArgs);
13674
13677 bool CXXDirectInit);
13678
13679 /// Perform substitution on the base class specifiers of the
13680 /// given class template specialization.
13681 ///
13682 /// Produces a diagnostic and returns true on error, returns false and
13683 /// attaches the instantiated base classes to the class template
13684 /// specialization if successful.
13685 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13686 const MultiLevelTemplateArgumentList &TemplateArgs);
13687
13688 /// Instantiate the definition of a class from a given pattern.
13689 ///
13690 /// \param PointOfInstantiation The point of instantiation within the
13691 /// source code.
13692 ///
13693 /// \param Instantiation is the declaration whose definition is being
13694 /// instantiated. This will be either a class template specialization
13695 /// or a member class of a class template specialization.
13696 ///
13697 /// \param Pattern is the pattern from which the instantiation
13698 /// occurs. This will be either the declaration of a class template or
13699 /// the declaration of a member class of a class template.
13700 ///
13701 /// \param TemplateArgs The template arguments to be substituted into
13702 /// the pattern.
13703 ///
13704 /// \param TSK the kind of implicit or explicit instantiation to perform.
13705 ///
13706 /// \param Complain whether to complain if the class cannot be instantiated
13707 /// due to the lack of a definition.
13708 ///
13709 /// \returns true if an error occurred, false otherwise.
13710 bool InstantiateClass(SourceLocation PointOfInstantiation,
13711 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13712 const MultiLevelTemplateArgumentList &TemplateArgs,
13713 TemplateSpecializationKind TSK, bool Complain = true);
13714
13715 /// Instantiate the definition of an enum from a given pattern.
13716 ///
13717 /// \param PointOfInstantiation The point of instantiation within the
13718 /// source code.
13719 /// \param Instantiation is the declaration whose definition is being
13720 /// instantiated. This will be a member enumeration of a class
13721 /// temploid specialization, or a local enumeration within a
13722 /// function temploid specialization.
13723 /// \param Pattern The templated declaration from which the instantiation
13724 /// occurs.
13725 /// \param TemplateArgs The template arguments to be substituted into
13726 /// the pattern.
13727 /// \param TSK The kind of implicit or explicit instantiation to perform.
13728 ///
13729 /// \return \c true if an error occurred, \c false otherwise.
13730 bool InstantiateEnum(SourceLocation PointOfInstantiation,
13731 EnumDecl *Instantiation, EnumDecl *Pattern,
13732 const MultiLevelTemplateArgumentList &TemplateArgs,
13734
13735 /// Instantiate the definition of a field from the given pattern.
13736 ///
13737 /// \param PointOfInstantiation The point of instantiation within the
13738 /// source code.
13739 /// \param Instantiation is the declaration whose definition is being
13740 /// instantiated. This will be a class of a class temploid
13741 /// specialization, or a local enumeration within a function temploid
13742 /// specialization.
13743 /// \param Pattern The templated declaration from which the instantiation
13744 /// occurs.
13745 /// \param TemplateArgs The template arguments to be substituted into
13746 /// the pattern.
13747 ///
13748 /// \return \c true if an error occurred, \c false otherwise.
13750 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
13751 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
13752
13754 SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
13755
13757 SourceLocation PointOfInstantiation,
13758 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13759 TemplateSpecializationKind TSK, bool Complain,
13760 bool PrimaryStrictPackMatch);
13761
13762 /// Instantiates the definitions of all of the member
13763 /// of the given class, which is an instantiation of a class template
13764 /// or a member class of a template.
13765 void
13766 InstantiateClassMembers(SourceLocation PointOfInstantiation,
13767 CXXRecordDecl *Instantiation,
13768 const MultiLevelTemplateArgumentList &TemplateArgs,
13770
13771 /// Instantiate the definitions of all of the members of the
13772 /// given class template specialization, which was named as part of an
13773 /// explicit instantiation.
13775 SourceLocation PointOfInstantiation,
13776 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13778
13781 const MultiLevelTemplateArgumentList &TemplateArgs);
13782
13783 /// Do template substitution on declaration name info.
13786 const MultiLevelTemplateArgumentList &TemplateArgs);
13788 SubstTemplateName(SourceLocation TemplateKWLoc,
13789 NestedNameSpecifierLoc &QualifierLoc, TemplateName Name,
13790 SourceLocation NameLoc,
13791 const MultiLevelTemplateArgumentList &TemplateArgs);
13792
13794 const MultiLevelTemplateArgumentList &TemplateArgs,
13795 bool EvaluateConstraint);
13796
13797 /// Determine whether we are currently performing template instantiation.
13800 }
13801
13802 /// Determine whether we are currently performing constraint substitution.
13804 return !CodeSynthesisContexts.empty() &&
13805 CodeSynthesisContexts.back().InConstraintSubstitution;
13806 }
13807
13808 using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
13809
13810 /// \brief create a Requirement::SubstitutionDiagnostic with only a
13811 /// SubstitutedEntity and DiagLoc using ASTContext's allocator.
13814
13815 ///@}
13816
13817 //
13818 //
13819 // -------------------------------------------------------------------------
13820 //
13821 //
13822
13823 /// \name C++ Template Declaration Instantiation
13824 /// Implementations are in SemaTemplateInstantiateDecl.cpp
13825 ///@{
13826
13827public:
13828 /// An entity for which implicit template instantiation is required.
13829 ///
13830 /// The source location associated with the declaration is the first place in
13831 /// the source code where the declaration was "used". It is not necessarily
13832 /// the point of instantiation (which will be either before or after the
13833 /// namespace-scope declaration that triggered this implicit instantiation),
13834 /// However, it is the location that diagnostics should generally refer to,
13835 /// because users will need to know what code triggered the instantiation.
13836 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
13837
13838 /// The queue of implicit template instantiations that are required
13839 /// but have not yet been performed.
13840 std::deque<PendingImplicitInstantiation> PendingInstantiations;
13841
13842 /// Queue of implicit template instantiations that cannot be performed
13843 /// eagerly.
13845
13849
13850 /// The queue of implicit template instantiations that are required
13851 /// and must be performed within the current local scope.
13852 ///
13853 /// This queue is only used for member functions of local classes in
13854 /// templates, which must be instantiated in the same scope as their
13855 /// enclosing function, so that they can reference function-local
13856 /// types, static variables, enumerators, etc.
13857 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
13858
13860 public:
13862 : S(S), AtEndOfTU(AtEndOfTU) {
13863 SavedPendingLocalImplicitInstantiations.swap(
13864 S.PendingLocalImplicitInstantiations);
13865 }
13866
13867 void perform() {
13868 S.PerformPendingInstantiations(/*LocalOnly=*/true,
13869 /*AtEndOfTU=*/AtEndOfTU);
13870 }
13871
13873 assert(S.PendingLocalImplicitInstantiations.empty() &&
13874 "there shouldn't be any pending local implicit instantiations");
13875 SavedPendingLocalImplicitInstantiations.swap(
13876 S.PendingLocalImplicitInstantiations);
13877 }
13878
13879 private:
13880 Sema &S;
13881 bool AtEndOfTU;
13882 std::deque<PendingImplicitInstantiation>
13883 SavedPendingLocalImplicitInstantiations;
13884 };
13885
13886 /// Records and restores the CurFPFeatures state on entry/exit of compound
13887 /// statements.
13889 public:
13892 FPOptionsOverride getOverrides() { return OldOverrides; }
13893
13894 private:
13895 Sema &S;
13896 FPOptions OldFPFeaturesState;
13897 FPOptionsOverride OldOverrides;
13898 LangOptions::FPEvalMethodKind OldEvalMethod;
13899 SourceLocation OldFPPragmaLocation;
13900 };
13901
13903 public:
13904 GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
13905 : S(S), Enabled(Enabled), AtEndOfTU(AtEndOfTU) {
13906 if (!Enabled)
13907 return;
13908
13909 S.SavedPendingInstantiations.emplace_back();
13910 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
13911
13912 S.SavedVTableUses.emplace_back();
13913 S.SavedVTableUses.back().swap(S.VTableUses);
13914 }
13915
13916 void perform() {
13917 if (Enabled) {
13918 S.DefineUsedVTables();
13919 S.PerformPendingInstantiations(/*LocalOnly=*/false,
13920 /*AtEndOfTU=*/AtEndOfTU);
13921 }
13922 }
13923
13925 if (!Enabled)
13926 return;
13927
13928 // Restore the set of pending vtables.
13929 assert(S.VTableUses.empty() &&
13930 "VTableUses should be empty before it is discarded.");
13931 S.VTableUses.swap(S.SavedVTableUses.back());
13932 S.SavedVTableUses.pop_back();
13933
13934 // Restore the set of pending implicit instantiations.
13935 if ((S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) &&
13936 AtEndOfTU) {
13937 assert(S.PendingInstantiations.empty() &&
13938 "PendingInstantiations should be empty before it is discarded.");
13939 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13940 S.SavedPendingInstantiations.pop_back();
13941 } else {
13942 // Template instantiations in the PCH may be delayed until the TU.
13943 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13944 S.PendingInstantiations.insert(
13945 S.PendingInstantiations.end(),
13946 S.SavedPendingInstantiations.back().begin(),
13947 S.SavedPendingInstantiations.back().end());
13948 S.SavedPendingInstantiations.pop_back();
13949 }
13950 }
13951
13952 private:
13953 Sema &S;
13954 bool Enabled;
13955 bool AtEndOfTU;
13956 };
13957
13959 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
13960
13971
13972 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
13973 const Decl *Pattern, Decl *Inst,
13974 LateInstantiatedAttrVec *LateAttrs = nullptr,
13975 LocalInstantiationScope *OuterMostScope = nullptr);
13976
13977 /// Update instantiation attributes after template was late parsed.
13978 ///
13979 /// Some attributes are evaluated based on the body of template. If it is
13980 /// late parsed, such attributes cannot be evaluated when declaration is
13981 /// instantiated. This function is used to update instantiation attributes
13982 /// when template definition is ready.
13983 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
13984
13985 void
13987 const Decl *Pattern, Decl *Inst,
13988 LateInstantiatedAttrVec *LateAttrs = nullptr,
13989 LocalInstantiationScope *OuterMostScope = nullptr);
13990
13991 /// In the MS ABI, we need to instantiate default arguments of dllexported
13992 /// default constructors along with the constructor definition. This allows IR
13993 /// gen to emit a constructor closure which calls the default constructor with
13994 /// its default arguments.
13996
13998 ParmVarDecl *Param);
13999 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
14001
14002 /// Instantiate (or find existing instantiation of) a function template with a
14003 /// given set of template arguments.
14004 ///
14005 /// Usually this should not be used, and template argument deduction should be
14006 /// used in its place.
14009 SourceLocation Loc,
14012
14013 /// Instantiate the definition of the given function from its
14014 /// template.
14015 ///
14016 /// \param PointOfInstantiation the point at which the instantiation was
14017 /// required. Note that this is not precisely a "point of instantiation"
14018 /// for the function, but it's close.
14019 ///
14020 /// \param Function the already-instantiated declaration of a
14021 /// function template specialization or member function of a class template
14022 /// specialization.
14023 ///
14024 /// \param Recursive if true, recursively instantiates any functions that
14025 /// are required by this instantiation.
14026 ///
14027 /// \param DefinitionRequired if true, then we are performing an explicit
14028 /// instantiation where the body of the function is required. Complain if
14029 /// there is no such body.
14030 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
14032 bool Recursive = false,
14033 bool DefinitionRequired = false,
14034 bool AtEndOfTU = false);
14037 const TemplateArgumentList *PartialSpecArgs,
14039 SourceLocation PointOfInstantiation,
14040 LateInstantiatedAttrVec *LateAttrs = nullptr,
14041 LocalInstantiationScope *StartingScope = nullptr);
14042
14043 /// Instantiates a variable template specialization by completing it
14044 /// with appropriate type information and initializer.
14046 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
14047 const MultiLevelTemplateArgumentList &TemplateArgs);
14048
14049 /// BuildVariableInstantiation - Used after a new variable has been created.
14050 /// Sets basic variable data and decides whether to postpone the
14051 /// variable instantiation.
14052 void
14054 const MultiLevelTemplateArgumentList &TemplateArgs,
14055 LateInstantiatedAttrVec *LateAttrs,
14056 DeclContext *Owner,
14057 LocalInstantiationScope *StartingScope,
14058 bool InstantiatingVarTemplate = false,
14059 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
14060
14061 /// Instantiate the initializer of a variable.
14063 VarDecl *Var, VarDecl *OldVar,
14064 const MultiLevelTemplateArgumentList &TemplateArgs);
14065
14066 /// Instantiate the definition of the given variable from its
14067 /// template.
14068 ///
14069 /// \param PointOfInstantiation the point at which the instantiation was
14070 /// required. Note that this is not precisely a "point of instantiation"
14071 /// for the variable, but it's close.
14072 ///
14073 /// \param Var the already-instantiated declaration of a templated variable.
14074 ///
14075 /// \param Recursive if true, recursively instantiates any functions that
14076 /// are required by this instantiation.
14077 ///
14078 /// \param DefinitionRequired if true, then we are performing an explicit
14079 /// instantiation where a definition of the variable is required. Complain
14080 /// if there is no such definition.
14081 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
14082 VarDecl *Var, bool Recursive = false,
14083 bool DefinitionRequired = false,
14084 bool AtEndOfTU = false);
14085
14088 const MultiLevelTemplateArgumentList &TemplateArgs);
14089
14090 /// Find the instantiation of the given declaration within the
14091 /// current instantiation.
14092 ///
14093 /// This routine is intended to be used when \p D is a declaration
14094 /// referenced from within a template, that needs to mapped into the
14095 /// corresponding declaration within an instantiation. For example,
14096 /// given:
14097 ///
14098 /// \code
14099 /// template<typename T>
14100 /// struct X {
14101 /// enum Kind {
14102 /// KnownValue = sizeof(T)
14103 /// };
14104 ///
14105 /// bool getKind() const { return KnownValue; }
14106 /// };
14107 ///
14108 /// template struct X<int>;
14109 /// \endcode
14110 ///
14111 /// In the instantiation of X<int>::getKind(), we need to map the \p
14112 /// EnumConstantDecl for \p KnownValue (which refers to
14113 /// X<T>::<Kind>::KnownValue) to its instantiation
14114 /// (X<int>::<Kind>::KnownValue).
14115 /// \p FindInstantiatedDecl performs this mapping from within the
14116 /// instantiation of X<int>.
14117 NamedDecl *
14119 const MultiLevelTemplateArgumentList &TemplateArgs,
14120 bool FindingInstantiatedContext = false);
14121
14122 /// Finds the instantiation of the given declaration context
14123 /// within the current instantiation.
14124 ///
14125 /// \returns NULL if there was an error
14126 DeclContext *
14128 const MultiLevelTemplateArgumentList &TemplateArgs);
14129
14130 Decl *SubstDecl(Decl *D, DeclContext *Owner,
14131 const MultiLevelTemplateArgumentList &TemplateArgs);
14132
14133 /// Substitute the name and return type of a defaulted 'operator<=>' to form
14134 /// an implicit 'operator=='.
14136 FunctionDecl *Spaceship);
14137
14138 /// Performs template instantiation for all implicit template
14139 /// instantiations we have seen until this point.
14140 void PerformPendingInstantiations(bool LocalOnly = false,
14141 bool AtEndOfTU = true);
14142
14145 const MultiLevelTemplateArgumentList &TemplateArgs,
14146 bool EvaluateConstraints = true);
14147
14149 const DeclContext *Pattern,
14150 const MultiLevelTemplateArgumentList &TemplateArgs);
14151
14152private:
14153 /// Introduce the instantiated local variables into the local
14154 /// instantiation scope.
14155 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
14156 const FunctionDecl *PatternDecl,
14158 /// Introduce the instantiated function parameters into the local
14159 /// instantiation scope, and set the parameter names to those used
14160 /// in the template.
14161 bool addInstantiatedParametersToScope(
14162 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14164 const MultiLevelTemplateArgumentList &TemplateArgs);
14165
14166 /// Introduce the instantiated captures of the lambda into the local
14167 /// instantiation scope.
14168 bool addInstantiatedCapturesToScope(
14169 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14171 const MultiLevelTemplateArgumentList &TemplateArgs);
14172
14173 int ParsingClassDepth = 0;
14174
14175 class SavePendingParsedClassStateRAII {
14176 public:
14177 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
14178
14179 ~SavePendingParsedClassStateRAII() {
14180 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
14181 "there shouldn't be any pending delayed exception spec checks");
14182 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
14183 "there shouldn't be any pending delayed exception spec checks");
14184 swapSavedState();
14185 }
14186
14187 private:
14188 Sema &S;
14190 SavedOverridingExceptionSpecChecks;
14192 SavedEquivalentExceptionSpecChecks;
14193
14194 void swapSavedState() {
14195 SavedOverridingExceptionSpecChecks.swap(
14196 S.DelayedOverridingExceptionSpecChecks);
14197 SavedEquivalentExceptionSpecChecks.swap(
14198 S.DelayedEquivalentExceptionSpecChecks);
14199 }
14200 };
14201
14202 ///@}
14203
14204 //
14205 //
14206 // -------------------------------------------------------------------------
14207 //
14208 //
14209
14210 /// \name C++ Variadic Templates
14211 /// Implementations are in SemaTemplateVariadic.cpp
14212 ///@{
14213
14214public:
14215 /// Determine whether an unexpanded parameter pack might be permitted in this
14216 /// location. Useful for error recovery.
14218
14219 /// The context in which an unexpanded parameter pack is
14220 /// being diagnosed.
14221 ///
14222 /// Note that the values of this enumeration line up with the first
14223 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
14225 /// An arbitrary expression.
14227
14228 /// The base type of a class type.
14230
14231 /// The type of an arbitrary declaration.
14233
14234 /// The type of a data member.
14236
14237 /// The size of a bit-field.
14239
14240 /// The expression in a static assertion.
14242
14243 /// The fixed underlying type of an enumeration.
14245
14246 /// The enumerator value.
14248
14249 /// A using declaration.
14251
14252 /// A friend declaration.
14254
14255 /// A declaration qualifier.
14257
14258 /// An initializer.
14260
14261 /// A default argument.
14263
14264 /// The type of a non-type template parameter.
14266
14267 /// The type of an exception.
14269
14270 /// Explicit specialization.
14272
14273 /// Partial specialization.
14275
14276 /// Microsoft __if_exists.
14278
14279 /// Microsoft __if_not_exists.
14281
14282 /// Lambda expression.
14284
14285 /// Block expression.
14287
14288 /// A type constraint.
14290
14291 // A requirement in a requires-expression.
14293
14294 // A requires-clause.
14296 };
14297
14298 /// Diagnose unexpanded parameter packs.
14299 ///
14300 /// \param Loc The location at which we should emit the diagnostic.
14301 ///
14302 /// \param UPPC The context in which we are diagnosing unexpanded
14303 /// parameter packs.
14304 ///
14305 /// \param Unexpanded the set of unexpanded parameter packs.
14306 ///
14307 /// \returns true if an error occurred, false otherwise.
14311
14312 /// If the given type contains an unexpanded parameter pack,
14313 /// diagnose the error.
14314 ///
14315 /// \param Loc The source location where a diagnostc should be emitted.
14316 ///
14317 /// \param T The type that is being checked for unexpanded parameter
14318 /// packs.
14319 ///
14320 /// \returns true if an error occurred, false otherwise.
14323
14324 /// If the given expression contains an unexpanded parameter
14325 /// pack, diagnose the error.
14326 ///
14327 /// \param E The expression that is being checked for unexpanded
14328 /// parameter packs.
14329 ///
14330 /// \returns true if an error occurred, false otherwise.
14333
14334 /// If the given requirees-expression contains an unexpanded reference to one
14335 /// of its own parameter packs, diagnose the error.
14336 ///
14337 /// \param RE The requiress-expression that is being checked for unexpanded
14338 /// parameter packs.
14339 ///
14340 /// \returns true if an error occurred, false otherwise.
14342
14343 /// If the given nested-name-specifier contains an unexpanded
14344 /// parameter pack, diagnose the error.
14345 ///
14346 /// \param SS The nested-name-specifier that is being checked for
14347 /// unexpanded parameter packs.
14348 ///
14349 /// \returns true if an error occurred, false otherwise.
14352
14353 /// If the given name contains an unexpanded parameter pack,
14354 /// diagnose the error.
14355 ///
14356 /// \param NameInfo The name (with source location information) that
14357 /// is being checked for unexpanded parameter packs.
14358 ///
14359 /// \returns true if an error occurred, false otherwise.
14362
14363 /// If the given template name contains an unexpanded parameter pack,
14364 /// diagnose the error.
14365 ///
14366 /// \param Loc The location of the template name.
14367 ///
14368 /// \param Template The template name that is being checked for unexpanded
14369 /// parameter packs.
14370 ///
14371 /// \returns true if an error occurred, false otherwise.
14375
14376 /// If the given template argument contains an unexpanded parameter
14377 /// pack, diagnose the error.
14378 ///
14379 /// \param Arg The template argument that is being checked for unexpanded
14380 /// parameter packs.
14381 ///
14382 /// \returns true if an error occurred, false otherwise.
14385
14386 /// Collect the set of unexpanded parameter packs within the given
14387 /// template argument.
14388 ///
14389 /// \param Arg The template argument that will be traversed to find
14390 /// unexpanded parameter packs.
14392 TemplateArgument Arg,
14394
14395 /// Collect the set of unexpanded parameter packs within the given
14396 /// template argument.
14397 ///
14398 /// \param Arg The template argument that will be traversed to find
14399 /// unexpanded parameter packs.
14403
14404 /// Collect the set of unexpanded parameter packs within the given
14405 /// type.
14406 ///
14407 /// \param T The type that will be traversed to find
14408 /// unexpanded parameter packs.
14411
14412 /// Collect the set of unexpanded parameter packs within the given
14413 /// type.
14414 ///
14415 /// \param TL The type that will be traversed to find
14416 /// unexpanded parameter packs.
14419
14420 /// Collect the set of unexpanded parameter packs within the given
14421 /// nested-name-specifier.
14422 ///
14423 /// \param NNS The nested-name-specifier that will be traversed to find
14424 /// unexpanded parameter packs.
14428
14429 /// Collect the set of unexpanded parameter packs within the given
14430 /// name.
14431 ///
14432 /// \param NameInfo The name that will be traversed to find
14433 /// unexpanded parameter packs.
14435 const DeclarationNameInfo &NameInfo,
14437
14438 /// Collect the set of unexpanded parameter packs within the given
14439 /// expression.
14442
14443 /// Invoked when parsing a template argument.
14444 ///
14445 /// \param Arg the template argument, which may already be invalid.
14446 ///
14447 /// If it is followed by ellipsis, this function is called before
14448 /// `ActOnPackExpansion`.
14451
14452 /// Invoked when parsing a template argument followed by an
14453 /// ellipsis, which creates a pack expansion.
14454 ///
14455 /// \param Arg The template argument preceding the ellipsis, which
14456 /// may already be invalid.
14457 ///
14458 /// \param EllipsisLoc The location of the ellipsis.
14460 SourceLocation EllipsisLoc);
14461
14462 /// Invoked when parsing a type followed by an ellipsis, which
14463 /// creates a pack expansion.
14464 ///
14465 /// \param Type The type preceding the ellipsis, which will become
14466 /// the pattern of the pack expansion.
14467 ///
14468 /// \param EllipsisLoc The location of the ellipsis.
14470
14471 /// Construct a pack expansion type from the pattern of the pack
14472 /// expansion.
14474 SourceLocation EllipsisLoc,
14475 UnsignedOrNone NumExpansions);
14476
14477 /// Construct a pack expansion type from the pattern of the pack
14478 /// expansion.
14479 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14480 SourceLocation EllipsisLoc,
14481 UnsignedOrNone NumExpansions);
14482
14483 /// Invoked when parsing an expression followed by an ellipsis, which
14484 /// creates a pack expansion.
14485 ///
14486 /// \param Pattern The expression preceding the ellipsis, which will become
14487 /// the pattern of the pack expansion.
14488 ///
14489 /// \param EllipsisLoc The location of the ellipsis.
14490 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14491
14492 /// Invoked when parsing an expression followed by an ellipsis, which
14493 /// creates a pack expansion.
14494 ///
14495 /// \param Pattern The expression preceding the ellipsis, which will become
14496 /// the pattern of the pack expansion.
14497 ///
14498 /// \param EllipsisLoc The location of the ellipsis.
14499 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14500 UnsignedOrNone NumExpansions);
14501
14502 /// Determine whether we could expand a pack expansion with the
14503 /// given set of parameter packs into separate arguments by repeatedly
14504 /// transforming the pattern.
14505 ///
14506 /// \param EllipsisLoc The location of the ellipsis that identifies the
14507 /// pack expansion.
14508 ///
14509 /// \param PatternRange The source range that covers the entire pattern of
14510 /// the pack expansion.
14511 ///
14512 /// \param Unexpanded The set of unexpanded parameter packs within the
14513 /// pattern.
14514 ///
14515 /// \param ShouldExpand Will be set to \c true if the transformer should
14516 /// expand the corresponding pack expansions into separate arguments. When
14517 /// set, \c NumExpansions must also be set.
14518 ///
14519 /// \param RetainExpansion Whether the caller should add an unexpanded
14520 /// pack expansion after all of the expanded arguments. This is used
14521 /// when extending explicitly-specified template argument packs per
14522 /// C++0x [temp.arg.explicit]p9.
14523 ///
14524 /// \param NumExpansions The number of separate arguments that will be in
14525 /// the expanded form of the corresponding pack expansion. This is both an
14526 /// input and an output parameter, which can be set by the caller if the
14527 /// number of expansions is known a priori (e.g., due to a prior substitution)
14528 /// and will be set by the callee when the number of expansions is known.
14529 /// The callee must set this value when \c ShouldExpand is \c true; it may
14530 /// set this value in other cases.
14531 ///
14532 /// \returns true if an error occurred (e.g., because the parameter packs
14533 /// are to be instantiated with arguments of different lengths), false
14534 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14535 /// must be set.
14537 SourceLocation EllipsisLoc, SourceRange PatternRange,
14539 const MultiLevelTemplateArgumentList &TemplateArgs,
14540 bool FailOnPackProducingTemplates, bool &ShouldExpand,
14541 bool &RetainExpansion, UnsignedOrNone &NumExpansions);
14542
14543 /// Determine the number of arguments in the given pack expansion
14544 /// type.
14545 ///
14546 /// This routine assumes that the number of arguments in the expansion is
14547 /// consistent across all of the unexpanded parameter packs in its pattern.
14548 ///
14549 /// Returns an empty Optional if the type can't be expanded.
14551 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14552
14555 const MultiLevelTemplateArgumentList &TemplateArgs);
14556
14557 /// Determine whether the given declarator contains any unexpanded
14558 /// parameter packs.
14559 ///
14560 /// This routine is used by the parser to disambiguate function declarators
14561 /// with an ellipsis prior to the ')', e.g.,
14562 ///
14563 /// \code
14564 /// void f(T...);
14565 /// \endcode
14566 ///
14567 /// To determine whether we have an (unnamed) function parameter pack or
14568 /// a variadic function.
14569 ///
14570 /// \returns true if the declarator contains any unexpanded parameter packs,
14571 /// false otherwise.
14573
14574 /// Returns the pattern of the pack expansion for a template argument.
14575 ///
14576 /// \param OrigLoc The template argument to expand.
14577 ///
14578 /// \param Ellipsis Will be set to the location of the ellipsis.
14579 ///
14580 /// \param NumExpansions Will be set to the number of expansions that will
14581 /// be generated from this pack expansion, if known a priori.
14584 SourceLocation &Ellipsis,
14585 UnsignedOrNone &NumExpansions) const;
14586
14587 /// Given a template argument that contains an unexpanded parameter pack, but
14588 /// which has already been substituted, attempt to determine the number of
14589 /// elements that will be produced once this argument is fully-expanded.
14590 ///
14591 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14592 /// avoid actually expanding the pack where possible.
14594
14595 /// Called when an expression computing the size of a parameter pack
14596 /// is parsed.
14597 ///
14598 /// \code
14599 /// template<typename ...Types> struct count {
14600 /// static const unsigned value = sizeof...(Types);
14601 /// };
14602 /// \endcode
14603 ///
14604 //
14605 /// \param OpLoc The location of the "sizeof" keyword.
14606 /// \param Name The name of the parameter pack whose size will be determined.
14607 /// \param NameLoc The source location of the name of the parameter pack.
14608 /// \param RParenLoc The location of the closing parentheses.
14610 IdentifierInfo &Name,
14611 SourceLocation NameLoc,
14612 SourceLocation RParenLoc);
14613
14614 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14615 SourceLocation EllipsisLoc,
14616 SourceLocation LSquareLoc, Expr *IndexExpr,
14617 SourceLocation RSquareLoc);
14618
14619 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14620 SourceLocation EllipsisLoc, Expr *IndexExpr,
14621 SourceLocation RSquareLoc,
14622 ArrayRef<Expr *> ExpandedExprs = {},
14623 bool FullySubstituted = false);
14624
14625 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
14626 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14627 tok::TokenKind Operator,
14628 SourceLocation EllipsisLoc, Expr *RHS,
14629 SourceLocation RParenLoc);
14630 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
14631 SourceLocation LParenLoc, Expr *LHS,
14632 BinaryOperatorKind Operator,
14633 SourceLocation EllipsisLoc, Expr *RHS,
14634 SourceLocation RParenLoc,
14635 UnsignedOrNone NumExpansions);
14636 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
14637 BinaryOperatorKind Operator);
14638
14639 ///@}
14640
14641 //
14642 //
14643 // -------------------------------------------------------------------------
14644 //
14645 //
14646
14647 /// \name Constraints and Concepts
14648 /// Implementations are in SemaConcept.cpp
14649 ///@{
14650
14651public:
14653 const llvm::FoldingSetNodeID &ID) {
14654 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14655 SatisfactionStack.emplace_back(Can, ID);
14656 }
14657
14658 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
14659
14661 const llvm::FoldingSetNodeID &ID) const {
14662 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14663 return llvm::is_contained(SatisfactionStack,
14664 SatisfactionStackEntryTy{Can, ID});
14665 }
14666
14668 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
14669
14670 // Resets the current SatisfactionStack for cases where we are instantiating
14671 // constraints as a 'side effect' of normal instantiation in a way that is not
14672 // indicative of recursive definition.
14675 Sema &SemaRef;
14676
14677 public:
14679 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14680 }
14681
14683 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14684 }
14685 };
14686
14689 SatisfactionStack.swap(NewSS);
14690 }
14691
14692 /// Check whether the given expression is a valid constraint expression.
14693 /// A diagnostic is emitted if it is not, false is returned, and
14694 /// PossibleNonPrimary will be set to true if the failure might be due to a
14695 /// non-primary expression being used as an atomic constraint.
14696 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
14697 bool *PossibleNonPrimary = nullptr,
14698 bool IsTrailingRequiresClause = false);
14699
14700 /// \brief Check whether the given list of constraint expressions are
14701 /// satisfied (as if in a 'conjunction') given template arguments.
14702 /// \param Template the template-like entity that triggered the constraints
14703 /// check (either a concept or a constrained entity).
14704 /// \param ConstraintExprs a list of constraint expressions, treated as if
14705 /// they were 'AND'ed together.
14706 /// \param TemplateArgLists the list of template arguments to substitute into
14707 /// the constraint expression.
14708 /// \param TemplateIDRange The source range of the template id that
14709 /// caused the constraints check.
14710 /// \param Satisfaction if true is returned, will contain details of the
14711 /// satisfaction, with enough information to diagnose an unsatisfied
14712 /// expression.
14713 /// \returns true if an error occurred and satisfaction could not be checked,
14714 /// false otherwise.
14716 const NamedDecl *Template,
14717 ArrayRef<AssociatedConstraint> AssociatedConstraints,
14718 const MultiLevelTemplateArgumentList &TemplateArgLists,
14719 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
14721 return CheckConstraintSatisfaction(Template, AssociatedConstraints,
14722 Converted, TemplateArgLists,
14723 TemplateIDRange, Satisfaction);
14724 }
14725
14726 /// \brief Check whether the given list of constraint expressions are
14727 /// satisfied (as if in a 'conjunction') given template arguments.
14728 /// Additionally, takes an empty list of Expressions which is populated with
14729 /// the instantiated versions of the ConstraintExprs.
14730 /// \param Template the template-like entity that triggered the constraints
14731 /// check (either a concept or a constrained entity).
14732 /// \param ConstraintExprs a list of constraint expressions, treated as if
14733 /// they were 'AND'ed together.
14734 /// \param ConvertedConstraints a out parameter that will get populated with
14735 /// the instantiated version of the ConstraintExprs if we successfully checked
14736 /// satisfaction.
14737 /// \param TemplateArgList the multi-level list of template arguments to
14738 /// substitute into the constraint expression. This should be relative to the
14739 /// top-level (hence multi-level), since we need to instantiate fully at the
14740 /// time of checking.
14741 /// \param TemplateIDRange The source range of the template id that
14742 /// caused the constraints check.
14743 /// \param Satisfaction if true is returned, will contain details of the
14744 /// satisfaction, with enough information to diagnose an unsatisfied
14745 /// expression.
14746 /// \returns true if an error occurred and satisfaction could not be checked,
14747 /// false otherwise.
14749 const NamedDecl *Template,
14750 ArrayRef<AssociatedConstraint> AssociatedConstraints,
14751 llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
14752 const MultiLevelTemplateArgumentList &TemplateArgList,
14753 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
14754
14755 /// \brief Check whether the given non-dependent constraint expression is
14756 /// satisfied. Returns false and updates Satisfaction with the satisfaction
14757 /// verdict if successful, emits a diagnostic and returns true if an error
14758 /// occurred and satisfaction could not be determined.
14759 ///
14760 /// \returns true if an error occurred, false otherwise.
14761 bool
14763 ConstraintSatisfaction &Satisfaction);
14764
14765 /// Check whether the given function decl's trailing requires clause is
14766 /// satisfied, if any. Returns false and updates Satisfaction with the
14767 /// satisfaction verdict if successful, emits a diagnostic and returns true if
14768 /// an error occurred and satisfaction could not be determined.
14769 ///
14770 /// \returns true if an error occurred, false otherwise.
14772 ConstraintSatisfaction &Satisfaction,
14773 SourceLocation UsageLoc = SourceLocation(),
14774 bool ForOverloadResolution = false);
14775
14776 // Calculates whether two constraint expressions are equal irrespective of a
14777 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
14778 // 'New', which are the "source" of the constraint, since this is necessary
14779 // for figuring out the relative 'depth' of the constraint. The depth of the
14780 // 'primary template' and the 'instantiated from' templates aren't necessarily
14781 // the same, such as a case when one is a 'friend' defined in a class.
14783 const Expr *OldConstr,
14784 const TemplateCompareNewDeclInfo &New,
14785 const Expr *NewConstr);
14786
14787 // Calculates whether the friend function depends on an enclosing template for
14788 // the purposes of [temp.friend] p9.
14790
14791 /// \brief Ensure that the given template arguments satisfy the constraints
14792 /// associated with the given template, emitting a diagnostic if they do not.
14793 ///
14794 /// \param Template The template to which the template arguments are being
14795 /// provided.
14796 ///
14797 /// \param TemplateArgs The converted, canonicalized template arguments.
14798 ///
14799 /// \param TemplateIDRange The source range of the template id that
14800 /// caused the constraints check.
14801 ///
14802 /// \returns true if the constrains are not satisfied or could not be checked
14803 /// for satisfaction, false if the constraints are satisfied.
14806 const MultiLevelTemplateArgumentList &TemplateArgs,
14807 SourceRange TemplateIDRange);
14808
14809 bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation,
14811 ArrayRef<TemplateArgument> TemplateArgs,
14812 ConstraintSatisfaction &Satisfaction);
14813
14814 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14815 /// unsatisfied.
14816 /// \param First whether this is the first time an unsatisfied constraint is
14817 /// diagnosed for this error.
14819 bool First = true);
14820
14821 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14822 /// unsatisfied.
14823 void
14825 bool First = true);
14826
14828 const NamedDecl *ConstrainedDecl,
14829 ArrayRef<AssociatedConstraint> AssociatedConstraints);
14830
14831 /// \brief Check whether the given declaration's associated constraints are
14832 /// at least as constrained than another declaration's according to the
14833 /// partial ordering of constraints.
14834 ///
14835 /// \param Result If no error occurred, receives the result of true if D1 is
14836 /// at least constrained than D2, and false otherwise.
14837 ///
14838 /// \returns true if an error occurred, false otherwise.
14839 bool IsAtLeastAsConstrained(const NamedDecl *D1,
14841 const NamedDecl *D2,
14843 bool &Result);
14844
14845 /// If D1 was not at least as constrained as D2, but would've been if a pair
14846 /// of atomic constraints involved had been declared in a concept and not
14847 /// repeated in two separate places in code.
14848 /// \returns true if such a diagnostic was emitted, false otherwise.
14852
14853private:
14854 /// Caches pairs of template-like decls whose associated constraints were
14855 /// checked for subsumption and whether or not the first's constraints did in
14856 /// fact subsume the second's.
14857 llvm::DenseMap<std::pair<const NamedDecl *, const NamedDecl *>, bool>
14858 SubsumptionCache;
14859 /// Caches the normalized associated constraints of declarations (concepts or
14860 /// constrained declarations). If an error occurred while normalizing the
14861 /// associated constraints of the template or concept, nullptr will be cached
14862 /// here.
14863 llvm::DenseMap<const NamedDecl *, NormalizedConstraint *> NormalizationCache;
14864
14865 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
14866 SatisfactionCache;
14867
14868 // The current stack of constraint satisfactions, so we can exit-early.
14870
14871 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to set up the
14872 /// LocalInstantiationScope of the current non-lambda function. For lambdas,
14873 /// use LambdaScopeForCallOperatorInstantiationRAII.
14874 bool
14875 SetupConstraintScope(FunctionDecl *FD,
14876 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14877 const MultiLevelTemplateArgumentList &MLTAL,
14879
14880 /// Used during constraint checking, sets up the constraint template argument
14881 /// lists, and calls SetupConstraintScope to set up the
14882 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
14883 std::optional<MultiLevelTemplateArgumentList>
14884 SetupConstraintCheckingTemplateArgumentsAndScope(
14885 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14887
14888 ///@}
14889
14890 //
14891 //
14892 // -------------------------------------------------------------------------
14893 //
14894 //
14895
14896 /// \name Types
14897 /// Implementations are in SemaType.cpp
14898 ///@{
14899
14900public:
14901 /// A mapping that describes the nullability we've seen in each header file.
14903
14904 static int getPrintable(int I) { return I; }
14905 static unsigned getPrintable(unsigned I) { return I; }
14906 static bool getPrintable(bool B) { return B; }
14907 static const char *getPrintable(const char *S) { return S; }
14908 static StringRef getPrintable(StringRef S) { return S; }
14909 static const std::string &getPrintable(const std::string &S) { return S; }
14910 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
14911 return II;
14912 }
14914 static QualType getPrintable(QualType T) { return T; }
14915 static SourceRange getPrintable(SourceRange R) { return R; }
14917 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
14919
14920 enum class CompleteTypeKind {
14921 /// Apply the normal rules for complete types. In particular,
14922 /// treat all sizeless types as incomplete.
14924
14925 /// Relax the normal rules for complete types so that they include
14926 /// sizeless built-in types.
14928
14929 // FIXME: Eventually we should flip the default to Normal and opt in
14930 // to AcceptSizeless rather than opt out of it.
14932 };
14933
14935 const DeclSpec *DS = nullptr);
14937 const DeclSpec *DS = nullptr);
14938
14939 /// Build a pointer type.
14940 ///
14941 /// \param T The type to which we'll be building a pointer.
14942 ///
14943 /// \param Loc The location of the entity whose type involves this
14944 /// pointer type or, if there is no such entity, the location of the
14945 /// type that will have pointer type.
14946 ///
14947 /// \param Entity The name of the entity that involves the pointer
14948 /// type, if known.
14949 ///
14950 /// \returns A suitable pointer type, if there are no
14951 /// errors. Otherwise, returns a NULL type.
14953 DeclarationName Entity);
14954
14955 /// Build a reference type.
14956 ///
14957 /// \param T The type to which we'll be building a reference.
14958 ///
14959 /// \param Loc The location of the entity whose type involves this
14960 /// reference type or, if there is no such entity, the location of the
14961 /// type that will have reference type.
14962 ///
14963 /// \param Entity The name of the entity that involves the reference
14964 /// type, if known.
14965 ///
14966 /// \returns A suitable reference type, if there are no
14967 /// errors. Otherwise, returns a NULL type.
14969 DeclarationName Entity);
14970
14971 /// Build an array type.
14972 ///
14973 /// \param T The type of each element in the array.
14974 ///
14975 /// \param ASM C99 array size modifier (e.g., '*', 'static').
14976 ///
14977 /// \param ArraySize Expression describing the size of the array.
14978 ///
14979 /// \param Brackets The range from the opening '[' to the closing ']'.
14980 ///
14981 /// \param Entity The name of the entity that involves the array
14982 /// type, if known.
14983 ///
14984 /// \returns A suitable array type, if there are no errors. Otherwise,
14985 /// returns a NULL type.
14987 unsigned Quals, SourceRange Brackets,
14988 DeclarationName Entity);
14990
14991 /// Build an ext-vector type.
14992 ///
14993 /// Run the required checks for the extended vector type.
14995 SourceLocation AttrLoc);
14996 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
14997 SourceLocation AttrLoc);
14998
15000 Expr *CountExpr,
15001 bool CountInBytes,
15002 bool OrNull);
15003
15004 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
15005 /// expression is uninstantiated. If instantiated it will apply the
15006 /// appropriate address space to the type. This function allows dependent
15007 /// template variables to be used in conjunction with the address_space
15008 /// attribute
15009 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
15010 SourceLocation AttrLoc);
15011
15012 /// Same as above, but constructs the AddressSpace index if not provided.
15014 SourceLocation AttrLoc);
15015
15017
15019
15020 /// Build a function type.
15021 ///
15022 /// This routine checks the function type according to C++ rules and
15023 /// under the assumption that the result type and parameter types have
15024 /// just been instantiated from a template. It therefore duplicates
15025 /// some of the behavior of GetTypeForDeclarator, but in a much
15026 /// simpler form that is only suitable for this narrow use case.
15027 ///
15028 /// \param T The return type of the function.
15029 ///
15030 /// \param ParamTypes The parameter types of the function. This array
15031 /// will be modified to account for adjustments to the types of the
15032 /// function parameters.
15033 ///
15034 /// \param Loc The location of the entity whose type involves this
15035 /// function type or, if there is no such entity, the location of the
15036 /// type that will have function type.
15037 ///
15038 /// \param Entity The name of the entity that involves the function
15039 /// type, if known.
15040 ///
15041 /// \param EPI Extra information about the function type. Usually this will
15042 /// be taken from an existing function with the same prototype.
15043 ///
15044 /// \returns A suitable function type, if there are no errors. The
15045 /// unqualified type will always be a FunctionProtoType.
15046 /// Otherwise, returns a NULL type.
15048 SourceLocation Loc, DeclarationName Entity,
15050
15051 /// Build a member pointer type \c T Class::*.
15052 ///
15053 /// \param T the type to which the member pointer refers.
15054 /// \param Class the class type into which the member pointer points.
15055 /// \param Loc the location where this type begins
15056 /// \param Entity the name of the entity that will have this member pointer
15057 /// type
15058 ///
15059 /// \returns a member pointer type, if successful, or a NULL type if there was
15060 /// an error.
15062 CXXRecordDecl *Cls, SourceLocation Loc,
15063 DeclarationName Entity);
15064
15065 /// Build a block pointer type.
15066 ///
15067 /// \param T The type to which we'll be building a block pointer.
15068 ///
15069 /// \param Loc The source location, used for diagnostics.
15070 ///
15071 /// \param Entity The name of the entity that involves the block pointer
15072 /// type, if known.
15073 ///
15074 /// \returns A suitable block pointer type, if there are no
15075 /// errors. Otherwise, returns a NULL type.
15077 DeclarationName Entity);
15078
15079 /// Build a paren type including \p T.
15082
15083 /// Build a Read-only Pipe type.
15084 ///
15085 /// \param T The type to which we'll be building a Pipe.
15086 ///
15087 /// \param Loc We do not use it for now.
15088 ///
15089 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15090 /// a NULL type.
15092
15093 /// Build a Write-only Pipe type.
15094 ///
15095 /// \param T The type to which we'll be building a Pipe.
15096 ///
15097 /// \param Loc We do not use it for now.
15098 ///
15099 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
15100 /// a NULL type.
15102
15103 /// Build a bit-precise integer type.
15104 ///
15105 /// \param IsUnsigned Boolean representing the signedness of the type.
15106 ///
15107 /// \param BitWidth Size of this int type in bits, or an expression
15108 /// representing that.
15109 ///
15110 /// \param Loc Location of the keyword.
15111 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
15112
15113 /// GetTypeForDeclarator - Convert the type for the specified
15114 /// declarator to Type instances.
15115 ///
15116 /// The result of this call will never be null, but the associated
15117 /// type may be a null type if there's an unrecoverable error.
15120
15121 /// Package the given type and TSI into a ParsedType.
15124 TypeSourceInfo **TInfo = nullptr);
15125
15127
15128 // Check whether the size of array element of type \p EltTy is a multiple of
15129 // its alignment and return false if it isn't.
15131
15132 void
15133 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
15134 SourceLocation FallbackLoc,
15135 SourceLocation ConstQualLoc = SourceLocation(),
15136 SourceLocation VolatileQualLoc = SourceLocation(),
15137 SourceLocation RestrictQualLoc = SourceLocation(),
15138 SourceLocation AtomicQualLoc = SourceLocation(),
15139 SourceLocation UnalignedQualLoc = SourceLocation());
15140
15141 /// Retrieve the keyword associated
15143
15144 /// Adjust the calling convention of a method to be the ABI default if it
15145 /// wasn't specified explicitly. This handles method types formed from
15146 /// function type typedefs and typename template arguments.
15147 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
15148 bool IsCtorOrDtor, SourceLocation Loc);
15149
15150 // Check if there is an explicit attribute, but only look through parens.
15151 // The intent is to look for an attribute on the current declarator, but not
15152 // one that came from a typedef.
15154
15155 /// Check whether a nullability type specifier can be added to the given
15156 /// type through some means not written in source (e.g. API notes).
15157 ///
15158 /// \param Type The type to which the nullability specifier will be
15159 /// added. On success, this type will be updated appropriately.
15160 ///
15161 /// \param Nullability The nullability specifier to add.
15162 ///
15163 /// \param DiagLoc The location to use for diagnostics.
15164 ///
15165 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
15166 /// array type (e.g., because it will decay to a pointer).
15167 ///
15168 /// \param OverrideExisting Whether to override an existing, locally-specified
15169 /// nullability specifier rather than complaining about the conflict.
15170 ///
15171 /// \returns true if nullability cannot be applied, false otherwise.
15173 NullabilityKind Nullability,
15174 SourceLocation DiagLoc,
15175 bool AllowArrayTypes,
15176 bool OverrideExisting);
15177
15178 /// Get the type of expression E, triggering instantiation to complete the
15179 /// type if necessary -- that is, if the expression refers to a templated
15180 /// static data member of incomplete array type.
15181 ///
15182 /// May still return an incomplete type if instantiation was not possible or
15183 /// if the type is incomplete for a different reason. Use
15184 /// RequireCompleteExprType instead if a diagnostic is expected for an
15185 /// incomplete expression type.
15187
15189
15190 /// Ensure that the type of the given expression is complete.
15191 ///
15192 /// This routine checks whether the expression \p E has a complete type. If
15193 /// the expression refers to an instantiable construct, that instantiation is
15194 /// performed as needed to complete its type. Furthermore
15195 /// Sema::RequireCompleteType is called for the expression's type (or in the
15196 /// case of a reference type, the referred-to type).
15197 ///
15198 /// \param E The expression whose type is required to be complete.
15199 /// \param Kind Selects which completeness rules should be applied.
15200 /// \param Diagnoser The object that will emit a diagnostic if the type is
15201 /// incomplete.
15202 ///
15203 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
15204 /// otherwise.
15206 TypeDiagnoser &Diagnoser);
15207 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
15208
15209 template <typename... Ts>
15210 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
15211 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15213 }
15214
15215 // Returns the underlying type of a decltype with the given expression.
15217
15219 /// If AsUnevaluated is false, E is treated as though it were an evaluated
15220 /// context, such as when building a type for decltype(auto).
15221 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
15222
15223 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
15224 SourceLocation Loc,
15225 SourceLocation EllipsisLoc);
15226 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
15227 SourceLocation Loc, SourceLocation EllipsisLoc,
15228 bool FullySubstituted = false,
15229 ArrayRef<QualType> Expansions = {});
15230
15231 using UTTKind = UnaryTransformType::UTTKind;
15233 SourceLocation Loc);
15239 SourceLocation Loc);
15241 SourceLocation Loc);
15243 SourceLocation Loc);
15244
15246 return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc);
15247 }
15248
15250 SourceLocation Loc);
15252 SourceLocation Loc);
15253
15254 bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);
15255
15256 /// Ensure that the type T is a literal type.
15257 ///
15258 /// This routine checks whether the type @p T is a literal type. If @p T is an
15259 /// incomplete type, an attempt is made to complete it. If @p T is a literal
15260 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
15261 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
15262 /// it the type @p T), along with notes explaining why the type is not a
15263 /// literal type, and returns true.
15264 ///
15265 /// @param Loc The location in the source that the non-literal type
15266 /// diagnostic should refer to.
15267 ///
15268 /// @param T The type that this routine is examining for literalness.
15269 ///
15270 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
15271 ///
15272 /// @returns @c true if @p T is not a literal type and a diagnostic was
15273 /// emitted, @c false otherwise.
15275 TypeDiagnoser &Diagnoser);
15276 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
15277
15278 template <typename... Ts>
15279 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID,
15280 const Ts &...Args) {
15281 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15282 return RequireLiteralType(Loc, T, Diagnoser);
15283 }
15284
15287 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
15288 }
15289
15290 /// Ensure that the type T is a complete type.
15291 ///
15292 /// This routine checks whether the type @p T is complete in any
15293 /// context where a complete type is required. If @p T is a complete
15294 /// type, returns false. If @p T is a class template specialization,
15295 /// this routine then attempts to perform class template
15296 /// instantiation. If instantiation fails, or if @p T is incomplete
15297 /// and cannot be completed, issues the diagnostic @p diag (giving it
15298 /// the type @p T) and returns true.
15299 ///
15300 /// @param Loc The location in the source that the incomplete type
15301 /// diagnostic should refer to.
15302 ///
15303 /// @param T The type that this routine is examining for completeness.
15304 ///
15305 /// @param Kind Selects which completeness rules should be applied.
15306 ///
15307 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
15308 /// @c false otherwise.
15310 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
15312 CompleteTypeKind Kind, unsigned DiagID);
15313
15315 TypeDiagnoser &Diagnoser) {
15316 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, Diagnoser);
15317 }
15318 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID) {
15319 return RequireCompleteType(Loc, T, CompleteTypeKind::Default, DiagID);
15320 }
15321
15322 template <typename... Ts>
15323 bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID,
15324 const Ts &...Args) {
15325 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15326 return RequireCompleteType(Loc, T, Diagnoser);
15327 }
15328
15329 /// Determine whether a declaration is visible to name lookup.
15330 bool isVisible(const NamedDecl *D) {
15331 return D->isUnconditionallyVisible() ||
15332 isAcceptableSlow(D, AcceptableKind::Visible);
15333 }
15334
15335 /// Determine whether a declaration is reachable.
15336 bool isReachable(const NamedDecl *D) {
15337 // All visible declarations are reachable.
15338 return D->isUnconditionallyVisible() ||
15339 isAcceptableSlow(D, AcceptableKind::Reachable);
15340 }
15341
15342 /// Determine whether a declaration is acceptable (visible/reachable).
15344 return Kind == AcceptableKind::Visible ? isVisible(D) : isReachable(D);
15345 }
15346
15347 /// Determine if \p D and \p Suggested have a structurally compatible
15348 /// layout as described in C11 6.2.7/1.
15349 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15350
15351 /// Determine if \p D has a visible definition. If not, suggest a declaration
15352 /// that should be made visible to expose the definition.
15353 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15354 bool OnlyNeedComplete = false);
15356 NamedDecl *Hidden;
15357 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15358 }
15359 /// Determine if \p D has a definition which allows we redefine it in current
15360 /// TU. \p Suggested is the definition that should be made visible to expose
15361 /// the definition.
15362 bool isRedefinitionAllowedFor(NamedDecl *D, NamedDecl **Suggested,
15363 bool &Visible);
15365 NamedDecl *Hidden;
15366 return isRedefinitionAllowedFor(const_cast<NamedDecl *>(D), &Hidden,
15367 Visible);
15368 }
15369
15370 /// Determine if \p D has a reachable definition. If not, suggest a
15371 /// declaration that should be made reachable to expose the definition.
15372 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15373 bool OnlyNeedComplete = false);
15375 NamedDecl *Hidden;
15376 return hasReachableDefinition(D, &Hidden);
15377 }
15378
15379 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15380 AcceptableKind Kind,
15381 bool OnlyNeedComplete = false);
15383 NamedDecl *Hidden;
15384 return hasAcceptableDefinition(D, &Hidden, Kind);
15385 }
15386
15387 /// Try to parse the conditional expression attached to an effect attribute
15388 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
15389 /// optional on error.
15390 std::optional<FunctionEffectMode>
15391 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
15392
15393private:
15394 /// The implementation of RequireCompleteType
15395 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15396 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15397
15398 /// Nullability type specifiers.
15399 IdentifierInfo *Ident__Nonnull = nullptr;
15400 IdentifierInfo *Ident__Nullable = nullptr;
15401 IdentifierInfo *Ident__Nullable_result = nullptr;
15402 IdentifierInfo *Ident__Null_unspecified = nullptr;
15403
15404 ///@}
15405
15406 //
15407 //
15408 // -------------------------------------------------------------------------
15409 //
15410 //
15411
15412 /// \name FixIt Helpers
15413 /// Implementations are in SemaFixItUtils.cpp
15414 ///@{
15415
15416public:
15417 /// Get a string to suggest for zero-initialization of a type.
15419 SourceLocation Loc) const;
15420 std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
15421
15422 ///@}
15423
15424 //
15425 //
15426 // -------------------------------------------------------------------------
15427 //
15428 //
15429
15430 /// \name Function Effects
15431 /// Implementations are in SemaFunctionEffects.cpp
15432 ///@{
15433public:
15436
15439 std::optional<FunctionEffectWithCondition>
15440 Old; // Invalid when 'Kind' is 'Added'.
15441 std::optional<FunctionEffectWithCondition>
15442 New; // Invalid when 'Kind' is 'Removed'.
15443
15444 StringRef effectName() const {
15445 if (Old)
15446 return Old.value().Effect.name();
15447 return New.value().Effect.name();
15448 }
15449
15450 /// Describes the result of effects differing between a base class's virtual
15451 /// method and an overriding method in a subclass.
15452 enum class OverrideResult {
15455 Merge // Merge missing effect from base to derived.
15456 };
15457
15458 /// Return true if adding or removing the effect as part of a type
15459 /// conversion should generate a diagnostic.
15461 const FunctionEffectsRef &SrcFX,
15462 QualType DstType,
15463 const FunctionEffectsRef &DstFX) const;
15464
15465 /// Return true if adding or removing the effect in a redeclaration should
15466 /// generate a diagnostic.
15467 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
15468 const FunctionEffectsRef &OldFX,
15469 const FunctionDecl &NewFunction,
15470 const FunctionEffectsRef &NewFX) const;
15471
15472 /// Return true if adding or removing the effect in a C++ virtual method
15473 /// override should generate a diagnostic.
15475 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
15476 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
15477 };
15478
15479 struct FunctionEffectDiffVector : public SmallVector<FunctionEffectDiff> {
15480 /// Caller should short-circuit by checking for equality first.
15482 const FunctionEffectsRef &New);
15483 };
15484
15485 /// All functions/lambdas/blocks which have bodies and which have a non-empty
15486 /// FunctionEffectsRef to be verified.
15488
15489 /// The union of all effects present on DeclsWithEffectsToVerify. Conditions
15490 /// are all null.
15492
15493public:
15494 /// Warn and return true if adding a function effect to a set would create a
15495 /// conflict.
15498 SourceLocation NewAttrLoc);
15499
15500 // Report a failure to merge function effects between declarations due to a
15501 // conflict.
15502 void
15504 SourceLocation NewLoc,
15505 SourceLocation OldLoc);
15506
15507 /// Inline checks from the start of maybeAddDeclWithEffects, to
15508 /// minimize performance impact on code not using effects.
15509 template <class FuncOrBlockDecl>
15510 void maybeAddDeclWithEffects(FuncOrBlockDecl *D) {
15511 if (Context.hasAnyFunctionEffects())
15512 if (FunctionEffectsRef FX = D->getFunctionEffects(); !FX.empty())
15514 }
15515
15516 /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify.
15517 void maybeAddDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15518
15519 /// Unconditionally add a Decl to DeclsWithEfffectsToVerify.
15520 void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15521
15523
15524 ///@}
15525};
15526
15527DeductionFailureInfo
15529 sema::TemplateDeductionInfo &Info);
15530
15531/// Contains a late templated function.
15532/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15535 /// The template function declaration to be late parsed.
15537 /// Floating-point options in the point of definition.
15539};
15540
15541template <>
15543 PragmaMsStackAction Action,
15544 llvm::StringRef StackSlotLabel,
15546
15547} // end namespace clang
15548
15549#endif
#define V(N, I)
Forward declaration of all AST node types.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines enum values for all the target-independent builtin functions.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
Defines enumerations for expression traits intrinsics.
Token Tok
The Token.
FormatToken * Previous
The previous token in the unwrapped line.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
Definition MachO.h:31
Defines the clang::Module class, which describes a module in the source code.
#define SM(sm)
Defines the clang::OpenCLOptions class.
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
AccessResult
A copy of Sema's enum without AR_delayed.
CastType
Definition SemaCast.cpp:49
static void CheckFormatString(Sema &S, const FormatStringLiteral *FExpr, const StringLiteral *ReferenceFormatString, const Expr *OrigFormatExpr, ArrayRef< const Expr * > Args, Sema::FormatArgumentPassingKind APK, unsigned format_idx, unsigned firstDataArg, FormatStringType Type, bool inFunctionCall, VariadicCallType CallType, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg, bool IgnoreStringsWithoutSpecifiers)
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
Sema::AllowedExplicit AllowedExplicit
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Defines a utilitiy for warning once when close to out of stack space.
Defines the clang::TemplateNameKind enum.
Defines the clang::TokenKind enum and support functions.
Defines the clang::TypeLoc interface and its subclasses.
Defines enumerations for the type traits support.
TypePropertyCache< Private > Cache
Definition Type.cpp:4792
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:188
Represents a member of a struct/union/class.
Definition Decl.h:3157
a trap message and trap category.
A class for storing results from argument-dependent lookup.
Definition Lookup.h:871
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:122
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition ASTConsumer.h:34
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:188
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Reads an AST files chain containing the contents of a translation unit.
Definition ASTReader.h:430
Writes an AST file containing the contents of a translation unit.
Definition ASTWriter.h:97
Represents an access specifier followed by colon ':'.
Definition DeclCXX.h:86
PtrTy get() const
Definition Ownership.h:171
bool isInvalid() const
Definition Ownership.h:167
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2721
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition TypeBase.h:3720
Attr - This represents one attribute.
Definition Attr.h:44
Represents a C++ declaration that introduces decls from somewhere else.
Definition DeclCXX.h:3496
A binding in a decomposition declaration.
Definition DeclCXX.h:4185
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4651
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
Definition DeclCXX.h:146
Represents a C++ constructor within a class.
Definition DeclCXX.h:2604
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2943
Represents a C++ base or member initializer.
Definition DeclCXX.h:2369
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2620
Represents a C++ destructor within a class.
Definition DeclCXX.h:2869
CXXFieldCollector - Used to keep track of CXXFieldDecls during parsing of C++ classes.
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2129
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Represents a C++ nested-name-specifier or a global scope specifier.
Definition DeclSpec.h:73
Represents the this expression in C++.
Definition ExprCXX.h:1155
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:69
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2877
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4923
CaseStmt - Represent a case statement.
Definition Stmt.h:1920
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3610
CharUnits - This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
Abstract interface for a consumer of code-completion information.
Declaration of a C++20 concept.
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:37
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition DeclCXX.h:3677
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
The information about the darwin SDK that was used during this compilation.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
Definition DeclBase.h:1382
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1449
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1270
Captures information about "declaration specifiers".
Definition DeclSpec.h:217
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Definition DeclBase.h:859
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition DeclBase.h:842
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:978
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:779
Information about one declarator, including the parsed type information and the identifier.
Definition DeclSpec.h:1874
A decomposition declaration.
Definition DeclCXX.h:4249
Captures a template argument whose value has been deduced via c++ template argument deduction.
Definition Template.h:327
A dependently-generated diagnostic.
Designation - Represent a full designation, which is a sequence of designators.
Definition Designator.h:208
A little helper class used to produce diagnostics.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:231
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3420
Represents an enum.
Definition Decl.h:4004
Store information needed for an explicit specifier.
Definition DeclCXX.h:1924
The return type of classify().
Definition Expr.h:337
This represents one expression.
Definition Expr.h:112
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition Expr.h:194
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
Definition Expr.h:802
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition Expr.cpp:273
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:3157
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:257
FileNullability & operator[](FileID file)
Definition Sema.h:268
FileNullability Nullability
Definition Sema.h:264
Represents a function declaration or definition.
Definition Decl.h:1999
A mutable set of FunctionEffect::Kind.
Definition TypeBase.h:5118
SmallVector< Conflict > Conflicts
Definition TypeBase.h:5232
Kind
Identifies the particular effect.
Definition TypeBase.h:4880
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition TypeBase.h:5064
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4835
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5264
Declaration of a template function.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition TypeBase.h:4486
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4460
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:615
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3464
Describes an C or C++ initializer list.
Definition Expr.h:5233
Describes the kind of initialization being performed, along with location information for tokens rela...
Describes the sequence of initializations required to initialize a given object or reference with a s...
Describes an entity that is being initialized.
Represents the declaration of a label.
Definition Decl.h:523
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:365
Represents the results of name lookup.
Definition Lookup.h:147
A global _GUID constant.
Definition DeclCXX.h:4398
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4344
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:4914
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3298
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition TypeBase.h:3651
Abstract interface for a module loader.
Describes a module or submodule.
Definition Module.h:144
Data structure that captures multiple levels of template argument lists for use in template instantia...
Definition Template.h:76
This represents a decl that may have a name.
Definition Decl.h:273
Represent a C++ namespace.
Definition Decl.h:591
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents an ObjC class declaration.
Definition DeclObjC.h:1154
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition TypeBase.h:7903
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:1153
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Definition Attr.h:290
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2182
Represents a parameter to a function.
Definition Decl.h:1789
ParsedAttr - Represents a syntactic attribute.
Definition ParsedAttr.h:119
ParsedAttributes - A collection of parsed attributes.
Definition ParsedAttr.h:937
Represents the parsed form of a C++ template argument.
void Emit(const DiagnosticBuilder &DB) const
PreferredTypeBuilder(ASTContext *Ctx, bool Enabled)
Definition Sema.h:291
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:327
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:2688
A (possibly-)qualified type.
Definition TypeBase.h:937
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
Represents a struct/union/class.
Definition Decl.h:4309
Represents the body of a requires-expression.
Definition DeclCXX.h:2098
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:41
Smart pointer class that efficiently represents Objective-C method names.
A generic diagnostic builder for errors which may or may not be deferred.
Definition SemaBase.h:111
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition SemaBase.cpp:61
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
AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
Definition Sema.h:1844
bool operator==(const AlignPackInfo &Info) const
Definition Sema.h:1904
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition Sema.h:1876
unsigned getPackNumber() const
Definition Sema.h:1894
bool IsXLStack() const
Definition Sema.h:1902
bool IsPackSet() const
Definition Sema.h:1896
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition Sema.h:1850
bool IsAlignAttr() const
Definition Sema.h:1890
bool IsPackAttr() const
Definition Sema.h:1888
bool operator!=(const AlignPackInfo &Info) const
Definition Sema.h:1910
AlignPackInfo(bool IsXL)
Definition Sema.h:1854
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition Sema.h:1861
Mode getAlignMode() const
Definition Sema.h:1892
ArgPackSubstIndexRAII(Sema &Self, UnsignedOrNone NewSubstIndex)
Definition Sema.h:13508
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8231
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8236
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition Sema.h:8223
std::tuple< const Ts &... > Args
Definition Sema.h:8220
CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals, bool Enabled=true)
Introduce a new scope where 'this' may be allowed (when enabled), using the given declaration (which ...
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition Sema.h:1291
std::pair< VarDecl *, Expr * > get() const
Definition Sema.h:7776
std::optional< bool > getKnownValue() const
Definition Sema.h:7780
A RAII object to temporarily push a declaration context.
Definition Sema.h:3475
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition Sema.h:3485
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition Sema.h:10267
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:10272
virtual bool match(QualType T)=0
Determine whether the specified type is a valid destination type for this conversion.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
DefaultedComparisonKind asComparison() const
Definition Sema.h:6352
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition Sema.h:6329
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition Sema.h:6357
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition Sema.h:6332
CXXSpecialMemberKind asSpecialMember() const
Definition Sema.h:6349
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition Sema.h:10006
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition Sema.h:1358
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition Sema.h:1377
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition Sema.h:1401
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition Sema.h:1370
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition Sema.h:1373
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:1387
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition Sema.h:1393
A helper class for building up ExtParameterInfos.
Definition Sema.h:12914
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:12933
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition Sema.h:12921
FPOptionsOverride getOverrides()
Definition Sema.h:13892
FullExprArg(Sema &actions)
Definition Sema.h:7720
ExprResult release()
Definition Sema.h:7722
friend class Sema
Definition Sema.h:7731
Expr * get() const
Definition Sema.h:7724
GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
Definition Sema.h:13904
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:10331
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:10323
unsigned size() const
The number of exceptions in the exception specification.
Definition Sema.h:5451
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition Sema.h:5444
const QualType * data() const
The set of exceptions in the exception specification.
Definition Sema.h:5454
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:5460
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition Sema.h:5467
LambdaScopeForCallOperatorInstantiationRAII(Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope, bool ShouldAddDeclsFromParentScope=true)
LocalEagerInstantiationScope(Sema &S, bool AtEndOfTU)
Definition Sema.h:13861
static NameClassification DependentNonType()
Definition Sema.h:3689
static NameClassification VarTemplate(TemplateName Name)
Definition Sema.h:3699
ExprResult getExpression() const
Definition Sema.h:3725
NameClassification(const IdentifierInfo *Keyword)
Definition Sema.h:3662
static NameClassification Unknown()
Definition Sema.h:3669
static NameClassification OverloadSet(ExprResult E)
Definition Sema.h:3673
NameClassificationKind getKind() const
Definition Sema.h:3723
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition Sema.h:3717
static NameClassification FunctionTemplate(TemplateName Name)
Definition Sema.h:3705
NamedDecl * getNonTypeDecl() const
Definition Sema.h:3735
NameClassification(ParsedType Type)
Definition Sema.h:3659
TemplateName getTemplateName() const
Definition Sema.h:3740
ParsedType getType() const
Definition Sema.h:3730
TemplateNameKind getTemplateNameKind() const
Definition Sema.h:3749
static NameClassification NonType(NamedDecl *D)
Definition Sema.h:3679
static NameClassification Concept(TemplateName Name)
Definition Sema.h:3711
static NameClassification UndeclaredNonType()
Definition Sema.h:3685
static NameClassification TypeTemplate(TemplateName Name)
Definition Sema.h:3693
static NameClassification Error()
Definition Sema.h:3665
void operator()(sema::FunctionScopeInfo *Scope) const
Definition Sema.cpp:2466
PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct)
Definition SemaAttr.cpp:29
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition Sema.h:11354
SourceLocation getTemplateKeywordLoc() const
Definition Sema.h:11356
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition Sema.h:11351
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition Sema.h:12366
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition Sema.h:12399
SFINAETrap(Sema &SemaRef, bool ForValidityCheck=false)
Definition Sema.h:12377
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition Sema.h:8248
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition Sema.h:8253
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition Sema.h:8250
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition Sema.h:9270
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition Sema.h:9257
CXXMethodDecl * getMethod() const
Definition Sema.h:9260
void setMethod(CXXMethodDecl *MD)
Definition Sema.h:9261
void addContextNote(SourceLocation UseLoc)
Definition Sema.h:13409
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition Sema.h:13397
SourceLocation getLocation() const
Definition Sema.h:12140
bool ContainsDecl(const NamedDecl *ND) const
Definition Sema.h:12130
const DeclContext * getDeclContext() const
Definition Sema.h:12136
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition Sema.h:12114
const NamedDecl * getDecl() const
Definition Sema.h:12128
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition Sema.h:12113
const DeclContext * getLexicalDeclContext() const
Definition Sema.h:12132
TentativeAnalysisScope(Sema &SemaRef)
Definition Sema.h:12415
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition Sema.h:7679
virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc)
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:853
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)
QualType CheckSizelessVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
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:1419
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:3567
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:13453
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:8153
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
Definition SemaAttr.cpp:503
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition Sema.h:13437
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:10915
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition Sema.h:12943
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
Definition Sema.cpp:2539
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
Scope * getCurScope() const
Retrieve the parser's current scope.
Definition Sema.h:1119
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:1562
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:13846
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
void PopParsingClass(ParsingClassState state)
Definition Sema.h:6520
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:10017
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition Sema.cpp:1061
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
std::optional< QualType > BuiltinVectorMath(CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr=EltwiseBuiltinArgTyRestriction::None)
bool CheckExplicitObjectOverride(CXXMethodDecl *New, const CXXMethodDecl *Old)
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
Definition Sema.h:6509
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
QualType CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs, SmallVectorImpl< const Attr * > &OutAttrs)
Process the attributes before creating an attributed statement.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
Unary Operators. 'Tok' is the token for the operator.
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition Sema.h:8203
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:8121
bool isExternalWithNoLinkageType(const ValueDecl *VD) const
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
Definition Sema.cpp:935
bool isAttrContext() const
Definition Sema.h:6911
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:8196
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition Sema.cpp:2639
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition Sema.h:6271
LookupNameKind
Describes the kind of name lookup to perform.
Definition Sema.h:9286
@ LookupLabel
Label name lookup.
Definition Sema.h:9295
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition Sema.h:9290
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition Sema.h:9317
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition Sema.h:9309
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition Sema.h:9331
@ LookupLocalFriendName
Look up a friend of a local class.
Definition Sema.h:9325
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition Sema.h:9327
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition Sema.h:9322
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition Sema.h:9302
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition Sema.h:9329
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition Sema.h:9313
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition Sema.h:9298
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition Sema.h:9305
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition Sema.h:9293
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition Sema.h:9333
@ LookupAnyName
Look up any declaration with any name.
Definition Sema.h:9335
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:405
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition Sema.h:9236
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition Sema.h:4870
UnaryTransformType::UTTKind UTTKind
Definition Sema.h:15231
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
void ActOnPopScope(SourceLocation Loc, Scope *S)
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
ActOnPragmaDetectMismatch - Call on well-formed #pragma detect_mismatch.
Definition SemaAttr.cpp:628
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:6208
SemaM68k & M68k()
Definition Sema.h:1469
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:13518
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.
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:1353
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
bool BuildTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc, bool AllowUnexpandedPack)
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
const Decl * PragmaAttributeCurrentTargetDecl
The declaration that is currently receiving an attribute from the pragma attribute stack.
Definition Sema.h:2109
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:9724
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:4815
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:5012
OpaquePtr< QualType > TypeTy
Definition Sema.h:1275
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:167
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
bool CheckCXXThisType(SourceLocation Loc, QualType Type)
Check whether the type of 'this' is valid in the current context.
void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body)
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class)
Perform qualified name lookup into all base classes of the given class.
void addImplicitTypedef(StringRef Name, QualType T)
Definition Sema.cpp:367
void PrintContextStack()
Definition Sema.h:13527
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc, StringRef Keyword)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition SemaStmt.cpp:631
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings={})
SemaOpenMP & OpenMP()
Definition Sema.h:1504
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition Sema.h:9235
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:2284
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition Sema.h:6246
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition Sema.h:9600
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt={})
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition Sema.h:1345
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
bool BoundsSafetyCheckAssignmentToCountAttrPtr(QualType LHSTy, Expr *RHSExpr, AssignmentAction Action, SourceLocation Loc, const ValueDecl *Assignee, bool ShowFullyQualifiedAssigneeName)
Perform Bounds Safety Semantic checks for assigning to a __counted_by or __counted_by_or_null pointer...
void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
void CheckExplicitObjectMemberFunction(Declarator &D, DeclarationName Name, QualType R, bool IsLambda, DeclContext *DC=nullptr)
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6....
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition Sema.h:14910
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:1240
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:4728
void CheckFloatComparison(SourceLocation Loc, const Expr *LHS, const Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition Sema.h:3549
PragmaClangSection PragmaClangRodataSection
Definition Sema.h:1816
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:15355
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:6482
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:5106
void emitAndClearUnusedLocalTypedefWarnings()
Definition Sema.cpp:1152
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Definition Sema.h:6463
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
Definition SemaStmt.cpp:85
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
TemplateName SubstTemplateName(SourceLocation TemplateKWLoc, NestedNameSpecifierLoc &QualifierLoc, TemplateName Name, SourceLocation NameLoc, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
VarDecl * buildCoroutinePromise(SourceLocation Loc)
unsigned CapturingFunctionScopes
Track the number of currently active capturing scopes.
Definition Sema.h:1229
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:1444
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:373
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
Definition Sema.h:7796
@ Switch
An integral condition for a 'switch' statement.
Definition Sema.h:7798
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
Definition Sema.h:7797
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition Sema.h:1322
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:15314
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition Sema.h:14916
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
bool needsRebuildOfDefaultArgOrInit() const
Definition Sema.h:8141
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:9837
@ Interface
'export module X;'
Definition Sema.h:9834
@ Implementation
'module X;'
Definition Sema.h:9835
@ PartitionInterface
'export module X:Y;'
Definition Sema.h:9836
SourceLocation LocationOfExcessPrecisionNotSatisfied
Definition Sema.h:8283
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition Sema.h:1222
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:9547
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition Sema.h:10350
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition Sema.h:10353
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition Sema.h:10359
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition Sema.h:10357
void inferLifetimeCaptureByAttribute(FunctionDecl *FD)
Add [[clang:lifetime_capture_by(this)]] to STL container methods.
Definition SemaAttr.cpp:277
void RefersToMemberWithReducedAlignment(Expr *E, llvm::function_ref< void(Expr *, RecordDecl *, FieldDecl *, CharUnits)> Action)
This function calls Action when it determines that E designates a misaligned member due to the packed...
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType)
Definition Sema.h:1774
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
@ AR_dependent
Definition Sema.h:1659
@ AR_accessible
Definition Sema.h:1657
@ AR_inaccessible
Definition Sema.h:1658
@ AR_delayed
Definition Sema.h:1660
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Definition Sema.cpp:2442
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:14923
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
Definition Sema.h:14927
bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA)
Check whether the given statement can have musttail applied to it, issuing a diagnostic and returning...
Definition SemaStmt.cpp:660
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, SourceLocation EllipsisLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
Preprocessor & getPreprocessor() const
Definition Sema.h:923
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition Sema.h:6889
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition Sema.cpp:2311
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope, LabelDecl *Label, SourceLocation LabelLoc)
QualType GetSignedSizelessVectorType(QualType V)
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition Sema.h:13440
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
void ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, Scope *CurContext)
Once the Lambdas capture are known, we can start to create the closure, call operator method,...
FunctionTemplateDecl * DeclareAggregateDeductionGuideFromInitList(TemplateDecl *Template, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc)
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:438
void AddTemplateParametersToLambdaCallOperator(CXXMethodDecl *CallOperator, CXXRecordDecl *Class, TemplateParameterList *TemplateParams)
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
Annotation attributes are the only attributes allowed after an access specifier.
FunctionDecl * getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2)
Returns the more constrained function according to the rules of partial ordering by constraints (C++ ...
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
llvm::SmallPtrSet< ConstantExpr *, 4 > FailedImmediateInvocations
Definition Sema.h:8272
void deduceOpenCLAddressSpace(ValueDecl *decl)
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition Sema.h:2047
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
DefaultedComparisonKind getDefaultedComparisonKind(const FunctionDecl *FD)
Definition Sema.h:8184
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition Sema.h:14917
PragmaStack< StringLiteral * > CodeSegStack
Definition Sema.h:2041
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:15491
void setFunctionHasBranchIntoScope()
Definition Sema.cpp:2492
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:4875
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition SemaStmt.cpp:485
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimizeoff". If this location is invalid,...
Definition Sema.h:2118
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:6723
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool CheckOverridingFunctionAttributes(CXXMethodDecl *New, const CXXMethodDecl *Old)
void ActOnPragmaMSComment(SourceLocation CommentLoc, PragmaMSCommentKind Kind, StringRef Arg)
ActOnPragmaMSComment - Called on well formed #pragma comment(kind, "arg").
Definition SemaAttr.cpp:620
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition Sema.h:2036
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:11072
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
Definition SemaAttr.cpp:54
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
bool CheckFormatStringsCompatible(FormatStringType FST, const StringLiteral *AuthoritativeFormatString, const StringLiteral *TestedFormatString, const Expr *FunctionCallArg=nullptr)
Verify that two format strings (as understood by attribute(format) and attribute(format_matches) are ...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver)
If VD is set but not otherwise used, diagnose, for a parameter or a variable.
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext)
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation, bool ReportInvalid)
type checking for vector binary operators.
void ActOnComment(SourceRange Comment)
Definition Sema.cpp:2591
bool IsCXXTriviallyRelocatableType(QualType T)
Determines if a type is trivially relocatable according to the C++26 rules.
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
@ Other
C++26 [dcl.fct.def.general]p1 function-body: ctor-initializer[opt] compound-statement function-try-bl...
Definition Sema.h:4131
@ Default
= default ;
Definition Sema.h:4133
@ Delete
deleted-function-body
Definition Sema.h:4139
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
bool RequireStructuralType(QualType T, SourceLocation Loc)
Require the given type to be a structural type, and diagnose if it is not.
ExprResult VerifyBitField(SourceLocation FieldLoc, const IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width,...
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
llvm::function_ref< void(llvm::raw_ostream &)> EntityPrinter
Definition Sema.h:13808
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
Definition SemaStmt.cpp:48
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
TemplateDeductionResult FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, SmallVectorImpl< OriginalCallArg > const *OriginalCallArgs, bool PartialOverloading, bool PartialOrdering, bool ForOverloadSetAddressResolution, llvm::function_ref< bool(bool)> CheckNonDependent=[](bool) { return false;})
Finish template argument deduction for a function template, checking the deduced template arguments f...
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition Sema.cpp:1231
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
ExprResult EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, const APValue &PreNarrowingValue)
EvaluateConvertedConstantExpression - Evaluate an Expression That is a converted constant expression ...
ConceptDecl * ActOnFinishConceptDefinition(Scope *S, ConceptDecl *C, Expr *ConstraintExpr, const ParsedAttributesView &Attrs)
FPOptionsOverride CurFPFeatureOverrides()
Definition Sema.h:2048
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:1459
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation=false, bool RetainFunctionScopeInfo=false)
Performs semantic analysis at the end of a function body.
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types?
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef)
Add an init-capture to a lambda scope.
FieldDecl * BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture)
Build a FieldDecl suitable to hold the given capture.
concepts::Requirement * ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc)
void ActOnPragmaMSSeg(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, StringLiteral *SegmentName, llvm::StringRef PragmaName)
Called on well formed #pragma bss_seg/data_seg/const_seg/code_seg.
Definition SemaAttr.cpp:847
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
void CheckThreadLocalForLargeAlignment(VarDecl *VD)
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc)
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
bool IsInsideALocalClassWithinATemplateFunction()
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
void ActOnTranslationUnitScope(Scope *S)
Scope actions.
Definition Sema.cpp:172
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition Sema.h:1529
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:2866
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:6901
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:1647
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
bool CheckConceptUseInDefinition(NamedDecl *Concept, SourceLocation Loc)
void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action, PragmaFloatControlKind Value)
ActOnPragmaFloatControl - Call on well-formed #pragma float_control.
Definition SemaAttr.cpp:663
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
Definition SemaExpr.cpp:827
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition Sema.h:11319
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT)
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition Sema.h:11899
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition Sema.h:11910
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition Sema.h:11902
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition Sema.h:11906
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:671
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
void ActOnPragmaMSPointersToMembers(LangOptions::PragmaMSPointersToMembersKind Kind, SourceLocation PragmaLoc)
ActOnPragmaMSPointersToMembers - called on well formed #pragma pointers_to_members(representation met...
Definition SemaAttr.cpp:717
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old)
[module.interface]p6: A redeclaration of an entity X is implicitly exported if X was introduced by an...
void DiagnosePrecisionLossInComplexDivision()
ExprResult CheckUnevaluatedOperand(Expr *E)
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
Definition Sema.h:9230
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
SemaX86 & X86()
Definition Sema.h:1549
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Look for instances where it is likely the comma operator is confused with another operator.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
llvm::DenseMap< NamedDecl *, NamedDecl * > VisibleNamespaceCache
Map from the most recent declaration of a namespace to the most recent visible declaration of that na...
Definition Sema.h:13457
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:1282
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:8108
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
Definition Sema.cpp:680
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
bool DiagIfReachable(SourceLocation Loc, ArrayRef< const Stmt * > Stmts, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the statements's reachability analysis.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E)
LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION()
This virtual key function only exists to limit the emission of debug info describing the Sema class.
bool ConstraintExpressionDependsOnEnclosingTemplate(const FunctionDecl *Friend, unsigned TemplateDepth, const Expr *Constraint)
bool BoundsSafetyCheckUseOfCountAttrPtr(const Expr *E)
Perform Bounds Safety semantic checks for uses of invalid uses counted_by or counted_by_or_null point...
void LazyProcessLifetimeCaptureByParams(FunctionDecl *FD)
bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc, TemplateDecl *PrimaryTemplate, unsigned NumExplicitArgs, ArrayRef< TemplateArgument > Args)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc)
ActOnCXXNullPtrLiteral - Parse 'nullptr'.
void ActOnCapturedRegionError()
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
IdentifierSourceLocations TypoCorrectionFailures
A cache containing identifiers for which typo correction failed and their locations,...
Definition Sema.h:9241
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition Sema.h:7741
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc)
ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Definition SemaAttr.cpp:935
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
Definition Sema.h:13464
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
Definition Sema.h:921
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void DiagnoseTypeTraitDetails(const Expr *E)
If E represents a built-in type trait, or a known standard type trait, try to print more information ...
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod)
The parser has left a submodule.
void CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC, bool *ICContext=nullptr, bool IsListInit=false)
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, CheckNonDependentConversionsFlag UserConversionFlag, CXXRecordDecl *ActingContext=nullptr, QualType ObjectType=QualType(), Expr::Classification ObjectClassification={}, OverloadCandidateParamOrder PO={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
void * SkippedDefinitionContext
Definition Sema.h:4357
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15279
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
void resetFPOptions(FPOptions FPO)
Definition Sema.h:11297
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition Sema.h:15382
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:9821
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:14906
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
SemaObjC & ObjC()
Definition Sema.h:1489
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:2821
bool isRedefinitionAllowedFor(NamedDecl *D, NamedDecl **Suggested, bool &Visible)
Determine if D has a definition which allows we redefine it in current TU.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
bool FunctionParamTypesAreEqual(ArrayRef< QualType > Old, ArrayRef< QualType > New, unsigned *ArgPos=nullptr, bool Reversed=false)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their param...
SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags
Diagnostics that are emitted only if we discover that the given function must be codegen'ed.
Definition Sema.h:1414
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition SemaDecl.cpp:75
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool FullySubstituted=false)
void InstantiateMemInitializers(CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, const MultiLevelTemplateArgumentList &TemplateArgs)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
void ActOnPragmaMSAllocText(SourceLocation PragmaLocation, StringRef Section, const SmallVector< std::tuple< IdentifierInfo *, SourceLocation > > &Functions)
Called on well-formed #pragma alloc_text().
Definition SemaAttr.cpp:899
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition Sema.h:3148
bool captureSwiftVersionIndependentAPINotes()
Whether APINotes should be gathered for all applicable Swift language versions, without being applied...
Definition Sema.h:1640
PragmaStack< bool > StrictGuardStackCheckStack
Definition Sema.h:2044
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void PrintInstantiationStack()
Definition Sema.h:13531
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:3557
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:748
bool isImmediateFunctionContext() const
Definition Sema.h:8133
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:924
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Definition Sema.h:1058
void addExternalSource(IntrusiveRefCntPtr< ExternalSemaSource > E)
Registers an external source.
Definition Sema.cpp:657
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition SemaExpr.cpp:758
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:6489
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)
ASTContext::CXXRecordDeclRelocationInfo CheckCXX2CRelocatableAndReplaceable(const clang::CXXRecordDecl *D)
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition Sema.h:1407
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:6573
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:2040
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
Definition Sema.cpp:756
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
Definition SemaAttr.cpp:334
bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction, const FunctionDecl *NewFunction, unsigned *ArgPos=nullptr, bool Reversed=false)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
Definition SemaExpr.cpp:877
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, SourceLocation TildeLoc, UnqualifiedId &SecondTypeName)
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S)
isMicrosoftMissingTypename - In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal...
Definition SemaDecl.cpp:695
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition Sema.h:2588
ParsingClassState PushParsingClass()
Definition Sema.h:6516
@ FRS_Success
Definition Sema.h:10738
@ FRS_DiagnosticIssued
Definition Sema.h:10740
@ FRS_NoViableFunction
Definition Sema.h:10739
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:13970
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:966
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition Sema.h:9283
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:9233
bool BuiltinVectorToScalarMath(CallExpr *TheCall)
bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn)
We've just determined that Old and New both appear to be definitions of the same variable.
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition Sema.h:6041
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
Definition Sema.h:6055
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
Definition Sema.h:6052
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
Definition Sema.h:6049
@ None
This is not a defaultable comparison operator.
Definition Sema.h:6043
@ Equal
This is an operator== that should be implemented as a series of subobject comparisons.
Definition Sema.h:6046
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool UseMemberUsingDeclRules)
Determine whether the given New declaration is an overload of the declarations in Old.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, ParsedType LhsTy, Expr *DimExpr, SourceLocation RParen)
ActOnArrayTypeTrait - Parsed one of the binary type trait support pseudo-functions.
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
llvm::SmallVector< QualType, 4 > CurrentParameterCopyTypes
Stack of types that correspond to the parameter entities that are currently being copy-initialized.
Definition Sema.h:8972
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:15487
@ Conversions
Allow explicit conversion functions but not explicit constructors.
Definition Sema.h:10068
@ All
Allow both explicit conversion functions and explicit constructors.
Definition Sema.h:10070
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:1212
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition Sema.h:6504
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
void * SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS)
Given a C++ nested-name-specifier, produce an annotation value that the parser can use later to recon...
ValueDecl * tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl, CXXScopeSpec &SS, ParsedType TemplateTypeTy, IdentifierInfo *MemberOrBase)
void ProcessPragmaWeak(Scope *S, Decl *D)
void DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range, DeclarationName Name, OverloadCandidateSet &CandidateSet, FunctionDecl *Fn, MultiExprArg Args, bool IsMember=false)
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation, bool IsUsingIfExists)
Builds a using declaration.
bool BuiltinConstantArg(CallExpr *TheCall, unsigned ArgNum, llvm::APSInt &Result)
BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr TheCall is a constant expression.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition Sema.h:1190
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
bool IsComplexPromotion(QualType FromType, QualType ToType)
Determine if a conversion is a complex promotion.
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union.
bool CheckDeclCompatibleWithTemplateTemplate(TemplateDecl *Template, TemplateTemplateParmDecl *Param, const TemplateArgumentLoc &Arg)
void ActOnPragmaFPEvalMethod(SourceLocation Loc, LangOptions::FPEvalMethodKind Value)
Definition SemaAttr.cpp:636
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
Definition Sema.h:3580
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Definition Sema.cpp:1652
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:2582
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition Sema.h:3472
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 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)
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
Definition Sema.h:11309
void setFunctionHasIndirectGoto()
Definition Sema.cpp:2502
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...
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:12072
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition Sema.h:12090
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition Sema.h:12080
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition Sema.h:12100
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:4866
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
bool AddingCFIUncheckedCallee(QualType From, QualType To) const
Returns true if From is a function or pointer to a function without the cfi_unchecked_callee attribut...
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
Definition Sema.cpp:1666
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:8314
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
Definition SemaAttr.cpp:389
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr * > Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
AssumedTemplateKind
Definition Sema.h:11369
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
Definition Sema.h:11376
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
Definition Sema.h:11373
bool CheckParamExceptionSpec(const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const FunctionProtoType *Target, bool SkipTargetFirstParameter, SourceLocation TargetLoc, const FunctionProtoType *Source, bool SkipSourceFirstParameter, SourceLocation SourceLoc)
CheckParamExceptionSpec - Check if the parameter and return types of the two functions have equivalen...
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, OverloadCandidateParamOrder PO={})
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
Definition SemaAttr.cpp:795
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfMove - Emits a warning if a value is moved to itself.
bool isSameOrCompatibleFunctionType(QualType Param, QualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment,...
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
AtomicArgumentOrder
Definition Sema.h:2700
void PushFunctionScope()
Enter a new function scope.
Definition Sema.cpp:2330
ExprResult ActOnNameClassifiedAsNonType(Scope *S, const CXXScopeSpec &SS, NamedDecl *Found, SourceLocation NameLoc, const Token &NextToken)
Act on the result of classifying a name as a specific non-type declaration.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
Definition SemaCast.cpp:426
SourceRange getExprRange(Expr *E) const
Definition SemaExpr.cpp:500
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:11302
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
Definition SemaAttr.cpp:168
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
LazyVector< const DeclaratorDecl *, ExternalSemaSource, &ExternalSemaSource::ReadUnusedFileScopedDecls, 2, 2 > UnusedFileScopedDeclsType
Definition Sema.h:3553
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition Sema.h:8168
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:14913
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition Sema.h:4566
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:1560
bool FriendConstraintsDependOnEnclosingTemplate(const FunctionDecl *FD)
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
Definition SemaStmt.cpp:405
FPOptions & getCurFPFeatures()
Definition Sema.h:919
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition Sema.h:8266
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
Definition Sema.cpp:272
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition Sema.h:1328
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition Sema.cpp:83
sema::LambdaScopeInfo * PushLambdaScope()
Definition Sema.cpp:2348
StmtResult ActOnCoreturnStmt(Scope *S, SourceLocation KwLoc, Expr *E)
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
void PopCompoundScope()
Definition Sema.cpp:2481
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition Sema.h:15323
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:14224
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition Sema.h:14244
@ UPPC_RequiresClause
Definition Sema.h:14295
@ UPPC_UsingDeclaration
A using declaration.
Definition Sema.h:14250
@ UPPC_IfExists
Microsoft __if_exists.
Definition Sema.h:14277
@ UPPC_Requirement
Definition Sema.h:14292
@ UPPC_ExceptionType
The type of an exception.
Definition Sema.h:14268
@ UPPC_EnumeratorValue
The enumerator value.
Definition Sema.h:14247
@ UPPC_Lambda
Lambda expression.
Definition Sema.h:14283
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition Sema.h:14280
@ UPPC_PartialSpecialization
Partial specialization.
Definition Sema.h:14274
@ UPPC_Initializer
An initializer.
Definition Sema.h:14259
@ UPPC_BaseType
The base type of a class type.
Definition Sema.h:14229
@ UPPC_FriendDeclaration
A friend declaration.
Definition Sema.h:14253
@ UPPC_DefaultArgument
A default argument.
Definition Sema.h:14262
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition Sema.h:14232
@ UPPC_Expression
An arbitrary expression.
Definition Sema.h:14226
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition Sema.h:14271
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition Sema.h:14256
@ UPPC_DataMemberType
The type of a data member.
Definition Sema.h:14235
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition Sema.h:14241
@ UPPC_Block
Block expression.
Definition Sema.h:14286
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition Sema.h:14238
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition Sema.h:14265
@ UPPC_TypeConstraint
A type constraint.
Definition Sema.h:14289
api_notes::APINotesManager APINotes
Definition Sema.h:1286
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:12431
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:917
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?
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< AssociatedConstraint > AssociatedConstraints, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
Definition Sema.h:14715
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:5820
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
SourceLocation CurInitSegLoc
Definition Sema.h:2080
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition SemaAttr.cpp:724
SemaCodeCompletion & CodeCompletion()
Definition Sema.h:1439
void inferLifetimeBoundAttribute(FunctionDecl *FD)
Add [[clang:lifetimebound]] attr for std:: functions and methods.
Definition SemaAttr.cpp:220
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition Sema.h:3574
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:1494
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition Sema.h:14687
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:6977
@ ReuseLambdaContextDecl
Definition Sema.h:6977
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:925
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:1434
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E)
Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
void * OpaqueParser
Definition Sema.h:1326
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr)
Diagnose an empty lookup.
Preprocessor & PP
Definition Sema.h:1281
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:2127
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
threadSafety::BeforeSet * ThreadSafetyDeclCache
Definition Sema.h:1319
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition Sema.h:2105
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, CXXRecordDecl *Base, CXXRecordDecl *Derived, const CXXBasePath &Path, unsigned DiagID, llvm::function_ref< void(PartialDiagnostic &PD)> SetupPDiag, bool ForceCheck=false, bool ForceUnprivileged=false)
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
void checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D=nullptr)
Check if the type is allowed to be used for the current target.
Definition Sema.cpp:2113
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy)
Are the two types matrix types and do they have the same dimensions i.e.
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
LazyVector< VarDecl *, ExternalSemaSource, &ExternalSemaSource::ReadTentativeDefinitions, 2, 2 > TentativeDefinitionsType
Definition Sema.h:3561
SemaDirectX & DirectX()
Definition Sema.h:1449
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition Sema.h:6465
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:1479
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:1561
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:1280
void InstantiateClassMembers(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiates the definitions of all of the member of the given class, which is an instantiation of a ...
NamedDecl * FindFirstQualifierInScope(Scope *S, NestedNameSpecifier NNS)
If the given nested-name-specifier begins with a bare identifier (e.g., Base::), perform name lookup ...
bool ActOnDuplicateDefinition(Scope *S, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
ExprResult PerformQualificationConversion(Expr *E, QualType Ty, ExprValueKind VK=VK_PRValue, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
void PushExpressionEvaluationContextForFunction(ExpressionEvaluationContext NewContext, FunctionDecl *FD)
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From,...
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition Sema.h:1218
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition Sema.cpp:2557
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:1213
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition Sema.h:8975
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:946
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition SemaStmt.cpp:416
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition Sema.h:15336
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:6467
SemaHLSL & HLSL()
Definition Sema.h:1454
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:11318
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition Sema.h:1216
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition Sema.h:9282
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
ExprResult ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ConvertVectorExpr - Handle __builtin_convertvector.
void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind)
Definition Sema.cpp:1171
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
CXXRecordDecl * getStdBadAlloc() const
ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation LParenOrBraceLoc, MultiExprArg Exprs, SourceLocation RParenOrBraceLoc, bool ListInitialization)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
ExpressionEvaluationContextRecord & currentEvaluationContext()
Definition Sema.h:6895
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:1817
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
static StringRef GetFormatStringTypeName(FormatStringType FST)
SemaMIPS & MIPS()
Definition Sema.h:1474
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition Sema.cpp:139
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
void CompleteLambdaCallOperator(CXXMethodDecl *Method, SourceLocation LambdaLoc, SourceLocation CallOperatorLoc, const AssociatedConstraint &TrailingRequiresClause, TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind, StorageClass SC, ArrayRef< ParmVarDecl * > Params, bool HasExplicitResultType)
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
SemaRISCV & RISCV()
Definition Sema.h:1519
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:15510
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition Sema.h:1806
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:5826
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....
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
Definition SemaExpr.cpp:207
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:5200
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
Definition Sema.h:5203
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
Definition Sema.h:5207
MemberPointerConversionDirection
Definition Sema.h:10188
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition Sema.h:13844
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition Sema.h:6460
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
Definition SemaExpr.cpp:75
ConditionResult ActOnConditionVariable(Decl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type.
void performFunctionEffectAnalysis(TranslationUnitDecl *TU)
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
EltwiseBuiltinArgTyRestriction
Definition Sema.h:2766
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:14908
SemaSwift & Swift()
Definition Sema.h:1534
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:2029
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:6565
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition Sema.h:6922
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition Sema.h:13489
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition Sema.h:6497
StmtResult ActOnExprStmtError()
Definition SemaStmt.cpp:65
PragmaStack< StringLiteral * > BSSSegStack
Definition Sema.h:2039
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
const VarDecl * getCopyElisionCandidate(NamedReturnInfo &Info, QualType ReturnType)
Updates given NamedReturnInfo's move-eligible and copy-elidable statuses, considering the function re...
CXXRecordDecl * getCurrentInstantiationOf(NestedNameSpecifier NNS)
If the given nested name specifier refers to the current instantiation, return the declaration that c...
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed.
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
void completeExprArrayBound(Expr *E)
DeclContext * getCurLexicalContext() const
Definition Sema.h:1123
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition Sema.h:1337
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:2083
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:1659
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:894
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
Definition SemaStmt.cpp:70
const NormalizedConstraint * getNormalizedAssociatedConstraints(const NamedDecl *ConstrainedDecl, ArrayRef< AssociatedConstraint > AssociatedConstraints)
OpenCLOptions OpenCLFeatures
Definition Sema.h:1277
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
Definition Sema.h:13848
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:2130
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
void ExitDeclaratorContext(Scope *S)
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI)
Diagnose shadowing for variables shadowed in the lambda record LambdaRD when these variables are capt...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition Sema.cpp:849
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D)
Determine if we're in a case where we need to (incorrectly) eagerly parse an exception specification ...
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
bool buildCoroutineParameterMoves(SourceLocation Loc)
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMemberKind CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
llvm::SmallSetVector< Decl *, 4 > DeclsToCheckForDeferredDiags
Function or variable declarations to be checked for whether the deferred diagnostics should be emitte...
Definition Sema.h:4743
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:10378
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition Sema.h:14902
ProcessingContextState ParsingClassState
Definition Sema.h:6515
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:1313
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:2476
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
MemberPointerConversionResult CheckMemberPointerConversion(QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind, CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange, bool IgnoreBaseAccess, MemberPointerConversionDirection Direction)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx, StringEvaluationContext EvalContext, bool ErrorOnInvalidMessage)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData, StringRef FileName)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
bool isDeclaratorFunctionLike(Declarator &D)
Determine whether.
Definition Sema.cpp:2910
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:3826
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition Sema.h:2668
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:15245
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
bool CheckNontrivialField(FieldDecl *FD)
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
Helper for delayed processing TransparentUnion or BPFPreserveAccessIndexAttr attribute.
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition Sema.h:6919
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
bool CheckExceptionSpecSubset(const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID, const FunctionProtoType *Superset, bool SkipSupersetFirstParameter, SourceLocation SuperLoc, const FunctionProtoType *Subset, bool SkipSubsetFirstParameter, SourceLocation SubLoc)
CheckExceptionSpecSubset - Check whether the second function type's exception specification is a subs...
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
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)
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
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:2294
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
QualType BuildMemberPointerType(QualType T, const CXXScopeSpec &SS, CXXRecordDecl *Cls, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
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:12955
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:4826
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.
void LateTemplateParserCleanupCB(void *P)
Definition Sema.h:1323
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:5816
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:633
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:15330
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition Sema.h:8137
StringLiteral * CurInitSeg
Last section used with pragma init_seg.
Definition Sema.h:2079
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition Sema.h:9816
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
bool CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
AddOverriddenMethods - See if a method overrides any in the base classes, and if so,...
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
static bool isCast(CheckedConversionKind CCK)
Definition Sema.h:2523
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...
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD, bool Diagnose, bool LookForGlobal)
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:8004
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:2512
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:6934
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:6474
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:1417
auto getDefaultDiagFunc()
Definition Sema.h:2286
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount)
Checks that a call expression's argument count is at least the desired number.
bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, AllocationFunctionScope NewScope, AllocationFunctionScope DeleteScope, QualType AllocType, bool IsArray, ImplicitAllocationParameters &IAP, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete, bool Diagnose=true)
Finds the overloads of operator new and delete that are appropriate for the allocation.
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc)
ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const,addrspace}_cast's.
Definition SemaCast.cpp:314
DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc, SourceLocation PrivateLoc)
The parser has processed a private-module-fragment declaration that begins the definition of the priv...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition Sema.h:12432
ClassTemplateDecl * StdTypeIdentity
The C++ "std::type_identity" template, which is defined in <type_traits>.
Definition Sema.h:6493
SemaOpenCL & OpenCL()
Definition Sema.h:1499
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:13857
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams, SourceLocation EllipsisLoc)
Handle a friend type declaration.
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc)
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
Definition SemaAttr.cpp:616
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition Sema.h:2210
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression, SourceLocation EllipsisLoc, SourceLocation LSquareLoc, Expr *IndexExpr, SourceLocation RSquareLoc)
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, StringLiteral *SegmentName)
Called on well-formed #pragma init_seg().
Definition SemaAttr.cpp:890
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
static SourceRange getPrintable(TypeLoc TL)
Definition Sema.h:14918
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...
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:2598
@ FAPK_Elsewhere
Definition Sema.h:2602
@ FAPK_Fixed
Definition Sema.h:2599
@ FAPK_Variadic
Definition Sema.h:2600
@ FAPK_VAList
Definition Sema.h:2601
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:8129
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition Sema.h:12946
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition Sema.cpp:1627
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, NamedReturnInfo &NRInfo, bool SupressSimplerImplicitMoves)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes.
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr, bool ForTypeDeduction=false)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
Stmt * MaybeCreateStmtWithCleanups(Stmt *SubStmt)
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
Parsed a C++ 'new' expression (C++ 5.3.4).
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
StmtResult ActOnCapturedRegionEnd(Stmt *S)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
bool IsCXXReplaceableType(QualType T)
Determines if a type is replaceable according to the C++26 rules.
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:15343
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:14667
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:8325
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:3571
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition Sema.h:6726
bool MSStructPragmaOn
Definition Sema.h:1803
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:13473
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:13798
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition Sema.h:15318
SourceManager & getSourceManager() const
Definition Sema.h:922
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition Sema.h:8396
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:4804
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:632
bool isModuleVisible(const Module *M, bool ModulePrivate=false)
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false, OverloadCandidateParamOrder PO={})
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
Definition Sema.h:3524
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
bool CheckRebuiltStmtAttributes(ArrayRef< const Attr * > Attrs)
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible.
bool hasVisibleMergedDefinition(const NamedDecl *Def)
void diagnoseFunctionEffectMergeConflicts(const FunctionEffectSet::Conflicts &Errs, SourceLocation NewLoc, SourceLocation OldLoc)
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
Definition Sema.cpp:946
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl * > Equiv)
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
void diagnoseFunctionEffectConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn when implicitly changing function effects.
Definition Sema.cpp:696
ClassTemplateDecl * lookupCoroutineTraits(SourceLocation KwLoc, SourceLocation FuncLoc)
Lookup 'coroutine_traits' in std namespace and std::experimental namespace.
bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Definition Sema.h:12172
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 ?
bool IsFunctionConversion(QualType FromType, QualType ToType, bool *DiscardingCFIUncheckedCallee=nullptr, bool *AddingCFIUncheckedCallee=nullptr) const
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
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:2298
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Definition Sema.h:9276
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition SemaAttr.cpp:550
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
bool ActOnCXXNestedNameSpecifierIndexedPack(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc, QualType Type)
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount, unsigned MaxArgCount)
Checks that a call expression's argument count is in the desired range.
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
bool inConstraintSubstitution() const
Determine whether we are currently performing constraint substitution.
Definition Sema.h:13803
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,...
bool AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors.
Definition Sema.h:12361
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:5936
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc)
PragmaClangSection PragmaClangTextSection
Definition Sema.h:1818
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:7429
bool BoundsSafetyCheckInitialization(const InitializedEntity &Entity, const InitializationKind &Kind, AssignmentAction Action, QualType LHSType, Expr *RHSExpr)
Perform Bounds Safety Semantic checks for initializing a Bounds Safety pointer.
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
NonTrivialCUnionKind
Definition Sema.h:4070
@ NTCUK_Destruct
Definition Sema.h:4072
@ NTCUK_Init
Definition Sema.h:4071
@ NTCUK_Copy
Definition Sema.h:4073
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr=EltwiseBuiltinArgTyRestriction::None)
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
DelayedDiagnosticsState ProcessingContextState
Definition Sema.h:1354
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:8282
PragmaClangSection PragmaClangDataSection
Definition Sema.h:1815
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
llvm::Error isValidSectionSpecifier(StringRef Str)
Used to implement to perform semantic checking on attribute((section("foo"))) specifiers.
void diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
ParsedType actOnLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init)
Perform initialization analysis of the init-capture and perform any implicit conversions such as an l...
Definition Sema.h:9071
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, SourceLocation RAngleLoc, Decl *Param, ArrayRef< TemplateArgument > SugaredConverted, ArrayRef< TemplateArgument > CanonicalConverted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
bool anyAltivecTypes(QualType srcType, QualType destType)
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
TypeSourceInfo * SubstAutoTypeSourceInfoDependent(TypeSourceInfo *TypeWithAuto)
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type?
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute.
ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc)
std::pair< AvailabilityResult, const NamedDecl * > ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message, ObjCInterfaceDecl *ClassReceiver)
The diagnostic we should emit for D, and the declaration that originated it, or AR_Available.
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition Sema.cpp:2342
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:2028
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:6724
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition Sema.h:927
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:1226
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition Sema.h:2086
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
FunctionDecl * BuildTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl, QualType AllocType, SourceLocation)
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition Sema.h:8756
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope, bool IsInstantiation=false)
ActOnLambdaError - If there is an error parsing a lambda, this callback is invoked to pop the informa...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
Definition SemaExpr.cpp:218
static SourceRange getPrintable(SourceRange R)
Definition Sema.h:14915
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:13497
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:14652
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:15285
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition Sema.h:1129
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:2872
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void emitDeferredDiags()
Definition Sema.cpp:2006
void setFunctionHasMustTail()
Definition Sema.cpp:2507
ExprResult BuildPseudoDestructorExpr(Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration,...
bool hasReachableMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is a member specialization declaration (as op...
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition Sema.h:8321
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange, SourceRange FixItRange, const sema::Capture &From)
Diagnose if an explicit lambda capture is unused.
void CheckCompleteVariableDeclaration(VarDecl *VD)
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
QualType CheckTemplateIdType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, Scope *Scope, bool ForNestedNameSpecifier)
void PopSatisfactionStackEntry()
Definition Sema.h:14658
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:2497
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition Sema.h:15374
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:2590
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition Sema.h:6485
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:623
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
bool SubstDefaultArgument(SourceLocation Loc, ParmVarDecl *Param, const MultiLevelTemplateArgumentList &TemplateArgs, bool ForCallExpr=false)
Substitute the given template arguments into the default argument.
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
bool BuiltinElementwiseTernaryMath(CallExpr *TheCall, EltwiseBuiltinArgTyRestriction ArgTyRestr=EltwiseBuiltinArgTyRestriction::FloatTy)
void ActOnStartOfTranslationUnit()
This is called before the very first declaration in the translation unit is parsed.
Definition Sema.cpp:1165
StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
friend class Parser
Definition Sema.h:1558
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:11178
void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
void ApplyNullability(Decl *D, NullabilityKind Nullability)
Apply the 'Nullability:' annotation to the specified declaration.
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition Sema.h:3545
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:270
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:1555
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:1283
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:4629
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
PragmaAlignPackDiagnoseKind
Definition Sema.h:2188
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:6926
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition SemaExpr.cpp:123
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition Sema.h:1318
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:1772
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition Sema.h:13840
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:9843
@ PrivateFragmentImportFinished
after 'module :private;' but a non-import decl has already been seen.
Definition Sema.h:9850
@ ImportFinished
after any non-import decl.
Definition Sema.h:9847
@ PrivateFragmentImportAllowed
after 'module :private;' but before any non-import decl.
Definition Sema.h:9848
@ FirstDecl
Parsing the first decl in a TU.
Definition Sema.h:9844
@ GlobalFragment
after 'module;' but before 'module X;'
Definition Sema.h:9845
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
Definition Sema.h:9852
@ ImportAllowed
after 'module X;' but before any non-import decl.
Definition Sema.h:9846
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:14914
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition Sema.cpp:109
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition Sema.h:1247
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 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:6668
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
Definition Sema.h:6690
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
Definition Sema.h:6680
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
Definition Sema.h:6695
@ DiscardedStatement
The current expression occurs within a discarded statement.
Definition Sema.h:6685
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
Definition Sema.h:6705
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Definition Sema.h:6674
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
Definition Sema.h:6700
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
Definition Sema.h:6715
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:13481
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition Sema.h:4789
@ AP_PragmaClangAttribute
The availability attribute was applied using 'pragma clang attribute'.
Definition Sema.h:4795
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition Sema.h:4799
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition Sema.h:4792
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:965
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....
SemaPPC & PPC()
Definition Sema.h:1509
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:2355
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc)
Handle a C++ member initializer.
void ActOnAfterCompoundStatementLeadingPragmas()
Definition SemaStmt.cpp:420
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition SemaStmt.cpp:75
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition Sema.h:4863
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:1245
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:14660
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...
LateTemplateParserCB * LateTemplateParser
Definition Sema.h:1324
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:8332
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:3564
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 FomatStringIn...
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition Sema.h:9998
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:8119
SemaSystemZ & SystemZ()
Definition Sema.h:1539
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition Sema.cpp:123
bool isRedefinitionAllowedFor(const NamedDecl *D, bool &Visible)
Definition Sema.h:15364
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:2894
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition Sema.h:8269
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:10180
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:9829
bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, unsigned ArgNum, unsigned ArgBits)
BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of TheCall is a constant expression re...
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AvailabilityMergeKind::Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
Definition SemaStmt.cpp:648
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true, bool *Unreachable=nullptr)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition Sema.h:1285
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:11346
@ TemplateNameIsRequired
Definition Sema.h:11346
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
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:777
bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const
Determine whether FD is an aligned allocation or deallocation function that is unavailable.
bool hasReachableExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is an explicit specialization declaration for...
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure.
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, CXXScopeSpec &SS, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration.
TypeSourceInfo * SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, StringRef SlotLabel, Expr *Alignment)
ActOnPragmaPack - Called on well formed #pragma pack(...).
Definition SemaAttr.cpp:438
static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD)
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
LazyVector< CXXConstructorDecl *, ExternalSemaSource, &ExternalSemaSource::ReadDelegatingConstructors, 2, 2 > DelegatingCtorDeclsType
Definition Sema.h:6478
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:1284
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
void DiagnoseUnterminatedPragmaAlignPack()
Definition SemaAttr.cpp:589
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition Sema.h:7745
OpenCLOptions & getOpenCLOptions()
Definition Sema.h:918
FPOptions CurFPFeatures
Definition Sema.h:1278
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
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition Sema.h:6469
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
bool IsAtLeastAsConstrained(const NamedDecl *D1, MutableArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, MutableArrayRef< AssociatedConstraint > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Definition SemaExpr.cpp:509
PragmaStack< StringLiteral * > DataSegStack
Definition Sema.h:2038
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition Sema.h:1325
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types?
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
Attr * CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
Definition Sema.cpp:2933
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< ParsedType > Args, SourceLocation RParenLoc)
Parsed one of the type trait support pseudo-functions.
TemplateParamListContext
The context in which we are checking a template parameter list.
Definition Sema.h:11529
@ TPC_TemplateTemplateParameterPack
Definition Sema.h:11539
@ TPC_FriendFunctionTemplate
Definition Sema.h:11537
@ TPC_ClassTemplateMember
Definition Sema.h:11535
@ TPC_FunctionTemplate
Definition Sema.h:11534
@ TPC_FriendClassTemplate
Definition Sema.h:11536
@ TPC_FriendFunctionTemplateDefinition
Definition Sema.h:11538
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:1429
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
friend class InitializationSequence
Definition Sema.h:1559
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:2114
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:7704
void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init)
bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS)
ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global scope or nested-name-specifi...
TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param, SourceLocation Location)
Get a template argument mapping the given template parameter to itself, e.g.
bool CheckIfFunctionSpecializationIsImmediate(FunctionDecl *FD, SourceLocation Loc)
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc)
Complete a lambda-expression having processed and attached the lambda body.
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
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:6501
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition Sema.h:13448
void PrintStats() const
Print out statistics about the semantic analysis.
Definition Sema.cpp:672
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:14905
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:1801
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:1231
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, const FunctionProtoType *Proto, Expr *Object, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddSurrogateCandidate - Adds a "surrogate" candidate function that converts the given Object to a fun...
SourceRange getRangeForNextToken(SourceLocation Loc, bool IncludeMacros, bool IncludeComments, std::optional< tok::TokenKind > ExpectedToken=std::nullopt)
Calls Lexer::findNextToken() to find the next token, and if the locations of both ends of the token c...
Definition Sema.cpp:88
MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
BuildForRangeKind
Definition Sema.h:11005
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition Sema.h:11013
@ BFRK_Build
Initial building of a for-range statement.
Definition Sema.h:11007
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition Sema.h:11010
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
SemaNVPTX & NVPTX()
Definition Sema.h:1484
void checkIncorrectVTablePointerAuthenticationAttribute(CXXRecordDecl &RD)
Check that VTable Pointer authentication is only being set on the first first instantiation of the vt...
StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl, Stmt *HandlerBlock)
ActOnCXXCatchBlock - Takes an exception declaration and a handler block and creates a proper catch ha...
void ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation, PragmaMsStackAction Action, bool Value)
ActOnPragmaMSStrictGuardStackCheck - Called on well formed #pragma strict_gs_check.
Definition SemaAttr.cpp:874
void ActOnUninitializedDecl(Decl *dcl)
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
void ApplyAPINotesType(Decl *D, StringRef TypeString)
Apply the 'Type:' annotation to the specified declaration.
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation, FunctionDecl *Decl, ArrayRef< TemplateArgument > TemplateArgs, ConstraintSatisfaction &Satisfaction)
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs)
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc)
void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction, const Expr *ThisArg, ArrayRef< const Expr * > Args)
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition SemaStmt.cpp:563
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
PragmaSectionKind
Definition Sema.h:2058
@ PSK_ConstSeg
Definition Sema.h:2061
@ PSK_DataSeg
Definition Sema.h:2059
@ PSK_CodeSeg
Definition Sema.h:2062
@ PSK_BSSSeg
Definition Sema.h:2060
void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope)
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
TypeResult ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword, SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, const IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
Definition Sema.cpp:627
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition SemaCast.cpp:337
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
Definition Sema.h:6245
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,...
FormatMatchesAttr * mergeFormatMatchesAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, StringLiteral *FormatStr)
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, IdentifierInfo *IIEnvironment)
void BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs, LateInstantiatedAttrVec *LateAttrs, DeclContext *Owner, LocalInstantiationScope *StartingScope, bool InstantiatingVarTemplate=false, VarTemplateSpecializationDecl *PrevVTSD=nullptr)
BuildVariableInstantiation - Used after a new variable has been created.
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void ActOnCXXForRangeDecl(Decl *D)
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Definition Sema.h:3539
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition Sema.cpp:2096
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
UnsignedOrNone GetDecompositionElementCount(QualType DecompType, SourceLocation Loc)
PragmaClangSection PragmaClangBSSSection
Definition Sema.h:1814
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:1341
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel)
AbstractDiagSelID
Definition Sema.h:6191
@ AbstractSynthesizedIvarType
Definition Sema.h:6198
@ AbstractVariableType
Definition Sema.h:6195
@ AbstractReturnType
Definition Sema.h:6193
@ AbstractNone
Definition Sema.h:6192
@ AbstractFieldType
Definition Sema.h:6196
@ AbstractArrayType
Definition Sema.h:6199
@ AbstractParamType
Definition Sema.h:6194
@ AbstractIvarType
Definition Sema.h:6197
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition SemaStmt.cpp:950
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiate the definition of an enum from a given pattern.
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
ExprResult CheckVarOrConceptTemplateTemplateId(const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, TemplateTemplateParmDecl *Template, SourceLocation TemplateLoc, const TemplateArgumentListInfo *TemplateArgs)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
ExprResult SubstCXXIdExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
Substitute an expression as if it is a address-of-operand, which makes it act like a CXXIdExpression ...
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:1524
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:8318
ExprResult ActOnNameClassifiedAsDependentNonType(const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, bool IsAddressOfOperand)
Act on the result of classifying a name as an undeclared member of a dependent base class.
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(const NamedDecl *D1, ArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, ArrayRef< AssociatedConstraint > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
Decl * ActOnFinishExportDecl(Scope *S, Decl *ExportDecl, SourceLocation RBraceLoc)
Complete the definition of an export declaration.
void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI)
Note that we have finished the explicit captures for the given lambda.
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, const DefaultArguments &DefaultArgs, bool PartialTemplateArgs, CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
void ActOnPragmaFPContract(SourceLocation Loc, LangOptions::FPModeKind FPC)
ActOnPragmaFPContract - Called on well formed #pragma {STDC,OPENCL} FP_CONTRACT and #pragma clang fp ...
void adjustMemberFunctionCC(QualType &T, bool HasThisPointer, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc)
Called on well formed #pragma clang optimize.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
QualType PreferredConditionType(ConditionKind K) const
Definition Sema.h:7927
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
Create an CUDALaunchBoundsAttr attribute.
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
Definition Sema.h:9339
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition Sema.h:9343
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition Sema.h:9349
@ LOLR_Error
The lookup resulted in an error.
Definition Sema.h:9341
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition Sema.h:9346
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition Sema.h:9357
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition Sema.h:9353
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:2527
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition Sema.h:6907
SemaLoongArch & LoongArch()
Definition Sema.h:1464
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:6380
@ CheckValid
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
Definition Sema.h:6385
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
Definition Sema.h:6382
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:13836
void CheckVariableDeclarationType(VarDecl *NewVD)
sema::CompoundScopeInfo & getCurCompoundScope() const
Definition SemaStmt.cpp:432
DeclContext * FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, const MultiLevelTemplateArgumentList &TemplateArgs)
Finds the instantiation of the given declaration context within the current instantiation.
sema::CapturedRegionScopeInfo * getCurCapturedRegion()
Retrieve the current captured region, if any.
Definition Sema.cpp:2886
OpaquePtr< TemplateName > TemplateTy
Definition Sema.h:1274
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
bool DiagnoseInvalidExplicitObjectParameterInLambda(CXXMethodDecl *Method, SourceLocation CallLoc)
Returns true if the explicit object parameter was invalid.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
Definition Sema.cpp:708
bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E)
CheckCXXThrowOperand - Validate the operand of a throw.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II)
Called on pragma clang __debug dump II.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled)
ActOnPragmaFenvAccess - Called on well formed #pragma STDC FENV_ACCESS.
bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New)
void checkEnumArithmeticConversions(Expr *LHS, Expr *RHS, SourceLocation Loc, ArithConvKind ACK)
Check that the usual arithmetic conversions can be performed on this pair of expressions that might b...
bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Perform substitution on the base class specifiers of the given class template specialization.
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
llvm::SmallPtrSet< const NamedDecl *, 4 > TypoCorrectedFunctionDefinitions
The function definitions which were renamed as part of typo-correction to match their respective decl...
Definition Sema.h:3520
void ActOnFinishOfCompoundStmt()
Definition SemaStmt.cpp:428
concepts::Requirement * ActOnNestedRequirement(Expr *Constraint)
void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB)
Cause the built diagnostic to be emitted on the DiagosticsEngine.
Definition Sema.cpp:1672
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:15210
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:7782
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition SemaStmt.cpp:436
void NoteTemplateParameterLocation(const NamedDecl &Decl)
SemaWasm & Wasm()
Definition Sema.h:1544
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
IdentifierResolver IdResolver
Definition Sema.h:3468
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:13444
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
LifetimeCaptureByAttr * ParseLifetimeCaptureByAttr(const ParsedAttr &AL, StringRef ParamName)
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
SemaPseudoObject & PseudoObject()
Definition Sema.h:1514
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:2488
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition SemaStmt.cpp:588
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition Sema.h:11311
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:7738
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:714
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:143
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:8277
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition Sema.h:1273
static int getPrintable(int I)
Definition Sema.h:14904
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply.
void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags, StringLiteral *SegmentName)
Called on well formed #pragma section().
Definition SemaAttr.cpp:885
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
Definition Sema.h:9609
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition Sema.h:12786
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition SemaStmt.cpp:568
ExprResult ActOnCXXThis(SourceLocation Loc)
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
Definition Sema.h:3812
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:14909
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
void warnOnReservedIdentifier(const NamedDecl *D)
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition SemaStmt.cpp:532
TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, UnsignedOrNone &NumExpansions) const
Returns the pattern of the pack expansion for a template argument.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
bool isCheckingDefaultArgumentOrInitializer() const
Definition Sema.h:8145
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
SemaARM & ARM()
Definition Sema.h:1424
bool CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, SourceLocation DefaultLoc)
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined.
void inferNullableClassAttribute(CXXRecordDecl *CRD)
Add _Nullable attributes for std:: types.
Definition SemaAttr.cpp:322
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation TriviallyRelocatable, SourceLocation Replaceable, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
static const char * getPrintable(const char *S)
Definition Sema.h:14907
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.
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:653
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
PragmaMsStackAction
Definition Sema.h:1820
@ PSK_Push_Set
Definition Sema.h:1826
@ PSK_Reset
Definition Sema.h:1821
@ PSK_Pop_Set
Definition Sema.h:1827
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:8608
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.
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:292
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:334
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3714
Exposes information about the current target.
Definition TargetInfo.h:226
A convenient class for passing around template argument information.
A template argument list.
Location wrapper for a TemplateArgument.
Represents a template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
This is a base class for callbacks that will be notified at every template instantiation.
Represents a C++ template name within the type system.
Stores a list of template parameters for a TemplateDecl and its derived classes.
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
Token - This structure provides full information about a lexed token.
Definition Token.h:36
A declaration that models statements at global scope.
Definition Decl.h:4614
The top declaration context.
Definition Decl.h:104
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:223
Represents a declaration of a type.
Definition Decl.h:3510
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:8256
The base class of the type hierarchy.
Definition TypeBase.h:1833
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3664
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3559
Simple class containing the result of Sema::CorrectTypo.
Represents a C++ unqualified-id that has been parsed.
Definition DeclSpec.h:998
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3384
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4120
A set of unresolved declarations.
The iterator over UnresolvedSets.
Represents a C++ using-declaration.
Definition DeclCXX.h:3591
Represents C++ using-directive.
Definition DeclCXX.h:3096
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3399
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:711
Represents a variable declaration or definition.
Definition Decl.h:925
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:4173
Represents a C++11 virt-specifier-seq.
Definition DeclSpec.h:2754
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Definition Lookup.h:838
Captures information about a #pragma weak directive.
Definition Weak.h:25
The API notes manager helps find API notes associated with declarations.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
Retains information about a block that is currently being parsed.
Definition ScopeInfo.h:790
Retains information about a captured region.
Definition ScopeInfo.h:816
Contains information about the compound statement currently being parsed.
Definition ScopeInfo.h:67
A collection of diagnostics which were delayed.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
Retains information about a function, method, or block that is currently being parsed.
Definition ScopeInfo.h:104
Provides information about an attempted template argument deduction, whose success or failure was des...
#define bool
Definition gpuintrin.h:32
#define UINT_MAX
Definition limits.h:64
Definition SPIR.cpp:47
Enums for the diagnostics of target, target_version and target_clones.
Definition Sema.h:839
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
void threadSafetyCleanup(BeforeSet *Cache)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition TokenKinds.h:25
The JSON file list parser is used to communicate input to InstallAPI.
PragmaClangSectionAction
Definition Sema.h:473
TypeSpecifierType
Specifies the kind of type.
Definition Specifiers.h:55
ImplicitTypenameContext
Definition DeclSpec.h:1857
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
OverloadKind
Definition Sema.h:808
@ NonFunction
This is not an overload because the lookup results contain a non-function.
Definition Sema.h:819
@ Match
This is not an overload because the signature exactly matches an existing declaration.
Definition Sema.h:815
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition Sema.h:811
bool isa(CodeGen::Address addr)
Definition Address.h:330
OpaquePtr< TemplateName > ParsedTemplateTy
Definition Ownership.h:256
ArrayTypeTrait
Names for the array type traits.
Definition TypeTraits.h:42
@ CPlusPlus
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
Definition Ownership.h:263
VariadicCallType
Definition Sema.h:510
FunctionEffectMode
Used with attributes/effects with a boolean condition, e.g. nonblocking.
Definition Sema.h:456
CUDAFunctionTarget
Definition Cuda.h:60
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:776
@ Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition Sema.h:784
PragmaMSCommentKind
Definition PragmaKinds.h:14
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition Specifiers.h:35
ArrayRef< IdentifierLoc > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
TryCaptureKind
Definition Sema.h:650
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition Specifiers.h:39
bool isInstanceMethod(const Decl *D)
Definition Attr.h:120
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition Sema.h:658
@ BitwiseOp
A bitwise operation.
Definition Sema.h:662
@ Arithmetic
An arithmetic operation.
Definition Sema.h:660
@ Conditional
A conditional (?:) operator.
Definition Sema.h:666
@ CompAssign
A compound assignment expression.
Definition Sema.h:668
@ Comparison
A comparison.
Definition Sema.h:664
NullabilityKind
Describes the nullability of a particular type.
Definition Specifiers.h:348
InClassInitStyle
In-class initialization styles for non-static data members.
Definition Specifiers.h:271
@ Success
Annotation was successful.
Definition Parser.h:65
CXXConstructionKind
Definition ExprCXX.h:1541
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition Specifiers.h:149
PointerAuthDiscArgKind
Definition Sema.h:591
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition Sema.h:601
@ TemplateTemplateArgument
Definition Sema.h:610
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
Definition Overload.h:84
NonTrivialCUnionContext
Definition Sema.h:529
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition Sema.h:625
@ Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition Sema.h:633
@ OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition Sema.h:639
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition Sema.h:630
@ ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition Sema.h:636
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
Definition Sema.h:235
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
void inferNoReturnAttr(Sema &S, const Decl *D)
TypeOfKind
The kind of 'typeof' expression we're after.
Definition TypeBase.h:918
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
Definition CallGraph.h:204
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition Specifiers.h:123
@ AS_none
Definition Specifiers.h:127
LazyOffsetPtr< Decl, GlobalDeclID, &ExternalASTSource::GetExternalDecl > LazyDeclPtr
A lazy pointer to a declaration.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
ActionResult< Decl * > DeclResult
Definition Ownership.h:255
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
CapturedRegionKind
The different kinds of captured statement.
StorageClass
Storage classes.
Definition Specifiers.h:248
Expr * Cond
};
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition Overload.h:922
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
Definition Parser.h:142
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition TypeTraits.h:51
bool isFunctionOrMethodOrBlockForAttrSubject(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
Definition Attr.h:40
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
Definition Overload.h:89
MutableArrayRef< Expr * > MultiExprArg
Definition Ownership.h:259
LambdaCaptureInitKind
Definition DeclSpec.h:2798
@ CopyInit
[a = b], [a = {b}]
Definition DeclSpec.h:2800
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Definition Linkage.h:54
@ AANT_ArgumentIntegerConstant
PragmaOptionsAlignKind
Definition Sema.h:475
@ Result
The result type of a method or function.
Definition TypeBase.h:905
ActionResult< ParsedType > TypeResult
Definition Ownership.h:251
OffsetOfKind
Definition Sema.h:613
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition TypeBase.h:3717
CorrectTypoKind
Definition Sema.h:803
ActionResult< CXXCtorInitializer * > MemInitResult
Definition Ownership.h:253
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isFunctionOrMethodVariadic(const Decl *D)
Definition Attr.h:112
@ Template
We are parsing a template declaration.
Definition Parser.h:81
ActionResult< CXXBaseSpecifier * > BaseResult
Definition Ownership.h:252
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition Sema.h:686
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition Sema.h:709
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition Sema.h:772
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition Sema.h:701
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition Sema.h:751
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition Sema.h:741
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition Sema.h:768
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition Sema.h:755
@ CompatibleVoidPtrToNonVoidPtr
CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because a void * can implicitly convert...
Definition Sema.h:693
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition Sema.h:735
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition Sema.h:730
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition Sema.h:764
@ Compatible
Compatible - the types are compatible according to the standard.
Definition Sema.h:688
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition Sema.h:720
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition Sema.h:697
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition Sema.h:705
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition Sema.h:747
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition Sema.h:714
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition Sema.h:726
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition Sema.h:759
TagUseKind
Definition Sema.h:448
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
Definition LangOptions.h:37
PragmaClangSectionKind
pragma clang section kind
Definition Sema.h:464
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:5888
TUFragmentKind
Definition Sema.h:484
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
NameClassificationKind
Describes the result of the name lookup and resolution performed by Sema::ClassifyName().
Definition Sema.h:552
@ FunctionTemplate
The name was classified as a function template name.
Definition Sema.h:584
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:559
@ DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition Sema.h:573
@ UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition Sema.h:586
@ NonType
The name was classified as a specific non-type, non-template declaration.
Definition Sema.h:565
@ Unknown
This name is not a type or template in this context, but might be something else.
Definition Sema.h:555
@ Error
Classification failed; an error has been produced.
Definition Sema.h:557
@ Type
The name was classified as a type.
Definition Sema.h:561
@ TypeTemplate
The name was classified as a template whose specializations are types.
Definition Sema.h:580
@ Concept
The name was classified as a concept name.
Definition Sema.h:588
@ OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition Sema.h:578
@ UndeclaredNonType
The name was classified as an ADL-only function name.
Definition Sema.h:569
@ VarTemplate
The name was classified as a variable template name.
Definition Sema.h:582
LangAS
Defines the address space values used by the address space qualifier of QualType.
FormatStringType
Definition Sema.h:496
CastKind
CastKind - The kind of operation required for a conversion.
AllowFoldKind
Definition Sema.h:652
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:673
PragmaMSStructKind
Definition PragmaKinds.h:23
AssignmentAction
Definition Sema.h:213
CXXSpecialMemberKind
Kinds of C++ special members.
Definition Sema.h:424
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:518
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition Lambda.h:22
PragmaFloatControlKind
Definition PragmaKinds.h:28
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition Specifiers.h:132
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:135
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Definition ASTContext.h:117
TypeAwareAllocationMode
Definition ExprCXX.h:2253
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition Sema.h:788
@ Exists
The symbol exists.
Definition Sema.h:790
@ DoesNotExist
The symbol does not exist.
Definition Sema.h:793
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition Specifiers.h:410
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
Definition Attr.h:55
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
Definition Attr.h:64
TPOC
The context in which partial ordering of function templates occurs.
Definition Template.h:298
TrivialABIHandling
Definition Sema.h:642
@ ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition Sema.h:647
@ IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition Sema.h:644
TemplateDeductionResult
Describes the result of template argument deduction.
Definition Sema.h:366
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
Definition Sema.h:416
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
Definition Sema.h:411
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
Definition Sema.h:414
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
Definition Sema.h:387
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
Definition Sema.h:373
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
Definition Sema.h:409
@ CUDATargetMismatch
CUDA Target attributes do not match.
Definition Sema.h:418
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
Definition Sema.h:406
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
Definition Sema.h:376
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
Definition Sema.h:390
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
Definition Sema.h:379
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Definition Sema.h:393
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
Definition Sema.h:382
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
Definition Sema.h:403
@ AlreadyDiagnosed
Some error which was already diagnosed.
Definition Sema.h:420
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
Definition Sema.h:397
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
Definition Sema.h:400
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition Specifiers.h:188
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:278
U cast(CodeGen::Address addr)
Definition Address.h:327
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
Definition DeclSpec.h:1215
@ None
The alignment was not explicit in code.
Definition ASTContext.h:146
CCEKind
Contexts in which a converted constant expression is required.
Definition Sema.h:823
@ CaseValue
Expression in a case label.
Definition Sema.h:824
@ StaticAssertMessageData
Call to data() in a static assert message.
Definition Sema.h:834
@ Enumerator
Enumerator value with fixed underlying type.
Definition Sema.h:825
@ StaticAssertMessageSize
Call to size() in a static assert message.
Definition Sema.h:832
@ Noexcept
Condition in a noexcept(bool) specifier.
Definition Sema.h:831
@ ArrayBound
Array bound in array declarator or new-expression.
Definition Sema.h:829
@ TempArgStrict
As above, but applies strict template checking rules.
Definition Sema.h:827
@ ExplicitBool
Condition in an explicit(bool) specifier.
Definition Sema.h:830
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition Ownership.h:230
SourceLocIdentKind
Definition Expr.h:4938
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition TypeBase.h:5863
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5874
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5877
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition TypeBase.h:5881
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
TypeTrait
Names for traits that operate specifically on types.
Definition TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
Definition ExprCXX.h:2247
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition Expr.h:1989
CheckedConversionKind
The kind of conversion being performed.
Definition Sema.h:435
@ Implicit
An implicit conversion.
Definition Sema.h:437
@ CStyleCast
A C-style cast.
Definition Sema.h:439
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
Definition Sema.h:445
@ OtherCast
A cast other than a C-style cast.
Definition Sema.h:443
@ FunctionalCast
A functional-style cast.
Definition Sema.h:441
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition Specifiers.h:173
unsigned int uint32_t
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
int const char * function
Definition c++config.h:31
#define false
Definition stdbool.h:26
#define true
Definition stdbool.h:25
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition ASTConcept.h:91
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A structure used to record information about a failed template argument deduction,...
Describes whether we've seen any nullability information for the given file.
Definition Sema.h:239
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition Sema.h:246
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition Sema.h:242
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition Sema.h:252
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition Sema.h:249
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition TypeBase.h:5001
Holds information about the various types of exception specification.
Definition TypeBase.h:5321
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition TypeBase.h:5323
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition TypeBase.h:5326
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition TypeBase.h:5329
Extra information about a function prototype.
Definition TypeBase.h:5349
Represents a complete lambda introducer.
Definition DeclSpec.h:2806
Contains a late templated function.
Definition Sema.h:15533
FPOptions FPO
Floating-point options in the point of definition.
Definition Sema.h:15538
Decl * D
The template function declaration to be late parsed.
Definition Sema.h:15536
A normalized constraint, as defined in C++ [temp.constr.normal], is either an atomic constraint,...
Definition SemaConcept.h:68
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Definition Overload.h:926
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation CurrentPragmaLocation
Definition Sema.h:2033
bool SuppressUserConversions
Do not consider any user-defined conversions when constructing the initializing sequence.
Definition Sema.h:10470
bool OnlyInitializeNonUserDefinedConversions
Before constructing the initializing sequence, we check whether the parameter type and argument type ...
Definition Sema.h:10477
CheckNonDependentConversionsFlag(bool SuppressUserConversions, bool OnlyInitializeNonUserDefinedConversions)
Definition Sema.h:10479
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
Definition Sema.h:11937
bool MatchingTTP
If true, assume these template arguments are the injected template arguments for a template template ...
Definition Sema.h:11933
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &)=delete
CheckTemplateArgumentInfo(bool PartialOrdering=false, bool MatchingTTP=false)
Definition Sema.h:11914
bool PartialOrdering
The check is being performed in the context of partial ordering.
Definition Sema.h:11926
SmallVector< TemplateArgument, 4 > SugaredConverted
The checked, converted argument will be added to the end of these vectors.
Definition Sema.h:11923
SmallVector< TemplateArgument, 4 > CanonicalConverted
Definition Sema.h:11923
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:12960
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition Sema.h:13127
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition Sema.h:13077
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition Sema.h:13096
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition Sema.h:13122
ArrayRef< TemplateArgument > template_arguments() const
Definition Sema.h:13115
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition Sema.h:13091
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition Sema.h:13083
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition Sema.h:13109
bool InConstraintSubstitution
Whether we're substituting into constraints.
Definition Sema.h:13080
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition Sema.h:13099
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition Sema.h:13106
SynthesisKind
The kind of template instantiation we are performing.
Definition Sema.h:12962
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition Sema.h:13054
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition Sema.h:12972
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition Sema.h:12981
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition Sema.h:13000
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition Sema.h:13051
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition Sema.h:13008
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition Sema.h:13015
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition Sema.h:13058
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition Sema.h:13026
@ Memoization
Added for Template instantiation observation.
Definition Sema.h:13064
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition Sema.h:12991
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition Sema.h:13070
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition Sema.h:13067
@ PartialOrderingTTP
We are performing partial ordering for template template parameters.
Definition Sema.h:13073
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition Sema.h:12988
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition Sema.h:12996
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition Sema.h:13004
@ TemplateInstantiation
We are instantiating a template declaration.
Definition Sema.h:12965
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition Sema.h:13018
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition Sema.h:13022
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition Sema.h:12977
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition Sema.h:13048
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition Sema.h:13011
Decl * Entity
The entity that is being synthesized.
Definition Sema.h:13086
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition Sema.h:13112
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:6824
Data structure used to record current or nested expression evaluation contexts.
Definition Sema.h:6730
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:6758
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition Sema.h:6760
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition Sema.h:6811
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition Sema.h:6750
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:6754
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition Sema.h:6765
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:6773
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition Sema.h:6769
bool IsCaseExpr
Whether evaluating an expression for a switch case label.
Definition Sema.h:6814
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition Sema.h:6779
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:6745
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition Sema.h:6787
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition Sema.h:6817
SmallVector< MisalignedMember, 4 > MisalignedMembers
Small set of gathered accesses to potentially misaligned members due to the packed attribute.
Definition Sema.h:6783
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition Sema.h:6735
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition Sema.h:6834
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition Sema.h:6836
ExpressionEvaluationContext Context
The expression evaluation context.
Definition Sema.h:6732
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition Sema.h:6739
FormatArgumentPassingKind ArgPassingKind
Definition Sema.h:2610
FunctionEffectDiffVector(const FunctionEffectsRef &Old, const FunctionEffectsRef &New)
Caller should short-circuit by checking for equality first.
std::optional< FunctionEffectWithCondition > Old
Definition Sema.h:15440
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:15444
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:15452
std::optional< FunctionEffectWithCondition > New
Definition Sema.h:15442
FunctionEffect::Kind EffectKind
Definition Sema.h:15437
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition Sema.h:13311
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.
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition Sema.h:13315
LocalInstantiationScope * Scope
Definition Sema.h:13963
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition Sema.h:13966
bool isMoveEligible() const
Definition Sema.h:11069
bool isCopyElidable() const
Definition Sema.h:11070
const VarDecl * Candidate
Definition Sema.h:11064
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition Sema.h:3281
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition Sema.h:3290
SourceLocation IdentifierLoc
The location of the identifier.
Definition Sema.h:3284
SourceLocation CCLoc
The location of the '::'.
Definition Sema.h:3287
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition Sema.h:3278
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition Sema.h:3296
SourceLocation LocStart
Definition Sema.h:7516
IdentifierInfo * IdentInfo
Definition Sema.h:7519
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition Sema.h:12533
This an attribute introduced by #pragma clang attribute.
Definition Sema.h:2089
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition Sema.h:2092
A push'd group of PragmaAttributeEntries.
Definition Sema.h:2097
SourceLocation Loc
The location of the push attribute.
Definition Sema.h:2099
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition Sema.h:2102
const IdentifierInfo * Namespace
The namespace of this push group.
Definition Sema.h:2101
SourceLocation PragmaLocation
Definition Sema.h:1811
PragmaMsStackAction Action
Definition Sema.h:1831
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition Sema.h:1944
llvm::StringRef StackSlotLabel
Definition Sema.h:1940
SourceLocation PragmaLocation
Definition Sema.h:1942
SourceLocation PragmaPushLocation
Definition Sema.h:1943
ValueType CurrentValue
Definition Sema.h:2014
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition Sema.h:2000
bool hasValue() const
Definition Sema.h:2010
SmallVector< Slot, 2 > Stack
Definition Sema.h:2012
ValueType DefaultValue
Definition Sema.h:2013
SourceLocation CurrentPragmaLocation
Definition Sema.h:2015
PragmaStack(const ValueType &Default)
Definition Sema.h:2007
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition Sema.h:1951
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition Sema.h:5046
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition Sema.h:5040
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition Sema.h:10367
Abstract class used to diagnose incomplete types.
Definition Sema.h:8210
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition Sema.h:2652
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition Sema.h:2661
bool CheckSameAsPrevious
Definition Sema.h:352
NamedDecl * Previous
Definition Sema.h:353
SkipBodyInfo()=default
NamedDecl * New
Definition Sema.h:354
Information about a template-id annotation token.