clang 20.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/Attr.h"
21#include "clang/AST/CharUnits.h"
22#include "clang/AST/DeclBase.h"
23#include "clang/AST/DeclCXX.h"
26#include "clang/AST/Expr.h"
27#include "clang/AST/ExprCXX.h"
32#include "clang/AST/StmtCXX.h"
33#include "clang/AST/Type.h"
34#include "clang/AST/TypeLoc.h"
38#include "clang/Basic/Cuda.h"
42#include "clang/Basic/LLVM.h"
43#include "clang/Basic/Lambda.h"
45#include "clang/Basic/Module.h"
57#include "clang/Sema/Attr.h"
59#include "clang/Sema/DeclSpec.h"
65#include "clang/Sema/Scope.h"
66#include "clang/Sema/SemaBase.h"
68#include "clang/Sema/Weak.h"
69#include "llvm/ADT/APInt.h"
70#include "llvm/ADT/ArrayRef.h"
71#include "llvm/ADT/BitmaskEnum.h"
72#include "llvm/ADT/DenseMap.h"
73#include "llvm/ADT/DenseSet.h"
74#include "llvm/ADT/FloatingPointMode.h"
75#include "llvm/ADT/FoldingSet.h"
76#include "llvm/ADT/MapVector.h"
77#include "llvm/ADT/PointerIntPair.h"
78#include "llvm/ADT/PointerUnion.h"
79#include "llvm/ADT/STLExtras.h"
80#include "llvm/ADT/STLForwardCompat.h"
81#include "llvm/ADT/STLFunctionalExtras.h"
82#include "llvm/ADT/SetVector.h"
83#include "llvm/ADT/SmallBitVector.h"
84#include "llvm/ADT/SmallPtrSet.h"
85#include "llvm/ADT/SmallSet.h"
86#include "llvm/ADT/SmallVector.h"
87#include "llvm/ADT/StringExtras.h"
88#include "llvm/ADT/StringMap.h"
89#include "llvm/ADT/TinyPtrVector.h"
90#include "llvm/Support/Allocator.h"
91#include "llvm/Support/Compiler.h"
92#include "llvm/Support/Error.h"
93#include "llvm/Support/ErrorHandling.h"
94#include <cassert>
95#include <climits>
96#include <cstddef>
97#include <cstdint>
98#include <deque>
99#include <functional>
100#include <iterator>
101#include <memory>
102#include <optional>
103#include <string>
104#include <tuple>
105#include <type_traits>
106#include <utility>
107#include <vector>
108
109namespace llvm {
110struct InlineAsmIdentifierInfo;
111} // namespace llvm
112
113namespace clang {
114class ADLResult;
115class APValue;
116struct ASTConstraintSatisfaction;
117class ASTConsumer;
118class ASTContext;
119class ASTDeclReader;
120class ASTMutationListener;
121class ASTReader;
122class ASTWriter;
123class CXXBasePath;
124class CXXBasePaths;
125class CXXFieldCollector;
126class CodeCompleteConsumer;
127enum class ComparisonCategoryType : unsigned char;
128class ConstraintSatisfaction;
129class DarwinSDKInfo;
130class DeclGroupRef;
131class DeducedTemplateArgument;
132struct DeductionFailureInfo;
133class DependentDiagnostic;
134class Designation;
135class IdentifierInfo;
136class ImplicitConversionSequence;
137typedef MutableArrayRef<ImplicitConversionSequence> ConversionSequenceList;
138class InitializationKind;
139class InitializationSequence;
140class InitializedEntity;
141enum class LangAS : unsigned int;
142class LocalInstantiationScope;
143class LookupResult;
144class MangleNumberingContext;
145typedef ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> ModuleIdPath;
146class ModuleLoader;
147class MultiLevelTemplateArgumentList;
148struct NormalizedConstraint;
149class ObjCInterfaceDecl;
150class ObjCMethodDecl;
151struct OverloadCandidate;
152enum class OverloadCandidateParamOrder : char;
154class OverloadCandidateSet;
155class Preprocessor;
156class SemaAMDGPU;
157class SemaARM;
158class SemaAVR;
159class SemaBPF;
160class SemaCodeCompletion;
161class SemaCUDA;
162class SemaHLSL;
163class SemaHexagon;
164class SemaLoongArch;
165class SemaM68k;
166class SemaMIPS;
167class SemaMSP430;
168class SemaNVPTX;
169class SemaObjC;
170class SemaOpenACC;
171class SemaOpenCL;
172class SemaOpenMP;
173class SemaPPC;
174class SemaPseudoObject;
175class SemaRISCV;
176class SemaSYCL;
177class SemaSwift;
178class SemaSystemZ;
179class SemaWasm;
180class SemaX86;
181class StandardConversionSequence;
182class TemplateArgument;
183class TemplateArgumentLoc;
184class TemplateInstantiationCallback;
185class TemplatePartialOrderingContext;
186class TemplateSpecCandidateSet;
187class Token;
188class TypeConstraint;
189class TypoCorrectionConsumer;
190class UnresolvedSetImpl;
191class UnresolvedSetIterator;
192class VisibleDeclConsumer;
193
194namespace sema {
195class BlockScopeInfo;
196class Capture;
197class CapturedRegionScopeInfo;
198class CapturingScopeInfo;
199class CompoundScopeInfo;
200class DelayedDiagnostic;
201class DelayedDiagnosticPool;
202class FunctionScopeInfo;
203class LambdaScopeInfo;
204class SemaPPCallbacks;
205class TemplateDeductionInfo;
206} // namespace sema
207
208// AssignmentAction - This is used by all the assignment diagnostic functions
209// to represent what is actually causing the operation
211 Assigning,
212 Passing,
213 Returning,
216 Sending,
217 Casting,
219};
221 const AssignmentAction &AA) {
222 DB << llvm::to_underlying(AA);
223 return DB;
224}
225
226namespace threadSafety {
227class BeforeSet;
228void threadSafetyCleanup(BeforeSet *Cache);
229} // namespace threadSafety
230
231// FIXME: No way to easily map from TemplateTypeParmTypes to
232// TemplateTypeParmDecls, so we have this horrible PointerUnion.
233typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *>,
234 SourceLocation>
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:
291 PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {}
292
293 void enterCondition(Sema &S, SourceLocation Tok);
294 void enterReturn(Sema &S, SourceLocation Tok);
296 /// Handles e.g. BaseType{ .D = Tok...
298 const Designation &D);
299 /// Computing a type for the function argument may require running
300 /// overloading, so we postpone its computation until it is actually needed.
301 ///
302 /// Clients should be very careful when using this function, as it stores a
303 /// function_ref, clients should make sure all calls to get() with the same
304 /// location happen while function_ref is alive.
305 ///
306 /// The callback should also emit signature help as a side-effect, but only
307 /// if the completion point has been reached.
309 llvm::function_ref<QualType()> ComputeType);
310
312 void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
313 SourceLocation OpLoc);
314 void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
316 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
317 /// Handles all type casts, including C-style cast, C++ casts, etc.
319
320 /// Get the expected type associated with this location, if any.
321 ///
322 /// If the location is a function argument, determining the expected type
323 /// involves considering all function overloads and the arguments so far.
324 /// In this case, signature help for these function overloads will be reported
325 /// as a side-effect (only if the completion point has been reached).
327 if (!Enabled || Tok != ExpectedLoc)
328 return QualType();
329 if (!Type.isNull())
330 return Type;
331 if (ComputeType)
332 return ComputeType();
333 return QualType();
334 }
335
336private:
337 bool Enabled;
338 /// Start position of a token for which we store expected type.
339 SourceLocation ExpectedLoc;
340 /// Expected type for a token starting at ExpectedLoc.
342 /// A function to compute expected type at ExpectedLoc. It is only considered
343 /// if Type is null.
344 llvm::function_ref<QualType()> ComputeType;
345};
346
348 SkipBodyInfo() = default;
349 bool ShouldSkip = false;
351 NamedDecl *Previous = nullptr;
352 NamedDecl *New = nullptr;
353};
354
355/// Describes the result of template argument deduction.
356///
357/// The TemplateDeductionResult enumeration describes the result of
358/// template argument deduction, as returned from
359/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
360/// structure provides additional information about the results of
361/// template argument deduction, e.g., the deduced template argument
362/// list (if successful) or the specific template parameters or
363/// deduced arguments that were involved in the failure.
365 /// Template argument deduction was successful.
366 Success = 0,
367 /// The declaration was invalid; do nothing.
368 Invalid,
369 /// Template argument deduction exceeded the maximum template
370 /// instantiation depth (which has already been diagnosed).
372 /// Template argument deduction did not deduce a value
373 /// for every template parameter.
375 /// Template argument deduction did not deduce a value for every
376 /// expansion of an expanded template parameter pack.
378 /// Template argument deduction produced inconsistent
379 /// deduced values for the given template parameter.
381 /// Template argument deduction failed due to inconsistent
382 /// cv-qualifiers on a template parameter type that would
383 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
384 /// but were given a non-const "X".
386 /// Substitution of the deduced template argument values
387 /// resulted in an error.
389 /// After substituting deduced template arguments, a dependent
390 /// parameter type did not match the corresponding argument.
392 /// After substituting deduced template arguments, an element of
393 /// a dependent parameter type did not match the corresponding element
394 /// of the corresponding argument (when deducing from an initializer list).
396 /// A non-depnedent component of the parameter did not match the
397 /// corresponding component of the argument.
399 /// When performing template argument deduction for a function
400 /// template, there were too many call arguments.
402 /// When performing template argument deduction for a function
403 /// template, there were too few call arguments.
405 /// The explicitly-specified template arguments were not valid
406 /// template arguments for the given template.
408 /// Checking non-dependent argument conversions failed.
410 /// The deduced arguments did not satisfy the constraints associated
411 /// with the template.
413 /// Deduction failed; that's all we know.
415 /// CUDA Target attributes do not match.
417 /// Some error which was already diagnosed.
419};
420
421/// Kinds of C++ special members.
429 Invalid
430};
431
432/// The kind of conversion being performed.
434 /// An implicit conversion.
435 Implicit,
436 /// A C-style cast.
438 /// A functional-style cast.
440 /// A cast other than a C-style cast.
441 OtherCast,
442 /// A conversion for an operand of a builtin overloaded operator.
444};
445
446enum class TagUseKind {
447 Reference, // Reference to a tag: 'struct foo *X;'
448 Declaration, // Fwd decl of a tag: 'struct foo;'
449 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
450 Friend // Friend declaration: 'friend struct foo;'
451};
452
453/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
454enum class FunctionEffectMode : uint8_t {
455 None, // effect is not present.
456 False, // effect(false).
457 True, // effect(true).
458 Dependent // effect(expr) where expr is dependent.
459};
460
461/// Sema - This implements semantic analysis and AST building for C.
462/// \nosubgrouping
463class Sema final : public SemaBase {
464 // Table of Contents
465 // -----------------
466 // 1. Semantic Analysis (Sema.cpp)
467 // 2. API Notes (SemaAPINotes.cpp)
468 // 3. C++ Access Control (SemaAccess.cpp)
469 // 4. Attributes (SemaAttr.cpp)
470 // 5. Availability Attribute Handling (SemaAvailability.cpp)
471 // 6. Bounds Safety (SemaBoundsSafety.cpp)
472 // 7. Casts (SemaCast.cpp)
473 // 8. Extra Semantic Checking (SemaChecking.cpp)
474 // 9. C++ Coroutines (SemaCoroutine.cpp)
475 // 10. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
476 // 11. Declarations (SemaDecl.cpp)
477 // 12. Declaration Attribute Handling (SemaDeclAttr.cpp)
478 // 13. C++ Declarations (SemaDeclCXX.cpp)
479 // 14. C++ Exception Specifications (SemaExceptionSpec.cpp)
480 // 15. Expressions (SemaExpr.cpp)
481 // 16. C++ Expressions (SemaExprCXX.cpp)
482 // 17. Member Access Expressions (SemaExprMember.cpp)
483 // 18. Initializers (SemaInit.cpp)
484 // 19. C++ Lambda Expressions (SemaLambda.cpp)
485 // 20. Name Lookup (SemaLookup.cpp)
486 // 21. Modules (SemaModule.cpp)
487 // 22. C++ Overloading (SemaOverload.cpp)
488 // 23. Statements (SemaStmt.cpp)
489 // 24. `inline asm` Statement (SemaStmtAsm.cpp)
490 // 25. Statement Attribute Handling (SemaStmtAttr.cpp)
491 // 26. C++ Templates (SemaTemplate.cpp)
492 // 27. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
493 // 28. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
494 // 29. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
495 // 30. C++ Template Declaration Instantiation
496 // (SemaTemplateInstantiateDecl.cpp)
497 // 31. C++ Variadic Templates (SemaTemplateVariadic.cpp)
498 // 32. Constraints and Concepts (SemaConcept.cpp)
499 // 33. Types (SemaType.cpp)
500 // 34. FixIt Helpers (SemaFixItUtils.cpp)
501 // 35. Function Effects (SemaFunctionEffects.cpp)
502
503 /// \name Semantic Analysis
504 /// Implementations are in Sema.cpp
505 ///@{
506
507public:
508 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
510 CodeCompleteConsumer *CompletionConsumer = nullptr);
511 ~Sema();
512
513 /// Perform initialization that occurs after the parser has been
514 /// initialized but before it parses anything.
515 void Initialize();
516
517 /// This virtual key function only exists to limit the emission of debug info
518 /// describing the Sema class. GCC and Clang only emit debug info for a class
519 /// with a vtable when the vtable is emitted. Sema is final and not
520 /// polymorphic, but the debug info size savings are so significant that it is
521 /// worth adding a vtable just to take advantage of this optimization.
522 virtual void anchor();
523
524 const LangOptions &getLangOpts() const { return LangOpts; }
527
530 Preprocessor &getPreprocessor() const { return PP; }
531 ASTContext &getASTContext() const { return Context; }
535
537 StringRef Platform);
539
540 /// Registers an external source. If an external source already exists,
541 /// creates a multiplex external source and appends to it.
542 ///
543 ///\param[in] E - A non-null external sema source.
544 ///
546
547 /// Print out statistics about the semantic analysis.
548 void PrintStats() const;
549
550 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
551 /// guaranteed). Produces a warning if we're low on stack space and allocates
552 /// more in that case. Use this in code that may recurse deeply (for example,
553 /// in template instantiation) to avoid stack overflow.
555 llvm::function_ref<void()> Fn);
556
557 /// Returns default addr space for method qualifiers.
559
560 /// Load weak undeclared identifiers from the external source.
562
563 /// Determine if VD, which must be a variable or function, is an external
564 /// symbol that nonetheless can't be referenced from outside this translation
565 /// unit because its type has no linkage and it's not extern "C".
566 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
567
568 /// Obtain a sorted list of functions that are undefined but ODR-used.
570 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
571
572 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
574 /// Retrieves list of suspicious delete-expressions that will be checked at
575 /// the end of translation unit.
576 const llvm::MapVector<FieldDecl *, DeleteLocs> &
578
579 /// Cause the built diagnostic to be emitted on the DiagosticsEngine.
580 /// This is closely coupled to the SemaDiagnosticBuilder class and
581 /// should not be used elsewhere.
582 void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB);
583
584 void addImplicitTypedef(StringRef Name, QualType T);
585
586 /// Whether uncompilable error has occurred. This includes error happens
587 /// in deferred diagnostics.
588 bool hasUncompilableErrorOccurred() const;
589
590 /// Looks through the macro-expansion chain for the given
591 /// location, looking for a macro expansion with the given name.
592 /// If one is found, returns true and sets the location to that
593 /// expansion loc.
594 bool findMacroSpelling(SourceLocation &loc, StringRef name);
595
596 /// Calls \c Lexer::getLocForEndOfToken()
598
599 /// Retrieve the module loader associated with the preprocessor.
601
602 /// Invent a new identifier for parameters of abbreviated templates.
605 unsigned Index);
606
608
609 // Emit all deferred diagnostics.
610 void emitDeferredDiags();
611
613 /// The global module fragment, between 'module;' and a module-declaration.
615 /// A normal translation unit fragment. For a non-module unit, this is the
616 /// entire translation unit. Otherwise, it runs from the module-declaration
617 /// to the private-module-fragment (if any) or the end of the TU (if not).
619 /// The private module fragment, between 'module :private;' and the end of
620 /// the translation unit.
621 Private
622 };
623
624 /// This is called before the very first declaration in the translation unit
625 /// is parsed. Note that the ASTContext may have already injected some
626 /// declarations.
628 /// ActOnEndOfTranslationUnit - This is called at the very end of the
629 /// translation unit when EOF is reached and all but the top-level scope is
630 /// popped.
633
634 /// Determines the active Scope associated with the given declaration
635 /// context.
636 ///
637 /// This routine maps a declaration context to the active Scope object that
638 /// represents that declaration context in the parser. It is typically used
639 /// from "scope-less" code (e.g., template instantiation, lazy creation of
640 /// declarations) that injects a name for name-lookup purposes and, therefore,
641 /// must update the Scope.
642 ///
643 /// \returns The scope corresponding to the given declaraion context, or NULL
644 /// if no such scope is open.
646
647 void PushFunctionScope();
648 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
650
651 /// This is used to inform Sema what the current TemplateParameterDepth
652 /// is during Parsing. Currently it is used to pass on the depth
653 /// when parsing generic lambda 'auto' parameters.
654 void RecordParsingTemplateParameterDepth(unsigned Depth);
655
656 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
658 unsigned OpenMPCaptureLevel = 0);
659
660 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
661 /// time after they've been popped.
663 Sema *Self;
664
665 public:
666 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
668 };
669
671 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
672
673 /// Pop a function (or block or lambda or captured region) scope from the
674 /// stack.
675 ///
676 /// \param WP The warning policy to use for CFG-based warnings, or null if
677 /// such warnings should not be produced.
678 /// \param D The declaration corresponding to this function scope, if
679 /// producing CFG-based warnings.
680 /// \param BlockType The type of the block expression, if D is a BlockDecl.
683 const Decl *D = nullptr,
684 QualType BlockType = QualType());
685
687
692
693 void PushCompoundScope(bool IsStmtExpr);
694 void PopCompoundScope();
695
696 /// Determine whether any errors occurred within this function/method/
697 /// block.
699
700 /// Retrieve the current block, if any.
702
703 /// Get the innermost lambda or block enclosing the current location, if any.
704 /// This looks through intervening non-lambda, non-block scopes such as local
705 /// functions.
707
708 /// Retrieve the current lambda scope info, if any.
709 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
710 /// lambda scope info ignoring all inner capturing scopes that are not
711 /// lambda scopes.
713 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
714
715 /// Retrieve the current generic lambda info, if any.
717
718 /// Retrieve the current captured region, if any.
720
721 void ActOnComment(SourceRange Comment);
722
723 /// Retrieve the parser's current scope.
724 ///
725 /// This routine must only be used when it is certain that semantic analysis
726 /// and the parser are in precisely the same context, which is not the case
727 /// when, e.g., we are performing any kind of template instantiation.
728 /// Therefore, the only safe places to use this scope are in the parser
729 /// itself and in routines directly invoked from the parser and *never* from
730 /// template substitution or instantiation.
731 Scope *getCurScope() const { return CurScope; }
732
734
737 }
738
739 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
740 const FunctionDecl *FD = nullptr);
742 const PartialDiagnostic &PD,
743 const FunctionDecl *FD = nullptr) {
744 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
745 }
746
747 /// Check if the type is allowed to be used for the current target.
749 ValueDecl *D = nullptr);
750
751 // /// The kind of conversion being performed.
752 // enum CheckedConversionKind {
753 // /// An implicit conversion.
754 // CCK_ImplicitConversion,
755 // /// A C-style cast.
756 // CCK_CStyleCast,
757 // /// A functional-style cast.
758 // CCK_FunctionalCast,
759 // /// A cast other than a C-style cast.
760 // CCK_OtherCast,
761 // /// A conversion for an operand of a builtin overloaded operator.
762 // CCK_ForBuiltinOverloadedOp
763 // };
764
765 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
766 /// cast. If there is already an implicit cast, merge into the existing one.
767 /// If isLvalue, the result of the cast is an lvalue.
770 const CXXCastPath *BasePath = nullptr,
772
773 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
774 /// to the conversion from scalar type ScalarTy to the Boolean type.
776
777 /// If \p AllowLambda is true, treat lambda as function.
778 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
779
780 /// Returns a pointer to the innermost enclosing function, or nullptr if the
781 /// current context is not inside a function. If \p AllowLambda is true,
782 /// this can return the call operator of an enclosing lambda, otherwise
783 /// lambdas are skipped when looking for an enclosing function.
784 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
785
786 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
787 /// the method decl for the method being parsed. If we're currently
788 /// in a 'block', this returns the containing context.
790
791 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
792 /// or C function we're in, otherwise return null. If we're currently
793 /// in a 'block', this returns the containing context.
795
796 /// Warn if we're implicitly casting from a _Nullable pointer type to a
797 /// _Nonnull one.
800
801 /// Warn when implicitly casting 0 to nullptr.
803
804 /// Warn when implicitly changing function effects.
807
808 /// makeUnavailableInSystemHeader - There is an error in the current
809 /// context. If we're still in a system header, and we can plausibly
810 /// make the relevant declaration unavailable instead of erroring, do
811 /// so and return true.
813 UnavailableAttr::ImplicitReason reason);
814
815 /// Retrieve a suitable printing policy for diagnostics.
818 }
819
820 /// Retrieve a suitable printing policy for diagnostics.
822 const Preprocessor &PP);
823
824 /// Scope actions.
826
827 /// Determine whether \param D is function like (function or function
828 /// template) for parsing.
830
831 /// The maximum alignment, same as in llvm::Value. We duplicate them here
832 /// because that allows us not to duplicate the constants in clang code,
833 /// which we must to since we can't directly use the llvm constants.
834 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
835 ///
836 /// This is the greatest alignment value supported by load, store, and alloca
837 /// instructions, and global values.
838 static const unsigned MaxAlignmentExponent = 32;
839 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
840
841 /// Flag indicating whether or not to collect detailed statistics.
843
844 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
845
846 /// Stack containing information about each of the nested
847 /// function, block, and method scopes that are currently active.
849
850 /// The index of the first FunctionScope that corresponds to the current
851 /// context.
853
854 /// Track the number of currently active capturing scopes.
856
857 llvm::BumpPtrAllocator BumpAlloc;
858
859 /// The kind of translation unit we are processing.
860 ///
861 /// When we're processing a complete translation unit, Sema will perform
862 /// end-of-translation-unit semantic tasks (such as creating
863 /// initializers for tentative definitions in C) once parsing has
864 /// completed. Modules and precompiled headers perform different kinds of
865 /// checks.
867
868 /// Translation Unit Scope - useful to Objective-C actions that need
869 /// to lookup file scope declarations in the "ordinary" C decl namespace.
870 /// For example, user-defined classes, built-in "id" type, etc.
872
874 return CurScope->incrementMSManglingNumber();
875 }
876
877 /// Try to recover by turning the given expression into a
878 /// call. Returns true if recovery was attempted or an error was
879 /// emitted; this may also leave the ExprResult invalid.
881 bool ForceComplain = false,
882 bool (*IsPlausibleResult)(QualType) = nullptr);
883
884 /// Figure out if an expression could be turned into a call.
885 ///
886 /// Use this when trying to recover from an error where the programmer may
887 /// have written just the name of a function instead of actually calling it.
888 ///
889 /// \param E - The expression to examine.
890 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
891 /// with no arguments, this parameter is set to the type returned by such a
892 /// call; otherwise, it is set to an empty QualType.
893 /// \param OverloadSet - If the expression is an overloaded function
894 /// name, this parameter is populated with the decls of the various
895 /// overloads.
896 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
897 UnresolvedSetImpl &NonTemplateOverloads);
898
902
905
913
914 /// A RAII object to enter scope of a compound statement.
916 public:
917 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
918 S.ActOnStartOfCompoundStmt(IsStmtExpr);
919 }
920
922
923 private:
924 Sema &S;
925 };
926
927 /// An RAII helper that pops function a function scope on exit.
930 bool Active;
933 if (Active)
935 }
936 void disable() { Active = false; }
937 };
938
940 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
941 }
942
943 /// Worker object for performing CFG-based warnings.
946
947 /// Callback to the parser to parse templated functions when needed.
948 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
949 typedef void LateTemplateParserCleanupCB(void *P);
953
955 LateTemplateParserCleanupCB *LTPCleanup, void *P) {
956 LateTemplateParser = LTP;
957 LateTemplateParserCleanup = LTPCleanup;
958 OpaqueParser = P;
959 }
960
961 /// Callback to the parser to parse a type expressed as a string.
962 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
964
965 /// VAListTagName - The declaration name corresponding to __va_list_tag.
966 /// This is used as part of a hack to omit that class from ADL results.
968
969 /// Is the last error level diagnostic immediate. This is used to determined
970 /// whether the next info diagnostic should be immediate.
972
973 class DelayedDiagnostics;
974
976 sema::DelayedDiagnosticPool *SavedPool = nullptr;
978 };
981
982 /// A class which encapsulates the logic for delaying diagnostics
983 /// during parsing and other processing.
985 /// The current pool of diagnostics into which delayed
986 /// diagnostics should go.
987 sema::DelayedDiagnosticPool *CurPool = nullptr;
988
989 public:
991
992 /// Adds a delayed diagnostic.
993 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
994
995 /// Determines whether diagnostics should be delayed.
996 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
997
998 /// Returns the current delayed-diagnostics pool.
999 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1000
1001 /// Enter a new scope. Access and deprecation diagnostics will be
1002 /// collected in this pool.
1005 state.SavedPool = CurPool;
1006 CurPool = &pool;
1007 return state;
1008 }
1009
1010 /// Leave a delayed-diagnostic state that was previously pushed.
1011 /// Do not emit any of the diagnostics. This is performed as part
1012 /// of the bookkeeping of popping a pool "properly".
1014 CurPool = state.SavedPool;
1015 }
1016
1017 /// Enter a new scope where access and deprecation diagnostics are
1018 /// not delayed.
1021 state.SavedPool = CurPool;
1022 CurPool = nullptr;
1023 return state;
1024 }
1025
1026 /// Undo a previous pushUndelayed().
1028 assert(CurPool == nullptr);
1029 CurPool = state.SavedPool;
1030 }
1031 } DelayedDiagnostics;
1032
1034 return DelayedDiagnostics.push(pool);
1035 }
1036
1037 /// Diagnostics that are emitted only if we discover that the given function
1038 /// must be codegen'ed. Because handling these correctly adds overhead to
1039 /// compilation, this is currently only enabled for CUDA compilations.
1040 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1041
1042 /// CurContext - This is the current declaration context of parsing.
1044
1046 assert(AMDGPUPtr);
1047 return *AMDGPUPtr;
1048 }
1049
1051 assert(ARMPtr);
1052 return *ARMPtr;
1053 }
1054
1056 assert(AVRPtr);
1057 return *AVRPtr;
1058 }
1059
1061 assert(BPFPtr);
1062 return *BPFPtr;
1063 }
1064
1066 assert(CodeCompletionPtr);
1067 return *CodeCompletionPtr;
1068 }
1069
1071 assert(CUDAPtr);
1072 return *CUDAPtr;
1073 }
1074
1076 assert(HLSLPtr);
1077 return *HLSLPtr;
1078 }
1079
1081 assert(HexagonPtr);
1082 return *HexagonPtr;
1083 }
1084
1086 assert(LoongArchPtr);
1087 return *LoongArchPtr;
1088 }
1089
1091 assert(M68kPtr);
1092 return *M68kPtr;
1093 }
1094
1096 assert(MIPSPtr);
1097 return *MIPSPtr;
1098 }
1099
1101 assert(MSP430Ptr);
1102 return *MSP430Ptr;
1103 }
1104
1106 assert(NVPTXPtr);
1107 return *NVPTXPtr;
1108 }
1109
1111 assert(ObjCPtr);
1112 return *ObjCPtr;
1113 }
1114
1116 assert(OpenACCPtr);
1117 return *OpenACCPtr;
1118 }
1119
1121 assert(OpenCLPtr);
1122 return *OpenCLPtr;
1123 }
1124
1126 assert(OpenMPPtr && "SemaOpenMP is dead");
1127 return *OpenMPPtr;
1128 }
1129
1131 assert(PPCPtr);
1132 return *PPCPtr;
1133 }
1134
1136 assert(PseudoObjectPtr);
1137 return *PseudoObjectPtr;
1138 }
1139
1141 assert(RISCVPtr);
1142 return *RISCVPtr;
1143 }
1144
1146 assert(SYCLPtr);
1147 return *SYCLPtr;
1148 }
1149
1151 assert(SwiftPtr);
1152 return *SwiftPtr;
1153 }
1154
1156 assert(SystemZPtr);
1157 return *SystemZPtr;
1158 }
1159
1161 assert(WasmPtr);
1162 return *WasmPtr;
1163 }
1164
1166 assert(X86Ptr);
1167 return *X86Ptr;
1168 }
1169
1170 /// Source of additional semantic information.
1172
1173protected:
1174 friend class Parser;
1176 friend class ASTReader;
1177 friend class ASTDeclReader;
1178 friend class ASTWriter;
1179
1180private:
1181 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1182 bool WarnedDarwinSDKInfoMissing = false;
1183
1184 StackExhaustionHandler StackHandler;
1185
1186 Sema(const Sema &) = delete;
1187 void operator=(const Sema &) = delete;
1188
1189 /// The handler for the FileChanged preprocessor events.
1190 ///
1191 /// Used for diagnostics that implement custom semantic analysis for #include
1192 /// directives, like -Wpragma-pack.
1193 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1194
1195 /// The parser's current scope.
1196 ///
1197 /// The parser maintains this state here.
1198 Scope *CurScope;
1199
1200 mutable IdentifierInfo *Ident_super;
1201
1202 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1203 std::unique_ptr<SemaARM> ARMPtr;
1204 std::unique_ptr<SemaAVR> AVRPtr;
1205 std::unique_ptr<SemaBPF> BPFPtr;
1206 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1207 std::unique_ptr<SemaCUDA> CUDAPtr;
1208 std::unique_ptr<SemaHLSL> HLSLPtr;
1209 std::unique_ptr<SemaHexagon> HexagonPtr;
1210 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1211 std::unique_ptr<SemaM68k> M68kPtr;
1212 std::unique_ptr<SemaMIPS> MIPSPtr;
1213 std::unique_ptr<SemaMSP430> MSP430Ptr;
1214 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1215 std::unique_ptr<SemaObjC> ObjCPtr;
1216 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1217 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1218 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1219 std::unique_ptr<SemaPPC> PPCPtr;
1220 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1221 std::unique_ptr<SemaRISCV> RISCVPtr;
1222 std::unique_ptr<SemaSYCL> SYCLPtr;
1223 std::unique_ptr<SemaSwift> SwiftPtr;
1224 std::unique_ptr<SemaSystemZ> SystemZPtr;
1225 std::unique_ptr<SemaWasm> WasmPtr;
1226 std::unique_ptr<SemaX86> X86Ptr;
1227
1228 ///@}
1229
1230 //
1231 //
1232 // -------------------------------------------------------------------------
1233 //
1234 //
1235
1236 /// \name API Notes
1237 /// Implementations are in SemaAPINotes.cpp
1238 ///@{
1239
1240public:
1241 /// Map any API notes provided for this declaration to attributes on the
1242 /// declaration.
1243 ///
1244 /// Triggered by declaration-attribute processing.
1245 void ProcessAPINotes(Decl *D);
1246
1247 ///@}
1248
1249 //
1250 //
1251 // -------------------------------------------------------------------------
1252 //
1253 //
1254
1255 /// \name C++ Access Control
1256 /// Implementations are in SemaAccess.cpp
1257 ///@{
1258
1259public:
1266
1267 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1268 /// Returns true on error (when the previous member decl access specifier
1269 /// is different from the new member decl access specifier).
1270 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1271 NamedDecl *PrevMemberDecl,
1272 AccessSpecifier LexicalAS);
1273
1274 /// Perform access-control checking on a previously-unresolved member
1275 /// access which has now been resolved to a member.
1277 DeclAccessPair FoundDecl);
1279 DeclAccessPair FoundDecl);
1280
1281 /// Checks access to an overloaded operator new or delete.
1283 SourceRange PlacementRange,
1284 CXXRecordDecl *NamingClass,
1285 DeclAccessPair FoundDecl,
1286 bool Diagnose = true);
1287
1288 /// Checks access to a constructor.
1290 DeclAccessPair FoundDecl,
1291 const InitializedEntity &Entity,
1292 bool IsCopyBindingRefToTemp = false);
1293
1294 /// Checks access to a constructor.
1296 DeclAccessPair FoundDecl,
1297 const InitializedEntity &Entity,
1298 const PartialDiagnostic &PDiag);
1300 CXXDestructorDecl *Dtor,
1301 const PartialDiagnostic &PDiag,
1302 QualType objectType = QualType());
1303
1304 /// Checks access to the target of a friend declaration.
1306
1307 /// Checks access to a member.
1309 CXXRecordDecl *NamingClass,
1311
1312 /// Checks implicit access to a member in a structured binding.
1315 CXXRecordDecl *DecomposedClass,
1316 DeclAccessPair Field);
1318 const SourceRange &,
1319 DeclAccessPair FoundDecl);
1320
1321 /// Checks access to an overloaded member operator, including
1322 /// conversion operators.
1324 Expr *ArgExpr,
1325 DeclAccessPair FoundDecl);
1327 ArrayRef<Expr *> ArgExprs,
1328 DeclAccessPair FoundDecl);
1330 DeclAccessPair FoundDecl);
1331
1332 /// Checks access for a hierarchy conversion.
1333 ///
1334 /// \param ForceCheck true if this check should be performed even if access
1335 /// control is disabled; some things rely on this for semantics
1336 /// \param ForceUnprivileged true if this check should proceed as if the
1337 /// context had no special privileges
1339 QualType Derived, const CXXBasePath &Path,
1340 unsigned DiagID, bool ForceCheck = false,
1341 bool ForceUnprivileged = false);
1342
1343 /// Checks access to all the declarations in the given result set.
1344 void CheckLookupAccess(const LookupResult &R);
1345
1346 /// Checks access to Target from the given class. The check will take access
1347 /// specifiers into account, but no member access expressions and such.
1348 ///
1349 /// \param Target the declaration to check if it can be accessed
1350 /// \param NamingClass the class in which the lookup was started.
1351 /// \param BaseType type of the left side of member access expression.
1352 /// \p BaseType and \p NamingClass are used for C++ access control.
1353 /// Depending on the lookup case, they should be set to the following:
1354 /// - lhs.target (member access without a qualifier):
1355 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1356 /// - lhs.X::target (member access with a qualifier):
1357 /// BaseType is the type of 'lhs', NamingClass is 'X'
1358 /// - X::target (qualified lookup without member access):
1359 /// BaseType is null, NamingClass is 'X'.
1360 /// - target (unqualified lookup).
1361 /// BaseType is null, NamingClass is the parent class of 'target'.
1362 /// \return true if the Target is accessible from the Class, false otherwise.
1363 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1364 QualType BaseType);
1365
1366 /// Is the given member accessible for the purposes of deciding whether to
1367 /// define a special member function as deleted?
1369 DeclAccessPair Found, QualType ObjectType,
1371 const PartialDiagnostic &Diag);
1374 QualType ObjectType) {
1375 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1376 SourceLocation(), PDiag());
1377 }
1378
1380 const DependentDiagnostic &DD,
1381 const MultiLevelTemplateArgumentList &TemplateArgs);
1383
1384 ///@}
1385
1386 //
1387 //
1388 // -------------------------------------------------------------------------
1389 //
1390 //
1391
1392 /// \name Attributes
1393 /// Implementations are in SemaAttr.cpp
1394 ///@{
1395
1396public:
1397 /// Controls member pointer representation format under the MS ABI.
1400
1401 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1402
1403 /// Source location for newly created implicit MSInheritanceAttrs
1405
1406 /// pragma clang section kind
1413 PCSK_Relro = 5
1415
1417
1419 std::string SectionName;
1420 bool Valid = false;
1422 };
1423
1429
1431 PSK_Reset = 0x0, // #pragma ()
1432 PSK_Set = 0x1, // #pragma (value)
1433 PSK_Push = 0x2, // #pragma (push[, id])
1434 PSK_Pop = 0x4, // #pragma (pop[, id])
1435 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1436 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1437 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1438 };
1439
1442 StringRef SlotLabel;
1444 };
1445
1446 // #pragma pack and align.
1448 public:
1449 // `Native` represents default align mode, which may vary based on the
1450 // platform.
1451 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1452
1453 // #pragma pack info constructor
1454 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1455 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1456 assert(Num == PackNumber && "The pack number has been truncated.");
1457 }
1458
1459 // #pragma align info constructor
1461 : PackAttr(false), AlignMode(M),
1462 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1463
1464 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1465
1467
1468 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1469 // integer encoding for it. This should only be passed to
1470 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1471 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1472 std::uint32_t Encoding{};
1473 if (Info.IsXLStack())
1474 Encoding |= IsXLMask;
1475
1476 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1477
1478 if (Info.IsPackAttr())
1479 Encoding |= PackAttrMask;
1480
1481 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1482
1483 return Encoding;
1484 }
1485
1486 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1487 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1489 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1490 int PackNumber = (Encoding & PackNumMask) >> 4;
1491
1492 if (Encoding & PackAttrMask)
1493 return AlignPackInfo(M, PackNumber, IsXL);
1494
1495 return AlignPackInfo(M, IsXL);
1496 }
1497
1498 bool IsPackAttr() const { return PackAttr; }
1499
1500 bool IsAlignAttr() const { return !PackAttr; }
1501
1502 Mode getAlignMode() const { return AlignMode; }
1503
1504 unsigned getPackNumber() const { return PackNumber; }
1505
1506 bool IsPackSet() const {
1507 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1508 // attriute on a decl.
1509 return PackNumber != UninitPackVal && PackNumber != 0;
1510 }
1511
1512 bool IsXLStack() const { return XLStack; }
1513
1514 bool operator==(const AlignPackInfo &Info) const {
1515 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1516 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1517 Info.XLStack);
1518 }
1519
1520 bool operator!=(const AlignPackInfo &Info) const {
1521 return !(*this == Info);
1522 }
1523
1524 private:
1525 /// \brief True if this is a pragma pack attribute,
1526 /// not a pragma align attribute.
1527 bool PackAttr;
1528
1529 /// \brief The alignment mode that is in effect.
1530 Mode AlignMode;
1531
1532 /// \brief The pack number of the stack.
1533 unsigned char PackNumber;
1534
1535 /// \brief True if it is a XL #pragma align/pack stack.
1536 bool XLStack;
1537
1538 /// \brief Uninitialized pack value.
1539 static constexpr unsigned char UninitPackVal = -1;
1540
1541 // Masks to encode and decode an AlignPackInfo.
1542 static constexpr uint32_t IsXLMask{0x0000'0001};
1543 static constexpr uint32_t AlignModeMask{0x0000'0006};
1544 static constexpr uint32_t PackAttrMask{0x00000'0008};
1545 static constexpr uint32_t PackNumMask{0x0000'01F0};
1546 };
1547
1548 template <typename ValueType> struct PragmaStack {
1549 struct Slot {
1550 llvm::StringRef StackSlotLabel;
1551 ValueType Value;
1554 Slot(llvm::StringRef StackSlotLabel, ValueType Value,
1559 };
1560
1561 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1562 llvm::StringRef StackSlotLabel, ValueType Value) {
1563 if (Action == PSK_Reset) {
1565 CurrentPragmaLocation = PragmaLocation;
1566 return;
1567 }
1568 if (Action & PSK_Push)
1569 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1570 PragmaLocation);
1571 else if (Action & PSK_Pop) {
1572 if (!StackSlotLabel.empty()) {
1573 // If we've got a label, try to find it and jump there.
1574 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1575 return x.StackSlotLabel == StackSlotLabel;
1576 });
1577 // If we found the label so pop from there.
1578 if (I != Stack.rend()) {
1579 CurrentValue = I->Value;
1580 CurrentPragmaLocation = I->PragmaLocation;
1581 Stack.erase(std::prev(I.base()), Stack.end());
1582 }
1583 } else if (!Stack.empty()) {
1584 // We do not have a label, just pop the last entry.
1585 CurrentValue = Stack.back().Value;
1586 CurrentPragmaLocation = Stack.back().PragmaLocation;
1587 Stack.pop_back();
1588 }
1589 }
1590 if (Action & PSK_Set) {
1592 CurrentPragmaLocation = PragmaLocation;
1593 }
1594 }
1595
1596 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1597 // method body to restore the stacks on exit, so it works like this:
1598 //
1599 // struct S {
1600 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1601 // void Method {}
1602 // #pragma <name>(pop, InternalPragmaSlot)
1603 // };
1604 //
1605 // It works even with #pragma vtordisp, although MSVC doesn't support
1606 // #pragma vtordisp(push [, id], n)
1607 // syntax.
1608 //
1609 // Push / pop a named sentinel slot.
1610 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
1611 assert((Action == PSK_Push || Action == PSK_Pop) &&
1612 "Can only push / pop #pragma stack sentinels!");
1614 }
1615
1616 // Constructors.
1617 explicit PragmaStack(const ValueType &Default)
1619
1620 bool hasValue() const { return CurrentValue != DefaultValue; }
1621
1623 ValueType DefaultValue; // Value used for PSK_Reset action.
1624 ValueType CurrentValue;
1626 };
1627 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
1628 // we shouldn't do so if they're in a module).
1629
1630 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
1631 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
1632 ///
1633 /// 0: Suppress all vtordisps
1634 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
1635 /// structors
1636 /// 2: Always insert vtordisps to support RTTI on partially constructed
1637 /// objects
1640 // The current #pragma align/pack values and locations at each #include.
1645 };
1647 // Segment #pragmas.
1652
1653 // #pragma strict_gs_check.
1655
1656 // This stack tracks the current state of Sema.CurFPFeatures.
1659 FPOptionsOverride result;
1660 if (!FpPragmaStack.hasValue()) {
1661 result = FPOptionsOverride();
1662 } else {
1663 result = FpPragmaStack.CurrentValue;
1664 }
1665 return result;
1666 }
1667
1673 };
1674
1675 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
1676 // Actions should be performed only if we enter / exit a C++ method body.
1678 public:
1679 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
1681
1682 private:
1683 Sema &S;
1684 StringRef SlotLabel;
1685 bool ShouldAct;
1686 };
1687
1688 /// Last section used with #pragma init_seg.
1691
1692 /// Sections used with #pragma alloc_text.
1693 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
1694
1695 /// VisContext - Manages the stack for \#pragma GCC visibility.
1696 void *VisContext; // Really a "PragmaVisStack*"
1697
1698 /// This an attribute introduced by \#pragma clang attribute.
1704 };
1705
1706 /// A push'd group of PragmaAttributeEntries.
1708 /// The location of the push attribute.
1710 /// The namespace of this push group.
1713 };
1714
1716
1717 /// The declaration that is currently receiving an attribute from the
1718 /// #pragma attribute stack.
1720
1721 /// This represents the last location of a "#pragma clang optimize off"
1722 /// directive if such a directive has not been closed by an "on" yet. If
1723 /// optimizations are currently "on", this is set to an invalid location.
1725
1726 /// Get the location for the currently active "\#pragma clang optimize
1727 /// off". If this location is invalid, then the state of the pragma is "on".
1730 }
1731
1732 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
1733 /// whether the optimizations in the list passed to the pragma should be
1734 /// turned off or on. This boolean is true by default because command line
1735 /// options are honored when `#pragma optimize("", on)`.
1736 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
1738
1739 /// Set of no-builtin functions listed by \#pragma function.
1741
1742 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
1743 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
1745
1746 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
1748
1749 /// Add gsl::Pointer attribute to std::container::iterator
1750 /// \param ND The declaration that introduces the name
1751 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
1752 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
1753
1754 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
1756
1757 /// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
1759
1760 /// Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
1762
1763 /// Add [[gsl::Pointer]] attributes for std:: types.
1765
1766 LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
1767 StringRef ParamName);
1768 // Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'
1769 // can be the name of a function parameter, we need to parse the function
1770 // declaration and rest of the parameters before processesing 'X'. Therefore
1771 // do this lazily instead of processing while parsing the annotation itself.
1773
1774 /// Add _Nullable attributes for std:: types.
1776
1778 POAK_Native, // #pragma options align=native
1779 POAK_Natural, // #pragma options align=natural
1780 POAK_Packed, // #pragma options align=packed
1781 POAK_Power, // #pragma options align=power
1782 POAK_Mac68k, // #pragma options align=mac68k
1783 POAK_Reset // #pragma options align=reset
1785
1786 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
1789 PragmaClangSectionKind SecKind,
1790 StringRef SecName);
1791
1792 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
1794 SourceLocation PragmaLoc);
1795
1796 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
1797 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
1798 StringRef SlotLabel, Expr *Alignment);
1799
1800 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
1801 /// (unless they are value dependent or type dependent). Returns false
1802 /// and emits a diagnostic if one or more of the arguments could not be
1803 /// folded into a constant.
1806
1810 };
1811
1813 SourceLocation IncludeLoc);
1815
1816 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
1818
1819 /// ActOnPragmaMSComment - Called on well formed
1820 /// \#pragma comment(kind, "arg").
1822 StringRef Arg);
1823
1824 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
1825 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
1826 StringRef Value);
1827
1828 /// Are precise floating point semantics currently enabled?
1830 return !CurFPFeatures.getAllowFPReassociate() &&
1831 !CurFPFeatures.getNoSignedZero() &&
1832 !CurFPFeatures.getAllowReciprocal() &&
1833 !CurFPFeatures.getAllowApproxFunc();
1834 }
1835
1838
1839 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
1842
1843 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
1844 /// pointers_to_members(representation method[, general purpose
1845 /// representation]).
1848 SourceLocation PragmaLoc);
1849
1850 /// Called on well formed \#pragma vtordisp().
1853
1854 bool UnifySection(StringRef SectionName, int SectionFlags,
1855 NamedDecl *TheDecl);
1856 bool UnifySection(StringRef SectionName, int SectionFlags,
1857 SourceLocation PragmaSectionLocation);
1858
1859 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
1860 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
1861 PragmaMsStackAction Action,
1862 llvm::StringRef StackSlotLabel,
1863 StringLiteral *SegmentName, llvm::StringRef PragmaName);
1864
1865 /// Called on well formed \#pragma section().
1866 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
1867 StringLiteral *SegmentName);
1868
1869 /// Called on well-formed \#pragma init_seg().
1870 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
1871 StringLiteral *SegmentName);
1872
1873 /// Called on well-formed \#pragma alloc_text().
1875 SourceLocation PragmaLocation, StringRef Section,
1876 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
1877 &Functions);
1878
1879 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
1880 /// strict_gs_check.
1882 PragmaMsStackAction Action,
1883 bool Value);
1884
1885 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
1886 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
1887 SourceLocation PragmaLoc);
1888
1890 SourceLocation PragmaLoc,
1893 const IdentifierInfo *Namespace);
1894
1895 /// Called on well-formed '\#pragma clang attribute pop'.
1897 const IdentifierInfo *Namespace);
1898
1899 /// Adds the attributes that have been specified using the
1900 /// '\#pragma clang attribute push' directives to the given declaration.
1901 void AddPragmaAttributes(Scope *S, Decl *D);
1902
1904
1906
1907 /// Called on well formed \#pragma clang optimize.
1908 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
1909
1910 /// #pragma optimize("[optimization-list]", on | off).
1911 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
1912
1913 /// Call on well formed \#pragma function.
1914 void
1916 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
1917
1918 /// Only called on function definitions; if there is a pragma in scope
1919 /// with the effect of a range-based optnone, consider marking the function
1920 /// with attribute optnone.
1922
1923 /// Only called on function definitions; if there is a `#pragma alloc_text`
1924 /// that decides which code section the function should be in, add
1925 /// attribute section to the function.
1927
1928 /// Adds the 'optnone' attribute to the function declaration if there
1929 /// are no conflicts; Loc represents the location causing the 'optnone'
1930 /// attribute to be added (usually because of a pragma).
1932
1933 /// Only called on function definitions; if there is a MSVC #pragma optimize
1934 /// in scope, consider changing the function's attributes based on the
1935 /// optimization list passed to the pragma.
1937
1938 /// Only called on function definitions; if there is a pragma in scope
1939 /// with the effect of a range-based no_builtin, consider marking the function
1940 /// with attribute no_builtin.
1942
1943 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
1944 /// add an appropriate visibility attribute.
1946
1947 /// FreeVisContext - Deallocate and null out VisContext.
1948 void FreeVisContext();
1949
1950 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
1951 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
1952 SourceLocation PragmaLoc);
1953
1954 /// ActOnPragmaFPContract - Called on well formed
1955 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
1956 /// \#pragma clang fp contract
1958
1959 /// Called on well formed
1960 /// \#pragma clang fp reassociate
1961 /// or
1962 /// \#pragma clang fp reciprocal
1964 bool IsEnabled);
1965
1966 /// ActOnPragmaFenvAccess - Called on well formed
1967 /// \#pragma STDC FENV_ACCESS
1968 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
1969
1970 /// ActOnPragmaCXLimitedRange - Called on well formed
1971 /// \#pragma STDC CX_LIMITED_RANGE
1974
1975 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
1978
1979 /// Called to set constant rounding mode for floating point operations.
1980 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
1981
1982 /// Called to set exception behavior for floating point operations.
1984
1985 /// PushNamespaceVisibilityAttr - Note that we've entered a
1986 /// namespace with a visibility attribute.
1987 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
1989
1990 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
1991 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
1992 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
1993
1994 /// Handles semantic checking for features that are common to all attributes,
1995 /// such as checking whether a parameter was properly specified, or the
1996 /// correct number of arguments were passed, etc. Returns true if the
1997 /// attribute has been diagnosed.
1998 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
1999 bool SkipArgCountCheck = false);
2000 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2001 bool SkipArgCountCheck = false);
2002
2003 ///@}
2004
2005 //
2006 //
2007 // -------------------------------------------------------------------------
2008 //
2009 //
2010
2011 /// \name Availability Attribute Handling
2012 /// Implementations are in SemaAvailability.cpp
2013 ///@{
2014
2015public:
2016 /// Issue any -Wunguarded-availability warnings in \c FD
2018
2020
2021 /// Retrieve the current function, if any, that should be analyzed for
2022 /// potential availability violations.
2024
2026 const ObjCInterfaceDecl *UnknownObjCClass,
2027 bool ObjCPropertyAccess,
2028 bool AvoidPartialAvailabilityChecks = false,
2029 ObjCInterfaceDecl *ClassReceiver = nullptr);
2030
2031 ///@}
2032
2033 //
2034 //
2035 // -------------------------------------------------------------------------
2036 //
2037 //
2038
2039 /// \name Bounds Safety
2040 /// Implementations are in SemaBoundsSafety.cpp
2041 ///@{
2042public:
2043 /// Check if applying the specified attribute variant from the "counted by"
2044 /// family of attributes to FieldDecl \p FD is semantically valid. If
2045 /// semantically invalid diagnostics will be emitted explaining the problems.
2046 ///
2047 /// \param FD The FieldDecl to apply the attribute to
2048 /// \param E The count expression on the attribute
2049 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2050 /// attributes. If the false the attribute is from
2051 /// "counted_by" family of attributes.
2052 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2053 /// of attributes. If false the attribute does not have the
2054 /// suffix.
2055 ///
2056 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2057 /// \p CountInBytes and \p OrNull both being true indicates the
2058 /// `counted_by_or_null` attribute.
2059 ///
2060 /// \returns false iff semantically valid.
2061 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2062 bool OrNull);
2063
2064 ///@}
2065
2066 //
2067 //
2068 // -------------------------------------------------------------------------
2069 //
2070 //
2071
2072 /// \name Casts
2073 /// Implementations are in SemaCast.cpp
2074 ///@{
2075
2076public:
2078 return CCK == CheckedConversionKind::CStyleCast ||
2081 }
2082
2083 /// ActOnCXXNamedCast - Parse
2084 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2086 SourceLocation LAngleBracketLoc, Declarator &D,
2087 SourceLocation RAngleBracketLoc,
2088 SourceLocation LParenLoc, Expr *E,
2089 SourceLocation RParenLoc);
2090
2092 TypeSourceInfo *Ty, Expr *E,
2093 SourceRange AngleBrackets, SourceRange Parens);
2094
2096 ExprResult Operand,
2097 SourceLocation RParenLoc);
2098
2100 Expr *Operand, SourceLocation RParenLoc);
2101
2102 // Checks that reinterpret casts don't have undefined behavior.
2103 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2104 bool IsDereference, SourceRange Range);
2105
2106 // Checks that the vector type should be initialized from a scalar
2107 // by splatting the value rather than populating a single element.
2108 // This is the case for AltiVecVector types as well as with
2109 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2110 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2111
2112 // Checks if the -faltivec-src-compat=gcc option is specified.
2113 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2114 // treated the same way as they are when trying to initialize
2115 // these vectors on gcc (an error is emitted).
2117 QualType SrcTy);
2118
2120 SourceLocation RParenLoc, Expr *Op);
2121
2123 SourceLocation LParenLoc,
2124 Expr *CastExpr,
2125 SourceLocation RParenLoc);
2126
2127 ///@}
2128
2129 //
2130 //
2131 // -------------------------------------------------------------------------
2132 //
2133 //
2134
2135 /// \name Extra Semantic Checking
2136 /// Implementations are in SemaChecking.cpp
2137 ///@{
2138
2139public:
2140 /// Used to change context to isConstantEvaluated without pushing a heavy
2141 /// ExpressionEvaluationContextRecord object.
2143
2147 }
2148
2150 unsigned ByteNo) const;
2151
2153 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2154 FAPK_Variadic, // values to format are passed as variadic arguments
2155 FAPK_VAList, // values to format are passed in a va_list
2156 };
2157
2158 // Used to grab the relevant information from a FormatAttr and a
2159 // FunctionDeclaration.
2161 unsigned FormatIdx;
2164 };
2165
2166 /// Given a FunctionDecl's FormatAttr, attempts to populate the
2167 /// FomatStringInfo parameter with the FormatAttr's correct format_idx and
2168 /// firstDataArg. Returns true when the format fits the function and the
2169 /// FormatStringInfo has been populated.
2170 static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
2171 bool IsVariadic, FormatStringInfo *FSI);
2172
2173 // Used by C++ template instantiation.
2175
2176 /// ConvertVectorExpr - Handle __builtin_convertvector
2178 SourceLocation BuiltinLoc,
2179 SourceLocation RParenLoc);
2180
2194 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2195
2196 bool FormatStringHasSArg(const StringLiteral *FExpr);
2197
2198 /// Check for comparisons of floating-point values using == and !=. Issue a
2199 /// warning if the comparison is not likely to do what the programmer
2200 /// intended.
2202 BinaryOperatorKind Opcode);
2203
2204 /// Register a magic integral constant to be used as a type tag.
2205 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2206 uint64_t MagicValue, QualType Type,
2207 bool LayoutCompatible, bool MustBeNull);
2208
2211
2215
2217
2218 /// If true, \c Type should be compared with other expression's types for
2219 /// layout-compatibility.
2220 LLVM_PREFERRED_TYPE(bool)
2222 LLVM_PREFERRED_TYPE(bool)
2223 unsigned MustBeNull : 1;
2224 };
2225
2226 /// A pair of ArgumentKind identifier and magic value. This uniquely
2227 /// identifies the magic value.
2228 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2229
2230 /// Diagnoses the current set of gathered accesses. This typically
2231 /// happens at full expression level. The set is cleared after emitting the
2232 /// diagnostics.
2234
2235 /// This function checks if the expression is in the sef of potentially
2236 /// misaligned members and it is converted to some pointer type T with lower
2237 /// or equal alignment requirements. If so it removes it. This is used when
2238 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2239 /// void*).
2241
2242 /// This function calls Action when it determines that E designates a
2243 /// misaligned member due to the packed attribute. This is used to emit
2244 /// local diagnostics like in reference binding.
2246 Expr *E,
2247 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2248 Action);
2249
2250 enum class AtomicArgumentOrder { API, AST };
2252 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2253 SourceLocation RParenLoc, MultiExprArg Args,
2256
2257 /// Check to see if a given expression could have '.c_str()' called on it.
2258 bool hasCStrMethod(const Expr *E);
2259
2260 /// Diagnose pointers that are always non-null.
2261 /// \param E the expression containing the pointer
2262 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2263 /// compared to a null pointer
2264 /// \param IsEqual True when the comparison is equal to a null pointer
2265 /// \param Range Extra SourceRange to highlight in the diagnostic
2268 bool IsEqual, SourceRange Range);
2269
2270 /// CheckParmsForFunctionDef - Check that the parameters of the given
2271 /// function are appropriate for the definition of a function. This
2272 /// takes care of any checks that cannot be performed on the
2273 /// declaration itself, e.g., that the types of each of the function
2274 /// parameters are complete.
2276 bool CheckParameterNames);
2277
2278 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2279 /// pointer cast increases the alignment requirements.
2280 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2281
2282 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2283 /// to weak/__unsafe_unretained type.
2285
2286 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2287 /// to weak/__unsafe_unretained expression.
2289
2290 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2291 /// statement as a \p Body, and it is located on the same line.
2292 ///
2293 /// This helps prevent bugs due to typos, such as:
2294 /// if (condition);
2295 /// do_stuff();
2296 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2297 unsigned DiagID);
2298
2299 /// Warn if a for/while loop statement \p S, which is followed by
2300 /// \p PossibleBody, has a suspicious null statement as a body.
2301 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2302
2303 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2304 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2305 SourceLocation OpLoc);
2306
2307 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
2315
2316 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2318 const TypeSourceInfo *Derived);
2319
2320 /// CheckFunctionCall - Check a direct function call for various correctness
2321 /// and safety properties not strictly enforced by the C type system.
2322 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2323 const FunctionProtoType *Proto);
2324
2325 /// \param FPOnly restricts the arguments to floating-point types.
2326 bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res, bool FPOnly = false);
2327 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2328
2329 void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
2330 const Expr *ThisArg, ArrayRef<const Expr *> Args);
2331
2332 /// Handles the checks for format strings, non-POD arguments to vararg
2333 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2334 /// attributes and AArch64 SME attributes.
2335 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2336 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2337 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2338 VariadicCallType CallType);
2339
2340 /// \brief Enforce the bounds of a TCB
2341 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2342 /// directly calls other functions in the same TCB as marked by the
2343 /// enforce_tcb and enforce_tcb_leaf attributes.
2344 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2345 const NamedDecl *Callee);
2346
2347 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2348
2349 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2350 /// TheCall is a constant expression.
2351 bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result);
2352
2353 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2354 /// TheCall is a constant expression in the range [Low, High].
2355 bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High,
2356 bool RangeIsError = true);
2357
2358 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2359 /// TheCall is a constant expression is a multiple of Num..
2360 bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
2361 unsigned Multiple);
2362
2363 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2364 /// constant expression representing a power of 2.
2365 bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum);
2366
2367 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2368 /// a constant expression representing an arbitrary byte value shifted left by
2369 /// a multiple of 8 bits.
2370 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
2371 unsigned ArgBits);
2372
2373 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2374 /// TheCall is a constant expression representing either a shifted byte value,
2375 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2376 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2377 /// Arm MVE intrinsics.
2378 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
2379 unsigned ArgBits);
2380
2381 /// Checks that a call expression's argument count is at least the desired
2382 /// number. This is useful when doing custom type-checking on a variadic
2383 /// function. Returns true on error.
2384 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2385
2386 /// Checks that a call expression's argument count is at most the desired
2387 /// number. This is useful when doing custom type-checking on a variadic
2388 /// function. Returns true on error.
2389 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2390
2391 /// Checks that a call expression's argument count is in the desired range.
2392 /// This is useful when doing custom type-checking on a variadic function.
2393 /// Returns true on error.
2394 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2395 unsigned MaxArgCount);
2396
2397 /// Checks that a call expression's argument count is the desired number.
2398 /// This is useful when doing custom type-checking. Returns true on error.
2399 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2400
2401 /// Returns true if the argument consists of one contiguous run of 1s with any
2402 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2403 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2404 /// since all 1s are not contiguous.
2405 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2406
2408 bool *ICContext = nullptr,
2409 bool IsListInit = false);
2410
2412 bool CheckForFloatArgs = true);
2414
2415private:
2416 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2417 const ArraySubscriptExpr *ASE = nullptr,
2418 bool AllowOnePastEnd = true, bool IndexNegated = false);
2419 void CheckArrayAccess(const Expr *E);
2420
2421 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2422 const FunctionProtoType *Proto);
2423
2424 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
2425 /// such as function pointers returned from functions.
2426 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2427
2428 /// CheckConstructorCall - Check a constructor call for correctness and safety
2429 /// properties not enforced by the C type system.
2430 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2432 const FunctionProtoType *Proto, SourceLocation Loc);
2433
2434 /// Warn if a pointer or reference argument passed to a function points to an
2435 /// object that is less aligned than the parameter. This can happen when
2436 /// creating a typedef with a lower alignment than the original type and then
2437 /// calling functions defined in terms of the original type.
2438 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2439 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2440
2441 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2442
2443 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2444 CallExpr *TheCall);
2445
2446 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2447 CallExpr *TheCall);
2448
2449 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2450
2451 /// Check the arguments to '__builtin_va_start' or '__builtin_ms_va_start'
2452 /// for validity. Emit an error and return true on failure; return false
2453 /// on success.
2454 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2455 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2456
2457 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
2458 /// friends. This is declared to take (...), so we have to check everything.
2459 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2460
2461 /// BuiltinSemaBuiltinFPClassification - Handle functions like
2462 /// __builtin_isnan and friends. This is declared to take (...), so we have
2463 /// to check everything.
2464 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2465 unsigned BuiltinID);
2466
2467 /// Perform semantic analysis for a call to __builtin_complex.
2468 bool BuiltinComplex(CallExpr *TheCall);
2469 bool BuiltinOSLogFormat(CallExpr *TheCall);
2470
2471 /// BuiltinPrefetch - Handle __builtin_prefetch.
2472 /// This is declared to take (const void*, ...) and can take two
2473 /// optional constant int args.
2474 bool BuiltinPrefetch(CallExpr *TheCall);
2475
2476 /// Handle __builtin_alloca_with_align. This is declared
2477 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
2478 /// than 8.
2479 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2480
2481 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
2482 bool BuiltinArithmeticFence(CallExpr *TheCall);
2483
2484 /// BuiltinAssume - Handle __assume (MS Extension).
2485 /// __assume does not evaluate its arguments, and should warn if its argument
2486 /// has side effects.
2487 bool BuiltinAssume(CallExpr *TheCall);
2488
2489 /// Handle __builtin_assume_aligned. This is declared
2490 /// as (const void*, size_t, ...) and can take one optional constant int arg.
2491 bool BuiltinAssumeAligned(CallExpr *TheCall);
2492
2493 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
2494 /// This checks that the target supports __builtin_longjmp and
2495 /// that val is a constant 1.
2496 bool BuiltinLongjmp(CallExpr *TheCall);
2497
2498 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
2499 /// This checks that the target supports __builtin_setjmp.
2500 bool BuiltinSetjmp(CallExpr *TheCall);
2501
2502 /// We have a call to a function like __sync_fetch_and_add, which is an
2503 /// overloaded function based on the pointer type of its first argument.
2504 /// The main BuildCallExpr routines have already promoted the types of
2505 /// arguments because all of these calls are prototyped as void(...).
2506 ///
2507 /// This function goes through and does final semantic checking for these
2508 /// builtins, as well as generating any warnings.
2509 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2510
2511 /// BuiltinNontemporalOverloaded - We have a call to
2512 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
2513 /// overloaded function based on the pointer type of its last argument.
2514 ///
2515 /// This function goes through and does final semantic checking for these
2516 /// builtins.
2517 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2518 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2520
2521 /// \param FPOnly restricts the arguments to floating-point types.
2522 bool BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly = false);
2523 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
2524
2525 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
2526
2527 enum BuiltinCountedByRefKind {
2528 AssignmentKind,
2529 InitializerKind,
2530 FunctionArgKind,
2531 ReturnArgKind,
2532 ArraySubscriptKind,
2533 BinaryExprKind,
2534 };
2535
2536 bool CheckInvalidBuiltinCountedByRef(const Expr *E,
2537 BuiltinCountedByRefKind K);
2538 bool BuiltinCountedByRef(CallExpr *TheCall);
2539
2540 // Matrix builtin handling.
2541 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
2542 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
2543 ExprResult CallResult);
2544 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
2545 ExprResult CallResult);
2546
2547 /// CheckFormatArguments - Check calls to printf and scanf (and similar
2548 /// functions) for correct use of format strings.
2549 /// Returns true if a format string has been fully checked.
2550 bool CheckFormatArguments(const FormatAttr *Format,
2551 ArrayRef<const Expr *> Args, bool IsCXXMember,
2552 VariadicCallType CallType, SourceLocation Loc,
2553 SourceRange Range,
2554 llvm::SmallBitVector &CheckedVarArgs);
2555 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
2556 FormatArgumentPassingKind FAPK, unsigned format_idx,
2557 unsigned firstDataArg, FormatStringType Type,
2558 VariadicCallType CallType, SourceLocation Loc,
2559 SourceRange range,
2560 llvm::SmallBitVector &CheckedVarArgs);
2561
2562 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
2563
2564 /// Warn when using the wrong abs() function.
2565 void CheckAbsoluteValueFunction(const CallExpr *Call,
2566 const FunctionDecl *FDecl);
2567
2568 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
2569
2570 /// Check for dangerous or invalid arguments to memset().
2571 ///
2572 /// This issues warnings on known problematic, dangerous or unspecified
2573 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
2574 /// function calls.
2575 ///
2576 /// \param Call The call expression to diagnose.
2577 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
2578 IdentifierInfo *FnName);
2579
2580 // Warn if the user has made the 'size' argument to strlcpy or strlcat
2581 // be the size of the source, instead of the destination.
2582 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2583
2584 // Warn on anti-patterns as the 'size' argument to strncat.
2585 // The correct size argument should look like following:
2586 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
2587 void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2588
2589 /// Alerts the user that they are attempting to free a non-malloc'd object.
2590 void CheckFreeArguments(const CallExpr *E);
2591
2592 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
2593 SourceLocation ReturnLoc, bool isObjCMethod = false,
2594 const AttrVec *Attrs = nullptr,
2595 const FunctionDecl *FD = nullptr);
2596
2597 /// Diagnoses "dangerous" implicit conversions within the given
2598 /// expression (which is a full expression). Implements -Wconversion
2599 /// and -Wsign-compare.
2600 ///
2601 /// \param CC the "context" location of the implicit conversion, i.e.
2602 /// the most location of the syntactic entity requiring the implicit
2603 /// conversion
2604 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
2605
2606 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
2607 /// Input argument E is a logical expression.
2608 void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
2609
2610 /// Diagnose when expression is an integer constant expression and its
2611 /// evaluation results in integer overflow
2612 void CheckForIntOverflow(const Expr *E);
2613 void CheckUnsequencedOperations(const Expr *E);
2614
2615 /// Perform semantic checks on a completed expression. This will either
2616 /// be a full-expression or a default argument expression.
2617 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
2618 bool IsConstexpr = false);
2619
2620 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
2621 Expr *Init);
2622
2623 /// A map from magic value to type information.
2624 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
2625 TypeTagForDatatypeMagicValues;
2626
2627 /// Peform checks on a call of a function with argument_with_type_tag
2628 /// or pointer_with_type_tag attributes.
2629 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
2630 const ArrayRef<const Expr *> ExprArgs,
2631 SourceLocation CallSiteLoc);
2632
2633 /// Check if we are taking the address of a packed field
2634 /// as this may be a problem if the pointer value is dereferenced.
2635 void CheckAddressOfPackedMember(Expr *rhs);
2636
2637 /// Helper class that collects misaligned member designations and
2638 /// their location info for delayed diagnostics.
2639 struct MisalignedMember {
2640 Expr *E;
2641 RecordDecl *RD;
2642 ValueDecl *MD;
2643 CharUnits Alignment;
2644
2645 MisalignedMember() : E(), RD(), MD() {}
2646 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
2647 CharUnits Alignment)
2648 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
2649 explicit MisalignedMember(Expr *E)
2650 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
2651
2652 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
2653 };
2654 /// Small set of gathered accesses to potentially misaligned members
2655 /// due to the packed attribute.
2656 SmallVector<MisalignedMember, 4> MisalignedMembers;
2657
2658 /// Adds an expression to the set of gathered misaligned members.
2659 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
2660 CharUnits Alignment);
2661 ///@}
2662
2663 //
2664 //
2665 // -------------------------------------------------------------------------
2666 //
2667 //
2668
2669 /// \name C++ Coroutines
2670 /// Implementations are in SemaCoroutine.cpp
2671 ///@{
2672
2673public:
2674 /// The C++ "std::coroutine_traits" template, which is defined in
2675 /// <coroutine_traits>
2677
2679 StringRef Keyword);
2683
2686 UnresolvedLookupExpr *Lookup);
2688 Expr *Awaiter, bool IsImplicit = false);
2690 UnresolvedLookupExpr *Lookup);
2693 bool IsImplicit = false);
2698
2699 // As a clang extension, enforces that a non-coroutine function must be marked
2700 // with [[clang::coro_wrapper]] if it returns a type marked with
2701 // [[clang::coro_return_type]].
2702 // Expects that FD is not a coroutine.
2704 /// Lookup 'coroutine_traits' in std namespace and std::experimental
2705 /// namespace. The namespace found is recorded in Namespace.
2707 SourceLocation FuncLoc);
2708 /// Check that the expression co_await promise.final_suspend() shall not be
2709 /// potentially-throwing.
2710 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
2711
2712 ///@}
2713
2714 //
2715 //
2716 // -------------------------------------------------------------------------
2717 //
2718 //
2719
2720 /// \name C++ Scope Specifiers
2721 /// Implementations are in SemaCXXScopeSpec.cpp
2722 ///@{
2723
2724public:
2725 // Marks SS invalid if it represents an incomplete type.
2727 // Complete an enum decl, maybe without a scope spec.
2729 CXXScopeSpec *SS = nullptr);
2730
2731 /// Compute the DeclContext that is associated with the given type.
2732 ///
2733 /// \param T the type for which we are attempting to find a DeclContext.
2734 ///
2735 /// \returns the declaration context represented by the type T,
2736 /// or NULL if the declaration context cannot be computed (e.g., because it is
2737 /// dependent and not the current instantiation).
2739
2740 /// Compute the DeclContext that is associated with the given
2741 /// scope specifier.
2742 ///
2743 /// \param SS the C++ scope specifier as it appears in the source
2744 ///
2745 /// \param EnteringContext when true, we will be entering the context of
2746 /// this scope specifier, so we can retrieve the declaration context of a
2747 /// class template or class template partial specialization even if it is
2748 /// not the current instantiation.
2749 ///
2750 /// \returns the declaration context represented by the scope specifier @p SS,
2751 /// or NULL if the declaration context cannot be computed (e.g., because it is
2752 /// dependent and not the current instantiation).
2754 bool EnteringContext = false);
2756
2757 /// If the given nested name specifier refers to the current
2758 /// instantiation, return the declaration that corresponds to that
2759 /// current instantiation (C++0x [temp.dep.type]p1).
2760 ///
2761 /// \param NNS a dependent nested name specifier.
2763
2764 /// The parser has parsed a global nested-name-specifier '::'.
2765 ///
2766 /// \param CCLoc The location of the '::'.
2767 ///
2768 /// \param SS The nested-name-specifier, which will be updated in-place
2769 /// to reflect the parsed nested-name-specifier.
2770 ///
2771 /// \returns true if an error occurred, false otherwise.
2773
2774 /// The parser has parsed a '__super' nested-name-specifier.
2775 ///
2776 /// \param SuperLoc The location of the '__super' keyword.
2777 ///
2778 /// \param ColonColonLoc The location of the '::'.
2779 ///
2780 /// \param SS The nested-name-specifier, which will be updated in-place
2781 /// to reflect the parsed nested-name-specifier.
2782 ///
2783 /// \returns true if an error occurred, false otherwise.
2785 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
2786
2787 /// Determines whether the given declaration is an valid acceptable
2788 /// result for name lookup of a nested-name-specifier.
2789 /// \param SD Declaration checked for nested-name-specifier.
2790 /// \param IsExtension If not null and the declaration is accepted as an
2791 /// extension, the pointed variable is assigned true.
2793 bool *CanCorrect = nullptr);
2794
2795 /// If the given nested-name-specifier begins with a bare identifier
2796 /// (e.g., Base::), perform name lookup for that identifier as a
2797 /// nested-name-specifier within the given scope, and return the result of
2798 /// that name lookup.
2800
2801 /// Keeps information about an identifier in a nested-name-spec.
2802 ///
2804 /// The type of the object, if we're parsing nested-name-specifier in
2805 /// a member access expression.
2807
2808 /// The identifier preceding the '::'.
2810
2811 /// The location of the identifier.
2813
2814 /// The location of the '::'.
2816
2817 /// Creates info object for the most typical case.
2819 SourceLocation ColonColonLoc,
2820 ParsedType ObjectType = ParsedType())
2821 : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
2822 CCLoc(ColonColonLoc) {}
2823
2825 SourceLocation ColonColonLoc, QualType ObjectType)
2826 : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
2827 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
2828 };
2829
2830 /// Build a new nested-name-specifier for "identifier::", as described
2831 /// by ActOnCXXNestedNameSpecifier.
2832 ///
2833 /// \param S Scope in which the nested-name-specifier occurs.
2834 /// \param IdInfo Parser information about an identifier in the
2835 /// nested-name-spec.
2836 /// \param EnteringContext If true, enter the context specified by the
2837 /// nested-name-specifier.
2838 /// \param SS Optional nested name specifier preceding the identifier.
2839 /// \param ScopeLookupResult Provides the result of name lookup within the
2840 /// scope of the nested-name-specifier that was computed at template
2841 /// definition time.
2842 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
2843 /// error recovery and what kind of recovery is performed.
2844 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
2845 /// are allowed. The bool value pointed by this parameter is set to
2846 /// 'true' if the identifier is treated as if it was followed by ':',
2847 /// not '::'.
2848 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2849 ///
2850 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
2851 /// that it contains an extra parameter \p ScopeLookupResult, which provides
2852 /// the result of name lookup within the scope of the nested-name-specifier
2853 /// that was computed at template definition time.
2854 ///
2855 /// If ErrorRecoveryLookup is true, then this call is used to improve error
2856 /// recovery. This means that it should not emit diagnostics, it should
2857 /// just return true on failure. It also means it should only return a valid
2858 /// scope if it *knows* that the result is correct. It should not return in a
2859 /// dependent context, for example. Nor will it extend \p SS with the scope
2860 /// specifier.
2861 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2862 bool EnteringContext, CXXScopeSpec &SS,
2863 NamedDecl *ScopeLookupResult,
2864 bool ErrorRecoveryLookup,
2865 bool *IsCorrectedToColon = nullptr,
2866 bool OnlyNamespace = false);
2867
2868 /// The parser has parsed a nested-name-specifier 'identifier::'.
2869 ///
2870 /// \param S The scope in which this nested-name-specifier occurs.
2871 ///
2872 /// \param IdInfo Parser information about an identifier in the
2873 /// nested-name-spec.
2874 ///
2875 /// \param EnteringContext Whether we're entering the context nominated by
2876 /// this nested-name-specifier.
2877 ///
2878 /// \param SS The nested-name-specifier, which is both an input
2879 /// parameter (the nested-name-specifier before this type) and an
2880 /// output parameter (containing the full nested-name-specifier,
2881 /// including this new type).
2882 ///
2883 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
2884 /// are allowed. The bool value pointed by this parameter is set to 'true'
2885 /// if the identifier is treated as if it was followed by ':', not '::'.
2886 ///
2887 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2888 ///
2889 /// \returns true if an error occurred, false otherwise.
2890 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2891 bool EnteringContext, CXXScopeSpec &SS,
2892 bool *IsCorrectedToColon = nullptr,
2893 bool OnlyNamespace = false);
2894
2895 /// The parser has parsed a nested-name-specifier
2896 /// 'template[opt] template-name < template-args >::'.
2897 ///
2898 /// \param S The scope in which this nested-name-specifier occurs.
2899 ///
2900 /// \param SS The nested-name-specifier, which is both an input
2901 /// parameter (the nested-name-specifier before this type) and an
2902 /// output parameter (containing the full nested-name-specifier,
2903 /// including this new type).
2904 ///
2905 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
2906 /// \param TemplateName the template name.
2907 /// \param TemplateNameLoc The location of the template name.
2908 /// \param LAngleLoc The location of the opening angle bracket ('<').
2909 /// \param TemplateArgs The template arguments.
2910 /// \param RAngleLoc The location of the closing angle bracket ('>').
2911 /// \param CCLoc The location of the '::'.
2912 ///
2913 /// \param EnteringContext Whether we're entering the context of the
2914 /// nested-name-specifier.
2915 ///
2916 ///
2917 /// \returns true if an error occurred, false otherwise.
2919 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
2920 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
2921 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
2922 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
2923
2925 SourceLocation ColonColonLoc);
2926
2928 const DeclSpec &DS,
2929 SourceLocation ColonColonLoc,
2930 QualType Type);
2931
2932 /// IsInvalidUnlessNestedName - This method is used for error recovery
2933 /// purposes to determine whether the specified identifier is only valid as
2934 /// a nested name specifier, for example a namespace name. It is
2935 /// conservatively correct to always return false from this method.
2936 ///
2937 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
2939 NestedNameSpecInfo &IdInfo,
2940 bool EnteringContext);
2941
2942 /// Given a C++ nested-name-specifier, produce an annotation value
2943 /// that the parser can use later to reconstruct the given
2944 /// nested-name-specifier.
2945 ///
2946 /// \param SS A nested-name-specifier.
2947 ///
2948 /// \returns A pointer containing all of the information in the
2949 /// nested-name-specifier \p SS.
2951
2952 /// Given an annotation pointer for a nested-name-specifier, restore
2953 /// the nested-name-specifier structure.
2954 ///
2955 /// \param Annotation The annotation pointer, produced by
2956 /// \c SaveNestedNameSpecifierAnnotation().
2957 ///
2958 /// \param AnnotationRange The source range corresponding to the annotation.
2959 ///
2960 /// \param SS The nested-name-specifier that will be updated with the contents
2961 /// of the annotation pointer.
2962 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
2963 SourceRange AnnotationRange,
2964 CXXScopeSpec &SS);
2965
2966 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2967
2968 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2969 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2970 /// After this method is called, according to [C++ 3.4.3p3], names should be
2971 /// looked up in the declarator-id's scope, until the declarator is parsed and
2972 /// ActOnCXXExitDeclaratorScope is called.
2973 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2975
2976 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2977 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2978 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2979 /// Used to indicate that names should revert to being looked up in the
2980 /// defining scope.
2982
2983 ///@}
2984
2985 //
2986 //
2987 // -------------------------------------------------------------------------
2988 //
2989 //
2990
2991 /// \name Declarations
2992 /// Implementations are in SemaDecl.cpp
2993 ///@{
2994
2995public:
2997
2998 /// The index of the first InventedParameterInfo that refers to the current
2999 /// context.
3001
3002 /// A RAII object to temporarily push a declaration context.
3004 private:
3005 Sema &S;
3006 DeclContext *SavedContext;
3007 ProcessingContextState SavedContextState;
3008 QualType SavedCXXThisTypeOverride;
3009 unsigned SavedFunctionScopesStart;
3010 unsigned SavedInventedParameterInfosStart;
3011
3012 public:
3013 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3014 : S(S), SavedContext(S.CurContext),
3015 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3016 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3017 SavedFunctionScopesStart(S.FunctionScopesStart),
3018 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3019 assert(ContextToPush && "pushing null context");
3020 S.CurContext = ContextToPush;
3021 if (NewThisContext)
3022 S.CXXThisTypeOverride = QualType();
3023 // Any saved FunctionScopes do not refer to this context.
3024 S.FunctionScopesStart = S.FunctionScopes.size();
3025 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3026 }
3027
3028 void pop() {
3029 if (!SavedContext)
3030 return;
3031 S.CurContext = SavedContext;
3032 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3033 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3034 S.FunctionScopesStart = SavedFunctionScopesStart;
3035 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3036 SavedContext = nullptr;
3037 }
3038
3039 ~ContextRAII() { pop(); }
3040 };
3041
3042 void DiagnoseInvalidJumps(Stmt *Body);
3043
3044 /// The function definitions which were renamed as part of typo-correction
3045 /// to match their respective declarations. We want to keep track of them
3046 /// to ensure that we don't emit a "redefinition" error if we encounter a
3047 /// correctly named definition after the renamed definition.
3049
3050 /// A cache of the flags available in enumerations with the flag_bits
3051 /// attribute.
3052 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3053
3054 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3055 /// declared. Rare. May alias another identifier, declared or undeclared.
3056 ///
3057 /// For aliases, the target identifier is used as a key for eventual
3058 /// processing when the target is declared. For the single-identifier form,
3059 /// the sole identifier is used as the key. Each entry is a `SetVector`
3060 /// (ordered by parse order) of aliases (identified by the alias name) in case
3061 /// of multiple aliases to the same undeclared identifier.
3062 llvm::MapVector<
3064 llvm::SetVector<
3066 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3068
3069 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3070 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3071 /// to define functions that occur in multiple standards to call the version
3072 /// in the currently selected standard.
3073 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
3074
3075 /// Set containing all typedefs that are likely unused.
3078
3082
3083 /// The set of file scoped decls seen so far that have not been used
3084 /// and must warn if not used. Only contains the first declaration.
3086
3090
3091 /// All the tentative definitions encountered in the TU.
3093
3094 /// All the external declarations encoutered and used in the TU.
3096
3097 /// Generally null except when we temporarily switch decl contexts,
3098 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3100
3101 /// Is the module scope we are in a C++ Header Unit?
3103 return ModuleScopes.empty() ? false
3104 : ModuleScopes.back().Module->isHeaderUnit();
3105 }
3106
3107 /// Get the module owning an entity.
3108 Module *getOwningModule(const Decl *Entity) {
3109 return Entity->getOwningModule();
3110 }
3111
3112 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3113
3114 /// If the identifier refers to a type name within this scope,
3115 /// return the declaration of that type.
3116 ///
3117 /// This routine performs ordinary name lookup of the identifier II
3118 /// within the given scope, with optional C++ scope specifier SS, to
3119 /// determine whether the name refers to a type. If so, returns an
3120 /// opaque pointer (actually a QualType) corresponding to that
3121 /// type. Otherwise, returns NULL.
3123 Scope *S, CXXScopeSpec *SS = nullptr,
3124 bool isClassName = false, bool HasTrailingDot = false,
3125 ParsedType ObjectType = nullptr,
3126 bool IsCtorOrDtorName = false,
3127 bool WantNontrivialTypeSourceInfo = false,
3128 bool IsClassTemplateDeductionContext = true,
3129 ImplicitTypenameContext AllowImplicitTypename =
3131 IdentifierInfo **CorrectedII = nullptr);
3132
3133 /// isTagName() - This method is called *for error recovery purposes only*
3134 /// to determine if the specified name is a valid tag name ("struct foo"). If
3135 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3136 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3137 /// diagnose cases in C where the user forgot to specify the tag.
3139
3140 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3141 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3142 /// then downgrade the missing typename error to a warning.
3143 /// This is needed for MSVC compatibility; Example:
3144 /// @code
3145 /// template<class T> class A {
3146 /// public:
3147 /// typedef int TYPE;
3148 /// };
3149 /// template<class T> class B : public A<T> {
3150 /// public:
3151 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3152 /// };
3153 /// @endcode
3154 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3156 Scope *S, CXXScopeSpec *SS,
3157 ParsedType &SuggestedType,
3158 bool IsTemplateName = false);
3159
3160 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3161 /// type name has failed in a dependent context. In these situations, we
3162 /// automatically form a DependentTypeName that will retry lookup in a related
3163 /// scope during instantiation.
3165 SourceLocation NameLoc,
3166 bool IsTemplateTypeArg);
3167
3168 /// Describes the result of the name lookup and resolution performed
3169 /// by \c ClassifyName().
3171 /// This name is not a type or template in this context, but might be
3172 /// something else.
3174 /// Classification failed; an error has been produced.
3176 /// The name has been typo-corrected to a keyword.
3178 /// The name was classified as a type.
3180 /// The name was classified as a specific non-type, non-template
3181 /// declaration. ActOnNameClassifiedAsNonType should be called to
3182 /// convert the declaration to an expression.
3184 /// The name was classified as an ADL-only function name.
3185 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
3186 /// result to an expression.
3188 /// The name denotes a member of a dependent type that could not be
3189 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
3190 /// convert the result to an expression.
3192 /// The name was classified as an overload set, and an expression
3193 /// representing that overload set has been formed.
3194 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
3195 /// expression referencing the overload set.
3197 /// The name was classified as a template whose specializations are types.
3199 /// The name was classified as a variable template name.
3201 /// The name was classified as a function template name.
3203 /// The name was classified as an ADL-only function template name.
3205 /// The name was classified as a concept name.
3207 };
3208
3211 union {
3216 };
3217
3219
3220 public:
3222
3223 NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
3224
3225 static NameClassification Error() { return NameClassification(NC_Error); }
3226
3228 return NameClassification(NC_Unknown);
3229 }
3230
3232 NameClassification Result(NC_OverloadSet);
3233 Result.Expr = E;
3234 return Result;
3235 }
3236
3238 NameClassification Result(NC_NonType);
3239 Result.NonTypeDecl = D;
3240 return Result;
3241 }
3242
3244 return NameClassification(NC_UndeclaredNonType);
3245 }
3246
3248 return NameClassification(NC_DependentNonType);
3249 }
3250
3252 NameClassification Result(NC_TypeTemplate);
3253 Result.Template = Name;
3254 return Result;
3255 }
3256
3258 NameClassification Result(NC_VarTemplate);
3259 Result.Template = Name;
3260 return Result;
3261 }
3262
3264 NameClassification Result(NC_FunctionTemplate);
3265 Result.Template = Name;
3266 return Result;
3267 }
3268
3270 NameClassification Result(NC_Concept);
3271 Result.Template = Name;
3272 return Result;
3273 }
3274
3276 NameClassification Result(NC_UndeclaredTemplate);
3277 Result.Template = Name;
3278 return Result;
3279 }
3280
3282
3284 assert(Kind == NC_OverloadSet);
3285 return Expr;
3286 }
3287
3289 assert(Kind == NC_Type);
3290 return Type;
3291 }
3292
3294 assert(Kind == NC_NonType);
3295 return NonTypeDecl;
3296 }
3297
3299 assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
3300 Kind == NC_VarTemplate || Kind == NC_Concept ||
3301 Kind == NC_UndeclaredTemplate);
3302 return Template;
3303 }
3304
3306 switch (Kind) {
3307 case NC_TypeTemplate:
3308 return TNK_Type_template;
3309 case NC_FunctionTemplate:
3310 return TNK_Function_template;
3311 case NC_VarTemplate:
3312 return TNK_Var_template;
3313 case NC_Concept:
3314 return TNK_Concept_template;
3315 case NC_UndeclaredTemplate:
3317 default:
3318 llvm_unreachable("unsupported name classification.");
3319 }
3320 }
3321 };
3322
3323 /// Perform name lookup on the given name, classifying it based on
3324 /// the results of name lookup and the following token.
3325 ///
3326 /// This routine is used by the parser to resolve identifiers and help direct
3327 /// parsing. When the identifier cannot be found, this routine will attempt
3328 /// to correct the typo and classify based on the resulting name.
3329 ///
3330 /// \param S The scope in which we're performing name lookup.
3331 ///
3332 /// \param SS The nested-name-specifier that precedes the name.
3333 ///
3334 /// \param Name The identifier. If typo correction finds an alternative name,
3335 /// this pointer parameter will be updated accordingly.
3336 ///
3337 /// \param NameLoc The location of the identifier.
3338 ///
3339 /// \param NextToken The token following the identifier. Used to help
3340 /// disambiguate the name.
3341 ///
3342 /// \param CCC The correction callback, if typo correction is desired.
3343 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3344 IdentifierInfo *&Name, SourceLocation NameLoc,
3345 const Token &NextToken,
3346 CorrectionCandidateCallback *CCC = nullptr);
3347
3348 /// Act on the result of classifying a name as an undeclared (ADL-only)
3349 /// non-type declaration.
3351 SourceLocation NameLoc);
3352 /// Act on the result of classifying a name as an undeclared member of a
3353 /// dependent base class.
3355 IdentifierInfo *Name,
3356 SourceLocation NameLoc,
3357 bool IsAddressOfOperand);
3358 /// Act on the result of classifying a name as a specific non-type
3359 /// declaration.
3362 SourceLocation NameLoc,
3363 const Token &NextToken);
3364 /// Act on the result of classifying a name as an overload set.
3366
3367 /// Describes the detailed kind of a template name. Used in diagnostics.
3374 Concept,
3376 };
3379
3380 /// Determine whether it's plausible that E was intended to be a
3381 /// template-name.
3383 if (!getLangOpts().CPlusPlus || E.isInvalid())
3384 return false;
3385 Dependent = false;
3386 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3387 return !DRE->hasExplicitTemplateArgs();
3388 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3389 return !ME->hasExplicitTemplateArgs();
3390 Dependent = true;
3391 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3392 return !DSDRE->hasExplicitTemplateArgs();
3393 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3394 return !DSME->hasExplicitTemplateArgs();
3395 // Any additional cases recognized here should also be handled by
3396 // diagnoseExprIntendedAsTemplateName.
3397 return false;
3398 }
3399
3401
3403
3405 MultiTemplateParamsArg TemplateParameterLists);
3406
3407 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3408 /// true if we were successful.
3411 unsigned FailedFoldDiagID);
3412
3413 /// Register the given locally-scoped extern "C" declaration so
3414 /// that it can be found later for redeclarations. We include any extern "C"
3415 /// declaration that is not visible in the translation unit here, not just
3416 /// function-scope declarations.
3418
3419 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3420 /// If T is the name of a class, then each of the following shall have a
3421 /// name different from T:
3422 /// - every static data member of class T;
3423 /// - every member function of class T
3424 /// - every member of class T that is itself a type;
3425 /// \returns true if the declaration name violates these rules.
3427
3428 /// Diagnose a declaration whose declarator-id has the given
3429 /// nested-name-specifier.
3430 ///
3431 /// \param SS The nested-name-specifier of the declarator-id.
3432 ///
3433 /// \param DC The declaration context to which the nested-name-specifier
3434 /// resolves.
3435 ///
3436 /// \param Name The name of the entity being declared.
3437 ///
3438 /// \param Loc The location of the name of the entity being declared.
3439 ///
3440 /// \param IsMemberSpecialization Whether we are declaring a member
3441 /// specialization.
3442 ///
3443 /// \param TemplateId The template-id, if any.
3444 ///
3445 /// \returns true if we cannot safely recover from this error, false
3446 /// otherwise.
3449 TemplateIdAnnotation *TemplateId,
3450 bool IsMemberSpecialization);
3451
3453
3454 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
3455
3456 /// Diagnose function specifiers on a declaration of an identifier that
3457 /// does not identify a function.
3458 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
3459
3460 /// Return the declaration shadowed by the given typedef \p D, or null
3461 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3463 const LookupResult &R);
3464
3465 /// Return the declaration shadowed by the given variable \p D, or null
3466 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3468
3469 /// Return the declaration shadowed by the given variable \p D, or null
3470 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3472 const LookupResult &R);
3473 /// Diagnose variable or built-in function shadowing. Implements
3474 /// -Wshadow.
3475 ///
3476 /// This method is called whenever a VarDecl is added to a "useful"
3477 /// scope.
3478 ///
3479 /// \param ShadowedDecl the declaration that is shadowed by the given variable
3480 /// \param R the lookup of the name
3481 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
3482 const LookupResult &R);
3483
3484 /// Check -Wshadow without the advantage of a previous lookup.
3485 void CheckShadow(Scope *S, VarDecl *D);
3486
3487 /// Warn if 'E', which is an expression that is about to be modified, refers
3488 /// to a shadowing declaration.
3490
3491 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
3492 /// when these variables are captured by the lambda.
3494
3495 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
3496 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
3497 TypedefNameDecl *NewTD);
3500 TypeSourceInfo *TInfo,
3502
3503 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
3504 /// declares a typedef-name, either using the 'typedef' type specifier or via
3505 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
3507 LookupResult &Previous, bool &Redeclaration);
3509 TypeSourceInfo *TInfo,
3511 MultiTemplateParamsArg TemplateParamLists,
3512 bool &AddToScope,
3514
3515 /// Perform semantic checking on a newly-created variable
3516 /// declaration.
3517 ///
3518 /// This routine performs all of the type-checking required for a
3519 /// variable declaration once it has been built. It is used both to
3520 /// check variables after they have been parsed and their declarators
3521 /// have been translated into a declaration, and to check variables
3522 /// that have been instantiated from a template.
3523 ///
3524 /// Sets NewVD->isInvalidDecl() if an error was encountered.
3525 ///
3526 /// Returns true if the variable declaration is a redeclaration.
3527 bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
3528 void CheckVariableDeclarationType(VarDecl *NewVD);
3529 void CheckCompleteVariableDeclaration(VarDecl *VD);
3530
3531 NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
3532 TypeSourceInfo *TInfo,
3533 LookupResult &Previous,
3534 MultiTemplateParamsArg TemplateParamLists,
3535 bool &AddToScope);
3536
3537 /// AddOverriddenMethods - See if a method overrides any in the base classes,
3538 /// and if so, check that it's a valid override and remember it.
3539 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
3540
3541 /// Perform semantic checking of a new function declaration.
3542 ///
3543 /// Performs semantic analysis of the new function declaration
3544 /// NewFD. This routine performs all semantic checking that does not
3545 /// require the actual declarator involved in the declaration, and is
3546 /// used both for the declaration of functions as they are parsed
3547 /// (called via ActOnDeclarator) and for the declaration of functions
3548 /// that have been instantiated via C++ template instantiation (called
3549 /// via InstantiateDecl).
3550 ///
3551 /// \param IsMemberSpecialization whether this new function declaration is
3552 /// a member specialization (that replaces any definition provided by the
3553 /// previous declaration).
3554 ///
3555 /// This sets NewFD->isInvalidDecl() to true if there was an error.
3556 ///
3557 /// \returns true if the function declaration is a redeclaration.
3558 bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
3559 LookupResult &Previous,
3560 bool IsMemberSpecialization, bool DeclIsDefn);
3561
3562 /// Checks if the new declaration declared in dependent context must be
3563 /// put in the same redeclaration chain as the specified declaration.
3564 ///
3565 /// \param D Declaration that is checked.
3566 /// \param PrevDecl Previous declaration found with proper lookup method for
3567 /// the same declaration name.
3568 /// \returns True if D must be added to the redeclaration chain which PrevDecl
3569 /// belongs to.
3570 bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
3571
3572 /// Determines if we can perform a correct type check for \p D as a
3573 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
3574 /// best-effort check.
3575 ///
3576 /// \param NewD The new declaration.
3577 /// \param OldD The old declaration.
3578 /// \param NewT The portion of the type of the new declaration to check.
3579 /// \param OldT The portion of the type of the old declaration to check.
3580 bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
3581 QualType NewT, QualType OldT);
3582 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
3583 void CheckMSVCRTEntryPoint(FunctionDecl *FD);
3584
3585 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
3586 /// containing class. Otherwise it will return implicit SectionAttr if the
3587 /// function is a definition and there is an active value on CodeSegStack
3588 /// (from the current #pragma code-seg value).
3589 ///
3590 /// \param FD Function being declared.
3591 /// \param IsDefinition Whether it is a definition or just a declaration.
3592 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
3593 /// nullptr if no attribute should be added.
3594 Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
3595 bool IsDefinition);
3596
3597 /// Common checks for a parameter-declaration that should apply to both
3598 /// function parameters and non-type template parameters.
3599 void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
3600
3601 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
3602 /// to introduce parameters into function prototype scope.
3603 Decl *ActOnParamDeclarator(Scope *S, Declarator &D,
3604 SourceLocation ExplicitThisLoc = {});
3605
3606 /// Synthesizes a variable for a parameter arising from a
3607 /// typedef.
3608 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
3609 QualType T);
3610 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
3611 SourceLocation NameLoc,
3612 const IdentifierInfo *Name, QualType T,
3613 TypeSourceInfo *TSInfo, StorageClass SC);
3614
3615 // Contexts where using non-trivial C union types can be disallowed. This is
3616 // passed to err_non_trivial_c_union_in_invalid_context.
3618 // Function parameter.
3620 // Function return.
3622 // Default-initialized object.
3624 // Variable with automatic storage duration.
3626 // Initializer expression that might copy from another object.
3628 // Assignment.
3630 // Compound literal.
3632 // Block capture.
3634 // lvalue-to-rvalue conversion of volatile type.
3636 };
3637
3638 /// Emit diagnostics if the initializer or any of its explicit or
3639 /// implicitly-generated subexpressions require copying or
3640 /// default-initializing a type that is or contains a C union type that is
3641 /// non-trivial to copy or default-initialize.
3643
3644 // These flags are passed to checkNonTrivialCUnion.
3649 };
3650
3651 /// Emit diagnostics if a non-trivial C union type or a struct that contains
3652 /// a non-trivial C union is used in an invalid context.
3654 NonTrivialCUnionContext UseContext,
3655 unsigned NonTrivialKind);
3656
3657 /// AddInitializerToDecl - Adds the initializer Init to the
3658 /// declaration dcl. If DirectInit is true, this is C++ direct
3659 /// initialization rather than copy initialization.
3660 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
3661 void ActOnUninitializedDecl(Decl *dcl);
3662
3663 /// ActOnInitializerError - Given that there was an error parsing an
3664 /// initializer for the given declaration, try to at least re-establish
3665 /// invariants such as whether a variable's type is either dependent or
3666 /// complete.
3667 void ActOnInitializerError(Decl *Dcl);
3668
3671 IdentifierInfo *Ident,
3672 ParsedAttributes &Attrs);
3673
3674 /// Check if VD needs to be dllexport/dllimport due to being in a
3675 /// dllexport/import function.
3678
3679 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
3680 /// any semantic actions necessary after any initializer has been attached.
3681 void FinalizeDeclaration(Decl *D);
3683 ArrayRef<Decl *> Group);
3684
3685 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
3686 /// group, performing any necessary semantic checking.
3688
3689 /// Should be called on all declarations that might have attached
3690 /// documentation comments.
3693
3694 enum class FnBodyKind {
3695 /// C++26 [dcl.fct.def.general]p1
3696 /// function-body:
3697 /// ctor-initializer[opt] compound-statement
3698 /// function-try-block
3699 Other,
3700 /// = default ;
3701 Default,
3702 /// deleted-function-body
3703 ///
3704 /// deleted-function-body:
3705 /// = delete ;
3706 /// = delete ( unevaluated-string ) ;
3707 Delete
3708 };
3709
3711 SourceLocation LocAfterDecls);
3713 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
3714 SkipBodyInfo *SkipBody = nullptr);
3716 MultiTemplateParamsArg TemplateParamLists,
3717 SkipBodyInfo *SkipBody = nullptr,
3718 FnBodyKind BodyKind = FnBodyKind::Other);
3720 SkipBodyInfo *SkipBody = nullptr,
3721 FnBodyKind BodyKind = FnBodyKind::Other);
3723
3724 /// Determine whether we can delay parsing the body of a function or
3725 /// function template until it is used, assuming we don't care about emitting
3726 /// code for that function.
3727 ///
3728 /// This will be \c false if we may need the body of the function in the
3729 /// middle of parsing an expression (where it's impractical to switch to
3730 /// parsing a different function), for instance, if it's constexpr in C++11
3731 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
3732 bool canDelayFunctionBody(const Declarator &D);
3733
3734 /// Determine whether we can skip parsing the body of a function
3735 /// definition, assuming we don't care about analyzing its body or emitting
3736 /// code for that function.
3737 ///
3738 /// This will be \c false only if we may need the body of the function in
3739 /// order to parse the rest of the program (for instance, if it is
3740 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
3741 bool canSkipFunctionBody(Decl *D);
3742
3743 /// Given the set of return statements within a function body,
3744 /// compute the variables that are subject to the named return value
3745 /// optimization.
3746 ///
3747 /// Each of the variables that is subject to the named return value
3748 /// optimization will be marked as NRVO variables in the AST, and any
3749 /// return statement that has a marked NRVO variable as its NRVO candidate can
3750 /// use the named return value optimization.
3751 ///
3752 /// This function applies a very simplistic algorithm for NRVO: if every
3753 /// return statement in the scope of a variable has the same NRVO candidate,
3754 /// that candidate is an NRVO variable.
3757 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
3760
3761 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
3762 /// attribute for which parsing is delayed.
3764
3765 /// Diagnose any unused parameters in the given sequence of
3766 /// ParmVarDecl pointers.
3768
3769 /// Diagnose whether the size of parameters or return value of a
3770 /// function or obj-c method definition is pass-by-value and larger than a
3771 /// specified threshold.
3772 void
3774 QualType ReturnTy, NamedDecl *D);
3775
3777 SourceLocation RParenLoc);
3778
3781
3783
3784 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3785 /// no declarator (e.g. "struct foo;") is parsed.
3787 const ParsedAttributesView &DeclAttrs,
3788 RecordDecl *&AnonRecord);
3789
3790 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3791 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
3792 /// parameters to cope with template friend declarations.
3794 const ParsedAttributesView &DeclAttrs,
3795 MultiTemplateParamsArg TemplateParams,
3796 bool IsExplicitInstantiation,
3797 RecordDecl *&AnonRecord,
3798 SourceLocation EllipsisLoc = {});
3799
3800 /// BuildAnonymousStructOrUnion - Handle the declaration of an
3801 /// anonymous structure or union. Anonymous unions are a C++ feature
3802 /// (C++ [class.union]) and a C11 feature; anonymous structures
3803 /// are a C11 feature and GNU C++ extension.
3804 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
3805 RecordDecl *Record,
3806 const PrintingPolicy &Policy);
3807
3808 /// Called once it is known whether
3809 /// a tag declaration is an anonymous union or struct.
3811
3812 /// Emit diagnostic warnings for placeholder members.
3813 /// We can only do that after the class is fully constructed,
3814 /// as anonymous union/structs can insert placeholders
3815 /// in their parent scope (which might be a Record).
3817
3818 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
3819 /// Microsoft C anonymous structure.
3820 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
3821 /// Example:
3822 ///
3823 /// struct A { int a; };
3824 /// struct B { struct A; int b; };
3825 ///
3826 /// void foo() {
3827 /// B var;
3828 /// var.a = 3;
3829 /// }
3830 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
3831 RecordDecl *Record);
3832
3833 /// Common ways to introduce type names without a tag for use in diagnostics.
3834 /// Keep in sync with err_tag_reference_non_tag.
3845 };
3846
3847 /// Given a non-tag type declaration, returns an enum useful for indicating
3848 /// what kind of non-tag type this is.
3850
3851 /// Determine whether a tag with a given kind is acceptable
3852 /// as a redeclaration of the given tag declaration.
3853 ///
3854 /// \returns true if the new tag kind is acceptable, false otherwise.
3856 bool isDefinition, SourceLocation NewTagLoc,
3857 const IdentifierInfo *Name);
3858
3860 // Not parsing a type within __builtin_offsetof.
3862 // Parsing a type within __builtin_offsetof.
3864 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
3865 // To improve our diagnostic message.
3867 };
3868
3869 /// This is invoked when we see 'struct foo' or 'struct {'. In the
3870 /// former case, Name will be non-null. In the later case, Name will be null.
3871 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
3872 /// a reference/declaration/definition of a tag.
3873 ///
3874 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
3875 /// trailing-type-specifier) other than one in an alias-declaration.
3876 ///
3877 /// \param SkipBody If non-null, will be set to indicate if the caller should
3878 /// skip the definition of this tag and treat it as if it were a declaration.
3879 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
3880 SourceLocation KWLoc, CXXScopeSpec &SS,
3881 IdentifierInfo *Name, SourceLocation NameLoc,
3883 SourceLocation ModulePrivateLoc,
3884 MultiTemplateParamsArg TemplateParameterLists,
3885 bool &OwnedDecl, bool &IsDependent,
3886 SourceLocation ScopedEnumKWLoc,
3887 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
3888 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
3889 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
3890
3891 /// ActOnField - Each field of a C struct/union is passed into this in order
3892 /// to create a FieldDecl object for it.
3893 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
3894 Declarator &D, Expr *BitfieldWidth);
3895
3896 /// HandleField - Analyze a field of a C struct or a C++ data member.
3897 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
3898 Declarator &D, Expr *BitfieldWidth,
3899 InClassInitStyle InitStyle, AccessSpecifier AS);
3900
3901 /// Build a new FieldDecl and check its well-formedness.
3902 ///
3903 /// This routine builds a new FieldDecl given the fields name, type,
3904 /// record, etc. \p PrevDecl should refer to any previous declaration
3905 /// with the same name and in the same scope as the field to be
3906 /// created.
3907 ///
3908 /// \returns a new FieldDecl.
3909 ///
3910 /// \todo The Declarator argument is a hack. It will be removed once
3913 SourceLocation Loc, bool Mutable,
3914 Expr *BitfieldWidth, InClassInitStyle InitStyle,
3916 NamedDecl *PrevDecl, Declarator *D = nullptr);
3917
3919
3920 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
3921 /// class and class extensions. For every class \@interface and class
3922 /// extension \@interface, if the last ivar is a bitfield of any type,
3923 /// then add an implicit `char :0` ivar to the end of that interface.
3924 void ActOnLastBitfield(SourceLocation DeclStart,
3925 SmallVectorImpl<Decl *> &AllIvarDecls);
3926
3927 // This is used for both record definitions and ObjC interface declarations.
3928 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
3929 ArrayRef<Decl *> Fields, SourceLocation LBrac,
3930 SourceLocation RBrac, const ParsedAttributesView &AttrList);
3931
3932 /// ActOnTagStartDefinition - Invoked when we have entered the
3933 /// scope of a tag's definition (e.g., for an enumeration, class,
3934 /// struct, or union).
3936
3937 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
3938 /// Differently from C++, actually parse the body and reject / error out
3939 /// in case of a structural mismatch.
3940 bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody);
3941
3943
3944 /// Invoked when we enter a tag definition that we're skipping.
3946
3947 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
3948 /// C++ record definition's base-specifiers clause and are starting its
3949 /// member declarations.
3951 SourceLocation FinalLoc,
3952 bool IsFinalSpelledSealed,
3953 bool IsAbstract,
3954 SourceLocation LBraceLoc);
3955
3956 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
3957 /// the definition of a tag (enumeration, class, struct, or union).
3959 SourceRange BraceRange);
3960
3962
3963 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
3964 /// error parsing the definition of a tag.
3966
3968 EnumConstantDecl *LastEnumConst,
3970 Expr *val);
3971
3972 /// Check that this is a valid underlying type for an enum declaration.
3974
3975 /// Check whether this is a valid redeclaration of a previous enumeration.
3976 /// \return true if the redeclaration was invalid.
3977 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
3978 QualType EnumUnderlyingTy, bool IsFixed,
3979 const EnumDecl *Prev);
3980
3981 /// Determine whether the body of an anonymous enumeration should be skipped.
3982 /// \param II The name of the first enumerator.
3984 SourceLocation IILoc);
3985
3986 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
3988 const ParsedAttributesView &Attrs,
3989 SourceLocation EqualLoc, Expr *Val);
3990 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
3991 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
3992 const ParsedAttributesView &Attr);
3993
3994 /// Set the current declaration context until it gets popped.
3995 void PushDeclContext(Scope *S, DeclContext *DC);
3996 void PopDeclContext();
3997
3998 /// EnterDeclaratorContext - Used when we must lookup names in the context
3999 /// of a declarator's nested name specifier.
4002
4003 /// Enter a template parameter scope, after it's been associated with a
4004 /// particular DeclContext. Causes lookup within the scope to chain through
4005 /// enclosing contexts in the correct order.
4007
4008 /// Push the parameters of D, which must be a function, into scope.
4011
4012 /// Add this decl to the scope shadowed decl chains.
4013 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4014
4015 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4016 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4017 /// true if 'D' belongs to the given declaration context.
4018 ///
4019 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4020 /// enclosing namespace set of the context, rather than contained
4021 /// directly within it.
4022 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4023 bool AllowInlineNamespace = false) const;
4024
4025 /// Finds the scope corresponding to the given decl context, if it
4026 /// happens to be an enclosing scope. Otherwise return NULL.
4028
4029 /// Subroutines of ActOnDeclarator().
4031 TypeSourceInfo *TInfo);
4032 bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New);
4033
4034 /// Describes the kind of merge to perform for availability
4035 /// attributes (including "deprecated", "unavailable", and "availability").
4037 /// Don't merge availability attributes at all.
4039 /// Merge availability attributes for a redeclaration, which requires
4040 /// an exact match.
4042 /// Merge availability attributes for an override, which requires
4043 /// an exact match or a weakening of constraints.
4045 /// Merge availability attributes for an implementation of
4046 /// a protocol requirement.
4048 /// Merge availability attributes for an implementation of
4049 /// an optional protocol requirement.
4052
4053 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4054 void mergeDeclAttributes(NamedDecl *New, Decl *Old,
4056
4057 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4058 /// same name and scope as a previous declaration 'Old'. Figure out
4059 /// how to resolve this situation, merging decls or emitting
4060 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4062 LookupResult &OldDecls);
4063
4064 /// MergeFunctionDecl - We just parsed a function 'New' from
4065 /// declarator D which has the same name and scope as a previous
4066 /// declaration 'Old'. Figure out how to resolve this situation,
4067 /// merging decls or emitting diagnostics as appropriate.
4068 ///
4069 /// In C++, New and Old must be declarations that are not
4070 /// overloaded. Use IsOverload to determine whether New and Old are
4071 /// overloaded, and to select the Old declaration that New should be
4072 /// merged with.
4073 ///
4074 /// Returns true if there was an error, false otherwise.
4075 bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
4076 bool MergeTypeWithOld, bool NewDeclIsDefn);
4077
4078 /// Completes the merge of two function declarations that are
4079 /// known to be compatible.
4080 ///
4081 /// This routine handles the merging of attributes and other
4082 /// properties of function declarations from the old declaration to
4083 /// the new declaration, once we know that New is in fact a
4084 /// redeclaration of Old.
4085 ///
4086 /// \returns false
4088 Scope *S, bool MergeTypeWithOld);
4090
4091 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4092 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4093 /// situation, merging decls or emitting diagnostics as appropriate.
4094 ///
4095 /// Tentative definition rules (C99 6.9.2p2) are checked by
4096 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4097 /// definitions here, since the initializer hasn't been attached.
4099
4100 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4101 /// scope as a previous declaration 'Old'. Figure out how to merge their
4102 /// types, emitting diagnostics as appropriate.
4103 ///
4104 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4105 /// back to here in AddInitializerToDecl. We can't check them before the
4106 /// initializer is attached.
4107 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4108
4109 /// We've just determined that \p Old and \p New both appear to be definitions
4110 /// of the same variable. Either diagnose or fix the problem.
4111 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4112 void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
4113
4114 /// Filters out lookup results that don't fall within the given scope
4115 /// as determined by isDeclInScope.
4117 bool ConsiderLinkage, bool AllowInlineNamespace);
4118
4119 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4120 /// have compatible owning modules.
4122
4123 /// [module.interface]p6:
4124 /// A redeclaration of an entity X is implicitly exported if X was introduced
4125 /// by an exported declaration; otherwise it shall not be exported.
4127
4128 /// A wrapper function for checking the semantic restrictions of
4129 /// a redeclaration within a module.
4131
4132 /// Check the redefinition in C++20 Modules.
4133 ///
4134 /// [basic.def.odr]p14:
4135 /// For any definable item D with definitions in multiple translation units,
4136 /// - if D is a non-inline non-templated function or variable, or
4137 /// - if the definitions in different translation units do not satisfy the
4138 /// following requirements,
4139 /// the program is ill-formed; a diagnostic is required only if the
4140 /// definable item is attached to a named module and a prior definition is
4141 /// reachable at the point where a later definition occurs.
4142 /// - Each such definition shall not be attached to a named module
4143 /// ([module.unit]).
4144 /// - Each such definition shall consist of the same sequence of tokens, ...
4145 /// ...
4146 ///
4147 /// Return true if the redefinition is not allowed. Return false otherwise.
4148 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4149
4151
4152 /// If it's a file scoped decl that must warn if not used, keep track
4153 /// of it.
4155
4156 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4158
4161 DiagReceiverTy DiagReceiver);
4162 void DiagnoseUnusedDecl(const NamedDecl *ND);
4163
4164 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4165 /// unless they are marked attr(unused).
4166 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4167
4168 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4169 /// variable.
4170 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4171
4172 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4173 /// from S, where a non-field would be declared. This routine copes
4174 /// with the difference between C and C++ scoping rules in structs and
4175 /// unions. For example, the following code is well-formed in C but
4176 /// ill-formed in C++:
4177 /// @code
4178 /// struct S6 {
4179 /// enum { BAR } e;
4180 /// };
4181 ///
4182 /// void test_S6() {
4183 /// struct S6 a;
4184 /// a.e = BAR;
4185 /// }
4186 /// @endcode
4187 /// For the declaration of BAR, this routine will return a different
4188 /// scope. The scope S will be the scope of the unnamed enumeration
4189 /// within S6. In C++, this routine will return the scope associated
4190 /// with S6, because the enumeration's scope is a transparent
4191 /// context but structures can contain non-field names. In C, this
4192 /// routine will return the translation unit scope, since the
4193 /// enumeration's scope is a transparent context and structures cannot
4194 /// contain non-field names.
4196
4199
4200 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4201 /// file scope. lazily create a decl for it. ForRedeclaration is true
4202 /// if we're creating this built-in in anticipation of redeclaring the
4203 /// built-in.
4205 bool ForRedeclaration, SourceLocation Loc);
4206
4207 /// Get the outermost AttributedType node that sets a calling convention.
4208 /// Valid types should not have multiple attributes with different CCs.
4210
4211 /// GetNameForDeclarator - Determine the full declaration name for the
4212 /// given Declarator.
4214
4215 /// Retrieves the declaration name from a parsed unqualified-id.
4217
4218 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4219 /// we are currently parsing the initializer.
4221
4222 /// Look for a locally scoped extern "C" declaration by the given name.
4224
4226
4227 /// Adjust the \c DeclContext for a function or variable that might be a
4228 /// function-local external declaration.
4230
4232
4233 /// Checks if the variant/multiversion functions are compatible.
4235 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4236 const PartialDiagnostic &NoProtoDiagID,
4237 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4238 const PartialDiagnosticAt &NoSupportDiagIDAt,
4239 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4240 bool ConstexprSupported, bool CLinkageMayDiffer);
4241
4242 /// type checking declaration initializers (C99 6.7.8)
4244 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4245
4249 Expr *Init);
4250
4252 Expr *Init);
4253
4255
4256 // Heuristically tells if the function is `get_return_object` member of a
4257 // coroutine promise_type by matching the function name.
4258 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4259 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4260
4261 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4262 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4264 Scope *S);
4265
4266 /// If this function is a C++ replaceable global allocation function
4267 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4268 /// adds any function attributes that we know a priori based on the standard.
4269 ///
4270 /// We need to check for duplicate attributes both here and where user-written
4271 /// attributes are applied to declarations.
4273 FunctionDecl *FD);
4274
4275 /// Adds any function attributes that we know a priori based on
4276 /// the declaration of this function.
4277 ///
4278 /// These attributes can apply both to implicitly-declared builtins
4279 /// (like __builtin___printf_chk) or to library-declared functions
4280 /// like NSLog or printf.
4281 ///
4282 /// We need to check for duplicate attributes both here and where user-written
4283 /// attributes are applied to declarations.
4285
4286 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4287 /// the correct width, and that the field type is valid.
4288 /// Returns false on success.
4290 const IdentifierInfo *FieldName, QualType FieldTy,
4291 bool IsMsStruct, Expr *BitWidth);
4292
4293 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4294 /// enum. If AllowMask is true, then we also allow the complement of a valid
4295 /// value, to be used as a mask.
4296 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4297 bool AllowMask) const;
4298
4299 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4300 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4301 SourceLocation WeakNameLoc);
4302
4303 /// ActOnPragmaRedefineExtname - Called on well formed
4304 /// \#pragma redefine_extname oldname newname.
4306 IdentifierInfo *AliasName,
4307 SourceLocation PragmaLoc,
4308 SourceLocation WeakNameLoc,
4309 SourceLocation AliasNameLoc);
4310
4311 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4312 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4313 SourceLocation PragmaLoc,
4314 SourceLocation WeakNameLoc,
4315 SourceLocation AliasNameLoc);
4316
4317 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4319 Emitted,
4320 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4321 OMPDiscarded, // Discarded due to OpenMP hostness
4322 TemplateDiscarded, // Discarded due to uninstantiated templates
4323 Unknown,
4324 };
4325 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4326 bool Final = false);
4327
4328 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4330
4331private:
4332 /// Function or variable declarations to be checked for whether the deferred
4333 /// diagnostics should be emitted.
4334 llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
4335
4336 /// Map of current shadowing declarations to shadowed declarations. Warn if
4337 /// it looks like the user is trying to modify the shadowing declaration.
4338 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4339
4340 // We need this to handle
4341 //
4342 // typedef struct {
4343 // void *foo() { return 0; }
4344 // } A;
4345 //
4346 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4347 // for example. If 'A', foo will have external linkage. If we have '*A',
4348 // foo will have no linkage. Since we can't know until we get to the end
4349 // of the typedef, this function finds out if D might have non-external
4350 // linkage. Callers should verify at the end of the TU if it D has external
4351 // linkage or not.
4352 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4353
4354 ///@}
4355
4356 //
4357 //
4358 // -------------------------------------------------------------------------
4359 //
4360 //
4361
4362 /// \name Declaration Attribute Handling
4363 /// Implementations are in SemaDeclAttr.cpp
4364 ///@{
4365
4366public:
4367 /// Describes the kind of priority given to an availability attribute.
4368 ///
4369 /// The sum of priorities deteremines the final priority of the attribute.
4370 /// The final priority determines how the attribute will be merged.
4371 /// An attribute with a lower priority will always remove higher priority
4372 /// attributes for the specified platform when it is being applied. An
4373 /// attribute with a higher priority will not be applied if the declaration
4374 /// already has an availability attribute with a lower priority for the
4375 /// specified platform. The final prirority values are not expected to match
4376 /// the values in this enumeration, but instead should be treated as a plain
4377 /// integer value. This enumeration just names the priority weights that are
4378 /// used to calculate that final vaue.
4380 /// The availability attribute was specified explicitly next to the
4381 /// declaration.
4383
4384 /// The availability attribute was applied using '#pragma clang attribute'.
4386
4387 /// The availability attribute for a specific platform was inferred from
4388 /// an availability attribute for another platform.
4391
4392 /// Describes the reason a calling convention specification was ignored, used
4393 /// for diagnostics.
4395 ForThisTarget = 0,
4399 };
4400
4401 /// A helper function to provide Attribute Location for the Attr types
4402 /// AND the ParsedAttr.
4403 template <typename AttrInfo>
4404 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4405 getAttrLoc(const AttrInfo &AL) {
4406 return AL.getLocation();
4407 }
4409
4410 /// If Expr is a valid integer constant, get the value of the integer
4411 /// expression and return success or failure. May output an error.
4412 ///
4413 /// Negative argument is implicitly converted to unsigned, unless
4414 /// \p StrictlyUnsigned is true.
4415 template <typename AttrInfo>
4416 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4417 unsigned Idx = UINT_MAX,
4418 bool StrictlyUnsigned = false) {
4419 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4420 if (Expr->isTypeDependent() ||
4422 if (Idx != UINT_MAX)
4423 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4424 << &AI << Idx << AANT_ArgumentIntegerConstant
4425 << Expr->getSourceRange();
4426 else
4427 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4429 return false;
4430 }
4431
4432 if (!I->isIntN(32)) {
4433 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4434 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4435 return false;
4436 }
4437
4438 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
4439 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
4440 << &AI << /*non-negative*/ 1;
4441 return false;
4442 }
4443
4444 Val = (uint32_t)I->getZExtValue();
4445 return true;
4446 }
4447
4448 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
4449 /// \#pragma weak during processing of other Decls.
4450 /// I couldn't figure out a clean way to generate these in-line, so
4451 /// we store them here and handle separately -- which is a hack.
4452 /// It would be best to refactor this.
4454
4455 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
4457
4461
4462 /// ExtVectorDecls - This is a list all the extended vector types. This allows
4463 /// us to associate a raw vector type with one of the ext_vector type names.
4464 /// This is only necessary for issuing pretty diagnostics.
4466
4467 /// Check if the argument \p E is a ASCII string literal. If not emit an error
4468 /// and return false, otherwise set \p Str to the value of the string literal
4469 /// and return true.
4471 const Expr *E, StringRef &Str,
4472 SourceLocation *ArgLocation = nullptr);
4473
4474 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
4475 /// If not emit an error and return false. If the argument is an identifier it
4476 /// will emit an error with a fixit hint and treat it as if it was a string
4477 /// literal.
4478 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
4479 StringRef &Str,
4480 SourceLocation *ArgLocation = nullptr);
4481
4482 /// Determine if type T is a valid subject for a nonnull and similar
4483 /// attributes. Dependent types are considered valid so they can be checked
4484 /// during instantiation time. By default, we look through references (the
4485 /// behavior used by nonnull), but if the second parameter is true, then we
4486 /// treat a reference type as valid.
4487 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
4488
4489 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
4490 /// declaration.
4492 Expr *OE);
4493
4494 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
4495 /// declaration.
4497 Expr *ParamExpr);
4498
4499 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
4500 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
4501
4502 AvailabilityAttr *mergeAvailabilityAttr(
4503 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform,
4504 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
4505 VersionTuple Obsoleted, bool IsUnavailable, StringRef Message,
4506 bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK,
4507 int Priority, IdentifierInfo *IIEnvironment);
4508
4509 TypeVisibilityAttr *
4511 TypeVisibilityAttr::VisibilityType Vis);
4512 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
4513 VisibilityAttr::VisibilityType Vis);
4514 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
4515 StringRef Name);
4516
4517 /// Used to implement to perform semantic checking on
4518 /// attribute((section("foo"))) specifiers.
4519 ///
4520 /// In this case, "foo" is passed in to be checked. If the section
4521 /// specifier is invalid, return an Error that indicates the problem.
4522 ///
4523 /// This is a simple quality of implementation feature to catch errors
4524 /// and give good diagnostics in cases when the assembler or code generator
4525 /// would otherwise reject the section specifier.
4526 llvm::Error isValidSectionSpecifier(StringRef Str);
4527 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
4528 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
4529 StringRef Name);
4530
4531 // Check for things we'd like to warn about. Multiversioning issues are
4532 // handled later in the process, once we know how many exist.
4533 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
4534
4535 /// Check Target Version attrs
4536 bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
4538 SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
4539 Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
4540 SmallVectorImpl<SmallString<64>> &StringsBuffer);
4541
4542 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
4543 StringRef NewUserDiagnostic);
4544 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
4545 IdentifierInfo *Format, int FormatIdx,
4546 int FirstArg);
4547
4548 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4549 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4550 bool IsPackExpansion);
4552 bool IsPackExpansion);
4553
4554 /// AddAlignValueAttr - Adds an align_value attribute to a particular
4555 /// declaration.
4556 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
4557
4558 /// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
4559 Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
4562
4564 bool BestCase,
4565 MSInheritanceModel SemanticSpelling);
4566
4568
4569 /// AddModeAttr - Adds a mode attribute to a particular declaration.
4570 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
4571 bool InInstantiation = false);
4572 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
4573 const AttributeCommonInfo &CI,
4574 const IdentifierInfo *Ident);
4575 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
4576 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
4577 const AttributeCommonInfo &CI);
4578 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
4579 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
4580 const InternalLinkageAttr &AL);
4581
4582 /// Check validaty of calling convention attribute \p attr. If \p FD
4583 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
4584 /// target. Otherwise, it is specified by \p CFT.
4586 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
4588
4589 /// Checks a regparm attribute, returning true if it is ill-formed and
4590 /// otherwise setting numParams to the appropriate value.
4591 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
4592
4593 /// Create an CUDALaunchBoundsAttr attribute.
4594 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
4595 Expr *MaxThreads,
4596 Expr *MinBlocks,
4597 Expr *MaxBlocks);
4598
4599 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
4600 /// declaration.
4602 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
4603
4604 enum class RetainOwnershipKind { NS, CF, OS };
4605
4606 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
4607 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
4608
4609 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
4610
4611 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
4612 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
4613 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
4614 const AttributeCommonInfo &CI,
4615 bool BestCase,
4616 MSInheritanceModel Model);
4617
4618 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
4619 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
4620 const EnforceTCBLeafAttr &AL);
4621
4622 /// Helper for delayed processing TransparentUnion or
4623 /// BPFPreserveAccessIndexAttr attribute.
4625 const ParsedAttributesView &AttrList);
4626
4627 // Options for ProcessDeclAttributeList().
4630 : IncludeCXX11Attributes(true), IgnoreTypeAttributes(false) {}
4631
4633 ProcessDeclAttributeOptions Result = *this;
4634 Result.IncludeCXX11Attributes = Val;
4635 return Result;
4636 }
4637
4639 ProcessDeclAttributeOptions Result = *this;
4640 Result.IgnoreTypeAttributes = Val;
4641 return Result;
4642 }
4643
4644 // Should C++11 attributes be processed?
4646
4647 // Should any type attributes encountered be ignored?
4648 // If this option is false, a diagnostic will be emitted for any type
4649 // attributes of a kind that does not "slide" from the declaration to
4650 // the decl-specifier-seq.
4652 };
4653
4654 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
4655 /// attribute list to the specified decl, ignoring any type attributes.
4657 const ParsedAttributesView &AttrList,
4658 const ProcessDeclAttributeOptions &Options =
4660
4661 /// Annotation attributes are the only attributes allowed after an access
4662 /// specifier.
4664 const ParsedAttributesView &AttrList);
4665
4666 /// checkUnusedDeclAttributes - Given a declarator which is not being
4667 /// used to build a declaration, complain about any decl attributes
4668 /// which might be lying around on it.
4670
4671 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
4672 /// \#pragma weak needs a non-definition decl and source may not have one.
4675
4676 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
4677 /// applied to it, possibly with an alias.
4678 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
4679
4680 void ProcessPragmaWeak(Scope *S, Decl *D);
4681 // Decl attributes - this routine is the top level dispatcher.
4682 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
4683
4685
4686 /// Given a set of delayed diagnostics, re-emit them as if they had
4687 /// been delayed in the current context instead of in the given pool.
4688 /// Essentially, this just moves them to the current pool.
4690
4691 /// Check if IdxExpr is a valid parameter index for a function or
4692 /// instance method D. May output an error.
4693 ///
4694 /// \returns true if IdxExpr is a valid index.
4695 template <typename AttrInfo>
4696 bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI,
4697 unsigned AttrArgNum,
4698 const Expr *IdxExpr, ParamIdx &Idx,
4699 bool CanIndexImplicitThis = false) {
4701
4702 // In C++ the implicit 'this' function parameter also counts.
4703 // Parameters are counted from one.
4704 bool HP = hasFunctionProto(D);
4705 bool HasImplicitThisParam = isInstanceMethod(D);
4706 bool IV = HP && isFunctionOrMethodVariadic(D);
4707 unsigned NumParams =
4708 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
4709
4710 std::optional<llvm::APSInt> IdxInt;
4711 if (IdxExpr->isTypeDependent() ||
4712 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
4713 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4714 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
4715 << IdxExpr->getSourceRange();
4716 return false;
4717 }
4718
4719 unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX);
4720 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
4721 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
4722 << &AI << AttrArgNum << IdxExpr->getSourceRange();
4723 return false;
4724 }
4725 if (HasImplicitThisParam && !CanIndexImplicitThis) {
4726 if (IdxSource == 1) {
4727 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
4728 << &AI << IdxExpr->getSourceRange();
4729 return false;
4730 }
4731 }
4732
4733 Idx = ParamIdx(IdxSource, D);
4734 return true;
4735 }
4736
4737 ///@}
4738
4739 //
4740 //
4741 // -------------------------------------------------------------------------
4742 //
4743 //
4744
4745 /// \name C++ Declarations
4746 /// Implementations are in SemaDeclCXX.cpp
4747 ///@{
4748
4749public:
4751
4752 /// Called before parsing a function declarator belonging to a function
4753 /// declaration.
4755 unsigned TemplateParameterDepth);
4756
4757 /// Called after parsing a function declarator belonging to a function
4758 /// declaration.
4760
4761 // Act on C++ namespaces
4763 SourceLocation NamespaceLoc,
4764 SourceLocation IdentLoc, IdentifierInfo *Ident,
4765 SourceLocation LBrace,
4766 const ParsedAttributesView &AttrList,
4767 UsingDirectiveDecl *&UsingDecl, bool IsNested);
4768
4769 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
4770 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
4771 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
4772
4774
4775 /// Retrieve the special "std" namespace, which may require us to
4776 /// implicitly define the namespace.
4778
4780 EnumDecl *getStdAlignValT() const;
4781
4783 const IdentifierInfo *MemberOrBase);
4784
4786 /// The '<=>' operator was used in an expression and a builtin operator
4787 /// was selected.
4789 /// A defaulted 'operator<=>' needed the comparison category. This
4790 /// typically only applies to 'std::strong_ordering', due to the implicit
4791 /// fallback return value.
4793 };
4794
4795 /// Lookup the specified comparison category types in the standard
4796 /// library, an check the VarDecls possibly returned by the operator<=>
4797 /// builtins for that type.
4798 ///
4799 /// \return The type of the comparison category type corresponding to the
4800 /// specified Kind, or a null type if an error occurs
4804
4805 /// Tests whether Ty is an instance of std::initializer_list and, if
4806 /// it is and Element is not NULL, assigns the element type to Element.
4807 bool isStdInitializerList(QualType Ty, QualType *Element);
4808
4809 /// Looks for the std::initializer_list template and instantiates it
4810 /// with Element, or emits an error if it's not found.
4811 ///
4812 /// \returns The instantiated template, or null on error.
4814
4815 /// Determine whether Ctor is an initializer-list constructor, as
4816 /// defined in [dcl.init.list]p2.
4817 bool isInitListConstructor(const FunctionDecl *Ctor);
4818
4819 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
4820 SourceLocation NamespcLoc, CXXScopeSpec &SS,
4821 SourceLocation IdentLoc,
4822 IdentifierInfo *NamespcName,
4823 const ParsedAttributesView &AttrList);
4824
4826
4827 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
4828 SourceLocation AliasLoc, IdentifierInfo *Alias,
4829 CXXScopeSpec &SS, SourceLocation IdentLoc,
4830 IdentifierInfo *Ident);
4831
4832 /// Remove decls we can't actually see from a lookup being used to declare
4833 /// shadow using decls.
4834 ///
4835 /// \param S - The scope of the potential shadow decl
4836 /// \param Previous - The lookup of a potential shadow decl's name.
4837 void FilterUsingLookup(Scope *S, LookupResult &lookup);
4838
4839 /// Hides a using shadow declaration. This is required by the current
4840 /// using-decl implementation when a resolvable using declaration in a
4841 /// class is followed by a declaration which would hide or override
4842 /// one or more of the using decl's targets; for example:
4843 ///
4844 /// struct Base { void foo(int); };
4845 /// struct Derived : Base {
4846 /// using Base::foo;
4847 /// void foo(int);
4848 /// };
4849 ///
4850 /// The governing language is C++03 [namespace.udecl]p12:
4851 ///
4852 /// When a using-declaration brings names from a base class into a
4853 /// derived class scope, member functions in the derived class
4854 /// override and/or hide member functions with the same name and
4855 /// parameter types in a base class (rather than conflicting).
4856 ///
4857 /// There are two ways to implement this:
4858 /// (1) optimistically create shadow decls when they're not hidden
4859 /// by existing declarations, or
4860 /// (2) don't create any shadow decls (or at least don't make them
4861 /// visible) until we've fully parsed/instantiated the class.
4862 /// The problem with (1) is that we might have to retroactively remove
4863 /// a shadow decl, which requires several O(n) operations because the
4864 /// decl structures are (very reasonably) not designed for removal.
4865 /// (2) avoids this but is very fiddly and phase-dependent.
4866 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
4867
4868 /// Determines whether to create a using shadow decl for a particular
4869 /// decl, given the set of decls existing prior to this using lookup.
4871 const LookupResult &PreviousDecls,
4872 UsingShadowDecl *&PrevShadow);
4873
4874 /// Builds a shadow declaration corresponding to a 'using' declaration.
4877 UsingShadowDecl *PrevDecl);
4878
4879 /// Checks that the given using declaration is not an invalid
4880 /// redeclaration. Note that this is checking only for the using decl
4881 /// itself, not for any ill-formedness among the UsingShadowDecls.
4883 bool HasTypenameKeyword,
4884 const CXXScopeSpec &SS,
4885 SourceLocation NameLoc,
4886 const LookupResult &Previous);
4887
4888 /// Checks that the given nested-name qualifier used in a using decl
4889 /// in the current context is appropriately related to the current
4890 /// scope. If an error is found, diagnoses it and returns true.
4891 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
4892 /// the result of that lookup. UD is likewise nullptr, except when we have an
4893 /// already-populated UsingDecl whose shadow decls contain the same
4894 /// information (i.e. we're instantiating a UsingDecl with non-dependent
4895 /// scope).
4896 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
4897 const CXXScopeSpec &SS,
4898 const DeclarationNameInfo &NameInfo,
4899 SourceLocation NameLoc,
4900 const LookupResult *R = nullptr,
4901 const UsingDecl *UD = nullptr);
4902
4903 /// Builds a using declaration.
4904 ///
4905 /// \param IsInstantiation - Whether this call arises from an
4906 /// instantiation of an unresolved using declaration. We treat
4907 /// the lookup differently for these declarations.
4909 SourceLocation UsingLoc,
4910 bool HasTypenameKeyword,
4911 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4912 DeclarationNameInfo NameInfo,
4913 SourceLocation EllipsisLoc,
4914 const ParsedAttributesView &AttrList,
4915 bool IsInstantiation, bool IsUsingIfExists);
4917 SourceLocation UsingLoc,
4918 SourceLocation EnumLoc,
4919 SourceLocation NameLoc,
4921 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
4922 ArrayRef<NamedDecl *> Expansions);
4923
4924 /// Additional checks for a using declaration referring to a constructor name.
4926
4927 /// Given a derived-class using shadow declaration for a constructor and the
4928 /// correspnding base class constructor, find or create the implicit
4929 /// synthesized derived class constructor to use for this initialization.
4932 ConstructorUsingShadowDecl *DerivedShadow);
4933
4935 SourceLocation UsingLoc,
4936 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4937 UnqualifiedId &Name, SourceLocation EllipsisLoc,
4938 const ParsedAttributesView &AttrList);
4940 SourceLocation UsingLoc,
4941 SourceLocation EnumLoc, SourceRange TyLoc,
4942 const IdentifierInfo &II, ParsedType Ty,
4943 CXXScopeSpec *SS = nullptr);
4945 MultiTemplateParamsArg TemplateParams,
4946 SourceLocation UsingLoc, UnqualifiedId &Name,
4947 const ParsedAttributesView &AttrList,
4948 TypeResult Type, Decl *DeclFromDeclSpec);
4949
4950 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
4951 /// including handling of its default argument expressions.
4952 ///
4953 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
4955 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4956 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
4957 bool HadMultipleCandidates, bool IsListInitialization,
4958 bool IsStdInitListInitialization, bool RequiresZeroInit,
4959 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4960
4961 /// Build a CXXConstructExpr whose constructor has already been resolved if
4962 /// it denotes an inherited constructor.
4964 SourceLocation ConstructLoc, QualType DeclInitType,
4965 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4966 bool HadMultipleCandidates, bool IsListInitialization,
4967 bool IsStdInitListInitialization, bool RequiresZeroInit,
4968 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4969
4970 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4971 // the constructor can be elidable?
4973 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4974 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4975 bool HadMultipleCandidates, bool IsListInitialization,
4976 bool IsStdInitListInitialization, bool RequiresZeroInit,
4977 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4978
4980 SourceLocation InitLoc);
4981
4982 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4983 /// constructed variable.
4984 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
4985
4986 /// Helper class that collects exception specifications for
4987 /// implicitly-declared special member functions.
4989 // Pointer to allow copying
4990 Sema *Self;
4991 // We order exception specifications thus:
4992 // noexcept is the most restrictive, but is only used in C++11.
4993 // throw() comes next.
4994 // Then a throw(collected exceptions)
4995 // Finally no specification, which is expressed as noexcept(false).
4996 // throw(...) is used instead if any called function uses it.
4997 ExceptionSpecificationType ComputedEST;
4998 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
4999 SmallVector<QualType, 4> Exceptions;
5000
5001 void ClearExceptions() {
5002 ExceptionsSeen.clear();
5003 Exceptions.clear();
5004 }
5005
5006 public:
5008 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5009 if (!Self.getLangOpts().CPlusPlus11)
5010 ComputedEST = EST_DynamicNone;
5011 }
5012
5013 /// Get the computed exception specification type.
5015 assert(!isComputedNoexcept(ComputedEST) &&
5016 "noexcept(expr) should not be a possible result");
5017 return ComputedEST;
5018 }
5019
5020 /// The number of exceptions in the exception specification.
5021 unsigned size() const { return Exceptions.size(); }
5022
5023 /// The set of exceptions in the exception specification.
5024 const QualType *data() const { return Exceptions.data(); }
5025
5026 /// Integrate another called method into the collected data.
5027 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5028
5029 /// Integrate an invoked expression into the collected data.
5030 void CalledExpr(Expr *E) { CalledStmt(E); }
5031
5032 /// Integrate an invoked statement into the collected data.
5033 void CalledStmt(Stmt *S);
5034
5035 /// Overwrite an EPI's exception specification with this
5036 /// computed exception specification.
5039 ESI.Type = getExceptionSpecType();
5040 if (ESI.Type == EST_Dynamic) {
5041 ESI.Exceptions = Exceptions;
5042 } else if (ESI.Type == EST_None) {
5043 /// C++11 [except.spec]p14:
5044 /// The exception-specification is noexcept(false) if the set of
5045 /// potential exceptions of the special member function contains "any"
5046 ESI.Type = EST_NoexceptFalse;
5047 ESI.NoexceptExpr =
5048 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5049 }
5050 return ESI;
5051 }
5052 };
5053
5054 /// Evaluate the implicit exception specification for a defaulted
5055 /// special member function.
5057
5058 /// Check the given exception-specification and update the
5059 /// exception specification information with the results.
5060 void checkExceptionSpecification(bool IsTopLevel,
5062 ArrayRef<ParsedType> DynamicExceptions,
5063 ArrayRef<SourceRange> DynamicExceptionRanges,
5064 Expr *NoexceptExpr,
5065 SmallVectorImpl<QualType> &Exceptions,
5067
5068 /// Add an exception-specification to the given member or friend function
5069 /// (or function template). The exception-specification was parsed
5070 /// after the function itself was declared.
5072 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5073 ArrayRef<ParsedType> DynamicExceptions,
5074 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5075
5076 class InheritedConstructorInfo;
5077
5078 /// Determine if a special member function should have a deleted
5079 /// definition when it is defaulted.
5081 InheritedConstructorInfo *ICI = nullptr,
5082 bool Diagnose = false);
5083
5084 /// Produce notes explaining why a defaulted function was defined as deleted.
5086
5087 /// Declare the implicit default constructor for the given class.
5088 ///
5089 /// \param ClassDecl The class declaration into which the implicit
5090 /// default constructor will be added.
5091 ///
5092 /// \returns The implicitly-declared default constructor.
5095
5096 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5097 /// defining this constructor as the default constructor.
5099 CXXConstructorDecl *Constructor);
5100
5101 /// Declare the implicit destructor for the given class.
5102 ///
5103 /// \param ClassDecl The class declaration into which the implicit
5104 /// destructor will be added.
5105 ///
5106 /// \returns The implicitly-declared destructor.
5108
5109 /// DefineImplicitDestructor - Checks for feasibility of
5110 /// defining this destructor as the default destructor.
5111 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5113
5114 /// Build an exception spec for destructors that don't have one.
5115 ///
5116 /// C++11 says that user-defined destructors with no exception spec get one
5117 /// that looks as if the destructor was implicitly declared.
5119
5120 /// Define the specified inheriting constructor.
5122 CXXConstructorDecl *Constructor);
5123
5124 /// Declare the implicit copy constructor for the given class.
5125 ///
5126 /// \param ClassDecl The class declaration into which the implicit
5127 /// copy constructor will be added.
5128 ///
5129 /// \returns The implicitly-declared copy constructor.
5131
5132 /// DefineImplicitCopyConstructor - Checks for feasibility of
5133 /// defining this constructor as the copy constructor.
5134 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5135 CXXConstructorDecl *Constructor);
5136
5137 /// Declare the implicit move constructor for the given class.
5138 ///
5139 /// \param ClassDecl The Class declaration into which the implicit
5140 /// move constructor will be added.
5141 ///
5142 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5143 /// declared.
5145
5146 /// DefineImplicitMoveConstructor - Checks for feasibility of
5147 /// defining this constructor as the move constructor.
5148 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5149 CXXConstructorDecl *Constructor);
5150
5151 /// Declare the implicit copy assignment operator for the given class.
5152 ///
5153 /// \param ClassDecl The class declaration into which the implicit
5154 /// copy assignment operator will be added.
5155 ///
5156 /// \returns The implicitly-declared copy assignment operator.
5158
5159 /// Defines an implicitly-declared copy assignment operator.
5160 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5161 CXXMethodDecl *MethodDecl);
5162
5163 /// Declare the implicit move assignment operator for the given class.
5164 ///
5165 /// \param ClassDecl The Class declaration into which the implicit
5166 /// move assignment operator will be added.
5167 ///
5168 /// \returns The implicitly-declared move assignment operator, or NULL if it
5169 /// wasn't declared.
5171
5172 /// Defines an implicitly-declared move assignment operator.
5173 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5174 CXXMethodDecl *MethodDecl);
5175
5176 /// Check a completed declaration of an implicit special member.
5178
5179 /// Determine whether the given function is an implicitly-deleted
5180 /// special member function.
5182
5183 /// Check whether 'this' shows up in the type of a static member
5184 /// function after the (naturally empty) cv-qualifier-seq would be.
5185 ///
5186 /// \returns true if an error occurred.
5188
5189 /// Whether this' shows up in the exception specification of a static
5190 /// member function.
5192
5193 /// Check whether 'this' shows up in the attributes of the given
5194 /// static member function.
5195 ///
5196 /// \returns true if an error occurred.
5198
5200 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5201
5203
5204 /// Given a constructor and the set of arguments provided for the
5205 /// constructor, convert the arguments and add any required default arguments
5206 /// to form a proper call to this constructor.
5207 ///
5208 /// \returns true if an error occurred, false otherwise.
5210 QualType DeclInitType, MultiExprArg ArgsPtr,
5212 SmallVectorImpl<Expr *> &ConvertedArgs,
5213 bool AllowExplicit = false,
5214 bool IsListInitialization = false);
5215
5216 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5217 /// initializer for the declaration 'Dcl'.
5218 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5219 /// static data member of class X, names should be looked up in the scope of
5220 /// class X.
5222
5223 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5224 /// initializer for the declaration 'Dcl'.
5225 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5226
5227 /// Define the "body" of the conversion from a lambda object to a
5228 /// function pointer.
5229 ///
5230 /// This routine doesn't actually define a sensible body; rather, it fills
5231 /// in the initialization expression needed to copy the lambda object into
5232 /// the block, and IR generation actually generates the real body of the
5233 /// block pointer conversion.
5234 void
5236 CXXConversionDecl *Conv);
5237
5238 /// Define the "body" of the conversion from a lambda object to a
5239 /// block pointer.
5240 ///
5241 /// This routine doesn't actually define a sensible body; rather, it fills
5242 /// in the initialization expression needed to copy the lambda object into
5243 /// the block, and IR generation actually generates the real body of the
5244 /// block pointer conversion.
5246 CXXConversionDecl *Conv);
5247
5248 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5249 /// linkage specification, including the language and (if present)
5250 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5251 /// language string literal. LBraceLoc, if valid, provides the location of
5252 /// the '{' brace. Otherwise, this linkage specification does not
5253 /// have any braces.
5255 Expr *LangStr, SourceLocation LBraceLoc);
5256
5257 /// ActOnFinishLinkageSpecification - Complete the definition of
5258 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5259 /// valid, it's the position of the closing '}' brace in a linkage
5260 /// specification that uses braces.
5262 SourceLocation RBraceLoc);
5263
5264 //===--------------------------------------------------------------------===//
5265 // C++ Classes
5266 //
5267
5268 /// Get the class that is directly named by the current context. This is the
5269 /// class for which an unqualified-id in this scope could name a constructor
5270 /// or destructor.
5271 ///
5272 /// If the scope specifier denotes a class, this will be that class.
5273 /// If the scope specifier is empty, this will be the class whose
5274 /// member-specification we are currently within. Otherwise, there
5275 /// is no such class.
5277
5278 /// isCurrentClassName - Determine whether the identifier II is the
5279 /// name of the class type currently being defined. In the case of
5280 /// nested classes, this will only return true if II is the name of
5281 /// the innermost class.
5282 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5283 const CXXScopeSpec *SS = nullptr);
5284
5285 /// Determine whether the identifier II is a typo for the name of
5286 /// the class type currently being defined. If so, update it to the identifier
5287 /// that should have been used.
5289
5290 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5292 SourceLocation ColonLoc,
5293 const ParsedAttributesView &Attrs);
5294
5295 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5296 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5297 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5298 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5299 /// present (but parsing it has been deferred).
5300 NamedDecl *
5302 MultiTemplateParamsArg TemplateParameterLists,
5303 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5304 InClassInitStyle InitStyle);
5305
5306 /// Enter a new C++ default initializer scope. After calling this, the
5307 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5308 /// parsing or instantiating the initializer failed.
5310
5311 /// This is invoked after parsing an in-class initializer for a
5312 /// non-static C++ class member, and after instantiating an in-class
5313 /// initializer in a class template. Such actions are deferred until the class
5314 /// is complete.
5316 SourceLocation EqualLoc,
5318
5319 /// Handle a C++ member initializer using parentheses syntax.
5321 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5322 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5323 const DeclSpec &DS, SourceLocation IdLoc,
5324 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5325 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5326
5327 /// Handle a C++ member initializer using braced-init-list syntax.
5328 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5329 CXXScopeSpec &SS,
5330 IdentifierInfo *MemberOrBase,
5331 ParsedType TemplateTypeTy,
5332 const DeclSpec &DS, SourceLocation IdLoc,
5333 Expr *InitList, SourceLocation EllipsisLoc);
5334
5335 /// Handle a C++ member initializer.
5336 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5337 CXXScopeSpec &SS,
5338 IdentifierInfo *MemberOrBase,
5339 ParsedType TemplateTypeTy,
5340 const DeclSpec &DS, SourceLocation IdLoc,
5341 Expr *Init, SourceLocation EllipsisLoc);
5342
5344 SourceLocation IdLoc);
5345
5347 TypeSourceInfo *BaseTInfo, Expr *Init,
5348 CXXRecordDecl *ClassDecl,
5349 SourceLocation EllipsisLoc);
5350
5352 CXXRecordDecl *ClassDecl);
5353
5356
5357 bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
5358 ArrayRef<CXXCtorInitializer *> Initializers = {});
5359
5360 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5361 /// mark all the non-trivial destructors of its members and bases as
5362 /// referenced.
5363 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
5364 CXXRecordDecl *Record);
5365
5366 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5367 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5368 /// class. In the Microsoft C++ ABI, this is done any time a class's
5369 /// destructor is referenced.
5371 SourceLocation Location, CXXRecordDecl *ClassDecl,
5372 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases = nullptr);
5373
5374 /// Do semantic checks to allow the complete destructor variant to be emitted
5375 /// when the destructor is defined in another translation unit. In the Itanium
5376 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
5377 /// can be emitted in separate TUs. To emit the complete variant, run a subset
5378 /// of the checks performed when emitting a regular destructor.
5379 void CheckCompleteDestructorVariant(SourceLocation CurrentLocation,
5380 CXXDestructorDecl *Dtor);
5381
5382 /// The list of classes whose vtables have been used within
5383 /// this translation unit, and the source locations at which the
5384 /// first use occurred.
5385 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
5386
5387 /// The list of vtables that are required but have not yet been
5388 /// materialized.
5390
5391 /// The set of classes whose vtables have been used within
5392 /// this translation unit, and a bit that will be true if the vtable is
5393 /// required to be emitted (otherwise, it should be emitted only if needed
5394 /// by code generation).
5395 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5396
5397 /// Load any externally-stored vtable uses.
5399
5400 /// Note that the vtable for the given class was used at the
5401 /// given location.
5403 bool DefinitionRequired = false);
5404
5405 /// Mark the exception specifications of all virtual member functions
5406 /// in the given class as needed.
5408 const CXXRecordDecl *RD);
5409
5410 /// MarkVirtualMembersReferenced - Will mark all members of the given
5411 /// CXXRecordDecl referenced.
5413 bool ConstexprOnly = false);
5414
5415 /// Define all of the vtables that have been used in this
5416 /// translation unit and reference any virtual members used by those
5417 /// vtables.
5418 ///
5419 /// \returns true if any work was done, false otherwise.
5420 bool DefineUsedVTables();
5421
5422 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
5423 /// special functions, such as the default constructor, copy
5424 /// constructor, or destructor, to the given C++ class (C++
5425 /// [special]p1). This routine can only be executed just before the
5426 /// definition of the class is complete.
5428
5429 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5430 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
5432 bool AnyErrors);
5433
5434 /// Check class-level dllimport/dllexport attribute. The caller must
5435 /// ensure that referenceDLLExportedClassMethods is called some point later
5436 /// when all outer classes of Class are complete.
5439
5441
5442 /// Perform propagation of DLL attributes from a derived class to a
5443 /// templated base class for MS compatibility.
5445 CXXRecordDecl *Class, Attr *ClassAttr,
5446 ClassTemplateSpecializationDecl *BaseTemplateSpec,
5447 SourceLocation BaseLoc);
5448
5449 /// Perform semantic checks on a class definition that has been
5450 /// completing, introducing implicitly-declared members, checking for
5451 /// abstract types, etc.
5452 ///
5453 /// \param S The scope in which the class was parsed. Null if we didn't just
5454 /// parse a class definition.
5455 /// \param Record The completed class.
5457
5458 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
5459 /// conditions that are needed for the attribute to have an effect.
5461
5462 /// Check that VTable Pointer authentication is only being set on the first
5463 /// first instantiation of the vtable
5465
5467 Decl *TagDecl, SourceLocation LBrac,
5468 SourceLocation RBrac,
5469 const ParsedAttributesView &AttrList);
5470
5471 /// Perform any semantic analysis which needs to be delayed until all
5472 /// pending class member declarations have been parsed.
5475
5476 /// This is used to implement the constant expression evaluation part of the
5477 /// attribute enable_if extension. There is nothing in standard C++ which
5478 /// would require reentering parameters.
5480 unsigned ActOnReenterTemplateScope(Decl *Template,
5481 llvm::function_ref<Scope *()> EnterScope);
5483
5484 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
5485 /// parsing a top-level (non-nested) C++ class, and we are now
5486 /// parsing those parts of the given Method declaration that could
5487 /// not be parsed earlier (C++ [class.mem]p2), such as default
5488 /// arguments. This action should enter the scope of the given
5489 /// Method declaration as if we had just parsed the qualified method
5490 /// name. However, it should not bring the parameters into scope;
5491 /// that will be performed by ActOnDelayedCXXMethodParameter.
5493 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
5495
5496 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
5497 /// processing the delayed method declaration for Method. The method
5498 /// declaration is now considered finished. There may be a separate
5499 /// ActOnStartOfFunctionDef action later (not necessarily
5500 /// immediately!) for this method, if it was also defined inside the
5501 /// class body.
5504
5505 bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result,
5506 ASTContext &Ctx,
5507 bool ErrorOnInvalidMessage);
5509 Expr *AssertExpr, Expr *AssertMessageExpr,
5510 SourceLocation RParenLoc);
5512 Expr *AssertExpr, Expr *AssertMessageExpr,
5513 SourceLocation RParenLoc, bool Failed);
5514
5515 /// Try to print more useful information about a failed static_assert
5516 /// with expression \E
5517 void DiagnoseStaticAssertDetails(const Expr *E);
5518
5519 /// Handle a friend type declaration. This works in tandem with
5520 /// ActOnTag.
5521 ///
5522 /// Notes on friend class templates:
5523 ///
5524 /// We generally treat friend class declarations as if they were
5525 /// declaring a class. So, for example, the elaborated type specifier
5526 /// in a friend declaration is required to obey the restrictions of a
5527 /// class-head (i.e. no typedefs in the scope chain), template
5528 /// parameters are required to match up with simple template-ids, &c.
5529 /// However, unlike when declaring a template specialization, it's
5530 /// okay to refer to a template specialization without an empty
5531 /// template parameter declaration, e.g.
5532 /// friend class A<T>::B<unsigned>;
5533 /// We permit this as a special case; if there are any template
5534 /// parameters present at all, require proper matching, i.e.
5535 /// template <> template <class T> friend class A<int>::B;
5536 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
5537 MultiTemplateParamsArg TemplateParams,
5538 SourceLocation EllipsisLoc);
5540 MultiTemplateParamsArg TemplateParams);
5541
5542 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
5543 /// the well-formedness of the constructor declarator @p D with type @p
5544 /// R. If there are any errors in the declarator, this routine will
5545 /// emit diagnostics and set the invalid bit to true. In any case, the type
5546 /// will be updated to reflect a well-formed type for the constructor and
5547 /// returned.
5549 StorageClass &SC);
5550
5551 /// CheckConstructor - Checks a fully-formed constructor for
5552 /// well-formedness, issuing any diagnostics required. Returns true if
5553 /// the constructor declarator is invalid.
5554 void CheckConstructor(CXXConstructorDecl *Constructor);
5555
5556 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
5557 /// the well-formednes of the destructor declarator @p D with type @p
5558 /// R. If there are any errors in the declarator, this routine will
5559 /// emit diagnostics and set the declarator to invalid. Even if this happens,
5560 /// will be updated to reflect a well-formed type for the destructor and
5561 /// returned.
5563 StorageClass &SC);
5564
5565 /// CheckDestructor - Checks a fully-formed destructor definition for
5566 /// well-formedness, issuing any diagnostics required. Returns true
5567 /// on error.
5569
5570 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
5571 /// well-formednes of the conversion function declarator @p D with
5572 /// type @p R. If there are any errors in the declarator, this routine
5573 /// will emit diagnostics and return true. Otherwise, it will return
5574 /// false. Either way, the type @p R will be updated to reflect a
5575 /// well-formed type for the conversion operator.
5577
5578 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
5579 /// the declaration of the given C++ conversion function. This routine
5580 /// is responsible for recording the conversion function in the C++
5581 /// class, if possible.
5583
5584 /// Check the validity of a declarator that we parsed for a deduction-guide.
5585 /// These aren't actually declarators in the grammar, so we need to check that
5586 /// the user didn't specify any pieces that are not part of the
5587 /// deduction-guide grammar. Return true on invalid deduction-guide.
5589 StorageClass &SC);
5590
5592
5595 SourceLocation DefaultLoc);
5597
5598 /// Kinds of defaulted comparison operator functions.
5599 enum class DefaultedComparisonKind : unsigned char {
5600 /// This is not a defaultable comparison operator.
5601 None,
5602 /// This is an operator== that should be implemented as a series of
5603 /// subobject comparisons.
5604 Equal,
5605 /// This is an operator<=> that should be implemented as a series of
5606 /// subobject comparisons.
5607 ThreeWay,
5608 /// This is an operator!= that should be implemented as a rewrite in terms
5609 /// of a == comparison.
5610 NotEqual,
5611 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
5612 /// terms of a <=> comparison.
5613 Relational,
5614 };
5615
5619 FunctionDecl *Spaceship);
5622
5624 QualType R, bool IsLambda,
5625 DeclContext *DC = nullptr);
5627 DeclarationName Name, QualType R);
5629
5630 //===--------------------------------------------------------------------===//
5631 // C++ Derived Classes
5632 //
5633
5634 /// Check the validity of a C++ base class specifier.
5635 ///
5636 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
5637 /// and returns NULL otherwise.
5639 SourceRange SpecifierRange, bool Virtual,
5640 AccessSpecifier Access,
5641 TypeSourceInfo *TInfo,
5642 SourceLocation EllipsisLoc);
5643
5644 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
5645 /// one entry in the base class list of a class specifier, for
5646 /// example:
5647 /// class foo : public bar, virtual private baz {
5648 /// 'public bar' and 'virtual private baz' are each base-specifiers.
5649 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
5650 const ParsedAttributesView &Attrs, bool Virtual,
5651 AccessSpecifier Access, ParsedType basetype,
5652 SourceLocation BaseLoc,
5653 SourceLocation EllipsisLoc);
5654
5655 /// Performs the actual work of attaching the given base class
5656 /// specifiers to a C++ class.
5659
5660 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
5661 /// class, after checking whether there are any duplicate base
5662 /// classes.
5663 void ActOnBaseSpecifiers(Decl *ClassDecl,
5665
5666 /// Determine whether the type \p Derived is a C++ class that is
5667 /// derived from the type \p Base.
5669
5670 /// Determine whether the type \p Derived is a C++ class that is
5671 /// derived from the type \p Base.
5673 CXXBasePaths &Paths);
5674
5675 // FIXME: I don't like this name.
5676 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
5677
5680 CXXCastPath *BasePath = nullptr,
5681 bool IgnoreAccess = false);
5682
5683 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
5684 /// conversion (where Derived and Base are class types) is
5685 /// well-formed, meaning that the conversion is unambiguous (and
5686 /// that all of the base classes are accessible). Returns true
5687 /// and emits a diagnostic if the code is ill-formed, returns false
5688 /// otherwise. Loc is the location where this routine should point to
5689 /// if there is an error, and Range is the source range to highlight
5690 /// if there is an error.
5691 ///
5692 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
5693 /// diagnostic for the respective type of error will be suppressed, but the
5694 /// check for ill-formed code will still be performed.
5696 unsigned InaccessibleBaseID,
5697 unsigned AmbiguousBaseConvID,
5699 DeclarationName Name, CXXCastPath *BasePath,
5700 bool IgnoreAccess = false);
5701
5702 /// Builds a string representing ambiguous paths from a
5703 /// specific derived class to different subobjects of the same base
5704 /// class.
5705 ///
5706 /// This function builds a string that can be used in error messages
5707 /// to show the different paths that one can take through the
5708 /// inheritance hierarchy to go from the derived class to different
5709 /// subobjects of a base class. The result looks something like this:
5710 /// @code
5711 /// struct D -> struct B -> struct A
5712 /// struct D -> struct C -> struct A
5713 /// @endcode
5714 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
5715
5717 const CXXMethodDecl *Old);
5718
5719 /// CheckOverridingFunctionReturnType - Checks whether the return types are
5720 /// covariant, according to C++ [class.virtual]p5.
5722 const CXXMethodDecl *Old);
5723
5724 // Check that the overriding method has no explicit object parameter.
5726 const CXXMethodDecl *Old);
5727
5728 /// Mark the given method pure.
5729 ///
5730 /// \param Method the method to be marked pure.
5731 ///
5732 /// \param InitRange the source range that covers the "0" initializer.
5733 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
5734
5735 /// CheckOverrideControl - Check C++11 override control semantics.
5737
5738 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
5739 /// not used in the declaration of an overriding method.
5741
5742 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
5743 /// function overrides a virtual member function marked 'final', according to
5744 /// C++11 [class.virtual]p4.
5746 const CXXMethodDecl *Old);
5747
5758
5759 struct TypeDiagnoser;
5760
5763 TypeDiagnoser &Diagnoser);
5764 template <typename... Ts>
5766 const Ts &...Args) {
5767 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
5768 return RequireNonAbstractType(Loc, T, Diagnoser);
5769 }
5770
5771 void DiagnoseAbstractType(const CXXRecordDecl *RD);
5772
5773 //===--------------------------------------------------------------------===//
5774 // C++ Overloaded Operators [C++ 13.5]
5775 //
5776
5777 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
5778 /// of this overloaded operator is well-formed. If so, returns false;
5779 /// otherwise, emits appropriate diagnostics and returns true.
5781
5782 /// CheckLiteralOperatorDeclaration - Check whether the declaration
5783 /// of this literal operator function is well-formed. If so, returns
5784 /// false; otherwise, emits appropriate diagnostics and returns true.
5786
5787 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
5788 /// found in an explicit(bool) specifier.
5790
5791 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
5792 /// Returns true if the explicit specifier is now resolved.
5794
5795 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
5796 /// C++ if/switch/while/for statement.
5797 /// e.g: "if (int x = f()) {...}"
5799
5800 // Emitting members of dllexported classes is delayed until the class
5801 // (including field initializers) is fully parsed.
5804
5805 /// Merge the exception specifications of two variable declarations.
5806 ///
5807 /// This is called when there's a redeclaration of a VarDecl. The function
5808 /// checks if the redeclaration might have an exception specification and
5809 /// validates compatibility and merges the specs if necessary.
5811
5812 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
5813 /// function, once we already know that they have the same
5814 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
5815 /// error, false otherwise.
5817
5818 /// Helpers for dealing with blocks and functions.
5820
5821 /// CheckExtraCXXDefaultArguments - Check for any extra default
5822 /// arguments in the declarator, which is not a function declaration
5823 /// or definition and therefore is not permitted to have default
5824 /// arguments. This routine should be invoked for every declarator
5825 /// that is not a function declaration or definition.
5827
5830 }
5831
5832 /// Perform semantic analysis for the variable declaration that
5833 /// occurs within a C++ catch clause, returning the newly-created
5834 /// variable.
5836 SourceLocation StartLoc,
5837 SourceLocation IdLoc,
5838 const IdentifierInfo *Id);
5839
5840 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
5841 /// handler.
5843
5845
5846 /// Handle a friend tag declaration where the scope specifier was
5847 /// templated.
5849 unsigned TagSpec, SourceLocation TagLoc,
5850 CXXScopeSpec &SS, IdentifierInfo *Name,
5851 SourceLocation NameLoc,
5852 SourceLocation EllipsisLoc,
5854 MultiTemplateParamsArg TempParamLists);
5855
5857 SourceLocation DeclStart, Declarator &D,
5858 Expr *BitfieldWidth,
5859 InClassInitStyle InitStyle,
5860 AccessSpecifier AS,
5861 const ParsedAttr &MSPropertyAttr);
5862
5863 /// Diagnose why the specified class does not have a trivial special member of
5864 /// the given kind.
5867
5869 /// The triviality of a method unaffected by "trivial_abi".
5871
5872 /// The triviality of a method affected by "trivial_abi".
5875
5876 /// Determine whether a defaulted or deleted special member function is
5877 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
5878 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
5881 bool Diagnose = false);
5882
5883 /// For a defaulted function, the kind of defaulted function that it is.
5885 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
5886 unsigned SpecialMember : 8;
5887 unsigned Comparison : 8;
5888
5889 public:
5891 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5892 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5894 : SpecialMember(llvm::to_underlying(CSM)),
5895 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5897 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5898 Comparison(llvm::to_underlying(Comp)) {}
5899
5900 bool isSpecialMember() const {
5901 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
5902 CXXSpecialMemberKind::Invalid;
5903 }
5904 bool isComparison() const {
5905 return static_cast<DefaultedComparisonKind>(Comparison) !=
5906 DefaultedComparisonKind::None;
5907 }
5908
5909 explicit operator bool() const {
5910 return isSpecialMember() || isComparison();
5911 }
5912
5914 return static_cast<CXXSpecialMemberKind>(SpecialMember);
5915 }
5917 return static_cast<DefaultedComparisonKind>(Comparison);
5918 }
5919
5920 /// Get the index of this function kind for use in diagnostics.
5921 unsigned getDiagnosticIndex() const {
5922 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
5923 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
5924 "invalid should have highest index");
5925 static_assert((unsigned)DefaultedComparisonKind::None == 0,
5926 "none should be equal to zero");
5927 return SpecialMember + Comparison;
5928 }
5929 };
5930
5931 /// Determine the kind of defaulting that would be done for a given function.
5932 ///
5933 /// If the function is both a default constructor and a copy / move
5934 /// constructor (due to having a default argument for the first parameter),
5935 /// this picks CXXSpecialMemberKind::DefaultConstructor.
5936 ///
5937 /// FIXME: Check that case is properly handled by all callers.
5938 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
5939
5940 /// Handle a C++11 empty-declaration and attribute-declaration.
5942 SourceLocation SemiLoc);
5943
5945 /// Diagnose issues that are non-constant or that are extensions.
5946 Diagnose,
5947 /// Identify whether this function satisfies the formal rules for constexpr
5948 /// functions in the current lanugage mode (with no extensions).
5950 };
5951
5952 // Check whether a function declaration satisfies the requirements of a
5953 // constexpr function definition or a constexpr constructor definition. If so,
5954 // return true. If not, produce appropriate diagnostics (unless asked not to
5955 // by Kind) and return false.
5956 //
5957 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
5960
5961 /// Diagnose methods which overload virtual methods in a base class
5962 /// without overriding any.
5964
5965 /// Check if a method overloads virtual methods in a base class without
5966 /// overriding any.
5967 void
5969 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5970 void
5972 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5973
5974 /// ActOnParamDefaultArgument - Check whether the default argument
5975 /// provided for a function parameter is well-formed. If so, attach it
5976 /// to the parameter declaration.
5977 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
5978 Expr *defarg);
5979
5980 /// ActOnParamUnparsedDefaultArgument - We've seen a default
5981 /// argument for a function parameter, but we can't parse it yet
5982 /// because we're inside a class definition. Note that this default
5983 /// argument will be parsed later.
5985 SourceLocation ArgLoc);
5986
5987 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
5988 /// the default argument for the parameter param failed.
5990 Expr *DefaultArg);
5992 SourceLocation EqualLoc);
5993 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
5994 SourceLocation EqualLoc);
5995
5996 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
5997 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
5998 StringLiteral *Message = nullptr);
5999 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6000
6002 StringLiteral *DeletedMessage = nullptr);
6006
6007 NamedDecl *
6009 MultiTemplateParamsArg TemplateParamLists);
6012 RecordDecl *ClassDecl,
6013 const IdentifierInfo *Name);
6014
6016
6017 /// Stack containing information needed when in C++2a an 'auto' is encountered
6018 /// in a function declaration parameter type specifier in order to invent a
6019 /// corresponding template parameter in the enclosing abbreviated function
6020 /// template. This information is also present in LambdaScopeInfo, stored in
6021 /// the FunctionScopes stack.
6023
6024 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6025 std::unique_ptr<CXXFieldCollector> FieldCollector;
6026
6028 /// Set containing all declared private fields that are not used.
6030
6032
6033 /// PureVirtualClassDiagSet - a set of class declarations which we have
6034 /// emitted a list of pure virtual functions. Used to prevent emitting the
6035 /// same list more than once.
6036 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6037
6041
6042 /// All the delegating constructors seen so far in the file, used for
6043 /// cycle detection at the end of the TU.
6045
6046 /// The C++ "std" namespace, where the standard library resides.
6048
6049 /// The C++ "std::initializer_list" template, which is defined in
6050 /// <initializer_list>.
6052
6053 // Contains the locations of the beginning of unparsed default
6054 // argument locations.
6055 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6056
6057 /// UndefinedInternals - all the used, undefined objects which require a
6058 /// definition in this translation unit.
6059 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6060
6061 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6063
6064 /// The C++ special members which we are currently in the process of
6065 /// declaring. If this process recursively triggers the declaration of the
6066 /// same special member, we should act as if it is not yet declared.
6068
6070
6071 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6072
6075 ParsingClassDepth++;
6077 }
6079 ParsingClassDepth--;
6081 }
6082
6084 CXXScopeSpec &SS,
6085 ParsedType TemplateTypeTy,
6086 IdentifierInfo *MemberOrBase);
6087
6088private:
6089 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6090 QualType ResultTy,
6091 ArrayRef<QualType> Args);
6092
6093 // A cache representing if we've fully checked the various comparison category
6094 // types stored in ASTContext. The bit-index corresponds to the integer value
6095 // of a ComparisonCategoryType enumerator.
6096 llvm::SmallBitVector FullyCheckedComparisonCategories;
6097
6098 /// Check if there is a field shadowing.
6099 void CheckShadowInheritedFields(const SourceLocation &Loc,
6100 DeclarationName FieldName,
6101 const CXXRecordDecl *RD,
6102 bool DeclIsField = true);
6103
6104 ///@}
6105
6106 //
6107 //
6108 // -------------------------------------------------------------------------
6109 //
6110 //
6111
6112 /// \name C++ Exception Specifications
6113 /// Implementations are in SemaExceptionSpec.cpp
6114 ///@{
6115
6116public:
6117 /// All the overriding functions seen during a class definition
6118 /// that had their exception spec checks delayed, plus the overridden
6119 /// function.
6122
6123 /// All the function redeclarations seen during a class definition that had
6124 /// their exception spec checks delayed, plus the prior declaration they
6125 /// should be checked against. Except during error recovery, the new decl
6126 /// should always be a friend declaration, as that's the only valid way to
6127 /// redeclare a special member before its class is complete.
6130
6131 /// Determine if we're in a case where we need to (incorrectly) eagerly
6132 /// parse an exception specification to work around a libstdc++ bug.
6134
6135 /// Check the given noexcept-specifier, convert its expression, and compute
6136 /// the appropriate ExceptionSpecificationType.
6137 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6139
6140 CanThrowResult canThrow(const Stmt *E);
6141 /// Determine whether the callee of a particular function call can throw.
6142 /// E, D and Loc are all optional.
6143 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6146 const FunctionProtoType *FPT);
6149
6150 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6151 /// exception specification. Incomplete types, or pointers to incomplete types
6152 /// other than void are not allowed.
6153 ///
6154 /// \param[in,out] T The exception type. This will be decayed to a pointer
6155 /// type
6156 /// when the input is an array or a function type.
6158
6159 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6160 /// pointer to member to a function with an exception specification. This
6161 /// means that it is invalid to add another level of indirection.
6164
6165 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6166 /// exception specifications. Exception specifications are equivalent if
6167 /// they allow exactly the same set of exception types. It does not matter how
6168 /// that is achieved. See C++ [except.spec]p2.
6170 SourceLocation OldLoc,
6171 const FunctionProtoType *New,
6172 SourceLocation NewLoc);
6174 const PartialDiagnostic &NoteID,
6175 const FunctionProtoType *Old,
6176 SourceLocation OldLoc,
6177 const FunctionProtoType *New,
6178 SourceLocation NewLoc);
6179 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6180
6181 /// CheckExceptionSpecSubset - Check whether the second function type's
6182 /// exception specification is a subset (or equivalent) of the first function
6183 /// type. This is used by override and pointer assignment checks.
6185 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6186 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6187 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6188 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6189 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6190
6191 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6192 /// two functions have equivalent exception specs. This is part of the
6193 /// assignment and override compatibility check. We do not check the
6194 /// parameters of parameter function pointers recursively, as no sane
6195 /// programmer would even be able to write such a function type.
6197 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6198 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6199 SourceLocation TargetLoc, const FunctionProtoType *Source,
6200 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6201
6202 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6203
6204 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6205 /// spec is a subset of base spec.
6207 const CXXMethodDecl *Old);
6208
6209 ///@}
6210
6211 //
6212 //
6213 // -------------------------------------------------------------------------
6214 //
6215 //
6216
6217 /// \name Expressions
6218 /// Implementations are in SemaExpr.cpp
6219 ///@{
6220
6221public:
6222 /// Describes how the expressions currently being parsed are
6223 /// evaluated at run-time, if at all.
6225 /// The current expression and its subexpressions occur within an
6226 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6227 /// \c sizeof, where the type of the expression may be significant but
6228 /// no code will be generated to evaluate the value of the expression at
6229 /// run time.
6231
6232 /// The current expression occurs within a braced-init-list within
6233 /// an unevaluated operand. This is mostly like a regular unevaluated
6234 /// context, except that we still instantiate constexpr functions that are
6235 /// referenced here so that we can perform narrowing checks correctly.
6237
6238 /// The current expression occurs within a discarded statement.
6239 /// This behaves largely similarly to an unevaluated operand in preventing
6240 /// definitions from being required, but not in other ways.
6242
6243 /// The current expression occurs within an unevaluated
6244 /// operand that unconditionally permits abstract references to
6245 /// fields, such as a SIZE operator in MS-style inline assembly.
6247
6248 /// The current context is "potentially evaluated" in C++11 terms,
6249 /// but the expression is evaluated at compile-time (like the values of
6250 /// cases in a switch statement).
6252
6253 /// In addition of being constant evaluated, the current expression
6254 /// occurs in an immediate function context - either a consteval function
6255 /// or a consteval if statement.
6257
6258 /// The current expression is potentially evaluated at run time,
6259 /// which means that code may be generated to evaluate the value of the
6260 /// expression at run time.
6262
6263 /// The current expression is potentially evaluated, but any
6264 /// declarations referenced inside that expression are only used if
6265 /// in fact the current expression is used.
6266 ///
6267 /// This value is used when parsing default function arguments, for which
6268 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6269 /// through varargs) but do not want to mark declarations as "referenced"
6270 /// until the default argument is used.
6272 };
6273
6274 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6275 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6276 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6277 /// have been applied to all subexpressions of the enclosing full expression.
6278 /// This is cleared at the end of each full expression.
6281
6282 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6283
6284 /// Data structure used to record current or nested
6285 /// expression evaluation contexts.
6287 /// The expression evaluation context.
6289
6290 /// Whether the enclosing context needed a cleanup.
6292
6293 /// The number of active cleanup objects when we entered
6294 /// this expression evaluation context.
6296
6297 /// The number of typos encountered during this expression evaluation
6298 /// context (i.e. the number of TypoExprs created).
6299 unsigned NumTypos;
6300
6302
6303 /// The lambdas that are present within this context, if it
6304 /// is indeed an unevaluated context.
6306
6307 /// The declaration that provides context for lambda expressions
6308 /// and block literals if the normal declaration context does not
6309 /// suffice, e.g., in a default function argument.
6311
6312 /// If we are processing a decltype type, a set of call expressions
6313 /// for which we have deferred checking the completeness of the return type.
6315
6316 /// If we are processing a decltype type, a set of temporary binding
6317 /// expressions for which we have deferred checking the destructor.
6319
6321
6322 /// Expressions appearing as the LHS of a volatile assignment in this
6323 /// context. We produce a warning for these when popping the context if
6324 /// they are not discarded-value expressions nor unevaluated operands.
6326
6327 /// Set of candidates for starting an immediate invocation.
6330
6331 /// Set of DeclRefExprs referencing a consteval function when used in a
6332 /// context not already known to be immediately invoked.
6334
6335 /// P2718R0 - Lifetime extension in range-based for loops.
6336 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6337 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6338 /// InLifetimeExtendingContext is true.
6340
6341 /// \brief Describes whether we are in an expression constext which we have
6342 /// to handle differently.
6347 EK_Other
6348 } ExprContext;
6349
6350 // A context can be nested in both a discarded statement context and
6351 // an immediate function context, so they need to be tracked independently.
6355
6356 bool IsCurrentlyCheckingDefaultArgumentOrInitializer = false;
6357
6358 // We are in a constant context, but we also allow
6359 // non constant expressions, for example for array bounds (which may be
6360 // VLAs).
6361 bool InConditionallyConstantEvaluateContext = false;
6362
6363 /// Whether we are currently in a context in which all temporaries must be
6364 /// lifetime-extended, even if they're not bound to a reference (for
6365 /// example, in a for-range initializer).
6366 bool InLifetimeExtendingContext = false;
6367
6368 /// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
6369 bool RebuildDefaultArgOrDefaultInit = false;
6370
6371 // When evaluating immediate functions in the initializer of a default
6372 // argument or default member initializer, this is the declaration whose
6373 // default initializer is being evaluated and the location of the call
6374 // or constructor definition.
6377 DeclContext *Context)
6378 : Loc(Loc), Decl(Decl), Context(Context) {
6379 assert(Decl && Context && "invalid initialization context");
6380 }
6381
6383 ValueDecl *Decl = nullptr;
6384 DeclContext *Context = nullptr;
6385 };
6386 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6387
6389 unsigned NumCleanupObjects,
6390 CleanupInfo ParentCleanup,
6391 Decl *ManglingContextDecl,
6392 ExpressionKind ExprContext)
6393 : Context(Context), ParentCleanup(ParentCleanup),
6394 NumCleanupObjects(NumCleanupObjects), NumTypos(0),
6395 ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext),
6396 InDiscardedStatement(false), InImmediateFunctionContext(false),
6397 InImmediateEscalatingFunctionContext(false) {}
6398
6399 bool isUnevaluated() const {
6400 return Context == ExpressionEvaluationContext::Unevaluated ||
6401 Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
6402 Context == ExpressionEvaluationContext::UnevaluatedList;
6403 }
6404
6406 return Context == ExpressionEvaluationContext::PotentiallyEvaluated ||
6407 Context ==
6408 ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed ||
6409 Context == ExpressionEvaluationContext::ConstantEvaluated;
6410 }
6411
6412 bool isConstantEvaluated() const {
6413 return Context == ExpressionEvaluationContext::ConstantEvaluated ||
6414 Context == ExpressionEvaluationContext::ImmediateFunctionContext;
6415 }
6416
6418 return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
6419 (Context == ExpressionEvaluationContext::DiscardedStatement &&
6420 InImmediateFunctionContext) ||
6421 // C++23 [expr.const]p14:
6422 // An expression or conversion is in an immediate function
6423 // context if it is potentially evaluated and either:
6424 // * its innermost enclosing non-block scope is a function
6425 // parameter scope of an immediate function, or
6426 // * its enclosing statement is enclosed by the compound-
6427 // statement of a consteval if statement.
6428 (Context == ExpressionEvaluationContext::PotentiallyEvaluated &&
6429 InImmediateFunctionContext);
6430 }
6431
6433 return Context == ExpressionEvaluationContext::DiscardedStatement ||
6434 (Context ==
6435 ExpressionEvaluationContext::ImmediateFunctionContext &&
6436 InDiscardedStatement);
6437 }
6438 };
6439
6441 assert(!ExprEvalContexts.empty() &&
6442 "Must be in an expression evaluation context");
6443 return ExprEvalContexts.back();
6444 };
6445
6447 assert(!ExprEvalContexts.empty() &&
6448 "Must be in an expression evaluation context");
6449 return ExprEvalContexts.back();
6450 };
6451
6453 assert(ExprEvalContexts.size() >= 2 &&
6454 "Must be in an expression evaluation context");
6455 return ExprEvalContexts[ExprEvalContexts.size() - 2];
6456 };
6457
6459 return const_cast<Sema *>(this)->parentEvaluationContext();
6460 };
6461
6462 bool isAttrContext() const {
6463 return ExprEvalContexts.back().ExprContext ==
6465 }
6466
6467 /// Increment when we find a reference; decrement when we find an ignored
6468 /// assignment. Ultimately the value is 0 if every reference is an ignored
6469 /// assignment.
6470 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
6471
6472 /// Used to control the generation of ExprWithCleanups.
6474
6475 /// ExprCleanupObjects - This is the stack of objects requiring
6476 /// cleanup that are created by the current full expression.
6478
6479 /// Determine whether the use of this declaration is valid, without
6480 /// emitting diagnostics.
6481 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
6482 // A version of DiagnoseUseOfDecl that should be used if overload resolution
6483 // has been used to find this declaration, which means we don't have to bother
6484 // checking the trailing requires clause.
6486 return DiagnoseUseOfDecl(
6487 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
6488 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
6489 /*SkipTrailingRequiresClause=*/true);
6490 }
6491
6492 /// Determine whether the use of this declaration is valid, and
6493 /// emit any corresponding diagnostics.
6494 ///
6495 /// This routine diagnoses various problems with referencing
6496 /// declarations that can occur when using a declaration. For example,
6497 /// it might warn if a deprecated or unavailable declaration is being
6498 /// used, or produce an error (and return true) if a C++0x deleted
6499 /// function is being used.
6500 ///
6501 /// \returns true if there was an error (this declaration cannot be
6502 /// referenced), false otherwise.
6504 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
6505 bool ObjCPropertyAccess = false,
6506 bool AvoidPartialAvailabilityChecks = false,
6507 ObjCInterfaceDecl *ClassReciever = nullptr,
6508 bool SkipTrailingRequiresClause = false);
6509
6510 /// Emit a note explaining that this function is deleted.
6512
6513 /// DiagnoseSentinelCalls - This routine checks whether a call or
6514 /// message-send is to a declaration with the sentinel attribute, and
6515 /// if so, it checks that the requirements of the sentinel are
6516 /// satisfied.
6518 ArrayRef<Expr *> Args);
6519
6521 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
6530
6532
6536
6537 /// Check whether E, which is either a discarded-value expression or an
6538 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
6539 /// lvalue, and if so, remove it from the list of volatile-qualified
6540 /// assignments that we are going to warn are deprecated.
6542
6544
6545 // Functions for marking a declaration referenced. These functions also
6546 // contain the relevant logic for marking if a reference to a function or
6547 // variable is an odr-use (in the C++11 sense). There are separate variants
6548 // for expressions referring to a decl; these exist because odr-use marking
6549 // needs to be delayed for some constant variables when we build one of the
6550 // named expressions.
6551 //
6552 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
6553 // should usually be true. This only needs to be set to false if the lack of
6554 // odr-use cannot be determined from the current context (for instance,
6555 // because the name denotes a virtual function and was written without an
6556 // explicit nested-name-specifier).
6557 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
6558
6559 /// Mark a function referenced, and check whether it is odr-used
6560 /// (C++ [basic.def.odr]p2, C99 6.9p3)
6562 bool MightBeOdrUse = true);
6563
6564 /// Mark a variable referenced, and check whether it is odr-used
6565 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
6566 /// used directly for normal expressions referring to VarDecl.
6568
6569 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
6570 ///
6571 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
6572 /// be handled with care if the DeclRefExpr is not newly-created.
6573 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
6574
6575 /// Perform reference-marking and odr-use handling for a MemberExpr.
6577
6578 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
6581 unsigned CapturingScopeIndex);
6582
6584 void CleanupVarDeclMarking();
6585
6591
6592 /// Try to capture the given variable.
6593 ///
6594 /// \param Var The variable to capture.
6595 ///
6596 /// \param Loc The location at which the capture occurs.
6597 ///
6598 /// \param Kind The kind of capture, which may be implicit (for either a
6599 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
6600 ///
6601 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
6602 /// an explicit lambda capture.
6603 ///
6604 /// \param BuildAndDiagnose Whether we are actually supposed to add the
6605 /// captures or diagnose errors. If false, this routine merely check whether
6606 /// the capture can occur without performing the capture itself or complaining
6607 /// if the variable cannot be captured.
6608 ///
6609 /// \param CaptureType Will be set to the type of the field used to capture
6610 /// this variable in the innermost block or lambda. Only valid when the
6611 /// variable can be captured.
6612 ///
6613 /// \param DeclRefType Will be set to the type of a reference to the capture
6614 /// from within the current scope. Only valid when the variable can be
6615 /// captured.
6616 ///
6617 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
6618 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
6619 /// This is useful when enclosing lambdas must speculatively capture
6620 /// variables that may or may not be used in certain specializations of
6621 /// a nested generic lambda.
6622 ///
6623 /// \returns true if an error occurred (i.e., the variable cannot be
6624 /// captured) and false if the capture succeeded.
6626 TryCaptureKind Kind, SourceLocation EllipsisLoc,
6627 bool BuildAndDiagnose, QualType &CaptureType,
6628 QualType &DeclRefType,
6629 const unsigned *const FunctionScopeIndexToStopAt);
6630
6631 /// Try to capture the given variable.
6634 SourceLocation EllipsisLoc = SourceLocation());
6635
6636 /// Checks if the variable must be captured.
6638
6639 /// Given a variable, determine the type that a reference to that
6640 /// variable will have in the given scope.
6642
6643 /// Mark all of the declarations referenced within a particular AST node as
6644 /// referenced. Used when template instantiation instantiates a non-dependent
6645 /// type -- entities referenced by the type are now referenced.
6647
6648 /// Mark any declarations that appear within this expression or any
6649 /// potentially-evaluated subexpressions as "referenced".
6650 ///
6651 /// \param SkipLocalVariables If true, don't mark local variables as
6652 /// 'referenced'.
6653 /// \param StopAt Subexpressions that we shouldn't recurse into.
6655 bool SkipLocalVariables = false,
6656 ArrayRef<const Expr *> StopAt = {});
6657
6658 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
6659 /// conversion.
6660 ExprResult tryConvertExprToType(Expr *E, QualType Ty);
6661
6662 /// Conditionally issue a diagnostic based on the statements's reachability
6663 /// analysis.
6664 ///
6665 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
6666 /// the function body is parsed, and then do a basic reachability analysis to
6667 /// determine if the statement is reachable. If it is unreachable, the
6668 /// diagnostic will not be emitted.
6669 bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
6670 const PartialDiagnostic &PD);
6671
6672 /// Conditionally issue a diagnostic based on the current
6673 /// evaluation context.
6674 ///
6675 /// \param Statement If Statement is non-null, delay reporting the
6676 /// diagnostic until the function body is parsed, and then do a basic
6677 /// reachability analysis to determine if the statement is reachable.
6678 /// If it is unreachable, the diagnostic will not be emitted.
6679 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
6680 const PartialDiagnostic &PD);
6681 /// Similar, but diagnostic is only produced if all the specified statements
6682 /// are reachable.
6683 bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
6684 const PartialDiagnostic &PD);
6685
6686 // Primary Expressions.
6687 SourceRange getExprRange(Expr *E) const;
6688
6689 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
6690 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
6691 bool HasTrailingLParen, bool IsAddressOfOperand,
6692 CorrectionCandidateCallback *CCC = nullptr,
6693 bool IsInlineAsmIdentifier = false,
6694 Token *KeywordReplacement = nullptr);
6695
6696 /// Decomposes the given name into a DeclarationNameInfo, its location, and
6697 /// possibly a list of template arguments.
6698 ///
6699 /// If this produces template arguments, it is permitted to call
6700 /// DecomposeTemplateName.
6701 ///
6702 /// This actually loses a lot of source location information for
6703 /// non-standard name kinds; we should consider preserving that in
6704 /// some way.
6705 void DecomposeUnqualifiedId(const UnqualifiedId &Id,
6706 TemplateArgumentListInfo &Buffer,
6707 DeclarationNameInfo &NameInfo,
6708 const TemplateArgumentListInfo *&TemplateArgs);
6709
6710 /// Diagnose a lookup that found results in an enclosing class during error
6711 /// recovery. This usually indicates that the results were found in a
6712 /// dependent base class that could not be searched as part of a template
6713 /// definition. Always issues a diagnostic (though this may be only a warning
6714 /// in MS compatibility mode).
6715 ///
6716 /// Return \c true if the error is unrecoverable, or \c false if the caller
6717 /// should attempt to recover using these lookup results.
6718 bool DiagnoseDependentMemberLookup(const LookupResult &R);
6719
6720 /// Diagnose an empty lookup.
6721 ///
6722 /// \return false if new lookup candidates were found
6723 bool
6724 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
6725 CorrectionCandidateCallback &CCC,
6726 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
6727 ArrayRef<Expr *> Args = {},
6728 DeclContext *LookupCtx = nullptr,
6729 TypoExpr **Out = nullptr);
6730
6731 /// If \p D cannot be odr-used in the current expression evaluation context,
6732 /// return a reason explaining why. Otherwise, return NOUR_None.
6734
6735 DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6736 SourceLocation Loc,
6737 const CXXScopeSpec *SS = nullptr);
6738 DeclRefExpr *
6739 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6740 const DeclarationNameInfo &NameInfo,
6741 const CXXScopeSpec *SS = nullptr,
6742 NamedDecl *FoundD = nullptr,
6743 SourceLocation TemplateKWLoc = SourceLocation(),
6744 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6745
6746 /// BuildDeclRefExpr - Build an expression that references a
6747 /// declaration that does not require a closure capture.
6748 DeclRefExpr *
6749 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6750 const DeclarationNameInfo &NameInfo,
6751 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
6752 SourceLocation TemplateKWLoc = SourceLocation(),
6753 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6754
6755 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
6756 bool HasTrailingLParen);
6757
6758 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
6759 /// declaration name, generally during template instantiation.
6760 /// There's a large number of things which don't need to be done along
6761 /// this path.
6763 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
6764 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
6765
6766 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
6767 bool NeedsADL,
6768 bool AcceptInvalidDecl = false);
6769
6770 /// Complete semantic analysis for a reference to the given declaration.
6772 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
6773 NamedDecl *FoundD = nullptr,
6774 const TemplateArgumentListInfo *TemplateArgs = nullptr,
6775 bool AcceptInvalidDecl = false);
6776
6777 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
6778 // where Tokens representing function local predefined macros (such as
6779 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
6780 std::vector<Token> ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks);
6781
6784 ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
6785
6786 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
6787
6788 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
6789 ExprResult ActOnCharacterConstant(const Token &Tok,
6790 Scope *UDLScope = nullptr);
6791 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
6792 ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
6793 MultiExprArg Val);
6794
6795 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
6796 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
6797 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
6798 /// from multiple tokens. However, the common case is that StringToks points
6799 /// to one string.
6800 ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
6801 Scope *UDLScope = nullptr);
6802
6803 ExprResult ActOnUnevaluatedStringLiteral(ArrayRef<Token> StringToks);
6804
6805 /// ControllingExprOrType is either an opaque pointer coming out of a
6806 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
6807 /// into two so we don't take a void *, but that's awkward because one of
6808 /// the operands is either a ParsedType or an Expr *, which doesn't lend
6809 /// itself to generic code very well.
6810 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
6811 SourceLocation DefaultLoc,
6812 SourceLocation RParenLoc,
6813 bool PredicateIsExpr,
6814 void *ControllingExprOrType,
6815 ArrayRef<ParsedType> ArgTypes,
6816 ArrayRef<Expr *> ArgExprs);
6817 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
6818 /// it'd be better to split this interface into two so we don't take a
6819 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
6820 /// isn't a trivial change.
6821 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
6822 SourceLocation DefaultLoc,
6823 SourceLocation RParenLoc,
6824 bool PredicateIsExpr,
6825 void *ControllingExprOrType,
6826 ArrayRef<TypeSourceInfo *> Types,
6827 ArrayRef<Expr *> Exprs);
6828
6829 // Binary/Unary Operators. 'Tok' is the token for the operator.
6830 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
6831 Expr *InputExpr, bool IsAfterAmp = false);
6832 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc,
6833 Expr *Input, bool IsAfterAmp = false);
6834
6835 /// Unary Operators. 'Tok' is the token for the operator.
6836 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op,
6837 Expr *Input, bool IsAfterAmp = false);
6838
6839 /// Determine whether the given expression is a qualified member
6840 /// access expression, of a form that could be turned into a pointer to member
6841 /// with the address-of operator.
6842 bool isQualifiedMemberAccess(Expr *E);
6843 bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
6844 const Expr *Op,
6845 const CXXMethodDecl *MD);
6846
6847 /// CheckAddressOfOperand - The operand of & must be either a function
6848 /// designator or an lvalue designating an object. If it is an lvalue, the
6849 /// object cannot be declared with storage class register or be a bit field.
6850 /// Note: The usual conversions are *not* applied to the operand of the &
6851 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
6852 /// In C++, the operand might be an overloaded function name, in which case
6853 /// we allow the '&' but retain the overloaded-function type.
6854 QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
6855
6856 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
6857 /// _Alignas(type-name) .
6858 /// [dcl.align] An alignment-specifier of the form
6859 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
6860 ///
6861 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
6862 /// _Alignas(_Alignof(type-name)).
6863 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
6864 SourceLocation OpLoc, SourceRange R);
6865 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
6866 SourceLocation OpLoc, SourceRange R);
6867
6868 /// Build a sizeof or alignof expression given a type operand.
6869 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
6870 SourceLocation OpLoc,
6871 UnaryExprOrTypeTrait ExprKind,
6872 SourceRange R);
6873
6874 /// Build a sizeof or alignof expression given an expression
6875 /// operand.
6876 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
6877 UnaryExprOrTypeTrait ExprKind);
6878
6879 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
6880 /// expr and the same for @c alignof and @c __alignof
6881 /// Note that the ArgRange is invalid if isType is false.
6882 ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
6883 UnaryExprOrTypeTrait ExprKind,
6884 bool IsType, void *TyOrEx,
6885 SourceRange ArgRange);
6886
6887 /// Check for operands with placeholder types and complain if found.
6888 /// Returns ExprError() if there was an error and no recovery was possible.
6890 bool CheckVecStepExpr(Expr *E);
6891
6892 /// Check the constraints on expression operands to unary type expression
6893 /// and type traits.
6894 ///
6895 /// Completes any types necessary and validates the constraints on the operand
6896 /// expression. The logic mostly mirrors the type-based overload, but may
6897 /// modify the expression as it completes the type for that expression through
6898 /// template instantiation, etc.
6900
6901 /// Check the constraints on operands to unary expression and type
6902 /// traits.
6903 ///
6904 /// This will complete any types necessary, and validate the various
6905 /// constraints on those operands.
6906 ///
6907 /// The UsualUnaryConversions() function is *not* called by this routine.
6908 /// C99 6.3.2.1p[2-4] all state:
6909 /// Except when it is the operand of the sizeof operator ...
6910 ///
6911 /// C++ [expr.sizeof]p4
6912 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
6913 /// standard conversions are not applied to the operand of sizeof.
6914 ///
6915 /// This policy is followed for all of the unary trait expressions.
6916 bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
6917 SourceRange ExprRange,
6918 UnaryExprOrTypeTrait ExprKind,
6919 StringRef KWName);
6920
6921 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
6922 tok::TokenKind Kind, Expr *Input);
6923
6924 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
6925 MultiExprArg ArgExprs,
6926 SourceLocation RLoc);
6927 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
6928 Expr *Idx, SourceLocation RLoc);
6929
6931 Expr *ColumnIdx,
6932 SourceLocation RBLoc);
6933
6934 /// ConvertArgumentsForCall - Converts the arguments specified in
6935 /// Args/NumArgs to the parameter types of the function FDecl with
6936 /// function prototype Proto. Call is the call expression itself, and
6937 /// Fn is the function expression. For a C++ member function, this
6938 /// routine does not attempt to convert the object argument. Returns
6939 /// true if the call is ill-formed.
6940 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl,
6941 const FunctionProtoType *Proto,
6942 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
6943 bool ExecConfig = false);
6944
6945 /// CheckStaticArrayArgument - If the given argument corresponds to a static
6946 /// array parameter, check that it is non-null, and that if it is formed by
6947 /// array-to-pointer decay, the underlying array is sufficiently large.
6948 ///
6949 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
6950 /// the array type derivation, then for each call to the function, the value
6951 /// of the corresponding actual argument shall provide access to the first
6952 /// element of an array with at least as many elements as specified by the
6953 /// size expression.
6954 void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
6955 const Expr *ArgExpr);
6956
6957 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
6958 /// This provides the location of the left/right parens and a list of comma
6959 /// locations.
6960 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
6961 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6962 Expr *ExecConfig = nullptr);
6963
6964 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
6965 /// This provides the location of the left/right parens and a list of comma
6966 /// locations.
6967 ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
6968 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6969 Expr *ExecConfig = nullptr,
6970 bool IsExecConfig = false,
6971 bool AllowRecovery = false);
6972
6973 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
6974 // with the specified CallArgs
6975 Expr *BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id,
6976 MultiExprArg CallArgs);
6977
6979
6980 /// BuildResolvedCallExpr - Build a call to a resolved expression,
6981 /// i.e. an expression not of \p OverloadTy. The expression should
6982 /// unary-convert to an expression of function-pointer or
6983 /// block-pointer type.
6984 ///
6985 /// \param NDecl the declaration being called, if available
6987 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
6988 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
6989 Expr *Config = nullptr, bool IsExecConfig = false,
6990 ADLCallKind UsesADL = ADLCallKind::NotADL);
6991
6993 ParsedType &Ty, SourceLocation RParenLoc,
6994 Expr *CastExpr);
6995
6996 /// Prepares for a scalar cast, performing all the necessary stages
6997 /// except the final cast and returning the kind required.
6999
7000 /// Build an altivec or OpenCL literal.
7002 SourceLocation RParenLoc, Expr *E,
7003 TypeSourceInfo *TInfo);
7004
7005 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7006 /// the ParenListExpr into a sequence of comma binary operators.
7008
7010 SourceLocation RParenLoc, Expr *InitExpr);
7011
7013 TypeSourceInfo *TInfo,
7014 SourceLocation RParenLoc,
7015 Expr *LiteralExpr);
7016
7017 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7018 SourceLocation RBraceLoc);
7019
7020 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7021 SourceLocation RBraceLoc);
7022
7023 /// Binary Operators. 'Tok' is the token for the operator.
7025 Expr *LHSExpr, Expr *RHSExpr);
7027 Expr *LHSExpr, Expr *RHSExpr);
7028
7029 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7030 /// operator @p Opc at location @c TokLoc. This routine only supports
7031 /// built-in operations; ActOnBinOp handles overloaded operators.
7033 Expr *LHSExpr, Expr *RHSExpr);
7035 UnresolvedSetImpl &Functions);
7036
7037 /// Look for instances where it is likely the comma operator is confused with
7038 /// another operator. There is an explicit list of acceptable expressions for
7039 /// the left hand side of the comma operator, otherwise emit a warning.
7040 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7041
7042 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7043 /// in the case of a the GNU conditional expr extension.
7045 SourceLocation ColonLoc, Expr *CondExpr,
7046 Expr *LHSExpr, Expr *RHSExpr);
7047
7048 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7050 LabelDecl *TheDecl);
7051
7052 void ActOnStartStmtExpr();
7053 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7054 SourceLocation RPLoc);
7056 SourceLocation RPLoc, unsigned TemplateDepth);
7057 // Handle the final expression in a statement expression.
7059 void ActOnStmtExprError();
7060
7061 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
7064 bool isBrackets; // true if [expr], false if .ident
7065 union {
7068 } U;
7069 };
7070
7071 /// __builtin_offsetof(type, a.b[123][456].c)
7073 TypeSourceInfo *TInfo,
7074 ArrayRef<OffsetOfComponent> Components,
7075 SourceLocation RParenLoc);
7078 ParsedType ParsedArgTy,
7079 ArrayRef<OffsetOfComponent> Components,
7080 SourceLocation RParenLoc);
7081
7082 // __builtin_choose_expr(constExpr, expr1, expr2)
7083 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7084 Expr *LHSExpr, Expr *RHSExpr,
7085 SourceLocation RPLoc);
7086
7087 // __builtin_va_arg(expr, type)
7089 SourceLocation RPLoc);
7091 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7092
7093 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7094 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7096 SourceLocation BuiltinLoc,
7097 SourceLocation RPLoc);
7098
7099 // #embed
7101 StringLiteral *BinaryData);
7102
7103 // Build a potentially resolved SourceLocExpr.
7105 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7106 DeclContext *ParentContext);
7107
7108 // __null
7110
7111 bool CheckCaseExpression(Expr *E);
7112
7113 //===------------------------- "Block" Extension ------------------------===//
7114
7115 /// ActOnBlockStart - This callback is invoked when a block literal is
7116 /// started.
7117 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7118
7119 /// ActOnBlockArguments - This callback allows processing of block arguments.
7120 /// If there are no arguments, this is still invoked.
7121 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7122 Scope *CurScope);
7123
7124 /// ActOnBlockError - If there is an error parsing a block, this callback
7125 /// is invoked to pop the information about the block from the action impl.
7126 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7127
7128 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7129 /// literal was successfully completed. ^(int x){...}
7131 Scope *CurScope);
7132
7133 //===---------------------------- Clang Extensions ----------------------===//
7134
7135 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7136 /// provided arguments.
7137 ///
7138 /// __builtin_convertvector( value, dst type )
7139 ///
7141 SourceLocation BuiltinLoc,
7142 SourceLocation RParenLoc);
7143
7144 //===---------------------------- OpenCL Features -----------------------===//
7145
7146 /// Parse a __builtin_astype expression.
7147 ///
7148 /// __builtin_astype( value, dst type )
7149 ///
7151 SourceLocation BuiltinLoc,
7152 SourceLocation RParenLoc);
7153
7154 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7156 SourceLocation BuiltinLoc,
7157 SourceLocation RParenLoc);
7158
7159 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7161 ArrayRef<Expr *> SubExprs,
7162 QualType T = QualType());
7163
7164 /// Cast a base object to a member's actual type.
7165 ///
7166 /// There are two relevant checks:
7167 ///
7168 /// C++ [class.access.base]p7:
7169 ///
7170 /// If a class member access operator [...] is used to access a non-static
7171 /// data member or non-static member function, the reference is ill-formed
7172 /// if the left operand [...] cannot be implicitly converted to a pointer to
7173 /// the naming class of the right operand.
7174 ///
7175 /// C++ [expr.ref]p7:
7176 ///
7177 /// If E2 is a non-static data member or a non-static member function, the
7178 /// program is ill-formed if the class of which E2 is directly a member is
7179 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7180 ///
7181 /// Note that the latter check does not consider access; the access of the
7182 /// "real" base class is checked as appropriate when checking the access of
7183 /// the member name.
7185 NestedNameSpecifier *Qualifier,
7186 NamedDecl *FoundDecl,
7187 NamedDecl *Member);
7188
7189 /// CheckCallReturnType - Checks that a call expression's return type is
7190 /// complete. Returns true on failure. The location passed in is the location
7191 /// that best represents the call.
7193 CallExpr *CE, FunctionDecl *FD);
7194
7195 /// Emit a warning for all pending noderef expressions that we recorded.
7196 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
7197
7199
7200 /// Instantiate or parse a C++ default argument expression as necessary.
7201 /// Return true on error.
7203 ParmVarDecl *Param, Expr *Init = nullptr,
7204 bool SkipImmediateInvocations = true);
7205
7206 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7207 /// the default expr if needed.
7209 ParmVarDecl *Param, Expr *Init = nullptr);
7210
7211 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7212 /// invocation.
7214
7216
7217 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7218 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7219
7220 /// Abstract base class used for diagnosing integer constant
7221 /// expression violations.
7223 public:
7225
7226 VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {}
7227
7228 virtual SemaDiagnosticBuilder
7229 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7231 SourceLocation Loc) = 0;
7232 virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc);
7234 };
7235
7239 };
7240
7241 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7242 /// and reports the appropriate diagnostics. Returns false on success.
7243 /// Can optionally return the value of the expression.
7245 VerifyICEDiagnoser &Diagnoser,
7246 AllowFoldKind CanFold = NoFold);
7248 unsigned DiagID,
7249 AllowFoldKind CanFold = NoFold);
7251 llvm::APSInt *Result = nullptr,
7252 AllowFoldKind CanFold = NoFold);
7254 AllowFoldKind CanFold = NoFold) {
7255 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7256 }
7257
7258 /// DiagnoseAssignmentAsCondition - Given that an expression is
7259 /// being used as a boolean condition, warn if it's an assignment.
7261
7262 /// Redundant parentheses over an equality comparison can indicate
7263 /// that the user intended an assignment used as condition.
7265
7267 public:
7268 FullExprArg() : E(nullptr) {}
7269 FullExprArg(Sema &actions) : E(nullptr) {}
7270
7271 ExprResult release() { return E; }
7272
7273 Expr *get() const { return E; }
7274
7275 Expr *operator->() { return E; }
7276
7277 private:
7278 // FIXME: No need to make the entire Sema class a friend when it's just
7279 // Sema::MakeFullExpr that needs access to the constructor below.
7280 friend class Sema;
7281
7282 explicit FullExprArg(Expr *expr) : E(expr) {}
7283
7284 Expr *E;
7285 };
7286
7288 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7289 }
7291 return FullExprArg(
7292 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7293 }
7295 ExprResult FE =
7296 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7297 /*DiscardedValue*/ true);
7298 return FullExprArg(FE.get());
7299 }
7300
7302 Decl *ConditionVar;
7304 bool Invalid;
7305 std::optional<bool> KnownValue;
7306
7307 friend class Sema;
7308 ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
7309 bool IsConstexpr)
7310 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7311 if (IsConstexpr && Condition.get()) {
7312 if (std::optional<llvm::APSInt> Val =
7313 Condition.get()->getIntegerConstantExpr(S.Context)) {
7314 KnownValue = !!(*Val);
7315 }
7316 }
7317 }
7318 explicit ConditionResult(bool Invalid)
7319 : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
7320 KnownValue(std::nullopt) {}
7321
7322 public:
7324 bool isInvalid() const { return Invalid; }
7325 std::pair<VarDecl *, Expr *> get() const {
7326 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7327 Condition.get());
7328 }
7329 std::optional<bool> getKnownValue() const { return KnownValue; }
7330 };
7332
7333 /// CheckBooleanCondition - Diagnose problems involving the use of
7334 /// the given expression as a boolean condition (e.g. in an if
7335 /// statement). Also performs the standard function and array
7336 /// decays, possibly changing the input variable.
7337 ///
7338 /// \param Loc - A location associated with the condition, e.g. the
7339 /// 'if' keyword.
7340 /// \return true iff there were any errors
7342 bool IsConstexpr = false);
7343
7344 enum class ConditionKind {
7345 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7346 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7347 Switch ///< An integral condition for a 'switch' statement.
7348 };
7349
7350 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7351 ConditionKind CK, bool MissingOK = false);
7352
7353 QualType CheckConditionalOperands( // C99 6.5.15
7354 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
7355 ExprObjectKind &OK, SourceLocation QuestionLoc);
7356
7357 /// Emit a specialized diagnostic when one expression is a null pointer
7358 /// constant and the other is not a pointer. Returns true if a diagnostic is
7359 /// emitted.
7360 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7361 SourceLocation QuestionLoc);
7362
7363 /// type checking for vector binary operators.
7365 SourceLocation Loc, bool IsCompAssign,
7366 bool AllowBothBool, bool AllowBoolConversion,
7367 bool AllowBoolOperation, bool ReportInvalid);
7368
7369 /// Return a signed ext_vector_type that is of identical size and number of
7370 /// elements. For floating point vectors, return an integer type of identical
7371 /// size and number of elements. In the non ext_vector_type case, search from
7372 /// the largest type to the smallest type to avoid cases where long long ==
7373 /// long, where long gets picked over long long.
7376
7377 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7378 /// operates on extended vector types. Instead of producing an IntTy result,
7379 /// like a scalar comparison, a vector comparison produces a vector of integer
7380 /// types.
7383 BinaryOperatorKind Opc);
7386 BinaryOperatorKind Opc);
7389 BinaryOperatorKind Opc);
7390
7391 /// Context in which we're performing a usual arithmetic conversion.
7393 /// An arithmetic operation.
7395 /// A bitwise operation.
7397 /// A comparison.
7399 /// A conditional (?:) operator.
7401 /// A compound assignment expression.
7403 };
7404
7405 // type checking for sizeless vector binary operators.
7407 SourceLocation Loc, bool IsCompAssign,
7408 ArithConvKind OperationKind);
7409
7410 /// Type checking for matrix binary operators.
7413 bool IsCompAssign);
7415 SourceLocation Loc, bool IsCompAssign);
7416
7417 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
7418 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
7419 /// VLST) allowed?
7420 ///
7421 /// This will also return false if the two given types do not make sense from
7422 /// the perspective of SVE bitcasts.
7423 bool isValidSveBitcast(QualType srcType, QualType destType);
7424
7425 /// Are the two types matrix types and do they have the same dimensions i.e.
7426 /// do they have the same number of rows and the same number of columns?
7428
7429 bool areVectorTypesSameSize(QualType srcType, QualType destType);
7430
7431 /// Are the two types lax-compatible vector types? That is, given
7432 /// that one of them is a vector, do they have equal storage sizes,
7433 /// where the storage size is the number of elements times the element
7434 /// size?
7435 ///
7436 /// This will also return false if either of the types is neither a
7437 /// vector nor a real type.
7438 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
7439
7440 /// Is this a legal conversion between two types, one of which is
7441 /// known to be a vector type?
7442 bool isLaxVectorConversion(QualType srcType, QualType destType);
7443
7444 // This returns true if at least one of the types is an altivec vector.
7445 bool anyAltivecTypes(QualType srcType, QualType destType);
7446
7447 // type checking C++ declaration initializers (C++ [dcl.init]).
7448
7449 /// Check a cast of an unknown-any type. We intentionally only
7450 /// trigger this for C-style casts.
7454
7455 /// Force an expression with unknown-type to an expression of the
7456 /// given type.
7458
7459 /// Type-check an expression that's being passed to an
7460 /// __unknown_anytype parameter.
7462 QualType &paramType);
7463
7464 // CheckMatrixCast - Check type constraints for matrix casts.
7465 // We allow casting between matrixes of the same dimensions i.e. when they
7466 // have the same number of rows and column. Returns true if the cast is
7467 // invalid.
7468 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
7469 CastKind &Kind);
7470
7471 // CheckVectorCast - check type constraints for vectors.
7472 // Since vectors are an extension, there are no C standard reference for this.
7473 // We allow casting between vectors and integer datatypes of the same size.
7474 // returns true if the cast is invalid
7475 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
7476 CastKind &Kind);
7477
7478 /// Prepare `SplattedExpr` for a vector splat operation, adding
7479 /// implicit casts if necessary.
7480 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
7481
7482 // CheckExtVectorCast - check type constraints for extended vectors.
7483 // Since vectors are an extension, there are no C standard reference for this.
7484 // We allow casting between vectors and integer datatypes of the same size,
7485 // or vectors and the element type of that vector.
7486 // returns the cast expr
7488 CastKind &Kind);
7489
7492 }
7493
7494 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
7495 // functions and arrays to their respective pointers (C99 6.3.2.1).
7497
7498 /// CallExprUnaryConversions - a special case of an unary conversion
7499 /// performed on a function designator of a call expression.
7501
7502 // DefaultFunctionArrayConversion - converts functions and arrays
7503 // to their respective pointers (C99 6.3.2.1).
7505
7506 // DefaultFunctionArrayLvalueConversion - converts functions and
7507 // arrays to their respective pointers and performs the
7508 // lvalue-to-rvalue conversion.
7510 bool Diagnose = true);
7511
7512 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
7513 // the operand. This function is a no-op if the operand has a function type
7514 // or an array type.
7516
7517 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
7518 // do not have a prototype. Integer promotions are performed on each
7519 // argument, and arguments that have type float are promoted to double.
7521
7523 const FunctionProtoType *Proto,
7524 Expr *Fn);
7525
7526 // Used for determining in which context a type is allowed to be passed to a
7527 // vararg function.
7535
7536 /// Determine the degree of POD-ness for an expression.
7537 /// Incomplete types are considered POD, since this check can be performed
7538 /// when we're in an unevaluated context.
7540
7541 /// Check to see if the given expression is a valid argument to a variadic
7542 /// function, issuing a diagnostic if not.
7544
7545 /// GatherArgumentsForCall - Collector argument expressions for various
7546 /// form of call prototypes.
7548 const FunctionProtoType *Proto,
7549 unsigned FirstParam, ArrayRef<Expr *> Args,
7550 SmallVectorImpl<Expr *> &AllArgs,
7552 bool AllowExplicit = false,
7553 bool IsListInitialization = false);
7554
7555 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
7556 // will create a runtime trap if the resulting type is not a POD type.
7558 FunctionDecl *FDecl);
7559
7560 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
7561 // operands and then handles various conversions that are common to binary
7562 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
7563 // routine returns the first non-arithmetic type found. The client is
7564 // responsible for emitting appropriate error diagnostics.
7567
7568 /// AssignConvertType - All of the 'assignment' semantic checks return this
7569 /// enum to indicate whether the assignment was allowed. These checks are
7570 /// done for simple assignments, as well as initialization, return from
7571 /// function, argument passing, etc. The query is phrased in terms of a
7572 /// source and destination type.
7574 /// Compatible - the types are compatible according to the standard.
7576
7577 /// PointerToInt - The assignment converts a pointer to an int, which we
7578 /// accept as an extension.
7580
7581 /// IntToPointer - The assignment converts an int to a pointer, which we
7582 /// accept as an extension.
7584
7585 /// FunctionVoidPointer - The assignment is between a function pointer and
7586 /// void*, which the standard doesn't allow, but we accept as an extension.
7588
7589 /// IncompatiblePointer - The assignment is between two pointers types that
7590 /// are not compatible, but we accept them as an extension.
7592
7593 /// IncompatibleFunctionPointer - The assignment is between two function
7594 /// pointers types that are not compatible, but we accept them as an
7595 /// extension.
7597
7598 /// IncompatibleFunctionPointerStrict - The assignment is between two
7599 /// function pointer types that are not identical, but are compatible,
7600 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
7601 /// may trip an indirect call runtime check.
7603
7604 /// IncompatiblePointerSign - The assignment is between two pointers types
7605 /// which point to integers which have a different sign, but are otherwise
7606 /// identical. This is a subset of the above, but broken out because it's by
7607 /// far the most common case of incompatible pointers.
7609
7610 /// CompatiblePointerDiscardsQualifiers - The assignment discards
7611 /// c/v/r qualifiers, which we accept as an extension.
7613
7614 /// IncompatiblePointerDiscardsQualifiers - The assignment
7615 /// discards qualifiers that we don't permit to be discarded,
7616 /// like address spaces.
7618
7619 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
7620 /// changes address spaces in nested pointer types which is not allowed.
7621 /// For instance, converting __private int ** to __generic int ** is
7622 /// illegal even though __private could be converted to __generic.
7624
7625 /// IncompatibleNestedPointerQualifiers - The assignment is between two
7626 /// nested pointer types, and the qualifiers other than the first two
7627 /// levels differ e.g. char ** -> const char **, but we accept them as an
7628 /// extension.
7630
7631 /// IncompatibleVectors - The assignment is between two vector types that
7632 /// have the same size, which we accept as an extension.
7634
7635 /// IntToBlockPointer - The assignment converts an int to a block
7636 /// pointer. We disallow this.
7638
7639 /// IncompatibleBlockPointer - The assignment is between two block
7640 /// pointers types that are not compatible.
7642
7643 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
7644 /// id type and something else (that is incompatible with it). For example,
7645 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
7647
7648 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
7649 /// object with __weak qualifier.
7651
7652 /// Incompatible - We reject this conversion outright, it is invalid to
7653 /// represent it in the AST.
7656
7657 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
7658 /// assignment conversion type specified by ConvTy. This returns true if the
7659 /// conversion was invalid or false if the conversion was accepted.
7661 QualType DstType, QualType SrcType,
7662 Expr *SrcExpr, AssignmentAction Action,
7663 bool *Complained = nullptr);
7664
7665 /// CheckAssignmentConstraints - Perform type checking for assignment,
7666 /// argument passing, variable initialization, and function return values.
7667 /// C99 6.5.16.
7669 QualType LHSType,
7670 QualType RHSType);
7671
7672 /// Check assignment constraints and optionally prepare for a conversion of
7673 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
7674 /// is true.
7676 ExprResult &RHS, CastKind &Kind,
7677 bool ConvertRHS = true);
7678
7679 /// Check assignment constraints for an assignment of RHS to LHSType.
7680 ///
7681 /// \param LHSType The destination type for the assignment.
7682 /// \param RHS The source expression for the assignment.
7683 /// \param Diagnose If \c true, diagnostics may be produced when checking
7684 /// for assignability. If a diagnostic is produced, \p RHS will be
7685 /// set to ExprError(). Note that this function may still return
7686 /// without producing a diagnostic, even for an invalid assignment.
7687 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
7688 /// in an audited Core Foundation API and does not need to be checked
7689 /// for ARC retain issues.
7690 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
7691 /// conversions necessary to perform the assignment. If \c false,
7692 /// \p Diagnose must also be \c false.
7694 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
7695 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
7696
7697 // If the lhs type is a transparent union, check whether we
7698 // can initialize the transparent union with the given expression.
7700 ExprResult &RHS);
7701
7702 /// the following "Check" methods will return a valid/converted QualType
7703 /// or a null QualType (indicating an error diagnostic was issued).
7704
7705 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
7707 ExprResult &RHS);
7708
7709 /// Diagnose cases where a scalar was implicitly converted to a vector and
7710 /// diagnose the underlying types. Otherwise, diagnose the error
7711 /// as invalid vector logical operands for non-C++ cases.
7713 ExprResult &RHS);
7714
7716 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
7717 bool IsDivide);
7718 QualType CheckRemainderOperands( // C99 6.5.5
7720 bool IsCompAssign = false);
7721 QualType CheckAdditionOperands( // C99 6.5.6
7723 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
7726 QualType *CompLHSTy = nullptr);
7727 QualType CheckShiftOperands( // C99 6.5.7
7729 BinaryOperatorKind Opc, bool IsCompAssign = false);
7731 QualType CheckCompareOperands( // C99 6.5.8/9
7733 BinaryOperatorKind Opc);
7734 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
7736 BinaryOperatorKind Opc);
7737 QualType CheckLogicalOperands( // C99 6.5.[13,14]
7739 BinaryOperatorKind Opc);
7740 // CheckAssignmentOperands is used for both simple and compound assignment.
7741 // For simple assignment, pass both expressions and a null converted type.
7742 // For compound assignment, pass both expressions and the converted type.
7743 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
7744 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
7745 BinaryOperatorKind Opc);
7746
7747 /// To be used for checking whether the arguments being passed to
7748 /// function exceeds the number of parameters expected for it.
7749 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
7750 bool PartialOverloading = false) {
7751 // We check whether we're just after a comma in code-completion.
7752 if (NumArgs > 0 && PartialOverloading)
7753 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
7754 return NumArgs > NumParams;
7755 }
7756
7757 /// Whether the AST is currently being rebuilt to correct immediate
7758 /// invocations. Immediate invocation candidates and references to consteval
7759 /// functions aren't tracked when this is set.
7761
7766 }
7767
7768 /// Determines whether we are currently in a context that
7769 /// is not evaluated as per C++ [expr] p5.
7772 }
7773
7776 }
7777
7780 }
7781
7784 }
7785
7788 return (Ctx.Context ==
7791 }
7792
7793 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7795 assert(!ExprEvalContexts.empty() &&
7796 "Must be in an expression evaluation context");
7797 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7799 Ctx.DelayedDefaultInitializationContext)
7800 return Ctx.DelayedDefaultInitializationContext;
7801 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7802 Ctx.isUnevaluated())
7803 break;
7804 }
7805 return std::nullopt;
7806 }
7807
7808 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7810 assert(!ExprEvalContexts.empty() &&
7811 "Must be in an expression evaluation context");
7812 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
7813 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7815 !Ctx.DelayedDefaultInitializationContext && Res)
7816 break;
7817 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7818 Ctx.isUnevaluated())
7819 break;
7820 Res = Ctx.DelayedDefaultInitializationContext;
7821 }
7822 return Res;
7823 }
7824
7827 }
7828
7829 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
7830 /// SelfAssigned when inside a CXXMethodDecl.
7831 const FieldDecl *
7833
7835
7836 template <typename... Ts>
7838 const Ts &...Args) {
7839 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7841 }
7842
7843 template <typename... Ts>
7844 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
7845 const Ts &...Args) {
7846 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7848 }
7849
7850 /// Abstract class used to diagnose incomplete types.
7853
7854 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
7855 virtual ~TypeDiagnoser() {}
7856 };
7857
7858 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
7859 protected:
7860 unsigned DiagID;
7861 std::tuple<const Ts &...> Args;
7862
7863 template <std::size_t... Is>
7865 std::index_sequence<Is...>) const {
7866 // Apply all tuple elements to the builder in order.
7867 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
7868 (void)Dummy;
7869 }
7870
7871 public:
7872 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7873 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
7874 assert(DiagID != 0 && "no diagnostic for type diagnoser");
7875 }
7876
7877 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7878 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
7879 emit(DB, std::index_sequence_for<Ts...>());
7880 DB << T;
7881 }
7882 };
7883
7884 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
7885 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
7886 /// For example, a diagnostic with no other parameters would generally have
7887 /// the form "...%select{incomplete|sizeless}0 type %1...".
7888 template <typename... Ts>
7890 public:
7891 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7892 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
7893
7894 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7895 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
7896 this->emit(DB, std::index_sequence_for<Ts...>());
7897 DB << T->isSizelessType() << T;
7898 }
7899 };
7900
7901 /// Check an argument list for placeholders that we won't try to
7902 /// handle later.
7904
7905 /// The C++ "std::source_location::__impl" struct, defined in
7906 /// <source_location>.
7908
7909 /// A stack of expression evaluation contexts.
7911
7912 // Set of failed immediate invocations to avoid double diagnosing.
7914
7915 /// List of SourceLocations where 'self' is implicitly retained inside a
7916 /// block.
7919
7920 /// Do an explicit extend of the given block pointer if we're in ARC.
7922
7923 std::vector<std::pair<QualType, unsigned>> ExcessPrecisionNotSatisfied;
7926
7927private:
7928 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
7929
7930 /// Methods for marking which expressions involve dereferencing a pointer
7931 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
7932 /// they are parsed, meaning that a noderef pointer may not be accessed. For
7933 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
7934 /// `*p`, but need to check that `address of` is called on it. This requires
7935 /// keeping a container of all pending expressions and checking if the address
7936 /// of them are eventually taken.
7937 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
7938 void CheckAddressOfNoDeref(const Expr *E);
7939
7940 ///@}
7941
7942 //
7943 //
7944 // -------------------------------------------------------------------------
7945 //
7946 //
7947
7948 /// \name C++ Expressions
7949 /// Implementations are in SemaExprCXX.cpp
7950 ///@{
7951
7952public:
7953 /// The C++ "std::bad_alloc" class, which is defined by the C++
7954 /// standard library.
7956
7957 /// The C++ "std::align_val_t" enum class, which is defined by the C++
7958 /// standard library.
7960
7961 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
7963
7964 /// A flag to remember whether the implicit forms of operator new and delete
7965 /// have been declared.
7967
7968 /// Delete-expressions to be analyzed at the end of translation unit
7969 ///
7970 /// This list contains class members, and locations of delete-expressions
7971 /// that could not be proven as to whether they mismatch with new-expression
7972 /// used in initializer of the field.
7973 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
7974
7975 /// Handle the result of the special case name lookup for inheriting
7976 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
7977 /// constructor names in member using declarations, even if 'X' is not the
7978 /// name of the corresponding type.
7980 SourceLocation NameLoc,
7981 const IdentifierInfo &Name);
7982
7984 SourceLocation NameLoc, Scope *S,
7985 CXXScopeSpec &SS, bool EnteringContext);
7987 Scope *S, CXXScopeSpec &SS,
7988 ParsedType ObjectType, bool EnteringContext);
7989
7991 ParsedType ObjectType);
7992
7993 /// Build a C++ typeid expression with a type operand.
7994 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
7995 TypeSourceInfo *Operand, SourceLocation RParenLoc);
7996
7997 /// Build a C++ typeid expression with an expression operand.
7998 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
7999 Expr *Operand, SourceLocation RParenLoc);
8000
8001 /// ActOnCXXTypeid - Parse typeid( something ).
8003 bool isType, void *TyOrExpr,
8004 SourceLocation RParenLoc);
8005
8006 /// Build a Microsoft __uuidof expression with a type operand.
8007 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8008 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8009
8010 /// Build a Microsoft __uuidof expression with an expression operand.
8011 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8012 Expr *Operand, SourceLocation RParenLoc);
8013
8014 /// ActOnCXXUuidof - Parse __uuidof( something ).
8016 bool isType, void *TyOrExpr,
8017 SourceLocation RParenLoc);
8018
8019 //// ActOnCXXThis - Parse 'this' pointer.
8021
8022 /// Check whether the type of 'this' is valid in the current context.
8024
8025 /// Build a CXXThisExpr and mark it referenced in the current context.
8027 void MarkThisReferenced(CXXThisExpr *This);
8028
8029 /// Try to retrieve the type of the 'this' pointer.
8030 ///
8031 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8033
8034 /// When non-NULL, the C++ 'this' expression is allowed despite the
8035 /// current context not being a non-static member function. In such cases,
8036 /// this provides the type used for 'this'.
8038
8039 /// RAII object used to temporarily allow the C++ 'this' expression
8040 /// to be used, with the given qualifiers on the current class type.
8042 Sema &S;
8043 QualType OldCXXThisTypeOverride;
8044 bool Enabled;
8045
8046 public:
8047 /// Introduce a new scope where 'this' may be allowed (when enabled),
8048 /// using the given declaration (which is either a class template or a
8049 /// class) along with the given qualifiers.
8050 /// along with the qualifiers placed on '*this'.
8051 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8052 bool Enabled = true);
8053
8055 };
8056
8057 /// Make sure the value of 'this' is actually available in the current
8058 /// context, if it is a potentially evaluated context.
8059 ///
8060 /// \param Loc The location at which the capture of 'this' occurs.
8061 ///
8062 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8063 /// capture list.
8064 ///
8065 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8066 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8067 /// This is useful when enclosing lambdas must speculatively capture
8068 /// 'this' that may or may not be used in certain specializations of
8069 /// a nested generic lambda (depending on whether the name resolves to
8070 /// a non-static member function or a static function).
8071 /// \return returns 'true' if failed, 'false' if success.
8073 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8074 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8075 bool ByCopy = false);
8076
8077 /// Determine whether the given type is the type of *this that is used
8078 /// outside of the body of a member function for a type that is currently
8079 /// being defined.
8081
8082 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8084
8085 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8087
8088 //// ActOnCXXThrow - Parse throw expressions.
8091 bool IsThrownVarInScope);
8092
8093 /// CheckCXXThrowOperand - Validate the operand of a throw.
8094 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8095
8096 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8097 /// Can be interpreted either as function-style casting ("int(x)")
8098 /// or class type construction ("ClassType(x,y,z)")
8099 /// or creation of a value-initialized type ("int()").
8101 SourceLocation LParenOrBraceLoc,
8102 MultiExprArg Exprs,
8103 SourceLocation RParenOrBraceLoc,
8104 bool ListInitialization);
8105
8107 SourceLocation LParenLoc,
8108 MultiExprArg Exprs,
8109 SourceLocation RParenLoc,
8110 bool ListInitialization);
8111
8112 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8113 ///
8114 /// E.g.:
8115 /// @code new (memory) int[size][4] @endcode
8116 /// or
8117 /// @code ::new Foo(23, "hello") @endcode
8118 ///
8119 /// \param StartLoc The first location of the expression.
8120 /// \param UseGlobal True if 'new' was prefixed with '::'.
8121 /// \param PlacementLParen Opening paren of the placement arguments.
8122 /// \param PlacementArgs Placement new arguments.
8123 /// \param PlacementRParen Closing paren of the placement arguments.
8124 /// \param TypeIdParens If the type is in parens, the source range.
8125 /// \param D The type to be allocated, as well as array dimensions.
8126 /// \param Initializer The initializing expression or initializer-list, or
8127 /// null if there is none.
8128 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8129 SourceLocation PlacementLParen,
8130 MultiExprArg PlacementArgs,
8131 SourceLocation PlacementRParen,
8132 SourceRange TypeIdParens, Declarator &D,
8133 Expr *Initializer);
8135 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8136 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8137 SourceRange TypeIdParens, QualType AllocType,
8138 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8139 SourceRange DirectInitRange, Expr *Initializer);
8140
8141 /// Determine whether \p FD is an aligned allocation or deallocation
8142 /// function that is unavailable.
8144
8145 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8146 /// function that is unavailable.
8149
8150 /// Checks that a type is suitable as the allocated type
8151 /// in a new-expression.
8153 SourceRange R);
8154
8155 /// The scope in which to find allocation functions.
8157 /// Only look for allocation functions in the global scope.
8159 /// Only look for allocation functions in the scope of the
8160 /// allocated class.
8162 /// Look for allocation functions in both the global scope
8163 /// and in the scope of the allocated class.
8164 AFS_Both
8166
8167 /// Finds the overloads of operator new and delete that are appropriate
8168 /// for the allocation.
8170 AllocationFunctionScope NewScope,
8171 AllocationFunctionScope DeleteScope,
8172 QualType AllocType, bool IsArray,
8173 bool &PassAlignment, MultiExprArg PlaceArgs,
8174 FunctionDecl *&OperatorNew,
8175 FunctionDecl *&OperatorDelete,
8176 bool Diagnose = true);
8177
8178 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8179 /// delete. These are:
8180 /// @code
8181 /// // C++03:
8182 /// void* operator new(std::size_t) throw(std::bad_alloc);
8183 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8184 /// void operator delete(void *) throw();
8185 /// void operator delete[](void *) throw();
8186 /// // C++11:
8187 /// void* operator new(std::size_t);
8188 /// void* operator new[](std::size_t);
8189 /// void operator delete(void *) noexcept;
8190 /// void operator delete[](void *) noexcept;
8191 /// // C++1y:
8192 /// void* operator new(std::size_t);
8193 /// void* operator new[](std::size_t);
8194 /// void operator delete(void *) noexcept;
8195 /// void operator delete[](void *) noexcept;
8196 /// void operator delete(void *, std::size_t) noexcept;
8197 /// void operator delete[](void *, std::size_t) noexcept;
8198 /// @endcode
8199 /// Note that the placement and nothrow forms of new are *not* implicitly
8200 /// declared. Their use requires including <new>.
8203 ArrayRef<QualType> Params);
8204
8206 DeclarationName Name, FunctionDecl *&Operator,
8207 bool Diagnose = true, bool WantSize = false,
8208 bool WantAligned = false);
8210 bool CanProvideSize,
8211 bool Overaligned,
8212 DeclarationName Name);
8214 CXXRecordDecl *RD);
8215
8216 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8217 /// @code ::delete ptr; @endcode
8218 /// or
8219 /// @code delete [] ptr; @endcode
8220 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8221 bool ArrayForm, Expr *Operand);
8223 bool IsDelete, bool CallCanBeVirtual,
8224 bool WarnOnNonAbstractTypes,
8225 SourceLocation DtorLoc);
8226
8228 Expr *Operand, SourceLocation RParen);
8230 SourceLocation RParen);
8231
8233 SourceLocation OpLoc,
8234 tok::TokenKind OpKind,
8235 ParsedType &ObjectType,
8236 bool &MayBePseudoDestructor);
8237
8239 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8240 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8241 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8242
8244 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8245 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8246 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8247
8249 SourceLocation OpLoc,
8250 tok::TokenKind OpKind,
8251 SourceLocation TildeLoc,
8252 const DeclSpec &DS);
8253
8254 /// MaybeCreateExprWithCleanups - If the current full-expression
8255 /// requires any cleanups, surround it with a ExprWithCleanups node.
8256 /// Otherwise, just returns the passed-in expression.
8260
8261 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8262 return ActOnFinishFullExpr(
8263 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8264 }
8266 bool DiscardedValue, bool IsConstexpr = false,
8267 bool IsTemplateArgument = false);
8269
8270 /// Process the expression contained within a decltype. For such expressions,
8271 /// certain semantic checks on temporaries are delayed until this point, and
8272 /// are omitted for the 'topmost' call in the decltype expression. If the
8273 /// topmost call bound a temporary, strip that temporary off the expression.
8275
8276 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8277 bool IsUDSuffix);
8278
8280
8281 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8282 SourceLocation StmtLoc,
8283 ConditionKind CK);
8284
8285 /// Check the use of the given variable as a C++ condition in an if,
8286 /// while, do-while, or switch statement.
8288 SourceLocation StmtLoc, ConditionKind CK);
8289
8290 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8291 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8292
8293 /// Helper function to determine whether this is the (deprecated) C++
8294 /// conversion from a string literal to a pointer to non-const char or
8295 /// non-const wchar_t (for narrow and wide string literals,
8296 /// respectively).
8298
8299 /// PerformImplicitConversion - Perform an implicit conversion of the
8300 /// expression From to the type ToType using the pre-computed implicit
8301 /// conversion sequence ICS. Returns the converted
8302 /// expression. Action is the kind of conversion we're performing,
8303 /// used in the error message.
8305 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8306 AssignmentAction Action,
8308
8309 /// PerformImplicitConversion - Perform an implicit conversion of the
8310 /// expression From to the type ToType by following the standard
8311 /// conversion sequence SCS. Returns the converted
8312 /// expression. Flavor is the context in which we're performing this
8313 /// conversion, for use in error messages.
8315 const StandardConversionSequence &SCS,
8316 AssignmentAction Action,
8318
8319 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8320
8321 /// Parsed one of the type trait support pseudo-functions.
8324 SourceLocation RParenLoc);
8327 SourceLocation RParenLoc);
8328
8329 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8330 /// pseudo-functions.
8332 ParsedType LhsTy, Expr *DimExpr,
8333 SourceLocation RParen);
8334
8336 TypeSourceInfo *TSInfo, Expr *DimExpr,
8337 SourceLocation RParen);
8338
8339 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8340 /// pseudo-functions.
8342 Expr *Queried, SourceLocation RParen);
8343
8345 Expr *Queried, SourceLocation RParen);
8346
8348 ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc,
8349 bool isIndirect);
8351 ExprResult &RHS,
8352 SourceLocation QuestionLoc);
8353
8355 ExprResult &LHS, ExprResult &RHS,
8356 SourceLocation QuestionLoc);
8357
8358 /// Check the operands of ?: under C++ semantics.
8359 ///
8360 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8361 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8362 ///
8363 /// This function also implements GCC's vector extension and the
8364 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8365 /// permit the use of a?b:c where the type of a is that of a integer vector
8366 /// with the same number of elements and size as the vectors of b and c. If
8367 /// one of either b or c is a scalar it is implicitly converted to match the
8368 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8369 /// c are scalars, then b and c are checked and converted to the type of a if
8370 /// possible.
8371 ///
8372 /// The expressions are evaluated differently for GCC's and OpenCL's
8373 /// extensions. For the GCC extension, the ?: operator is evaluated as
8374 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8375 /// For the OpenCL extensions, the ?: operator is evaluated as
8376 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8377 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8379 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8380 ExprObjectKind &OK, SourceLocation questionLoc);
8381
8382 /// Find a merged pointer type and convert the two expressions to it.
8383 ///
8384 /// This finds the composite pointer type for \p E1 and \p E2 according to
8385 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8386 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8387 /// ConvertArgs is \c true).
8388 ///
8389 /// \param Loc The location of the operator requiring these two expressions to
8390 /// be converted to the composite pointer type.
8391 ///
8392 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8393 /// type.
8395 bool ConvertArgs = true);
8397 ExprResult &E2, bool ConvertArgs = true) {
8398 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8399 QualType Composite =
8400 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8401 E1 = E1Tmp;
8402 E2 = E2Tmp;
8403 return Composite;
8404 }
8405
8406 /// MaybeBindToTemporary - If the passed in expression has a record type with
8407 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8408 /// it simply returns the passed in expression.
8410
8411 /// IgnoredValueConversions - Given that an expression's result is
8412 /// syntactically ignored, perform any conversions that are
8413 /// required.
8415
8417
8418 /// Process any TypoExprs in the given Expr and its children,
8419 /// generating diagnostics as appropriate and returning a new Expr if there
8420 /// were typos that were all successfully corrected and ExprError if one or
8421 /// more typos could not be corrected.
8422 ///
8423 /// \param E The Expr to check for TypoExprs.
8424 ///
8425 /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
8426 /// initializer.
8427 ///
8428 /// \param RecoverUncorrectedTypos If true, when typo correction fails, it
8429 /// will rebuild the given Expr with all TypoExprs degraded to RecoveryExprs.
8430 ///
8431 /// \param Filter A function applied to a newly rebuilt Expr to determine if
8432 /// it is an acceptable/usable result from a single combination of typo
8433 /// corrections. As long as the filter returns ExprError, different
8434 /// combinations of corrections will be tried until all are exhausted.
8436 Expr *E, VarDecl *InitDecl = nullptr,
8437 bool RecoverUncorrectedTypos = false,
8438 llvm::function_ref<ExprResult(Expr *)> Filter =
8439 [](Expr *E) -> ExprResult { return E; });
8440
8442 ExprResult ER, VarDecl *InitDecl = nullptr,
8443 bool RecoverUncorrectedTypos = false,
8444 llvm::function_ref<ExprResult(Expr *)> Filter =
8445 [](Expr *E) -> ExprResult { return E; }) {
8446 return ER.isInvalid()
8447 ? ER
8448 : CorrectDelayedTyposInExpr(ER.get(), InitDecl,
8449 RecoverUncorrectedTypos, Filter);
8450 }
8451
8452 /// Describes the result of an "if-exists" condition check.
8454 /// The symbol exists.
8456
8457 /// The symbol does not exist.
8459
8460 /// The name is a dependent name, so the results will differ
8461 /// from one instantiation to the next.
8463
8464 /// An error occurred.
8465 IER_Error
8467
8470 const DeclarationNameInfo &TargetNameInfo);
8471
8473 SourceLocation KeywordLoc,
8474 bool IsIfExists, CXXScopeSpec &SS,
8475 UnqualifiedId &Name);
8476
8479 ArrayRef<ParmVarDecl *> LocalParameters,
8480 Scope *BodyScope);
8484 CXXScopeSpec &SS,
8485 SourceLocation NameLoc,
8486 const IdentifierInfo *TypeName,
8487 TemplateIdAnnotation *TemplateId);
8489 SourceLocation NoexceptLoc);
8491 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8492 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8495 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8499 bool IsSatisfied, SourceLocation NoexceptLoc,
8506 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8507 const ASTConstraintSatisfaction &Satisfaction);
8510 SourceLocation LParenLoc,
8511 ArrayRef<ParmVarDecl *> LocalParameters,
8512 SourceLocation RParenLoc,
8514 SourceLocation ClosingBraceLoc);
8515
8516private:
8517 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8518 bool IsDelete);
8519
8520 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8521 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8522 bool DeleteWasArrayForm);
8523
8524 ///@}
8525
8526 //
8527 //
8528 // -------------------------------------------------------------------------
8529 //
8530 //
8531
8532 /// \name Member Access Expressions
8533 /// Implementations are in SemaExprMember.cpp
8534 ///@{
8535
8536public:
8537 /// Check whether an expression might be an implicit class member access.
8539 bool IsAddressOfOperand);
8540
8541 /// Builds an expression which might be an implicit member expression.
8543 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
8544 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
8545
8546 /// Builds an implicit member access expression. The current context
8547 /// is known to be an instance method, and the given unqualified lookup
8548 /// set is known to contain only instance members, at least one of which
8549 /// is from an appropriate type.
8551 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8552 LookupResult &R,
8553 const TemplateArgumentListInfo *TemplateArgs,
8554 bool IsDefiniteInstance, const Scope *S);
8555
8557 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
8558 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8559 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8560 const TemplateArgumentListInfo *TemplateArgs);
8561
8562 /// The main callback when the parser finds something like
8563 /// expression . [nested-name-specifier] identifier
8564 /// expression -> [nested-name-specifier] identifier
8565 /// where 'identifier' encompasses a fairly broad spectrum of
8566 /// possibilities, including destructor and operator references.
8567 ///
8568 /// \param OpKind either tok::arrow or tok::period
8569 /// \param ObjCImpDecl the current Objective-C \@implementation
8570 /// decl; this is an ugly hack around the fact that Objective-C
8571 /// \@implementations aren't properly put in the context chain
8573 tok::TokenKind OpKind, CXXScopeSpec &SS,
8574 SourceLocation TemplateKWLoc,
8575 UnqualifiedId &Member, Decl *ObjCImpDecl);
8576
8577 MemberExpr *
8578 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
8579 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
8580 ValueDecl *Member, DeclAccessPair FoundDecl,
8581 bool HadMultipleCandidates,
8582 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
8584 const TemplateArgumentListInfo *TemplateArgs = nullptr);
8585
8586 // Check whether the declarations we found through a nested-name
8587 // specifier in a member expression are actually members of the base
8588 // type. The restriction here is:
8589 //
8590 // C++ [expr.ref]p2:
8591 // ... In these cases, the id-expression shall name a
8592 // member of the class or of one of its base classes.
8593 //
8594 // So it's perfectly legitimate for the nested-name specifier to name
8595 // an unrelated class, and for us to find an overload set including
8596 // decls from classes which are not superclasses, as long as the decl
8597 // we actually pick through overload resolution is from a superclass.
8598 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
8599 const CXXScopeSpec &SS,
8600 const LookupResult &R);
8601
8602 // This struct is for use by ActOnMemberAccess to allow
8603 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
8604 // changing the access operator from a '.' to a '->' (to see if that is the
8605 // change needed to fix an error about an unknown member, e.g. when the class
8606 // defines a custom operator->).
8611 };
8612
8614 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
8615 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8616 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8617 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
8618 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8619
8622 bool IsArrow, const CXXScopeSpec &SS,
8623 SourceLocation TemplateKWLoc,
8624 NamedDecl *FirstQualifierInScope, LookupResult &R,
8625 const TemplateArgumentListInfo *TemplateArgs,
8626 const Scope *S, bool SuppressQualifierCheck = false,
8627 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8628
8629 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
8630 SourceLocation OpLoc,
8631 const CXXScopeSpec &SS, FieldDecl *Field,
8632 DeclAccessPair FoundDecl,
8633 const DeclarationNameInfo &MemberNameInfo);
8634
8635 /// Perform conversions on the LHS of a member access expression.
8637
8639 const CXXScopeSpec &SS, SourceLocation nameLoc,
8640 IndirectFieldDecl *indirectField,
8641 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
8642 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
8643
8644private:
8645 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
8646
8647 ///@}
8648
8649 //
8650 //
8651 // -------------------------------------------------------------------------
8652 //
8653 //
8654
8655 /// \name Initializers
8656 /// Implementations are in SemaInit.cpp
8657 ///@{
8658
8659public:
8660 /// Stack of types that correspond to the parameter entities that are
8661 /// currently being copy-initialized. Can be empty.
8663
8664 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
8666
8667 bool IsStringInit(Expr *Init, const ArrayType *AT);
8668
8669 /// Determine whether we can perform aggregate initialization for the purposes
8670 /// of overload resolution.
8672 const InitializedEntity &Entity, InitListExpr *From);
8673
8675 SourceLocation EqualOrColonLoc,
8676 bool GNUSyntax, ExprResult Init);
8677
8678 /// Check that the lifetime of the initializer (and its subobjects) is
8679 /// sufficient for initializing the entity, and perform lifetime extension
8680 /// (when permitted) if not.
8682
8685 bool BoundToLvalueReference);
8686
8687 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
8688 /// it as an xvalue. In C++98, the result will still be a prvalue, because
8689 /// we don't have xvalues there.
8691
8695
8699 SourceLocation EqualLoc, ExprResult Init,
8700 bool TopLevelOfInitList = false,
8701 bool AllowExplicit = false);
8702
8704 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
8706
8707 ///@}
8708
8709 //
8710 //
8711 // -------------------------------------------------------------------------
8712 //
8713 //
8714
8715 /// \name C++ Lambda Expressions
8716 /// Implementations are in SemaLambda.cpp
8717 ///@{
8718
8719public:
8720 /// Create a new lambda closure type.
8722 TypeSourceInfo *Info,
8723 unsigned LambdaDependencyKind,
8724 LambdaCaptureDefault CaptureDefault);
8725
8726 /// Number lambda for linkage purposes if necessary.
8728 std::optional<CXXRecordDecl::LambdaNumbering>
8729 NumberingOverride = std::nullopt);
8730
8731 /// Endow the lambda scope info with the relevant properties.
8732 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
8733 SourceRange IntroducerRange,
8734 LambdaCaptureDefault CaptureDefault,
8735 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
8736 bool Mutable);
8737
8740
8742 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
8743 TemplateParameterList *TemplateParams);
8744
8746 CXXMethodDecl *Method, SourceLocation LambdaLoc,
8747 SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause,
8748 TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind,
8750 bool HasExplicitResultType);
8751
8752 /// Returns true if the explicit object parameter was invalid.
8754 SourceLocation CallLoc);
8755
8756 /// Perform initialization analysis of the init-capture and perform
8757 /// any implicit conversions such as an lvalue-to-rvalue conversion if
8758 /// not being used to initialize a reference.
8760 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8763 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
8765 }
8767 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8768 std::optional<unsigned> NumExpansions, IdentifierInfo *Id,
8769 bool DirectInit, Expr *&Init);
8770
8771 /// Create a dummy variable within the declcontext of the lambda's
8772 /// call operator, for name lookup purposes for a lambda init capture.
8773 ///
8774 /// CodeGen handles emission of lambda captures, ignoring these dummy
8775 /// variables appropriately.
8777 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
8778 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
8779
8780 /// Add an init-capture to a lambda scope.
8781 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
8782
8783 /// Note that we have finished the explicit captures for the
8784 /// given lambda.
8786
8787 /// Deduce a block or lambda's return type based on the return
8788 /// statements present in the body.
8790
8791 /// Once the Lambdas capture are known, we can start to create the closure,
8792 /// call operator method, and keep track of the captures.
8793 /// We do the capture lookup here, but they are not actually captured until
8794 /// after we know what the qualifiers of the call operator are.
8796 Scope *CurContext);
8797
8798 /// This is called after parsing the explicit template parameter list
8799 /// on a lambda (if it exists) in C++2a.
8801 SourceLocation LAngleLoc,
8802 ArrayRef<NamedDecl *> TParams,
8803 SourceLocation RAngleLoc,
8804 ExprResult RequiresClause);
8805
8807 SourceLocation MutableLoc);
8808
8810 Scope *LambdaScope,
8812
8813 /// ActOnStartOfLambdaDefinition - This is called just before we start
8814 /// parsing the body of a lambda; it analyzes the explicit captures and
8815 /// arguments, and sets up various data-structures for the body of the
8816 /// lambda.
8818 Declarator &ParamInfo, const DeclSpec &DS);
8819
8820 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
8821 /// is invoked to pop the information about the lambda.
8822 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
8823 bool IsInstantiation = false);
8824
8825 /// ActOnLambdaExpr - This is called when the body of a lambda expression
8826 /// was successfully completed.
8828
8829 /// Does copying/destroying the captured variable have side effects?
8830 bool CaptureHasSideEffects(const sema::Capture &From);
8831
8832 /// Diagnose if an explicit lambda capture is unused. Returns true if a
8833 /// diagnostic is emitted.
8834 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
8835 const sema::Capture &From);
8836
8837 /// Build a FieldDecl suitable to hold the given capture.
8839
8840 /// Initialize the given capture with a suitable expression.
8842 SourceLocation ImplicitCaptureLoc,
8843 bool IsOpenMPMapping = false);
8844
8845 /// Complete a lambda-expression having processed and attached the
8846 /// lambda body.
8849
8850 /// Get the return type to use for a lambda's conversion function(s) to
8851 /// function pointer type, given the type of the call operator.
8852 QualType
8854 CallingConv CC);
8855
8857 SourceLocation ConvLocation,
8858 CXXConversionDecl *Conv, Expr *Src);
8859
8861 : private FunctionScopeRAII {
8862 public:
8864 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
8866 bool ShouldAddDeclsFromParentScope = true);
8867 };
8868
8869 /// Compute the mangling number context for a lambda expression or
8870 /// block literal. Also return the extra mangling decl if any.
8871 ///
8872 /// \param DC - The DeclContext containing the lambda expression or
8873 /// block literal.
8874 std::tuple<MangleNumberingContext *, Decl *>
8876
8877 ///@}
8878
8879 //
8880 //
8881 // -------------------------------------------------------------------------
8882 //
8883 //
8884
8885 /// \name Name Lookup
8886 ///
8887 /// These routines provide name lookup that is used during semantic
8888 /// analysis to resolve the various kinds of names (identifiers,
8889 /// overloaded operator names, constructor names, etc.) into zero or
8890 /// more declarations within a particular scope. The major entry
8891 /// points are LookupName, which performs unqualified name lookup,
8892 /// and LookupQualifiedName, which performs qualified name lookup.
8893 ///
8894 /// All name lookup is performed based on some specific criteria,
8895 /// which specify what names will be visible to name lookup and how
8896 /// far name lookup should work. These criteria are important both
8897 /// for capturing language semantics (certain lookups will ignore
8898 /// certain names, for example) and for performance, since name
8899 /// lookup is often a bottleneck in the compilation of C++. Name
8900 /// lookup criteria is specified via the LookupCriteria enumeration.
8901 ///
8902 /// The results of name lookup can vary based on the kind of name
8903 /// lookup performed, the current language, and the translation
8904 /// unit. In C, for example, name lookup will either return nothing
8905 /// (no entity found) or a single declaration. In C++, name lookup
8906 /// can additionally refer to a set of overloaded functions or
8907 /// result in an ambiguity. All of the possible results of name
8908 /// lookup are captured by the LookupResult class, which provides
8909 /// the ability to distinguish among them.
8910 ///
8911 /// Implementations are in SemaLookup.cpp
8912 ///@{
8913
8914public:
8915 /// Tracks whether we are in a context where typo correction is
8916 /// disabled.
8918
8919 /// The number of typos corrected by CorrectTypo.
8921
8922 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
8923 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
8924
8925 /// A cache containing identifiers for which typo correction failed and
8926 /// their locations, so that repeated attempts to correct an identifier in a
8927 /// given location are ignored if typo correction already failed for it.
8929
8930 /// SpecialMemberOverloadResult - The overloading result for a special member
8931 /// function.
8932 ///
8933 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
8934 /// integer are used to determine whether overload resolution succeeded.
8936 public:
8937 enum Kind { NoMemberOrDeleted, Ambiguous, Success };
8938
8939 private:
8940 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
8941
8942 public:
8945 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
8946
8947 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
8948 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
8949
8950 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
8951 void setKind(Kind K) { Pair.setInt(K); }
8952 };
8953
8954 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
8956 public:
8957 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
8958 : FastFoldingSetNode(ID) {}
8959 };
8960
8961 /// A cache of special member function overload resolution results
8962 /// for C++ records.
8963 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
8964
8965 /// Holds TypoExprs that are created from `createDelayedTypo`. This is used by
8966 /// `TransformTypos` in order to keep track of any TypoExprs that are created
8967 /// recursively during typo correction and wipe them away if the correction
8968 /// fails.
8970
8972
8973 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
8974 // TODO: make this is a typesafe union.
8977
8978 /// Describes the kind of name lookup to perform.
8980 /// Ordinary name lookup, which finds ordinary names (functions,
8981 /// variables, typedefs, etc.) in C and most kinds of names
8982 /// (functions, variables, members, types, etc.) in C++.
8984 /// Tag name lookup, which finds the names of enums, classes,
8985 /// structs, and unions.
8987 /// Label name lookup.
8989 /// Member name lookup, which finds the names of
8990 /// class/struct/union members.
8992 /// Look up of an operator name (e.g., operator+) for use with
8993 /// operator overloading. This lookup is similar to ordinary name
8994 /// lookup, but will ignore any declarations that are class members.
8996 /// Look up a name following ~ in a destructor name. This is an ordinary
8997 /// lookup, but prefers tags to typedefs.
8999 /// Look up of a name that precedes the '::' scope resolution
9000 /// operator in C++. This lookup completely ignores operator, object,
9001 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9003 /// Look up a namespace name within a C++ using directive or
9004 /// namespace alias definition, ignoring non-namespace names (C++
9005 /// [basic.lookup.udir]p1).
9007 /// Look up all declarations in a scope with the given name,
9008 /// including resolved using declarations. This is appropriate
9009 /// for checking redeclarations for a using declaration.
9011 /// Look up an ordinary name that is going to be redeclared as a
9012 /// name with linkage. This lookup ignores any declarations that
9013 /// are outside of the current scope unless they have linkage. See
9014 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9016 /// Look up a friend of a local class. This lookup does not look
9017 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9019 /// Look up the name of an Objective-C protocol.
9021 /// Look up implicit 'self' parameter of an objective-c method.
9023 /// Look up the name of an OpenMP user-defined reduction operation.
9025 /// Look up the name of an OpenMP user-defined mapper.
9027 /// Look up any declaration with any name.
9030
9031 /// The possible outcomes of name lookup for a literal operator.
9033 /// The lookup resulted in an error.
9035 /// The lookup found no match but no diagnostic was issued.
9037 /// The lookup found a single 'cooked' literal operator, which
9038 /// expects a normal literal to be built and passed to it.
9040 /// The lookup found a single 'raw' literal operator, which expects
9041 /// a string literal containing the spelling of the literal token.
9043 /// The lookup found an overload set of literal operator templates,
9044 /// which expect the characters of the spelling of the literal token to be
9045 /// passed as a non-type template argument pack.
9047 /// The lookup found an overload set of literal operator templates,
9048 /// which expect the character type and characters of the spelling of the
9049 /// string literal token to be passed as template arguments.
9051 };
9052
9053 SpecialMemberOverloadResult
9055 bool VolatileArg, bool RValueThis, bool ConstThis,
9056 bool VolatileThis);
9057
9058 typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
9059 typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
9061
9063
9064 /// Look up a name, looking for a single declaration. Return
9065 /// null if the results were absent, ambiguous, or overloaded.
9066 ///
9067 /// It is preferable to use the elaborated form and explicitly handle
9068 /// ambiguity and overloaded.
9071 LookupNameKind NameKind,
9072 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
9073
9074 /// Lookup a builtin function, when name lookup would otherwise
9075 /// fail.
9076 bool LookupBuiltin(LookupResult &R);
9077 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9078
9079 /// Perform unqualified name lookup starting from a given
9080 /// scope.
9081 ///
9082 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9083 /// used to find names within the current scope. For example, 'x' in
9084 /// @code
9085 /// int x;
9086 /// int f() {
9087 /// return x; // unqualified name look finds 'x' in the global scope
9088 /// }
9089 /// @endcode
9090 ///
9091 /// Different lookup criteria can find different names. For example, a
9092 /// particular scope can have both a struct and a function of the same
9093 /// name, and each can be found by certain lookup criteria. For more
9094 /// information about lookup criteria, see the documentation for the
9095 /// class LookupCriteria.
9096 ///
9097 /// @param S The scope from which unqualified name lookup will
9098 /// begin. If the lookup criteria permits, name lookup may also search
9099 /// in the parent scopes.
9100 ///
9101 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9102 /// look up and the lookup kind), and is updated with the results of lookup
9103 /// including zero or more declarations and possibly additional information
9104 /// used to diagnose ambiguities.
9105 ///
9106 /// @returns \c true if lookup succeeded and false otherwise.
9107 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9108 bool ForceNoCPlusPlus = false);
9109
9110 /// Perform qualified name lookup into a given context.
9111 ///
9112 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9113 /// names when the context of those names is explicit specified, e.g.,
9114 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9115 ///
9116 /// Different lookup criteria can find different names. For example, a
9117 /// particular scope can have both a struct and a function of the same
9118 /// name, and each can be found by certain lookup criteria. For more
9119 /// information about lookup criteria, see the documentation for the
9120 /// class LookupCriteria.
9121 ///
9122 /// \param R captures both the lookup criteria and any lookup results found.
9123 ///
9124 /// \param LookupCtx The context in which qualified name lookup will
9125 /// search. If the lookup criteria permits, name lookup may also search
9126 /// in the parent contexts or (for C++ classes) base classes.
9127 ///
9128 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9129 /// occurs as part of unqualified name lookup.
9130 ///
9131 /// \returns true if lookup succeeded, false if it failed.
9132 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9133 bool InUnqualifiedLookup = false);
9134
9135 /// Performs qualified name lookup or special type of lookup for
9136 /// "__super::" scope specifier.
9137 ///
9138 /// This routine is a convenience overload meant to be called from contexts
9139 /// that need to perform a qualified name lookup with an optional C++ scope
9140 /// specifier that might require special kind of lookup.
9141 ///
9142 /// \param R captures both the lookup criteria and any lookup results found.
9143 ///
9144 /// \param LookupCtx The context in which qualified name lookup will
9145 /// search.
9146 ///
9147 /// \param SS An optional C++ scope-specifier.
9148 ///
9149 /// \returns true if lookup succeeded, false if it failed.
9150 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9151 CXXScopeSpec &SS);
9152
9153 /// Performs name lookup for a name that was parsed in the
9154 /// source code, and may contain a C++ scope specifier.
9155 ///
9156 /// This routine is a convenience routine meant to be called from
9157 /// contexts that receive a name and an optional C++ scope specifier
9158 /// (e.g., "N::M::x"). It will then perform either qualified or
9159 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9160 /// respectively) on the given name and return those results. It will
9161 /// perform a special type of lookup for "__super::" scope specifier.
9162 ///
9163 /// @param S The scope from which unqualified name lookup will
9164 /// begin.
9165 ///
9166 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9167 ///
9168 /// @param EnteringContext Indicates whether we are going to enter the
9169 /// context of the scope-specifier SS (if present).
9170 ///
9171 /// @returns True if any decls were found (but possibly ambiguous)
9173 QualType ObjectType, bool AllowBuiltinCreation = false,
9174 bool EnteringContext = false);
9175
9176 /// Perform qualified name lookup into all base classes of the given
9177 /// class.
9178 ///
9179 /// \param R captures both the lookup criteria and any lookup results found.
9180 ///
9181 /// \param Class The context in which qualified name lookup will
9182 /// search. Name lookup will search in all base classes merging the results.
9183 ///
9184 /// @returns True if any decls were found (but possibly ambiguous)
9186
9188 UnresolvedSetImpl &Functions);
9189
9190 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9191 /// If GnuLabelLoc is a valid source location, then this is a definition
9192 /// of an __label__ label name, otherwise it is a normal label definition
9193 /// or use.
9195 SourceLocation GnuLabelLoc = SourceLocation());
9196
9197 /// Look up the constructors for the given class.
9199
9200 /// Look up the default constructor for the given class.
9202
9203 /// Look up the copying constructor for the given class.
9205 unsigned Quals);
9206
9207 /// Look up the copying assignment operator for the given class.
9209 bool RValueThis, unsigned ThisQuals);
9210
9211 /// Look up the moving constructor for the given class.
9213 unsigned Quals);
9214
9215 /// Look up the moving assignment operator for the given class.
9217 bool RValueThis, unsigned ThisQuals);
9218
9219 /// Look for the destructor of the given class.
9220 ///
9221 /// During semantic analysis, this routine should be used in lieu of
9222 /// CXXRecordDecl::getDestructor().
9223 ///
9224 /// \returns The destructor for this class.
9226
9227 /// Force the declaration of any implicitly-declared members of this
9228 /// class.
9230
9231 /// Make a merged definition of an existing hidden definition \p ND
9232 /// visible at the specified location.
9234
9235 /// Check ODR hashes for C/ObjC when merging types from modules.
9236 /// Differently from C++, actually parse the body and reject in case
9237 /// of a mismatch.
9238 template <typename T,
9239 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9241 if (Duplicate->getODRHash() != Previous->getODRHash())
9242 return false;
9243
9244 // Make the previous decl visible.
9246 return true;
9247 }
9248
9249 /// Get the set of additional modules that should be checked during
9250 /// name lookup. A module and its imports become visible when instanting a
9251 /// template defined within it.
9252 llvm::DenseSet<Module *> &getLookupModules();
9253
9254 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9256
9257 /// Determine if the template parameter \p D has a visible default argument.
9258 bool
9260 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9261 /// Determine if the template parameter \p D has a reachable default argument.
9263 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9264 /// Determine if the template parameter \p D has a reachable default argument.
9268
9269 /// Determine if there is a visible declaration of \p D that is an explicit
9270 /// specialization declaration for a specialization of a template. (For a
9271 /// member specialization, use hasVisibleMemberSpecialization.)
9273 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9274 /// Determine if there is a reachable declaration of \p D that is an explicit
9275 /// specialization declaration for a specialization of a template. (For a
9276 /// member specialization, use hasReachableMemberSpecialization.)
9278 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9279
9280 /// Determine if there is a visible declaration of \p D that is a member
9281 /// specialization declaration (as opposed to an instantiated declaration).
9283 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9284 /// Determine if there is a reachable declaration of \p D that is a member
9285 /// specialization declaration (as opposed to an instantiated declaration).
9287 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9288
9289 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9290
9291 /// Determine whether any declaration of an entity is visible.
9292 bool
9294 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9295 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9296 }
9297
9300 /// Determine whether any declaration of an entity is reachable.
9301 bool
9303 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9304 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9305 }
9307 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9308
9309 void diagnoseTypo(const TypoCorrection &Correction,
9310 const PartialDiagnostic &TypoDiag,
9311 bool ErrorRecovery = true);
9312
9313 /// Diagnose a successfully-corrected typo. Separated from the correction
9314 /// itself to allow external validation of the result, etc.
9315 ///
9316 /// \param Correction The result of performing typo correction.
9317 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9318 /// string added to it (and usually also a fixit).
9319 /// \param PrevNote A note to use when indicating the location of the entity
9320 /// to which we are correcting. Will have the correction string added
9321 /// to it.
9322 /// \param ErrorRecovery If \c true (the default), the caller is going to
9323 /// recover from the typo as if the corrected string had been typed.
9324 /// In this case, \c PDiag must be an error, and we will attach a fixit
9325 /// to it.
9326 void diagnoseTypo(const TypoCorrection &Correction,
9327 const PartialDiagnostic &TypoDiag,
9328 const PartialDiagnostic &PrevNote,
9329 bool ErrorRecovery = true);
9330
9331 /// Find the associated classes and namespaces for
9332 /// argument-dependent lookup for a call with the given set of
9333 /// arguments.
9334 ///
9335 /// This routine computes the sets of associated classes and associated
9336 /// namespaces searched by argument-dependent lookup
9337 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9339 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9340 AssociatedNamespaceSet &AssociatedNamespaces,
9341 AssociatedClassSet &AssociatedClasses);
9342
9343 /// Produce a diagnostic describing the ambiguity that resulted
9344 /// from name lookup.
9345 ///
9346 /// \param Result The result of the ambiguous lookup to be diagnosed.
9348
9349 /// LookupLiteralOperator - Determine which literal operator should be used
9350 /// for a user-defined literal, per C++11 [lex.ext].
9351 ///
9352 /// Normal overload resolution is not used to select which literal operator to
9353 /// call for a user-defined literal. Look up the provided literal operator
9354 /// name, and filter the results to the appropriate set for the given argument
9355 /// types.
9358 bool AllowRaw, bool AllowTemplate,
9359 bool AllowStringTemplate, bool DiagnoseMissing,
9360 StringLiteral *StringLit = nullptr);
9361
9363 ArrayRef<Expr *> Args, ADLResult &Functions);
9364
9367 bool IncludeGlobalScope = true,
9368 bool LoadExternal = true);
9371 bool IncludeGlobalScope = true,
9372 bool IncludeDependentBases = false,
9373 bool LoadExternal = true);
9374
9376 CTK_NonError, // CorrectTypo used in a non error recovery situation.
9377 CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
9379
9380 /// Try to "correct" a typo in the source code by finding
9381 /// visible declarations whose names are similar to the name that was
9382 /// present in the source code.
9383 ///
9384 /// \param TypoName the \c DeclarationNameInfo structure that contains
9385 /// the name that was present in the source code along with its location.
9386 ///
9387 /// \param LookupKind the name-lookup criteria used to search for the name.
9388 ///
9389 /// \param S the scope in which name lookup occurs.
9390 ///
9391 /// \param SS the nested-name-specifier that precedes the name we're
9392 /// looking for, if present.
9393 ///
9394 /// \param CCC A CorrectionCandidateCallback object that provides further
9395 /// validation of typo correction candidates. It also provides flags for
9396 /// determining the set of keywords permitted.
9397 ///
9398 /// \param MemberContext if non-NULL, the context in which to look for
9399 /// a member access expression.
9400 ///
9401 /// \param EnteringContext whether we're entering the context described by
9402 /// the nested-name-specifier SS.
9403 ///
9404 /// \param OPT when non-NULL, the search for visible declarations will
9405 /// also walk the protocols in the qualified interfaces of \p OPT.
9406 ///
9407 /// \returns a \c TypoCorrection containing the corrected name if the typo
9408 /// along with information such as the \c NamedDecl where the corrected name
9409 /// was declared, and any additional \c NestedNameSpecifier needed to access
9410 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9412 Sema::LookupNameKind LookupKind, Scope *S,
9414 CorrectTypoKind Mode,
9415 DeclContext *MemberContext = nullptr,
9416 bool EnteringContext = false,
9417 const ObjCObjectPointerType *OPT = nullptr,
9418 bool RecordFailure = true);
9419
9420 /// Try to "correct" a typo in the source code by finding
9421 /// visible declarations whose names are similar to the name that was
9422 /// present in the source code.
9423 ///
9424 /// \param TypoName the \c DeclarationNameInfo structure that contains
9425 /// the name that was present in the source code along with its location.
9426 ///
9427 /// \param LookupKind the name-lookup criteria used to search for the name.
9428 ///
9429 /// \param S the scope in which name lookup occurs.
9430 ///
9431 /// \param SS the nested-name-specifier that precedes the name we're
9432 /// looking for, if present.
9433 ///
9434 /// \param CCC A CorrectionCandidateCallback object that provides further
9435 /// validation of typo correction candidates. It also provides flags for
9436 /// determining the set of keywords permitted.
9437 ///
9438 /// \param TDG A TypoDiagnosticGenerator functor that will be used to print
9439 /// diagnostics when the actual typo correction is attempted.
9440 ///
9441 /// \param TRC A TypoRecoveryCallback functor that will be used to build an
9442 /// Expr from a typo correction candidate.
9443 ///
9444 /// \param MemberContext if non-NULL, the context in which to look for
9445 /// a member access expression.
9446 ///
9447 /// \param EnteringContext whether we're entering the context described by
9448 /// the nested-name-specifier SS.
9449 ///
9450 /// \param OPT when non-NULL, the search for visible declarations will
9451 /// also walk the protocols in the qualified interfaces of \p OPT.
9452 ///
9453 /// \returns a new \c TypoExpr that will later be replaced in the AST with an
9454 /// Expr representing the result of performing typo correction, or nullptr if
9455 /// typo correction is not possible. If nullptr is returned, no diagnostics
9456 /// will be emitted and it is the responsibility of the caller to emit any
9457 /// that are needed.
9459 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9462 CorrectTypoKind Mode, DeclContext *MemberContext = nullptr,
9463 bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr);
9464
9465 /// Kinds of missing import. Note, the values of these enumerators correspond
9466 /// to %select values in diagnostics.
9469 Definition,
9473 };
9474
9475 /// Diagnose that the specified declaration needs to be visible but
9476 /// isn't, and suggest a module import that would resolve the problem.
9478 MissingImportKind MIK, bool Recover = true);
9480 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9481 MissingImportKind MIK, bool Recover);
9482
9484 std::unique_ptr<TypoCorrectionConsumer> Consumer;
9487 TypoExprState();
9488 TypoExprState(TypoExprState &&other) noexcept;
9489 TypoExprState &operator=(TypoExprState &&other) noexcept;
9490 };
9491
9492 const TypoExprState &getTypoExprState(TypoExpr *TE) const;
9493
9494 /// Clears the state of the given TypoExpr.
9495 void clearDelayedTypo(TypoExpr *TE);
9496
9497 /// Called on #pragma clang __debug dump II
9499
9500 /// Called on #pragma clang __debug dump E
9501 void ActOnPragmaDump(Expr *E);
9502
9503private:
9504 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9505 //
9506 // The boolean value will be true to indicate that the namespace was loaded
9507 // from an AST/PCH file, or false otherwise.
9508 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9509
9510 /// Whether we have already loaded known namespaces from an extenal
9511 /// source.
9512 bool LoadedExternalKnownNamespaces;
9513
9514 bool CppLookupName(LookupResult &R, Scope *S);
9515
9516 /// Determine if we could use all the declarations in the module.
9517 bool isUsableModule(const Module *M);
9518
9519 /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
9520 /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
9521 /// should be skipped entirely.
9522 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9523 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9525 DeclContext *MemberContext, bool EnteringContext,
9526 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9527
9528 /// The set of unhandled TypoExprs and their associated state.
9529 llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
9530
9531 /// Creates a new TypoExpr AST node.
9532 TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
9535
9536 /// Cache for module units which is usable for current module.
9537 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9538
9539 /// Record the typo correction failure and return an empty correction.
9540 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9541 bool RecordFailure = true) {
9542 if (RecordFailure)
9543 TypoCorrectionFailures[Typo].insert(TypoLoc);
9544 return TypoCorrection();
9545 }
9546
9547 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9548
9549 /// Determine whether two declarations should be linked together, given that
9550 /// the old declaration might not be visible and the new declaration might
9551 /// not have external linkage.
9552 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9553 const NamedDecl *New) {
9554 if (isVisible(Old))
9555 return true;
9556 // See comment in below overload for why it's safe to compute the linkage
9557 // of the new declaration here.
9558 if (New->isExternallyDeclarable()) {
9559 assert(Old->isExternallyDeclarable() &&
9560 "should not have found a non-externally-declarable previous decl");
9561 return true;
9562 }
9563 return false;
9564 }
9565 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9566
9567 ///@}
9568
9569 //
9570 //
9571 // -------------------------------------------------------------------------
9572 //
9573 //
9574
9575 /// \name Modules
9576 /// Implementations are in SemaModule.cpp
9577 ///@{
9578
9579public:
9580 /// Get the module unit whose scope we are currently within.
9582 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9583 }
9584
9585 /// Is the module scope we are an implementation unit?
9587 return ModuleScopes.empty()
9588 ? false
9589 : ModuleScopes.back().Module->isModuleImplementation();
9590 }
9591
9592 // When loading a non-modular PCH files, this is used to restore module
9593 // visibility.
9595 VisibleModules.setVisible(Mod, ImportLoc);
9596 }
9597
9598 enum class ModuleDeclKind {
9599 Interface, ///< 'export module X;'
9600 Implementation, ///< 'module X;'
9601 PartitionInterface, ///< 'export module X:Y;'
9602 PartitionImplementation, ///< 'module X:Y;'
9603 };
9604
9605 /// An enumeration to represent the transition of states in parsing module
9606 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9607 /// an error in state transition, the state is set to NotACXX20Module.
9609 FirstDecl, ///< Parsing the first decl in a TU.
9610 GlobalFragment, ///< after 'module;' but before 'module X;'
9611 ImportAllowed, ///< after 'module X;' but before any non-import decl.
9612 ImportFinished, ///< after any non-import decl.
9613 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
9614 ///< non-import decl.
9615 PrivateFragmentImportFinished, ///< after 'module :private;' but a
9616 ///< non-import decl has already been seen.
9617 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
9618 };
9619
9620 /// The parser has processed a module-declaration that begins the definition
9621 /// of a module interface or implementation.
9623 SourceLocation ModuleLoc, ModuleDeclKind MDK,
9624 ModuleIdPath Path, ModuleIdPath Partition,
9625 ModuleImportState &ImportState);
9626
9627 /// The parser has processed a global-module-fragment declaration that begins
9628 /// the definition of the global module fragment of the current module unit.
9629 /// \param ModuleLoc The location of the 'module' keyword.
9631
9632 /// The parser has processed a private-module-fragment declaration that begins
9633 /// the definition of the private module fragment of the current module unit.
9634 /// \param ModuleLoc The location of the 'module' keyword.
9635 /// \param PrivateLoc The location of the 'private' keyword.
9637 SourceLocation PrivateLoc);
9638
9639 /// The parser has processed a module import declaration.
9640 ///
9641 /// \param StartLoc The location of the first token in the declaration. This
9642 /// could be the location of an '@', 'export', or 'import'.
9643 /// \param ExportLoc The location of the 'export' keyword, if any.
9644 /// \param ImportLoc The location of the 'import' keyword.
9645 /// \param Path The module toplevel name as an access path.
9646 /// \param IsPartition If the name is for a partition.
9648 SourceLocation ExportLoc,
9649 SourceLocation ImportLoc, ModuleIdPath Path,
9650 bool IsPartition = false);
9652 SourceLocation ExportLoc,
9653 SourceLocation ImportLoc, Module *M,
9654 ModuleIdPath Path = {});
9655
9656 /// The parser has processed a module import translated from a
9657 /// #include or similar preprocessing directive.
9658 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9659 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9660
9661 /// The parsed has entered a submodule.
9662 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
9663 /// The parser has left a submodule.
9664 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
9665
9666 /// Create an implicit import of the given module at the given
9667 /// source location, for error recovery, if possible.
9668 ///
9669 /// This routine is typically used when an entity found by name lookup
9670 /// is actually hidden within a module that we know about but the user
9671 /// has forgotten to import.
9673 Module *Mod);
9674
9675 /// We have parsed the start of an export declaration, including the '{'
9676 /// (if present).
9677 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
9678 SourceLocation LBraceLoc);
9679
9680 /// Complete the definition of an export declaration.
9681 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
9682 SourceLocation RBraceLoc);
9683
9684private:
9685 /// The parser has begun a translation unit to be compiled as a C++20
9686 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
9687 void HandleStartOfHeaderUnit();
9688
9689 struct ModuleScope {
9690 SourceLocation BeginLoc;
9691 clang::Module *Module = nullptr;
9692 VisibleModuleSet OuterVisibleModules;
9693 };
9694 /// The modules we're currently parsing.
9696
9697 /// For an interface unit, this is the implicitly imported interface unit.
9698 clang::Module *ThePrimaryInterface = nullptr;
9699
9700 /// The explicit global module fragment of the current translation unit.
9701 /// The explicit Global Module Fragment, as specified in C++
9702 /// [module.global.frag].
9703 clang::Module *TheGlobalModuleFragment = nullptr;
9704
9705 /// The implicit global module fragments of the current translation unit.
9706 ///
9707 /// The contents in the implicit global module fragment can't be discarded.
9708 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
9709
9710 /// Namespace definitions that we will export when they finish.
9711 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
9712
9713 /// In a C++ standard module, inline declarations require a definition to be
9714 /// present at the end of a definition domain. This set holds the decls to
9715 /// be checked at the end of the TU.
9716 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
9717
9718 /// Helper function to judge if we are in module purview.
9719 /// Return false if we are not in a module.
9720 bool isCurrentModulePurview() const;
9721
9722 /// Enter the scope of the explicit global module fragment.
9723 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
9724 /// Leave the scope of the explicit global module fragment.
9725 void PopGlobalModuleFragment();
9726
9727 /// Enter the scope of an implicit global module fragment.
9728 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
9729 /// Leave the scope of an implicit global module fragment.
9730 void PopImplicitGlobalModuleFragment();
9731
9732 VisibleModuleSet VisibleModules;
9733
9734 ///@}
9735
9736 //
9737 //
9738 // -------------------------------------------------------------------------
9739 //
9740 //
9741
9742 /// \name C++ Overloading
9743 /// Implementations are in SemaOverload.cpp
9744 ///@{
9745
9746public:
9747 /// Whether deferrable diagnostics should be deferred.
9748 bool DeferDiags = false;
9749
9750 /// RAII class to control scope of DeferDiags.
9752 Sema &S;
9753 bool SavedDeferDiags = false;
9754
9755 public:
9756 DeferDiagsRAII(Sema &S, bool DeferDiags)
9757 : S(S), SavedDeferDiags(S.DeferDiags) {
9758 S.DeferDiags = DeferDiags;
9759 }
9760 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
9761 };
9762
9763 /// Flag indicating if Sema is building a recovery call expression.
9764 ///
9765 /// This flag is used to avoid building recovery call expressions
9766 /// if Sema is already doing so, which would cause infinite recursions.
9768
9770 /// This is a legitimate overload: the existing declarations are
9771 /// functions or function templates with different signatures.
9773
9774 /// This is not an overload because the signature exactly matches
9775 /// an existing declaration.
9777
9778 /// This is not an overload because the lookup results contain a
9779 /// non-function.
9782
9783 /// Determine whether the given New declaration is an overload of the
9784 /// declarations in Old. This routine returns Ovl_Match or Ovl_NonFunction if
9785 /// New and Old cannot be overloaded, e.g., if New has the same signature as
9786 /// some function in Old (C++ 1.3.10) or if the Old declarations aren't
9787 /// functions (or function templates) at all. When it does return Ovl_Match or
9788 /// Ovl_NonFunction, MatchedDecl will point to the decl that New cannot be
9789 /// overloaded with. This decl may be a UsingShadowDecl on top of the
9790 /// underlying declaration.
9791 ///
9792 /// Example: Given the following input:
9793 ///
9794 /// void f(int, float); // #1
9795 /// void f(int, int); // #2
9796 /// int f(int, int); // #3
9797 ///
9798 /// When we process #1, there is no previous declaration of "f", so IsOverload
9799 /// will not be used.
9800 ///
9801 /// When we process #2, Old contains only the FunctionDecl for #1. By
9802 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
9803 /// they have different signatures), so this routine returns Ovl_Overload;
9804 /// MatchedDecl is unchanged.
9805 ///
9806 /// When we process #3, Old is an overload set containing #1 and #2. We
9807 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
9808 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
9809 /// types of functions are not part of the signature), IsOverload returns
9810 /// Ovl_Match and MatchedDecl will be set to point to the FunctionDecl for #2.
9811 ///
9812 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
9813 /// class by a using declaration. The rules for whether to hide shadow
9814 /// declarations ignore some properties which otherwise figure into a function
9815 /// template's signature.
9817 const LookupResult &OldDecls, NamedDecl *&OldDecl,
9818 bool UseMemberUsingDeclRules);
9819 bool IsOverload(FunctionDecl *New, FunctionDecl *Old,
9820 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9821
9822 // Checks whether MD constitutes an override the base class method BaseMD.
9823 // When checking for overrides, the object object members are ignored.
9824 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
9825 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9826
9827 enum class AllowedExplicit {
9828 /// Allow no explicit functions to be used.
9829 None,
9830 /// Allow explicit conversion functions but not explicit constructors.
9832 /// Allow both explicit conversion functions and explicit constructors.
9833 All
9834 };
9835
9837 Expr *From, QualType ToType, bool SuppressUserConversions,
9838 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
9839 bool AllowObjCWritebackConversion);
9840
9841 /// PerformImplicitConversion - Perform an implicit conversion of the
9842 /// expression From to the type ToType. Returns the
9843 /// converted expression. Flavor is the kind of conversion we're
9844 /// performing, used in the error message. If @p AllowExplicit,
9845 /// explicit user-defined conversions are permitted.
9847 AssignmentAction Action,
9848 bool AllowExplicit = false);
9849
9850 /// IsIntegralPromotion - Determines whether the conversion from the
9851 /// expression From (whose potentially-adjusted type is FromType) to
9852 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
9853 /// sets PromotedType to the promoted type.
9854 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
9855
9856 /// IsFloatingPointPromotion - Determines whether the conversion from
9857 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
9858 /// returns true and sets PromotedType to the promoted type.
9859 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
9860
9861 /// Determine if a conversion is a complex promotion.
9862 ///
9863 /// A complex promotion is defined as a complex -> complex conversion
9864 /// where the conversion between the underlying real types is a
9865 /// floating-point or integral promotion.
9866 bool IsComplexPromotion(QualType FromType, QualType ToType);
9867
9868 /// IsPointerConversion - Determines whether the conversion of the
9869 /// expression From, which has the (possibly adjusted) type FromType,
9870 /// can be converted to the type ToType via a pointer conversion (C++
9871 /// 4.10). If so, returns true and places the converted type (that
9872 /// might differ from ToType in its cv-qualifiers at some level) into
9873 /// ConvertedType.
9874 ///
9875 /// This routine also supports conversions to and from block pointers
9876 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
9877 /// pointers to interfaces. FIXME: Once we've determined the
9878 /// appropriate overloading rules for Objective-C, we may want to
9879 /// split the Objective-C checks into a different routine; however,
9880 /// GCC seems to consider all of these conversions to be pointer
9881 /// conversions, so for now they live here. IncompatibleObjC will be
9882 /// set if the conversion is an allowed Objective-C conversion that
9883 /// should result in a warning.
9884 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
9885 bool InOverloadResolution, QualType &ConvertedType,
9886 bool &IncompatibleObjC);
9887
9888 /// isObjCPointerConversion - Determines whether this is an
9889 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
9890 /// with the same arguments and return values.
9891 bool isObjCPointerConversion(QualType FromType, QualType ToType,
9892 QualType &ConvertedType, bool &IncompatibleObjC);
9893 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
9894 QualType &ConvertedType);
9895
9896 /// FunctionParamTypesAreEqual - This routine checks two function proto types
9897 /// for equality of their parameter types. Caller has already checked that
9898 /// they have same number of parameters. If the parameters are different,
9899 /// ArgPos will have the parameter index of the first different parameter.
9900 /// If `Reversed` is true, the parameters of `NewType` will be compared in
9901 /// reverse order. That's useful if one of the functions is being used as a
9902 /// C++20 synthesized operator overload with a reversed parameter order.
9905 unsigned *ArgPos = nullptr,
9906 bool Reversed = false);
9907
9909 const FunctionProtoType *NewType,
9910 unsigned *ArgPos = nullptr,
9911 bool Reversed = false);
9912
9913 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
9914 const FunctionDecl *NewFunction,
9915 unsigned *ArgPos = nullptr,
9916 bool Reversed = false);
9917
9918 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
9919 /// function types. Catches different number of parameter, mismatch in
9920 /// parameter types, and different return types.
9922 QualType ToType);
9923
9924 /// CheckPointerConversion - Check the pointer conversion from the
9925 /// expression From to the type ToType. This routine checks for
9926 /// ambiguous or inaccessible derived-to-base pointer
9927 /// conversions for which IsPointerConversion has already returned
9928 /// true. It returns true and produces a diagnostic if there was an
9929 /// error, or returns false otherwise.
9930 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
9931 CXXCastPath &BasePath, bool IgnoreBaseAccess,
9932 bool Diagnose = true);
9933
9934 /// IsMemberPointerConversion - Determines whether the conversion of the
9935 /// expression From, which has the (possibly adjusted) type FromType, can be
9936 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
9937 /// If so, returns true and places the converted type (that might differ from
9938 /// ToType in its cv-qualifiers at some level) into ConvertedType.
9939 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
9940 bool InOverloadResolution,
9941 QualType &ConvertedType);
9942
9943 /// CheckMemberPointerConversion - Check the member pointer conversion from
9944 /// the expression From to the type ToType. This routine checks for ambiguous
9945 /// or virtual or inaccessible base-to-derived member pointer conversions for
9946 /// which IsMemberPointerConversion has already returned true. It returns true
9947 /// and produces a diagnostic if there was an error, or returns false
9948 /// otherwise.
9950 CXXCastPath &BasePath,
9951 bool IgnoreBaseAccess);
9952
9953 /// IsQualificationConversion - Determines whether the conversion from
9954 /// an rvalue of type FromType to ToType is a qualification conversion
9955 /// (C++ 4.4).
9956 ///
9957 /// \param ObjCLifetimeConversion Output parameter that will be set to
9958 /// indicate when the qualification conversion involves a change in the
9959 /// Objective-C object lifetime.
9960 bool IsQualificationConversion(QualType FromType, QualType ToType,
9961 bool CStyle, bool &ObjCLifetimeConversion);
9962
9963 /// Determine whether the conversion from FromType to ToType is a valid
9964 /// conversion that strips "noexcept" or "noreturn" off the nested function
9965 /// type.
9966 bool IsFunctionConversion(QualType FromType, QualType ToType,
9967 QualType &ResultTy);
9970 DeclarationName Name,
9971 OverloadCandidateSet &CandidateSet,
9972 FunctionDecl *Fn, MultiExprArg Args,
9973 bool IsMember = false);
9974
9976 FunctionDecl *Fun);
9978 Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl,
9979 CXXMethodDecl *Method);
9980
9981 /// PerformContextuallyConvertToBool - Perform a contextual conversion
9982 /// of the expression From to bool (C++0x [conv]p3).
9984
9985 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
9986 /// conversion of the expression From to an Objective-C pointer type.
9987 /// Returns a valid but null ExprResult if no conversion sequence exists.
9989
9990 /// Contexts in which a converted constant expression is required.
9991 enum CCEKind {
9992 CCEK_CaseValue, ///< Expression in a case label.
9993 CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
9994 CCEK_TemplateArg, ///< Value of a non-type template parameter.
9995 CCEK_ArrayBound, ///< Array bound in array declarator or new-expression.
9996 CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier.
9997 CCEK_Noexcept, ///< Condition in a noexcept(bool) specifier.
9998 CCEK_StaticAssertMessageSize, ///< Call to size() in a static assert
9999 ///< message.
10000 CCEK_StaticAssertMessageData, ///< Call to data() in a static assert
10001 ///< message.
10002 };
10003
10005 CCEKind CCE,
10006 NamedDecl *Dest = nullptr);
10007
10009 llvm::APSInt &Value, CCEKind CCE);
10011 APValue &Value, CCEKind CCE,
10012 NamedDecl *Dest = nullptr);
10013
10014 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10015 /// That is a converted constant expression
10016 /// (which was built with BuildConvertedConstantExpression)
10019 CCEKind CCE, bool RequireInt,
10020 const APValue &PreNarrowingValue);
10021
10022 /// Abstract base class used to perform a contextual implicit
10023 /// conversion from an expression to any type passing a filter.
10025 public:
10028
10029 ContextualImplicitConverter(bool Suppress = false,
10030 bool SuppressConversion = false)
10031 : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
10032
10033 /// Determine whether the specified type is a valid destination type
10034 /// for this conversion.
10035 virtual bool match(QualType T) = 0;
10036
10037 /// Emits a diagnostic complaining that the expression does not have
10038 /// integral or enumeration type.
10040 QualType T) = 0;
10041
10042 /// Emits a diagnostic when the expression has incomplete class type.
10043 virtual SemaDiagnosticBuilder
10045
10046 /// Emits a diagnostic when the only matching conversion function
10047 /// is explicit.
10050 QualType T,
10051 QualType ConvTy) = 0;
10052
10053 /// Emits a note for the explicit conversion function.
10054 virtual SemaDiagnosticBuilder
10056
10057 /// Emits a diagnostic when there are multiple possible conversion
10058 /// functions.
10060 QualType T) = 0;
10061
10062 /// Emits a note for one of the candidate conversions.
10063 virtual SemaDiagnosticBuilder
10065
10066 /// Emits a diagnostic when we picked a conversion function
10067 /// (for cases when we are not allowed to pick a conversion function).
10070 QualType T,
10071 QualType ConvTy) = 0;
10072
10074 };
10075
10077 bool AllowScopedEnumerations;
10078
10079 public:
10080 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10081 bool SuppressConversion)
10082 : ContextualImplicitConverter(Suppress, SuppressConversion),
10083 AllowScopedEnumerations(AllowScopedEnumerations) {}
10084
10085 /// Match an integral or (possibly scoped) enumeration type.
10086 bool match(QualType T) override;
10087
10089 QualType T) override {
10090 return diagnoseNotInt(S, Loc, T);
10091 }
10092
10093 /// Emits a diagnostic complaining that the expression does not have
10094 /// integral or enumeration type.
10096 QualType T) = 0;
10097 };
10098
10099 /// Perform a contextual implicit conversion.
10102 ContextualImplicitConverter &Converter);
10103
10104 /// ReferenceCompareResult - Expresses the result of comparing two
10105 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10106 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10108 /// Ref_Incompatible - The two types are incompatible, so direct
10109 /// reference binding is not possible.
10111 /// Ref_Related - The two types are reference-related, which means
10112 /// that their unqualified forms (T1 and T2) are either the same
10113 /// or T1 is a base class of T2.
10115 /// Ref_Compatible - The two types are reference-compatible.
10118
10119 // Fake up a scoped enumeration that still contextually converts to bool.
10121 /// The conversions that would be performed on an lvalue of type T2 when
10122 /// binding a reference of type T1 to it, as determined when evaluating
10123 /// whether T1 is reference-compatible with T2.
10125 Qualification = 0x1,
10126 NestedQualification = 0x2,
10128 DerivedToBase = 0x8,
10129 ObjC = 0x10,
10130 ObjCLifetime = 0x20,
10131
10132 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
10133 };
10134 };
10136
10137 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10138 /// determine whether they are reference-compatible,
10139 /// reference-related, or incompatible, for use in C++ initialization by
10140 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10141 /// type, and the first type (T1) is the pointee type of the reference
10142 /// type being initialized.
10145 ReferenceConversions *Conv = nullptr);
10146
10147 /// AddOverloadCandidate - Adds the given function to the set of
10148 /// candidate functions, using the given function call arguments. If
10149 /// @p SuppressUserConversions, then don't allow user-defined
10150 /// conversions via constructors or conversion operators.
10151 ///
10152 /// \param PartialOverloading true if we are performing "partial" overloading
10153 /// based on an incomplete set of function arguments. This feature is used by
10154 /// code completion.
10156 ArrayRef<Expr *> Args,
10157 OverloadCandidateSet &CandidateSet,
10158 bool SuppressUserConversions = false,
10159 bool PartialOverloading = false,
10160 bool AllowExplicit = true,
10161 bool AllowExplicitConversion = false,
10162 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10163 ConversionSequenceList EarlyConversions = {},
10165 bool AggregateCandidateDeduction = false);
10166
10167 /// Add all of the function declarations in the given function set to
10168 /// the overload candidate set.
10170 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10171 OverloadCandidateSet &CandidateSet,
10172 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10173 bool SuppressUserConversions = false, bool PartialOverloading = false,
10174 bool FirstArgumentIsBase = false);
10175
10176 /// AddMethodCandidate - Adds a named decl (which is some kind of
10177 /// method) as a method candidate to the given overload set.
10178 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10179 Expr::Classification ObjectClassification,
10180 ArrayRef<Expr *> Args,
10181 OverloadCandidateSet &CandidateSet,
10182 bool SuppressUserConversion = false,
10184
10185 /// AddMethodCandidate - Adds the given C++ member function to the set
10186 /// of candidate functions, using the given function call arguments
10187 /// and the object argument (@c Object). For example, in a call
10188 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10189 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10190 /// allow user-defined conversions via constructors or conversion
10191 /// operators.
10192 void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10193 CXXRecordDecl *ActingContext, QualType ObjectType,
10194 Expr::Classification ObjectClassification,
10195 ArrayRef<Expr *> Args,
10196 OverloadCandidateSet &CandidateSet,
10197 bool SuppressUserConversions = false,
10198 bool PartialOverloading = false,
10199 ConversionSequenceList EarlyConversions = {},
10201
10202 /// Add a C++ member function template as a candidate to the candidate
10203 /// set, using template argument deduction to produce an appropriate member
10204 /// function template specialization.
10206 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10207 CXXRecordDecl *ActingContext,
10208 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10209 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10210 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10211 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10212
10213 /// Add a C++ function template specialization as a candidate
10214 /// in the candidate set, using template argument deduction to produce
10215 /// an appropriate function template specialization.
10217 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10218 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10219 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10220 bool PartialOverloading = false, bool AllowExplicit = true,
10221 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10223 bool AggregateCandidateDeduction = false);
10224
10225 /// Check that implicit conversion sequences can be formed for each argument
10226 /// whose corresponding parameter has a non-dependent type, per DR1391's
10227 /// [temp.deduct.call]p10.
10229 FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes,
10230 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10231 ConversionSequenceList &Conversions, bool SuppressUserConversions,
10232 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10233 Expr::Classification ObjectClassification = {},
10235
10236 /// AddConversionCandidate - Add a C++ conversion function as a
10237 /// candidate in the candidate set (C++ [over.match.conv],
10238 /// C++ [over.match.copy]). From is the expression we're converting from,
10239 /// and ToType is the type that we're eventually trying to convert to
10240 /// (which may or may not be the same type as the type that the
10241 /// conversion function produces).
10243 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10244 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10245 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10246 bool AllowExplicit, bool AllowResultConversion = true);
10247
10248 /// Adds a conversion function template specialization
10249 /// candidate to the overload set, using template argument deduction
10250 /// to deduce the template arguments of the conversion function
10251 /// template from the type that we are converting to (C++
10252 /// [temp.deduct.conv]).
10254 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10255 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10256 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10257 bool AllowExplicit, bool AllowResultConversion = true);
10258
10259 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10260 /// converts the given @c Object to a function pointer via the
10261 /// conversion function @c Conversion, and then attempts to call it
10262 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10263 /// the type of function that we'll eventually be calling.
10264 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10265 DeclAccessPair FoundDecl,
10266 CXXRecordDecl *ActingContext,
10267 const FunctionProtoType *Proto, Expr *Object,
10268 ArrayRef<Expr *> Args,
10269 OverloadCandidateSet &CandidateSet);
10270
10271 /// Add all of the non-member operator function declarations in the given
10272 /// function set to the overload candidate set.
10274 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10275 OverloadCandidateSet &CandidateSet,
10276 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10277
10278 /// Add overload candidates for overloaded operators that are
10279 /// member functions.
10280 ///
10281 /// Add the overloaded operator candidates that are member functions
10282 /// for the operator Op that was used in an operator expression such
10283 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10284 /// CandidateSet will store the added overload candidates. (C++
10285 /// [over.match.oper]).
10287 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10288 OverloadCandidateSet &CandidateSet,
10290
10291 /// AddBuiltinCandidate - Add a candidate for a built-in
10292 /// operator. ResultTy and ParamTys are the result and parameter types
10293 /// of the built-in candidate, respectively. Args and NumArgs are the
10294 /// arguments being passed to the candidate. IsAssignmentOperator
10295 /// should be true when this built-in candidate is an assignment
10296 /// operator. NumContextualBoolArguments is the number of arguments
10297 /// (at the beginning of the argument list) that will be contextually
10298 /// converted to bool.
10299 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10300 OverloadCandidateSet &CandidateSet,
10301 bool IsAssignmentOperator = false,
10302 unsigned NumContextualBoolArguments = 0);
10303
10304 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10305 /// operator overloads to the candidate set (C++ [over.built]), based
10306 /// on the operator @p Op and the arguments given. For example, if the
10307 /// operator is a binary '+', this routine might add "int
10308 /// operator+(int, int)" to cover integer addition.
10310 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10311 OverloadCandidateSet &CandidateSet);
10312
10313 /// Add function candidates found via argument-dependent lookup
10314 /// to the set of overloading candidates.
10315 ///
10316 /// This routine performs argument-dependent name lookup based on the
10317 /// given function name (which may also be an operator name) and adds
10318 /// all of the overload candidates found by ADL to the overload
10319 /// candidate set (C++ [basic.lookup.argdep]).
10321 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10322 TemplateArgumentListInfo *ExplicitTemplateArgs,
10323 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10324
10325 /// Check the enable_if expressions on the given function. Returns the first
10326 /// failing attribute, or NULL if they were all successful.
10327 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10328 ArrayRef<Expr *> Args,
10329 bool MissingImplicitThis = false);
10330
10331 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10332 /// non-ArgDependent DiagnoseIfAttrs.
10333 ///
10334 /// Argument-dependent diagnose_if attributes should be checked each time a
10335 /// function is used as a direct callee of a function call.
10336 ///
10337 /// Returns true if any errors were emitted.
10338 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10339 const Expr *ThisArg,
10340 ArrayRef<const Expr *> Args,
10341 SourceLocation Loc);
10342
10343 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10344 /// ArgDependent DiagnoseIfAttrs.
10345 ///
10346 /// Argument-independent diagnose_if attributes should be checked on every use
10347 /// of a function.
10348 ///
10349 /// Returns true if any errors were emitted.
10350 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10351 SourceLocation Loc);
10352
10353 /// Determine if \p A and \p B are equivalent internal linkage declarations
10354 /// from different modules, and thus an ambiguity error can be downgraded to
10355 /// an extension warning.
10356 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10357 const NamedDecl *B);
10359 SourceLocation Loc, const NamedDecl *D,
10360 ArrayRef<const NamedDecl *> Equiv);
10361
10362 // Emit as a 'note' the specific overload candidate
10364 const NamedDecl *Found, const FunctionDecl *Fn,
10366 QualType DestType = QualType(), bool TakingAddress = false);
10367
10368 // Emit as a series of 'note's all template and non-templates identified by
10369 // the expression Expr
10370 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10371 bool TakingAddress = false);
10372
10373 /// Returns whether the given function's address can be taken or not,
10374 /// optionally emitting a diagnostic if the address can't be taken.
10375 ///
10376 /// Returns false if taking the address of the function is illegal.
10377 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10378 bool Complain = false,
10379 SourceLocation Loc = SourceLocation());
10380
10381 // [PossiblyAFunctionType] --> [Return]
10382 // NonFunctionType --> NonFunctionType
10383 // R (A) --> R(A)
10384 // R (*)(A) --> R (A)
10385 // R (&)(A) --> R (A)
10386 // R (S::*)(A) --> R (A)
10387 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10388
10389 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10390 /// an overloaded function (C++ [over.over]), where @p From is an
10391 /// expression with overloaded function type and @p ToType is the type
10392 /// we're trying to resolve to. For example:
10393 ///
10394 /// @code
10395 /// int f(double);
10396 /// int f(int);
10397 ///
10398 /// int (*pfd)(double) = f; // selects f(double)
10399 /// @endcode
10400 ///
10401 /// This routine returns the resulting FunctionDecl if it could be
10402 /// resolved, and NULL otherwise. When @p Complain is true, this
10403 /// routine will emit diagnostics if there is an error.
10404 FunctionDecl *
10405 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10406 bool Complain, DeclAccessPair &Found,
10407 bool *pHadMultipleCandidates = nullptr);
10408
10409 /// Given an expression that refers to an overloaded function, try to
10410 /// resolve that function to a single function that can have its address
10411 /// taken. This will modify `Pair` iff it returns non-null.
10412 ///
10413 /// This routine can only succeed if from all of the candidates in the
10414 /// overload set for SrcExpr that can have their addresses taken, there is one
10415 /// candidate that is more constrained than the rest.
10416 FunctionDecl *
10417 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10418
10419 /// Given an overloaded function, tries to turn it into a non-overloaded
10420 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10421 /// will perform access checks, diagnose the use of the resultant decl, and,
10422 /// if requested, potentially perform a function-to-pointer decay.
10423 ///
10424 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10425 /// Otherwise, returns true. This may emit diagnostics and return true.
10427 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10428
10429 /// Given an expression that refers to an overloaded function, try to
10430 /// resolve that overloaded function expression down to a single function.
10431 ///
10432 /// This routine can only resolve template-ids that refer to a single function
10433 /// template, where that template-id refers to a single template whose
10434 /// template arguments are either provided by the template-id or have
10435 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10436 ///
10437 /// If no template-ids are found, no diagnostics are emitted and NULL is
10438 /// returned.
10440 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10441 TemplateSpecCandidateSet *FailedTSC = nullptr);
10442
10443 // Resolve and fix an overloaded expression that can be resolved
10444 // because it identifies a single function template specialization.
10445 //
10446 // Last three arguments should only be supplied if Complain = true
10447 //
10448 // Return true if it was logically possible to so resolve the
10449 // expression, regardless of whether or not it succeeded. Always
10450 // returns true if 'complain' is set.
10452 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10453 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10454 QualType DestTypeForComplaining = QualType(),
10455 unsigned DiagIDForComplaining = 0);
10456
10457 /// Add the overload candidates named by callee and/or found by argument
10458 /// dependent lookup to the given overload set.
10459 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10460 ArrayRef<Expr *> Args,
10461 OverloadCandidateSet &CandidateSet,
10462 bool PartialOverloading = false);
10463
10464 /// Add the call candidates from the given set of lookup results to the given
10465 /// overload set. Non-function lookup results are ignored.
10467 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10468 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10469
10470 // An enum used to represent the different possible results of building a
10471 // range-based for loop.
10477
10478 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10479 /// given LookupResult is non-empty, it is assumed to describe a member which
10480 /// will be invoked. Otherwise, the function will be found via argument
10481 /// dependent lookup.
10482 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10483 /// otherwise CallExpr is set to ExprError() and some non-success value
10484 /// is returned.
10486 SourceLocation RangeLoc,
10487 const DeclarationNameInfo &NameInfo,
10488 LookupResult &MemberLookup,
10489 OverloadCandidateSet *CandidateSet,
10491
10492 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10493 /// (which eventually refers to the declaration Func) and the call
10494 /// arguments Args/NumArgs, attempt to resolve the function call down
10495 /// to a specific function. If overload resolution succeeds, returns
10496 /// the call expression produced by overload resolution.
10497 /// Otherwise, emits diagnostics and returns ExprError.
10499 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10500 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10501 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10502
10503 /// Constructs and populates an OverloadedCandidateSet from
10504 /// the given function.
10505 /// \returns true when an the ExprResult output parameter has been set.
10507 MultiExprArg Args, SourceLocation RParenLoc,
10508 OverloadCandidateSet *CandidateSet,
10510
10514 const UnresolvedSetImpl &Fns,
10515 bool PerformADL = true);
10516
10517 /// Create a unary operation that may resolve to an overloaded
10518 /// operator.
10519 ///
10520 /// \param OpLoc The location of the operator itself (e.g., '*').
10521 ///
10522 /// \param Opc The UnaryOperatorKind that describes this operator.
10523 ///
10524 /// \param Fns The set of non-member functions that will be
10525 /// considered by overload resolution. The caller needs to build this
10526 /// set based on the context using, e.g.,
10527 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10528 /// set should not contain any member functions; those will be added
10529 /// by CreateOverloadedUnaryOp().
10530 ///
10531 /// \param Input The input argument.
10534 const UnresolvedSetImpl &Fns, Expr *input,
10535 bool RequiresADL = true);
10536
10537 /// Perform lookup for an overloaded binary operator.
10540 const UnresolvedSetImpl &Fns,
10541 ArrayRef<Expr *> Args, bool RequiresADL = true);
10542
10543 /// Create a binary operation that may resolve to an overloaded
10544 /// operator.
10545 ///
10546 /// \param OpLoc The location of the operator itself (e.g., '+').
10547 ///
10548 /// \param Opc The BinaryOperatorKind that describes this operator.
10549 ///
10550 /// \param Fns The set of non-member functions that will be
10551 /// considered by overload resolution. The caller needs to build this
10552 /// set based on the context using, e.g.,
10553 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10554 /// set should not contain any member functions; those will be added
10555 /// by CreateOverloadedBinOp().
10556 ///
10557 /// \param LHS Left-hand argument.
10558 /// \param RHS Right-hand argument.
10559 /// \param PerformADL Whether to consider operator candidates found by ADL.
10560 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10561 /// C++20 operator rewrites.
10562 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
10563 /// the function in question. Such a function is never a candidate in
10564 /// our overload resolution. This also enables synthesizing a three-way
10565 /// comparison from < and == as described in C++20 [class.spaceship]p1.
10567 const UnresolvedSetImpl &Fns, Expr *LHS,
10568 Expr *RHS, bool RequiresADL = true,
10569 bool AllowRewrittenCandidates = true,
10570 FunctionDecl *DefaultedFn = nullptr);
10572 const UnresolvedSetImpl &Fns,
10573 Expr *LHS, Expr *RHS,
10574 FunctionDecl *DefaultedFn);
10575
10577 SourceLocation RLoc, Expr *Base,
10578 MultiExprArg Args);
10579
10580 /// BuildCallToMemberFunction - Build a call to a member
10581 /// function. MemExpr is the expression that refers to the member
10582 /// function (and includes the object parameter), Args/NumArgs are the
10583 /// arguments to the function call (not including the object
10584 /// parameter). The caller needs to validate that the member
10585 /// expression refers to a non-static member function or an overloaded
10586 /// member function.
10588 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
10589 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
10590 bool IsExecConfig = false, bool AllowRecovery = false);
10591
10592 /// BuildCallToObjectOfClassType - Build a call to an object of class
10593 /// type (C++ [over.call.object]), which can end up invoking an
10594 /// overloaded function call operator (@c operator()) or performing a
10595 /// user-defined conversion on the object argument.
10597 SourceLocation LParenLoc,
10598 MultiExprArg Args,
10599 SourceLocation RParenLoc);
10600
10601 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
10602 /// (if one exists), where @c Base is an expression of class type and
10603 /// @c Member is the name of the member we're trying to find.
10605 SourceLocation OpLoc,
10606 bool *NoArrowOperatorFound = nullptr);
10607
10609 CXXConversionDecl *Method,
10610 bool HadMultipleCandidates);
10611
10612 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
10613 /// to a literal operator described by the provided lookup results.
10616 SourceLocation LitEndLoc,
10617 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10618
10619 /// FixOverloadedFunctionReference - E is an expression that refers to
10620 /// a C++ overloaded function (possibly with some parentheses and
10621 /// perhaps a '&' around it). We have resolved the overloaded function
10622 /// to the function declaration Fn, so patch up the expression E to
10623 /// refer (possibly indirectly) to Fn. Returns the new expr.
10625 FunctionDecl *Fn);
10627 DeclAccessPair FoundDecl,
10628 FunctionDecl *Fn);
10629
10630 /// - Returns a selector which best matches given argument list or
10631 /// nullptr if none could be found
10633 bool IsInstance,
10635
10636 ///@}
10637
10638 //
10639 //
10640 // -------------------------------------------------------------------------
10641 //
10642 //
10643
10644 /// \name Statements
10645 /// Implementations are in SemaStmt.cpp
10646 ///@{
10647
10648public:
10649 /// Stack of active SEH __finally scopes. Can be empty.
10651
10652 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
10654
10656 bool HasLeadingEmptyMacro = false);
10657
10659 SourceLocation EndLoc);
10661
10662 /// DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is
10663 /// semantically a discarded-value expression, diagnose if any [[nodiscard]]
10664 /// value has been discarded.
10666
10667 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
10668 /// whose result is unused, warn.
10669 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
10670
10671 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
10675 ArrayRef<Stmt *> Elts, bool isStmtExpr);
10676
10678
10681 SourceLocation DotDotDotLoc, ExprResult RHS,
10682 SourceLocation ColonLoc);
10683
10684 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
10685 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
10686
10688 SourceLocation ColonLoc, Stmt *SubStmt,
10689 Scope *CurScope);
10691 SourceLocation ColonLoc, Stmt *SubStmt);
10692
10694 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
10696 Stmt *SubStmt);
10697
10698 /// Check whether the given statement can have musttail applied to it,
10699 /// issuing a diagnostic and returning false if not. In the success case,
10700 /// the statement is rewritten to remove implicit nodes from the return
10701 /// value.
10702 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
10703
10705 SourceLocation LParenLoc, Stmt *InitStmt,
10706 ConditionResult Cond, SourceLocation RParenLoc,
10707 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10709 SourceLocation LParenLoc, Stmt *InitStmt,
10710 ConditionResult Cond, SourceLocation RParenLoc,
10711 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10712
10714
10716 SourceLocation LParenLoc, Stmt *InitStmt,
10717 ConditionResult Cond,
10718 SourceLocation RParenLoc);
10720 Stmt *Body);
10721
10722 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
10723 /// integer not in the range of enum values.
10724 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
10725 Expr *SrcExpr);
10726
10728 ConditionResult Cond, SourceLocation RParenLoc,
10729 Stmt *Body);
10731 SourceLocation WhileLoc, SourceLocation CondLParen,
10732 Expr *Cond, SourceLocation CondRParen);
10733
10735 Stmt *First, ConditionResult Second,
10736 FullExprArg Third, SourceLocation RParenLoc,
10737 Stmt *Body);
10738
10739 /// In an Objective C collection iteration statement:
10740 /// for (x in y)
10741 /// x can be an arbitrary l-value expression. Bind it up as a
10742 /// full-expression.
10744
10746 /// Initial building of a for-range statement.
10748 /// Instantiation or recovery rebuild of a for-range statement. Don't
10749 /// attempt any typo-correction.
10751 /// Determining whether a for-range statement could be built. Avoid any
10752 /// unnecessary or irreversible actions.
10755
10756 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
10757 ///
10758 /// C++11 [stmt.ranged]:
10759 /// A range-based for statement is equivalent to
10760 ///
10761 /// {
10762 /// auto && __range = range-init;
10763 /// for ( auto __begin = begin-expr,
10764 /// __end = end-expr;
10765 /// __begin != __end;
10766 /// ++__begin ) {
10767 /// for-range-declaration = *__begin;
10768 /// statement
10769 /// }
10770 /// }
10771 ///
10772 /// The body of the loop is not available yet, since it cannot be analysed
10773 /// until we have determined the type of the for-range-declaration.
10775 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
10776 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
10778 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10779
10780 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
10782 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
10783 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
10784 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
10786 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10787
10788 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
10789 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
10790 /// body cannot be performed until after the type of the range variable is
10791 /// determined.
10792 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
10793
10794 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
10795 LabelDecl *TheDecl);
10796 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
10797 SourceLocation StarLoc, Expr *DestExp);
10798 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
10799 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
10800
10803
10804 enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
10806
10807 bool isMoveEligible() const { return S != None; };
10808 bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
10809 };
10811
10812 /// Determine whether the given expression might be move-eligible or
10813 /// copy-elidable in either a (co_)return statement or throw expression,
10814 /// without considering function return type, if applicable.
10815 ///
10816 /// \param E The expression being returned from the function or block,
10817 /// being thrown, or being co_returned from a coroutine. This expression
10818 /// might be modified by the implementation.
10819 ///
10820 /// \param Mode Overrides detection of current language mode
10821 /// and uses the rules for C++23.
10822 ///
10823 /// \returns An aggregate which contains the Candidate and isMoveEligible
10824 /// and isCopyElidable methods. If Candidate is non-null, it means
10825 /// isMoveEligible() would be true under the most permissive language
10826 /// standard.
10827 NamedReturnInfo getNamedReturnInfo(
10829
10830 /// Determine whether the given NRVO candidate variable is move-eligible or
10831 /// copy-elidable, without considering function return type.
10832 ///
10833 /// \param VD The NRVO candidate variable.
10834 ///
10835 /// \returns An aggregate which contains the Candidate and isMoveEligible
10836 /// and isCopyElidable methods. If Candidate is non-null, it means
10837 /// isMoveEligible() would be true under the most permissive language
10838 /// standard.
10839 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
10840
10841 /// Updates given NamedReturnInfo's move-eligible and
10842 /// copy-elidable statuses, considering the function
10843 /// return type criteria as applicable to return statements.
10844 ///
10845 /// \param Info The NamedReturnInfo object to update.
10846 ///
10847 /// \param ReturnType This is the return type of the function.
10848 /// \returns The copy elision candidate, in case the initial return expression
10849 /// was copy elidable, or nullptr otherwise.
10850 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
10851 QualType ReturnType);
10852
10853 /// Perform the initialization of a potentially-movable value, which
10854 /// is the result of return value.
10855 ///
10856 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
10857 /// treat returned lvalues as rvalues in certain cases (to prefer move
10858 /// construction), then falls back to treating them as lvalues if that failed.
10861 const NamedReturnInfo &NRInfo, Expr *Value,
10862 bool SupressSimplerImplicitMoves = false);
10863
10865
10866 /// Deduce the return type for a function from a returned expression, per
10867 /// C++1y [dcl.spec.auto]p6.
10869 SourceLocation ReturnLoc, Expr *RetExpr,
10870 const AutoType *AT);
10871
10872 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10873 Scope *CurScope);
10874 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10875 bool AllowRecovery = false);
10876
10877 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
10878 /// for capturing scopes.
10880 NamedReturnInfo &NRInfo,
10881 bool SupressSimplerImplicitMoves);
10882
10883 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
10884 /// and creates a proper catch handler from them.
10886 Stmt *HandlerBlock);
10887
10888 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
10889 /// handlers and creates a try statement from them.
10891 ArrayRef<Stmt *> Handlers);
10892
10893 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
10894 SourceLocation TryLoc, Stmt *TryBlock,
10895 Stmt *Handler);
10897 Stmt *Block);
10902
10904 bool IsIfExists,
10905 NestedNameSpecifierLoc QualifierLoc,
10906 DeclarationNameInfo NameInfo,
10907 Stmt *Nested);
10909 bool IsIfExists, CXXScopeSpec &SS,
10910 UnqualifiedId &Name, Stmt *Nested);
10911
10913 CapturedRegionKind Kind, unsigned NumParams);
10914 typedef std::pair<StringRef, QualType> CapturedParamNameType;
10918 unsigned OpenMPCaptureLevel = 0);
10923 unsigned NumParams);
10924
10925private:
10926 /// Check whether the given statement can have musttail applied to it,
10927 /// issuing a diagnostic and returning false if not.
10928 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
10929
10930 /// Check if the given expression contains 'break' or 'continue'
10931 /// statement that produces control flow different from GCC.
10932 void CheckBreakContinueBinding(Expr *E);
10933
10934 ///@}
10935
10936 //
10937 //
10938 // -------------------------------------------------------------------------
10939 //
10940 //
10941
10942 /// \name `inline asm` Statement
10943 /// Implementations are in SemaStmtAsm.cpp
10944 ///@{
10945
10946public:
10947 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
10948 bool IsVolatile, unsigned NumOutputs,
10949 unsigned NumInputs, IdentifierInfo **Names,
10950 MultiExprArg Constraints, MultiExprArg Exprs,
10951 Expr *AsmString, MultiExprArg Clobbers,
10952 unsigned NumLabels, SourceLocation RParenLoc);
10953
10955 llvm::InlineAsmIdentifierInfo &Info);
10957 SourceLocation TemplateKWLoc,
10959 bool IsUnevaluatedContext);
10960 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
10961 SourceLocation AsmLoc);
10963 SourceLocation AsmLoc);
10965 ArrayRef<Token> AsmToks, StringRef AsmString,
10966 unsigned NumOutputs, unsigned NumInputs,
10967 ArrayRef<StringRef> Constraints,
10968 ArrayRef<StringRef> Clobbers,
10969 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
10970 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
10971 SourceLocation Location, bool AlwaysCreate);
10972
10973 ///@}
10974
10975 //
10976 //
10977 // -------------------------------------------------------------------------
10978 //
10979 //
10980
10981 /// \name Statement Attribute Handling
10982 /// Implementations are in SemaStmtAttr.cpp
10983 ///@{
10984
10985public:
10986 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
10987 const AttributeCommonInfo &A);
10988 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
10989 const AttributeCommonInfo &A);
10990
10991 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
10993
10994 /// Process the attributes before creating an attributed statement. Returns
10995 /// the semantic attributes that have been processed.
10996 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
10998
11002 const IdentifierInfo *AttrName,
11004
11005 ///@}
11006
11007 //
11008 //
11009 // -------------------------------------------------------------------------
11010 //
11011 //
11012
11013 /// \name C++ Templates
11014 /// Implementations are in SemaTemplate.cpp
11015 ///@{
11016
11017public:
11018 // Saves the current floating-point pragma stack and clear it in this Sema.
11020 public:
11022 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11023 S.FpPragmaStack.Stack.clear();
11024 }
11025 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11026
11027 private:
11028 Sema &S;
11030 };
11031
11033 CurFPFeatures = FPO;
11034 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11035 }
11036
11038 return llvm::ArrayRef(InventedParameterInfos.begin() +
11041 }
11042
11043 /// The number of SFINAE diagnostics that have been trapped.
11045
11048 FunctionScopes.end());
11049 }
11050
11051 typedef llvm::MapVector<const FunctionDecl *,
11052 std::unique_ptr<LateParsedTemplate>>
11055
11056 /// Determine the number of levels of enclosing template parameters. This is
11057 /// only usable while parsing. Note that this does not include dependent
11058 /// contexts in which no template parameters have yet been declared, such as
11059 /// in a terse function template or generic lambda before the first 'auto' is
11060 /// encountered.
11061 unsigned getTemplateDepth(Scope *S) const;
11062
11064 bool AllowFunctionTemplates = true,
11065 bool AllowDependent = true);
11067 bool AllowFunctionTemplates = true,
11068 bool AllowDependent = true,
11069 bool AllowNonTemplateFunctions = false);
11070 /// Try to interpret the lookup result D as a template-name.
11071 ///
11072 /// \param D A declaration found by name lookup.
11073 /// \param AllowFunctionTemplates Whether function templates should be
11074 /// considered valid results.
11075 /// \param AllowDependent Whether unresolved using declarations (that might
11076 /// name templates) should be considered valid results.
11078 bool AllowFunctionTemplates = true,
11079 bool AllowDependent = true);
11080
11082 /// Whether and why a template name is required in this lookup.
11084 public:
11085 /// Template name is required if TemplateKWLoc is valid.
11087 : TemplateKW(TemplateKWLoc) {}
11088 /// Template name is unconditionally required.
11090
11092 return TemplateKW.value_or(SourceLocation());
11093 }
11094 bool hasTemplateKeyword() const {
11095 return getTemplateKeywordLoc().isValid();
11096 }
11097 bool isRequired() const { return TemplateKW != SourceLocation(); }
11098 explicit operator bool() const { return isRequired(); }
11099
11100 private:
11101 std::optional<SourceLocation> TemplateKW;
11102 };
11103
11105 /// This is not assumed to be a template name.
11106 None,
11107 /// This is assumed to be a template name because lookup found nothing.
11109 /// This is assumed to be a template name because lookup found one or more
11110 /// functions (but no function templates).
11112 };
11113
11114 bool
11116 QualType ObjectType, bool EnteringContext,
11117 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11118 AssumedTemplateKind *ATK = nullptr,
11119 bool AllowTypoCorrection = true);
11120
11122 bool hasTemplateKeyword,
11123 const UnqualifiedId &Name,
11124 ParsedType ObjectType, bool EnteringContext,
11125 TemplateTy &Template,
11126 bool &MemberOfUnknownSpecialization,
11127 bool Disambiguation = false);
11128
11129 /// Try to resolve an undeclared template name as a type template.
11130 ///
11131 /// Sets II to the identifier corresponding to the template name, and updates
11132 /// Name to a corresponding (typo-corrected) type template name and TNK to
11133 /// the corresponding kind, if possible.
11135 TemplateNameKind &TNK,
11136 SourceLocation NameLoc,
11137 IdentifierInfo *&II);
11138
11140 SourceLocation NameLoc,
11141 bool Diagnose = true);
11142
11143 /// Determine whether a particular identifier might be the name in a C++1z
11144 /// deduction-guide declaration.
11145 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11146 SourceLocation NameLoc, CXXScopeSpec &SS,
11147 ParsedTemplateTy *Template = nullptr);
11148
11150 SourceLocation IILoc, Scope *S,
11151 const CXXScopeSpec *SS,
11152 TemplateTy &SuggestedTemplate,
11153 TemplateNameKind &SuggestedKind);
11154
11155 /// Determine whether we would be unable to instantiate this template (because
11156 /// it either has no definition, or is in the process of being instantiated).
11157 bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
11158 NamedDecl *Instantiation,
11159 bool InstantiatedFromMember,
11160 const NamedDecl *Pattern,
11161 const NamedDecl *PatternDef,
11163 bool Complain = true);
11164
11165 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11166 /// that the template parameter 'PrevDecl' is being shadowed by a new
11167 /// declaration at location Loc. Returns true to indicate that this is
11168 /// an error, and false otherwise.
11169 ///
11170 /// \param Loc The location of the declaration that shadows a template
11171 /// parameter.
11172 ///
11173 /// \param PrevDecl The template parameter that the declaration shadows.
11174 ///
11175 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11176 /// a warning for compatibility with older versions of clang.
11177 /// Ignored when MSVC compatibility is enabled.
11179 bool SupportedForCompatibility = false);
11180
11181 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11182 /// the parameter D to reference the templated declaration and return a
11183 /// pointer to the template declaration. Otherwise, do nothing to D and return
11184 /// null.
11186
11187 /// ActOnTypeParameter - Called when a C++ template type parameter
11188 /// (e.g., "typename T") has been parsed. Typename specifies whether
11189 /// the keyword "typename" was used to declare the type parameter
11190 /// (otherwise, "class" was used), and KeyLoc is the location of the
11191 /// "class" or "typename" keyword. ParamName is the name of the
11192 /// parameter (NULL indicates an unnamed template parameter) and
11193 /// ParamNameLoc is the location of the parameter name (if any).
11194 /// If the type parameter has a default argument, it will be added
11195 /// later via ActOnTypeParameterDefault.
11197 SourceLocation EllipsisLoc,
11198 SourceLocation KeyLoc,
11199 IdentifierInfo *ParamName,
11200 SourceLocation ParamNameLoc, unsigned Depth,
11201 unsigned Position, SourceLocation EqualLoc,
11202 ParsedType DefaultArg, bool HasTypeConstraint);
11203
11205
11206 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11208 TemplateTypeParmDecl *ConstrainedParameter,
11209 SourceLocation EllipsisLoc);
11210 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11212 TemplateTypeParmDecl *ConstrainedParameter,
11213 SourceLocation EllipsisLoc,
11214 bool AllowUnexpandedPack);
11215
11216 /// Attach a type-constraint to a template parameter.
11217 /// \returns true if an error occurred. This can happen if the
11218 /// immediately-declared constraint could not be formed (e.g. incorrect number
11219 /// of arguments for the named concept).
11221 DeclarationNameInfo NameInfo,
11222 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
11223 const TemplateArgumentListInfo *TemplateArgs,
11224 TemplateTypeParmDecl *ConstrainedParameter,
11225 QualType ConstrainedType,
11226 SourceLocation EllipsisLoc);
11227
11229 NonTypeTemplateParmDecl *NewConstrainedParm,
11230 NonTypeTemplateParmDecl *OrigConstrainedParm,
11231 SourceLocation EllipsisLoc);
11232
11233 /// Require the given type to be a structural type, and diagnose if it is not.
11234 ///
11235 /// \return \c true if an error was produced.
11237
11238 /// Check that the type of a non-type template parameter is
11239 /// well-formed.
11240 ///
11241 /// \returns the (possibly-promoted) parameter type if valid;
11242 /// otherwise, produces a diagnostic and returns a NULL type.
11246
11248 unsigned Depth, unsigned Position,
11249 SourceLocation EqualLoc,
11250 Expr *DefaultArg);
11251
11252 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11253 /// parameter (e.g. T in template <template <typename> class T> class array)
11254 /// has been parsed. S is the current scope.
11256 Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params,
11257 bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11258 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11259 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11260
11261 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11262 /// constrained by RequiresClause, that contains the template parameters in
11263 /// Params.
11265 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11266 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11267 SourceLocation RAngleLoc, Expr *RequiresClause);
11268
11269 /// The context in which we are checking a template parameter list.
11280
11281 /// Checks the validity of a template parameter list, possibly
11282 /// considering the template parameter list from a previous
11283 /// declaration.
11284 ///
11285 /// If an "old" template parameter list is provided, it must be
11286 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11287 /// template parameter list.
11288 ///
11289 /// \param NewParams Template parameter list for a new template
11290 /// declaration. This template parameter list will be updated with any
11291 /// default arguments that are carried through from the previous
11292 /// template parameter list.
11293 ///
11294 /// \param OldParams If provided, template parameter list from a
11295 /// previous declaration of the same template. Default template
11296 /// arguments will be merged from the old template parameter list to
11297 /// the new template parameter list.
11298 ///
11299 /// \param TPC Describes the context in which we are checking the given
11300 /// template parameter list.
11301 ///
11302 /// \param SkipBody If we might have already made a prior merged definition
11303 /// of this template visible, the corresponding body-skipping information.
11304 /// Default argument redefinition is not an error when skipping such a body,
11305 /// because (under the ODR) we can assume the default arguments are the same
11306 /// as the prior merged definition.
11307 ///
11308 /// \returns true if an error occurred, false otherwise.
11310 TemplateParameterList *OldParams,
11312 SkipBodyInfo *SkipBody = nullptr);
11313
11314 /// Match the given template parameter lists to the given scope
11315 /// specifier, returning the template parameter list that applies to the
11316 /// name.
11317 ///
11318 /// \param DeclStartLoc the start of the declaration that has a scope
11319 /// specifier or a template parameter list.
11320 ///
11321 /// \param DeclLoc The location of the declaration itself.
11322 ///
11323 /// \param SS the scope specifier that will be matched to the given template
11324 /// parameter lists. This scope specifier precedes a qualified name that is
11325 /// being declared.
11326 ///
11327 /// \param TemplateId The template-id following the scope specifier, if there
11328 /// is one. Used to check for a missing 'template<>'.
11329 ///
11330 /// \param ParamLists the template parameter lists, from the outermost to the
11331 /// innermost template parameter lists.
11332 ///
11333 /// \param IsFriend Whether to apply the slightly different rules for
11334 /// matching template parameters to scope specifiers in friend
11335 /// declarations.
11336 ///
11337 /// \param IsMemberSpecialization will be set true if the scope specifier
11338 /// denotes a fully-specialized type, and therefore this is a declaration of
11339 /// a member specialization.
11340 ///
11341 /// \returns the template parameter list, if any, that corresponds to the
11342 /// name that is preceded by the scope specifier @p SS. This template
11343 /// parameter list may have template parameters (if we're declaring a
11344 /// template) or may have no template parameters (if we're declaring a
11345 /// template specialization), or may be NULL (if what we're declaring isn't
11346 /// itself a template).
11348 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11349 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11350 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11351 bool &IsMemberSpecialization, bool &Invalid,
11352 bool SuppressDiagnostic = false);
11353
11354 /// Returns the template parameter list with all default template argument
11355 /// information.
11357
11359 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11360 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11361 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11362 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11363 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11364 TemplateParameterList **OuterTemplateParamLists,
11365 SkipBodyInfo *SkipBody = nullptr);
11366
11367 /// Translates template arguments as provided by the parser
11368 /// into template arguments used by semantic analysis.
11371
11372 /// Convert a parsed type into a parsed template argument. This is mostly
11373 /// trivial, except that we may have parsed a C++17 deduced class template
11374 /// specialization type, in which case we should form a template template
11375 /// argument instead of a type template argument.
11377
11379
11381 SourceLocation TemplateLoc,
11382 TemplateArgumentListInfo &TemplateArgs);
11383
11386 TemplateTy Template, const IdentifierInfo *TemplateII,
11387 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11388 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11389 bool IsCtorOrDtorName = false, bool IsClassName = false,
11390 ImplicitTypenameContext AllowImplicitTypename =
11392
11393 /// Parsed an elaborated-type-specifier that refers to a template-id,
11394 /// such as \c class T::template apply<U>.
11396 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11397 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11398 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11399 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11400
11403 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11405
11406 /// Get the specialization of the given variable template corresponding to
11407 /// the specified argument list, or a null-but-valid result if the arguments
11408 /// are dependent.
11410 SourceLocation TemplateLoc,
11411 SourceLocation TemplateNameLoc,
11412 const TemplateArgumentListInfo &TemplateArgs);
11413
11414 /// Form a reference to the specialization of the given variable template
11415 /// corresponding to the specified argument list, or a null-but-valid result
11416 /// if the arguments are dependent.
11418 const DeclarationNameInfo &NameInfo,
11419 VarTemplateDecl *Template, NamedDecl *FoundD,
11420 SourceLocation TemplateLoc,
11421 const TemplateArgumentListInfo *TemplateArgs);
11422
11424 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11425 const DeclarationNameInfo &ConceptNameInfo,
11426 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
11427 const TemplateArgumentListInfo *TemplateArgs);
11428
11431 bool TemplateKeyword, TemplateDecl *TD,
11433
11435 SourceLocation TemplateKWLoc, LookupResult &R,
11436 bool RequiresADL,
11437 const TemplateArgumentListInfo *TemplateArgs);
11438
11439 // We actually only call this from template instantiation.
11442 const DeclarationNameInfo &NameInfo,
11443 const TemplateArgumentListInfo *TemplateArgs,
11444 bool IsAddressOfOperand);
11445
11446 /// Form a template name from a name that is syntactically required to name a
11447 /// template, either due to use of the 'template' keyword or because a name in
11448 /// this syntactic context is assumed to name a template (C++
11449 /// [temp.names]p2-4).
11450 ///
11451 /// This action forms a template name given the name of the template and its
11452 /// optional scope specifier. This is used when the 'template' keyword is used
11453 /// or when the parsing context unambiguously treats a following '<' as
11454 /// introducing a template argument list. Note that this may produce a
11455 /// non-dependent template name if we can perform the lookup now and identify
11456 /// the named template.
11457 ///
11458 /// For example, given "x.MetaFun::template apply", the scope specifier
11459 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11460 /// of the "template" keyword, and "apply" is the \p Name.
11462 SourceLocation TemplateKWLoc,
11463 const UnqualifiedId &Name,
11464 ParsedType ObjectType,
11465 bool EnteringContext, TemplateTy &Template,
11466 bool AllowInjectedClassName = false);
11467
11469 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11470 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11472 MultiTemplateParamsArg TemplateParameterLists,
11473 SkipBodyInfo *SkipBody = nullptr);
11474
11475 /// Check the non-type template arguments of a class template
11476 /// partial specialization according to C++ [temp.class.spec]p9.
11477 ///
11478 /// \param TemplateNameLoc the location of the template name.
11479 /// \param PrimaryTemplate the template parameters of the primary class
11480 /// template.
11481 /// \param NumExplicit the number of explicitly-specified template arguments.
11482 /// \param TemplateArgs the template arguments of the class template
11483 /// partial specialization.
11484 ///
11485 /// \returns \c true if there was an error, \c false otherwise.
11487 TemplateDecl *PrimaryTemplate,
11488 unsigned NumExplicitArgs,
11494
11496 MultiTemplateParamsArg TemplateParameterLists,
11497 Declarator &D);
11498
11499 /// Diagnose cases where we have an explicit template specialization
11500 /// before/after an explicit template instantiation, producing diagnostics
11501 /// for those cases where they are required and determining whether the
11502 /// new specialization/instantiation will have any effect.
11503 ///
11504 /// \param NewLoc the location of the new explicit specialization or
11505 /// instantiation.
11506 ///
11507 /// \param NewTSK the kind of the new explicit specialization or
11508 /// instantiation.
11509 ///
11510 /// \param PrevDecl the previous declaration of the entity.
11511 ///
11512 /// \param PrevTSK the kind of the old explicit specialization or
11513 /// instantiatin.
11514 ///
11515 /// \param PrevPointOfInstantiation if valid, indicates where the previous
11516 /// declaration was instantiated (either implicitly or explicitly).
11517 ///
11518 /// \param HasNoEffect will be set to true to indicate that the new
11519 /// specialization or instantiation has no effect and should be ignored.
11520 ///
11521 /// \returns true if there was an error that should prevent the introduction
11522 /// of the new declaration into the AST, false otherwise.
11524 SourceLocation NewLoc,
11525 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
11526 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
11527 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
11528
11529 /// Perform semantic analysis for the given dependent function
11530 /// template specialization.
11531 ///
11532 /// The only possible way to get a dependent function template specialization
11533 /// is with a friend declaration, like so:
11534 ///
11535 /// \code
11536 /// template <class T> void foo(T);
11537 /// template <class T> class A {
11538 /// friend void foo<>(T);
11539 /// };
11540 /// \endcode
11541 ///
11542 /// There really isn't any useful analysis we can do here, so we
11543 /// just store the information.
11545 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
11547
11548 /// Perform semantic analysis for the given function template
11549 /// specialization.
11550 ///
11551 /// This routine performs all of the semantic analysis required for an
11552 /// explicit function template specialization. On successful completion,
11553 /// the function declaration \p FD will become a function template
11554 /// specialization.
11555 ///
11556 /// \param FD the function declaration, which will be updated to become a
11557 /// function template specialization.
11558 ///
11559 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
11560 /// if any. Note that this may be valid info even when 0 arguments are
11561 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
11562 /// as it anyway contains info on the angle brackets locations.
11563 ///
11564 /// \param Previous the set of declarations that may be specialized by
11565 /// this function specialization.
11566 ///
11567 /// \param QualifiedFriend whether this is a lookup for a qualified friend
11568 /// declaration with no explicit template argument list that might be
11569 /// befriending a function template specialization.
11571 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
11572 LookupResult &Previous, bool QualifiedFriend = false);
11573
11574 /// Perform semantic analysis for the given non-template member
11575 /// specialization.
11576 ///
11577 /// This routine performs all of the semantic analysis required for an
11578 /// explicit member function specialization. On successful completion,
11579 /// the function declaration \p FD will become a member function
11580 /// specialization.
11581 ///
11582 /// \param Member the member declaration, which will be updated to become a
11583 /// specialization.
11584 ///
11585 /// \param Previous the set of declarations, one of which may be specialized
11586 /// by this function specialization; the set will be modified to contain the
11587 /// redeclared member.
11590
11591 // Explicit instantiation of a class template specialization
11593 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
11594 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
11595 TemplateTy Template, SourceLocation TemplateNameLoc,
11596 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
11597 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
11598
11599 // Explicit instantiation of a member class of a class template.
11601 SourceLocation TemplateLoc,
11602 unsigned TagSpec, SourceLocation KWLoc,
11603 CXXScopeSpec &SS, IdentifierInfo *Name,
11604 SourceLocation NameLoc,
11605 const ParsedAttributesView &Attr);
11606
11608 SourceLocation TemplateLoc,
11609 Declarator &D);
11610
11611 /// If the given template parameter has a default template
11612 /// argument, substitute into that default template argument and
11613 /// return the corresponding template argument.
11615 TemplateDecl *Template, SourceLocation TemplateLoc,
11616 SourceLocation RAngleLoc, Decl *Param,
11617 ArrayRef<TemplateArgument> SugaredConverted,
11618 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
11619
11620 /// Returns the top most location responsible for the definition of \p N.
11621 /// If \p N is a a template specialization, this is the location
11622 /// of the top of the instantiation stack.
11623 /// Otherwise, the location of \p N is returned.
11625
11626 /// Specifies the context in which a particular template
11627 /// argument is being checked.
11629 /// The template argument was specified in the code or was
11630 /// instantiated with some deduced template arguments.
11632
11633 /// The template argument was deduced via template argument
11634 /// deduction.
11636
11637 /// The template argument was deduced from an array bound
11638 /// via template argument deduction.
11641
11642 /// Check that the given template argument corresponds to the given
11643 /// template parameter.
11644 ///
11645 /// \param Param The template parameter against which the argument will be
11646 /// checked.
11647 ///
11648 /// \param Arg The template argument, which may be updated due to conversions.
11649 ///
11650 /// \param Template The template in which the template argument resides.
11651 ///
11652 /// \param TemplateLoc The location of the template name for the template
11653 /// whose argument list we're matching.
11654 ///
11655 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
11656 /// the template argument list.
11657 ///
11658 /// \param ArgumentPackIndex The index into the argument pack where this
11659 /// argument will be placed. Only valid if the parameter is a parameter pack.
11660 ///
11661 /// \param Converted The checked, converted argument will be added to the
11662 /// end of this small vector.
11663 ///
11664 /// \param CTAK Describes how we arrived at this particular template argument:
11665 /// explicitly written, deduced, etc.
11666 ///
11667 /// \returns true on error, false otherwise.
11668 bool
11670 NamedDecl *Template, SourceLocation TemplateLoc,
11671 SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
11672 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11673 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11675
11676 /// Check that the given template arguments can be provided to
11677 /// the given template, converting the arguments along the way.
11678 ///
11679 /// \param Template The template to which the template arguments are being
11680 /// provided.
11681 ///
11682 /// \param TemplateLoc The location of the template name in the source.
11683 ///
11684 /// \param TemplateArgs The list of template arguments. If the template is
11685 /// a template template parameter, this function may extend the set of
11686 /// template arguments to also include substituted, defaulted template
11687 /// arguments.
11688 ///
11689 /// \param PartialTemplateArgs True if the list of template arguments is
11690 /// intentionally partial, e.g., because we're checking just the initial
11691 /// set of template arguments.
11692 ///
11693 /// \param Converted Will receive the converted, canonicalized template
11694 /// arguments.
11695 ///
11696 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
11697 /// contain the converted forms of the template arguments as written.
11698 /// Otherwise, \p TemplateArgs will not be modified.
11699 ///
11700 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
11701 /// receive true if the cause for the error is the associated constraints of
11702 /// the template not being satisfied by the template arguments.
11703 ///
11704 /// \param DefaultArgs any default arguments from template specialization
11705 /// deduction.
11706 ///
11707 /// \param PartialOrderingTTP If true, assume these template arguments are
11708 /// the injected template arguments for a template template parameter.
11709 /// This will relax the requirement that all its possible uses are valid:
11710 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11711 /// during instantiation.
11712 ///
11713 /// \returns true if an error occurred, false otherwise.
11715 TemplateDecl *Template, SourceLocation TemplateLoc,
11716 TemplateArgumentListInfo &TemplateArgs,
11717 const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
11718 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11719 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11720 bool UpdateArgsWithConversions = true,
11721 bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false);
11722
11725 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11726 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
11727
11728 /// Check a template argument against its corresponding
11729 /// template type parameter.
11730 ///
11731 /// This routine implements the semantics of C++ [temp.arg.type]. It
11732 /// returns true if an error occurred, and false otherwise.
11734
11735 /// Check a template argument against its corresponding
11736 /// non-type template parameter.
11737 ///
11738 /// This routine implements the semantics of C++ [temp.arg.nontype].
11739 /// If an error occurred, it returns ExprError(); otherwise, it
11740 /// returns the converted template argument. \p ParamType is the
11741 /// type of the non-type template parameter after it has been instantiated.
11743 QualType InstantiatedParamType, Expr *Arg,
11744 TemplateArgument &SugaredConverted,
11745 TemplateArgument &CanonicalConverted,
11747
11748 /// Check a template argument against its corresponding
11749 /// template template parameter.
11750 ///
11751 /// This routine implements the semantics of C++ [temp.arg.template].
11752 /// It returns true if an error occurred, and false otherwise.
11754 TemplateParameterList *Params,
11755 TemplateArgumentLoc &Arg, bool IsDeduced);
11756
11758 std::optional<SourceRange> ParamRange = {});
11759 void NoteTemplateParameterLocation(const NamedDecl &Decl);
11760
11761 /// Given a non-type template argument that refers to a
11762 /// declaration and the type of its corresponding non-type template
11763 /// parameter, produce an expression that properly refers to that
11764 /// declaration.
11766 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
11767 NamedDecl *TemplateParam = nullptr);
11769 BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg,
11770 SourceLocation Loc);
11771
11772 /// Enumeration describing how template parameter lists are compared
11773 /// for equality.
11775 /// We are matching the template parameter lists of two templates
11776 /// that might be redeclarations.
11777 ///
11778 /// \code
11779 /// template<typename T> struct X;
11780 /// template<typename T> struct X;
11781 /// \endcode
11783
11784 /// We are matching the template parameter lists of two template
11785 /// template parameters as part of matching the template parameter lists
11786 /// of two templates that might be redeclarations.
11787 ///
11788 /// \code
11789 /// template<template<int I> class TT> struct X;
11790 /// template<template<int Value> class Other> struct X;
11791 /// \endcode
11793
11794 /// We are matching the template parameter lists of a template
11795 /// template argument against the template parameter lists of a template
11796 /// template parameter.
11797 ///
11798 /// \code
11799 /// template<template<int Value> class Metafun> struct X;
11800 /// template<int Value> struct integer_c;
11801 /// X<integer_c> xic;
11802 /// \endcode
11804
11805 /// We are determining whether the template-parameters are equivalent
11806 /// according to C++ [temp.over.link]/6. This comparison does not consider
11807 /// constraints.
11808 ///
11809 /// \code
11810 /// template<C1 T> void f(T);
11811 /// template<C2 T> void f(T);
11812 /// \endcode
11814 };
11815
11816 // A struct to represent the 'new' declaration, which is either itself just
11817 // the named decl, or the important information we need about it in order to
11818 // do constraint comparisons.
11820 const NamedDecl *ND = nullptr;
11821 const DeclContext *DC = nullptr;
11822 const DeclContext *LexicalDC = nullptr;
11824
11825 public:
11828 const DeclContext *LexicalDeclCtx,
11830
11831 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
11832 assert(DC && LexicalDC &&
11833 "Constructor only for cases where we have the information to put "
11834 "in here");
11835 }
11836
11837 // If this was constructed with no information, we cannot do substitution
11838 // for constraint comparison, so make sure we can check that.
11839 bool isInvalid() const { return !ND && !DC; }
11840
11841 const NamedDecl *getDecl() const { return ND; }
11842
11843 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
11844
11846 return ND ? ND->getLexicalDeclContext() : LexicalDC;
11847 }
11848
11850 return ND ? ND->getDeclContext() : DC;
11851 }
11852
11853 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
11854 };
11855
11856 /// Determine whether the given template parameter lists are
11857 /// equivalent.
11858 ///
11859 /// \param New The new template parameter list, typically written in the
11860 /// source code as part of a new template declaration.
11861 ///
11862 /// \param Old The old template parameter list, typically found via
11863 /// name lookup of the template declared with this template parameter
11864 /// list.
11865 ///
11866 /// \param Complain If true, this routine will produce a diagnostic if
11867 /// the template parameter lists are not equivalent.
11868 ///
11869 /// \param Kind describes how we are to match the template parameter lists.
11870 ///
11871 /// \param TemplateArgLoc If this source location is valid, then we
11872 /// are actually checking the template parameter list of a template
11873 /// argument (New) against the template parameter list of its
11874 /// corresponding template template parameter (Old). We produce
11875 /// slightly different diagnostics in this scenario.
11876 ///
11877 /// \returns True if the template parameter lists are equal, false
11878 /// otherwise.
11880 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
11881 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
11883 SourceLocation TemplateArgLoc = SourceLocation());
11884
11886 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
11888 SourceLocation TemplateArgLoc = SourceLocation()) {
11889 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
11890 Kind, TemplateArgLoc);
11891 }
11892
11893 /// Check whether a template can be declared within this scope.
11894 ///
11895 /// If the template declaration is valid in this scope, returns
11896 /// false. Otherwise, issues a diagnostic and returns true.
11897 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
11898
11899 /// Called when the parser has parsed a C++ typename
11900 /// specifier, e.g., "typename T::type".
11901 ///
11902 /// \param S The scope in which this typename type occurs.
11903 /// \param TypenameLoc the location of the 'typename' keyword
11904 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11905 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
11906 /// \param IdLoc the location of the identifier.
11907 /// \param IsImplicitTypename context where T::type refers to a type.
11909 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
11910 const IdentifierInfo &II, SourceLocation IdLoc,
11912
11913 /// Called when the parser has parsed a C++ typename
11914 /// specifier that ends in a template-id, e.g.,
11915 /// "typename MetaFun::template apply<T1, T2>".
11916 ///
11917 /// \param S The scope in which this typename type occurs.
11918 /// \param TypenameLoc the location of the 'typename' keyword
11919 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11920 /// \param TemplateLoc the location of the 'template' keyword, if any.
11921 /// \param TemplateName The template name.
11922 /// \param TemplateII The identifier used to name the template.
11923 /// \param TemplateIILoc The location of the template name.
11924 /// \param LAngleLoc The location of the opening angle bracket ('<').
11925 /// \param TemplateArgs The template arguments.
11926 /// \param RAngleLoc The location of the closing angle bracket ('>').
11928 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
11929 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
11930 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
11931 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11932 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
11933
11935 SourceLocation KeywordLoc,
11936 NestedNameSpecifierLoc QualifierLoc,
11937 const IdentifierInfo &II, SourceLocation IILoc,
11938 TypeSourceInfo **TSI, bool DeducedTSTContext);
11939
11941 SourceLocation KeywordLoc,
11942 NestedNameSpecifierLoc QualifierLoc,
11943 const IdentifierInfo &II, SourceLocation IILoc,
11944 bool DeducedTSTContext = true);
11945
11946 /// Rebuilds a type within the context of the current instantiation.
11947 ///
11948 /// The type \p T is part of the type of an out-of-line member definition of
11949 /// a class template (or class template partial specialization) that was
11950 /// parsed and constructed before we entered the scope of the class template
11951 /// (or partial specialization thereof). This routine will rebuild that type
11952 /// now that we have entered the declarator's scope, which may produce
11953 /// different canonical types, e.g.,
11954 ///
11955 /// \code
11956 /// template<typename T>
11957 /// struct X {
11958 /// typedef T* pointer;
11959 /// pointer data();
11960 /// };
11961 ///
11962 /// template<typename T>
11963 /// typename X<T>::pointer X<T>::data() { ... }
11964 /// \endcode
11965 ///
11966 /// Here, the type "typename X<T>::pointer" will be created as a
11967 /// DependentNameType, since we do not know that we can look into X<T> when we
11968 /// parsed the type. This function will rebuild the type, performing the
11969 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
11970 /// canonical type is the same as the canonical type of T*, allowing the
11971 /// return types of the out-of-line definition and the declaration to match.
11974 DeclarationName Name);
11976
11978
11979 /// Rebuild the template parameters now that we know we're in a current
11980 /// instantiation.
11981 bool
11983
11984 /// Produces a formatted string that describes the binding of
11985 /// template parameters to template arguments.
11986 std::string
11988 const TemplateArgumentList &Args);
11989
11990 std::string
11992 const TemplateArgument *Args,
11993 unsigned NumArgs);
11994
11998
11999 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12000 /// was just parsed. This is only possible with an explicit scope
12001 /// specifier naming a dependent type.
12003 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12004 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12005 const TemplateArgumentListInfo *TemplateArgs);
12006
12009 SourceLocation TemplateKWLoc,
12010 const DeclarationNameInfo &NameInfo,
12011 const TemplateArgumentListInfo *TemplateArgs);
12012
12013 // Calculates whether the expression Constraint depends on an enclosing
12014 // template, for the purposes of [temp.friend] p9.
12015 // TemplateDepth is the 'depth' of the friend function, which is used to
12016 // compare whether a declaration reference is referring to a containing
12017 // template, or just the current friend function. A 'lower' TemplateDepth in
12018 // the AST refers to a 'containing' template. As the constraint is
12019 // uninstantiated, this is relative to the 'top' of the TU.
12020 bool
12022 unsigned TemplateDepth,
12023 const Expr *Constraint);
12024
12025 /// Find the failed Boolean condition within a given Boolean
12026 /// constant expression, and describe it with a string.
12027 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12028
12030
12032 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12033 const IdentifierInfo *Name, SourceLocation NameLoc);
12034
12036 Expr *ConstraintExpr,
12037 const ParsedAttributesView &Attrs);
12038
12040 bool &AddToScope);
12042
12043 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12044 const CXXScopeSpec &SS,
12045 const IdentifierInfo *Name,
12046 SourceLocation TagLoc, SourceLocation NameLoc);
12047
12049 CachedTokens &Toks);
12052
12053 /// We've found a use of a templated declaration that would trigger an
12054 /// implicit instantiation. Check that any relevant explicit specializations
12055 /// and partial specializations are visible/reachable, and diagnose if not.
12058
12059 ///@}
12060
12061 //
12062 //
12063 // -------------------------------------------------------------------------
12064 //
12065 //
12066
12067 /// \name C++ Template Argument Deduction
12068 /// Implementations are in SemaTemplateDeduction.cpp
12069 ///@{
12070
12071public:
12072 /// When true, access checking violations are treated as SFINAE
12073 /// failures rather than hard errors.
12075
12076 /// RAII class used to determine whether SFINAE has
12077 /// trapped any errors that occur during template argument
12078 /// deduction.
12080 Sema &SemaRef;
12081 unsigned PrevSFINAEErrors;
12082 bool PrevInNonInstantiationSFINAEContext;
12083 bool PrevAccessCheckingSFINAE;
12084 bool PrevLastDiagnosticIgnored;
12085
12086 public:
12087 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
12088 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
12089 PrevInNonInstantiationSFINAEContext(
12090 SemaRef.InNonInstantiationSFINAEContext),
12091 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
12092 PrevLastDiagnosticIgnored(
12093 SemaRef.getDiagnostics().isLastDiagnosticIgnored()) {
12094 if (!SemaRef.isSFINAEContext())
12095 SemaRef.InNonInstantiationSFINAEContext = true;
12096 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
12097 }
12098
12100 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
12102 PrevInNonInstantiationSFINAEContext;
12103 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
12105 PrevLastDiagnosticIgnored);
12106 }
12107
12108 /// Determine whether any SFINAE errors have been trapped.
12109 bool hasErrorOccurred() const {
12110 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
12111 }
12112 };
12113
12114 /// RAII class used to indicate that we are performing provisional
12115 /// semantic analysis to determine the validity of a construct, so
12116 /// typo-correction and diagnostics in the immediate context (not within
12117 /// implicitly-instantiated templates) should be suppressed.
12119 Sema &SemaRef;
12120 // FIXME: Using a SFINAETrap for this is a hack.
12121 SFINAETrap Trap;
12122 bool PrevDisableTypoCorrection;
12123
12124 public:
12125 explicit TentativeAnalysisScope(Sema &SemaRef)
12126 : SemaRef(SemaRef), Trap(SemaRef, true),
12127 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12128 SemaRef.DisableTypoCorrection = true;
12129 }
12131 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12132 }
12133 };
12134
12135 /// For each declaration that involved template argument deduction, the
12136 /// set of diagnostics that were suppressed during that template argument
12137 /// deduction.
12138 ///
12139 /// FIXME: Serialize this structure to the AST file.
12140 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12143
12144 /// Compare types for equality with respect to possibly compatible
12145 /// function types (noreturn adjustment, implicit calling conventions). If any
12146 /// of parameter and argument is not a function, just perform type comparison.
12147 ///
12148 /// \param P the template parameter type.
12149 ///
12150 /// \param A the argument type.
12152
12153 /// Allocate a TemplateArgumentLoc where all locations have
12154 /// been initialized to the given location.
12155 ///
12156 /// \param Arg The template argument we are producing template argument
12157 /// location information for.
12158 ///
12159 /// \param NTTPType For a declaration template argument, the type of
12160 /// the non-type template parameter that corresponds to this template
12161 /// argument. Can be null if no type sugar is available to add to the
12162 /// type from the template argument.
12163 ///
12164 /// \param Loc The source location to use for the resulting template
12165 /// argument.
12169 NamedDecl *TemplateParam = nullptr);
12170
12171 /// Get a template argument mapping the given template parameter to itself,
12172 /// e.g. for X in \c template<int X>, this would return an expression template
12173 /// argument referencing X.
12175 SourceLocation Location);
12176
12177 /// Adjust the type \p ArgFunctionType to match the calling convention,
12178 /// noreturn, and optionally the exception specification of \p FunctionType.
12179 /// Deduction often wants to ignore these properties when matching function
12180 /// types.
12182 bool AdjustExceptionSpec = false);
12183
12186 ArrayRef<TemplateArgument> TemplateArgs,
12188
12191 ArrayRef<TemplateArgument> TemplateArgs,
12193
12194 /// Deduce the template arguments of the given template from \p FromType.
12195 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12196 /// [over.match.class.deduct]p4.
12197 ///
12198 /// It only supports class or type alias templates.
12202
12207 bool NumberOfArgumentsMustMatch);
12208
12209 /// Substitute the explicitly-provided template arguments into the
12210 /// given function template according to C++ [temp.arg.explicit].
12211 ///
12212 /// \param FunctionTemplate the function template into which the explicit
12213 /// template arguments will be substituted.
12214 ///
12215 /// \param ExplicitTemplateArgs the explicitly-specified template
12216 /// arguments.
12217 ///
12218 /// \param Deduced the deduced template arguments, which will be populated
12219 /// with the converted and checked explicit template arguments.
12220 ///
12221 /// \param ParamTypes will be populated with the instantiated function
12222 /// parameters.
12223 ///
12224 /// \param FunctionType if non-NULL, the result type of the function template
12225 /// will also be instantiated and the pointed-to value will be updated with
12226 /// the instantiated function type.
12227 ///
12228 /// \param Info if substitution fails for any reason, this object will be
12229 /// populated with more information about the failure.
12230 ///
12231 /// \returns TemplateDeductionResult::Success if substitution was successful,
12232 /// or some failure condition.
12235 TemplateArgumentListInfo &ExplicitTemplateArgs,
12239
12240 /// brief A function argument from which we performed template argument
12241 // deduction for a call.
12243 OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
12244 unsigned ArgIdx, QualType OriginalArgType)
12245 : OriginalParamType(OriginalParamType),
12246 DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
12247 OriginalArgType(OriginalArgType) {}
12248
12251 unsigned ArgIdx;
12253 };
12254
12255 /// Finish template argument deduction for a function template,
12256 /// checking the deduced template arguments for completeness and forming
12257 /// the function template specialization.
12258 ///
12259 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12260 /// which the deduced argument types should be compared.
12264 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12266 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
12267 bool PartialOverloading = false,
12268 llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
12269
12270 /// Perform template argument deduction from a function call
12271 /// (C++ [temp.deduct.call]).
12272 ///
12273 /// \param FunctionTemplate the function template for which we are performing
12274 /// template argument deduction.
12275 ///
12276 /// \param ExplicitTemplateArgs the explicit template arguments provided
12277 /// for this call.
12278 ///
12279 /// \param Args the function call arguments
12280 ///
12281 /// \param Specialization if template argument deduction was successful,
12282 /// this will be set to the function template specialization produced by
12283 /// template argument deduction.
12284 ///
12285 /// \param Info the argument will be updated to provide additional information
12286 /// about template argument deduction.
12287 ///
12288 /// \param CheckNonDependent A callback to invoke to check conversions for
12289 /// non-dependent parameters, between deduction and substitution, per DR1391.
12290 /// If this returns true, substitution will be skipped and we return
12291 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12292 /// passed the parameter types (after substituting explicit template
12293 /// arguments).
12294 ///
12295 /// \returns the result of template argument deduction.
12298 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12300 bool PartialOverloading, bool AggregateDeductionCandidate,
12301 QualType ObjectType, Expr::Classification ObjectClassification,
12302 llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
12303
12304 /// Deduce template arguments when taking the address of a function
12305 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12306 /// a template.
12307 ///
12308 /// \param FunctionTemplate the function template for which we are performing
12309 /// template argument deduction.
12310 ///
12311 /// \param ExplicitTemplateArgs the explicitly-specified template
12312 /// arguments.
12313 ///
12314 /// \param ArgFunctionType the function type that will be used as the
12315 /// "argument" type (A) when performing template argument deduction from the
12316 /// function template's function type. This type may be NULL, if there is no
12317 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12318 ///
12319 /// \param Specialization if template argument deduction was successful,
12320 /// this will be set to the function template specialization produced by
12321 /// template argument deduction.
12322 ///
12323 /// \param Info the argument will be updated to provide additional information
12324 /// about template argument deduction.
12325 ///
12326 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12327 /// the address of a function template per [temp.deduct.funcaddr] and
12328 /// [over.over]. If \c false, we are looking up a function template
12329 /// specialization based on its signature, per [temp.deduct.decl].
12330 ///
12331 /// \returns the result of template argument deduction.
12334 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12336 bool IsAddressOfFunction = false);
12337
12338 /// Deduce template arguments for a templated conversion
12339 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12340 /// conversion function template specialization.
12343 Expr::Classification ObjectClassification, QualType ToType,
12345
12346 /// Deduce template arguments for a function template when there is
12347 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12348 ///
12349 /// \param FunctionTemplate the function template for which we are performing
12350 /// template argument deduction.
12351 ///
12352 /// \param ExplicitTemplateArgs the explicitly-specified template
12353 /// arguments.
12354 ///
12355 /// \param Specialization if template argument deduction was successful,
12356 /// this will be set to the function template specialization produced by
12357 /// template argument deduction.
12358 ///
12359 /// \param Info the argument will be updated to provide additional information
12360 /// about template argument deduction.
12361 ///
12362 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12363 /// the address of a function template in a context where we do not have a
12364 /// target type, per [over.over]. If \c false, we are looking up a function
12365 /// template specialization based on its signature, which only happens when
12366 /// deducing a function parameter type from an argument that is a template-id
12367 /// naming a function template specialization.
12368 ///
12369 /// \returns the result of template argument deduction.
12372 TemplateArgumentListInfo *ExplicitTemplateArgs,
12375 bool IsAddressOfFunction = false);
12376
12377 /// Substitute Replacement for \p auto in \p TypeWithAuto
12378 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12379 /// Substitute Replacement for auto in TypeWithAuto
12381 QualType Replacement);
12382
12383 // Substitute auto in TypeWithAuto for a Dependent auto type
12385
12386 // Substitute auto in TypeWithAuto for a Dependent auto type
12389
12390 /// Completely replace the \c auto in \p TypeWithAuto by
12391 /// \p Replacement. This does not retain any \c auto type sugar.
12392 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12394 QualType Replacement);
12395
12396 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12397 ///
12398 /// Note that this is done even if the initializer is dependent. (This is
12399 /// necessary to support partial ordering of templates using 'auto'.)
12400 /// A dependent type will be produced when deducing from a dependent type.
12401 ///
12402 /// \param Type the type pattern using the auto type-specifier.
12403 /// \param Init the initializer for the variable whose type is to be deduced.
12404 /// \param Result if type deduction was successful, this will be set to the
12405 /// deduced type.
12406 /// \param Info the argument will be updated to provide additional information
12407 /// about template argument deduction.
12408 /// \param DependentDeduction Set if we should permit deduction in
12409 /// dependent cases. This is necessary for template partial ordering
12410 /// with 'auto' template parameters. The template parameter depth to be
12411 /// used should be specified in the 'Info' parameter.
12412 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12413 /// does not satisfy the type-constraint in the auto
12414 /// type.
12418 bool DependentDeduction = false,
12419 bool IgnoreConstraints = false,
12420 TemplateSpecCandidateSet *FailedTSC = nullptr);
12421 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12423 bool Diagnose = true);
12424
12427
12428 /// Returns the more specialized class template partial specialization
12429 /// according to the rules of partial ordering of class template partial
12430 /// specializations (C++ [temp.class.order]).
12431 ///
12432 /// \param PS1 the first class template partial specialization
12433 ///
12434 /// \param PS2 the second class template partial specialization
12435 ///
12436 /// \returns the more specialized class template partial specialization. If
12437 /// neither partial specialization is more specialized, returns NULL.
12442
12445
12449
12452
12454 TemplateParameterList *PParam, TemplateDecl *AArg,
12455 const DefaultArguments &DefaultArgs, SourceLocation Loc, bool IsDeduced);
12456
12457 /// Mark which template parameters are used in a given expression.
12458 ///
12459 /// \param E the expression from which template parameters will be deduced.
12460 ///
12461 /// \param Used a bit vector whose elements will be set to \c true
12462 /// to indicate when the corresponding template parameter will be
12463 /// deduced.
12464 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12465 unsigned Depth, llvm::SmallBitVector &Used);
12466
12467 /// Mark which template parameters can be deduced from a given
12468 /// template argument list.
12469 ///
12470 /// \param TemplateArgs the template argument list from which template
12471 /// parameters will be deduced.
12472 ///
12473 /// \param Used a bit vector whose elements will be set to \c true
12474 /// to indicate when the corresponding template parameter will be
12475 /// deduced.
12476 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
12477 bool OnlyDeduced, unsigned Depth,
12478 llvm::SmallBitVector &Used);
12479 void
12481 llvm::SmallBitVector &Deduced) {
12483 }
12484
12485 /// Marks all of the template parameters that will be deduced by a
12486 /// call to the given function template.
12487 static void
12490 llvm::SmallBitVector &Deduced);
12491
12492 /// Returns the more specialized function template according
12493 /// to the rules of function template partial ordering (C++
12494 /// [temp.func.order]).
12495 ///
12496 /// \param FT1 the first function template
12497 ///
12498 /// \param FT2 the second function template
12499 ///
12500 /// \param TPOC the context in which we are performing partial ordering of
12501 /// function templates.
12502 ///
12503 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
12504 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
12505 /// when calling a member function.
12506 ///
12507 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
12508 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
12509 /// template from a member function
12510 ///
12511 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
12512 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
12513 /// template from a member function
12514 ///
12515 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
12516 /// candidate with a reversed parameter order. In this case, the corresponding
12517 /// P/A pairs between FT1 and FT2 are reversed.
12518 ///
12519 /// \returns the more specialized function template. If neither
12520 /// template is more specialized, returns NULL.
12523 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
12524 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false);
12525
12526 /// Retrieve the most specialized of the given function template
12527 /// specializations.
12528 ///
12529 /// \param SpecBegin the start iterator of the function template
12530 /// specializations that we will be comparing.
12531 ///
12532 /// \param SpecEnd the end iterator of the function template
12533 /// specializations, paired with \p SpecBegin.
12534 ///
12535 /// \param Loc the location where the ambiguity or no-specializations
12536 /// diagnostic should occur.
12537 ///
12538 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
12539 /// no matching candidates.
12540 ///
12541 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
12542 /// occurs.
12543 ///
12544 /// \param CandidateDiag partial diagnostic used for each function template
12545 /// specialization that is a candidate in the ambiguous ordering. One
12546 /// parameter in this diagnostic should be unbound, which will correspond to
12547 /// the string describing the template arguments for the function template
12548 /// specialization.
12549 ///
12550 /// \returns the most specialized function template specialization, if
12551 /// found. Otherwise, returns SpecEnd.
12552 UnresolvedSetIterator
12553 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
12554 TemplateSpecCandidateSet &FailedCandidates,
12555 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
12556 const PartialDiagnostic &AmbigDiag,
12557 const PartialDiagnostic &CandidateDiag,
12558 bool Complain = true, QualType TargetType = QualType());
12559
12560 /// Returns the more constrained function according to the rules of
12561 /// partial ordering by constraints (C++ [temp.constr.order]).
12562 ///
12563 /// \param FD1 the first function
12564 ///
12565 /// \param FD2 the second function
12566 ///
12567 /// \returns the more constrained function. If neither function is
12568 /// more constrained, returns NULL.
12569 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
12570 FunctionDecl *FD2);
12571
12572 ///@}
12573
12574 //
12575 //
12576 // -------------------------------------------------------------------------
12577 //
12578 //
12579
12580 /// \name C++ Template Deduction Guide
12581 /// Implementations are in SemaTemplateDeductionGuide.cpp
12582 ///@{
12583
12584 /// Declare implicit deduction guides for a class template if we've
12585 /// not already done so.
12586 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12587 SourceLocation Loc);
12588
12589 FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12590 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12591 SourceLocation Loc);
12592
12593 ///@}
12594
12595 //
12596 //
12597 // -------------------------------------------------------------------------
12598 //
12599 //
12600
12601 /// \name C++ Template Instantiation
12602 /// Implementations are in SemaTemplateInstantiate.cpp
12603 ///@{
12604
12605public:
12606 /// A helper class for building up ExtParameterInfos.
12609 bool HasInteresting = false;
12610
12611 public:
12612 /// Set the ExtParameterInfo for the parameter at the given index,
12613 ///
12614 void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
12615 assert(Infos.size() <= index);
12616 Infos.resize(index);
12617 Infos.push_back(info);
12618
12619 if (!HasInteresting)
12620 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
12621 }
12622
12623 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
12624 /// ExtParameterInfo array we've built up.
12626 getPointerOrNull(unsigned numParams) {
12627 if (!HasInteresting)
12628 return nullptr;
12629 Infos.resize(numParams);
12630 return Infos.data();
12631 }
12632 };
12633
12634 /// The current instantiation scope used to store local
12635 /// variables.
12637
12638 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
12640
12641 /// A mapping from parameters with unparsed default arguments to the
12642 /// set of instantiations of each parameter.
12643 ///
12644 /// This mapping is a temporary data structure used when parsing
12645 /// nested class templates or nested classes of class templates,
12646 /// where we might end up instantiating an inner class before the
12647 /// default arguments of its methods have been parsed.
12649
12650 /// A context in which code is being synthesized (where a source location
12651 /// alone is not sufficient to identify the context). This covers template
12652 /// instantiation and various forms of implicitly-generated functions.
12654 /// The kind of template instantiation we are performing
12656 /// We are instantiating a template declaration. The entity is
12657 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
12659
12660 /// We are instantiating a default argument for a template
12661 /// parameter. The Entity is the template parameter whose argument is
12662 /// being instantiated, the Template is the template, and the
12663 /// TemplateArgs/NumTemplateArguments provide the template arguments as
12664 /// specified.
12666
12667 /// We are instantiating a default argument for a function.
12668 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
12669 /// provides the template arguments as specified.
12671
12672 /// We are substituting explicit template arguments provided for
12673 /// a function template. The entity is a FunctionTemplateDecl.
12675
12676 /// We are substituting template argument determined as part of
12677 /// template argument deduction for either a class template
12678 /// partial specialization or a function template. The
12679 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
12680 /// a TemplateDecl.
12682
12683 /// We are substituting into a lambda expression.
12685
12686 /// We are substituting prior template arguments into a new
12687 /// template parameter. The template parameter itself is either a
12688 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
12690
12691 /// We are checking the validity of a default template argument that
12692 /// has been used when naming a template-id.
12694
12695 /// We are computing the exception specification for a defaulted special
12696 /// member function.
12698
12699 /// We are instantiating the exception specification for a function
12700 /// template which was deferred until it was needed.
12702
12703 /// We are instantiating a requirement of a requires expression.
12705
12706 /// We are checking the satisfaction of a nested requirement of a requires
12707 /// expression.
12709
12710 /// We are declaring an implicit special member function.
12712
12713 /// We are declaring an implicit 'operator==' for a defaulted
12714 /// 'operator<=>'.
12716
12717 /// We are defining a synthesized function (such as a defaulted special
12718 /// member).
12720
12721 // We are checking the constraints associated with a constrained entity or
12722 // the constraint expression of a concept. This includes the checks that
12723 // atomic constraints have the type 'bool' and that they can be constant
12724 // evaluated.
12726
12727 // We are substituting template arguments into a constraint expression.
12729
12730 // We are normalizing a constraint expression.
12732
12733 // Instantiating a Requires Expression parameter clause.
12735
12736 // We are substituting into the parameter mapping of an atomic constraint
12737 // during normalization.
12739
12740 /// We are rewriting a comparison operator in terms of an operator<=>.
12742
12743 /// We are initializing a structured binding.
12745
12746 /// We are marking a class as __dllexport.
12748
12749 /// We are building an implied call from __builtin_dump_struct. The
12750 /// arguments are in CallArgs.
12752
12753 /// Added for Template instantiation observation.
12754 /// Memoization means we are _not_ instantiating a template because
12755 /// it is already instantiated (but we entered a context where we
12756 /// would have had to if it was not already instantiated).
12758
12759 /// We are building deduction guides for a class.
12761
12762 /// We are instantiating a type alias template declaration.
12765
12766 /// Was the enclosing context a non-instantiation SFINAE context?
12768
12769 /// The point of instantiation or synthesis within the source code.
12771
12772 /// The entity that is being synthesized.
12774
12775 /// The template (or partial specialization) in which we are
12776 /// performing the instantiation, for substitutions of prior template
12777 /// arguments.
12779
12780 union {
12781 /// The list of template arguments we are substituting, if they
12782 /// are not part of the entity.
12784
12785 /// The list of argument expressions in a synthesized call.
12786 const Expr *const *CallArgs;
12787 };
12788
12789 // FIXME: Wrap this union around more members, or perhaps store the
12790 // kind-specific members in the RAII object owning the context.
12791 union {
12792 /// The number of template arguments in TemplateArgs.
12794
12795 /// The number of expressions in CallArgs.
12796 unsigned NumCallArgs;
12797
12798 /// The special member being declared or defined.
12800 };
12801
12803 assert(Kind != DeclaringSpecialMember);
12804 return {TemplateArgs, NumTemplateArgs};
12805 }
12806
12807 /// The template deduction info object associated with the
12808 /// substitution or checking of explicit or deduced template arguments.
12810
12811 /// The source range that covers the construct that cause
12812 /// the instantiation, e.g., the template-id that causes a class
12813 /// template instantiation.
12815
12817 : Kind(TemplateInstantiation),
12818 SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
12819 Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
12820 DeductionInfo(nullptr) {}
12821
12822 /// Determines whether this template is an actual instantiation
12823 /// that should be counted toward the maximum instantiation depth.
12824 bool isInstantiationRecord() const;
12825 };
12826
12827 /// A stack object to be created when performing template
12828 /// instantiation.
12829 ///
12830 /// Construction of an object of type \c InstantiatingTemplate
12831 /// pushes the current instantiation onto the stack of active
12832 /// instantiations. If the size of this stack exceeds the maximum
12833 /// number of recursive template instantiations, construction
12834 /// produces an error and evaluates true.
12835 ///
12836 /// Destruction of this object will pop the named instantiation off
12837 /// the stack.
12839 /// Note that we are instantiating a class template,
12840 /// function template, variable template, alias template,
12841 /// or a member thereof.
12842 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12843 Decl *Entity,
12844 SourceRange InstantiationRange = SourceRange());
12845
12847 /// Note that we are instantiating an exception specification
12848 /// of a function template.
12849 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12851 SourceRange InstantiationRange = SourceRange());
12852
12853 /// Note that we are instantiating a type alias template declaration.
12854 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12855 TypeAliasTemplateDecl *Entity,
12856 ArrayRef<TemplateArgument> TemplateArgs,
12857 SourceRange InstantiationRange = SourceRange());
12858
12859 /// Note that we are instantiating a default argument in a
12860 /// template-id.
12861 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12862 TemplateParameter Param, TemplateDecl *Template,
12863 ArrayRef<TemplateArgument> TemplateArgs,
12864 SourceRange InstantiationRange = SourceRange());
12865
12866 /// Note that we are substituting either explicitly-specified or
12867 /// deduced template arguments during function template argument deduction.
12868 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12869 FunctionTemplateDecl *FunctionTemplate,
12870 ArrayRef<TemplateArgument> TemplateArgs,
12872 sema::TemplateDeductionInfo &DeductionInfo,
12873 SourceRange InstantiationRange = SourceRange());
12874
12875 /// Note that we are instantiating as part of template
12876 /// argument deduction for a class template declaration.
12877 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12878 TemplateDecl *Template,
12879 ArrayRef<TemplateArgument> TemplateArgs,
12880 sema::TemplateDeductionInfo &DeductionInfo,
12881 SourceRange InstantiationRange = SourceRange());
12882
12883 /// Note that we are instantiating as part of template
12884 /// argument deduction for a class template partial
12885 /// specialization.
12886 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12888 ArrayRef<TemplateArgument> TemplateArgs,
12889 sema::TemplateDeductionInfo &DeductionInfo,
12890 SourceRange InstantiationRange = SourceRange());
12891
12892 /// Note that we are instantiating as part of template
12893 /// argument deduction for a variable template partial
12894 /// specialization.
12895 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12897 ArrayRef<TemplateArgument> TemplateArgs,
12898 sema::TemplateDeductionInfo &DeductionInfo,
12899 SourceRange InstantiationRange = SourceRange());
12900
12901 /// Note that we are instantiating a default argument for a function
12902 /// parameter.
12903 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12904 ParmVarDecl *Param,
12905 ArrayRef<TemplateArgument> TemplateArgs,
12906 SourceRange InstantiationRange = SourceRange());
12907
12908 /// Note that we are substituting prior template arguments into a
12909 /// non-type parameter.
12910 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12911 NamedDecl *Template, NonTypeTemplateParmDecl *Param,
12912 ArrayRef<TemplateArgument> TemplateArgs,
12913 SourceRange InstantiationRange);
12914
12915 /// Note that we are substituting prior template arguments into a
12916 /// template template parameter.
12917 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12918 NamedDecl *Template, TemplateTemplateParmDecl *Param,
12919 ArrayRef<TemplateArgument> TemplateArgs,
12920 SourceRange InstantiationRange);
12921
12922 /// Note that we are checking the default template argument
12923 /// against the template parameter for a given template-id.
12924 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12925 TemplateDecl *Template, NamedDecl *Param,
12926 ArrayRef<TemplateArgument> TemplateArgs,
12927 SourceRange InstantiationRange);
12928
12930 /// \brief Note that we are checking the constraints associated with some
12931 /// constrained entity (a concept declaration or a template with associated
12932 /// constraints).
12933 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12934 ConstraintsCheck, NamedDecl *Template,
12935 ArrayRef<TemplateArgument> TemplateArgs,
12936 SourceRange InstantiationRange);
12937
12939 /// \brief Note that we are checking a constraint expression associated
12940 /// with a template declaration or as part of the satisfaction check of a
12941 /// concept.
12942 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12944 sema::TemplateDeductionInfo &DeductionInfo,
12945 SourceRange InstantiationRange);
12946
12948 /// \brief Note that we are normalizing a constraint expression.
12949 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12951 SourceRange InstantiationRange);
12952
12954 /// \brief Note that we are subtituting into the parameter mapping of an
12955 /// atomic constraint during constraint normalization.
12956 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12958 SourceRange InstantiationRange);
12959
12960 /// \brief Note that we are substituting template arguments into a part of
12961 /// a requirement of a requires expression.
12962 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12964 sema::TemplateDeductionInfo &DeductionInfo,
12965 SourceRange InstantiationRange = SourceRange());
12966
12967 /// \brief Note that we are checking the satisfaction of the constraint
12968 /// expression inside of a nested requirement.
12969 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12971 SourceRange InstantiationRange = SourceRange());
12972
12973 /// \brief Note that we are checking a requires clause.
12974 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12975 const RequiresExpr *E,
12976 sema::TemplateDeductionInfo &DeductionInfo,
12977 SourceRange InstantiationRange);
12978
12980 /// \brief Note that we are building deduction guides.
12981 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12983 SourceRange InstantiationRange = SourceRange());
12984
12985 /// Note that we have finished instantiating this template.
12986 void Clear();
12987
12989
12990 /// Determines whether we have exceeded the maximum
12991 /// recursive template instantiations.
12992 bool isInvalid() const { return Invalid; }
12993
12994 /// Determine whether we are already instantiating this
12995 /// specialization in some surrounding active instantiation.
12996 bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
12997
12998 private:
12999 Sema &SemaRef;
13000 bool Invalid;
13001 bool AlreadyInstantiating;
13002 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
13003 SourceRange InstantiationRange);
13004
13005 InstantiatingTemplate(Sema &SemaRef,
13007 SourceLocation PointOfInstantiation,
13008 SourceRange InstantiationRange, Decl *Entity,
13009 NamedDecl *Template = nullptr,
13010 ArrayRef<TemplateArgument> TemplateArgs = {},
13011 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
13012
13013 InstantiatingTemplate(const InstantiatingTemplate &) = delete;
13014
13015 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13016 };
13017
13018 bool SubstTemplateArgument(const TemplateArgumentLoc &Input,
13019 const MultiLevelTemplateArgumentList &TemplateArgs,
13020 TemplateArgumentLoc &Output,
13021 SourceLocation Loc = {},
13022 const DeclarationName &Entity = {});
13023 bool
13024 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13025 const MultiLevelTemplateArgumentList &TemplateArgs,
13026 TemplateArgumentListInfo &Outputs);
13027
13028 /// Retrieve the template argument list(s) that should be used to
13029 /// instantiate the definition of the given declaration.
13030 ///
13031 /// \param ND the declaration for which we are computing template
13032 /// instantiation arguments.
13033 ///
13034 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13035 /// the decl context where it will be created. In this case, the `Innermost`
13036 /// should likely be provided. If ND is non-null, this is ignored.
13037 ///
13038 /// \param Innermost if non-NULL, specifies a template argument list for the
13039 /// template declaration passed as ND.
13040 ///
13041 /// \param RelativeToPrimary true if we should get the template
13042 /// arguments relative to the primary template, even when we're
13043 /// dealing with a specialization. This is only relevant for function
13044 /// template specializations.
13045 ///
13046 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13047 /// instantiating the definition of the given declaration, \p ND. This is
13048 /// used to determine the proper set of template instantiation arguments for
13049 /// friend function template specializations.
13050 ///
13051 /// \param ForConstraintInstantiation when collecting arguments,
13052 /// ForConstraintInstantiation indicates we should continue looking when
13053 /// encountering a lambda generic call operator, and continue looking for
13054 /// arguments on an enclosing class template.
13055 ///
13056 /// \param SkipForSpecialization when specified, any template specializations
13057 /// in a traversal would be ignored.
13058 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13059 /// when encountering a specialized member function template, rather than
13060 /// returning immediately.
13061 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13062 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13063 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13064 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13065 bool ForConstraintInstantiation = false,
13066 bool SkipForSpecialization = false,
13067 bool ForDefaultArgumentSubstitution = false);
13068
13069 /// RAII object to handle the state changes required to synthesize
13070 /// a function body.
13072 Sema &S;
13073 Sema::ContextRAII SavedContext;
13074 bool PushedCodeSynthesisContext = false;
13075
13076 public:
13078 : S(S), SavedContext(S, DC) {
13079 auto *FD = dyn_cast<FunctionDecl>(DC);
13080 S.PushFunctionScope();
13081 S.PushExpressionEvaluationContext(
13082 (FD && FD->isConsteval())
13083 ? ExpressionEvaluationContext::ImmediateFunctionContext
13084 : ExpressionEvaluationContext::PotentiallyEvaluated);
13085 if (FD) {
13086 FD->setWillHaveBody(true);
13087 S.ExprEvalContexts.back().InImmediateFunctionContext =
13088 FD->isImmediateFunction() ||
13089 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
13090 .isConstantEvaluated() ||
13091 S.ExprEvalContexts[S.ExprEvalContexts.size() - 2]
13092 .isImmediateFunctionContext();
13093 S.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
13094 S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating();
13095 } else
13096 assert(isa<ObjCMethodDecl>(DC));
13097 }
13098
13100 assert(!PushedCodeSynthesisContext);
13101
13103 Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
13104 Ctx.PointOfInstantiation = UseLoc;
13105 Ctx.Entity = cast<Decl>(S.CurContext);
13106 S.pushCodeSynthesisContext(Ctx);
13107
13108 PushedCodeSynthesisContext = true;
13109 }
13110
13112 if (PushedCodeSynthesisContext)
13113 S.popCodeSynthesisContext();
13114 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13115 FD->setWillHaveBody(false);
13116 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13117 }
13118 S.PopExpressionEvaluationContext();
13119 S.PopFunctionScopeInfo();
13120 }
13121 };
13122
13123 /// List of active code synthesis contexts.
13124 ///
13125 /// This vector is treated as a stack. As synthesis of one entity requires
13126 /// synthesis of another, additional contexts are pushed onto the stack.
13128
13129 /// Specializations whose definitions are currently being instantiated.
13130 llvm::DenseSet<std::pair<Decl *, unsigned>> InstantiatingSpecializations;
13131
13132 /// Non-dependent types used in templates that have already been instantiated
13133 /// by some template instantiation.
13134 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13135
13136 /// Extra modules inspected when performing a lookup during a template
13137 /// instantiation. Computed lazily.
13139
13140 /// Cache of additional modules that should be used for name lookup
13141 /// within the current template instantiation. Computed lazily; use
13142 /// getLookupModules() to get a complete set.
13143 llvm::DenseSet<Module *> LookupModulesCache;
13144
13145 /// Map from the most recent declaration of a namespace to the most
13146 /// recent visible declaration of that namespace.
13147 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13148
13149 /// Whether we are in a SFINAE context that is not associated with
13150 /// template instantiation.
13151 ///
13152 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
13153 /// of a template instantiation or template argument deduction.
13155
13156 /// The number of \p CodeSynthesisContexts that are not template
13157 /// instantiations and, therefore, should not be counted as part of the
13158 /// instantiation depth.
13159 ///
13160 /// When the instantiation depth reaches the user-configurable limit
13161 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13162 // FIXME: Should we have a similar limit for other forms of synthesis?
13164
13165 /// The depth of the context stack at the point when the most recent
13166 /// error or warning was produced.
13167 ///
13168 /// This value is used to suppress printing of redundant context stacks
13169 /// when there are multiple errors or warnings in the same instantiation.
13170 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13172
13173 /// The template instantiation callbacks to trace or track
13174 /// instantiations (objects can be chained).
13175 ///
13176 /// This callbacks is used to print, trace or track template
13177 /// instantiations as they are being constructed.
13178 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
13180
13181 /// The current index into pack expansion arguments that will be
13182 /// used for substitution of parameter packs.
13183 ///
13184 /// The pack expansion index will be -1 to indicate that parameter packs
13185 /// should be instantiated as themselves. Otherwise, the index specifies
13186 /// which argument within the parameter pack will be used for substitution.
13188
13189 /// RAII object used to change the argument pack substitution index
13190 /// within a \c Sema object.
13191 ///
13192 /// See \c ArgumentPackSubstitutionIndex for more information.
13194 Sema &Self;
13195 int OldSubstitutionIndex;
13196
13197 public:
13198 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
13199 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
13200 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
13201 }
13202
13204 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
13205 }
13206 };
13207
13209
13212
13214 if (!CodeSynthesisContexts.empty() &&
13218 }
13221 }
13222 /// Prints the current instantiation stack through a series of
13223 /// notes.
13225
13226 /// Determines whether we are currently in a context where
13227 /// template argument substitution failures are not considered
13228 /// errors.
13229 ///
13230 /// \returns An empty \c Optional if we're not in a SFINAE context.
13231 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
13232 /// template-deduction context object, which can be used to capture
13233 /// diagnostics that will be suppressed.
13234 std::optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
13235
13236 /// Perform substitution on the type T with a given set of template
13237 /// arguments.
13238 ///
13239 /// This routine substitutes the given template arguments into the
13240 /// type T and produces the instantiated type.
13241 ///
13242 /// \param T the type into which the template arguments will be
13243 /// substituted. If this type is not dependent, it will be returned
13244 /// immediately.
13245 ///
13246 /// \param Args the template arguments that will be
13247 /// substituted for the top-level template parameters within T.
13248 ///
13249 /// \param Loc the location in the source code where this substitution
13250 /// is being performed. It will typically be the location of the
13251 /// declarator (if we're instantiating the type of some declaration)
13252 /// or the location of the type in the source code (if, e.g., we're
13253 /// instantiating the type of a cast expression).
13254 ///
13255 /// \param Entity the name of the entity associated with a declaration
13256 /// being instantiated (if any). May be empty to indicate that there
13257 /// is no such entity (if, e.g., this is a type that occurs as part of
13258 /// a cast expression) or that the entity has no name (e.g., an
13259 /// unnamed function parameter).
13260 ///
13261 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13262 /// acceptable as the top level type of the result.
13263 ///
13264 /// \param IsIncompleteSubstitution If provided, the pointee will be set
13265 /// whenever substitution would perform a replacement with a null or
13266 /// non-existent template argument.
13267 ///
13268 /// \returns If the instantiation succeeds, the instantiated
13269 /// type. Otherwise, produces diagnostics and returns a NULL type.
13271 const MultiLevelTemplateArgumentList &TemplateArgs,
13273 bool AllowDeducedTST = false);
13274
13276 const MultiLevelTemplateArgumentList &TemplateArgs,
13278 bool *IsIncompleteSubstitution = nullptr);
13279
13281 const MultiLevelTemplateArgumentList &TemplateArgs,
13283
13284 /// A form of SubstType intended specifically for instantiating the
13285 /// type of a FunctionDecl. Its purpose is solely to force the
13286 /// instantiation of default-argument expressions and to avoid
13287 /// instantiating an exception-specification.
13289 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13290 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13291 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13292 void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
13293 const MultiLevelTemplateArgumentList &Args);
13296 SmallVectorImpl<QualType> &ExceptionStorage,
13297 const MultiLevelTemplateArgumentList &Args);
13298 ParmVarDecl *
13300 const MultiLevelTemplateArgumentList &TemplateArgs,
13301 int indexAdjustment, std::optional<unsigned> NumExpansions,
13302 bool ExpectParameterPack, bool EvaluateConstraints = true);
13303
13304 /// Substitute the given template arguments into the given set of
13305 /// parameters, producing the set of parameter types that would be generated
13306 /// from such a substitution.
13308 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13309 const MultiLevelTemplateArgumentList &TemplateArgs,
13310 SmallVectorImpl<QualType> &ParamTypes,
13312 ExtParameterInfoBuilder &ParamInfos);
13313
13314 /// Substitute the given template arguments into the default argument.
13316 const MultiLevelTemplateArgumentList &TemplateArgs,
13317 bool ForCallExpr = false);
13319 const MultiLevelTemplateArgumentList &TemplateArgs);
13320
13321 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
13322 // to disable constraint evaluation, then restore the state.
13323 template <typename InstTy> struct ConstraintEvalRAII {
13324 InstTy &TI;
13326
13328 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
13329 TI.setEvaluateConstraints(false);
13330 }
13331 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
13332 };
13333
13334 // Must be used instead of SubstExpr at 'constraint checking' time.
13337 const MultiLevelTemplateArgumentList &TemplateArgs);
13338 // Unlike the above, this does not evaluates constraints.
13340 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13341
13342 /// Substitute the given template arguments into a list of
13343 /// expressions, expanding pack expansions if required.
13344 ///
13345 /// \param Exprs The list of expressions to substitute into.
13346 ///
13347 /// \param IsCall Whether this is some form of call, in which case
13348 /// default arguments will be dropped.
13349 ///
13350 /// \param TemplateArgs The set of template arguments to substitute.
13351 ///
13352 /// \param Outputs Will receive all of the substituted arguments.
13353 ///
13354 /// \returns true if an error occurred, false otherwise.
13355 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13356 const MultiLevelTemplateArgumentList &TemplateArgs,
13357 SmallVectorImpl<Expr *> &Outputs);
13358
13360 const MultiLevelTemplateArgumentList &TemplateArgs);
13361
13364 bool CXXDirectInit);
13365
13366 /// Perform substitution on the base class specifiers of the
13367 /// given class template specialization.
13368 ///
13369 /// Produces a diagnostic and returns true on error, returns false and
13370 /// attaches the instantiated base classes to the class template
13371 /// specialization if successful.
13372 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13373 const MultiLevelTemplateArgumentList &TemplateArgs);
13374
13375 /// Instantiate the definition of a class from a given pattern.
13376 ///
13377 /// \param PointOfInstantiation The point of instantiation within the
13378 /// source code.
13379 ///
13380 /// \param Instantiation is the declaration whose definition is being
13381 /// instantiated. This will be either a class template specialization
13382 /// or a member class of a class template specialization.
13383 ///
13384 /// \param Pattern is the pattern from which the instantiation
13385 /// occurs. This will be either the declaration of a class template or
13386 /// the declaration of a member class of a class template.
13387 ///
13388 /// \param TemplateArgs The template arguments to be substituted into
13389 /// the pattern.
13390 ///
13391 /// \param TSK the kind of implicit or explicit instantiation to perform.
13392 ///
13393 /// \param Complain whether to complain if the class cannot be instantiated
13394 /// due to the lack of a definition.
13395 ///
13396 /// \returns true if an error occurred, false otherwise.
13397 bool InstantiateClass(SourceLocation PointOfInstantiation,
13398 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13399 const MultiLevelTemplateArgumentList &TemplateArgs,
13400 TemplateSpecializationKind TSK, bool Complain = true);
13401
13402 /// Instantiate the definition of an enum from a given pattern.
13403 ///
13404 /// \param PointOfInstantiation The point of instantiation within the
13405 /// source code.
13406 /// \param Instantiation is the declaration whose definition is being
13407 /// instantiated. This will be a member enumeration of a class
13408 /// temploid specialization, or a local enumeration within a
13409 /// function temploid specialization.
13410 /// \param Pattern The templated declaration from which the instantiation
13411 /// occurs.
13412 /// \param TemplateArgs The template arguments to be substituted into
13413 /// the pattern.
13414 /// \param TSK The kind of implicit or explicit instantiation to perform.
13415 ///
13416 /// \return \c true if an error occurred, \c false otherwise.
13417 bool InstantiateEnum(SourceLocation PointOfInstantiation,
13418 EnumDecl *Instantiation, EnumDecl *Pattern,
13419 const MultiLevelTemplateArgumentList &TemplateArgs,
13421
13422 /// Instantiate the definition of a field from the given pattern.
13423 ///
13424 /// \param PointOfInstantiation The point of instantiation within the
13425 /// source code.
13426 /// \param Instantiation is the declaration whose definition is being
13427 /// instantiated. This will be a class of a class temploid
13428 /// specialization, or a local enumeration within a function temploid
13429 /// specialization.
13430 /// \param Pattern The templated declaration from which the instantiation
13431 /// occurs.
13432 /// \param TemplateArgs The template arguments to be substituted into
13433 /// the pattern.
13434 ///
13435 /// \return \c true if an error occurred, \c false otherwise.
13437 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
13438 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
13439
13442
13444 SourceLocation PointOfInstantiation,
13445 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13446 TemplateSpecializationKind TSK, bool Complain = true);
13447
13448 /// Instantiates the definitions of all of the member
13449 /// of the given class, which is an instantiation of a class template
13450 /// or a member class of a template.
13451 void
13452 InstantiateClassMembers(SourceLocation PointOfInstantiation,
13453 CXXRecordDecl *Instantiation,
13454 const MultiLevelTemplateArgumentList &TemplateArgs,
13456
13457 /// Instantiate the definitions of all of the members of the
13458 /// given class template specialization, which was named as part of an
13459 /// explicit instantiation.
13461 SourceLocation PointOfInstantiation,
13462 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13464
13467 const MultiLevelTemplateArgumentList &TemplateArgs);
13468
13469 /// Do template substitution on declaration name info.
13472 const MultiLevelTemplateArgumentList &TemplateArgs);
13476 const MultiLevelTemplateArgumentList &TemplateArgs);
13477
13479 const MultiLevelTemplateArgumentList &TemplateArgs,
13480 bool EvaluateConstraint);
13481
13482 /// Determine whether we are currently performing template instantiation.
13485 }
13486
13487 using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
13488
13489 /// \brief create a Requirement::SubstitutionDiagnostic with only a
13490 /// SubstitutedEntity and DiagLoc using ASTContext's allocator.
13493
13494 ///@}
13495
13496 //
13497 //
13498 // -------------------------------------------------------------------------
13499 //
13500 //
13501
13502 /// \name C++ Template Declaration Instantiation
13503 /// Implementations are in SemaTemplateInstantiateDecl.cpp
13504 ///@{
13505
13506public:
13507 /// An entity for which implicit template instantiation is required.
13508 ///
13509 /// The source location associated with the declaration is the first place in
13510 /// the source code where the declaration was "used". It is not necessarily
13511 /// the point of instantiation (which will be either before or after the
13512 /// namespace-scope declaration that triggered this implicit instantiation),
13513 /// However, it is the location that diagnostics should generally refer to,
13514 /// because users will need to know what code triggered the instantiation.
13515 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
13516
13517 /// The queue of implicit template instantiations that are required
13518 /// but have not yet been performed.
13519 std::deque<PendingImplicitInstantiation> PendingInstantiations;
13520
13521 /// Queue of implicit template instantiations that cannot be performed
13522 /// eagerly.
13524
13528
13529 /// The queue of implicit template instantiations that are required
13530 /// and must be performed within the current local scope.
13531 ///
13532 /// This queue is only used for member functions of local classes in
13533 /// templates, which must be instantiated in the same scope as their
13534 /// enclosing function, so that they can reference function-local
13535 /// types, static variables, enumerators, etc.
13536 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
13537
13539 public:
13541 SavedPendingLocalImplicitInstantiations.swap(
13542 S.PendingLocalImplicitInstantiations);
13543 }
13544
13545 void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
13546
13548 assert(S.PendingLocalImplicitInstantiations.empty() &&
13549 "there shouldn't be any pending local implicit instantiations");
13550 SavedPendingLocalImplicitInstantiations.swap(
13551 S.PendingLocalImplicitInstantiations);
13552 }
13553
13554 private:
13555 Sema &S;
13556 std::deque<PendingImplicitInstantiation>
13557 SavedPendingLocalImplicitInstantiations;
13558 };
13559
13560 /// Records and restores the CurFPFeatures state on entry/exit of compound
13561 /// statements.
13563 public:
13566 FPOptionsOverride getOverrides() { return OldOverrides; }
13567
13568 private:
13569 Sema &S;
13570 FPOptions OldFPFeaturesState;
13571 FPOptionsOverride OldOverrides;
13572 LangOptions::FPEvalMethodKind OldEvalMethod;
13573 SourceLocation OldFPPragmaLocation;
13574 };
13575
13577 public:
13579 : S(S), Enabled(Enabled) {
13580 if (!Enabled)
13581 return;
13582
13583 S.SavedPendingInstantiations.emplace_back();
13584 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
13585
13586 S.SavedVTableUses.emplace_back();
13587 S.SavedVTableUses.back().swap(S.VTableUses);
13588 }
13589
13590 void perform() {
13591 if (Enabled) {
13592 S.DefineUsedVTables();
13593 S.PerformPendingInstantiations();
13594 }
13595 }
13596
13598 if (!Enabled)
13599 return;
13600
13601 // Restore the set of pending vtables.
13602 assert(S.VTableUses.empty() &&
13603 "VTableUses should be empty before it is discarded.");
13604 S.VTableUses.swap(S.SavedVTableUses.back());
13605 S.SavedVTableUses.pop_back();
13606
13607 // Restore the set of pending implicit instantiations.
13608 if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
13609 assert(S.PendingInstantiations.empty() &&
13610 "PendingInstantiations should be empty before it is discarded.");
13611 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13612 S.SavedPendingInstantiations.pop_back();
13613 } else {
13614 // Template instantiations in the PCH may be delayed until the TU.
13615 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13616 S.PendingInstantiations.insert(
13617 S.PendingInstantiations.end(),
13618 S.SavedPendingInstantiations.back().begin(),
13619 S.SavedPendingInstantiations.back().end());
13620 S.SavedPendingInstantiations.pop_back();
13621 }
13622 }
13623
13624 private:
13625 Sema &S;
13626 bool Enabled;
13627 };
13628
13630 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
13631
13636
13638 Decl *D)
13639 : TmplAttr(A), Scope(S), NewDecl(D) {}
13640 };
13642
13643 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
13644 const Decl *Pattern, Decl *Inst,
13645 LateInstantiatedAttrVec *LateAttrs = nullptr,
13646 LocalInstantiationScope *OuterMostScope = nullptr);
13647
13648 /// Update instantiation attributes after template was late parsed.
13649 ///
13650 /// Some attributes are evaluated based on the body of template. If it is
13651 /// late parsed, such attributes cannot be evaluated when declaration is
13652 /// instantiated. This function is used to update instantiation attributes
13653 /// when template definition is ready.
13654 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
13655
13656 void
13658 const Decl *Pattern, Decl *Inst,
13659 LateInstantiatedAttrVec *LateAttrs = nullptr,
13660 LocalInstantiationScope *OuterMostScope = nullptr);
13661
13662 /// In the MS ABI, we need to instantiate default arguments of dllexported
13663 /// default constructors along with the constructor definition. This allows IR
13664 /// gen to emit a constructor closure which calls the default constructor with
13665 /// its default arguments.
13667
13669 ParmVarDecl *Param);
13670 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
13672
13673 /// Instantiate (or find existing instantiation of) a function template with a
13674 /// given set of template arguments.
13675 ///
13676 /// Usually this should not be used, and template argument deduction should be
13677 /// used in its place.
13683
13684 /// Instantiate the definition of the given function from its
13685 /// template.
13686 ///
13687 /// \param PointOfInstantiation the point at which the instantiation was
13688 /// required. Note that this is not precisely a "point of instantiation"
13689 /// for the function, but it's close.
13690 ///
13691 /// \param Function the already-instantiated declaration of a
13692 /// function template specialization or member function of a class template
13693 /// specialization.
13694 ///
13695 /// \param Recursive if true, recursively instantiates any functions that
13696 /// are required by this instantiation.
13697 ///
13698 /// \param DefinitionRequired if true, then we are performing an explicit
13699 /// instantiation where the body of the function is required. Complain if
13700 /// there is no such body.
13701 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
13703 bool Recursive = false,
13704 bool DefinitionRequired = false,
13705 bool AtEndOfTU = false);
13708 const TemplateArgumentList *PartialSpecArgs,
13709 const TemplateArgumentListInfo &TemplateArgsInfo,
13711 SourceLocation PointOfInstantiation,
13712 LateInstantiatedAttrVec *LateAttrs = nullptr,
13713 LocalInstantiationScope *StartingScope = nullptr);
13714
13715 /// Instantiates a variable template specialization by completing it
13716 /// with appropriate type information and initializer.
13718 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
13719 const MultiLevelTemplateArgumentList &TemplateArgs);
13720
13721 /// BuildVariableInstantiation - Used after a new variable has been created.
13722 /// Sets basic variable data and decides whether to postpone the
13723 /// variable instantiation.
13724 void
13726 const MultiLevelTemplateArgumentList &TemplateArgs,
13727 LateInstantiatedAttrVec *LateAttrs,
13728 DeclContext *Owner,
13729 LocalInstantiationScope *StartingScope,
13730 bool InstantiatingVarTemplate = false,
13731 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
13732
13733 /// Instantiate the initializer of a variable.
13735 VarDecl *Var, VarDecl *OldVar,
13736 const MultiLevelTemplateArgumentList &TemplateArgs);
13737
13738 /// Instantiate the definition of the given variable from its
13739 /// template.
13740 ///
13741 /// \param PointOfInstantiation the point at which the instantiation was
13742 /// required. Note that this is not precisely a "point of instantiation"
13743 /// for the variable, but it's close.
13744 ///
13745 /// \param Var the already-instantiated declaration of a templated variable.
13746 ///
13747 /// \param Recursive if true, recursively instantiates any functions that
13748 /// are required by this instantiation.
13749 ///
13750 /// \param DefinitionRequired if true, then we are performing an explicit
13751 /// instantiation where a definition of the variable is required. Complain
13752 /// if there is no such definition.
13753 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
13754 VarDecl *Var, bool Recursive = false,
13755 bool DefinitionRequired = false,
13756 bool AtEndOfTU = false);
13757
13759 CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl,
13760 const MultiLevelTemplateArgumentList &TemplateArgs);
13761
13762 /// Find the instantiation of the given declaration within the
13763 /// current instantiation.
13764 ///
13765 /// This routine is intended to be used when \p D is a declaration
13766 /// referenced from within a template, that needs to mapped into the
13767 /// corresponding declaration within an instantiation. For example,
13768 /// given:
13769 ///
13770 /// \code
13771 /// template<typename T>
13772 /// struct X {
13773 /// enum Kind {
13774 /// KnownValue = sizeof(T)
13775 /// };
13776 ///
13777 /// bool getKind() const { return KnownValue; }
13778 /// };
13779 ///
13780 /// template struct X<int>;
13781 /// \endcode
13782 ///
13783 /// In the instantiation of X<int>::getKind(), we need to map the \p
13784 /// EnumConstantDecl for \p KnownValue (which refers to
13785 /// X<T>::<Kind>::KnownValue) to its instantiation
13786 /// (X<int>::<Kind>::KnownValue).
13787 /// \p FindInstantiatedDecl performs this mapping from within the
13788 /// instantiation of X<int>.
13789 NamedDecl *
13791 const MultiLevelTemplateArgumentList &TemplateArgs,
13792 bool FindingInstantiatedContext = false);
13793
13794 /// Finds the instantiation of the given declaration context
13795 /// within the current instantiation.
13796 ///
13797 /// \returns NULL if there was an error
13798 DeclContext *
13800 const MultiLevelTemplateArgumentList &TemplateArgs);
13801
13802 Decl *SubstDecl(Decl *D, DeclContext *Owner,
13803 const MultiLevelTemplateArgumentList &TemplateArgs);
13804
13805 /// Substitute the name and return type of a defaulted 'operator<=>' to form
13806 /// an implicit 'operator=='.
13808 FunctionDecl *Spaceship);
13809
13810 /// Performs template instantiation for all implicit template
13811 /// instantiations we have seen until this point.
13812 void PerformPendingInstantiations(bool LocalOnly = false);
13813
13816 const MultiLevelTemplateArgumentList &TemplateArgs,
13817 bool EvaluateConstraints = true);
13818
13820 const DeclContext *Pattern,
13821 const MultiLevelTemplateArgumentList &TemplateArgs);
13822
13823private:
13824 /// Introduce the instantiated local variables into the local
13825 /// instantiation scope.
13826 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
13827 const FunctionDecl *PatternDecl,
13829 /// Introduce the instantiated function parameters into the local
13830 /// instantiation scope, and set the parameter names to those used
13831 /// in the template.
13832 bool addInstantiatedParametersToScope(
13833 FunctionDecl *Function, const FunctionDecl *PatternDecl,
13835 const MultiLevelTemplateArgumentList &TemplateArgs);
13836
13837 int ParsingClassDepth = 0;
13838
13839 class SavePendingParsedClassStateRAII {
13840 public:
13841 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
13842
13843 ~SavePendingParsedClassStateRAII() {
13844 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
13845 "there shouldn't be any pending delayed exception spec checks");
13846 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
13847 "there shouldn't be any pending delayed exception spec checks");
13848 swapSavedState();
13849 }
13850
13851 private:
13852 Sema &S;
13853 decltype(DelayedOverridingExceptionSpecChecks)
13854 SavedOverridingExceptionSpecChecks;
13855 decltype(DelayedEquivalentExceptionSpecChecks)
13856 SavedEquivalentExceptionSpecChecks;
13857
13858 void swapSavedState() {
13859 SavedOverridingExceptionSpecChecks.swap(
13860 S.DelayedOverridingExceptionSpecChecks);
13861 SavedEquivalentExceptionSpecChecks.swap(
13862 S.DelayedEquivalentExceptionSpecChecks);
13863 }
13864 };
13865
13866 ///@}
13867
13868 //
13869 //
13870 // -------------------------------------------------------------------------
13871 //
13872 //
13873
13874 /// \name C++ Variadic Templates
13875 /// Implementations are in SemaTemplateVariadic.cpp
13876 ///@{
13877
13878public:
13879 /// Determine whether an unexpanded parameter pack might be permitted in this
13880 /// location. Useful for error recovery.
13882
13883 /// The context in which an unexpanded parameter pack is
13884 /// being diagnosed.
13885 ///
13886 /// Note that the values of this enumeration line up with the first
13887 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
13889 /// An arbitrary expression.
13891
13892 /// The base type of a class type.
13894
13895 /// The type of an arbitrary declaration.
13897
13898 /// The type of a data member.
13900
13901 /// The size of a bit-field.
13903
13904 /// The expression in a static assertion.
13906
13907 /// The fixed underlying type of an enumeration.
13909
13910 /// The enumerator value.
13912
13913 /// A using declaration.
13915
13916 /// A friend declaration.
13918
13919 /// A declaration qualifier.
13921
13922 /// An initializer.
13924
13925 /// A default argument.
13927
13928 /// The type of a non-type template parameter.
13930
13931 /// The type of an exception.
13933
13934 /// Explicit specialization.
13936
13937 /// Partial specialization.
13939
13940 /// Microsoft __if_exists.
13942
13943 /// Microsoft __if_not_exists.
13945
13946 /// Lambda expression.
13948
13949 /// Block expression.
13951
13952 /// A type constraint.
13954
13955 // A requirement in a requires-expression.
13957
13958 // A requires-clause.
13960 };
13961
13962 /// Diagnose unexpanded parameter packs.
13963 ///
13964 /// \param Loc The location at which we should emit the diagnostic.
13965 ///
13966 /// \param UPPC The context in which we are diagnosing unexpanded
13967 /// parameter packs.
13968 ///
13969 /// \param Unexpanded the set of unexpanded parameter packs.
13970 ///
13971 /// \returns true if an error occurred, false otherwise.
13975
13976 /// If the given type contains an unexpanded parameter pack,
13977 /// diagnose the error.
13978 ///
13979 /// \param Loc The source location where a diagnostc should be emitted.
13980 ///
13981 /// \param T The type that is being checked for unexpanded parameter
13982 /// packs.
13983 ///
13984 /// \returns true if an error occurred, false otherwise.
13987
13988 /// If the given expression contains an unexpanded parameter
13989 /// pack, diagnose the error.
13990 ///
13991 /// \param E The expression that is being checked for unexpanded
13992 /// parameter packs.
13993 ///
13994 /// \returns true if an error occurred, false otherwise.
13997
13998 /// If the given requirees-expression contains an unexpanded reference to one
13999 /// of its own parameter packs, diagnose the error.
14000 ///
14001 /// \param RE The requiress-expression that is being checked for unexpanded
14002 /// parameter packs.
14003 ///
14004 /// \returns true if an error occurred, false otherwise.
14006
14007 /// If the given nested-name-specifier contains an unexpanded
14008 /// parameter pack, diagnose the error.
14009 ///
14010 /// \param SS The nested-name-specifier that is being checked for
14011 /// unexpanded parameter packs.
14012 ///
14013 /// \returns true if an error occurred, false otherwise.
14016
14017 /// If the given name contains an unexpanded parameter pack,
14018 /// diagnose the error.
14019 ///
14020 /// \param NameInfo The name (with source location information) that
14021 /// is being checked for unexpanded parameter packs.
14022 ///
14023 /// \returns true if an error occurred, false otherwise.
14026
14027 /// If the given template name contains an unexpanded parameter pack,
14028 /// diagnose the error.
14029 ///
14030 /// \param Loc The location of the template name.
14031 ///
14032 /// \param Template The template name that is being checked for unexpanded
14033 /// parameter packs.
14034 ///
14035 /// \returns true if an error occurred, false otherwise.
14037 TemplateName Template,
14039
14040 /// If the given template argument contains an unexpanded parameter
14041 /// pack, diagnose the error.
14042 ///
14043 /// \param Arg The template argument that is being checked for unexpanded
14044 /// parameter packs.
14045 ///
14046 /// \returns true if an error occurred, false otherwise.
14049
14050 /// Collect the set of unexpanded parameter packs within the given
14051 /// template argument.
14052 ///
14053 /// \param Arg The template argument that will be traversed to find
14054 /// unexpanded parameter packs.
14056 TemplateArgument Arg,
14058
14059 /// Collect the set of unexpanded parameter packs within the given
14060 /// template argument.
14061 ///
14062 /// \param Arg The template argument that will be traversed to find
14063 /// unexpanded parameter packs.
14067
14068 /// Collect the set of unexpanded parameter packs within the given
14069 /// type.
14070 ///
14071 /// \param T The type that will be traversed to find
14072 /// unexpanded parameter packs.
14075
14076 /// Collect the set of unexpanded parameter packs within the given
14077 /// type.
14078 ///
14079 /// \param TL The type that will be traversed to find
14080 /// unexpanded parameter packs.
14083
14084 /// Collect the set of unexpanded parameter packs within the given
14085 /// nested-name-specifier.
14086 ///
14087 /// \param NNS The nested-name-specifier that will be traversed to find
14088 /// unexpanded parameter packs.
14092
14093 /// Collect the set of unexpanded parameter packs within the given
14094 /// name.
14095 ///
14096 /// \param NameInfo The name that will be traversed to find
14097 /// unexpanded parameter packs.
14099 const DeclarationNameInfo &NameInfo,
14101
14102 /// Collect the set of unexpanded parameter packs within the given
14103 /// expression.
14106
14107 /// Invoked when parsing a template argument followed by an
14108 /// ellipsis, which creates a pack expansion.
14109 ///
14110 /// \param Arg The template argument preceding the ellipsis, which
14111 /// may already be invalid.
14112 ///
14113 /// \param EllipsisLoc The location of the ellipsis.
14115 SourceLocation EllipsisLoc);
14116
14117 /// Invoked when parsing a type followed by an ellipsis, which
14118 /// creates a pack expansion.
14119 ///
14120 /// \param Type The type preceding the ellipsis, which will become
14121 /// the pattern of the pack expansion.
14122 ///
14123 /// \param EllipsisLoc The location of the ellipsis.
14125
14126 /// Construct a pack expansion type from the pattern of the pack
14127 /// expansion.
14129 SourceLocation EllipsisLoc,
14130 std::optional<unsigned> NumExpansions);
14131
14132 /// Construct a pack expansion type from the pattern of the pack
14133 /// expansion.
14134 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14135 SourceLocation EllipsisLoc,
14136 std::optional<unsigned> NumExpansions);
14137
14138 /// Invoked when parsing an expression followed by an ellipsis, which
14139 /// creates a pack expansion.
14140 ///
14141 /// \param Pattern The expression preceding the ellipsis, which will become
14142 /// the pattern of the pack expansion.
14143 ///
14144 /// \param EllipsisLoc The location of the ellipsis.
14145 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14146
14147 /// Invoked when parsing an expression followed by an ellipsis, which
14148 /// creates a pack expansion.
14149 ///
14150 /// \param Pattern The expression preceding the ellipsis, which will become
14151 /// the pattern of the pack expansion.
14152 ///
14153 /// \param EllipsisLoc The location of the ellipsis.
14154 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14155 std::optional<unsigned> NumExpansions);
14156
14157 /// Determine whether we could expand a pack expansion with the
14158 /// given set of parameter packs into separate arguments by repeatedly
14159 /// transforming the pattern.
14160 ///
14161 /// \param EllipsisLoc The location of the ellipsis that identifies the
14162 /// pack expansion.
14163 ///
14164 /// \param PatternRange The source range that covers the entire pattern of
14165 /// the pack expansion.
14166 ///
14167 /// \param Unexpanded The set of unexpanded parameter packs within the
14168 /// pattern.
14169 ///
14170 /// \param ShouldExpand Will be set to \c true if the transformer should
14171 /// expand the corresponding pack expansions into separate arguments. When
14172 /// set, \c NumExpansions must also be set.
14173 ///
14174 /// \param RetainExpansion Whether the caller should add an unexpanded
14175 /// pack expansion after all of the expanded arguments. This is used
14176 /// when extending explicitly-specified template argument packs per
14177 /// C++0x [temp.arg.explicit]p9.
14178 ///
14179 /// \param NumExpansions The number of separate arguments that will be in
14180 /// the expanded form of the corresponding pack expansion. This is both an
14181 /// input and an output parameter, which can be set by the caller if the
14182 /// number of expansions is known a priori (e.g., due to a prior substitution)
14183 /// and will be set by the callee when the number of expansions is known.
14184 /// The callee must set this value when \c ShouldExpand is \c true; it may
14185 /// set this value in other cases.
14186 ///
14187 /// \returns true if an error occurred (e.g., because the parameter packs
14188 /// are to be instantiated with arguments of different lengths), false
14189 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14190 /// must be set.
14192 SourceLocation EllipsisLoc, SourceRange PatternRange,
14194 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
14195 bool &RetainExpansion, std::optional<unsigned> &NumExpansions);
14196
14197 /// Determine the number of arguments in the given pack expansion
14198 /// type.
14199 ///
14200 /// This routine assumes that the number of arguments in the expansion is
14201 /// consistent across all of the unexpanded parameter packs in its pattern.
14202 ///
14203 /// Returns an empty Optional if the type can't be expanded.
14204 std::optional<unsigned> getNumArgumentsInExpansion(
14205 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14206
14207 std::optional<unsigned> getNumArgumentsInExpansionFromUnexpanded(
14209 const MultiLevelTemplateArgumentList &TemplateArgs);
14210
14211 /// Determine whether the given declarator contains any unexpanded
14212 /// parameter packs.
14213 ///
14214 /// This routine is used by the parser to disambiguate function declarators
14215 /// with an ellipsis prior to the ')', e.g.,
14216 ///
14217 /// \code
14218 /// void f(T...);
14219 /// \endcode
14220 ///
14221 /// To determine whether we have an (unnamed) function parameter pack or
14222 /// a variadic function.
14223 ///
14224 /// \returns true if the declarator contains any unexpanded parameter packs,
14225 /// false otherwise.
14227
14228 /// Returns the pattern of the pack expansion for a template argument.
14229 ///
14230 /// \param OrigLoc The template argument to expand.
14231 ///
14232 /// \param Ellipsis Will be set to the location of the ellipsis.
14233 ///
14234 /// \param NumExpansions Will be set to the number of expansions that will
14235 /// be generated from this pack expansion, if known a priori.
14237 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
14238 std::optional<unsigned> &NumExpansions) const;
14239
14240 /// Given a template argument that contains an unexpanded parameter pack, but
14241 /// which has already been substituted, attempt to determine the number of
14242 /// elements that will be produced once this argument is fully-expanded.
14243 ///
14244 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14245 /// avoid actually expanding the pack where possible.
14246 std::optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
14247
14248 /// Called when an expression computing the size of a parameter pack
14249 /// is parsed.
14250 ///
14251 /// \code
14252 /// template<typename ...Types> struct count {
14253 /// static const unsigned value = sizeof...(Types);
14254 /// };
14255 /// \endcode
14256 ///
14257 //
14258 /// \param OpLoc The location of the "sizeof" keyword.
14259 /// \param Name The name of the parameter pack whose size will be determined.
14260 /// \param NameLoc The source location of the name of the parameter pack.
14261 /// \param RParenLoc The location of the closing parentheses.
14263 IdentifierInfo &Name,
14264 SourceLocation NameLoc,
14265 SourceLocation RParenLoc);
14266
14267 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14268 SourceLocation EllipsisLoc,
14269 SourceLocation LSquareLoc, Expr *IndexExpr,
14270 SourceLocation RSquareLoc);
14271
14272 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14273 SourceLocation EllipsisLoc, Expr *IndexExpr,
14274 SourceLocation RSquareLoc,
14275 ArrayRef<Expr *> ExpandedExprs = {},
14276 bool FullySubstituted = false);
14277
14278 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
14279 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14280 tok::TokenKind Operator,
14281 SourceLocation EllipsisLoc, Expr *RHS,
14282 SourceLocation RParenLoc);
14283 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
14284 SourceLocation LParenLoc, Expr *LHS,
14285 BinaryOperatorKind Operator,
14286 SourceLocation EllipsisLoc, Expr *RHS,
14287 SourceLocation RParenLoc,
14288 std::optional<unsigned> NumExpansions);
14289 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
14290 BinaryOperatorKind Operator);
14291
14292 ///@}
14293
14294 //
14295 //
14296 // -------------------------------------------------------------------------
14297 //
14298 //
14299
14300 /// \name Constraints and Concepts
14301 /// Implementations are in SemaConcept.cpp
14302 ///@{
14303
14304public:
14306 const llvm::FoldingSetNodeID &ID) {
14307 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14308 SatisfactionStack.emplace_back(Can, ID);
14309 }
14310
14311 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
14312
14314 const llvm::FoldingSetNodeID &ID) const {
14315 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14316 return llvm::find(SatisfactionStack, SatisfactionStackEntryTy{Can, ID}) !=
14317 SatisfactionStack.end();
14318 }
14319
14321 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
14322
14323 // Resets the current SatisfactionStack for cases where we are instantiating
14324 // constraints as a 'side effect' of normal instantiation in a way that is not
14325 // indicative of recursive definition.
14328 Sema &SemaRef;
14329
14330 public:
14332 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14333 }
14334
14336 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14337 }
14338 };
14339
14342 SatisfactionStack.swap(NewSS);
14343 }
14344
14345 /// Check whether the given expression is a valid constraint expression.
14346 /// A diagnostic is emitted if it is not, false is returned, and
14347 /// PossibleNonPrimary will be set to true if the failure might be due to a
14348 /// non-primary expression being used as an atomic constraint.
14349 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
14350 bool *PossibleNonPrimary = nullptr,
14351 bool IsTrailingRequiresClause = false);
14352
14353 /// \brief Check whether the given list of constraint expressions are
14354 /// satisfied (as if in a 'conjunction') given template arguments.
14355 /// \param Template the template-like entity that triggered the constraints
14356 /// check (either a concept or a constrained entity).
14357 /// \param ConstraintExprs a list of constraint expressions, treated as if
14358 /// they were 'AND'ed together.
14359 /// \param TemplateArgLists the list of template arguments to substitute into
14360 /// the constraint expression.
14361 /// \param TemplateIDRange The source range of the template id that
14362 /// caused the constraints check.
14363 /// \param Satisfaction if true is returned, will contain details of the
14364 /// satisfaction, with enough information to diagnose an unsatisfied
14365 /// expression.
14366 /// \returns true if an error occurred and satisfaction could not be checked,
14367 /// false otherwise.
14369 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14370 const MultiLevelTemplateArgumentList &TemplateArgLists,
14371 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
14373 return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted,
14374 TemplateArgLists, TemplateIDRange,
14375 Satisfaction);
14376 }
14377
14378 /// \brief Check whether the given list of constraint expressions are
14379 /// satisfied (as if in a 'conjunction') given template arguments.
14380 /// Additionally, takes an empty list of Expressions which is populated with
14381 /// the instantiated versions of the ConstraintExprs.
14382 /// \param Template the template-like entity that triggered the constraints
14383 /// check (either a concept or a constrained entity).
14384 /// \param ConstraintExprs a list of constraint expressions, treated as if
14385 /// they were 'AND'ed together.
14386 /// \param ConvertedConstraints a out parameter that will get populated with
14387 /// the instantiated version of the ConstraintExprs if we successfully checked
14388 /// satisfaction.
14389 /// \param TemplateArgList the multi-level list of template arguments to
14390 /// substitute into the constraint expression. This should be relative to the
14391 /// top-level (hence multi-level), since we need to instantiate fully at the
14392 /// time of checking.
14393 /// \param TemplateIDRange The source range of the template id that
14394 /// caused the constraints check.
14395 /// \param Satisfaction if true is returned, will contain details of the
14396 /// satisfaction, with enough information to diagnose an unsatisfied
14397 /// expression.
14398 /// \returns true if an error occurred and satisfaction could not be checked,
14399 /// false otherwise.
14401 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14402 llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
14403 const MultiLevelTemplateArgumentList &TemplateArgList,
14404 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
14405
14406 /// \brief Check whether the given non-dependent constraint expression is
14407 /// satisfied. Returns false and updates Satisfaction with the satisfaction
14408 /// verdict if successful, emits a diagnostic and returns true if an error
14409 /// occurred and satisfaction could not be determined.
14410 ///
14411 /// \returns true if an error occurred, false otherwise.
14412 bool CheckConstraintSatisfaction(const Expr *ConstraintExpr,
14413 ConstraintSatisfaction &Satisfaction);
14414
14415 /// Check whether the given function decl's trailing requires clause is
14416 /// satisfied, if any. Returns false and updates Satisfaction with the
14417 /// satisfaction verdict if successful, emits a diagnostic and returns true if
14418 /// an error occurred and satisfaction could not be determined.
14419 ///
14420 /// \returns true if an error occurred, false otherwise.
14422 ConstraintSatisfaction &Satisfaction,
14423 SourceLocation UsageLoc = SourceLocation(),
14424 bool ForOverloadResolution = false);
14425
14426 // Calculates whether two constraint expressions are equal irrespective of a
14427 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
14428 // 'New', which are the "source" of the constraint, since this is necessary
14429 // for figuring out the relative 'depth' of the constraint. The depth of the
14430 // 'primary template' and the 'instantiated from' templates aren't necessarily
14431 // the same, such as a case when one is a 'friend' defined in a class.
14433 const Expr *OldConstr,
14434 const TemplateCompareNewDeclInfo &New,
14435 const Expr *NewConstr);
14436
14437 // Calculates whether the friend function depends on an enclosing template for
14438 // the purposes of [temp.friend] p9.
14440
14441 /// \brief Ensure that the given template arguments satisfy the constraints
14442 /// associated with the given template, emitting a diagnostic if they do not.
14443 ///
14444 /// \param Template The template to which the template arguments are being
14445 /// provided.
14446 ///
14447 /// \param TemplateArgs The converted, canonicalized template arguments.
14448 ///
14449 /// \param TemplateIDRange The source range of the template id that
14450 /// caused the constraints check.
14451 ///
14452 /// \returns true if the constrains are not satisfied or could not be checked
14453 /// for satisfaction, false if the constraints are satisfied.
14455 TemplateDecl *Template,
14456 const MultiLevelTemplateArgumentList &TemplateArgs,
14457 SourceRange TemplateIDRange);
14458
14460 SourceLocation PointOfInstantiation, FunctionDecl *Decl,
14461 ArrayRef<TemplateArgument> TemplateArgs,
14462 ConstraintSatisfaction &Satisfaction);
14463
14464 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14465 /// unsatisfied.
14466 /// \param First whether this is the first time an unsatisfied constraint is
14467 /// diagnosed for this error.
14469 bool First = true);
14470
14471 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14472 /// unsatisfied.
14473 void
14475 bool First = true);
14476
14478 NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints);
14479
14480 /// \brief Check whether the given declaration's associated constraints are
14481 /// at least as constrained than another declaration's according to the
14482 /// partial ordering of constraints.
14483 ///
14484 /// \param Result If no error occurred, receives the result of true if D1 is
14485 /// at least constrained than D2, and false otherwise.
14486 ///
14487 /// \returns true if an error occurred, false otherwise.
14490 bool &Result);
14491
14492 /// If D1 was not at least as constrained as D2, but would've been if a pair
14493 /// of atomic constraints involved had been declared in a concept and not
14494 /// repeated in two separate places in code.
14495 /// \returns true if such a diagnostic was emitted, false otherwise.
14499
14500private:
14501 /// Caches pairs of template-like decls whose associated constraints were
14502 /// checked for subsumption and whether or not the first's constraints did in
14503 /// fact subsume the second's.
14504 llvm::DenseMap<std::pair<NamedDecl *, NamedDecl *>, bool> SubsumptionCache;
14505 /// Caches the normalized associated constraints of declarations (concepts or
14506 /// constrained declarations). If an error occurred while normalizing the
14507 /// associated constraints of the template or concept, nullptr will be cached
14508 /// here.
14509 llvm::DenseMap<NamedDecl *, NormalizedConstraint *> NormalizationCache;
14510
14511 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
14512 SatisfactionCache;
14513
14514 // The current stack of constraint satisfactions, so we can exit-early.
14516
14517 /// Introduce the instantiated captures of the lambda into the local
14518 /// instantiation scope.
14519 bool addInstantiatedCapturesToScope(
14520 FunctionDecl *Function, const FunctionDecl *PatternDecl,
14522 const MultiLevelTemplateArgumentList &TemplateArgs);
14523
14524 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in
14525 /// the case of lambdas) set up the LocalInstantiationScope of the current
14526 /// function.
14527 bool
14528 SetupConstraintScope(FunctionDecl *FD,
14529 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14530 const MultiLevelTemplateArgumentList &MLTAL,
14532
14533 /// Used during constraint checking, sets up the constraint template argument
14534 /// lists, and calls SetupConstraintScope to set up the
14535 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
14536 std::optional<MultiLevelTemplateArgumentList>
14537 SetupConstraintCheckingTemplateArgumentsAndScope(
14538 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14540
14541 ///@}
14542
14543 //
14544 //
14545 // -------------------------------------------------------------------------
14546 //
14547 //
14548
14549 /// \name Types
14550 /// Implementations are in SemaType.cpp
14551 ///@{
14552
14553public:
14554 /// A mapping that describes the nullability we've seen in each header file.
14556
14557 static int getPrintable(int I) { return I; }
14558 static unsigned getPrintable(unsigned I) { return I; }
14559 static bool getPrintable(bool B) { return B; }
14560 static const char *getPrintable(const char *S) { return S; }
14561 static StringRef getPrintable(StringRef S) { return S; }
14562 static const std::string &getPrintable(const std::string &S) { return S; }
14563 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
14564 return II;
14565 }
14567 static QualType getPrintable(QualType T) { return T; }
14568 static SourceRange getPrintable(SourceRange R) { return R; }
14570 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
14572
14573 enum class CompleteTypeKind {
14574 /// Apply the normal rules for complete types. In particular,
14575 /// treat all sizeless types as incomplete.
14576 Normal,
14577
14578 /// Relax the normal rules for complete types so that they include
14579 /// sizeless built-in types.
14581
14582 // FIXME: Eventually we should flip the default to Normal and opt in
14583 // to AcceptSizeless rather than opt out of it.
14585 };
14586
14588 const DeclSpec *DS = nullptr);
14590 const DeclSpec *DS = nullptr);
14591
14592 /// Build a pointer type.
14593 ///
14594 /// \param T The type to which we'll be building a pointer.
14595 ///
14596 /// \param Loc The location of the entity whose type involves this
14597 /// pointer type or, if there is no such entity, the location of the
14598 /// type that will have pointer type.
14599 ///
14600 /// \param Entity The name of the entity that involves the pointer
14601 /// type, if known.
14602 ///
14603 /// \returns A suitable pointer type, if there are no
14604 /// errors. Otherwise, returns a NULL type.
14606 DeclarationName Entity);
14607
14608 /// Build a reference type.
14609 ///
14610 /// \param T The type to which we'll be building a reference.
14611 ///
14612 /// \param Loc The location of the entity whose type involves this
14613 /// reference type or, if there is no such entity, the location of the
14614 /// type that will have reference type.
14615 ///
14616 /// \param Entity The name of the entity that involves the reference
14617 /// type, if known.
14618 ///
14619 /// \returns A suitable reference type, if there are no
14620 /// errors. Otherwise, returns a NULL type.
14622 DeclarationName Entity);
14623
14624 /// Build an array type.
14625 ///
14626 /// \param T The type of each element in the array.
14627 ///
14628 /// \param ASM C99 array size modifier (e.g., '*', 'static').
14629 ///
14630 /// \param ArraySize Expression describing the size of the array.
14631 ///
14632 /// \param Brackets The range from the opening '[' to the closing ']'.
14633 ///
14634 /// \param Entity The name of the entity that involves the array
14635 /// type, if known.
14636 ///
14637 /// \returns A suitable array type, if there are no errors. Otherwise,
14638 /// returns a NULL type.
14640 unsigned Quals, SourceRange Brackets,
14641 DeclarationName Entity);
14643
14644 /// Build an ext-vector type.
14645 ///
14646 /// Run the required checks for the extended vector type.
14648 SourceLocation AttrLoc);
14649 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
14650 SourceLocation AttrLoc);
14651
14653 Expr *CountExpr,
14654 bool CountInBytes,
14655 bool OrNull);
14656
14657 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
14658 /// expression is uninstantiated. If instantiated it will apply the
14659 /// appropriate address space to the type. This function allows dependent
14660 /// template variables to be used in conjunction with the address_space
14661 /// attribute
14662 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
14663 SourceLocation AttrLoc);
14664
14665 /// Same as above, but constructs the AddressSpace index if not provided.
14667 SourceLocation AttrLoc);
14668
14670
14672
14673 /// Build a function type.
14674 ///
14675 /// This routine checks the function type according to C++ rules and
14676 /// under the assumption that the result type and parameter types have
14677 /// just been instantiated from a template. It therefore duplicates
14678 /// some of the behavior of GetTypeForDeclarator, but in a much
14679 /// simpler form that is only suitable for this narrow use case.
14680 ///
14681 /// \param T The return type of the function.
14682 ///
14683 /// \param ParamTypes The parameter types of the function. This array
14684 /// will be modified to account for adjustments to the types of the
14685 /// function parameters.
14686 ///
14687 /// \param Loc The location of the entity whose type involves this
14688 /// function type or, if there is no such entity, the location of the
14689 /// type that will have function type.
14690 ///
14691 /// \param Entity The name of the entity that involves the function
14692 /// type, if known.
14693 ///
14694 /// \param EPI Extra information about the function type. Usually this will
14695 /// be taken from an existing function with the same prototype.
14696 ///
14697 /// \returns A suitable function type, if there are no errors. The
14698 /// unqualified type will always be a FunctionProtoType.
14699 /// Otherwise, returns a NULL type.
14703
14704 /// Build a member pointer type \c T Class::*.
14705 ///
14706 /// \param T the type to which the member pointer refers.
14707 /// \param Class the class type into which the member pointer points.
14708 /// \param Loc the location where this type begins
14709 /// \param Entity the name of the entity that will have this member pointer
14710 /// type
14711 ///
14712 /// \returns a member pointer type, if successful, or a NULL type if there was
14713 /// an error.
14716
14717 /// Build a block pointer type.
14718 ///
14719 /// \param T The type to which we'll be building a block pointer.
14720 ///
14721 /// \param Loc The source location, used for diagnostics.
14722 ///
14723 /// \param Entity The name of the entity that involves the block pointer
14724 /// type, if known.
14725 ///
14726 /// \returns A suitable block pointer type, if there are no
14727 /// errors. Otherwise, returns a NULL type.
14729 DeclarationName Entity);
14730
14731 /// Build a paren type including \p T.
14734
14735 /// Build a Read-only Pipe type.
14736 ///
14737 /// \param T The type to which we'll be building a Pipe.
14738 ///
14739 /// \param Loc We do not use it for now.
14740 ///
14741 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14742 /// a NULL type.
14744
14745 /// Build a Write-only Pipe type.
14746 ///
14747 /// \param T The type to which we'll be building a Pipe.
14748 ///
14749 /// \param Loc We do not use it for now.
14750 ///
14751 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14752 /// a NULL type.
14754
14755 /// Build a bit-precise integer type.
14756 ///
14757 /// \param IsUnsigned Boolean representing the signedness of the type.
14758 ///
14759 /// \param BitWidth Size of this int type in bits, or an expression
14760 /// representing that.
14761 ///
14762 /// \param Loc Location of the keyword.
14763 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
14764
14765 /// GetTypeForDeclarator - Convert the type for the specified
14766 /// declarator to Type instances.
14767 ///
14768 /// The result of this call will never be null, but the associated
14769 /// type may be a null type if there's an unrecoverable error.
14772
14773 /// Package the given type and TSI into a ParsedType.
14776 TypeSourceInfo **TInfo = nullptr);
14777
14779
14780 // Check whether the size of array element of type \p EltTy is a multiple of
14781 // its alignment and return false if it isn't.
14783
14784 void
14785 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
14786 SourceLocation FallbackLoc,
14787 SourceLocation ConstQualLoc = SourceLocation(),
14788 SourceLocation VolatileQualLoc = SourceLocation(),
14789 SourceLocation RestrictQualLoc = SourceLocation(),
14790 SourceLocation AtomicQualLoc = SourceLocation(),
14791 SourceLocation UnalignedQualLoc = SourceLocation());
14792
14793 /// Retrieve the keyword associated
14795
14796 /// Adjust the calling convention of a method to be the ABI default if it
14797 /// wasn't specified explicitly. This handles method types formed from
14798 /// function type typedefs and typename template arguments.
14799 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
14800 bool IsCtorOrDtor, SourceLocation Loc);
14801
14802 // Check if there is an explicit attribute, but only look through parens.
14803 // The intent is to look for an attribute on the current declarator, but not
14804 // one that came from a typedef.
14806
14807 /// Check whether a nullability type specifier can be added to the given
14808 /// type through some means not written in source (e.g. API notes).
14809 ///
14810 /// \param Type The type to which the nullability specifier will be
14811 /// added. On success, this type will be updated appropriately.
14812 ///
14813 /// \param Nullability The nullability specifier to add.
14814 ///
14815 /// \param DiagLoc The location to use for diagnostics.
14816 ///
14817 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
14818 /// array type (e.g., because it will decay to a pointer).
14819 ///
14820 /// \param OverrideExisting Whether to override an existing, locally-specified
14821 /// nullability specifier rather than complaining about the conflict.
14822 ///
14823 /// \returns true if nullability cannot be applied, false otherwise.
14825 NullabilityKind Nullability,
14826 SourceLocation DiagLoc,
14827 bool AllowArrayTypes,
14828 bool OverrideExisting);
14829
14830 /// Get the type of expression E, triggering instantiation to complete the
14831 /// type if necessary -- that is, if the expression refers to a templated
14832 /// static data member of incomplete array type.
14833 ///
14834 /// May still return an incomplete type if instantiation was not possible or
14835 /// if the type is incomplete for a different reason. Use
14836 /// RequireCompleteExprType instead if a diagnostic is expected for an
14837 /// incomplete expression type.
14839
14841
14842 /// Ensure that the type of the given expression is complete.
14843 ///
14844 /// This routine checks whether the expression \p E has a complete type. If
14845 /// the expression refers to an instantiable construct, that instantiation is
14846 /// performed as needed to complete its type. Furthermore
14847 /// Sema::RequireCompleteType is called for the expression's type (or in the
14848 /// case of a reference type, the referred-to type).
14849 ///
14850 /// \param E The expression whose type is required to be complete.
14851 /// \param Kind Selects which completeness rules should be applied.
14852 /// \param Diagnoser The object that will emit a diagnostic if the type is
14853 /// incomplete.
14854 ///
14855 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
14856 /// otherwise.
14858 TypeDiagnoser &Diagnoser);
14859 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
14860
14861 template <typename... Ts>
14862 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
14863 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14865 }
14866
14867 /// Retrieve a version of the type 'T' that is elaborated by Keyword,
14868 /// qualified by the nested-name-specifier contained in SS, and that is
14869 /// (re)declared by OwnedTagDecl, which is nullptr if this is not a
14870 /// (re)declaration.
14872 const CXXScopeSpec &SS, QualType T,
14873 TagDecl *OwnedTagDecl = nullptr);
14874
14875 // Returns the underlying type of a decltype with the given expression.
14877
14879 /// If AsUnevaluated is false, E is treated as though it were an evaluated
14880 /// context, such as when building a type for decltype(auto).
14881 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
14882
14883 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
14885 SourceLocation EllipsisLoc);
14886 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
14887 SourceLocation Loc, SourceLocation EllipsisLoc,
14888 bool FullySubstituted = false,
14889 ArrayRef<QualType> Expansions = {});
14890
14908
14909 /// Ensure that the type T is a literal type.
14910 ///
14911 /// This routine checks whether the type @p T is a literal type. If @p T is an
14912 /// incomplete type, an attempt is made to complete it. If @p T is a literal
14913 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
14914 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
14915 /// it the type @p T), along with notes explaining why the type is not a
14916 /// literal type, and returns true.
14917 ///
14918 /// @param Loc The location in the source that the non-literal type
14919 /// diagnostic should refer to.
14920 ///
14921 /// @param T The type that this routine is examining for literalness.
14922 ///
14923 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
14924 ///
14925 /// @returns @c true if @p T is not a literal type and a diagnostic was
14926 /// emitted, @c false otherwise.
14928 TypeDiagnoser &Diagnoser);
14929 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
14930
14931 template <typename... Ts>
14933 const Ts &...Args) {
14934 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14935 return RequireLiteralType(Loc, T, Diagnoser);
14936 }
14937
14940 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
14941 }
14942
14943 /// Ensure that the type T is a complete type.
14944 ///
14945 /// This routine checks whether the type @p T is complete in any
14946 /// context where a complete type is required. If @p T is a complete
14947 /// type, returns false. If @p T is a class template specialization,
14948 /// this routine then attempts to perform class template
14949 /// instantiation. If instantiation fails, or if @p T is incomplete
14950 /// and cannot be completed, issues the diagnostic @p diag (giving it
14951 /// the type @p T) and returns true.
14952 ///
14953 /// @param Loc The location in the source that the incomplete type
14954 /// diagnostic should refer to.
14955 ///
14956 /// @param T The type that this routine is examining for completeness.
14957 ///
14958 /// @param Kind Selects which completeness rules should be applied.
14959 ///
14960 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
14961 /// @c false otherwise.
14963 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
14965 CompleteTypeKind Kind, unsigned DiagID);
14966
14968 TypeDiagnoser &Diagnoser) {
14970 }
14973 }
14974
14975 template <typename... Ts>
14977 const Ts &...Args) {
14978 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14979 return RequireCompleteType(Loc, T, Diagnoser);
14980 }
14981
14982 /// Determine whether a declaration is visible to name lookup.
14983 bool isVisible(const NamedDecl *D) {
14984 return D->isUnconditionallyVisible() ||
14985 isAcceptableSlow(D, AcceptableKind::Visible);
14986 }
14987
14988 /// Determine whether a declaration is reachable.
14989 bool isReachable(const NamedDecl *D) {
14990 // All visible declarations are reachable.
14991 return D->isUnconditionallyVisible() ||
14992 isAcceptableSlow(D, AcceptableKind::Reachable);
14993 }
14994
14995 /// Determine whether a declaration is acceptable (visible/reachable).
14998 }
14999
15000 /// Determine if \p D and \p Suggested have a structurally compatible
15001 /// layout as described in C11 6.2.7/1.
15002 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15003
15004 /// Determine if \p D has a visible definition. If not, suggest a declaration
15005 /// that should be made visible to expose the definition.
15006 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15007 bool OnlyNeedComplete = false);
15009 NamedDecl *Hidden;
15010 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15011 }
15012
15013 /// Determine if \p D has a reachable definition. If not, suggest a
15014 /// declaration that should be made reachable to expose the definition.
15015 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15016 bool OnlyNeedComplete = false);
15018 NamedDecl *Hidden;
15019 return hasReachableDefinition(D, &Hidden);
15020 }
15021
15022 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15024 bool OnlyNeedComplete = false);
15026 NamedDecl *Hidden;
15027 return hasAcceptableDefinition(D, &Hidden, Kind);
15028 }
15029
15030 /// Try to parse the conditional expression attached to an effect attribute
15031 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
15032 /// optional on error.
15033 std::optional<FunctionEffectMode>
15034 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
15035
15036private:
15037 /// The implementation of RequireCompleteType
15038 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15039 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15040
15041 /// Nullability type specifiers.
15042 IdentifierInfo *Ident__Nonnull = nullptr;
15043 IdentifierInfo *Ident__Nullable = nullptr;
15044 IdentifierInfo *Ident__Nullable_result = nullptr;
15045 IdentifierInfo *Ident__Null_unspecified = nullptr;
15046
15047 ///@}
15048
15049 //
15050 //
15051 // -------------------------------------------------------------------------
15052 //
15053 //
15054
15055 /// \name FixIt Helpers
15056 /// Implementations are in SemaFixItUtils.cpp
15057 ///@{
15058
15059public:
15060 /// Get a string to suggest for zero-initialization of a type.
15062 SourceLocation Loc) const;
15064
15065 ///@}
15066
15067 //
15068 //
15069 // -------------------------------------------------------------------------
15070 //
15071 //
15072
15073 /// \name Function Effects
15074 /// Implementations are in SemaFunctionEffects.cpp
15075 ///@{
15076public:
15078 enum class Kind { Added, Removed, ConditionMismatch };
15079
15082 std::optional<FunctionEffectWithCondition>
15083 Old; // Invalid when 'Kind' is 'Added'.
15084 std::optional<FunctionEffectWithCondition>
15085 New; // Invalid when 'Kind' is 'Removed'.
15086
15087 StringRef effectName() const {
15088 if (Old)
15089 return Old.value().Effect.name();
15090 return New.value().Effect.name();
15091 }
15092
15093 /// Describes the result of effects differing between a base class's virtual
15094 /// method and an overriding method in a subclass.
15095 enum class OverrideResult {
15096 NoAction,
15097 Warn,
15098 Merge // Merge missing effect from base to derived.
15099 };
15100
15101 /// Return true if adding or removing the effect as part of a type
15102 /// conversion should generate a diagnostic.
15103 bool shouldDiagnoseConversion(QualType SrcType,
15104 const FunctionEffectsRef &SrcFX,
15105 QualType DstType,
15106 const FunctionEffectsRef &DstFX) const;
15107
15108 /// Return true if adding or removing the effect in a redeclaration should
15109 /// generate a diagnostic.
15110 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
15111 const FunctionEffectsRef &OldFX,
15112 const FunctionDecl &NewFunction,
15113 const FunctionEffectsRef &NewFX) const;
15114
15115 /// Return true if adding or removing the effect in a C++ virtual method
15116 /// override should generate a diagnostic.
15117 OverrideResult shouldDiagnoseMethodOverride(
15118 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
15119 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
15120 };
15121
15122 struct FunctionEffectDiffVector : public SmallVector<FunctionEffectDiff> {
15123 /// Caller should short-circuit by checking for equality first.
15125 const FunctionEffectsRef &New);
15126 };
15127
15128 /// All functions/lambdas/blocks which have bodies and which have a non-empty
15129 /// FunctionEffectsRef to be verified.
15131
15132 /// The union of all effects present on DeclsWithEffectsToVerify. Conditions
15133 /// are all null.
15135
15136public:
15137 /// Warn and return true if adding a function effect to a set would create a
15138 /// conflict.
15141 SourceLocation NewAttrLoc);
15142
15143 // Report a failure to merge function effects between declarations due to a
15144 // conflict.
15145 void
15147 SourceLocation NewLoc,
15148 SourceLocation OldLoc);
15149
15150 /// Inline checks from the start of maybeAddDeclWithEffects, to
15151 /// minimize performance impact on code not using effects.
15152 template <class FuncOrBlockDecl>
15153 void maybeAddDeclWithEffects(FuncOrBlockDecl *D) {
15155 if (FunctionEffectsRef FX = D->getFunctionEffects(); !FX.empty())
15157 }
15158
15159 /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify.
15160 void maybeAddDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15161
15162 /// Unconditionally add a Decl to DeclsWithEfffectsToVerify.
15163 void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15164
15166
15167 ///@}
15168};
15169
15170DeductionFailureInfo
15172 sema::TemplateDeductionInfo &Info);
15173
15174/// Contains a late templated function.
15175/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15178 /// The template function declaration to be late parsed.
15180 /// Floating-point options in the point of definition.
15182};
15183
15184template <>
15186 PragmaMsStackAction Action,
15187 llvm::StringRef StackSlotLabel,
15189} // end namespace clang
15190
15191#endif
#define V(N, I)
Definition: ASTContext.h:3443
Forward declaration of all AST node types.
MatchType Type
StringRef P
static char ID
Definition: Arena.cpp:183
#define SM(sm)
Definition: Cuda.cpp:84
Defines enum values for all the target-independent builtin functions.
static void emit(Program &P, std::vector< std::byte > &Code, const T &Val, bool &Success)
Helper to write bytecode and bail out if 32-bit offsets become invalid.
const Decl * D
IndirectLocalPath & Path
const LambdaCapture * Capture
Expr * E
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
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.
int Priority
Definition: Format.cpp:3036
StringRef Identifier
Definition: Format.cpp:3040
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::Target Target
Definition: MachO.h:51
llvm::MachO::Record Record
Definition: MachO.h:31
Defines the clang::Module class, which describes a module in the source code.
Defines the clang::OpenCLOptions class.
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
Definition: Redeclaration.h:18
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
uint32_t Id
Definition: SemaARM.cpp:1134
AccessResult
A copy of Sema's enum without AR_delayed.
Definition: SemaAccess.cpp:30
CastType
Definition: SemaCast.cpp:48
SourceRange Range
Definition: SemaObjC.cpp:758
SourceLocation Loc
Definition: SemaObjC.cpp:759
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:4547
C Language Family Type Representation.
SourceLocation Begin
StateNode * Previous
std::string Label
__device__ int
#define bool
Definition: amdgpuintrin.h:20
A class for storing results from argument-dependent lookup.
Definition: Lookup.h:869
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
CanQualType BoolTy
Definition: ASTContext.h:1161
bool hasAnyFunctionEffects() const
Definition: ASTContext.h:3014
CanQualType IntTy
Definition: ASTContext.h:1169
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:383
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:89
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:86
PtrTy get() const
Definition: Ownership.h:170
bool isInvalid() const
Definition: Ownership.h:166
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2718
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:3577
Attr - This represents one attribute.
Definition: Attr.h:43
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:6127
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:6556
Represents a C++ declaration that introduces decls from somewhere else.
Definition: DeclCXX.h:3435
A binding in a decomposition declaration.
Definition: DeclCXX.h:4125
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4474
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:2553
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2880
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2318
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2498
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2817
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2078
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:74
Represents the this expression in C++.
Definition: ExprCXX.h:1152
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:2874
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4673
CaseStmt - Represent a case statement.
Definition: Stmt.h:1828
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3547
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.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:35
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3616
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4582
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.
Definition: DarwinSDKInfo.h:29
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:1368
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1435
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1265
Captures information about "declaration specifiers".
Definition: DeclSpec.h:247
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:835
SourceLocation getLocation() const
Definition: DeclBase.h:442
DeclContext * getDeclContext()
Definition: DeclBase.h:451
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:907
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:735
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1903
A decomposition declaration.
Definition: DeclCXX.h:4184
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.
Definition: Diagnostic.h:1220
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
void setLastDiagnosticIgnored(bool Ignored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed,...
Definition: Diagnostic.h:784
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3277
Represents an enum.
Definition: Decl.h:3847
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:6098
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1912
The return type of classify().
Definition: Expr.h:330
This represents one expression.
Definition: Expr.h:110
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:192
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
Definition: Expr.h:797
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:277
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
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.
Definition: LangOptions.h:978
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
Definition: LangOptions.h:1085
Represents a member of a struct/union/class.
Definition: Decl.h:3033
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:1935
A mutable set of FunctionEffect::Kind.
Definition: Type.h:4957
Kind
Identifies the particular effect.
Definition: Type.h:4719
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition: Type.h:4903
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4654
Represents a prototype with parameter type info, e.g.
Definition: Type.h:5102
Declaration of a template function.
Definition: DeclTemplate.h:959
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition: Type.h:4347
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4321
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:567
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3321
Describes an C or C++ initializer list.
Definition: Expr.h:5088
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:503
ComplexRangeKind
Controls the various implementations for complex multiplication and.
Definition: LangOptions.h:441
FPEvalMethodKind
Possible float expression evaluation method choices.
Definition: LangOptions.h:299
FPExceptionModeKind
Possible floating point exception behavior.
Definition: LangOptions.h:287
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
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:46
A global _GUID constant.
Definition: DeclCXX.h:4307
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4253
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4734
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3236
Abstract interface for a module loader.
Definition: ModuleLoader.h:82
Describes a module or submodule.
Definition: Module.h:115
Module(ModuleConstructorTag, StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit, unsigned VisibilityID)
Construct a new module or submodule.
Definition: Module.cpp:37
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:253
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
Definition: Decl.h:418
Represent a C++ namespace.
Definition: Decl.h:551
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:1153
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition: Type.h:7580
Wrapper for void* pointer.
Definition: Ownership.h:50
static OpaquePtr make(QualType P)
Definition: Ownership.h:60
OpenCL supported extensions and optional core features.
Definition: OpenCLOptions.h:69
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
Definition: Overload.h:1008
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
Definition: Attr.h:255
ParenExpr - This represents a parenthesized expression, e.g.
Definition: Expr.h:2170
Represents a parameter to a function.
Definition: Decl.h:1725
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:129
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:956
Represents the parsed form of a C++ template argument.
Parser - This implements a parser for the C family of languages.
Definition: Parser.h:58
Tracks expected type during expression parsing, for use in code completion.
Definition: Sema.h:289
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)
PreferredTypeBuilder(bool Enabled)
Definition: Sema.h:291
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
Definition: Sema.h:326
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:138
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2566
A (possibly-)qualified type.
Definition: Type.h:929
The collection of all-type qualifiers we support.
Definition: Type.h:324
Represents a struct/union/class.
Definition: Decl.h:4148
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:6072
Represents the body of a requires-expression.
Definition: DeclCXX.h:2047
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:502
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:41
void incrementMSManglingNumber()
Definition: Scope.h:356
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:110
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: SemaBase.cpp:60
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Definition: SemaBase.cpp:32
AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
Definition: Sema.h:1454
bool operator==(const AlignPackInfo &Info) const
Definition: Sema.h:1514
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:1486
unsigned getPackNumber() const
Definition: Sema.h:1504
bool IsXLStack() const
Definition: Sema.h:1512
bool IsPackSet() const
Definition: Sema.h:1506
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition: Sema.h:1460
bool IsAlignAttr() const
Definition: Sema.h:1500
bool IsPackAttr() const
Definition: Sema.h:1498
bool operator!=(const AlignPackInfo &Info) const
Definition: Sema.h:1520
AlignPackInfo(bool IsXL)
Definition: Sema.h:1464
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition: Sema.h:1471
Mode getAlignMode() const
Definition: Sema.h:1502
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:13193
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:13198
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7872
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7877
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition: Sema.h:7864
std::tuple< const Ts &... > Args
Definition: Sema.h:7861
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:8041
A RAII object to enter scope of a compound statement.
Definition: Sema.h:915
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:917
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:7325
bool isInvalid() const
Definition: Sema.h:7324
std::optional< bool > getKnownValue() const
Definition: Sema.h:7329
A RAII object to temporarily push a declaration context.
Definition: Sema.h:3003
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition: Sema.h:3013
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:10024
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:10029
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.
For a defaulted function, the kind of defaulted function that it is.
Definition: Sema.h:5884
DefaultedComparisonKind asComparison() const
Definition: Sema.h:5916
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition: Sema.h:5893
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition: Sema.h:5921
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition: Sema.h:5896
CXXSpecialMemberKind asSpecialMember() const
Definition: Sema.h:5913
RAII class to control scope of DeferDiags.
Definition: Sema.h:9751
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition: Sema.h:9756
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition: Sema.h:984
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:1003
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:1027
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:996
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:999
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:1013
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:1019
A helper class for building up ExtParameterInfos.
Definition: Sema.h:12607
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:12626
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:12614
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:13562
FPOptionsOverride getOverrides()
Definition: Sema.h:13566
FullExprArg(Sema &actions)
Definition: Sema.h:7269
ExprResult release()
Definition: Sema.h:7271
Expr * get() const
Definition: Sema.h:7273
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:13578
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:10088
virtual SemaDiagnosticBuilder diagnoseNotInt(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress, bool SuppressConversion)
Definition: Sema.h:10080
Helper class that collects exception specifications for implicitly-declared special member functions.
Definition: Sema.h:4988
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:5021
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:5014
const QualType * data() const
The set of exceptions in the exception specification.
Definition: Sema.h:5024
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
Definition: Sema.h:5030
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition: Sema.h:5037
static NameClassification DependentNonType()
Definition: Sema.h:3247
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:3257
ExprResult getExpression() const
Definition: Sema.h:3283
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:3223
static NameClassification Unknown()
Definition: Sema.h:3227
static NameClassification OverloadSet(ExprResult E)
Definition: Sema.h:3231
NameClassificationKind getKind() const
Definition: Sema.h:3281
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition: Sema.h:3275
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:3263
NamedDecl * getNonTypeDecl() const
Definition: Sema.h:3293
NameClassification(ParsedType Type)
Definition: Sema.h:3221
TemplateName getTemplateName() const
Definition: Sema.h:3298
ParsedType getType() const
Definition: Sema.h:3288
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:3305
static NameClassification NonType(NamedDecl *D)
Definition: Sema.h:3237
static NameClassification Concept(TemplateName Name)
Definition: Sema.h:3269
static NameClassification UndeclaredNonType()
Definition: Sema.h:3243
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:3251
static NameClassification Error()
Definition: Sema.h:3225
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
Definition: Sema.h:662
void operator()(sema::FunctionScopeInfo *Scope) const
Definition: Sema.cpp:2313
Whether and why a template name is required in this lookup.
Definition: Sema.h:11083
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition: Sema.h:11089
SourceLocation getTemplateKeywordLoc() const
Definition: Sema.h:11091
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition: Sema.h:11086
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:12079
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:12109
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:12087
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition: Sema.h:7889
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7894
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7891
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:8957
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:8935
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:8944
CXXMethodDecl * getMethod() const
Definition: Sema.h:8947
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:8948
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:13071
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:13099
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:13077
SourceLocation getLocation() const
Definition: Sema.h:11853
bool ContainsDecl(const NamedDecl *ND) const
Definition: Sema.h:11843
const DeclContext * getDeclContext() const
Definition: Sema.h:11849
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition: Sema.h:11827
const NamedDecl * getDecl() const
Definition: Sema.h:11841
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition: Sema.h:11826
const DeclContext * getLexicalDeclContext() const
Definition: Sema.h:11845
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:12118
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:12125
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:7222
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition: Sema.h:7226
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:463
FunctionDecl * FindUsualDeallocationFunction(SourceLocation StartLoc, bool CanProvideSize, bool Overaligned, DeclarationName Name)
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...
Definition: SemaExpr.cpp:14555
void DeclareGlobalNewDelete()
DeclareGlobalNewDelete - Declare the global forms of operator new and delete.
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs)
Definition: SemaDecl.cpp:14284
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
bool CheckInstantiatedFunctionTemplateConstraints(SourceLocation PointOfInstantiation, FunctionDecl *Decl, ArrayRef< TemplateArgument > TemplateArgs, ConstraintSatisfaction &Satisfaction)
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.
Definition: SemaType.cpp:9207
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 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.
Definition: SemaDecl.cpp:11006
ExprResult PerformImplicitObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
QualType BuildParenType(QualType T)
Build a paren type including T.
Definition: SemaType.cpp:1674
SemaAMDGPU & AMDGPU()
Definition: Sema.h:1045
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6394
SmallVector< DeclaratorDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
Definition: Sema.h:3095
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
Definition: SemaDecl.cpp:6677
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:13143
void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn)
#pragma optimize("[optimization-list]", on | off).
Definition: SemaAttr.cpp:1249
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, const TemplateArgumentListInfo &TemplateArgsInfo, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
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 EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result, ASTContext &Ctx, bool ErrorOnInvalidMessage)
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:7794
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
Definition: SemaAttr.cpp:499
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Definition: Sema.h:13127
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...
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:10650
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:12636
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
sema::CapturingScopeInfo * getEnclosingLambdaOrBlock() const
Get the innermost lambda or block enclosing the current location, if any.
Definition: Sema.cpp:2386
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:731
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...
Definition: SemaDecl.cpp:2469
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....
Definition: SemaType.cpp:9082
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
Definition: SemaDecl.cpp:6597
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
SmallVector< SmallVector< VTableUse, 16 >, 8 > SavedVTableUses
Definition: Sema.h:13525
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Definition: SemaDecl.cpp:9776
void PopParsingClass(ParsingClassState state)
Definition: Sema.h:6078
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...
void DiagnoseDiscardedExprMarkedNodiscard(const Expr *E)
DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is semantically a discarded-value exp...
Definition: SemaStmt.cpp:416
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
Definition: Sema.h:9767
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition: Sema.cpp:994
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
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:6067
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)
Definition: SemaType.cpp:2030
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.
Definition: SemaExpr.cpp:15821
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7844
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',...
Definition: SemaDecl.cpp:1559
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
Definition: SemaExpr.cpp:15498
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:7762
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:868
bool isAttrContext() const
Definition: Sema.h:6462
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
Definition: SemaDecl.cpp:15177
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Definition: SemaStmt.cpp:4433
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, bool &RetainExpansion, std::optional< unsigned > &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Definition: SemaAttr.cpp:1148
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.
NamedDecl * FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS)
If the given nested-name-specifier begins with a bare identifier (e.g., Base::), perform name lookup ...
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7837
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:2486
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition: Sema.h:5828
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:8979
@ LookupLabel
Label name lookup.
Definition: Sema.h:8988
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:8983
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition: Sema.h:9010
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition: Sema.h:9002
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:9024
@ LookupLocalFriendName
Look up a friend of a local class.
Definition: Sema.h:9018
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition: Sema.h:9020
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:9015
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:8995
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition: Sema.h:9022
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition: Sema.h:9006
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:8991
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition: Sema.h:8998
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:8986
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition: Sema.h:9026
@ LookupAnyName
Look up any declaration with any name.
Definition: Sema.h:9028
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:412
llvm::DenseMap< IdentifierInfo *, SrcLocSet > IdentifierSourceLocations
Definition: Sema.h:8923
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:4460
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.
Definition: SemaDecl.cpp:6613
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
Definition: SemaType.cpp:6497
void ActOnPragmaAttributePop(SourceLocation PragmaLoc, const IdentifierInfo *Namespace)
Called on well-formed '#pragma clang attribute pop'.
Definition: SemaAttr.cpp:1155
void ActOnPopScope(SourceLocation Loc, Scope *S)
Definition: SemaDecl.cpp:2180
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
Definition: SemaDecl.cpp:5306
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
Definition: SemaExpr.cpp:19647
void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
ActOnPragmaDetectMismatch - Call on well-formed #pragma detect_mismatch.
Definition: SemaAttr.cpp:625
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13158
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
Definition: SemaDecl.cpp:15876
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:5765
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS=nullptr)
VariadicCallType
Definition: Sema.h:2308
@ VariadicDoesNotApply
Definition: Sema.h:2313
@ VariadicFunction
Definition: Sema.h:2309
@ VariadicMethod
Definition: Sema.h:2311
@ VariadicConstructor
Definition: Sema.h:2312
@ VariadicBlock
Definition: Sema.h:2310
SemaM68k & M68k()
Definition: Sema.h:1090
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
Definition: SemaDecl.cpp:12931
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.
Definition: SemaModule.cpp:768
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
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)
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, std::optional< unsigned > NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true)
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...
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
Definition: SemaExpr.cpp:2452
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
Definition: SemaExpr.cpp:7040
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...
Definition: SemaLambda.cpp:850
bool DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc, RecordDecl *ClassDecl, const IdentifierInfo *Name)
bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum)
BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a constant expression representing ...
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:979
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
Definition: SemaAccess.cpp:36
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)
NonTrivialCUnionContext
Definition: Sema.h:3617
@ NTCUC_CopyInit
Definition: Sema.h:3627
@ NTCUC_AutoVar
Definition: Sema.h:3625
@ NTCUC_CompoundLiteral
Definition: Sema.h:3631
@ NTCUC_DefaultInitializedObject
Definition: Sema.h:3623
@ NTCUC_Assignment
Definition: Sema.h:3629
@ NTCUC_BlockCapture
Definition: Sema.h:3633
@ NTCUC_FunctionReturn
Definition: Sema.h:3621
@ NTCUC_LValueToRValueVolatile
Definition: Sema.h:3635
@ NTCUC_FunctionParam
Definition: Sema.h:3619
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:1719
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...
Definition: SemaDecl.cpp:3519
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.
bool hasReachableDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
MissingImportKind
Kinds of missing import.
Definition: Sema.h:9467
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
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)
Definition: SemaExpr.cpp:7544
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.
Definition: SemaDecl.cpp:6090
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:4405
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID)
Definition: SemaLookup.cpp:995
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 directiv...
Definition: SemaModule.cpp:729
bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum, unsigned Multiple)
BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr TheCall is a constant expr...
RetainOwnershipKind
Definition: Sema.h:4604
OpaquePtr< QualType > TypeTy
Definition: Sema.h:901
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
Definition: SemaDecl.cpp:18275
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:165
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
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:303
void PrintContextStack()
Definition: Sema.h:13213
TypeResult ActOnTemplateIdType(Scope *S, 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 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...
Definition: SemaExpr.cpp:2338
bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc, StringRef Keyword)
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
Definition: SemaType.cpp:2326
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:642
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e....
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings={})
Definition: SemaDecl.cpp:7430
SemaOpenMP & OpenMP()
Definition: Sema.h:1125
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:8453
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:8458
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:8462
@ IER_Error
An error occurred.
Definition: Sema.h:8465
@ IER_Exists
The symbol exists.
Definition: Sema.h:8455
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:8922
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:15840
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, sema::LambdaScopeInfo *LSI)
Complete a lambda-expression having processed and attached the lambda body.
bool ActOnTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, MultiExprArg Args)
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
Definition: Sema.h:5803
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:9293
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
Definition: SemaExpr.cpp:17452
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
Definition: SemaExpr.cpp:15846
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt={})
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
Definition: SemaExpr.cpp:20164
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition: Sema.h:971
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
Definition: SemaStmt.cpp:4422
void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode)
Called to set constant rounding mode for floating point operations.
Definition: SemaAttr.cpp:1427
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,...
Definition: SemaDecl.cpp:6075
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....
Definition: SemaExpr.cpp:1557
static const IdentifierInfo * getPrintable(const IdentifierInfo *II)
Definition: Sema.h:14563
StmtResult ActOnForEachLValueExpr(Expr *E)
In an Objective C collection iteration statement: for (x in y) x can be an arbitrary l-value expressi...
Definition: SemaStmt.cpp:2267
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:866
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Definition: SemaDecl.cpp:18207
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
Definition: Sema.h:4318
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:3077
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:1426
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.
Definition: SemaType.cpp:7624
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
Definition: SemaExpr.cpp:12167
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.
Definition: SemaLambda.cpp:249
bool hasVisibleDefinition(const NamedDecl *D)
Definition: Sema.h:15008
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:6044
void emitAndClearUnusedLocalTypedefWarnings()
Definition: Sema.cpp:1085
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...
Definition: SemaDecl.cpp:16415
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Definition: Sema.h:6025
static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember, bool IsVariadic, FormatStringInfo *FSI)
Given a FunctionDecl's FormatAttr, attempts to populate the FomatStringInfo parameter with the Format...
void ActOnForEachDeclStmt(DeclGroupPtrTy Decl)
Definition: SemaStmt.cpp:86
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
Definition: SemaDecl.cpp:15043
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
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:855
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
Definition: SemaAttr.cpp:1190
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:1070
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)
Definition: SemaExpr.cpp:17387
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 ...
Definition: SemaAttr.cpp:1561
PragmaClangSectionAction
Definition: Sema.h:1416
@ PCSA_Set
Definition: Sema.h:1416
@ PCSA_Clear
Definition: Sema.h:1416
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...
Definition: SemaExpr.cpp:20380
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:309
ConditionKind
Definition: Sema.h:7344
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
@ Switch
An integral condition for a 'switch' statement.
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
void LateTemplateParserCB(void *P, LateParsedTemplate &LPT)
Callback to the parser to parse templated functions when needed.
Definition: Sema.h:948
void AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc)
Adds the 'optnone' attribute to the function declaration if there are no conflicts; Loc represents th...
Definition: SemaAttr.cpp:1298
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Definition: Sema.h:14967
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:14569
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
Definition: SemaExpr.cpp:2676
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:7782
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
ModuleDeclKind
Definition: Sema.h:9598
@ PartitionImplementation
'module X:Y;'
@ Interface
'export module X;'
@ PartitionInterface
'export module X:Y;'
SourceLocation LocationOfExcessPrecisionNotSatisfied
Definition: Sema.h:7924
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, 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...
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Definition: Sema.h:848
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()
Definition: SemaDecl.cpp:1455
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
Definition: Sema.h:9240
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition: Sema.h:10107
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition: Sema.h:10110
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition: Sema.h:10116
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition: Sema.h:10114
bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum, unsigned ArgBits)
BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is a constant expression represen...
void inferLifetimeCaptureByAttribute(FunctionDecl *FD)
Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
Definition: SemaAttr.cpp:272
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:1372
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, LookupResult &Previous, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
AccessResult
Definition: Sema.h:1260
@ AR_dependent
Definition: Sema.h:1263
@ AR_accessible
Definition: Sema.h:1261
@ AR_inaccessible
Definition: Sema.h:1262
@ AR_delayed
Definition: Sema.h:1264
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:2290
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
CompleteTypeKind
Definition: Sema.h:14573
@ Normal
Apply the normal rules for complete types.
@ AcceptSizeless
Relax the normal rules for complete types so that they include sizeless built-in types.
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:671
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
Definition: SemaCast.cpp:3377
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:530
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition: Sema.h:6440
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:2159
QualType GetSignedSizelessVectorType(QualType V)
Definition: SemaExpr.cpp:12726
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:13130
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:394
void AddTemplateParametersToLambdaCallOperator(CXXMethodDecl *CallOperator, CXXRecordDecl *Class, TemplateParameterList *TemplateParams)
Definition: SemaLambda.cpp:998
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
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:7913
void deduceOpenCLAddressSpace(ValueDecl *decl)
Definition: SemaDecl.cpp:6828
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3538
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3171
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:1657
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:7825
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:14570
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:1651
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)
Definition: SemaStmt.cpp:3782
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
Definition: SemaAttr.cpp:1268
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)
Definition: SemaExpr.cpp:18430
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:15134
void setFunctionHasBranchIntoScope()
Definition: Sema.cpp:2339
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:4465
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition: SemaStmt.cpp:500
SourceLocation getOptimizeOffPragmaLocation() const
Get the location for the currently active "\#pragma clang optimize off". If this location is invalid,...
Definition: Sema.h:1728
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
Definition: SemaDecl.cpp:6218
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
Definition: SemaExpr.cpp:17145
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:617
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...
virtual void anchor()
This virtual key function only exists to limit the emission of debug info describing the Sema class.
Definition: Sema.cpp:301
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Definition: SemaType.cpp:2392
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
Definition: SemaDecl.cpp:4805
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition: Sema.h:1646
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:10810
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
Definition: SemaExpr.cpp:6682
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
Definition: SemaAttr.cpp:53
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...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
Definition: SemaDecl.cpp:12345
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
Definition: SemaDecl.cpp:16616
void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver)
If VD is set but not otherwise used, diagnose, for a parameter or a variable.
Definition: SemaDecl.cpp:2099
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.
Definition: SemaExpr.cpp:10143
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:2438
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3493
@ Other
C++26 [dcl.fct.def.general]p1 function-body: ctor-initializer[opt] compound-statement function-try-bl...
@ Delete
deleted-function-body
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,...
Definition: SemaDecl.cpp:18294
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
llvm::function_ref< void(llvm::raw_ostream &)> EntityPrinter
Definition: Sema.h:13487
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
Definition: SemaStmt.cpp:49
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
Definition: SemaDecl.cpp:18390
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition: Sema.cpp:1169
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:1658
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:1080
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
Definition: SemaExpr.cpp:7518
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.
Definition: SemaLambda.cpp:876
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:844
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
void CheckThreadLocalForLargeAlignment(VarDecl *VD)
Definition: SemaDecl.cpp:14657
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
Definition: SemaExpr.cpp:15859
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.
bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str)
Check Target Version attrs.
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
void ActOnTranslationUnitScope(Scope *S)
Scope actions.
Definition: Sema.cpp:148
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
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.
Definition: SemaDecl.cpp:1431
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
bool CheckConceptUseInDefinition(ConceptDecl *Concept, SourceLocation Loc)
SemaSYCL & SYCL()
Definition: Sema.h:1145
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)
Definition: SemaDecl.cpp:15512
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16502
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:2713
StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:1026
ExpressionEvaluationContextRecord & parentEvaluationContext()
Definition: Sema.h:6452
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:1568
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
void ActOnPragmaFloatControl(SourceLocation Loc, PragmaMsStackAction Action, PragmaFloatControlKind Value)
ActOnPragmaFloatControl - Call on well-formed #pragma float_control.
Definition: SemaAttr.cpp:660
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
Definition: SemaExpr.cpp:784
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
LateParsedTemplateMapT LateParsedTemplateMap
Definition: Sema.h:11054
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
Definition: SemaDecl.cpp:3397
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition: Sema.h:11628
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition: Sema.h:11639
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:11631
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition: Sema.h:11635
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:641
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:714
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old)
[module.interface]p6: A redeclaration of an entity X is implicitly exported if X was introduced by an...
Definition: SemaDecl.cpp:1657
void DiagnosePrecisionLossInComplexDivision()
Definition: SemaAttr.cpp:1226
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:8917
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:1165
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
Definition: SemaExpr.cpp:1042
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Look for instances where it is likely the comma operator is confused with another operator.
Definition: SemaExpr.cpp:13879
DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, ModuleDeclKind MDK, ModuleIdPath Path, ModuleIdPath Partition, ModuleImportState &ImportState)
The parser has processed a module-declaration that begins the definition of a module interface or imp...
Definition: SemaModule.cpp:258
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:13147
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
Definition: SemaExpr.cpp:4998
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
Definition: SemaDecl.cpp:20259
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
Definition: SemaExpr.cpp:1999
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
Definition: SemaExpr.cpp:7628
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
Definition: SemaExpr.cpp:14159
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.
Definition: SemaDecl.cpp:15164
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
Definition: SemaStmt.cpp:1102
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
ASTContext & Context
Definition: Sema.h:908
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:7749
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:614
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
Definition: SemaCast.cpp:2700
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12962
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
Definition: SemaExpr.cpp:9833
bool DiagIfReachable(SourceLocation Loc, ArrayRef< const Stmt * > Stmts, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the statements's reachability analysis.
Definition: SemaExpr.cpp:20175
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Definition: SemaDecl.cpp:14677
ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E)
bool ConstraintExpressionDependsOnEnclosingTemplate(const FunctionDecl *Friend, unsigned TemplateDepth, const Expr *Constraint)
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()
Definition: SemaStmt.cpp:4614
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:8928
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:7290
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
Definition: SemaType.cpp:2632
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:11504
void ActOnPragmaUnused(const Token &Identifier, Scope *curScope, SourceLocation PragmaLoc)
ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Definition: SemaAttr.cpp:932
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
Definition: SemaDecl.cpp:5782
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:13154
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:528
static FormatStringType GetFormatStringType(const FormatAttr *Format)
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...
Definition: SemaExpr.cpp:7893
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
Definition: SemaDecl.cpp:20280
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
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.
Definition: SemaModule.cpp:792
void CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC, bool *ICContext=nullptr, bool IsListInit=false)
void * SkippedDefinitionContext
Definition: Sema.h:3942
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14932
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
Definition: SemaExpr.cpp:21153
void resetFPOptions(FPOptions FPO)
Definition: Sema.h:11032
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition: Sema.h:15025
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:9586
DeclResult ActOnModuleImport(SourceLocation StartLoc, SourceLocation ExportLoc, SourceLocation ImportLoc, ModuleIdPath Path, bool IsPartition=false)
The parser has processed a module import declaration.
Definition: SemaModule.cpp:573
static bool getPrintable(bool B)
Definition: Sema.h:14559
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Definition: SemaLookup.cpp:916
SemaObjC & ObjC()
Definition: Sema.h:1110
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...
void DiagPlaceholderFieldDeclDefinitions(RecordDecl *Record)
Emit diagnostic warnings for placeholder members.
Definition: SemaDecl.cpp:5311
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
Definition: SemaDecl.cpp:4915
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
Definition: SemaExpr.cpp:12997
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:2668
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:1040
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition: SemaDecl.cpp:70
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
AllowFoldKind
Definition: Sema.h:7236
@ AllowFold
Definition: Sema.h:7238
@ NoFold
Definition: Sema.h:7237
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.
Definition: SemaDecl.cpp:1497
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:896
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
Definition: Sema.h:2676
PragmaStack< bool > StrictGuardStackCheckStack
Definition: Sema.h:1654
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
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:3085
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
void CleanupVarDeclMarking()
Definition: SemaExpr.cpp:19660
bool CheckConstraintExpression(const Expr *CE, Token NextToken=Token(), bool *PossibleNonPrimary=nullptr, bool IsTrailingRequiresClause=false)
Check whether the given expression is a valid constraint expression.
Definition: SemaConcept.cpp:90
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
Definition: SemaExpr.cpp:752
bool isImmediateFunctionContext() const
Definition: Sema.h:7774
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
Definition: SemaDecl.cpp:2331
ASTContext & getASTContext() const
Definition: Sema.h:531
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
Definition: SemaExpr.cpp:762
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...
ExprResult VerifyIntegerConstantExpression(Expr *E, AllowFoldKind CanFold=NoFold)
Definition: Sema.h:7253
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)
Definition: SemaDecl.cpp:15948
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:6051
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)
Definition: SemaExpr.cpp:15777
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:1033
void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules)
Definition: SemaAttr.cpp:1015
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.
Definition: SemaExpr.cpp:18930
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
Definition: SemaExpr.cpp:19908
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Check the redefinition in C++20 Modules.
Definition: SemaDecl.cpp:1713
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
Definition: SemaModule.cpp:851
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:6129
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:15295
NameClassificationKind
Describes the result of the name lookup and resolution performed by ClassifyName().
Definition: Sema.h:3170
@ NC_Unknown
This name is not a type or template in this context, but might be something else.
Definition: Sema.h:3173
@ NC_VarTemplate
The name was classified as a variable template name.
Definition: Sema.h:3200
@ NC_NonType
The name was classified as a specific non-type, non-template declaration.
Definition: Sema.h:3183
@ NC_TypeTemplate
The name was classified as a template whose specializations are types.
Definition: Sema.h:3198
@ NC_Error
Classification failed; an error has been produced.
Definition: Sema.h:3175
@ NC_FunctionTemplate
The name was classified as a function template name.
Definition: Sema.h:3202
@ NC_DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition: Sema.h:3191
@ NC_UndeclaredNonType
The name was classified as an ADL-only function name.
Definition: Sema.h:3187
@ NC_UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition: Sema.h:3204
@ NC_Keyword
The name has been typo-corrected to a keyword.
Definition: Sema.h:3177
@ NC_Type
The name was classified as a type.
Definition: Sema.h:3179
@ NC_OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition: Sema.h:3196
@ NC_Concept
The name was classified as a concept name.
Definition: Sema.h:3206
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()
Definition: SemaExpr.cpp:17820
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
Definition: SemaExpr.cpp:9576
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:1650
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: SemaStmt.cpp:4357
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:690
void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, SourceLocation PragmaLoc)
ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
Definition: SemaAttr.cpp:329
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:867
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Definition: SemaExpr.cpp:3486
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg, bool IsDeduced)
Check a template argument against its corresponding template template parameter.
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:665
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition: Sema.h:2142
ParsingClassState PushParsingClass()
Definition: Sema.h:6074
ForRangeStatus
Definition: Sema.h:10472
@ FRS_Success
Definition: Sema.h:10473
@ FRS_DiagnosticIssued
Definition: Sema.h:10475
@ FRS_NoViableFunction
Definition: Sema.h:10474
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
Definition: SemaExpr.cpp:6199
void ActOnPragmaCXLimitedRange(SourceLocation Loc, LangOptions::ComplexRangeKind Range)
ActOnPragmaCXLimitedRange - Called on well formed #pragma STDC CX_LIMITED_RANGE.
Definition: SemaAttr.cpp:1458
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
Definition: SemaExpr.cpp:3101
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'.
Definition: SemaAttr.cpp:1466
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:111
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
Definition: SemaExpr.cpp:7054
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:15827
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:573
TemplateArgumentLoc getTemplateArgumentPackExpansionPattern(TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis, std::optional< unsigned > &NumExpansions) const
Returns the pattern of the pack expansion for a template argument.
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
Definition: Sema.h:8976
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, SourceRange PlacementRange, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose=true)
Checks access to an overloaded operator new or delete.
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:8920
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.
Definition: SemaDecl.cpp:4762
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition: Sema.h:5599
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
@ None
This is not a defaultable comparison operator.
@ Equal
This is an operator== that should be implemented as a series of subobject comparisons.
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)
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
Definition: SemaExpr.cpp:7909
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:8662
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.
Definition: SemaType.cpp:9435
SmallVector< const Decl * > DeclsWithEffectsToVerify
All functions/lambdas/blocks which have bodies and which have a non-empty FunctionEffectsRef to be ve...
Definition: Sema.h:15130
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
AllowedExplicit
Definition: Sema.h:9827
@ Conversions
Allow explicit conversion functions but not explicit constructors.
@ All
Allow both explicit conversion functions and explicit constructors.
void ActOnFinishRequiresExpr()
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
Definition: SemaType.cpp:9563
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
Definition: Sema.h:838
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition: Sema.h:6062
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Definition: SemaExpr.cpp:13043
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)
Definition: SemaDecl.cpp:20426
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.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Definition: Sema.h:816
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.
Definition: SemaDecl.cpp:5464
void ActOnPragmaFPEvalMethod(SourceLocation Loc, LangOptions::FPEvalMethodKind Value)
Definition: SemaAttr.cpp:633
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
Definition: Sema.h:3108
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:1573
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...
Definition: SemaDecl.cpp:16951
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition: Sema.cpp:2429
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition: Sema.h:3000
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
Definition: SemaDecl.cpp:9039
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
Definition: SemaExpr.cpp:2204
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.
Definition: SemaLambda.cpp:456
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
Definition: Sema.h:11044
void setFunctionHasIndirectGoto()
Definition: Sema.cpp:2349
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.
Definition: SemaType.cpp:1939
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition: Sema.h:11774
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:11792
@ TPL_TemplateTemplateArgumentMatch
We are matching the template parameter lists of a template template argument against the template par...
Definition: Sema.h:11803
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:11782
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition: Sema.h:11813
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16115
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:4456
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
Definition: Sema.cpp:1587
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9804
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 *.
Definition: SemaExpr.cpp:1671
ExprResult BuildCaptureInit(const sema::Capture &Capture, SourceLocation ImplicitCaptureLoc, bool IsOpenMPMapping=false)
Initialize the given capture with a suitable expression.
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
Definition: Sema.h:7955
void ActOnPragmaClangSection(SourceLocation PragmaLoc, PragmaClangSectionAction Action, PragmaClangSectionKind SecKind, StringRef SecName)
ActOnPragmaClangSection - Called on well formed #pragma clang section.
Definition: SemaAttr.cpp:384
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:11104
@ FoundFunctions
This is assumed to be a template name because lookup found one or more functions (but no function tem...
@ FoundNothing
This is assumed to be a template name because lookup found nothing.
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:792
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...
Definition: SemaDecl.cpp:4352
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Definition: SemaExpr.cpp:1969
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
Definition: SemaType.cpp:1580
std::optional< unsigned > getNumArgumentsInExpansionFromUnexpanded(llvm::ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs)
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfMove - Emits a warning if a value is moved to itself.
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
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)
Definition: SemaStmt.cpp:1290
AtomicArgumentOrder
Definition: Sema.h:2250
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:2178
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.
Definition: SemaDecl.cpp:1247
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
Definition: SemaCast.cpp:382
SourceRange getExprRange(Expr *E) const
Definition: SemaExpr.cpp:507
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...
Definition: SemaStmt.cpp:3283
void setExceptionMode(SourceLocation Loc, LangOptions::FPExceptionModeKind)
Called to set exception behavior for floating point operations.
Definition: SemaAttr.cpp:1434
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 PrintPragmaAttributeInstantiationPoint()
Definition: SemaAttr.cpp:1220
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)
Definition: SemaType.cpp:2527
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
Definition: Sema.h:11037
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
Definition: SemaAttr.cpp:167
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Definition: Sema.h:671
bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
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:3081
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:7809
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:14566
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition: Sema.h:4157
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
Definition: SemaDecl.cpp:16850
bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id, bool IsUDSuffix)
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:420
FPOptions & getCurFPFeatures()
Definition: Sema.h:526
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition: Sema.h:7907
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:954
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
Definition: SemaExpr.cpp:20411
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:81
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:2196
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:2328
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14976
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.
Definition: SemaDecl.cpp:19730
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:13888
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition: Sema.h:13908
@ UPPC_RequiresClause
Definition: Sema.h:13959
@ UPPC_UsingDeclaration
A using declaration.
Definition: Sema.h:13914
@ UPPC_IfExists
Microsoft __if_exists.
Definition: Sema.h:13941
@ UPPC_Requirement
Definition: Sema.h:13956
@ UPPC_ExceptionType
The type of an exception.
Definition: Sema.h:13932
@ UPPC_EnumeratorValue
The enumerator value.
Definition: Sema.h:13911
@ UPPC_Lambda
Lambda expression.
Definition: Sema.h:13947
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition: Sema.h:13944
@ UPPC_PartialSpecialization
Partial specialization.
Definition: Sema.h:13938
@ UPPC_Initializer
An initializer.
Definition: Sema.h:13923
@ UPPC_BaseType
The base type of a class type.
Definition: Sema.h:13893
@ UPPC_FriendDeclaration
A friend declaration.
Definition: Sema.h:13917
@ UPPC_DefaultArgument
A default argument.
Definition: Sema.h:13926
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition: Sema.h:13896
@ UPPC_Expression
An arbitrary expression.
Definition: Sema.h:13890
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition: Sema.h:13935
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition: Sema.h:13920
@ UPPC_DataMemberType
The type of a data member.
Definition: Sema.h:13899
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition: Sema.h:13905
@ UPPC_Block
Block expression.
Definition: Sema.h:13950
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition: Sema.h:13902
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition: Sema.h:13929
@ UPPC_TypeConstraint
A type constraint.
Definition: Sema.h:13953
api_notes::APINotesManager APINotes
Definition: Sema.h:912
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:12141
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.
Definition: SemaLambda.cpp:523
const LangOptions & getLangOpts() const
Definition: Sema.h:524
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.
Definition: SemaType.cpp:9057
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?
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
StmtResult ActOnFinishFullStmt(Stmt *Stmt)
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, QualType ConstrainedType, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
SmallVector< VTableUse, 16 > VTableUses
The list of vtables that are required but have not yet been materialized.
Definition: Sema.h:5389
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
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)
Definition: SemaStmt.cpp:1764
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12194
SourceLocation CurInitSegLoc
Definition: Sema.h:1690
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
Definition: SemaExpr.cpp:7292
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition: SemaAttr.cpp:721
SemaCodeCompletion & CodeCompletion()
Definition: Sema.h:1065
void inferLifetimeBoundAttribute(FunctionDecl *FD)
Add [[clang:::lifetimebound]] attr for std:: functions and methods.
Definition: SemaAttr.cpp:219
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
Definition: Sema.h:3102
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:1115
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition: Sema.h:14340
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
Definition: SemaDecl.cpp:1388
ReuseLambdaContextDecl_t
Definition: Sema.h:6524
@ ReuseLambdaContextDecl
Definition: Sema.h:6524
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.
Definition: SemaDecl.cpp:6573
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)
Definition: SemaExpr.cpp:17483
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.
Definition: SemaDecl.cpp:6607
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
Definition: SemaDecl.cpp:1598
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:532
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
Definition: SemaExpr.cpp:2252
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:1060
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.
Definition: SemaExpr.cpp:20049
void * OpaqueParser
Definition: Sema.h:952
Preprocessor & PP
Definition: Sema.h:907
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:10939
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
Definition: SemaExpr.cpp:5710
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
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.
Definition: SemaExpr.cpp:6475
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9729
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)
Definition: SemaExpr.cpp:14131
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
Definition: Sema.h:1737
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)
Definition: SemaExpr.cpp:16776
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
Definition: SemaExpr.cpp:4711
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:945
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:1715
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
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 ...
Definition: SemaDecl.cpp:8239
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:1978
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.
Definition: SemaExpr.cpp:7533
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:3089
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:6027
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:1100
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< const Expr * > ConstraintExprs, 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:14368
const LangOptions & LangOpts
Definition: Sema.h:906
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 ...
void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ActOnCXXExitDeclaratorScope - Called when a declarator that previously invoked ActOnCXXEnterDeclarato...
std::pair< Expr *, std::string > findFailedBooleanCondition(Expr *Cond)
Find the failed Boolean condition within a given Boolean constant expression, and describe it with a ...
bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, AllocationFunctionScope NewScope, AllocationFunctionScope DeleteScope, QualType AllocType, bool IsArray, bool &PassAlignment, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete, bool Diagnose=true)
Finds the overloads of operator new and delete that are appropriate for the allocation.
ExprResult PerformQualificationConversion(Expr *E, QualType Ty, ExprValueKind VK=VK_PRValue, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
Definition: SemaInit.cpp:7565
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
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)
Definition: SemaExpr.cpp:15929
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:844
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:8441
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2404
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.
Definition: SemaExpr.cpp:6732
static const uint64_t MaximumAlignment
Definition: Sema.h:839
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition: Sema.h:8665
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.
Definition: SemaExpr.cpp:17504
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
Definition: SemaInit.cpp:7547
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
void ActOnStartOfCompoundStmt(bool IsStmtExpr)
Definition: SemaStmt.cpp:431
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
Definition: Sema.h:14989
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
Definition: SemaDecl.cpp:15352
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:6029
SemaHLSL & HLSL()
Definition: Sema.h:1075
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:11053
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:842
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:8975
bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange, const sema::Capture &From)
Diagnose if an explicit lambda capture is unused.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind)
Definition: Sema.cpp:1104
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Definition: SemaDecl.cpp:1830
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
Definition: SemaDecl.cpp:11912
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.
Definition: SemaDecl.cpp:18485
ExpressionEvaluationContextRecord & currentEvaluationContext()
Definition: Sema.h:6446
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
Definition: SemaExpr.cpp:17468
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:1427
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
SemaMIPS & MIPS()
Definition: Sema.h:1095
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition: Sema.cpp:115
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
SemaRISCV & RISCV()
Definition: Sema.h:1140
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:15153
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition: Sema.h:1404
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:5395
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....
Definition: SemaStmt.cpp:3671
QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions, IdentifierInfo *Id, bool DirectInit, Expr *&Init)
Definition: SemaLambda.cpp:784
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
Definition: SemaExpr.cpp:205
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:4785
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
@ DefaultedOperator
A defaulted 'operator<=>' needed the comparison category.
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Definition: Sema.h:13523
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition: Sema.h:6022
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:73
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.
Definition: SemaExpr.cpp:20059
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.
Definition: SemaExpr.cpp:9857
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:14561
SemaSwift & Swift()
Definition: Sema.h:1150
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...
Definition: SemaAttr.cpp:1312
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
Definition: SemaStmt.cpp:3664
PragmaStack< AlignPackInfo > AlignPackStack
Definition: Sema.h:1639
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used,...
Definition: SemaDecl.cpp:15834
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:6121
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:6473
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:13179
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:6055
StmtResult ActOnExprStmtError()
Definition: SemaStmt.cpp:66
AcceptableKind
Definition: Sema.h:8971
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:1649
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...
Definition: SemaStmt.cpp:3361
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)
Definition: SemaType.cpp:8985
DeclContext * getCurLexicalContext() const
Definition: Sema.h:735
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition: Sema.h:963
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:1693
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:1580
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
Definition: SemaType.cpp:9531
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)
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.
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)
Definition: SemaType.cpp:8119
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:860
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
Definition: SemaStmt.cpp:71
OpenCLOptions OpenCLFeatures
Definition: Sema.h:903
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:13527
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Definition: SemaExpr.cpp:936
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...
Definition: SemaDecl.cpp:16926
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
Definition: Sema.h:1740
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
void ExitDeclaratorContext(Scope *S)
Definition: SemaDecl.cpp:1375
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
Definition: SemaExpr.cpp:15740
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...
Definition: SemaDecl.cpp:8386
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition: Sema.cpp:782
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
Definition: SemaStmt.cpp:4457
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)
Definition: SemaCast.cpp:3351
DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc)
The parser has processed a global-module-fragment declaration that begins the definition of the globa...
Definition: SemaModule.cpp:162
bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted)
void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams)
Definition: SemaStmt.cpp:4525
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Definition: SemaDecl.cpp:12532
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition: Sema.h:14555
ProcessingContextState ParsingClassState
Definition: Sema.h:6073
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.
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val)
Definition: SemaDecl.cpp:19756
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:939
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:2323
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Definition: SemaDecl.cpp:14909
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Definition: SemaDecl.cpp:2287
FunctionTemplateDecl * getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1, QualType RawObj1Ty={}, QualType RawObj2Ty={}, bool Reversed=false)
Returns the more specialized function template according to the rules of function template partial or...
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
Definition: SemaDecl.cpp:2262
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:2757
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
Definition: SemaExpr.cpp:3638
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
Definition: SemaType.cpp:1856
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it's plausible that E was intended to be a template-name.
Definition: Sema.h:3382
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:2228
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Definition: SemaDecl.cpp:20314
std::optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
Definition: SemaExpr.cpp:10406
bool CheckNontrivialField(FieldDecl *FD)
Definition: SemaDecl.cpp:18683
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
Helper for delayed processing TransparentUnion or BPFPreserveAccessIndexAttr attribute.
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.
Definition: SemaExpr.cpp:9628
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...
Definition: SemaStmt.cpp:1708
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition: Sema.h:6470
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
Definition: SemaAttr.cpp:1324
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...
CXXRecordDecl * getCurrentInstantiationOf(NestedNameSpecifier *NNS)
If the given nested name specifier refers to the current instantiation, return the declaration that c...
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
Definition: SemaDecl.cpp:18165
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:2142
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)
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:12648
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
Definition: SemaInit.cpp:9788
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:4416
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.
Definition: SemaDecl.cpp:8914
void LateTemplateParserCleanupCB(void *P)
Definition: Sema.h:949
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:5385
void MarkThisReferenced(CXXThisExpr *This)
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, ArrayRef< const Expr * > AC1, NamedDecl *D2, ArrayRef< const Expr * > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
std::optional< unsigned > getFullyPackExpandedSize(TemplateArgument Arg)
Given a template argument that contains an unexpanded parameter pack, but which has already been subs...
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:640
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:13187
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)
Definition: SemaExpr.cpp:3189
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:14983
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition: Sema.h:7778
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:1689
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Definition: SemaDecl.cpp:20344
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition: Sema.h:9581
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,...
Definition: SemaDecl.cpp:8934
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.
Definition: SemaExpr.cpp:7279
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:2077
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 *.
Definition: SemaExpr.cpp:1639
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...
Definition: SemaExpr.cpp:16291
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
Definition: SemaExpr.cpp:7669
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)
Definition: SemaDecl.cpp:15458
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:2359
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
Definition: Sema.h:6485
IfExistsResult CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo)
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
std::unique_ptr< RecordDeclSetTy > PureVirtualClassDiagSet
PureVirtualClassDiagSet - a set of class declarations which we have emitted a list of pure virtual fu...
Definition: Sema.h:6036
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...
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
Definition: SemaDecl.cpp:18156
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
Definition: SemaDecl.cpp:15382
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:1043
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, bool Diagnose=true, bool WantSize=false, bool WantAligned=false)
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
Definition: SemaInit.cpp:7530
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.
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
Definition: Sema.h:9058
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
Definition: SemaExpr.cpp:20874
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:273
DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc, SourceLocation PrivateLoc)
The parser has processed a private-module-fragment declaration that begins the definition of the priv...
Definition: SemaModule.cpp:511
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
Definition: SemaDecl.cpp:14949
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition: Sema.h:12142
@ VAK_Invalid
Definition: Sema.h:7533
@ VAK_Valid
Definition: Sema.h:7529
@ VAK_ValidInCXX11
Definition: Sema.h:7530
@ VAK_MSVCUndefined
Definition: Sema.h:7532
@ VAK_Undefined
Definition: Sema.h:7531
SemaOpenCL & OpenCL()
Definition: Sema.h:1120
void ActOnPragmaMSFunction(SourceLocation Loc, const llvm::SmallVectorImpl< StringRef > &NoBuiltins)
Call on well formed #pragma function.
Definition: SemaAttr.cpp:1258
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
Definition: SemaDecl.cpp:5787
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:13536
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)
Definition: SemaType.cpp:9765
void ActOnPragmaMSStruct(PragmaMSStructKind Kind)
ActOnPragmaMSStruct - Called on well formed #pragma ms_struct [on|off].
Definition: SemaAttr.cpp:613
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
Definition: SemaExpr.cpp:16658
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition: Sema.h:1829
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
Definition: SemaDecl.cpp:15219
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
Definition: SemaType.cpp:3773
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:887
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:14571
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...
Definition: SemaExpr.cpp:7915
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)
TrivialABIHandling
Definition: Sema.h:5868
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:5870
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition: Sema.h:5873
FormatArgumentPassingKind
Definition: Sema.h:2152
@ FAPK_Fixed
Definition: Sema.h:2153
@ FAPK_Variadic
Definition: Sema.h:2154
@ FAPK_VAList
Definition: Sema.h:2155
void FillInlineAsmIdentifierInfo(Expr *Res, llvm::InlineAsmIdentifierInfo &Info)
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.
Definition: SemaExpr.cpp:20110
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:7770
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:12639
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition: Sema.cpp:1548
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, NamedReturnInfo &NRInfo, bool SupressSimplerImplicitMoves)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes.
Definition: SemaStmt.cpp:3458
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...
llvm::SmallVector< TypoExpr *, 2 > TypoExprs
Holds TypoExprs that are created from createDelayedTypo.
Definition: Sema.h:8969
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition: Sema.h:7573
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition: Sema.h:7617
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition: Sema.h:7583
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:7641
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:7646
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition: Sema.h:7633
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:7612
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition: Sema.h:7591
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition: Sema.h:7650
@ Compatible
Compatible - the types are compatible according to the standard.
Definition: Sema.h:7575
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition: Sema.h:7602
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition: Sema.h:7654
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:7587
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition: Sema.h:7596
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:7608
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition: Sema.h:7629
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition: Sema.h:7623
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition: Sema.h:7579
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:7637
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).
void MarkVirtualBaseDestructorsReferenced(SourceLocation Location, CXXRecordDecl *ClassDecl, llvm::SmallPtrSetImpl< const RecordType * > *DirectVirtualBases=nullptr)
Mark destructors of virtual bases of this class referenced.
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.
Definition: SemaDecl.cpp:8427
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1289
StmtResult ActOnCapturedRegionEnd(Stmt *S)
Definition: SemaStmt.cpp:4629
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition: Sema.h:7392
@ ACK_Arithmetic
An arithmetic operation.
Definition: Sema.h:7394
@ ACK_CompAssign
A compound assignment expression.
Definition: Sema.h:7402
@ ACK_BitwiseOp
A bitwise operation.
Definition: Sema.h:7396
@ ACK_Conditional
A conditional (?:) operator.
Definition: Sema.h:7400
@ ACK_Comparison
A comparison.
Definition: Sema.h:7398
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
Definition: SemaDecl.cpp:4707
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
Definition: SemaExpr.cpp:20008
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
Definition: SemaDecl.cpp:15809
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:14996
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...
Definition: SemaType.cpp:9580
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...
Definition: SemaExpr.cpp:2896
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)
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:2209
bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result)
BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr TheCall is a constant expression.
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
Definition: SemaStmt.cpp:3186
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
Definition: Sema.h:7966
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)
Definition: SemaExpr.cpp:4109
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16743
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:3099
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition: Sema.h:6282
bool MSStructPragmaOn
Definition: Sema.h:1401
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:20964
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Definition: SemaType.cpp:9190
ExprResult TransformToPotentiallyEvaluated(Expr *E)
Definition: SemaExpr.cpp:17367
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
unsigned ActOnReenterTemplateScope(Decl *Template, llvm::function_ref< Scope *()> EnterScope)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore,...
Definition: Sema.h:13163
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
Definition: SemaDecl.cpp:15858
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.
Definition: SemaDecl.cpp:11018
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:13483
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:3835
@ NTK_Typedef
Definition: Sema.h:3840
@ NTK_NonUnion
Definition: Sema.h:3838
@ NTK_TypeAlias
Definition: Sema.h:3841
@ NTK_NonClass
Definition: Sema.h:3837
@ NTK_NonEnum
Definition: Sema.h:3839
@ NTK_NonStruct
Definition: Sema.h:3836
@ NTK_TemplateTemplateArgument
Definition: Sema.h:3844
@ NTK_TypeAliasTemplate
Definition: Sema.h:3843
@ NTK_Template
Definition: Sema.h:3842
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition: Sema.h:14971
SourceManager & getSourceManager() const
Definition: Sema.h:529
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
Definition: SemaModule.cpp:734
TryCaptureKind
Definition: Sema.h:6586
@ TryCapture_Implicit
Definition: Sema.h:6587
@ TryCapture_ExplicitByVal
Definition: Sema.h:6588
@ TryCapture_ExplicitByRef
Definition: Sema.h:6589
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9781
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition: Sema.h:8037
FunctionDecl * SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD, FunctionDecl *Spaceship)
Substitute the name and return type of a defaulted 'operator<=>' to form an implicit 'operator=='.
CallingConventionIgnoredReason
Describes the reason a calling convention specification was ignored, used for diagnostics.
Definition: Sema.h:4394
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.
Definition: SemaExpr.cpp:6710
bool CheckVecStepExpr(Expr *E)
Definition: SemaExpr.cpp:4390
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
Definition: Sema.cpp:567
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:3052
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.
Definition: SemaDecl.cpp:4277
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:879
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
Definition: SemaDecl.cpp:20011
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 ...
Definition: SemaDecl.cpp:1340
void diagnoseFunctionEffectConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn when implicitly changing function effects.
Definition: Sema.cpp:630
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:11885
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.
Definition: SemaDecl.cpp:11193
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.
Definition: SemaStmt.cpp:3418
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 ?: operation.
Definition: SemaExpr.cpp:8776
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
Definition: SemaExpr.cpp:12738
ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
bool BuiltinElementwiseTernaryMath(CallExpr *TheCall, bool CheckForFloatArgs=true)
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...
Definition: SemaLambda.cpp:545
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
Definition: SemaExpr.cpp:10581
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)
Get the specialization of the given variable template corresponding to the specified argument list,...
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Definition: Sema.h:8963
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
Definition: SemaExpr.cpp:19624
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Definition: SemaType.cpp:9685
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13718
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
Definition: SemaAttr.cpp:547
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....
Definition: SemaDecl.cpp:18142
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.
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 AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors.
Definition: Sema.h:12074
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...
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:1428
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
CallExpr::ADLCallKind ADLCallKind
Definition: Sema.h:6978
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:3645
@ NTCUK_Destruct
Definition: Sema.h:3647
@ NTCUK_Init
Definition: Sema.h:3646
@ NTCUK_Copy
Definition: Sema.h:3648
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
DelayedDiagnosticsState ProcessingContextState
Definition: Sema.h:980
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.
Definition: SemaAttr.cpp:1391
QualType BuildAtomicType(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:9968
std::vector< std::pair< QualType, unsigned > > ExcessPrecisionNotSatisfied
Definition: Sema.h:7923
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:1425
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Definition: SemaExpr.cpp:20245
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Definition: SemaDecl.cpp:15886
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
Definition: SemaExpr.cpp:5487
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...
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:8759
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
Definition: SemaDecl.cpp:13903
bool anyAltivecTypes(QualType srcType, QualType destType)
Definition: SemaExpr.cpp:7563
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?
Definition: SemaExpr.cpp:7600
void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc)
PushNamespaceVisibilityAttr - Note that we've entered a namespace with a visibility attribute.
Definition: SemaAttr.cpp:1471
ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc)
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
Definition: SemaDecl.cpp:1228
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.
Definition: SemaStmt.cpp:2379
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition: Sema.cpp:2190
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.
bool IsAtLeastAsConstrained(NamedDecl *D1, MutableArrayRef< const Expr * > AC1, NamedDecl *D2, MutableArrayRef< const Expr * > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
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.
Definition: SemaDecl.cpp:20287
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:1638
TypeSourceInfo * ReplaceAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
Definition: SemaAttr.cpp:89
QualType CXXCheckConditionalOperands(ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc)
Check the operands of ?: under C++ semantics.
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)
Definition: SemaType.cpp:6413
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
MaybeODRUseExprSet MaybeODRUseExprs
Definition: Sema.h:6280
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:534
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:852
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:1696
SourceLocation getTopMostPointOfInstantiation(const NamedDecl *) const
Returns the top most location responsible for the definition of N.
bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum, unsigned ArgBits)
BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of TheCall is a constant expression re...
QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, bool ConvertArgs=true)
Definition: Sema.h:8396
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:216
static SourceRange getPrintable(SourceRange R)
Definition: Sema.h:14568
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)
Definition: SemaDecl.cpp:20271
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.
Definition: SemaDecl.cpp:8262
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.
Definition: SemaExprCXX.cpp:59
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....
Definition: SemaExpr.cpp:2048
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
void PushSatisfactionStackEntry(const NamedDecl *D, const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:14305
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)
Definition: SemaStmt.cpp:3837
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition: Sema.h:14938
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition: Sema.h:741
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
Binary Operators. 'Tok' is the token for the operator.
Definition: SemaExpr.cpp:15271
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
Definition: Sema.cpp:2719
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:1874
void setFunctionHasMustTail()
Definition: Sema.cpp:2354
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)
Definition: SemaExpr.cpp:7702
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:7962
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
CorrectTypoKind
Definition: Sema.h:9375
@ CTK_NonError
Definition: Sema.h:9376
@ CTK_ErrorRecovery
Definition: Sema.h:9377
void CheckCompleteVariableDeclaration(VarDecl *VD)
Definition: SemaDecl.cpp:14313
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
Definition: SemaInit.cpp:3459
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
TUFragmentKind
Definition: Sema.h:612
@ Global
The global module fragment, between 'module;' and a module-declaration.
Definition: Sema.h:614
@ Private
The private module fragment, between 'module :private;' and the end of the translation unit.
Definition: Sema.h:621
@ Normal
A normal translation unit fragment.
Definition: Sema.h:618
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
void PopSatisfactionStackEntry()
Definition: Sema.h:14311
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
Definition: SemaType.cpp:1804
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)
Definition: SemaDecl.cpp:14834
void setFunctionHasBranchProtectedScope()
Definition: Sema.cpp:2344
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition: Sema.h:15017
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
Definition: SemaDecl.cpp:4468
bool isConstantEvaluatedContext() const
Definition: Sema.h:2144
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:6047
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
Definition: SemaStmt.cpp:4415
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:592
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.
std::pair< const NamedDecl *, llvm::FoldingSetNodeID > SatisfactionStackEntryTy
Definition: Sema.h:14321
bool SubstDefaultArgument(SourceLocation Loc, ParmVarDecl *Param, const MultiLevelTemplateArgumentList &TemplateArgs, bool ForCallExpr=false)
Substitute the given template arguments into the default argument.
StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope)
Definition: SemaStmt.cpp:3227
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9748
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
void ActOnStartOfTranslationUnit()
This is called before the very first declaration in the translation unit is parsed.
Definition: Sema.cpp:1098
CCEKind
Contexts in which a converted constant expression is required.
Definition: Sema.h:9991
@ CCEK_StaticAssertMessageSize
Call to size() in a static assert message.
Definition: Sema.h:9998
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
Definition: Sema.h:9996
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
Definition: Sema.h:9997
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:9995
@ CCEK_CaseValue
Expression in a case label.
Definition: Sema.h:9992
@ CCEK_TemplateArg
Value of a non-type template parameter.
Definition: Sema.h:9994
@ CCEK_StaticAssertMessageData
Call to data() in a static assert message.
Definition: Sema.h:10000
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
Definition: Sema.h:9993
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.
Definition: SemaStmt.cpp:2637
ExprResult ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, SourceRange Range)
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
Definition: SemaStmt.cpp:1785
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.
Definition: SemaDecl.cpp:18746
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:10914
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:1166
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
Definition: SemaDecl.cpp:3083
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
Definition: SemaDecl.cpp:1893
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition: Sema.h:3073
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:286
ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Definition: SemaDecl.cpp:19542
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
Definition: Sema.h:1171
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
Definition: SemaDecl.cpp:12567
ASTConsumer & Consumer
Definition: Sema.h:909
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:4220
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
OverloadKind
Definition: Sema.h:9769
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
Definition: Sema.h:9780
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:9772
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:9776
PragmaAlignPackDiagnoseKind
Definition: Sema.h:1807
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:6477
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
Definition: SemaExpr.cpp:121
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
Definition: SemaDecl.cpp:2050
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:944
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
Definition: Sema.cpp:1684
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition: Sema.h:13519
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Definition: SemaExpr.cpp:5120
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...
Definition: SemaType.cpp:7407
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:9608
@ PrivateFragmentImportFinished
after 'module :private;' but a non-import decl has already been seen.
@ ImportFinished
after any non-import decl.
@ PrivateFragmentImportAllowed
after 'module :private;' but before any non-import decl.
@ FirstDecl
Parsing the first decl in a TU.
@ GlobalFragment
after 'module;' but before 'module X;'
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
@ ImportAllowed
after 'module X;' but before any non-import decl.
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:14567
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Definition: SemaExpr.cpp:3534
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData)
Definition: SemaExpr.cpp:16784
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
Definition: SemaExpr.cpp:12683
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition: Sema.cpp:85
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
Definition: SemaStmt.cpp:4445
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition: Sema.h:873
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.
Definition: SemaExpr.cpp:8403
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
Definition: SemaDecl.cpp:16547
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition: Sema.h:6224
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ DiscardedStatement
The current expression occurs within a discarded statement.
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
Definition: SemaCast.cpp:2050
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...
Definition: SemaType.cpp:9653
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
Definition: Sema.h:13171
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)
Definition: SemaType.cpp:9912
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition: Sema.h:4379
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
Definition: Sema.h:4385
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition: Sema.h:4389
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition: Sema.h:4382
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition: Sema.h:4036
@ AMK_None
Don't merge availability attributes at all.
Definition: Sema.h:4038
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition: Sema.h:4044
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:4047
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition: Sema.h:4050
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition: Sema.h:4041
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
Definition: SemaDecl.cpp:14953
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Parse a __builtin_astype expression.
Definition: SemaExpr.cpp:6703
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4395
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
Definition: SemaExpr.cpp:4617
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
Definition: SemaType.cpp:5703
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
Definition: SemaDecl.cpp:14620
ExprResult BuildOperatorCoawaitLookupExpr(Scope *S, SourceLocation Loc)
std::pair< SourceLocation, bool > DeleteExprLoc
Definition: Sema.h:572
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.
Definition: SemaExpr.cpp:20252
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
Definition: SemaExpr.cpp:4227
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 {'.
Definition: SemaDecl.cpp:17135
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....
Definition: SemaDecl.cpp:4785
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
SemaPPC & PPC()
Definition: Sema.h:1130
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:2203
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16495
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:435
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
Definition: SemaType.cpp:5816
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition: SemaStmt.cpp:76
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
Definition: Sema.h:4453
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:9068
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Definition: SemaDecl.cpp:15304
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:871
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)
Definition: SemaDecl.cpp:1336
void DiagnoseUnterminatedPragmaAttribute()
Definition: SemaAttr.cpp:1236
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
Definition: SemaAttr.cpp:1343
bool SatisfactionStackContains(const NamedDecl *D, const llvm::FoldingSetNodeID &ID) const
Definition: Sema.h:14313
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
Definition: SemaExpr.cpp:20894
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:950
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)
Definition: SemaDecl.cpp:18992
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.
Definition: SemaExpr.cpp:19256
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Definition: SemaExpr.cpp:7737
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC #pragma optimize in scope,...
Definition: SemaAttr.cpp:1291
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, const DefaultArguments &DefaultArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr, bool PartialOrderingTTP=false)
Check that the given template arguments can be provided to the given template, converting the argumen...
void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc)
PopPragmaVisibility - Pop the top element of the visibility stack; used for '#pragma GCC visibility' ...
Definition: SemaAttr.cpp:1480
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Delete-expressions to be analyzed at the end of translation unit.
Definition: Sema.h:7973
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
Definition: SemaDecl.cpp:11042
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:3092
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition: Sema.h:9748
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
Definition: SemaInit.cpp:7403
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:7760
SemaSystemZ & SystemZ()
Definition: Sema.h:1155
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition: Sema.cpp:99
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr)
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:2741
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
Definition: SemaExpr.cpp:17897
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9793
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
Definition: SemaExpr.cpp:19248
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:7910
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
Definition: SemaDecl.cpp:1308
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
Definition: SemaExpr.cpp:7649
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:9594
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
Definition: SemaType.cpp:9043
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
Definition: SemaStmt.cpp:659
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9819
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition: Sema.h:911
TemplateNameIsRequiredTag
Definition: Sema.h:11081
@ TemplateNameIsRequired
Definition: Sema.h:11081
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
Definition: SemaExpr.cpp:4703
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
Definition: SemaExpr.cpp:7810
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.
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.
Definition: SemaDecl.cpp:5740
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:433
static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD)
Definition: SemaDecl.cpp:15943
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:6040
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.
Definition: SemaExpr.cpp:2393
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Definition: Sema.h:9060
DiagnosticsEngine & Diags
Definition: Sema.h:910
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
Definition: SemaLambda.cpp:973
void DiagnoseUnterminatedPragmaAlignPack()
Definition: SemaAttr.cpp:586
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope)
Definition: SemaStmt.cpp:3254
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:7294
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:525
FPOptions CurFPFeatures
Definition: Sema.h:904
void ActOnStartSEHFinallyBlock()
Definition: SemaStmt.cpp:4407
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
static bool CanBeGetReturnObject(const FunctionDecl *FD)
Definition: SemaDecl.cpp:15939
NamespaceDecl * getStdNamespace() const
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9757
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition: Sema.h:6031
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
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)
Definition: SemaDecl.cpp:6630
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
Definition: SemaType.cpp:2047
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
Definition: SemaExpr.cpp:516
PragmaStack< StringLiteral * > DataSegStack
Definition: Sema.h:1648
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
Definition: SemaLambda.cpp:691
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:951
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector,...
Definition: SemaExpr.cpp:7586
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Definition: SemaInit.cpp:9718
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Definition: SemaDecl.cpp:7253
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:2780
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
Definition: SemaDecl.cpp:14984
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:11270
@ TPC_ClassTemplate
Definition: Sema.h:11271
@ TPC_FriendFunctionTemplate
Definition: Sema.h:11276
@ TPC_ClassTemplateMember
Definition: Sema.h:11274
@ TPC_FunctionTemplate
Definition: Sema.h:11273
@ TPC_FriendClassTemplate
Definition: Sema.h:11275
@ TPC_FriendFunctionTemplateDefinition
Definition: Sema.h:11277
@ TPC_TypeAliasTemplate
Definition: Sema.h:11278
@ TPC_VarTemplate
Definition: Sema.h:11272
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
Definition: SemaAttr.cpp:1357
void ActOnAbortSEHFinallyBlock()
Definition: SemaStmt.cpp:4411
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,...
Definition: SemaDecl.cpp:6714
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
Definition: SemaDecl.cpp:16402
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:1783
ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val)
Definition: SemaExpr.cpp:3598
SemaAVR & AVR()
Definition: Sema.h:1055
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:13641
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5581
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
bool checkTargetClonesAttrString(SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal, Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault, SmallVectorImpl< SmallString< 64 > > &StringsBuffer)
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition,...
Definition: SemaExpr.cpp:20295
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:1724
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)
Definition: SemaDecl.cpp:2068
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
friend class ArgumentPackSubstitutionRAII
Definition: Sema.h:13208
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.
Definition: SemaType.cpp:1931
void PopDeclContext()
Definition: SemaDecl.cpp:1315
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)
void diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, SourceLocation FallbackLoc, SourceLocation ConstQualLoc=SourceLocation(), SourceLocation VolatileQualLoc=SourceLocation(), SourceLocation RestrictQualLoc=SourceLocation(), SourceLocation AtomicQualLoc=SourceLocation(), SourceLocation UnalignedQualLoc=SourceLocation())
Definition: SemaType.cpp:2870
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13094
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:6059
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition: Sema.h:13138
void PrintStats() const
Print out statistics about the semantic analysis.
Definition: Sema.cpp:606
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
Definition: SemaExpr.cpp:15854
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:14558
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...
Definition: SemaExpr.cpp:997
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,...
Definition: SemaExpr.cpp:6074
FormatStringType
Definition: Sema.h:2181
@ FST_NSString
Definition: Sema.h:2184
@ FST_Syslog
Definition: Sema.h:2191
@ FST_Unknown
Definition: Sema.h:2192
@ FST_Strftime
Definition: Sema.h:2185
@ FST_Printf
Definition: Sema.h:2183
@ FST_FreeBSDKPrintf
Definition: Sema.h:2188
@ FST_Scanf
Definition: Sema.h:2182
@ FST_Strfmon
Definition: Sema.h:2186
@ FST_OSLog
Definition: Sema.h:2190
@ FST_Kprintf
Definition: Sema.h:2187
@ FST_OSTrace
Definition: Sema.h:2189
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:1399
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.
Definition: SemaDecl.cpp:1579
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)
Definition: SemaExpr.cpp:12799
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:857
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.
Definition: SemaType.cpp:1935
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...
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:10745
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition: Sema.h:10753
@ BFRK_Build
Initial building of a for-range statement.
Definition: Sema.h:10747
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:10750
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
Definition: SemaExpr.cpp:8879
SemaNVPTX & NVPTX()
Definition: Sema.h:1105
bool resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name, SourceLocation NameLoc, bool Diagnose=true)
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...
Definition: SemaStmt.cpp:4124
void ActOnPragmaMSStrictGuardStackCheck(SourceLocation PragmaLocation, PragmaMsStackAction Action, bool Value)
ActOnPragmaMSStrictGuardStackCheck - Called on well formed #pragma strict_gs_check.
Definition: SemaAttr.cpp:871
void ActOnUninitializedDecl(Decl *dcl)
Definition: SemaDecl.cpp:13945
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
Definition: SemaDecl.cpp:13113
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
Definition: SemaDecl.cpp:1564
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
Definition: SemaDecl.cpp:16794
bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res, bool FPOnly=false)
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)
Definition: SemaType.cpp:9667
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:583
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
Definition: SemaExpr.cpp:16301
OffsetOfKind
Definition: Sema.h:3859
@ OOK_Outside
Definition: Sema.h:3861
@ OOK_Macro
Definition: Sema.h:3866
@ OOK_Builtin
Definition: Sema.h:3863
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
Definition: SemaDecl.cpp:13386
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
Definition: SemaType.cpp:9540
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
PragmaSectionKind
Definition: Sema.h:1668
@ PSK_ConstSeg
Definition: Sema.h:1671
@ PSK_DataSeg
Definition: Sema.h:1669
@ PSK_CodeSeg
Definition: Sema.h:1672
@ PSK_BSSSeg
Definition: Sema.h:1670
TemplateDeductionResult FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, SmallVectorImpl< OriginalCallArg > const *OriginalCallArgs=nullptr, bool PartialOverloading=false, llvm::function_ref< bool()> CheckNonDependent=[] { return false;})
Finish template argument deduction for a function template, checking the deduced template arguments f...
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)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
Definition: Sema.cpp:562
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Definition: SemaExpr.cpp:20030
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Definition: Sema.cpp:592
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition: SemaCast.cpp:296
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...
Definition: SemaExpr.cpp:16812
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:5802
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...
Definition: SemaDecl.cpp:18382
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,...
Definition: SemaExpr.cpp:18078
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
Definition: SemaExpr.cpp:15898
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)
Definition: SemaExpr.cpp:4756
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
Definition: SemaDecl.cpp:4313
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)
Definition: SemaDecl.cpp:14230
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
Definition: SemaExpr.cpp:5953
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
Definition: SemaLambda.cpp:282
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
Definition: SemaType.cpp:2446
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
Definition: SemaExpr.cpp:20351
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:3067
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition: Sema.cpp:1961
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
Definition: SemaExpr.cpp:21161
bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis=false)
Check if IdxExpr is a valid parameter index for a function or instance method D.
Definition: Sema.h:4696
void CompleteLambdaCallOperator(CXXMethodDecl *Method, SourceLocation LambdaLoc, SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause, TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind, StorageClass SC, ArrayRef< ParmVarDecl * > Params, bool HasExplicitResultType)
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
Definition: SemaType.cpp:9097
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15345
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:1424
Decl * ActOnDeclarator(Scope *S, Declarator &D)
Definition: SemaDecl.cpp:6049
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3672
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
Definition: Sema.h:967
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *AArg, const DefaultArguments &DefaultArgs, SourceLocation Loc, bool IsDeduced)
AbstractDiagSelID
Definition: Sema.h:5748
@ AbstractSynthesizedIvarType
Definition: Sema.h:5755
@ AbstractVariableType
Definition: Sema.h:5752
@ AbstractReturnType
Definition: Sema.h:5750
@ AbstractNone
Definition: Sema.h:5749
@ AbstractFieldType
Definition: Sema.h:5753
@ AbstractArrayType
Definition: Sema.h:5756
@ AbstractParamType
Definition: Sema.h:5751
@ AbstractIvarType
Definition: Sema.h:5754
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:2969
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:953
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 BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High, bool RangeIsError=true)
BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr TheCall is a constant express...
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)
Definition: SemaExpr.cpp:7254
PragmaOptionsAlignKind
Definition: Sema.h:1777
@ POAK_Power
Definition: Sema.h:1781
@ POAK_Reset
Definition: Sema.h:1783
@ POAK_Packed
Definition: Sema.h:1780
@ POAK_Mac68k
Definition: Sema.h:1782
@ POAK_Natural
Definition: Sema.h:1779
@ POAK_Native
Definition: Sema.h:1778
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:16153
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
void CheckAlignasUnderalignment(Decl *D)
ParsedType getConstructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext)
Definition: SemaExprCXX.cpp:93
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
Definition: SemaExpr.cpp:4829
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.
Definition: SemaDecl.cpp:1703
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition: Sema.h:7959
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.
Definition: SemaDecl.cpp:1237
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
Definition: SemaExpr.cpp:14768
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.
Definition: SemaLambda.cpp:541
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9886
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
Definition: SemaExpr.cpp:9154
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 ...
Definition: SemaAttr.cpp:1372
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.
Definition: SemaType.cpp:8133
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc)
Called on well formed #pragma clang optimize.
Definition: SemaAttr.cpp:1242
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.
Definition: SemaExpr.cpp:6437
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...
Definition: SemaExpr.cpp:4686
QualType PreferredConditionType(ConditionKind K) const
Definition: Sema.h:7490
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.
void clearDelayedTypo(TypoExpr *TE)
Clears the state of the given TypoExpr.
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
Definition: Sema.h:9032
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition: Sema.h:9036
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition: Sema.h:9042
@ LOLR_Error
The lookup resulted in an error.
Definition: Sema.h:9034
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:9039
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition: Sema.h:9050
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:9046
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Definition: SemaDecl.cpp:20326
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition: Sema.cpp:2374
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition: Sema.h:6458
SemaLoongArch & LoongArch()
Definition: Sema.h:1085
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Definition: SemaExpr.cpp:16182
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:10620
CheckConstexprKind
Definition: Sema.h:5944
@ CheckValid
Identify whether this function satisfies the formal rules for constexpr functions in the current lanu...
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
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:13515
void CheckVariableDeclarationType(VarDecl *NewVD)
Definition: SemaDecl.cpp:8598
sema::CompoundScopeInfo & getCurCompoundScope() const
Definition: SemaStmt.cpp:447
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:2733
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:900
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
Definition: SemaInit.cpp:9703
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.
Definition: SemaLambda.cpp:393
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
Definition: SemaDecl.cpp:1322
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
Definition: Sema.cpp:642
bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E)
CheckCXXThrowOperand - Validate the operand of a throw.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
Definition: SemaDecl.cpp:13079
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.
Definition: SemaAttr.cpp:1442
bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New)
Definition: SemaDecl.cpp:2435
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)
Definition: SemaType.cpp:2750
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:3048
void ActOnFinishOfCompoundStmt()
Definition: SemaStmt.cpp:443
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:1593
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...
Definition: SemaAttr.cpp:1275
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
Definition: SemaDecl.cpp:15823
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14862
void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
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...
Definition: SemaDecl.cpp:13365
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:11062
static ConditionResult ConditionError()
Definition: Sema.h:7331
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition: SemaStmt.cpp:451
void NoteTemplateParameterLocation(const NamedDecl &Decl)
SemaWasm & Wasm()
Definition: Sema.h:1160
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
Definition: SemaExpr.cpp:6724
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, bool SuppressUserConversions, 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 HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
const NormalizedConstraint * getNormalizedAssociatedConstraints(NamedDecl *ConstrainedDecl, ArrayRef< const Expr * > AssociatedConstraints)
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:2996
bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo, bool EnteringContext)
IsInvalidUnlessNestedName - This method is used for error recovery purposes to determine whether the ...
const TypoExprState & getTypoExprState(TypoExpr *TE) const
llvm::DenseSet< QualType > InstantiatedNonDependentTypes
Non-dependent types used in templates that have already been instantiated by some template instantiat...
Definition: Sema.h:13134
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
Definition: SemaExpr.cpp:20898
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.
Definition: SemaDecl.cpp:19982
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 ...
Definition: SemaExpr.cpp:5813
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
Definition: SemaExpr.cpp:16096
SemaPseudoObject & PseudoObject()
Definition: Sema.h:1135
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:2335
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:608
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition: Sema.h:11046
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...
Definition: SemaStmt.cpp:4244
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:7287
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:681
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...
Definition: SemaDecl.cpp:15193
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
Definition: Sema.h:7918
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:899
static int getPrintable(int I)
Definition: Sema.h:14557
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:882
bool hasReachableDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is reachable.
Definition: Sema.h:9302
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:12480
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition: SemaStmt.cpp:588
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMemberKind CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
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:3368
bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, QualType SrcTy)
Definition: SemaCast.cpp:2713
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)
Definition: SemaExpr.cpp:17905
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:14562
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:1407
@ PCSK_Invalid
Definition: Sema.h:1408
@ PCSK_BSS
Definition: Sema.h:1409
@ PCSK_Data
Definition: Sema.h:1410
@ PCSK_Text
Definition: Sema.h:1412
@ PCSK_Relro
Definition: Sema.h:1413
@ PCSK_Rodata
Definition: Sema.h:1411
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7186
void warnOnReservedIdentifier(const NamedDecl *D)
Definition: SemaDecl.cpp:6036
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition: SemaStmt.cpp:552
bool isCheckingDefaultArgumentOrInitializer() const
Definition: Sema.h:7786
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
Definition: SemaDecl.cpp:16867
SemaARM & ARM()
Definition: Sema.h:1050
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:317
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
static const char * getPrintable(const char *S)
Definition: Sema.h:14560
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.
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
Definition: SemaType.cpp:2681
AllocationFunctionScope
The scope in which to find allocation functions.
Definition: Sema.h:8156
@ AFS_Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition: Sema.h:8164
@ AFS_Class
Only look for allocation functions in the scope of the allocated class.
Definition: Sema.h:8161
@ AFS_Global
Only look for allocation functions in the global scope.
Definition: Sema.h:8158
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.
Definition: SemaExpr.cpp:5332
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:588
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Definition: SemaType.cpp:2733
PragmaMsStackAction
Definition: Sema.h:1430
@ PSK_Push_Set
Definition: Sema.h:1436
@ PSK_Reset
Definition: Sema.h:1431
@ PSK_Pop_Set
Definition: Sema.h:1437
@ PSK_Show
Definition: Sema.h:1435
@ PSK_Pop
Definition: Sema.h:1434
@ PSK_Set
Definition: Sema.h:1432
@ PSK_Push
Definition: Sema.h:1433
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3153
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
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:8261
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
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)
Definition: SemaExpr.cpp:5006
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Definition: SemaDecl.cpp:1264
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,...
Definition: SemaModule.cpp:832
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)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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.
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:84
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:333
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Definition: Diagnostic.h:1102
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3564
Exposes information about the current target.
Definition: TargetInfo.h:220
A convenient class for passing around template argument information.
Definition: TemplateBase.h:632
A template argument list.
Definition: DeclTemplate.h:250
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
Represents a template argument.
Definition: TemplateBase.h:61
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:399
Represents a C++ template name within the type system.
Definition: TemplateName.h:220
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:73
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:4437
The top declaration context.
Definition: Decl.h:84
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition: ASTConcept.h:227
Represents a declaration of a type.
Definition: Decl.h:3370
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:153
A container of type source information.
Definition: Type.h:7902
The base class of the type hierarchy.
Definition: Type.h:1828
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
Definition: Type.cpp:2511
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3514
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3413
Simple class containing the result of Sema::CorrectTypo.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:6837
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:1028
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3203
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3943
A set of unresolved declarations.
Definition: UnresolvedSet.h:62
Represents a C++ using-declaration.
Definition: DeclCXX.h:3530
Represents C++ using-directive.
Definition: DeclCXX.h:3033
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3338
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
Represents a variable declaration or definition.
Definition: Decl.h:882
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: Type.h:4034
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2783
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Definition: Lookup.h:836
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...
Definition: ExprConcepts.h:280
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
Definition: ExprConcepts.h:429
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:168
A requires-expression requirement which queries the existence of a type name or type template special...
Definition: ExprConcepts.h:225
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 UINT_MAX
Definition: limits.h:64
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
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.
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:55
ImplicitTypenameContext
Definition: DeclSpec.h:1886
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
PragmaFPKind
Definition: PragmaKinds.h:38
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:42
@ CPlusPlus
Definition: LangStandard.h:55
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
Definition: Overload.h:869
FunctionEffectMode
Used with attributes/effects with a boolean condition, e.g. nonblocking.
Definition: Sema.h:454
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
Definition: AttrIterator.h:30
CUDAFunctionTarget
Definition: Cuda.h:145
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...
PragmaMSCommentKind
Definition: PragmaKinds.h:14
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition: Specifiers.h:35
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
ArrayRef< std::pair< IdentifierInfo *, SourceLocation > > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
Definition: ModuleLoader.h:32
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:336
InClassInitStyle
In-class initialization styles for non-static data members.
Definition: Specifiers.h:271
CXXConstructionKind
Definition: ExprCXX.h:1538
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:149
BinaryOperatorKind
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
Definition: Overload.h:84
TypeOfKind
The kind of 'typeof' expression we're after.
Definition: Type.h:910
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
Definition: CallGraph.h:204
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:16
StorageClass
Storage classes.
Definition: Specifiers.h:248
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:51
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
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
LambdaCaptureInitKind
Definition: DeclSpec.h:2827
@ CopyInit
[a = b], [a = {b}]
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ AANT_ArgumentIntegerConstant
Definition: ParsedAttr.h:1079
@ Result
The result type of a method or function.
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:3574
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isFunctionOrMethodVariadic(const Decl *D)
Definition: Attr.h:112
TagUseKind
Definition: Sema.h:446
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
Definition: LangOptions.h:36
UnaryOperatorKind
ActionResult< Expr * > ExprResult
Definition: Ownership.h:248
TagTypeKind
The kind of a tag type.
Definition: Type.h:6871
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
Definition: Ownership.h:262
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...
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Definition: DeclTemplate.h:65
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
CastKind
CastKind - The kind of operation required for a conversion.
TranslationUnitKind
Describes the kind of translation unit being processed.
Definition: LangOptions.h:1096
@ TU_Complete
The translation unit is a complete translation unit.
Definition: LangOptions.h:1098
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:1102
ComparisonCategoryType
An enumeration representing the different comparison categories types.
PragmaMSStructKind
Definition: PragmaKinds.h:23
AssignmentAction
Definition: Sema.h:210
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:249
CXXSpecialMemberKind
Kinds of C++ special members.
Definition: Sema.h:422
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
Definition: TemplateKinds.h:20
@ TNK_Var_template
The name refers to a variable template whose specialization produces a variable.
Definition: TemplateKinds.h:33
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
Definition: TemplateKinds.h:30
@ TNK_Function_template
The name refers to a function template or a set of overloaded functions that includes at least one fu...
Definition: TemplateKinds.h:26
@ TNK_Concept_template
The name refers to a concept.
Definition: TemplateKinds.h:52
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
Definition: TemplateKinds.h:50
ActionResult< ParsedType > TypeResult
Definition: Ownership.h:250
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
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition: Ownership.h:229
const FunctionProtoType * T
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
Definition: Specifiers.h:398
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
Definition: Attr.h:55
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
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:235
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
TemplateDeductionResult
Describes the result of template argument deduction.
Definition: Sema.h:364
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
@ CUDATargetMismatch
CUDA Target attributes do not match.
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ Success
Template argument deduction was successful.
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
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
@ None
The alignment was not explicit in code.
SourceLocIdentKind
Definition: Expr.h:4797
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:6846
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DynamicNone
throw()
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition: Expr.h:1975
CheckedConversionKind
The kind of conversion being performed.
Definition: Sema.h:433
@ Implicit
An implicit conversion.
@ CStyleCast
A C-style cast.
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
@ OtherCast
A cast other than a C-style cast.
@ FunctionalCast
A functional-style cast.
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
MutableArrayRef< Expr * > MultiExprArg
Definition: Ownership.h:258
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
#define true
Definition: stdbool.h:25
#define false
Definition: stdbool.h:26
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:89
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
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: Type.h:4840
Holds information about the various types of exception specification.
Definition: Type.h:5159
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:5161
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:5164
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:5167
Extra information about a function prototype.
Definition: Type.h:5187
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:103
Represents a complete lambda introducer.
Definition: DeclSpec.h:2835
Contains a late templated function.
Definition: Sema.h:15176
CachedTokens Toks
Definition: Sema.h:15177
FPOptions FPO
Floating-point options in the point of definition.
Definition: Sema.h:15181
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:15179
A normalized constraint, as defined in C++ [temp.constr.normal], is either an atomic constraint,...
Definition: SemaConcept.h:106
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1643
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:12653
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:12814
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:12767
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:12783
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:12809
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:12802
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition: Sema.h:12778
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:12770
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition: Sema.h:12796
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition: Sema.h:12786
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:12793
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:12655
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition: Sema.h:12747
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition: Sema.h:12665
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition: Sema.h:12674
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:12693
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition: Sema.h:12744
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:12701
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition: Sema.h:12708
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition: Sema.h:12751
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:12719
@ Memoization
Added for Template instantiation observation.
Definition: Sema.h:12757
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition: Sema.h:12684
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition: Sema.h:12763
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition: Sema.h:12760
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:12681
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:12689
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:12697
@ TemplateInstantiation
We are instantiating a template declaration.
Definition: Sema.h:12658
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition: Sema.h:12711
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition: Sema.h:12715
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition: Sema.h:12670
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:12741
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition: Sema.h:12704
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:12773
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition: Sema.h:12799
ConstraintEvalRAII(InstTy &TI)
Definition: Sema.h:13327
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition: Sema.h:6376
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:6286
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:6318
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition: Sema.h:6320
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition: Sema.h:6366
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:6310
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:6314
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition: Sema.h:6325
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:6333
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition: Sema.h:6329
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition: Sema.h:6339
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:6305
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:6343
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition: Sema.h:6369
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:6291
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:6299
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition: Sema.h:6386
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:6388
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:6288
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:6295
FormatArgumentPassingKind ArgPassingKind
Definition: Sema.h:2163
std::optional< FunctionEffectWithCondition > Old
Definition: Sema.h:15083
StringRef effectName() const
Definition: Sema.h:15087
OverrideResult
Describes the result of effects differing between a base class's virtual method and an overriding met...
Definition: Sema.h:15095
std::optional< FunctionEffectWithCondition > New
Definition: Sema.h:15085
FunctionEffect::Kind EffectKind
Definition: Sema.h:15080
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:928
A stack object to be created when performing template instantiation.
Definition: Sema.h:12838
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:12992
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:12996
LocalInstantiationScope * Scope
Definition: Sema.h:13634
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:13637
bool isMoveEligible() const
Definition: Sema.h:10807
bool isCopyElidable() const
Definition: Sema.h:10808
const VarDecl * Candidate
Definition: Sema.h:10802
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2803
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition: Sema.h:2809
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:2818
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:2812
SourceLocation CCLoc
The location of the '::'.
Definition: Sema.h:2815
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition: Sema.h:2806
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:2824
SourceLocation LocEnd
Definition: Sema.h:7063
IdentifierInfo * IdentInfo
Definition: Sema.h:7066
brief A function argument from which we performed template argument
Definition: Sema.h:12242
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition: Sema.h:12243
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:1699
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:1702
A push'd group of PragmaAttributeEntries.
Definition: Sema.h:1707
SourceLocation Loc
The location of the push attribute.
Definition: Sema.h:1709
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition: Sema.h:1712
const IdentifierInfo * Namespace
The namespace of this push group.
Definition: Sema.h:1711
SourceLocation PragmaLocation
Definition: Sema.h:1421
PragmaMsStackAction Action
Definition: Sema.h:1441
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:1554
llvm::StringRef StackSlotLabel
Definition: Sema.h:1550
SourceLocation PragmaLocation
Definition: Sema.h:1552
SourceLocation PragmaPushLocation
Definition: Sema.h:1553
ValueType CurrentValue
Definition: Sema.h:1624
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:1610
bool hasValue() const
Definition: Sema.h:1620
SmallVector< Slot, 2 > Stack
Definition: Sema.h:1622
ValueType DefaultValue
Definition: Sema.h:1623
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1625
PragmaStack(const ValueType &Default)
Definition: Sema.h:1617
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition: Sema.h:1561
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition: Sema.h:4638
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition: Sema.h:4632
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition: Sema.h:10124
Abstract class used to diagnose incomplete types.
Definition: Sema.h:7851
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
virtual ~TypeDiagnoser()
Definition: Sema.h:7855
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:2212
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition: Sema.h:2221
std::unique_ptr< TypoCorrectionConsumer > Consumer
Definition: Sema.h:9484
TypoDiagnosticGenerator DiagHandler
Definition: Sema.h:9485
TypoRecoveryCallback RecoveryHandler
Definition: Sema.h:9486
bool CheckSameAsPrevious
Definition: Sema.h:350
NamedDecl * Previous
Definition: Sema.h:351
SkipBodyInfo()=default
NamedDecl * New
Definition: Sema.h:352
Information about a template-id annotation token.