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/ASTLambda.h"
20#include "clang/AST/Attr.h"
22#include "clang/AST/CharUnits.h"
23#include "clang/AST/DeclBase.h"
24#include "clang/AST/DeclCXX.h"
27#include "clang/AST/Expr.h"
28#include "clang/AST/ExprCXX.h"
33#include "clang/AST/StmtCXX.h"
34#include "clang/AST/Type.h"
35#include "clang/AST/TypeLoc.h"
39#include "clang/Basic/Cuda.h"
43#include "clang/Basic/LLVM.h"
44#include "clang/Basic/Lambda.h"
46#include "clang/Basic/Module.h"
58#include "clang/Sema/Attr.h"
60#include "clang/Sema/DeclSpec.h"
66#include "clang/Sema/Scope.h"
67#include "clang/Sema/SemaBase.h"
69#include "clang/Sema/Weak.h"
70#include "llvm/ADT/APInt.h"
71#include "llvm/ADT/ArrayRef.h"
72#include "llvm/ADT/BitmaskEnum.h"
73#include "llvm/ADT/DenseMap.h"
74#include "llvm/ADT/DenseSet.h"
75#include "llvm/ADT/FloatingPointMode.h"
76#include "llvm/ADT/FoldingSet.h"
77#include "llvm/ADT/MapVector.h"
78#include "llvm/ADT/PointerIntPair.h"
79#include "llvm/ADT/PointerUnion.h"
80#include "llvm/ADT/STLExtras.h"
81#include "llvm/ADT/STLForwardCompat.h"
82#include "llvm/ADT/STLFunctionalExtras.h"
83#include "llvm/ADT/SetVector.h"
84#include "llvm/ADT/SmallBitVector.h"
85#include "llvm/ADT/SmallPtrSet.h"
86#include "llvm/ADT/SmallSet.h"
87#include "llvm/ADT/SmallVector.h"
88#include "llvm/ADT/StringExtras.h"
89#include "llvm/ADT/StringMap.h"
90#include "llvm/ADT/TinyPtrVector.h"
91#include "llvm/Support/Allocator.h"
92#include "llvm/Support/Compiler.h"
93#include "llvm/Support/Error.h"
94#include "llvm/Support/ErrorHandling.h"
95#include <cassert>
96#include <climits>
97#include <cstddef>
98#include <cstdint>
99#include <deque>
100#include <functional>
101#include <iterator>
102#include <memory>
103#include <optional>
104#include <string>
105#include <tuple>
106#include <type_traits>
107#include <utility>
108#include <vector>
109
110namespace llvm {
111struct InlineAsmIdentifierInfo;
112} // namespace llvm
113
114namespace clang {
115class ADLResult;
116class APValue;
117struct ASTConstraintSatisfaction;
118class ASTConsumer;
119class ASTContext;
120class ASTDeclReader;
121class ASTMutationListener;
122class ASTReader;
123class ASTWriter;
124class CXXBasePath;
125class CXXBasePaths;
126class CXXFieldCollector;
127class CodeCompleteConsumer;
128enum class ComparisonCategoryType : unsigned char;
129class ConstraintSatisfaction;
130class DarwinSDKInfo;
131class DeclGroupRef;
132class DeducedTemplateArgument;
133struct DeductionFailureInfo;
134class DependentDiagnostic;
135class Designation;
136class IdentifierInfo;
137class ImplicitConversionSequence;
138typedef MutableArrayRef<ImplicitConversionSequence> ConversionSequenceList;
139class InitializationKind;
140class InitializationSequence;
141class InitializedEntity;
142enum class LangAS : unsigned int;
143class LocalInstantiationScope;
144class LookupResult;
145class MangleNumberingContext;
146typedef ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> ModuleIdPath;
147class ModuleLoader;
148class MultiLevelTemplateArgumentList;
149struct NormalizedConstraint;
150class ObjCInterfaceDecl;
151class ObjCMethodDecl;
152struct OverloadCandidate;
153enum class OverloadCandidateParamOrder : char;
155class OverloadCandidateSet;
156class Preprocessor;
157class SemaAMDGPU;
158class SemaARM;
159class SemaAVR;
160class SemaBPF;
161class SemaCodeCompletion;
162class SemaCUDA;
163class SemaHLSL;
164class SemaHexagon;
165class SemaLoongArch;
166class SemaM68k;
167class SemaMIPS;
168class SemaMSP430;
169class SemaNVPTX;
170class SemaObjC;
171class SemaOpenACC;
172class SemaOpenCL;
173class SemaOpenMP;
174class SemaPPC;
175class SemaPseudoObject;
176class SemaRISCV;
177class SemaSPIRV;
178class SemaSYCL;
179class SemaSwift;
180class SemaSystemZ;
181class SemaWasm;
182class SemaX86;
183class StandardConversionSequence;
184class TemplateArgument;
185class TemplateArgumentLoc;
186class TemplateInstantiationCallback;
187class TemplatePartialOrderingContext;
188class TemplateSpecCandidateSet;
189class Token;
190class TypeConstraint;
191class TypoCorrectionConsumer;
192class UnresolvedSetImpl;
193class UnresolvedSetIterator;
194class VisibleDeclConsumer;
195
196namespace sema {
197class BlockScopeInfo;
198class Capture;
199class CapturedRegionScopeInfo;
200class CapturingScopeInfo;
201class CompoundScopeInfo;
202class DelayedDiagnostic;
203class DelayedDiagnosticPool;
204class FunctionScopeInfo;
205class LambdaScopeInfo;
206class SemaPPCallbacks;
207class TemplateDeductionInfo;
208} // namespace sema
209
210// AssignmentAction - This is used by all the assignment diagnostic functions
211// to represent what is actually causing the operation
213 Assigning,
214 Passing,
215 Returning,
218 Sending,
219 Casting,
221};
223 const AssignmentAction &AA) {
224 DB << llvm::to_underlying(AA);
225 return DB;
226}
227
228namespace threadSafety {
229class BeforeSet;
230void threadSafetyCleanup(BeforeSet *Cache);
231} // namespace threadSafety
232
233// FIXME: No way to easily map from TemplateTypeParmTypes to
234// TemplateTypeParmDecls, so we have this horrible PointerUnion.
235typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType *, NamedDecl *>,
236 SourceLocation>
238
239/// Describes whether we've seen any nullability information for the given
240/// file.
242 /// The first pointer declarator (of any pointer kind) in the file that does
243 /// not have a corresponding nullability annotation.
245
246 /// The end location for the first pointer declarator in the file. Used for
247 /// placing fix-its.
249
250 /// Which kind of pointer declarator we saw.
251 uint8_t PointerKind;
252
253 /// Whether we saw any type nullability annotations in the given file.
254 bool SawTypeNullability = false;
255};
256
257/// A mapping from file IDs to a record of whether we've seen nullability
258/// information in that file.
260 /// A mapping from file IDs to the nullability information for each file ID.
261 llvm::DenseMap<FileID, FileNullability> Map;
262
263 /// A single-element cache based on the file ID.
264 struct {
267 } Cache;
268
269public:
271 // Check the single-element cache.
272 if (file == Cache.File)
273 return Cache.Nullability;
274
275 // It's not in the single-element cache; flush the cache if we have one.
276 if (!Cache.File.isInvalid()) {
277 Map[Cache.File] = Cache.Nullability;
278 }
279
280 // Pull this entry into the cache.
281 Cache.File = file;
282 Cache.Nullability = Map[file];
283 return Cache.Nullability;
284 }
285};
286
287/// Tracks expected type during expression parsing, for use in code completion.
288/// The type is tied to a particular token, all functions that update or consume
289/// the type take a start location of the token they are looking at as a
290/// parameter. This avoids updating the type on hot paths in the parser.
292public:
293 PreferredTypeBuilder(bool Enabled) : Enabled(Enabled) {}
294
295 void enterCondition(Sema &S, SourceLocation Tok);
296 void enterReturn(Sema &S, SourceLocation Tok);
298 /// Handles e.g. BaseType{ .D = Tok...
300 const Designation &D);
301 /// Computing a type for the function argument may require running
302 /// overloading, so we postpone its computation until it is actually needed.
303 ///
304 /// Clients should be very careful when using this function, as it stores a
305 /// function_ref, clients should make sure all calls to get() with the same
306 /// location happen while function_ref is alive.
307 ///
308 /// The callback should also emit signature help as a side-effect, but only
309 /// if the completion point has been reached.
311 llvm::function_ref<QualType()> ComputeType);
312
314 void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
315 SourceLocation OpLoc);
316 void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
318 void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS);
319 /// Handles all type casts, including C-style cast, C++ casts, etc.
321
322 /// Get the expected type associated with this location, if any.
323 ///
324 /// If the location is a function argument, determining the expected type
325 /// involves considering all function overloads and the arguments so far.
326 /// In this case, signature help for these function overloads will be reported
327 /// as a side-effect (only if the completion point has been reached).
329 if (!Enabled || Tok != ExpectedLoc)
330 return QualType();
331 if (!Type.isNull())
332 return Type;
333 if (ComputeType)
334 return ComputeType();
335 return QualType();
336 }
337
338private:
339 bool Enabled;
340 /// Start position of a token for which we store expected type.
341 SourceLocation ExpectedLoc;
342 /// Expected type for a token starting at ExpectedLoc.
344 /// A function to compute expected type at ExpectedLoc. It is only considered
345 /// if Type is null.
346 llvm::function_ref<QualType()> ComputeType;
347};
348
350 SkipBodyInfo() = default;
351 bool ShouldSkip = false;
353 NamedDecl *Previous = nullptr;
354 NamedDecl *New = nullptr;
355};
356
357/// Describes the result of template argument deduction.
358///
359/// The TemplateDeductionResult enumeration describes the result of
360/// template argument deduction, as returned from
361/// DeduceTemplateArguments(). The separate TemplateDeductionInfo
362/// structure provides additional information about the results of
363/// template argument deduction, e.g., the deduced template argument
364/// list (if successful) or the specific template parameters or
365/// deduced arguments that were involved in the failure.
367 /// Template argument deduction was successful.
368 Success = 0,
369 /// The declaration was invalid; do nothing.
370 Invalid,
371 /// Template argument deduction exceeded the maximum template
372 /// instantiation depth (which has already been diagnosed).
374 /// Template argument deduction did not deduce a value
375 /// for every template parameter.
377 /// Template argument deduction did not deduce a value for every
378 /// expansion of an expanded template parameter pack.
380 /// Template argument deduction produced inconsistent
381 /// deduced values for the given template parameter.
383 /// Template argument deduction failed due to inconsistent
384 /// cv-qualifiers on a template parameter type that would
385 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
386 /// but were given a non-const "X".
388 /// Substitution of the deduced template argument values
389 /// resulted in an error.
391 /// After substituting deduced template arguments, a dependent
392 /// parameter type did not match the corresponding argument.
394 /// After substituting deduced template arguments, an element of
395 /// a dependent parameter type did not match the corresponding element
396 /// of the corresponding argument (when deducing from an initializer list).
398 /// A non-depnedent component of the parameter did not match the
399 /// corresponding component of the argument.
401 /// When performing template argument deduction for a function
402 /// template, there were too many call arguments.
404 /// When performing template argument deduction for a function
405 /// template, there were too few call arguments.
407 /// The explicitly-specified template arguments were not valid
408 /// template arguments for the given template.
410 /// Checking non-dependent argument conversions failed.
412 /// The deduced arguments did not satisfy the constraints associated
413 /// with the template.
415 /// Deduction failed; that's all we know.
417 /// CUDA Target attributes do not match.
419 /// Some error which was already diagnosed.
421};
422
423/// Kinds of C++ special members.
431 Invalid
432};
433
434/// The kind of conversion being performed.
436 /// An implicit conversion.
437 Implicit,
438 /// A C-style cast.
440 /// A functional-style cast.
442 /// A cast other than a C-style cast.
443 OtherCast,
444 /// A conversion for an operand of a builtin overloaded operator.
446};
447
448enum class TagUseKind {
449 Reference, // Reference to a tag: 'struct foo *X;'
450 Declaration, // Fwd decl of a tag: 'struct foo;'
451 Definition, // Definition of a tag: 'struct foo { int X; } Y;'
452 Friend // Friend declaration: 'friend struct foo;'
453};
454
455/// Used with attributes/effects with a boolean condition, e.g. `nonblocking`.
456enum class FunctionEffectMode : uint8_t {
457 None, // effect is not present.
458 False, // effect(false).
459 True, // effect(true).
460 Dependent // effect(expr) where expr is dependent.
461};
462
463/// Sema - This implements semantic analysis and AST building for C.
464/// \nosubgrouping
465class Sema final : public SemaBase {
466 // Table of Contents
467 // -----------------
468 // 1. Semantic Analysis (Sema.cpp)
469 // 2. API Notes (SemaAPINotes.cpp)
470 // 3. C++ Access Control (SemaAccess.cpp)
471 // 4. Attributes (SemaAttr.cpp)
472 // 5. Availability Attribute Handling (SemaAvailability.cpp)
473 // 6. Bounds Safety (SemaBoundsSafety.cpp)
474 // 7. Casts (SemaCast.cpp)
475 // 8. Extra Semantic Checking (SemaChecking.cpp)
476 // 9. C++ Coroutines (SemaCoroutine.cpp)
477 // 10. C++ Scope Specifiers (SemaCXXScopeSpec.cpp)
478 // 11. Declarations (SemaDecl.cpp)
479 // 12. Declaration Attribute Handling (SemaDeclAttr.cpp)
480 // 13. C++ Declarations (SemaDeclCXX.cpp)
481 // 14. C++ Exception Specifications (SemaExceptionSpec.cpp)
482 // 15. Expressions (SemaExpr.cpp)
483 // 16. C++ Expressions (SemaExprCXX.cpp)
484 // 17. Member Access Expressions (SemaExprMember.cpp)
485 // 18. Initializers (SemaInit.cpp)
486 // 19. C++ Lambda Expressions (SemaLambda.cpp)
487 // 20. Name Lookup (SemaLookup.cpp)
488 // 21. Modules (SemaModule.cpp)
489 // 22. C++ Overloading (SemaOverload.cpp)
490 // 23. Statements (SemaStmt.cpp)
491 // 24. `inline asm` Statement (SemaStmtAsm.cpp)
492 // 25. Statement Attribute Handling (SemaStmtAttr.cpp)
493 // 26. C++ Templates (SemaTemplate.cpp)
494 // 27. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
495 // 28. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
496 // 29. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
497 // 30. C++ Template Declaration Instantiation
498 // (SemaTemplateInstantiateDecl.cpp)
499 // 31. C++ Variadic Templates (SemaTemplateVariadic.cpp)
500 // 32. Constraints and Concepts (SemaConcept.cpp)
501 // 33. Types (SemaType.cpp)
502 // 34. FixIt Helpers (SemaFixItUtils.cpp)
503 // 35. Function Effects (SemaFunctionEffects.cpp)
504
505 /// \name Semantic Analysis
506 /// Implementations are in Sema.cpp
507 ///@{
508
509public:
510 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
512 CodeCompleteConsumer *CompletionConsumer = nullptr);
513 ~Sema();
514
515 /// Perform initialization that occurs after the parser has been
516 /// initialized but before it parses anything.
517 void Initialize();
518
519 /// This virtual key function only exists to limit the emission of debug info
520 /// describing the Sema class. GCC and Clang only emit debug info for a class
521 /// with a vtable when the vtable is emitted. Sema is final and not
522 /// polymorphic, but the debug info size savings are so significant that it is
523 /// worth adding a vtable just to take advantage of this optimization.
524 virtual void anchor();
525
526 const LangOptions &getLangOpts() const { return LangOpts; }
529
532 Preprocessor &getPreprocessor() const { return PP; }
533 ASTContext &getASTContext() const { return Context; }
537
539 StringRef Platform);
541
542 /// Registers an external source. If an external source already exists,
543 /// creates a multiplex external source and appends to it.
544 ///
545 ///\param[in] E - A non-null external sema source.
546 ///
548
549 /// Print out statistics about the semantic analysis.
550 void PrintStats() const;
551
552 /// Run some code with "sufficient" stack space. (Currently, at least 256K is
553 /// guaranteed). Produces a warning if we're low on stack space and allocates
554 /// more in that case. Use this in code that may recurse deeply (for example,
555 /// in template instantiation) to avoid stack overflow.
557 llvm::function_ref<void()> Fn);
558
559 /// Returns default addr space for method qualifiers.
561
562 /// Load weak undeclared identifiers from the external source.
564
565 /// Determine if VD, which must be a variable or function, is an external
566 /// symbol that nonetheless can't be referenced from outside this translation
567 /// unit because its type has no linkage and it's not extern "C".
568 bool isExternalWithNoLinkageType(const ValueDecl *VD) const;
569
570 /// Obtain a sorted list of functions that are undefined but ODR-used.
572 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined);
573
574 typedef std::pair<SourceLocation, bool> DeleteExprLoc;
576 /// Retrieves list of suspicious delete-expressions that will be checked at
577 /// the end of translation unit.
578 const llvm::MapVector<FieldDecl *, DeleteLocs> &
580
581 /// Cause the built diagnostic to be emitted on the DiagosticsEngine.
582 /// This is closely coupled to the SemaDiagnosticBuilder class and
583 /// should not be used elsewhere.
584 void EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB);
585
586 void addImplicitTypedef(StringRef Name, QualType T);
587
588 /// Whether uncompilable error has occurred. This includes error happens
589 /// in deferred diagnostics.
590 bool hasUncompilableErrorOccurred() const;
591
592 /// Looks through the macro-expansion chain for the given
593 /// location, looking for a macro expansion with the given name.
594 /// If one is found, returns true and sets the location to that
595 /// expansion loc.
596 bool findMacroSpelling(SourceLocation &loc, StringRef name);
597
598 /// Calls \c Lexer::getLocForEndOfToken()
600
601 /// Retrieve the module loader associated with the preprocessor.
603
604 /// Invent a new identifier for parameters of abbreviated templates.
607 unsigned Index);
608
610
611 // Emit all deferred diagnostics.
612 void emitDeferredDiags();
613
615 /// The global module fragment, between 'module;' and a module-declaration.
617 /// A normal translation unit fragment. For a non-module unit, this is the
618 /// entire translation unit. Otherwise, it runs from the module-declaration
619 /// to the private-module-fragment (if any) or the end of the TU (if not).
621 /// The private module fragment, between 'module :private;' and the end of
622 /// the translation unit.
623 Private
624 };
625
626 /// This is called before the very first declaration in the translation unit
627 /// is parsed. Note that the ASTContext may have already injected some
628 /// declarations.
630 /// ActOnEndOfTranslationUnit - This is called at the very end of the
631 /// translation unit when EOF is reached and all but the top-level scope is
632 /// popped.
635
636 /// Determines the active Scope associated with the given declaration
637 /// context.
638 ///
639 /// This routine maps a declaration context to the active Scope object that
640 /// represents that declaration context in the parser. It is typically used
641 /// from "scope-less" code (e.g., template instantiation, lazy creation of
642 /// declarations) that injects a name for name-lookup purposes and, therefore,
643 /// must update the Scope.
644 ///
645 /// \returns The scope corresponding to the given declaraion context, or NULL
646 /// if no such scope is open.
648
649 void PushFunctionScope();
650 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
652
653 /// This is used to inform Sema what the current TemplateParameterDepth
654 /// is during Parsing. Currently it is used to pass on the depth
655 /// when parsing generic lambda 'auto' parameters.
656 void RecordParsingTemplateParameterDepth(unsigned Depth);
657
658 void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
660 unsigned OpenMPCaptureLevel = 0);
661
662 /// Custom deleter to allow FunctionScopeInfos to be kept alive for a short
663 /// time after they've been popped.
665 Sema *Self;
666
667 public:
668 explicit PoppedFunctionScopeDeleter(Sema *Self) : Self(Self) {}
670 };
671
673 std::unique_ptr<sema::FunctionScopeInfo, PoppedFunctionScopeDeleter>;
674
675 /// Pop a function (or block or lambda or captured region) scope from the
676 /// stack.
677 ///
678 /// \param WP The warning policy to use for CFG-based warnings, or null if
679 /// such warnings should not be produced.
680 /// \param D The declaration corresponding to this function scope, if
681 /// producing CFG-based warnings.
682 /// \param BlockType The type of the block expression, if D is a BlockDecl.
685 const Decl *D = nullptr,
686 QualType BlockType = QualType());
687
689
694
695 void PushCompoundScope(bool IsStmtExpr);
696 void PopCompoundScope();
697
698 /// Determine whether any errors occurred within this function/method/
699 /// block.
701
702 /// Retrieve the current block, if any.
704
705 /// Get the innermost lambda or block enclosing the current location, if any.
706 /// This looks through intervening non-lambda, non-block scopes such as local
707 /// functions.
709
710 /// Retrieve the current lambda scope info, if any.
711 /// \param IgnoreNonLambdaCapturingScope true if should find the top-most
712 /// lambda scope info ignoring all inner capturing scopes that are not
713 /// lambda scopes.
715 getCurLambda(bool IgnoreNonLambdaCapturingScope = false);
716
717 /// Retrieve the current generic lambda info, if any.
719
720 /// Retrieve the current captured region, if any.
722
723 void ActOnComment(SourceRange Comment);
724
725 /// Retrieve the parser's current scope.
726 ///
727 /// This routine must only be used when it is certain that semantic analysis
728 /// and the parser are in precisely the same context, which is not the case
729 /// when, e.g., we are performing any kind of template instantiation.
730 /// Therefore, the only safe places to use this scope are in the parser
731 /// itself and in routines directly invoked from the parser and *never* from
732 /// template substitution or instantiation.
733 Scope *getCurScope() const { return CurScope; }
734
736
739 }
740
741 SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
742 const FunctionDecl *FD = nullptr);
744 const PartialDiagnostic &PD,
745 const FunctionDecl *FD = nullptr) {
746 return targetDiag(Loc, PD.getDiagID(), FD) << PD;
747 }
748
749 /// Check if the type is allowed to be used for the current target.
751 ValueDecl *D = nullptr);
752
753 // /// The kind of conversion being performed.
754 // enum CheckedConversionKind {
755 // /// An implicit conversion.
756 // CCK_ImplicitConversion,
757 // /// A C-style cast.
758 // CCK_CStyleCast,
759 // /// A functional-style cast.
760 // CCK_FunctionalCast,
761 // /// A cast other than a C-style cast.
762 // CCK_OtherCast,
763 // /// A conversion for an operand of a builtin overloaded operator.
764 // CCK_ForBuiltinOverloadedOp
765 // };
766
767 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
768 /// cast. If there is already an implicit cast, merge into the existing one.
769 /// If isLvalue, the result of the cast is an lvalue.
772 const CXXCastPath *BasePath = nullptr,
774
775 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
776 /// to the conversion from scalar type ScalarTy to the Boolean type.
778
779 /// If \p AllowLambda is true, treat lambda as function.
780 DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
781
782 /// Returns a pointer to the innermost enclosing function, or nullptr if the
783 /// current context is not inside a function. If \p AllowLambda is true,
784 /// this can return the call operator of an enclosing lambda, otherwise
785 /// lambdas are skipped when looking for an enclosing function.
786 FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
787
788 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
789 /// the method decl for the method being parsed. If we're currently
790 /// in a 'block', this returns the containing context.
792
793 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
794 /// or C function we're in, otherwise return null. If we're currently
795 /// in a 'block', this returns the containing context.
797
798 /// Warn if we're implicitly casting from a _Nullable pointer type to a
799 /// _Nonnull one.
802
803 /// Warn when implicitly casting 0 to nullptr.
805
806 /// Warn when implicitly changing function effects.
809
810 /// makeUnavailableInSystemHeader - There is an error in the current
811 /// context. If we're still in a system header, and we can plausibly
812 /// make the relevant declaration unavailable instead of erroring, do
813 /// so and return true.
815 UnavailableAttr::ImplicitReason reason);
816
817 /// Retrieve a suitable printing policy for diagnostics.
820 }
821
822 /// Retrieve a suitable printing policy for diagnostics.
824 const Preprocessor &PP);
825
826 /// Scope actions.
828
829 /// Determine whether \param D is function like (function or function
830 /// template) for parsing.
832
833 /// The maximum alignment, same as in llvm::Value. We duplicate them here
834 /// because that allows us not to duplicate the constants in clang code,
835 /// which we must to since we can't directly use the llvm constants.
836 /// The value is verified against llvm here: lib/CodeGen/CGDecl.cpp
837 ///
838 /// This is the greatest alignment value supported by load, store, and alloca
839 /// instructions, and global values.
840 static const unsigned MaxAlignmentExponent = 32;
841 static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent;
842
843 /// Flag indicating whether or not to collect detailed statistics.
845
846 std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;
847
848 /// Stack containing information about each of the nested
849 /// function, block, and method scopes that are currently active.
851
852 /// The index of the first FunctionScope that corresponds to the current
853 /// context.
855
856 /// Track the number of currently active capturing scopes.
858
859 llvm::BumpPtrAllocator BumpAlloc;
860
861 /// The kind of translation unit we are processing.
862 ///
863 /// When we're processing a complete translation unit, Sema will perform
864 /// end-of-translation-unit semantic tasks (such as creating
865 /// initializers for tentative definitions in C) once parsing has
866 /// completed. Modules and precompiled headers perform different kinds of
867 /// checks.
869
870 /// Translation Unit Scope - useful to Objective-C actions that need
871 /// to lookup file scope declarations in the "ordinary" C decl namespace.
872 /// For example, user-defined classes, built-in "id" type, etc.
874
876 return CurScope->incrementMSManglingNumber();
877 }
878
879 /// Try to recover by turning the given expression into a
880 /// call. Returns true if recovery was attempted or an error was
881 /// emitted; this may also leave the ExprResult invalid.
883 bool ForceComplain = false,
884 bool (*IsPlausibleResult)(QualType) = nullptr);
885
886 /// Figure out if an expression could be turned into a call.
887 ///
888 /// Use this when trying to recover from an error where the programmer may
889 /// have written just the name of a function instead of actually calling it.
890 ///
891 /// \param E - The expression to examine.
892 /// \param ZeroArgCallReturnTy - If the expression can be turned into a call
893 /// with no arguments, this parameter is set to the type returned by such a
894 /// call; otherwise, it is set to an empty QualType.
895 /// \param OverloadSet - If the expression is an overloaded function
896 /// name, this parameter is populated with the decls of the various
897 /// overloads.
898 bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
899 UnresolvedSetImpl &NonTemplateOverloads);
900
904
907
915
916 /// A RAII object to enter scope of a compound statement.
918 public:
919 CompoundScopeRAII(Sema &S, bool IsStmtExpr = false) : S(S) {
920 S.ActOnStartOfCompoundStmt(IsStmtExpr);
921 }
922
924
925 private:
926 Sema &S;
927 };
928
929 /// An RAII helper that pops function a function scope on exit.
932 bool Active;
935 if (Active)
937 }
938 void disable() { Active = false; }
939 };
940
942 return FunctionScopes.empty() ? nullptr : FunctionScopes.back();
943 }
944
945 /// Worker object for performing CFG-based warnings.
948
949 /// Callback to the parser to parse templated functions when needed.
950 typedef void LateTemplateParserCB(void *P, LateParsedTemplate &LPT);
951 typedef void LateTemplateParserCleanupCB(void *P);
955
957 LateTemplateParserCleanupCB *LTPCleanup, void *P) {
958 LateTemplateParser = LTP;
959 LateTemplateParserCleanup = LTPCleanup;
960 OpaqueParser = P;
961 }
962
963 /// Callback to the parser to parse a type expressed as a string.
964 std::function<TypeResult(StringRef, StringRef, SourceLocation)>
966
967 /// VAListTagName - The declaration name corresponding to __va_list_tag.
968 /// This is used as part of a hack to omit that class from ADL results.
970
971 /// Is the last error level diagnostic immediate. This is used to determined
972 /// whether the next info diagnostic should be immediate.
974
975 class DelayedDiagnostics;
976
978 sema::DelayedDiagnosticPool *SavedPool = nullptr;
980 };
983
984 /// A class which encapsulates the logic for delaying diagnostics
985 /// during parsing and other processing.
987 /// The current pool of diagnostics into which delayed
988 /// diagnostics should go.
989 sema::DelayedDiagnosticPool *CurPool = nullptr;
990
991 public:
993
994 /// Adds a delayed diagnostic.
995 void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h
996
997 /// Determines whether diagnostics should be delayed.
998 bool shouldDelayDiagnostics() { return CurPool != nullptr; }
999
1000 /// Returns the current delayed-diagnostics pool.
1001 sema::DelayedDiagnosticPool *getCurrentPool() const { return CurPool; }
1002
1003 /// Enter a new scope. Access and deprecation diagnostics will be
1004 /// collected in this pool.
1007 state.SavedPool = CurPool;
1008 CurPool = &pool;
1009 return state;
1010 }
1011
1012 /// Leave a delayed-diagnostic state that was previously pushed.
1013 /// Do not emit any of the diagnostics. This is performed as part
1014 /// of the bookkeeping of popping a pool "properly".
1016 CurPool = state.SavedPool;
1017 }
1018
1019 /// Enter a new scope where access and deprecation diagnostics are
1020 /// not delayed.
1023 state.SavedPool = CurPool;
1024 CurPool = nullptr;
1025 return state;
1026 }
1027
1028 /// Undo a previous pushUndelayed().
1030 assert(CurPool == nullptr);
1031 CurPool = state.SavedPool;
1032 }
1033 } DelayedDiagnostics;
1034
1036 return DelayedDiagnostics.push(pool);
1037 }
1038
1039 /// Diagnostics that are emitted only if we discover that the given function
1040 /// must be codegen'ed. Because handling these correctly adds overhead to
1041 /// compilation, this is currently only enabled for CUDA compilations.
1042 SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags;
1043
1044 /// CurContext - This is the current declaration context of parsing.
1046
1048 assert(AMDGPUPtr);
1049 return *AMDGPUPtr;
1050 }
1051
1053 assert(ARMPtr);
1054 return *ARMPtr;
1055 }
1056
1058 assert(AVRPtr);
1059 return *AVRPtr;
1060 }
1061
1063 assert(BPFPtr);
1064 return *BPFPtr;
1065 }
1066
1068 assert(CodeCompletionPtr);
1069 return *CodeCompletionPtr;
1070 }
1071
1073 assert(CUDAPtr);
1074 return *CUDAPtr;
1075 }
1076
1078 assert(HLSLPtr);
1079 return *HLSLPtr;
1080 }
1081
1083 assert(HexagonPtr);
1084 return *HexagonPtr;
1085 }
1086
1088 assert(LoongArchPtr);
1089 return *LoongArchPtr;
1090 }
1091
1093 assert(M68kPtr);
1094 return *M68kPtr;
1095 }
1096
1098 assert(MIPSPtr);
1099 return *MIPSPtr;
1100 }
1101
1103 assert(MSP430Ptr);
1104 return *MSP430Ptr;
1105 }
1106
1108 assert(NVPTXPtr);
1109 return *NVPTXPtr;
1110 }
1111
1113 assert(ObjCPtr);
1114 return *ObjCPtr;
1115 }
1116
1118 assert(OpenACCPtr);
1119 return *OpenACCPtr;
1120 }
1121
1123 assert(OpenCLPtr);
1124 return *OpenCLPtr;
1125 }
1126
1128 assert(OpenMPPtr && "SemaOpenMP is dead");
1129 return *OpenMPPtr;
1130 }
1131
1133 assert(PPCPtr);
1134 return *PPCPtr;
1135 }
1136
1138 assert(PseudoObjectPtr);
1139 return *PseudoObjectPtr;
1140 }
1141
1143 assert(RISCVPtr);
1144 return *RISCVPtr;
1145 }
1146
1148 assert(SPIRVPtr);
1149 return *SPIRVPtr;
1150 }
1151
1153 assert(SYCLPtr);
1154 return *SYCLPtr;
1155 }
1156
1158 assert(SwiftPtr);
1159 return *SwiftPtr;
1160 }
1161
1163 assert(SystemZPtr);
1164 return *SystemZPtr;
1165 }
1166
1168 assert(WasmPtr);
1169 return *WasmPtr;
1170 }
1171
1173 assert(X86Ptr);
1174 return *X86Ptr;
1175 }
1176
1177 /// Source of additional semantic information.
1179
1180protected:
1181 friend class Parser;
1183 friend class ASTReader;
1184 friend class ASTDeclReader;
1185 friend class ASTWriter;
1186
1187private:
1188 std::optional<std::unique_ptr<DarwinSDKInfo>> CachedDarwinSDKInfo;
1189 bool WarnedDarwinSDKInfoMissing = false;
1190
1191 StackExhaustionHandler StackHandler;
1192
1193 Sema(const Sema &) = delete;
1194 void operator=(const Sema &) = delete;
1195
1196 /// The handler for the FileChanged preprocessor events.
1197 ///
1198 /// Used for diagnostics that implement custom semantic analysis for #include
1199 /// directives, like -Wpragma-pack.
1200 sema::SemaPPCallbacks *SemaPPCallbackHandler;
1201
1202 /// The parser's current scope.
1203 ///
1204 /// The parser maintains this state here.
1205 Scope *CurScope;
1206
1207 mutable IdentifierInfo *Ident_super;
1208
1209 std::unique_ptr<SemaAMDGPU> AMDGPUPtr;
1210 std::unique_ptr<SemaARM> ARMPtr;
1211 std::unique_ptr<SemaAVR> AVRPtr;
1212 std::unique_ptr<SemaBPF> BPFPtr;
1213 std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
1214 std::unique_ptr<SemaCUDA> CUDAPtr;
1215 std::unique_ptr<SemaHLSL> HLSLPtr;
1216 std::unique_ptr<SemaHexagon> HexagonPtr;
1217 std::unique_ptr<SemaLoongArch> LoongArchPtr;
1218 std::unique_ptr<SemaM68k> M68kPtr;
1219 std::unique_ptr<SemaMIPS> MIPSPtr;
1220 std::unique_ptr<SemaMSP430> MSP430Ptr;
1221 std::unique_ptr<SemaNVPTX> NVPTXPtr;
1222 std::unique_ptr<SemaObjC> ObjCPtr;
1223 std::unique_ptr<SemaOpenACC> OpenACCPtr;
1224 std::unique_ptr<SemaOpenCL> OpenCLPtr;
1225 std::unique_ptr<SemaOpenMP> OpenMPPtr;
1226 std::unique_ptr<SemaPPC> PPCPtr;
1227 std::unique_ptr<SemaPseudoObject> PseudoObjectPtr;
1228 std::unique_ptr<SemaRISCV> RISCVPtr;
1229 std::unique_ptr<SemaSPIRV> SPIRVPtr;
1230 std::unique_ptr<SemaSYCL> SYCLPtr;
1231 std::unique_ptr<SemaSwift> SwiftPtr;
1232 std::unique_ptr<SemaSystemZ> SystemZPtr;
1233 std::unique_ptr<SemaWasm> WasmPtr;
1234 std::unique_ptr<SemaX86> X86Ptr;
1235
1236 ///@}
1237
1238 //
1239 //
1240 // -------------------------------------------------------------------------
1241 //
1242 //
1243
1244 /// \name API Notes
1245 /// Implementations are in SemaAPINotes.cpp
1246 ///@{
1247
1248public:
1249 /// Map any API notes provided for this declaration to attributes on the
1250 /// declaration.
1251 ///
1252 /// Triggered by declaration-attribute processing.
1253 void ProcessAPINotes(Decl *D);
1254
1255 ///@}
1256
1257 //
1258 //
1259 // -------------------------------------------------------------------------
1260 //
1261 //
1262
1263 /// \name C++ Access Control
1264 /// Implementations are in SemaAccess.cpp
1265 ///@{
1266
1267public:
1274
1275 /// SetMemberAccessSpecifier - Set the access specifier of a member.
1276 /// Returns true on error (when the previous member decl access specifier
1277 /// is different from the new member decl access specifier).
1278 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
1279 NamedDecl *PrevMemberDecl,
1280 AccessSpecifier LexicalAS);
1281
1282 /// Perform access-control checking on a previously-unresolved member
1283 /// access which has now been resolved to a member.
1285 DeclAccessPair FoundDecl);
1287 DeclAccessPair FoundDecl);
1288
1289 /// Checks access to an overloaded operator new or delete.
1291 SourceRange PlacementRange,
1292 CXXRecordDecl *NamingClass,
1293 DeclAccessPair FoundDecl,
1294 bool Diagnose = true);
1295
1296 /// Checks access to a constructor.
1298 DeclAccessPair FoundDecl,
1299 const InitializedEntity &Entity,
1300 bool IsCopyBindingRefToTemp = false);
1301
1302 /// Checks access to a constructor.
1304 DeclAccessPair FoundDecl,
1305 const InitializedEntity &Entity,
1306 const PartialDiagnostic &PDiag);
1308 CXXDestructorDecl *Dtor,
1309 const PartialDiagnostic &PDiag,
1310 QualType objectType = QualType());
1311
1312 /// Checks access to the target of a friend declaration.
1314
1315 /// Checks access to a member.
1317 CXXRecordDecl *NamingClass,
1319
1320 /// Checks implicit access to a member in a structured binding.
1323 CXXRecordDecl *DecomposedClass,
1324 DeclAccessPair Field);
1326 const SourceRange &,
1327 DeclAccessPair FoundDecl);
1328
1329 /// Checks access to an overloaded member operator, including
1330 /// conversion operators.
1332 Expr *ArgExpr,
1333 DeclAccessPair FoundDecl);
1335 ArrayRef<Expr *> ArgExprs,
1336 DeclAccessPair FoundDecl);
1338 DeclAccessPair FoundDecl);
1339
1340 /// Checks access for a hierarchy conversion.
1341 ///
1342 /// \param ForceCheck true if this check should be performed even if access
1343 /// control is disabled; some things rely on this for semantics
1344 /// \param ForceUnprivileged true if this check should proceed as if the
1345 /// context had no special privileges
1347 QualType Derived, const CXXBasePath &Path,
1348 unsigned DiagID, bool ForceCheck = false,
1349 bool ForceUnprivileged = false);
1350
1351 /// Checks access to all the declarations in the given result set.
1352 void CheckLookupAccess(const LookupResult &R);
1353
1354 /// Checks access to Target from the given class. The check will take access
1355 /// specifiers into account, but no member access expressions and such.
1356 ///
1357 /// \param Target the declaration to check if it can be accessed
1358 /// \param NamingClass the class in which the lookup was started.
1359 /// \param BaseType type of the left side of member access expression.
1360 /// \p BaseType and \p NamingClass are used for C++ access control.
1361 /// Depending on the lookup case, they should be set to the following:
1362 /// - lhs.target (member access without a qualifier):
1363 /// \p BaseType and \p NamingClass are both the type of 'lhs'.
1364 /// - lhs.X::target (member access with a qualifier):
1365 /// BaseType is the type of 'lhs', NamingClass is 'X'
1366 /// - X::target (qualified lookup without member access):
1367 /// BaseType is null, NamingClass is 'X'.
1368 /// - target (unqualified lookup).
1369 /// BaseType is null, NamingClass is the parent class of 'target'.
1370 /// \return true if the Target is accessible from the Class, false otherwise.
1371 bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass,
1372 QualType BaseType);
1373
1374 /// Is the given member accessible for the purposes of deciding whether to
1375 /// define a special member function as deleted?
1377 DeclAccessPair Found, QualType ObjectType,
1379 const PartialDiagnostic &Diag);
1382 QualType ObjectType) {
1383 return isMemberAccessibleForDeletion(NamingClass, Found, ObjectType,
1384 SourceLocation(), PDiag());
1385 }
1386
1388 const DependentDiagnostic &DD,
1389 const MultiLevelTemplateArgumentList &TemplateArgs);
1391
1392 ///@}
1393
1394 //
1395 //
1396 // -------------------------------------------------------------------------
1397 //
1398 //
1399
1400 /// \name Attributes
1401 /// Implementations are in SemaAttr.cpp
1402 ///@{
1403
1404public:
1405 /// Controls member pointer representation format under the MS ABI.
1408
1409 bool MSStructPragmaOn; // True when \#pragma ms_struct on
1410
1411 /// Source location for newly created implicit MSInheritanceAttrs
1413
1414 /// pragma clang section kind
1421 PCSK_Relro = 5
1423
1425
1427 std::string SectionName;
1428 bool Valid = false;
1430 };
1431
1437
1439 PSK_Reset = 0x0, // #pragma ()
1440 PSK_Set = 0x1, // #pragma (value)
1441 PSK_Push = 0x2, // #pragma (push[, id])
1442 PSK_Pop = 0x4, // #pragma (pop[, id])
1443 PSK_Show = 0x8, // #pragma (show) -- only for "pack"!
1444 PSK_Push_Set = PSK_Push | PSK_Set, // #pragma (push[, id], value)
1445 PSK_Pop_Set = PSK_Pop | PSK_Set, // #pragma (pop[, id], value)
1446 };
1447
1450 StringRef SlotLabel;
1452 };
1453
1454 // #pragma pack and align.
1456 public:
1457 // `Native` represents default align mode, which may vary based on the
1458 // platform.
1459 enum Mode : unsigned char { Native, Natural, Packed, Mac68k };
1460
1461 // #pragma pack info constructor
1462 AlignPackInfo(AlignPackInfo::Mode M, unsigned Num, bool IsXL)
1463 : PackAttr(true), AlignMode(M), PackNumber(Num), XLStack(IsXL) {
1464 assert(Num == PackNumber && "The pack number has been truncated.");
1465 }
1466
1467 // #pragma align info constructor
1469 : PackAttr(false), AlignMode(M),
1470 PackNumber(M == Packed ? 1 : UninitPackVal), XLStack(IsXL) {}
1471
1472 explicit AlignPackInfo(bool IsXL) : AlignPackInfo(Native, IsXL) {}
1473
1475
1476 // When a AlignPackInfo itself cannot be used, this returns an 32-bit
1477 // integer encoding for it. This should only be passed to
1478 // AlignPackInfo::getFromRawEncoding, it should not be inspected directly.
1479 static uint32_t getRawEncoding(const AlignPackInfo &Info) {
1480 std::uint32_t Encoding{};
1481 if (Info.IsXLStack())
1482 Encoding |= IsXLMask;
1483
1484 Encoding |= static_cast<uint32_t>(Info.getAlignMode()) << 1;
1485
1486 if (Info.IsPackAttr())
1487 Encoding |= PackAttrMask;
1488
1489 Encoding |= static_cast<uint32_t>(Info.getPackNumber()) << 4;
1490
1491 return Encoding;
1492 }
1493
1494 static AlignPackInfo getFromRawEncoding(unsigned Encoding) {
1495 bool IsXL = static_cast<bool>(Encoding & IsXLMask);
1497 static_cast<AlignPackInfo::Mode>((Encoding & AlignModeMask) >> 1);
1498 int PackNumber = (Encoding & PackNumMask) >> 4;
1499
1500 if (Encoding & PackAttrMask)
1501 return AlignPackInfo(M, PackNumber, IsXL);
1502
1503 return AlignPackInfo(M, IsXL);
1504 }
1505
1506 bool IsPackAttr() const { return PackAttr; }
1507
1508 bool IsAlignAttr() const { return !PackAttr; }
1509
1510 Mode getAlignMode() const { return AlignMode; }
1511
1512 unsigned getPackNumber() const { return PackNumber; }
1513
1514 bool IsPackSet() const {
1515 // #pragma align, #pragma pack(), and #pragma pack(0) do not set the pack
1516 // attriute on a decl.
1517 return PackNumber != UninitPackVal && PackNumber != 0;
1518 }
1519
1520 bool IsXLStack() const { return XLStack; }
1521
1522 bool operator==(const AlignPackInfo &Info) const {
1523 return std::tie(AlignMode, PackNumber, PackAttr, XLStack) ==
1524 std::tie(Info.AlignMode, Info.PackNumber, Info.PackAttr,
1525 Info.XLStack);
1526 }
1527
1528 bool operator!=(const AlignPackInfo &Info) const {
1529 return !(*this == Info);
1530 }
1531
1532 private:
1533 /// \brief True if this is a pragma pack attribute,
1534 /// not a pragma align attribute.
1535 bool PackAttr;
1536
1537 /// \brief The alignment mode that is in effect.
1538 Mode AlignMode;
1539
1540 /// \brief The pack number of the stack.
1541 unsigned char PackNumber;
1542
1543 /// \brief True if it is a XL #pragma align/pack stack.
1544 bool XLStack;
1545
1546 /// \brief Uninitialized pack value.
1547 static constexpr unsigned char UninitPackVal = -1;
1548
1549 // Masks to encode and decode an AlignPackInfo.
1550 static constexpr uint32_t IsXLMask{0x0000'0001};
1551 static constexpr uint32_t AlignModeMask{0x0000'0006};
1552 static constexpr uint32_t PackAttrMask{0x00000'0008};
1553 static constexpr uint32_t PackNumMask{0x0000'01F0};
1554 };
1555
1556 template <typename ValueType> struct PragmaStack {
1557 struct Slot {
1558 llvm::StringRef StackSlotLabel;
1559 ValueType Value;
1562 Slot(llvm::StringRef StackSlotLabel, ValueType Value,
1567 };
1568
1569 void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action,
1570 llvm::StringRef StackSlotLabel, ValueType Value) {
1571 if (Action == PSK_Reset) {
1573 CurrentPragmaLocation = PragmaLocation;
1574 return;
1575 }
1576 if (Action & PSK_Push)
1577 Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
1578 PragmaLocation);
1579 else if (Action & PSK_Pop) {
1580 if (!StackSlotLabel.empty()) {
1581 // If we've got a label, try to find it and jump there.
1582 auto I = llvm::find_if(llvm::reverse(Stack), [&](const Slot &x) {
1583 return x.StackSlotLabel == StackSlotLabel;
1584 });
1585 // If we found the label so pop from there.
1586 if (I != Stack.rend()) {
1587 CurrentValue = I->Value;
1588 CurrentPragmaLocation = I->PragmaLocation;
1589 Stack.erase(std::prev(I.base()), Stack.end());
1590 }
1591 } else if (!Stack.empty()) {
1592 // We do not have a label, just pop the last entry.
1593 CurrentValue = Stack.back().Value;
1594 CurrentPragmaLocation = Stack.back().PragmaLocation;
1595 Stack.pop_back();
1596 }
1597 }
1598 if (Action & PSK_Set) {
1600 CurrentPragmaLocation = PragmaLocation;
1601 }
1602 }
1603
1604 // MSVC seems to add artificial slots to #pragma stacks on entering a C++
1605 // method body to restore the stacks on exit, so it works like this:
1606 //
1607 // struct S {
1608 // #pragma <name>(push, InternalPragmaSlot, <current_pragma_value>)
1609 // void Method {}
1610 // #pragma <name>(pop, InternalPragmaSlot)
1611 // };
1612 //
1613 // It works even with #pragma vtordisp, although MSVC doesn't support
1614 // #pragma vtordisp(push [, id], n)
1615 // syntax.
1616 //
1617 // Push / pop a named sentinel slot.
1618 void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
1619 assert((Action == PSK_Push || Action == PSK_Pop) &&
1620 "Can only push / pop #pragma stack sentinels!");
1622 }
1623
1624 // Constructors.
1625 explicit PragmaStack(const ValueType &Default)
1627
1628 bool hasValue() const { return CurrentValue != DefaultValue; }
1629
1631 ValueType DefaultValue; // Value used for PSK_Reset action.
1632 ValueType CurrentValue;
1634 };
1635 // FIXME: We should serialize / deserialize these if they occur in a PCH (but
1636 // we shouldn't do so if they're in a module).
1637
1638 /// Whether to insert vtordisps prior to virtual bases in the Microsoft
1639 /// C++ ABI. Possible values are 0, 1, and 2, which mean:
1640 ///
1641 /// 0: Suppress all vtordisps
1642 /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
1643 /// structors
1644 /// 2: Always insert vtordisps to support RTTI on partially constructed
1645 /// objects
1648 // The current #pragma align/pack values and locations at each #include.
1653 };
1655 // Segment #pragmas.
1660
1661 // #pragma strict_gs_check.
1663
1664 // This stack tracks the current state of Sema.CurFPFeatures.
1667 FPOptionsOverride result;
1668 if (!FpPragmaStack.hasValue()) {
1669 result = FPOptionsOverride();
1670 } else {
1671 result = FpPragmaStack.CurrentValue;
1672 }
1673 return result;
1674 }
1675
1681 };
1682
1683 // RAII object to push / pop sentinel slots for all MS #pragma stacks.
1684 // Actions should be performed only if we enter / exit a C++ method body.
1686 public:
1687 PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
1689
1690 private:
1691 Sema &S;
1692 StringRef SlotLabel;
1693 bool ShouldAct;
1694 };
1695
1696 /// Last section used with #pragma init_seg.
1699
1700 /// Sections used with #pragma alloc_text.
1701 llvm::StringMap<std::tuple<StringRef, SourceLocation>> FunctionToSectionMap;
1702
1703 /// VisContext - Manages the stack for \#pragma GCC visibility.
1704 void *VisContext; // Really a "PragmaVisStack*"
1705
1706 /// This an attribute introduced by \#pragma clang attribute.
1712 };
1713
1714 /// A push'd group of PragmaAttributeEntries.
1716 /// The location of the push attribute.
1718 /// The namespace of this push group.
1721 };
1722
1724
1725 /// The declaration that is currently receiving an attribute from the
1726 /// #pragma attribute stack.
1728
1729 /// This represents the last location of a "#pragma clang optimize off"
1730 /// directive if such a directive has not been closed by an "on" yet. If
1731 /// optimizations are currently "on", this is set to an invalid location.
1733
1734 /// Get the location for the currently active "\#pragma clang optimize
1735 /// off". If this location is invalid, then the state of the pragma is "on".
1738 }
1739
1740 /// The "on" or "off" argument passed by \#pragma optimize, that denotes
1741 /// whether the optimizations in the list passed to the pragma should be
1742 /// turned off or on. This boolean is true by default because command line
1743 /// options are honored when `#pragma optimize("", on)`.
1744 /// (i.e. `ModifyFnAttributeMSPragmaOptimze()` does nothing)
1746
1747 /// Set of no-builtin functions listed by \#pragma function.
1749
1750 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
1751 /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
1753
1754 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
1756
1757 /// Add gsl::Pointer attribute to std::container::iterator
1758 /// \param ND The declaration that introduces the name
1759 /// std::container::iterator. \param UnderlyingRecord The record named by ND.
1760 void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord);
1761
1762 /// Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
1764
1765 /// Add [[clang:::lifetimebound]] attr for std:: functions and methods.
1767
1768 /// Add [[clang:::lifetime_capture_by(this)]] to STL container methods.
1770
1771 /// Add [[gsl::Pointer]] attributes for std:: types.
1773
1774 LifetimeCaptureByAttr *ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
1775 StringRef ParamName);
1776 // Processes the argument 'X' in [[clang::lifetime_capture_by(X)]]. Since 'X'
1777 // can be the name of a function parameter, we need to parse the function
1778 // declaration and rest of the parameters before processesing 'X'. Therefore
1779 // do this lazily instead of processing while parsing the annotation itself.
1781
1782 /// Add _Nullable attributes for std:: types.
1784
1786 POAK_Native, // #pragma options align=native
1787 POAK_Natural, // #pragma options align=natural
1788 POAK_Packed, // #pragma options align=packed
1789 POAK_Power, // #pragma options align=power
1790 POAK_Mac68k, // #pragma options align=mac68k
1791 POAK_Reset // #pragma options align=reset
1793
1794 /// ActOnPragmaClangSection - Called on well formed \#pragma clang section
1797 PragmaClangSectionKind SecKind,
1798 StringRef SecName);
1799
1800 /// ActOnPragmaOptionsAlign - Called on well formed \#pragma options align.
1802 SourceLocation PragmaLoc);
1803
1804 /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
1805 void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
1806 StringRef SlotLabel, Expr *Alignment);
1807
1808 /// ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs
1809 /// (unless they are value dependent or type dependent). Returns false
1810 /// and emits a diagnostic if one or more of the arguments could not be
1811 /// folded into a constant.
1814
1818 };
1819
1821 SourceLocation IncludeLoc);
1823
1824 /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
1826
1827 /// ActOnPragmaMSComment - Called on well formed
1828 /// \#pragma comment(kind, "arg").
1830 StringRef Arg);
1831
1832 /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch
1833 void ActOnPragmaDetectMismatch(SourceLocation Loc, StringRef Name,
1834 StringRef Value);
1835
1836 /// Are precise floating point semantics currently enabled?
1838 return !CurFPFeatures.getAllowFPReassociate() &&
1839 !CurFPFeatures.getNoSignedZero() &&
1840 !CurFPFeatures.getAllowReciprocal() &&
1841 !CurFPFeatures.getAllowApproxFunc();
1842 }
1843
1846
1847 /// ActOnPragmaFloatControl - Call on well-formed \#pragma float_control
1850
1851 /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma
1852 /// pointers_to_members(representation method[, general purpose
1853 /// representation]).
1856 SourceLocation PragmaLoc);
1857
1858 /// Called on well formed \#pragma vtordisp().
1861
1862 bool UnifySection(StringRef SectionName, int SectionFlags,
1863 NamedDecl *TheDecl);
1864 bool UnifySection(StringRef SectionName, int SectionFlags,
1865 SourceLocation PragmaSectionLocation);
1866
1867 /// Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg.
1868 void ActOnPragmaMSSeg(SourceLocation PragmaLocation,
1869 PragmaMsStackAction Action,
1870 llvm::StringRef StackSlotLabel,
1871 StringLiteral *SegmentName, llvm::StringRef PragmaName);
1872
1873 /// Called on well formed \#pragma section().
1874 void ActOnPragmaMSSection(SourceLocation PragmaLocation, int SectionFlags,
1875 StringLiteral *SegmentName);
1876
1877 /// Called on well-formed \#pragma init_seg().
1878 void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation,
1879 StringLiteral *SegmentName);
1880
1881 /// Called on well-formed \#pragma alloc_text().
1883 SourceLocation PragmaLocation, StringRef Section,
1884 const SmallVector<std::tuple<IdentifierInfo *, SourceLocation>>
1885 &Functions);
1886
1887 /// ActOnPragmaMSStrictGuardStackCheck - Called on well formed \#pragma
1888 /// strict_gs_check.
1890 PragmaMsStackAction Action,
1891 bool Value);
1892
1893 /// ActOnPragmaUnused - Called on well-formed '\#pragma unused'.
1894 void ActOnPragmaUnused(const Token &Identifier, Scope *curScope,
1895 SourceLocation PragmaLoc);
1896
1898 SourceLocation PragmaLoc,
1901 const IdentifierInfo *Namespace);
1902
1903 /// Called on well-formed '\#pragma clang attribute pop'.
1905 const IdentifierInfo *Namespace);
1906
1907 /// Adds the attributes that have been specified using the
1908 /// '\#pragma clang attribute push' directives to the given declaration.
1909 void AddPragmaAttributes(Scope *S, Decl *D);
1910
1912
1914
1915 /// Called on well formed \#pragma clang optimize.
1916 void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
1917
1918 /// #pragma optimize("[optimization-list]", on | off).
1919 void ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn);
1920
1921 /// Call on well formed \#pragma function.
1922 void
1924 const llvm::SmallVectorImpl<StringRef> &NoBuiltins);
1925
1926 /// Only called on function definitions; if there is a pragma in scope
1927 /// with the effect of a range-based optnone, consider marking the function
1928 /// with attribute optnone.
1930
1931 /// Only called on function definitions; if there is a `#pragma alloc_text`
1932 /// that decides which code section the function should be in, add
1933 /// attribute section to the function.
1935
1936 /// Adds the 'optnone' attribute to the function declaration if there
1937 /// are no conflicts; Loc represents the location causing the 'optnone'
1938 /// attribute to be added (usually because of a pragma).
1940
1941 /// Only called on function definitions; if there is a MSVC #pragma optimize
1942 /// in scope, consider changing the function's attributes based on the
1943 /// optimization list passed to the pragma.
1945
1946 /// Only called on function definitions; if there is a pragma in scope
1947 /// with the effect of a range-based no_builtin, consider marking the function
1948 /// with attribute no_builtin.
1950
1951 /// AddPushedVisibilityAttribute - If '\#pragma GCC visibility' was used,
1952 /// add an appropriate visibility attribute.
1954
1955 /// FreeVisContext - Deallocate and null out VisContext.
1956 void FreeVisContext();
1957
1958 /// ActOnPragmaVisibility - Called on well formed \#pragma GCC visibility... .
1959 void ActOnPragmaVisibility(const IdentifierInfo *VisType,
1960 SourceLocation PragmaLoc);
1961
1962 /// ActOnPragmaFPContract - Called on well formed
1963 /// \#pragma {STDC,OPENCL} FP_CONTRACT and
1964 /// \#pragma clang fp contract
1966
1967 /// Called on well formed
1968 /// \#pragma clang fp reassociate
1969 /// or
1970 /// \#pragma clang fp reciprocal
1972 bool IsEnabled);
1973
1974 /// ActOnPragmaFenvAccess - Called on well formed
1975 /// \#pragma STDC FENV_ACCESS
1976 void ActOnPragmaFEnvAccess(SourceLocation Loc, bool IsEnabled);
1977
1978 /// ActOnPragmaCXLimitedRange - Called on well formed
1979 /// \#pragma STDC CX_LIMITED_RANGE
1982
1983 /// Called on well formed '\#pragma clang fp' that has option 'exceptions'.
1986
1987 /// Called to set constant rounding mode for floating point operations.
1988 void ActOnPragmaFEnvRound(SourceLocation Loc, llvm::RoundingMode);
1989
1990 /// Called to set exception behavior for floating point operations.
1992
1993 /// PushNamespaceVisibilityAttr - Note that we've entered a
1994 /// namespace with a visibility attribute.
1995 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr,
1997
1998 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
1999 /// for '\#pragma GCC visibility' and visibility attributes on namespaces.
2000 void PopPragmaVisibility(bool IsNamespaceEnd, SourceLocation EndLoc);
2001
2002 /// Handles semantic checking for features that are common to all attributes,
2003 /// such as checking whether a parameter was properly specified, or the
2004 /// correct number of arguments were passed, etc. Returns true if the
2005 /// attribute has been diagnosed.
2006 bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A,
2007 bool SkipArgCountCheck = false);
2008 bool checkCommonAttributeFeatures(const Stmt *S, const ParsedAttr &A,
2009 bool SkipArgCountCheck = false);
2010
2011 ///@}
2012
2013 //
2014 //
2015 // -------------------------------------------------------------------------
2016 //
2017 //
2018
2019 /// \name Availability Attribute Handling
2020 /// Implementations are in SemaAvailability.cpp
2021 ///@{
2022
2023public:
2024 /// Issue any -Wunguarded-availability warnings in \c FD
2026
2028
2029 /// Retrieve the current function, if any, that should be analyzed for
2030 /// potential availability violations.
2032
2034 const ObjCInterfaceDecl *UnknownObjCClass,
2035 bool ObjCPropertyAccess,
2036 bool AvoidPartialAvailabilityChecks = false,
2037 ObjCInterfaceDecl *ClassReceiver = nullptr);
2038
2039 ///@}
2040
2041 //
2042 //
2043 // -------------------------------------------------------------------------
2044 //
2045 //
2046
2047 /// \name Bounds Safety
2048 /// Implementations are in SemaBoundsSafety.cpp
2049 ///@{
2050public:
2051 /// Check if applying the specified attribute variant from the "counted by"
2052 /// family of attributes to FieldDecl \p FD is semantically valid. If
2053 /// semantically invalid diagnostics will be emitted explaining the problems.
2054 ///
2055 /// \param FD The FieldDecl to apply the attribute to
2056 /// \param E The count expression on the attribute
2057 /// \param CountInBytes If true the attribute is from the "sized_by" family of
2058 /// attributes. If the false the attribute is from
2059 /// "counted_by" family of attributes.
2060 /// \param OrNull If true the attribute is from the "_or_null" suffixed family
2061 /// of attributes. If false the attribute does not have the
2062 /// suffix.
2063 ///
2064 /// Together \p CountInBytes and \p OrNull decide the attribute variant. E.g.
2065 /// \p CountInBytes and \p OrNull both being true indicates the
2066 /// `counted_by_or_null` attribute.
2067 ///
2068 /// \returns false iff semantically valid.
2069 bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
2070 bool OrNull);
2071
2072 ///@}
2073
2074 //
2075 //
2076 // -------------------------------------------------------------------------
2077 //
2078 //
2079
2080 /// \name Casts
2081 /// Implementations are in SemaCast.cpp
2082 ///@{
2083
2084public:
2086 return CCK == CheckedConversionKind::CStyleCast ||
2089 }
2090
2091 /// ActOnCXXNamedCast - Parse
2092 /// {dynamic,static,reinterpret,const,addrspace}_cast's.
2094 SourceLocation LAngleBracketLoc, Declarator &D,
2095 SourceLocation RAngleBracketLoc,
2096 SourceLocation LParenLoc, Expr *E,
2097 SourceLocation RParenLoc);
2098
2100 TypeSourceInfo *Ty, Expr *E,
2101 SourceRange AngleBrackets, SourceRange Parens);
2102
2104 ExprResult Operand,
2105 SourceLocation RParenLoc);
2106
2108 Expr *Operand, SourceLocation RParenLoc);
2109
2110 // Checks that reinterpret casts don't have undefined behavior.
2111 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
2112 bool IsDereference, SourceRange Range);
2113
2114 // Checks that the vector type should be initialized from a scalar
2115 // by splatting the value rather than populating a single element.
2116 // This is the case for AltiVecVector types as well as with
2117 // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
2118 bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
2119
2120 // Checks if the -faltivec-src-compat=gcc option is specified.
2121 // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
2122 // treated the same way as they are when trying to initialize
2123 // these vectors on gcc (an error is emitted).
2125 QualType SrcTy);
2126
2128 SourceLocation RParenLoc, Expr *Op);
2129
2131 SourceLocation LParenLoc,
2132 Expr *CastExpr,
2133 SourceLocation RParenLoc);
2134
2135 ///@}
2136
2137 //
2138 //
2139 // -------------------------------------------------------------------------
2140 //
2141 //
2142
2143 /// \name Extra Semantic Checking
2144 /// Implementations are in SemaChecking.cpp
2145 ///@{
2146
2147public:
2148 /// Used to change context to isConstantEvaluated without pushing a heavy
2149 /// ExpressionEvaluationContextRecord object.
2151
2155 }
2156
2158 unsigned ByteNo) const;
2159
2161 FAPK_Fixed, // values to format are fixed (no C-style variadic arguments)
2162 FAPK_Variadic, // values to format are passed as variadic arguments
2163 FAPK_VAList, // values to format are passed in a va_list
2164 };
2165
2166 // Used to grab the relevant information from a FormatAttr and a
2167 // FunctionDeclaration.
2169 unsigned FormatIdx;
2172 };
2173
2174 /// Given a FunctionDecl's FormatAttr, attempts to populate the
2175 /// FomatStringInfo parameter with the FormatAttr's correct format_idx and
2176 /// firstDataArg. Returns true when the format fits the function and the
2177 /// FormatStringInfo has been populated.
2178 static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
2179 bool IsVariadic, FormatStringInfo *FSI);
2180
2181 // Used by C++ template instantiation.
2183
2184 /// ConvertVectorExpr - Handle __builtin_convertvector
2186 SourceLocation BuiltinLoc,
2187 SourceLocation RParenLoc);
2188
2202 static FormatStringType GetFormatStringType(const FormatAttr *Format);
2203
2204 bool FormatStringHasSArg(const StringLiteral *FExpr);
2205
2206 /// Check for comparisons of floating-point values using == and !=. Issue a
2207 /// warning if the comparison is not likely to do what the programmer
2208 /// intended.
2210 BinaryOperatorKind Opcode);
2211
2212 /// Register a magic integral constant to be used as a type tag.
2213 void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
2214 uint64_t MagicValue, QualType Type,
2215 bool LayoutCompatible, bool MustBeNull);
2216
2219
2223
2225
2226 /// If true, \c Type should be compared with other expression's types for
2227 /// layout-compatibility.
2228 LLVM_PREFERRED_TYPE(bool)
2230 LLVM_PREFERRED_TYPE(bool)
2231 unsigned MustBeNull : 1;
2232 };
2233
2234 /// A pair of ArgumentKind identifier and magic value. This uniquely
2235 /// identifies the magic value.
2236 typedef std::pair<const IdentifierInfo *, uint64_t> TypeTagMagicValue;
2237
2238 /// Diagnoses the current set of gathered accesses. This typically
2239 /// happens at full expression level. The set is cleared after emitting the
2240 /// diagnostics.
2242
2243 /// This function checks if the expression is in the sef of potentially
2244 /// misaligned members and it is converted to some pointer type T with lower
2245 /// or equal alignment requirements. If so it removes it. This is used when
2246 /// we do not want to diagnose such misaligned access (e.g. in conversions to
2247 /// void*).
2249
2250 /// This function calls Action when it determines that E designates a
2251 /// misaligned member due to the packed attribute. This is used to emit
2252 /// local diagnostics like in reference binding.
2254 Expr *E,
2255 llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
2256 Action);
2257
2258 enum class AtomicArgumentOrder { API, AST };
2260 BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
2261 SourceLocation RParenLoc, MultiExprArg Args,
2264
2265 /// Check to see if a given expression could have '.c_str()' called on it.
2266 bool hasCStrMethod(const Expr *E);
2267
2268 /// Diagnose pointers that are always non-null.
2269 /// \param E the expression containing the pointer
2270 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
2271 /// compared to a null pointer
2272 /// \param IsEqual True when the comparison is equal to a null pointer
2273 /// \param Range Extra SourceRange to highlight in the diagnostic
2276 bool IsEqual, SourceRange Range);
2277
2278 /// CheckParmsForFunctionDef - Check that the parameters of the given
2279 /// function are appropriate for the definition of a function. This
2280 /// takes care of any checks that cannot be performed on the
2281 /// declaration itself, e.g., that the types of each of the function
2282 /// parameters are complete.
2284 bool CheckParameterNames);
2285
2286 /// CheckCastAlign - Implements -Wcast-align, which warns when a
2287 /// pointer cast increases the alignment requirements.
2288 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
2289
2290 /// checkUnsafeAssigns - Check whether +1 expr is being assigned
2291 /// to weak/__unsafe_unretained type.
2293
2294 /// checkUnsafeExprAssigns - Check whether +1 expr is being assigned
2295 /// to weak/__unsafe_unretained expression.
2297
2298 /// Emit \p DiagID if statement located on \p StmtLoc has a suspicious null
2299 /// statement as a \p Body, and it is located on the same line.
2300 ///
2301 /// This helps prevent bugs due to typos, such as:
2302 /// if (condition);
2303 /// do_stuff();
2304 void DiagnoseEmptyStmtBody(SourceLocation StmtLoc, const Stmt *Body,
2305 unsigned DiagID);
2306
2307 /// Warn if a for/while loop statement \p S, which is followed by
2308 /// \p PossibleBody, has a suspicious null statement as a body.
2309 void DiagnoseEmptyLoopBody(const Stmt *S, const Stmt *PossibleBody);
2310
2311 /// DiagnoseSelfMove - Emits a warning if a value is moved to itself.
2312 void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
2313 SourceLocation OpLoc);
2314
2315 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
2323
2324 bool IsLayoutCompatible(QualType T1, QualType T2) const;
2326 const TypeSourceInfo *Derived);
2327
2328 /// CheckFunctionCall - Check a direct function call for various correctness
2329 /// and safety properties not strictly enforced by the C type system.
2330 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
2331 const FunctionProtoType *Proto);
2332
2333 /// \param FPOnly restricts the arguments to floating-point types.
2334 bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res, bool FPOnly = false);
2335 bool BuiltinVectorToScalarMath(CallExpr *TheCall);
2336
2337 void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
2338 const Expr *ThisArg, ArrayRef<const Expr *> Args);
2339
2340 /// Handles the checks for format strings, non-POD arguments to vararg
2341 /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
2342 /// attributes and AArch64 SME attributes.
2343 void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
2344 const Expr *ThisArg, ArrayRef<const Expr *> Args,
2345 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
2346 VariadicCallType CallType);
2347
2348 /// \brief Enforce the bounds of a TCB
2349 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
2350 /// directly calls other functions in the same TCB as marked by the
2351 /// enforce_tcb and enforce_tcb_leaf attributes.
2352 void CheckTCBEnforcement(const SourceLocation CallExprLoc,
2353 const NamedDecl *Callee);
2354
2355 void CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc);
2356
2357 /// BuiltinConstantArg - Handle a check if argument ArgNum of CallExpr
2358 /// TheCall is a constant expression.
2359 bool BuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result);
2360
2361 /// BuiltinConstantArgRange - Handle a check if argument ArgNum of CallExpr
2362 /// TheCall is a constant expression in the range [Low, High].
2363 bool BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High,
2364 bool RangeIsError = true);
2365
2366 /// BuiltinConstantArgMultiple - Handle a check if argument ArgNum of CallExpr
2367 /// TheCall is a constant expression is a multiple of Num..
2368 bool BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
2369 unsigned Multiple);
2370
2371 /// BuiltinConstantArgPower2 - Check if argument ArgNum of TheCall is a
2372 /// constant expression representing a power of 2.
2373 bool BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum);
2374
2375 /// BuiltinConstantArgShiftedByte - Check if argument ArgNum of TheCall is
2376 /// a constant expression representing an arbitrary byte value shifted left by
2377 /// a multiple of 8 bits.
2378 bool BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
2379 unsigned ArgBits);
2380
2381 /// BuiltinConstantArgShiftedByteOr0xFF - Check if argument ArgNum of
2382 /// TheCall is a constant expression representing either a shifted byte value,
2383 /// or a value of the form 0x??FF (i.e. a member of the arithmetic progression
2384 /// 0x00FF, 0x01FF, ..., 0xFFFF). This strange range check is needed for some
2385 /// Arm MVE intrinsics.
2386 bool BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
2387 unsigned ArgBits);
2388
2389 /// Checks that a call expression's argument count is at least the desired
2390 /// number. This is useful when doing custom type-checking on a variadic
2391 /// function. Returns true on error.
2392 bool checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount);
2393
2394 /// Checks that a call expression's argument count is at most the desired
2395 /// number. This is useful when doing custom type-checking on a variadic
2396 /// function. Returns true on error.
2397 bool checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount);
2398
2399 /// Checks that a call expression's argument count is in the desired range.
2400 /// This is useful when doing custom type-checking on a variadic function.
2401 /// Returns true on error.
2402 bool checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
2403 unsigned MaxArgCount);
2404
2405 /// Checks that a call expression's argument count is the desired number.
2406 /// This is useful when doing custom type-checking. Returns true on error.
2407 bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount);
2408
2409 /// Returns true if the argument consists of one contiguous run of 1s with any
2410 /// number of 0s on either side. The 1s are allowed to wrap from LSB to MSB,
2411 /// so 0x000FFF0, 0x0000FFFF, 0xFF0000FF, 0x0 are all runs. 0x0F0F0000 is not,
2412 /// since all 1s are not contiguous.
2413 bool ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum);
2414
2416 bool *ICContext = nullptr,
2417 bool IsListInit = false);
2418
2420 bool CheckForFloatArgs = true);
2422
2423private:
2424 void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
2425 const ArraySubscriptExpr *ASE = nullptr,
2426 bool AllowOnePastEnd = true, bool IndexNegated = false);
2427 void CheckArrayAccess(const Expr *E);
2428
2429 bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
2430 const FunctionProtoType *Proto);
2431
2432 /// Checks function calls when a FunctionDecl or a NamedDecl is not available,
2433 /// such as function pointers returned from functions.
2434 bool CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto);
2435
2436 /// CheckConstructorCall - Check a constructor call for correctness and safety
2437 /// properties not enforced by the C type system.
2438 void CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
2440 const FunctionProtoType *Proto, SourceLocation Loc);
2441
2442 /// Warn if a pointer or reference argument passed to a function points to an
2443 /// object that is less aligned than the parameter. This can happen when
2444 /// creating a typedef with a lower alignment than the original type and then
2445 /// calling functions defined in terms of the original type.
2446 void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
2447 StringRef ParamName, QualType ArgTy, QualType ParamTy);
2448
2449 ExprResult CheckOSLogFormatStringArg(Expr *Arg);
2450
2451 ExprResult CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
2452 CallExpr *TheCall);
2453
2454 bool CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
2455 CallExpr *TheCall);
2456
2457 void checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, CallExpr *TheCall);
2458
2459 /// Check the arguments to '__builtin_va_start' or '__builtin_ms_va_start'
2460 /// for validity. Emit an error and return true on failure; return false
2461 /// on success.
2462 bool BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
2463 bool BuiltinVAStartARMMicrosoft(CallExpr *Call);
2464
2465 /// BuiltinUnorderedCompare - Handle functions like __builtin_isgreater and
2466 /// friends. This is declared to take (...), so we have to check everything.
2467 bool BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID);
2468
2469 /// BuiltinSemaBuiltinFPClassification - Handle functions like
2470 /// __builtin_isnan and friends. This is declared to take (...), so we have
2471 /// to check everything.
2472 bool BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
2473 unsigned BuiltinID);
2474
2475 /// Perform semantic analysis for a call to __builtin_complex.
2476 bool BuiltinComplex(CallExpr *TheCall);
2477 bool BuiltinOSLogFormat(CallExpr *TheCall);
2478
2479 /// BuiltinPrefetch - Handle __builtin_prefetch.
2480 /// This is declared to take (const void*, ...) and can take two
2481 /// optional constant int args.
2482 bool BuiltinPrefetch(CallExpr *TheCall);
2483
2484 /// Handle __builtin_alloca_with_align. This is declared
2485 /// as (size_t, size_t) where the second size_t must be a power of 2 greater
2486 /// than 8.
2487 bool BuiltinAllocaWithAlign(CallExpr *TheCall);
2488
2489 /// BuiltinArithmeticFence - Handle __arithmetic_fence.
2490 bool BuiltinArithmeticFence(CallExpr *TheCall);
2491
2492 /// BuiltinAssume - Handle __assume (MS Extension).
2493 /// __assume does not evaluate its arguments, and should warn if its argument
2494 /// has side effects.
2495 bool BuiltinAssume(CallExpr *TheCall);
2496
2497 /// Handle __builtin_assume_aligned. This is declared
2498 /// as (const void*, size_t, ...) and can take one optional constant int arg.
2499 bool BuiltinAssumeAligned(CallExpr *TheCall);
2500
2501 /// BuiltinLongjmp - Handle __builtin_longjmp(void *env[5], int val).
2502 /// This checks that the target supports __builtin_longjmp and
2503 /// that val is a constant 1.
2504 bool BuiltinLongjmp(CallExpr *TheCall);
2505
2506 /// BuiltinSetjmp - Handle __builtin_setjmp(void *env[5]).
2507 /// This checks that the target supports __builtin_setjmp.
2508 bool BuiltinSetjmp(CallExpr *TheCall);
2509
2510 /// We have a call to a function like __sync_fetch_and_add, which is an
2511 /// overloaded function based on the pointer type of its first argument.
2512 /// The main BuildCallExpr routines have already promoted the types of
2513 /// arguments because all of these calls are prototyped as void(...).
2514 ///
2515 /// This function goes through and does final semantic checking for these
2516 /// builtins, as well as generating any warnings.
2517 ExprResult BuiltinAtomicOverloaded(ExprResult TheCallResult);
2518
2519 /// BuiltinNontemporalOverloaded - We have a call to
2520 /// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
2521 /// overloaded function based on the pointer type of its last argument.
2522 ///
2523 /// This function goes through and does final semantic checking for these
2524 /// builtins.
2525 ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
2526 ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
2528
2529 /// \param FPOnly restricts the arguments to floating-point types.
2530 bool BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly = false);
2531 bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
2532
2533 bool BuiltinNonDeterministicValue(CallExpr *TheCall);
2534
2535 enum BuiltinCountedByRefKind {
2536 AssignmentKind,
2537 InitializerKind,
2538 FunctionArgKind,
2539 ReturnArgKind,
2540 ArraySubscriptKind,
2541 BinaryExprKind,
2542 };
2543
2544 bool CheckInvalidBuiltinCountedByRef(const Expr *E,
2545 BuiltinCountedByRefKind K);
2546 bool BuiltinCountedByRef(CallExpr *TheCall);
2547
2548 // Matrix builtin handling.
2549 ExprResult BuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult);
2550 ExprResult BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
2551 ExprResult CallResult);
2552 ExprResult BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
2553 ExprResult CallResult);
2554
2555 /// CheckFormatArguments - Check calls to printf and scanf (and similar
2556 /// functions) for correct use of format strings.
2557 /// Returns true if a format string has been fully checked.
2558 bool CheckFormatArguments(const FormatAttr *Format,
2559 ArrayRef<const Expr *> Args, bool IsCXXMember,
2560 VariadicCallType CallType, SourceLocation Loc,
2561 SourceRange Range,
2562 llvm::SmallBitVector &CheckedVarArgs);
2563 bool CheckFormatArguments(ArrayRef<const Expr *> Args,
2564 FormatArgumentPassingKind FAPK, unsigned format_idx,
2565 unsigned firstDataArg, FormatStringType Type,
2566 VariadicCallType CallType, SourceLocation Loc,
2567 SourceRange range,
2568 llvm::SmallBitVector &CheckedVarArgs);
2569
2570 void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
2571
2572 /// Warn when using the wrong abs() function.
2573 void CheckAbsoluteValueFunction(const CallExpr *Call,
2574 const FunctionDecl *FDecl);
2575
2576 void CheckMaxUnsignedZero(const CallExpr *Call, const FunctionDecl *FDecl);
2577
2578 /// Check for dangerous or invalid arguments to memset().
2579 ///
2580 /// This issues warnings on known problematic, dangerous or unspecified
2581 /// arguments to the standard 'memset', 'memcpy', 'memmove', and 'memcmp'
2582 /// function calls.
2583 ///
2584 /// \param Call The call expression to diagnose.
2585 void CheckMemaccessArguments(const CallExpr *Call, unsigned BId,
2586 IdentifierInfo *FnName);
2587
2588 // Warn if the user has made the 'size' argument to strlcpy or strlcat
2589 // be the size of the source, instead of the destination.
2590 void CheckStrlcpycatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2591
2592 // Warn on anti-patterns as the 'size' argument to strncat.
2593 // The correct size argument should look like following:
2594 // strncat(dst, src, sizeof(dst) - strlen(dest) - 1);
2595 void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName);
2596
2597 /// Alerts the user that they are attempting to free a non-malloc'd object.
2598 void CheckFreeArguments(const CallExpr *E);
2599
2600 void CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
2601 SourceLocation ReturnLoc, bool isObjCMethod = false,
2602 const AttrVec *Attrs = nullptr,
2603 const FunctionDecl *FD = nullptr);
2604
2605 /// Diagnoses "dangerous" implicit conversions within the given
2606 /// expression (which is a full expression). Implements -Wconversion
2607 /// and -Wsign-compare.
2608 ///
2609 /// \param CC the "context" location of the implicit conversion, i.e.
2610 /// the most location of the syntactic entity requiring the implicit
2611 /// conversion
2612 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
2613
2614 /// CheckBoolLikeConversion - Check conversion of given expression to boolean.
2615 /// Input argument E is a logical expression.
2616 void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
2617
2618 /// Diagnose when expression is an integer constant expression and its
2619 /// evaluation results in integer overflow
2620 void CheckForIntOverflow(const Expr *E);
2621 void CheckUnsequencedOperations(const Expr *E);
2622
2623 /// Perform semantic checks on a completed expression. This will either
2624 /// be a full-expression or a default argument expression.
2625 void CheckCompletedExpr(Expr *E, SourceLocation CheckLoc = SourceLocation(),
2626 bool IsConstexpr = false);
2627
2628 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
2629 Expr *Init);
2630
2631 /// A map from magic value to type information.
2632 std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>>
2633 TypeTagForDatatypeMagicValues;
2634
2635 /// Peform checks on a call of a function with argument_with_type_tag
2636 /// or pointer_with_type_tag attributes.
2637 void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
2638 const ArrayRef<const Expr *> ExprArgs,
2639 SourceLocation CallSiteLoc);
2640
2641 /// Check if we are taking the address of a packed field
2642 /// as this may be a problem if the pointer value is dereferenced.
2643 void CheckAddressOfPackedMember(Expr *rhs);
2644
2645 /// Helper class that collects misaligned member designations and
2646 /// their location info for delayed diagnostics.
2647 struct MisalignedMember {
2648 Expr *E;
2649 RecordDecl *RD;
2650 ValueDecl *MD;
2651 CharUnits Alignment;
2652
2653 MisalignedMember() : E(), RD(), MD() {}
2654 MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
2655 CharUnits Alignment)
2656 : E(E), RD(RD), MD(MD), Alignment(Alignment) {}
2657 explicit MisalignedMember(Expr *E)
2658 : MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
2659
2660 bool operator==(const MisalignedMember &m) { return this->E == m.E; }
2661 };
2662 /// Small set of gathered accesses to potentially misaligned members
2663 /// due to the packed attribute.
2664 SmallVector<MisalignedMember, 4> MisalignedMembers;
2665
2666 /// Adds an expression to the set of gathered misaligned members.
2667 void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
2668 CharUnits Alignment);
2669 ///@}
2670
2671 //
2672 //
2673 // -------------------------------------------------------------------------
2674 //
2675 //
2676
2677 /// \name C++ Coroutines
2678 /// Implementations are in SemaCoroutine.cpp
2679 ///@{
2680
2681public:
2682 /// The C++ "std::coroutine_traits" template, which is defined in
2683 /// <coroutine_traits>
2685
2687 StringRef Keyword);
2691
2694 UnresolvedLookupExpr *Lookup);
2696 Expr *Awaiter, bool IsImplicit = false);
2698 UnresolvedLookupExpr *Lookup);
2701 bool IsImplicit = false);
2706
2707 // As a clang extension, enforces that a non-coroutine function must be marked
2708 // with [[clang::coro_wrapper]] if it returns a type marked with
2709 // [[clang::coro_return_type]].
2710 // Expects that FD is not a coroutine.
2712 /// Lookup 'coroutine_traits' in std namespace and std::experimental
2713 /// namespace. The namespace found is recorded in Namespace.
2715 SourceLocation FuncLoc);
2716 /// Check that the expression co_await promise.final_suspend() shall not be
2717 /// potentially-throwing.
2718 bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
2719
2720 ///@}
2721
2722 //
2723 //
2724 // -------------------------------------------------------------------------
2725 //
2726 //
2727
2728 /// \name C++ Scope Specifiers
2729 /// Implementations are in SemaCXXScopeSpec.cpp
2730 ///@{
2731
2732public:
2733 // Marks SS invalid if it represents an incomplete type.
2735 // Complete an enum decl, maybe without a scope spec.
2737 CXXScopeSpec *SS = nullptr);
2738
2739 /// Compute the DeclContext that is associated with the given type.
2740 ///
2741 /// \param T the type for which we are attempting to find a DeclContext.
2742 ///
2743 /// \returns the declaration context represented by the type T,
2744 /// or NULL if the declaration context cannot be computed (e.g., because it is
2745 /// dependent and not the current instantiation).
2747
2748 /// Compute the DeclContext that is associated with the given
2749 /// scope specifier.
2750 ///
2751 /// \param SS the C++ scope specifier as it appears in the source
2752 ///
2753 /// \param EnteringContext when true, we will be entering the context of
2754 /// this scope specifier, so we can retrieve the declaration context of a
2755 /// class template or class template partial specialization even if it is
2756 /// not the current instantiation.
2757 ///
2758 /// \returns the declaration context represented by the scope specifier @p SS,
2759 /// or NULL if the declaration context cannot be computed (e.g., because it is
2760 /// dependent and not the current instantiation).
2762 bool EnteringContext = false);
2764
2765 /// If the given nested name specifier refers to the current
2766 /// instantiation, return the declaration that corresponds to that
2767 /// current instantiation (C++0x [temp.dep.type]p1).
2768 ///
2769 /// \param NNS a dependent nested name specifier.
2771
2772 /// The parser has parsed a global nested-name-specifier '::'.
2773 ///
2774 /// \param CCLoc The location of the '::'.
2775 ///
2776 /// \param SS The nested-name-specifier, which will be updated in-place
2777 /// to reflect the parsed nested-name-specifier.
2778 ///
2779 /// \returns true if an error occurred, false otherwise.
2781
2782 /// The parser has parsed a '__super' nested-name-specifier.
2783 ///
2784 /// \param SuperLoc The location of the '__super' keyword.
2785 ///
2786 /// \param ColonColonLoc The location of the '::'.
2787 ///
2788 /// \param SS The nested-name-specifier, which will be updated in-place
2789 /// to reflect the parsed nested-name-specifier.
2790 ///
2791 /// \returns true if an error occurred, false otherwise.
2793 SourceLocation ColonColonLoc, CXXScopeSpec &SS);
2794
2795 /// Determines whether the given declaration is an valid acceptable
2796 /// result for name lookup of a nested-name-specifier.
2797 /// \param SD Declaration checked for nested-name-specifier.
2798 /// \param IsExtension If not null and the declaration is accepted as an
2799 /// extension, the pointed variable is assigned true.
2801 bool *CanCorrect = nullptr);
2802
2803 /// If the given nested-name-specifier begins with a bare identifier
2804 /// (e.g., Base::), perform name lookup for that identifier as a
2805 /// nested-name-specifier within the given scope, and return the result of
2806 /// that name lookup.
2808
2809 /// Keeps information about an identifier in a nested-name-spec.
2810 ///
2812 /// The type of the object, if we're parsing nested-name-specifier in
2813 /// a member access expression.
2815
2816 /// The identifier preceding the '::'.
2818
2819 /// The location of the identifier.
2821
2822 /// The location of the '::'.
2824
2825 /// Creates info object for the most typical case.
2827 SourceLocation ColonColonLoc,
2828 ParsedType ObjectType = ParsedType())
2829 : ObjectType(ObjectType), Identifier(II), IdentifierLoc(IdLoc),
2830 CCLoc(ColonColonLoc) {}
2831
2833 SourceLocation ColonColonLoc, QualType ObjectType)
2834 : ObjectType(ParsedType::make(ObjectType)), Identifier(II),
2835 IdentifierLoc(IdLoc), CCLoc(ColonColonLoc) {}
2836 };
2837
2838 /// Build a new nested-name-specifier for "identifier::", as described
2839 /// by ActOnCXXNestedNameSpecifier.
2840 ///
2841 /// \param S Scope in which the nested-name-specifier occurs.
2842 /// \param IdInfo Parser information about an identifier in the
2843 /// nested-name-spec.
2844 /// \param EnteringContext If true, enter the context specified by the
2845 /// nested-name-specifier.
2846 /// \param SS Optional nested name specifier preceding the identifier.
2847 /// \param ScopeLookupResult Provides the result of name lookup within the
2848 /// scope of the nested-name-specifier that was computed at template
2849 /// definition time.
2850 /// \param ErrorRecoveryLookup Specifies if the method is called to improve
2851 /// error recovery and what kind of recovery is performed.
2852 /// \param IsCorrectedToColon If not null, suggestion of replace '::' -> ':'
2853 /// are allowed. The bool value pointed by this parameter is set to
2854 /// 'true' if the identifier is treated as if it was followed by ':',
2855 /// not '::'.
2856 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2857 ///
2858 /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in
2859 /// that it contains an extra parameter \p ScopeLookupResult, which provides
2860 /// the result of name lookup within the scope of the nested-name-specifier
2861 /// that was computed at template definition time.
2862 ///
2863 /// If ErrorRecoveryLookup is true, then this call is used to improve error
2864 /// recovery. This means that it should not emit diagnostics, it should
2865 /// just return true on failure. It also means it should only return a valid
2866 /// scope if it *knows* that the result is correct. It should not return in a
2867 /// dependent context, for example. Nor will it extend \p SS with the scope
2868 /// specifier.
2869 bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2870 bool EnteringContext, CXXScopeSpec &SS,
2871 NamedDecl *ScopeLookupResult,
2872 bool ErrorRecoveryLookup,
2873 bool *IsCorrectedToColon = nullptr,
2874 bool OnlyNamespace = false);
2875
2876 /// The parser has parsed a nested-name-specifier 'identifier::'.
2877 ///
2878 /// \param S The scope in which this nested-name-specifier occurs.
2879 ///
2880 /// \param IdInfo Parser information about an identifier in the
2881 /// nested-name-spec.
2882 ///
2883 /// \param EnteringContext Whether we're entering the context nominated by
2884 /// this nested-name-specifier.
2885 ///
2886 /// \param SS The nested-name-specifier, which is both an input
2887 /// parameter (the nested-name-specifier before this type) and an
2888 /// output parameter (containing the full nested-name-specifier,
2889 /// including this new type).
2890 ///
2891 /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':'
2892 /// are allowed. The bool value pointed by this parameter is set to 'true'
2893 /// if the identifier is treated as if it was followed by ':', not '::'.
2894 ///
2895 /// \param OnlyNamespace If true, only considers namespaces in lookup.
2896 ///
2897 /// \returns true if an error occurred, false otherwise.
2898 bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
2899 bool EnteringContext, CXXScopeSpec &SS,
2900 bool *IsCorrectedToColon = nullptr,
2901 bool OnlyNamespace = false);
2902
2903 /// The parser has parsed a nested-name-specifier
2904 /// 'template[opt] template-name < template-args >::'.
2905 ///
2906 /// \param S The scope in which this nested-name-specifier occurs.
2907 ///
2908 /// \param SS The nested-name-specifier, which is both an input
2909 /// parameter (the nested-name-specifier before this type) and an
2910 /// output parameter (containing the full nested-name-specifier,
2911 /// including this new type).
2912 ///
2913 /// \param TemplateKWLoc the location of the 'template' keyword, if any.
2914 /// \param TemplateName the template name.
2915 /// \param TemplateNameLoc The location of the template name.
2916 /// \param LAngleLoc The location of the opening angle bracket ('<').
2917 /// \param TemplateArgs The template arguments.
2918 /// \param RAngleLoc The location of the closing angle bracket ('>').
2919 /// \param CCLoc The location of the '::'.
2920 ///
2921 /// \param EnteringContext Whether we're entering the context of the
2922 /// nested-name-specifier.
2923 ///
2924 ///
2925 /// \returns true if an error occurred, false otherwise.
2927 Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
2928 TemplateTy TemplateName, SourceLocation TemplateNameLoc,
2929 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
2930 SourceLocation RAngleLoc, SourceLocation CCLoc, bool EnteringContext);
2931
2933 SourceLocation ColonColonLoc);
2934
2936 const DeclSpec &DS,
2937 SourceLocation ColonColonLoc,
2938 QualType Type);
2939
2940 /// IsInvalidUnlessNestedName - This method is used for error recovery
2941 /// purposes to determine whether the specified identifier is only valid as
2942 /// a nested name specifier, for example a namespace name. It is
2943 /// conservatively correct to always return false from this method.
2944 ///
2945 /// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
2947 NestedNameSpecInfo &IdInfo,
2948 bool EnteringContext);
2949
2950 /// Given a C++ nested-name-specifier, produce an annotation value
2951 /// that the parser can use later to reconstruct the given
2952 /// nested-name-specifier.
2953 ///
2954 /// \param SS A nested-name-specifier.
2955 ///
2956 /// \returns A pointer containing all of the information in the
2957 /// nested-name-specifier \p SS.
2959
2960 /// Given an annotation pointer for a nested-name-specifier, restore
2961 /// the nested-name-specifier structure.
2962 ///
2963 /// \param Annotation The annotation pointer, produced by
2964 /// \c SaveNestedNameSpecifierAnnotation().
2965 ///
2966 /// \param AnnotationRange The source range corresponding to the annotation.
2967 ///
2968 /// \param SS The nested-name-specifier that will be updated with the contents
2969 /// of the annotation pointer.
2970 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
2971 SourceRange AnnotationRange,
2972 CXXScopeSpec &SS);
2973
2974 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2975
2976 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2977 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2978 /// After this method is called, according to [C++ 3.4.3p3], names should be
2979 /// looked up in the declarator-id's scope, until the declarator is parsed and
2980 /// ActOnCXXExitDeclaratorScope is called.
2981 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2983
2984 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2985 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2986 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2987 /// Used to indicate that names should revert to being looked up in the
2988 /// defining scope.
2990
2991 ///@}
2992
2993 //
2994 //
2995 // -------------------------------------------------------------------------
2996 //
2997 //
2998
2999 /// \name Declarations
3000 /// Implementations are in SemaDecl.cpp
3001 ///@{
3002
3003public:
3005
3006 /// The index of the first InventedParameterInfo that refers to the current
3007 /// context.
3009
3010 /// A RAII object to temporarily push a declaration context.
3012 private:
3013 Sema &S;
3014 DeclContext *SavedContext;
3015 ProcessingContextState SavedContextState;
3016 QualType SavedCXXThisTypeOverride;
3017 unsigned SavedFunctionScopesStart;
3018 unsigned SavedInventedParameterInfosStart;
3019
3020 public:
3021 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
3022 : S(S), SavedContext(S.CurContext),
3023 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
3024 SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
3025 SavedFunctionScopesStart(S.FunctionScopesStart),
3026 SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
3027 assert(ContextToPush && "pushing null context");
3028 S.CurContext = ContextToPush;
3029 if (NewThisContext)
3030 S.CXXThisTypeOverride = QualType();
3031 // Any saved FunctionScopes do not refer to this context.
3032 S.FunctionScopesStart = S.FunctionScopes.size();
3033 S.InventedParameterInfosStart = S.InventedParameterInfos.size();
3034 }
3035
3036 void pop() {
3037 if (!SavedContext)
3038 return;
3039 S.CurContext = SavedContext;
3040 S.DelayedDiagnostics.popUndelayed(SavedContextState);
3041 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
3042 S.FunctionScopesStart = SavedFunctionScopesStart;
3043 S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
3044 SavedContext = nullptr;
3045 }
3046
3047 ~ContextRAII() { pop(); }
3048 };
3049
3050 void DiagnoseInvalidJumps(Stmt *Body);
3051
3052 /// The function definitions which were renamed as part of typo-correction
3053 /// to match their respective declarations. We want to keep track of them
3054 /// to ensure that we don't emit a "redefinition" error if we encounter a
3055 /// correctly named definition after the renamed definition.
3057
3058 /// A cache of the flags available in enumerations with the flag_bits
3059 /// attribute.
3060 mutable llvm::DenseMap<const EnumDecl *, llvm::APInt> FlagBitsCache;
3061
3062 /// WeakUndeclaredIdentifiers - Identifiers contained in \#pragma weak before
3063 /// declared. Rare. May alias another identifier, declared or undeclared.
3064 ///
3065 /// For aliases, the target identifier is used as a key for eventual
3066 /// processing when the target is declared. For the single-identifier form,
3067 /// the sole identifier is used as the key. Each entry is a `SetVector`
3068 /// (ordered by parse order) of aliases (identified by the alias name) in case
3069 /// of multiple aliases to the same undeclared identifier.
3070 llvm::MapVector<
3072 llvm::SetVector<
3074 llvm::SmallDenseSet<WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly>>>
3076
3077 /// ExtnameUndeclaredIdentifiers - Identifiers contained in
3078 /// \#pragma redefine_extname before declared. Used in Solaris system headers
3079 /// to define functions that occur in multiple standards to call the version
3080 /// in the currently selected standard.
3081 llvm::DenseMap<IdentifierInfo *, AsmLabelAttr *> ExtnameUndeclaredIdentifiers;
3082
3083 /// Set containing all typedefs that are likely unused.
3086
3090
3091 /// The set of file scoped decls seen so far that have not been used
3092 /// and must warn if not used. Only contains the first declaration.
3094
3098
3099 /// All the tentative definitions encountered in the TU.
3101
3102 /// All the external declarations encoutered and used in the TU.
3104
3105 /// Generally null except when we temporarily switch decl contexts,
3106 /// like in \see SemaObjC::ActOnObjCTemporaryExitContainerContext.
3108
3109 /// Is the module scope we are in a C++ Header Unit?
3111 return ModuleScopes.empty() ? false
3112 : ModuleScopes.back().Module->isHeaderUnit();
3113 }
3114
3115 /// Get the module owning an entity.
3116 Module *getOwningModule(const Decl *Entity) {
3117 return Entity->getOwningModule();
3118 }
3119
3120 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
3121
3122 /// If the identifier refers to a type name within this scope,
3123 /// return the declaration of that type.
3124 ///
3125 /// This routine performs ordinary name lookup of the identifier II
3126 /// within the given scope, with optional C++ scope specifier SS, to
3127 /// determine whether the name refers to a type. If so, returns an
3128 /// opaque pointer (actually a QualType) corresponding to that
3129 /// type. Otherwise, returns NULL.
3131 Scope *S, CXXScopeSpec *SS = nullptr,
3132 bool isClassName = false, bool HasTrailingDot = false,
3133 ParsedType ObjectType = nullptr,
3134 bool IsCtorOrDtorName = false,
3135 bool WantNontrivialTypeSourceInfo = false,
3136 bool IsClassTemplateDeductionContext = true,
3137 ImplicitTypenameContext AllowImplicitTypename =
3139 IdentifierInfo **CorrectedII = nullptr);
3140
3141 /// isTagName() - This method is called *for error recovery purposes only*
3142 /// to determine if the specified name is a valid tag name ("struct foo"). If
3143 /// so, this returns the TST for the tag corresponding to it (TST_enum,
3144 /// TST_union, TST_struct, TST_interface, TST_class). This is used to
3145 /// diagnose cases in C where the user forgot to specify the tag.
3147
3148 /// isMicrosoftMissingTypename - In Microsoft mode, within class scope,
3149 /// if a CXXScopeSpec's type is equal to the type of one of the base classes
3150 /// then downgrade the missing typename error to a warning.
3151 /// This is needed for MSVC compatibility; Example:
3152 /// @code
3153 /// template<class T> class A {
3154 /// public:
3155 /// typedef int TYPE;
3156 /// };
3157 /// template<class T> class B : public A<T> {
3158 /// public:
3159 /// A<T>::TYPE a; // no typename required because A<T> is a base class.
3160 /// };
3161 /// @endcode
3162 bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
3164 Scope *S, CXXScopeSpec *SS,
3165 ParsedType &SuggestedType,
3166 bool IsTemplateName = false);
3167
3168 /// Attempt to behave like MSVC in situations where lookup of an unqualified
3169 /// type name has failed in a dependent context. In these situations, we
3170 /// automatically form a DependentTypeName that will retry lookup in a related
3171 /// scope during instantiation.
3173 SourceLocation NameLoc,
3174 bool IsTemplateTypeArg);
3175
3176 /// Describes the result of the name lookup and resolution performed
3177 /// by \c ClassifyName().
3179 /// This name is not a type or template in this context, but might be
3180 /// something else.
3182 /// Classification failed; an error has been produced.
3184 /// The name has been typo-corrected to a keyword.
3186 /// The name was classified as a type.
3188 /// The name was classified as a specific non-type, non-template
3189 /// declaration. ActOnNameClassifiedAsNonType should be called to
3190 /// convert the declaration to an expression.
3192 /// The name was classified as an ADL-only function name.
3193 /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
3194 /// result to an expression.
3196 /// The name denotes a member of a dependent type that could not be
3197 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
3198 /// convert the result to an expression.
3200 /// The name was classified as an overload set, and an expression
3201 /// representing that overload set has been formed.
3202 /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
3203 /// expression referencing the overload set.
3205 /// The name was classified as a template whose specializations are types.
3207 /// The name was classified as a variable template name.
3209 /// The name was classified as a function template name.
3211 /// The name was classified as an ADL-only function template name.
3213 /// The name was classified as a concept name.
3215 };
3216
3219 union {
3224 };
3225
3227
3228 public:
3230
3231 NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
3232
3233 static NameClassification Error() { return NameClassification(NC_Error); }
3234
3236 return NameClassification(NC_Unknown);
3237 }
3238
3240 NameClassification Result(NC_OverloadSet);
3241 Result.Expr = E;
3242 return Result;
3243 }
3244
3246 NameClassification Result(NC_NonType);
3247 Result.NonTypeDecl = D;
3248 return Result;
3249 }
3250
3252 return NameClassification(NC_UndeclaredNonType);
3253 }
3254
3256 return NameClassification(NC_DependentNonType);
3257 }
3258
3260 NameClassification Result(NC_TypeTemplate);
3261 Result.Template = Name;
3262 return Result;
3263 }
3264
3266 NameClassification Result(NC_VarTemplate);
3267 Result.Template = Name;
3268 return Result;
3269 }
3270
3272 NameClassification Result(NC_FunctionTemplate);
3273 Result.Template = Name;
3274 return Result;
3275 }
3276
3278 NameClassification Result(NC_Concept);
3279 Result.Template = Name;
3280 return Result;
3281 }
3282
3284 NameClassification Result(NC_UndeclaredTemplate);
3285 Result.Template = Name;
3286 return Result;
3287 }
3288
3290
3292 assert(Kind == NC_OverloadSet);
3293 return Expr;
3294 }
3295
3297 assert(Kind == NC_Type);
3298 return Type;
3299 }
3300
3302 assert(Kind == NC_NonType);
3303 return NonTypeDecl;
3304 }
3305
3307 assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
3308 Kind == NC_VarTemplate || Kind == NC_Concept ||
3309 Kind == NC_UndeclaredTemplate);
3310 return Template;
3311 }
3312
3314 switch (Kind) {
3315 case NC_TypeTemplate:
3316 return TNK_Type_template;
3317 case NC_FunctionTemplate:
3318 return TNK_Function_template;
3319 case NC_VarTemplate:
3320 return TNK_Var_template;
3321 case NC_Concept:
3322 return TNK_Concept_template;
3323 case NC_UndeclaredTemplate:
3325 default:
3326 llvm_unreachable("unsupported name classification.");
3327 }
3328 }
3329 };
3330
3331 /// Perform name lookup on the given name, classifying it based on
3332 /// the results of name lookup and the following token.
3333 ///
3334 /// This routine is used by the parser to resolve identifiers and help direct
3335 /// parsing. When the identifier cannot be found, this routine will attempt
3336 /// to correct the typo and classify based on the resulting name.
3337 ///
3338 /// \param S The scope in which we're performing name lookup.
3339 ///
3340 /// \param SS The nested-name-specifier that precedes the name.
3341 ///
3342 /// \param Name The identifier. If typo correction finds an alternative name,
3343 /// this pointer parameter will be updated accordingly.
3344 ///
3345 /// \param NameLoc The location of the identifier.
3346 ///
3347 /// \param NextToken The token following the identifier. Used to help
3348 /// disambiguate the name.
3349 ///
3350 /// \param CCC The correction callback, if typo correction is desired.
3351 NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS,
3352 IdentifierInfo *&Name, SourceLocation NameLoc,
3353 const Token &NextToken,
3354 CorrectionCandidateCallback *CCC = nullptr);
3355
3356 /// Act on the result of classifying a name as an undeclared (ADL-only)
3357 /// non-type declaration.
3359 SourceLocation NameLoc);
3360 /// Act on the result of classifying a name as an undeclared member of a
3361 /// dependent base class.
3363 IdentifierInfo *Name,
3364 SourceLocation NameLoc,
3365 bool IsAddressOfOperand);
3366 /// Act on the result of classifying a name as a specific non-type
3367 /// declaration.
3370 SourceLocation NameLoc,
3371 const Token &NextToken);
3372 /// Act on the result of classifying a name as an overload set.
3374
3375 /// Describes the detailed kind of a template name. Used in diagnostics.
3382 Concept,
3384 };
3387
3388 /// Determine whether it's plausible that E was intended to be a
3389 /// template-name.
3391 if (!getLangOpts().CPlusPlus || E.isInvalid())
3392 return false;
3393 Dependent = false;
3394 if (auto *DRE = dyn_cast<DeclRefExpr>(E.get()))
3395 return !DRE->hasExplicitTemplateArgs();
3396 if (auto *ME = dyn_cast<MemberExpr>(E.get()))
3397 return !ME->hasExplicitTemplateArgs();
3398 Dependent = true;
3399 if (auto *DSDRE = dyn_cast<DependentScopeDeclRefExpr>(E.get()))
3400 return !DSDRE->hasExplicitTemplateArgs();
3401 if (auto *DSME = dyn_cast<CXXDependentScopeMemberExpr>(E.get()))
3402 return !DSME->hasExplicitTemplateArgs();
3403 // Any additional cases recognized here should also be handled by
3404 // diagnoseExprIntendedAsTemplateName.
3405 return false;
3406 }
3407
3409
3411
3413 MultiTemplateParamsArg TemplateParameterLists);
3414
3415 /// Attempt to fold a variable-sized type to a constant-sized type, returning
3416 /// true if we were successful.
3419 unsigned FailedFoldDiagID);
3420
3421 /// Register the given locally-scoped extern "C" declaration so
3422 /// that it can be found later for redeclarations. We include any extern "C"
3423 /// declaration that is not visible in the translation unit here, not just
3424 /// function-scope declarations.
3426
3427 /// DiagnoseClassNameShadow - Implement C++ [class.mem]p13:
3428 /// If T is the name of a class, then each of the following shall have a
3429 /// name different from T:
3430 /// - every static data member of class T;
3431 /// - every member function of class T
3432 /// - every member of class T that is itself a type;
3433 /// \returns true if the declaration name violates these rules.
3435
3436 /// Diagnose a declaration whose declarator-id has the given
3437 /// nested-name-specifier.
3438 ///
3439 /// \param SS The nested-name-specifier of the declarator-id.
3440 ///
3441 /// \param DC The declaration context to which the nested-name-specifier
3442 /// resolves.
3443 ///
3444 /// \param Name The name of the entity being declared.
3445 ///
3446 /// \param Loc The location of the name of the entity being declared.
3447 ///
3448 /// \param IsMemberSpecialization Whether we are declaring a member
3449 /// specialization.
3450 ///
3451 /// \param TemplateId The template-id, if any.
3452 ///
3453 /// \returns true if we cannot safely recover from this error, false
3454 /// otherwise.
3457 TemplateIdAnnotation *TemplateId,
3458 bool IsMemberSpecialization);
3459
3461
3462 bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key);
3463
3464 /// Diagnose function specifiers on a declaration of an identifier that
3465 /// does not identify a function.
3466 void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
3467
3468 /// Return the declaration shadowed by the given typedef \p D, or null
3469 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3471 const LookupResult &R);
3472
3473 /// Return the declaration shadowed by the given variable \p D, or null
3474 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3476
3477 /// Return the declaration shadowed by the given variable \p D, or null
3478 /// if it doesn't shadow any declaration or shadowing warnings are disabled.
3480 const LookupResult &R);
3481 /// Diagnose variable or built-in function shadowing. Implements
3482 /// -Wshadow.
3483 ///
3484 /// This method is called whenever a VarDecl is added to a "useful"
3485 /// scope.
3486 ///
3487 /// \param ShadowedDecl the declaration that is shadowed by the given variable
3488 /// \param R the lookup of the name
3489 void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
3490 const LookupResult &R);
3491
3492 /// Check -Wshadow without the advantage of a previous lookup.
3493 void CheckShadow(Scope *S, VarDecl *D);
3494
3495 /// Warn if 'E', which is an expression that is about to be modified, refers
3496 /// to a shadowing declaration.
3498
3499 /// Diagnose shadowing for variables shadowed in the lambda record \p LambdaRD
3500 /// when these variables are captured by the lambda.
3502
3503 void handleTagNumbering(const TagDecl *Tag, Scope *TagScope);
3504 void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
3505 TypedefNameDecl *NewTD);
3508 TypeSourceInfo *TInfo,
3510
3511 /// ActOnTypedefNameDecl - Perform semantic checking for a declaration which
3512 /// declares a typedef-name, either using the 'typedef' type specifier or via
3513 /// a C++0x [dcl.typedef]p2 alias-declaration: 'using T = A;'.
3515 LookupResult &Previous, bool &Redeclaration);
3517 TypeSourceInfo *TInfo,
3519 MultiTemplateParamsArg TemplateParamLists,
3520 bool &AddToScope,
3522
3523 /// Perform semantic checking on a newly-created variable
3524 /// declaration.
3525 ///
3526 /// This routine performs all of the type-checking required for a
3527 /// variable declaration once it has been built. It is used both to
3528 /// check variables after they have been parsed and their declarators
3529 /// have been translated into a declaration, and to check variables
3530 /// that have been instantiated from a template.
3531 ///
3532 /// Sets NewVD->isInvalidDecl() if an error was encountered.
3533 ///
3534 /// Returns true if the variable declaration is a redeclaration.
3535 bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
3536 void CheckVariableDeclarationType(VarDecl *NewVD);
3537 void CheckCompleteVariableDeclaration(VarDecl *VD);
3538
3539 NamedDecl *ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
3540 TypeSourceInfo *TInfo,
3541 LookupResult &Previous,
3542 MultiTemplateParamsArg TemplateParamLists,
3543 bool &AddToScope);
3544
3545 /// AddOverriddenMethods - See if a method overrides any in the base classes,
3546 /// and if so, check that it's a valid override and remember it.
3547 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
3548
3549 /// Perform semantic checking of a new function declaration.
3550 ///
3551 /// Performs semantic analysis of the new function declaration
3552 /// NewFD. This routine performs all semantic checking that does not
3553 /// require the actual declarator involved in the declaration, and is
3554 /// used both for the declaration of functions as they are parsed
3555 /// (called via ActOnDeclarator) and for the declaration of functions
3556 /// that have been instantiated via C++ template instantiation (called
3557 /// via InstantiateDecl).
3558 ///
3559 /// \param IsMemberSpecialization whether this new function declaration is
3560 /// a member specialization (that replaces any definition provided by the
3561 /// previous declaration).
3562 ///
3563 /// This sets NewFD->isInvalidDecl() to true if there was an error.
3564 ///
3565 /// \returns true if the function declaration is a redeclaration.
3566 bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
3567 LookupResult &Previous,
3568 bool IsMemberSpecialization, bool DeclIsDefn);
3569
3570 /// Checks if the new declaration declared in dependent context must be
3571 /// put in the same redeclaration chain as the specified declaration.
3572 ///
3573 /// \param D Declaration that is checked.
3574 /// \param PrevDecl Previous declaration found with proper lookup method for
3575 /// the same declaration name.
3576 /// \returns True if D must be added to the redeclaration chain which PrevDecl
3577 /// belongs to.
3578 bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
3579
3580 /// Determines if we can perform a correct type check for \p D as a
3581 /// redeclaration of \p PrevDecl. If not, we can generally still perform a
3582 /// best-effort check.
3583 ///
3584 /// \param NewD The new declaration.
3585 /// \param OldD The old declaration.
3586 /// \param NewT The portion of the type of the new declaration to check.
3587 /// \param OldT The portion of the type of the old declaration to check.
3588 bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD,
3589 QualType NewT, QualType OldT);
3590 void CheckMain(FunctionDecl *FD, const DeclSpec &D);
3591 void CheckMSVCRTEntryPoint(FunctionDecl *FD);
3592
3593 /// Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a
3594 /// containing class. Otherwise it will return implicit SectionAttr if the
3595 /// function is a definition and there is an active value on CodeSegStack
3596 /// (from the current #pragma code-seg value).
3597 ///
3598 /// \param FD Function being declared.
3599 /// \param IsDefinition Whether it is a definition or just a declaration.
3600 /// \returns A CodeSegAttr or SectionAttr to apply to the function or
3601 /// nullptr if no attribute should be added.
3602 Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD,
3603 bool IsDefinition);
3604
3605 /// Common checks for a parameter-declaration that should apply to both
3606 /// function parameters and non-type template parameters.
3607 void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D);
3608
3609 /// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
3610 /// to introduce parameters into function prototype scope.
3611 Decl *ActOnParamDeclarator(Scope *S, Declarator &D,
3612 SourceLocation ExplicitThisLoc = {});
3613
3614 /// Synthesizes a variable for a parameter arising from a
3615 /// typedef.
3616 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc,
3617 QualType T);
3618 ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc,
3619 SourceLocation NameLoc,
3620 const IdentifierInfo *Name, QualType T,
3621 TypeSourceInfo *TSInfo, StorageClass SC);
3622
3623 // Contexts where using non-trivial C union types can be disallowed. This is
3624 // passed to err_non_trivial_c_union_in_invalid_context.
3626 // Function parameter.
3628 // Function return.
3630 // Default-initialized object.
3632 // Variable with automatic storage duration.
3634 // Initializer expression that might copy from another object.
3636 // Assignment.
3638 // Compound literal.
3640 // Block capture.
3642 // lvalue-to-rvalue conversion of volatile type.
3644 };
3645
3646 /// Emit diagnostics if the initializer or any of its explicit or
3647 /// implicitly-generated subexpressions require copying or
3648 /// default-initializing a type that is or contains a C union type that is
3649 /// non-trivial to copy or default-initialize.
3651
3652 // These flags are passed to checkNonTrivialCUnion.
3657 };
3658
3659 /// Emit diagnostics if a non-trivial C union type or a struct that contains
3660 /// a non-trivial C union is used in an invalid context.
3662 NonTrivialCUnionContext UseContext,
3663 unsigned NonTrivialKind);
3664
3665 /// AddInitializerToDecl - Adds the initializer Init to the
3666 /// declaration dcl. If DirectInit is true, this is C++ direct
3667 /// initialization rather than copy initialization.
3668 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
3669 void ActOnUninitializedDecl(Decl *dcl);
3670
3671 /// ActOnInitializerError - Given that there was an error parsing an
3672 /// initializer for the given declaration, try to at least re-establish
3673 /// invariants such as whether a variable's type is either dependent or
3674 /// complete.
3675 void ActOnInitializerError(Decl *Dcl);
3676
3679 IdentifierInfo *Ident,
3680 ParsedAttributes &Attrs);
3681
3682 /// Check if VD needs to be dllexport/dllimport due to being in a
3683 /// dllexport/import function.
3686
3687 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
3688 /// any semantic actions necessary after any initializer has been attached.
3689 void FinalizeDeclaration(Decl *D);
3691 ArrayRef<Decl *> Group);
3692
3693 /// BuildDeclaratorGroup - convert a list of declarations into a declaration
3694 /// group, performing any necessary semantic checking.
3696
3697 /// Should be called on all declarations that might have attached
3698 /// documentation comments.
3701
3702 enum class FnBodyKind {
3703 /// C++26 [dcl.fct.def.general]p1
3704 /// function-body:
3705 /// ctor-initializer[opt] compound-statement
3706 /// function-try-block
3707 Other,
3708 /// = default ;
3709 Default,
3710 /// deleted-function-body
3711 ///
3712 /// deleted-function-body:
3713 /// = delete ;
3714 /// = delete ( unevaluated-string ) ;
3715 Delete
3716 };
3717
3719 SourceLocation LocAfterDecls);
3721 FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = nullptr,
3722 SkipBodyInfo *SkipBody = nullptr);
3724 MultiTemplateParamsArg TemplateParamLists,
3725 SkipBodyInfo *SkipBody = nullptr,
3726 FnBodyKind BodyKind = FnBodyKind::Other);
3728 SkipBodyInfo *SkipBody = nullptr,
3729 FnBodyKind BodyKind = FnBodyKind::Other);
3731
3732 /// Determine whether we can delay parsing the body of a function or
3733 /// function template until it is used, assuming we don't care about emitting
3734 /// code for that function.
3735 ///
3736 /// This will be \c false if we may need the body of the function in the
3737 /// middle of parsing an expression (where it's impractical to switch to
3738 /// parsing a different function), for instance, if it's constexpr in C++11
3739 /// or has an 'auto' return type in C++14. These cases are essentially bugs.
3740 bool canDelayFunctionBody(const Declarator &D);
3741
3742 /// Determine whether we can skip parsing the body of a function
3743 /// definition, assuming we don't care about analyzing its body or emitting
3744 /// code for that function.
3745 ///
3746 /// This will be \c false only if we may need the body of the function in
3747 /// order to parse the rest of the program (for instance, if it is
3748 /// \c constexpr in C++11 or has an 'auto' return type in C++14).
3749 bool canSkipFunctionBody(Decl *D);
3750
3751 /// Given the set of return statements within a function body,
3752 /// compute the variables that are subject to the named return value
3753 /// optimization.
3754 ///
3755 /// Each of the variables that is subject to the named return value
3756 /// optimization will be marked as NRVO variables in the AST, and any
3757 /// return statement that has a marked NRVO variable as its NRVO candidate can
3758 /// use the named return value optimization.
3759 ///
3760 /// This function applies a very simplistic algorithm for NRVO: if every
3761 /// return statement in the scope of a variable has the same NRVO candidate,
3762 /// that candidate is an NRVO variable.
3765 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
3768
3769 /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an
3770 /// attribute for which parsing is delayed.
3772
3773 /// Diagnose any unused parameters in the given sequence of
3774 /// ParmVarDecl pointers.
3776
3777 /// Diagnose whether the size of parameters or return value of a
3778 /// function or obj-c method definition is pass-by-value and larger than a
3779 /// specified threshold.
3780 void
3782 QualType ReturnTy, NamedDecl *D);
3783
3785 SourceLocation RParenLoc);
3786
3789
3791
3792 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3793 /// no declarator (e.g. "struct foo;") is parsed.
3795 const ParsedAttributesView &DeclAttrs,
3796 RecordDecl *&AnonRecord);
3797
3798 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
3799 /// no declarator (e.g. "struct foo;") is parsed. It also accepts template
3800 /// parameters to cope with template friend declarations.
3802 const ParsedAttributesView &DeclAttrs,
3803 MultiTemplateParamsArg TemplateParams,
3804 bool IsExplicitInstantiation,
3805 RecordDecl *&AnonRecord,
3806 SourceLocation EllipsisLoc = {});
3807
3808 /// BuildAnonymousStructOrUnion - Handle the declaration of an
3809 /// anonymous structure or union. Anonymous unions are a C++ feature
3810 /// (C++ [class.union]) and a C11 feature; anonymous structures
3811 /// are a C11 feature and GNU C++ extension.
3812 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS,
3813 RecordDecl *Record,
3814 const PrintingPolicy &Policy);
3815
3816 /// Called once it is known whether
3817 /// a tag declaration is an anonymous union or struct.
3819
3820 /// Emit diagnostic warnings for placeholder members.
3821 /// We can only do that after the class is fully constructed,
3822 /// as anonymous union/structs can insert placeholders
3823 /// in their parent scope (which might be a Record).
3825
3826 /// BuildMicrosoftCAnonymousStruct - Handle the declaration of an
3827 /// Microsoft C anonymous structure.
3828 /// Ref: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx
3829 /// Example:
3830 ///
3831 /// struct A { int a; };
3832 /// struct B { struct A; int b; };
3833 ///
3834 /// void foo() {
3835 /// B var;
3836 /// var.a = 3;
3837 /// }
3838 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
3839 RecordDecl *Record);
3840
3841 /// Common ways to introduce type names without a tag for use in diagnostics.
3842 /// Keep in sync with err_tag_reference_non_tag.
3853 };
3854
3855 /// Given a non-tag type declaration, returns an enum useful for indicating
3856 /// what kind of non-tag type this is.
3858
3859 /// Determine whether a tag with a given kind is acceptable
3860 /// as a redeclaration of the given tag declaration.
3861 ///
3862 /// \returns true if the new tag kind is acceptable, false otherwise.
3864 bool isDefinition, SourceLocation NewTagLoc,
3865 const IdentifierInfo *Name);
3866
3868 // Not parsing a type within __builtin_offsetof.
3870 // Parsing a type within __builtin_offsetof.
3872 // Parsing a type within macro "offsetof", defined in __buitin_offsetof
3873 // To improve our diagnostic message.
3875 };
3876
3877 /// This is invoked when we see 'struct foo' or 'struct {'. In the
3878 /// former case, Name will be non-null. In the later case, Name will be null.
3879 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is
3880 /// a reference/declaration/definition of a tag.
3881 ///
3882 /// \param IsTypeSpecifier \c true if this is a type-specifier (or
3883 /// trailing-type-specifier) other than one in an alias-declaration.
3884 ///
3885 /// \param SkipBody If non-null, will be set to indicate if the caller should
3886 /// skip the definition of this tag and treat it as if it were a declaration.
3887 DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
3888 SourceLocation KWLoc, CXXScopeSpec &SS,
3889 IdentifierInfo *Name, SourceLocation NameLoc,
3891 SourceLocation ModulePrivateLoc,
3892 MultiTemplateParamsArg TemplateParameterLists,
3893 bool &OwnedDecl, bool &IsDependent,
3894 SourceLocation ScopedEnumKWLoc,
3895 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType,
3896 bool IsTypeSpecifier, bool IsTemplateParamOrArg,
3897 OffsetOfKind OOK, SkipBodyInfo *SkipBody = nullptr);
3898
3899 /// ActOnField - Each field of a C struct/union is passed into this in order
3900 /// to create a FieldDecl object for it.
3901 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
3902 Declarator &D, Expr *BitfieldWidth);
3903
3904 /// HandleField - Analyze a field of a C struct or a C++ data member.
3905 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
3906 Declarator &D, Expr *BitfieldWidth,
3907 InClassInitStyle InitStyle, AccessSpecifier AS);
3908
3909 /// Build a new FieldDecl and check its well-formedness.
3910 ///
3911 /// This routine builds a new FieldDecl given the fields name, type,
3912 /// record, etc. \p PrevDecl should refer to any previous declaration
3913 /// with the same name and in the same scope as the field to be
3914 /// created.
3915 ///
3916 /// \returns a new FieldDecl.
3917 ///
3918 /// \todo The Declarator argument is a hack. It will be removed once
3921 SourceLocation Loc, bool Mutable,
3922 Expr *BitfieldWidth, InClassInitStyle InitStyle,
3924 NamedDecl *PrevDecl, Declarator *D = nullptr);
3925
3927
3928 /// ActOnLastBitfield - This routine handles synthesized bitfields rules for
3929 /// class and class extensions. For every class \@interface and class
3930 /// extension \@interface, if the last ivar is a bitfield of any type,
3931 /// then add an implicit `char :0` ivar to the end of that interface.
3932 void ActOnLastBitfield(SourceLocation DeclStart,
3933 SmallVectorImpl<Decl *> &AllIvarDecls);
3934
3935 // This is used for both record definitions and ObjC interface declarations.
3936 void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl,
3937 ArrayRef<Decl *> Fields, SourceLocation LBrac,
3938 SourceLocation RBrac, const ParsedAttributesView &AttrList);
3939
3940 /// ActOnTagStartDefinition - Invoked when we have entered the
3941 /// scope of a tag's definition (e.g., for an enumeration, class,
3942 /// struct, or union).
3944
3945 /// Perform ODR-like check for C/ObjC when merging tag types from modules.
3946 /// Differently from C++, actually parse the body and reject / error out
3947 /// in case of a structural mismatch.
3948 bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody);
3949
3951
3952 /// Invoked when we enter a tag definition that we're skipping.
3954
3955 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
3956 /// C++ record definition's base-specifiers clause and are starting its
3957 /// member declarations.
3959 SourceLocation FinalLoc,
3960 bool IsFinalSpelledSealed,
3961 bool IsAbstract,
3962 SourceLocation LBraceLoc);
3963
3964 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
3965 /// the definition of a tag (enumeration, class, struct, or union).
3967 SourceRange BraceRange);
3968
3970
3971 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
3972 /// error parsing the definition of a tag.
3974
3976 EnumConstantDecl *LastEnumConst,
3978 Expr *val);
3979
3980 /// Check that this is a valid underlying type for an enum declaration.
3982
3983 /// Check whether this is a valid redeclaration of a previous enumeration.
3984 /// \return true if the redeclaration was invalid.
3985 bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
3986 QualType EnumUnderlyingTy, bool IsFixed,
3987 const EnumDecl *Prev);
3988
3989 /// Determine whether the body of an anonymous enumeration should be skipped.
3990 /// \param II The name of the first enumerator.
3992 SourceLocation IILoc);
3993
3994 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
3996 const ParsedAttributesView &Attrs,
3997 SourceLocation EqualLoc, Expr *Val);
3998 void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
3999 Decl *EnumDecl, ArrayRef<Decl *> Elements, Scope *S,
4000 const ParsedAttributesView &Attr);
4001
4002 /// Set the current declaration context until it gets popped.
4003 void PushDeclContext(Scope *S, DeclContext *DC);
4004 void PopDeclContext();
4005
4006 /// EnterDeclaratorContext - Used when we must lookup names in the context
4007 /// of a declarator's nested name specifier.
4010
4011 /// Enter a template parameter scope, after it's been associated with a
4012 /// particular DeclContext. Causes lookup within the scope to chain through
4013 /// enclosing contexts in the correct order.
4015
4016 /// Push the parameters of D, which must be a function, into scope.
4019
4020 /// Add this decl to the scope shadowed decl chains.
4021 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
4022
4023 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
4024 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
4025 /// true if 'D' belongs to the given declaration context.
4026 ///
4027 /// \param AllowInlineNamespace If \c true, allow the declaration to be in the
4028 /// enclosing namespace set of the context, rather than contained
4029 /// directly within it.
4030 bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
4031 bool AllowInlineNamespace = false) const;
4032
4033 /// Finds the scope corresponding to the given decl context, if it
4034 /// happens to be an enclosing scope. Otherwise return NULL.
4036
4037 /// Subroutines of ActOnDeclarator().
4039 TypeSourceInfo *TInfo);
4040 bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New);
4041
4042 /// Describes the kind of merge to perform for availability
4043 /// attributes (including "deprecated", "unavailable", and "availability").
4045 /// Don't merge availability attributes at all.
4047 /// Merge availability attributes for a redeclaration, which requires
4048 /// an exact match.
4050 /// Merge availability attributes for an override, which requires
4051 /// an exact match or a weakening of constraints.
4053 /// Merge availability attributes for an implementation of
4054 /// a protocol requirement.
4056 /// Merge availability attributes for an implementation of
4057 /// an optional protocol requirement.
4060
4061 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
4062 void mergeDeclAttributes(NamedDecl *New, Decl *Old,
4064
4065 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
4066 /// same name and scope as a previous declaration 'Old'. Figure out
4067 /// how to resolve this situation, merging decls or emitting
4068 /// diagnostics as appropriate. If there was an error, set New to be invalid.
4070 LookupResult &OldDecls);
4071
4072 /// MergeFunctionDecl - We just parsed a function 'New' from
4073 /// declarator D which has the same name and scope as a previous
4074 /// declaration 'Old'. Figure out how to resolve this situation,
4075 /// merging decls or emitting diagnostics as appropriate.
4076 ///
4077 /// In C++, New and Old must be declarations that are not
4078 /// overloaded. Use IsOverload to determine whether New and Old are
4079 /// overloaded, and to select the Old declaration that New should be
4080 /// merged with.
4081 ///
4082 /// Returns true if there was an error, false otherwise.
4083 bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S,
4084 bool MergeTypeWithOld, bool NewDeclIsDefn);
4085
4086 /// Completes the merge of two function declarations that are
4087 /// known to be compatible.
4088 ///
4089 /// This routine handles the merging of attributes and other
4090 /// properties of function declarations from the old declaration to
4091 /// the new declaration, once we know that New is in fact a
4092 /// redeclaration of Old.
4093 ///
4094 /// \returns false
4096 Scope *S, bool MergeTypeWithOld);
4098
4099 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4100 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4101 /// situation, merging decls or emitting diagnostics as appropriate.
4102 ///
4103 /// Tentative definition rules (C99 6.9.2p2) are checked by
4104 /// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
4105 /// definitions here, since the initializer hasn't been attached.
4107
4108 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
4109 /// scope as a previous declaration 'Old'. Figure out how to merge their
4110 /// types, emitting diagnostics as appropriate.
4111 ///
4112 /// Declarations using the auto type specifier (C++ [decl.spec.auto]) call
4113 /// back to here in AddInitializerToDecl. We can't check them before the
4114 /// initializer is attached.
4115 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
4116
4117 /// We've just determined that \p Old and \p New both appear to be definitions
4118 /// of the same variable. Either diagnose or fix the problem.
4119 bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
4120 void notePreviousDefinition(const NamedDecl *Old, SourceLocation New);
4121
4122 /// Filters out lookup results that don't fall within the given scope
4123 /// as determined by isDeclInScope.
4125 bool ConsiderLinkage, bool AllowInlineNamespace);
4126
4127 /// We've determined that \p New is a redeclaration of \p Old. Check that they
4128 /// have compatible owning modules.
4130
4131 /// [module.interface]p6:
4132 /// A redeclaration of an entity X is implicitly exported if X was introduced
4133 /// by an exported declaration; otherwise it shall not be exported.
4135
4136 /// A wrapper function for checking the semantic restrictions of
4137 /// a redeclaration within a module.
4139
4140 /// Check the redefinition in C++20 Modules.
4141 ///
4142 /// [basic.def.odr]p14:
4143 /// For any definable item D with definitions in multiple translation units,
4144 /// - if D is a non-inline non-templated function or variable, or
4145 /// - if the definitions in different translation units do not satisfy the
4146 /// following requirements,
4147 /// the program is ill-formed; a diagnostic is required only if the
4148 /// definable item is attached to a named module and a prior definition is
4149 /// reachable at the point where a later definition occurs.
4150 /// - Each such definition shall not be attached to a named module
4151 /// ([module.unit]).
4152 /// - Each such definition shall consist of the same sequence of tokens, ...
4153 /// ...
4154 ///
4155 /// Return true if the redefinition is not allowed. Return false otherwise.
4156 bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;
4157
4159
4160 /// If it's a file scoped decl that must warn if not used, keep track
4161 /// of it.
4163
4164 typedef llvm::function_ref<void(SourceLocation Loc, PartialDiagnostic PD)>
4166
4169 DiagReceiverTy DiagReceiver);
4170 void DiagnoseUnusedDecl(const NamedDecl *ND);
4171
4172 /// DiagnoseUnusedDecl - Emit warnings about declarations that are not used
4173 /// unless they are marked attr(unused).
4174 void DiagnoseUnusedDecl(const NamedDecl *ND, DiagReceiverTy DiagReceiver);
4175
4176 /// If VD is set but not otherwise used, diagnose, for a parameter or a
4177 /// variable.
4178 void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver);
4179
4180 /// getNonFieldDeclScope - Retrieves the innermost scope, starting
4181 /// from S, where a non-field would be declared. This routine copes
4182 /// with the difference between C and C++ scoping rules in structs and
4183 /// unions. For example, the following code is well-formed in C but
4184 /// ill-formed in C++:
4185 /// @code
4186 /// struct S6 {
4187 /// enum { BAR } e;
4188 /// };
4189 ///
4190 /// void test_S6() {
4191 /// struct S6 a;
4192 /// a.e = BAR;
4193 /// }
4194 /// @endcode
4195 /// For the declaration of BAR, this routine will return a different
4196 /// scope. The scope S will be the scope of the unnamed enumeration
4197 /// within S6. In C++, this routine will return the scope associated
4198 /// with S6, because the enumeration's scope is a transparent
4199 /// context but structures can contain non-field names. In C, this
4200 /// routine will return the translation unit scope, since the
4201 /// enumeration's scope is a transparent context and structures cannot
4202 /// contain non-field names.
4204
4207
4208 /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
4209 /// file scope. lazily create a decl for it. ForRedeclaration is true
4210 /// if we're creating this built-in in anticipation of redeclaring the
4211 /// built-in.
4213 bool ForRedeclaration, SourceLocation Loc);
4214
4215 /// Get the outermost AttributedType node that sets a calling convention.
4216 /// Valid types should not have multiple attributes with different CCs.
4218
4219 /// GetNameForDeclarator - Determine the full declaration name for the
4220 /// given Declarator.
4222
4223 /// Retrieves the declaration name from a parsed unqualified-id.
4225
4226 /// ParsingInitForAutoVars - a set of declarations with auto types for which
4227 /// we are currently parsing the initializer.
4229
4230 /// Look for a locally scoped extern "C" declaration by the given name.
4232
4234
4235 /// Adjust the \c DeclContext for a function or variable that might be a
4236 /// function-local external declaration.
4238
4240
4241 /// Checks if the variant/multiversion functions are compatible.
4243 const FunctionDecl *OldFD, const FunctionDecl *NewFD,
4244 const PartialDiagnostic &NoProtoDiagID,
4245 const PartialDiagnosticAt &NoteCausedDiagIDAt,
4246 const PartialDiagnosticAt &NoSupportDiagIDAt,
4247 const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported,
4248 bool ConstexprSupported, bool CLinkageMayDiffer);
4249
4250 /// type checking declaration initializers (C99 6.7.8)
4252 Expr *Init, unsigned DiagID = diag::err_init_element_not_constant);
4253
4257 Expr *Init);
4258
4260 Expr *Init);
4261
4263
4264 // Heuristically tells if the function is `get_return_object` member of a
4265 // coroutine promise_type by matching the function name.
4266 static bool CanBeGetReturnObject(const FunctionDecl *FD);
4267 static bool CanBeGetReturnTypeOnAllocFailure(const FunctionDecl *FD);
4268
4269 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
4270 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
4272 Scope *S);
4273
4274 /// If this function is a C++ replaceable global allocation function
4275 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
4276 /// adds any function attributes that we know a priori based on the standard.
4277 ///
4278 /// We need to check for duplicate attributes both here and where user-written
4279 /// attributes are applied to declarations.
4281 FunctionDecl *FD);
4282
4283 /// Adds any function attributes that we know a priori based on
4284 /// the declaration of this function.
4285 ///
4286 /// These attributes can apply both to implicitly-declared builtins
4287 /// (like __builtin___printf_chk) or to library-declared functions
4288 /// like NSLog or printf.
4289 ///
4290 /// We need to check for duplicate attributes both here and where user-written
4291 /// attributes are applied to declarations.
4293
4294 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4295 /// the correct width, and that the field type is valid.
4296 /// Returns false on success.
4298 const IdentifierInfo *FieldName, QualType FieldTy,
4299 bool IsMsStruct, Expr *BitWidth);
4300
4301 /// IsValueInFlagEnum - Determine if a value is allowed as part of a flag
4302 /// enum. If AllowMask is true, then we also allow the complement of a valid
4303 /// value, to be used as a mask.
4304 bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val,
4305 bool AllowMask) const;
4306
4307 /// ActOnPragmaWeakID - Called on well formed \#pragma weak ident.
4308 void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc,
4309 SourceLocation WeakNameLoc);
4310
4311 /// ActOnPragmaRedefineExtname - Called on well formed
4312 /// \#pragma redefine_extname oldname newname.
4314 IdentifierInfo *AliasName,
4315 SourceLocation PragmaLoc,
4316 SourceLocation WeakNameLoc,
4317 SourceLocation AliasNameLoc);
4318
4319 /// ActOnPragmaWeakAlias - Called on well formed \#pragma weak ident = ident.
4320 void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName,
4321 SourceLocation PragmaLoc,
4322 SourceLocation WeakNameLoc,
4323 SourceLocation AliasNameLoc);
4324
4325 /// Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
4327 Emitted,
4328 CUDADiscarded, // Discarded due to CUDA/HIP hostness
4329 OMPDiscarded, // Discarded due to OpenMP hostness
4330 TemplateDiscarded, // Discarded due to uninstantiated templates
4331 Unknown,
4332 };
4333 FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl,
4334 bool Final = false);
4335
4336 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
4338
4339private:
4340 /// Function or variable declarations to be checked for whether the deferred
4341 /// diagnostics should be emitted.
4342 llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
4343
4344 /// Map of current shadowing declarations to shadowed declarations. Warn if
4345 /// it looks like the user is trying to modify the shadowing declaration.
4346 llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
4347
4348 // We need this to handle
4349 //
4350 // typedef struct {
4351 // void *foo() { return 0; }
4352 // } A;
4353 //
4354 // When we see foo we don't know if after the typedef we will get 'A' or '*A'
4355 // for example. If 'A', foo will have external linkage. If we have '*A',
4356 // foo will have no linkage. Since we can't know until we get to the end
4357 // of the typedef, this function finds out if D might have non-external
4358 // linkage. Callers should verify at the end of the TU if it D has external
4359 // linkage or not.
4360 static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);
4361
4362 ///@}
4363
4364 //
4365 //
4366 // -------------------------------------------------------------------------
4367 //
4368 //
4369
4370 /// \name Declaration Attribute Handling
4371 /// Implementations are in SemaDeclAttr.cpp
4372 ///@{
4373
4374public:
4375 /// Describes the kind of priority given to an availability attribute.
4376 ///
4377 /// The sum of priorities deteremines the final priority of the attribute.
4378 /// The final priority determines how the attribute will be merged.
4379 /// An attribute with a lower priority will always remove higher priority
4380 /// attributes for the specified platform when it is being applied. An
4381 /// attribute with a higher priority will not be applied if the declaration
4382 /// already has an availability attribute with a lower priority for the
4383 /// specified platform. The final prirority values are not expected to match
4384 /// the values in this enumeration, but instead should be treated as a plain
4385 /// integer value. This enumeration just names the priority weights that are
4386 /// used to calculate that final vaue.
4388 /// The availability attribute was specified explicitly next to the
4389 /// declaration.
4391
4392 /// The availability attribute was applied using '#pragma clang attribute'.
4394
4395 /// The availability attribute for a specific platform was inferred from
4396 /// an availability attribute for another platform.
4399
4400 /// Describes the reason a calling convention specification was ignored, used
4401 /// for diagnostics.
4403 ForThisTarget = 0,
4407 };
4408
4409 /// A helper function to provide Attribute Location for the Attr types
4410 /// AND the ParsedAttr.
4411 template <typename AttrInfo>
4412 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>, SourceLocation>
4413 getAttrLoc(const AttrInfo &AL) {
4414 return AL.getLocation();
4415 }
4417
4418 /// If Expr is a valid integer constant, get the value of the integer
4419 /// expression and return success or failure. May output an error.
4420 ///
4421 /// Negative argument is implicitly converted to unsigned, unless
4422 /// \p StrictlyUnsigned is true.
4423 template <typename AttrInfo>
4424 bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val,
4425 unsigned Idx = UINT_MAX,
4426 bool StrictlyUnsigned = false) {
4427 std::optional<llvm::APSInt> I = llvm::APSInt(32);
4428 if (Expr->isTypeDependent() ||
4430 if (Idx != UINT_MAX)
4431 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4432 << &AI << Idx << AANT_ArgumentIntegerConstant
4433 << Expr->getSourceRange();
4434 else
4435 Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
4437 return false;
4438 }
4439
4440 if (!I->isIntN(32)) {
4441 Diag(Expr->getExprLoc(), diag::err_ice_too_large)
4442 << toString(*I, 10, false) << 32 << /* Unsigned */ 1;
4443 return false;
4444 }
4445
4446 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
4447 Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
4448 << &AI << /*non-negative*/ 1;
4449 return false;
4450 }
4451
4452 Val = (uint32_t)I->getZExtValue();
4453 return true;
4454 }
4455
4456 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
4457 /// \#pragma weak during processing of other Decls.
4458 /// I couldn't figure out a clean way to generate these in-line, so
4459 /// we store them here and handle separately -- which is a hack.
4460 /// It would be best to refactor this.
4462
4463 /// WeakTopLevelDeclDecls - access to \#pragma weak-generated Decls
4465
4469
4470 /// ExtVectorDecls - This is a list all the extended vector types. This allows
4471 /// us to associate a raw vector type with one of the ext_vector type names.
4472 /// This is only necessary for issuing pretty diagnostics.
4474
4475 /// Check if the argument \p E is a ASCII string literal. If not emit an error
4476 /// and return false, otherwise set \p Str to the value of the string literal
4477 /// and return true.
4479 const Expr *E, StringRef &Str,
4480 SourceLocation *ArgLocation = nullptr);
4481
4482 /// Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
4483 /// If not emit an error and return false. If the argument is an identifier it
4484 /// will emit an error with a fixit hint and treat it as if it was a string
4485 /// literal.
4486 bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum,
4487 StringRef &Str,
4488 SourceLocation *ArgLocation = nullptr);
4489
4490 /// Determine if type T is a valid subject for a nonnull and similar
4491 /// attributes. Dependent types are considered valid so they can be checked
4492 /// during instantiation time. By default, we look through references (the
4493 /// behavior used by nonnull), but if the second parameter is true, then we
4494 /// treat a reference type as valid.
4495 bool isValidPointerAttrType(QualType T, bool RefOkay = false);
4496
4497 /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
4498 /// declaration.
4500 Expr *OE);
4501
4502 /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
4503 /// declaration.
4505 Expr *ParamExpr);
4506
4507 bool CheckAttrTarget(const ParsedAttr &CurrAttr);
4508 bool CheckAttrNoArgs(const ParsedAttr &CurrAttr);
4509
4510 AvailabilityAttr *mergeAvailabilityAttr(
4511 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform,
4512 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
4513 VersionTuple Obsoleted, bool IsUnavailable, StringRef Message,
4514 bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK,
4515 int Priority, IdentifierInfo *IIEnvironment);
4516
4517 TypeVisibilityAttr *
4519 TypeVisibilityAttr::VisibilityType Vis);
4520 VisibilityAttr *mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
4521 VisibilityAttr::VisibilityType Vis);
4522 SectionAttr *mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
4523 StringRef Name);
4524
4525 /// Used to implement to perform semantic checking on
4526 /// attribute((section("foo"))) specifiers.
4527 ///
4528 /// In this case, "foo" is passed in to be checked. If the section
4529 /// specifier is invalid, return an Error that indicates the problem.
4530 ///
4531 /// This is a simple quality of implementation feature to catch errors
4532 /// and give good diagnostics in cases when the assembler or code generator
4533 /// would otherwise reject the section specifier.
4534 llvm::Error isValidSectionSpecifier(StringRef Str);
4535 bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
4536 CodeSegAttr *mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
4537 StringRef Name);
4538
4539 // Check for things we'd like to warn about. Multiversioning issues are
4540 // handled later in the process, once we know how many exist.
4541 bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
4542
4543 /// Check Target Version attrs
4544 bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
4546 SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
4547 Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
4548 SmallVectorImpl<SmallString<64>> &StringsBuffer);
4549
4550 ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
4551 StringRef NewUserDiagnostic);
4552 FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
4553 IdentifierInfo *Format, int FormatIdx,
4554 int FirstArg);
4555
4556 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4557 void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4558 bool IsPackExpansion);
4560 bool IsPackExpansion);
4561
4562 /// AddAlignValueAttr - Adds an align_value attribute to a particular
4563 /// declaration.
4564 void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
4565
4566 /// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
4567 Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
4570
4572 bool BestCase,
4573 MSInheritanceModel SemanticSpelling);
4574
4576
4577 /// AddModeAttr - Adds a mode attribute to a particular declaration.
4578 void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name,
4579 bool InInstantiation = false);
4580 AlwaysInlineAttr *mergeAlwaysInlineAttr(Decl *D,
4581 const AttributeCommonInfo &CI,
4582 const IdentifierInfo *Ident);
4583 MinSizeAttr *mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI);
4584 OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
4585 const AttributeCommonInfo &CI);
4586 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);
4587 InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D,
4588 const InternalLinkageAttr &AL);
4589
4590 /// Check validaty of calling convention attribute \p attr. If \p FD
4591 /// is not null pointer, use \p FD to determine the CUDA/HIP host/device
4592 /// target. Otherwise, it is specified by \p CFT.
4594 const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr,
4596
4597 /// Checks a regparm attribute, returning true if it is ill-formed and
4598 /// otherwise setting numParams to the appropriate value.
4599 bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value);
4600
4601 /// Create an CUDALaunchBoundsAttr attribute.
4602 CUDALaunchBoundsAttr *CreateLaunchBoundsAttr(const AttributeCommonInfo &CI,
4603 Expr *MaxThreads,
4604 Expr *MinBlocks,
4605 Expr *MaxBlocks);
4606
4607 /// AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular
4608 /// declaration.
4610 Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks);
4611
4612 enum class RetainOwnershipKind { NS, CF, OS };
4613
4614 UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
4615 StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
4616
4617 BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL);
4618
4619 DLLImportAttr *mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI);
4620 DLLExportAttr *mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI);
4621 MSInheritanceAttr *mergeMSInheritanceAttr(Decl *D,
4622 const AttributeCommonInfo &CI,
4623 bool BestCase,
4624 MSInheritanceModel Model);
4625
4626 EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL);
4627 EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D,
4628 const EnforceTCBLeafAttr &AL);
4629
4630 /// Helper for delayed processing TransparentUnion or
4631 /// BPFPreserveAccessIndexAttr attribute.
4633 const ParsedAttributesView &AttrList);
4634
4635 // Options for ProcessDeclAttributeList().
4638 : IncludeCXX11Attributes(true), IgnoreTypeAttributes(false) {}
4639
4641 ProcessDeclAttributeOptions Result = *this;
4642 Result.IncludeCXX11Attributes = Val;
4643 return Result;
4644 }
4645
4647 ProcessDeclAttributeOptions Result = *this;
4648 Result.IgnoreTypeAttributes = Val;
4649 return Result;
4650 }
4651
4652 // Should C++11 attributes be processed?
4654
4655 // Should any type attributes encountered be ignored?
4656 // If this option is false, a diagnostic will be emitted for any type
4657 // attributes of a kind that does not "slide" from the declaration to
4658 // the decl-specifier-seq.
4660 };
4661
4662 /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
4663 /// attribute list to the specified decl, ignoring any type attributes.
4665 const ParsedAttributesView &AttrList,
4666 const ProcessDeclAttributeOptions &Options =
4668
4669 /// Annotation attributes are the only attributes allowed after an access
4670 /// specifier.
4672 const ParsedAttributesView &AttrList);
4673
4674 /// checkUnusedDeclAttributes - Given a declarator which is not being
4675 /// used to build a declaration, complain about any decl attributes
4676 /// which might be lying around on it.
4678
4679 /// DeclClonePragmaWeak - clone existing decl (maybe definition),
4680 /// \#pragma weak needs a non-definition decl and source may not have one.
4683
4684 /// DeclApplyPragmaWeak - A declaration (maybe definition) needs \#pragma weak
4685 /// applied to it, possibly with an alias.
4686 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W);
4687
4688 void ProcessPragmaWeak(Scope *S, Decl *D);
4689 // Decl attributes - this routine is the top level dispatcher.
4690 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
4691
4693
4694 /// Given a set of delayed diagnostics, re-emit them as if they had
4695 /// been delayed in the current context instead of in the given pool.
4696 /// Essentially, this just moves them to the current pool.
4698
4699 /// Check if IdxExpr is a valid parameter index for a function or
4700 /// instance method D. May output an error.
4701 ///
4702 /// \returns true if IdxExpr is a valid index.
4703 template <typename AttrInfo>
4704 bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI,
4705 unsigned AttrArgNum,
4706 const Expr *IdxExpr, ParamIdx &Idx,
4707 bool CanIndexImplicitThis = false) {
4709
4710 // In C++ the implicit 'this' function parameter also counts.
4711 // Parameters are counted from one.
4712 bool HP = hasFunctionProto(D);
4713 bool HasImplicitThisParam = isInstanceMethod(D);
4714 bool IV = HP && isFunctionOrMethodVariadic(D);
4715 unsigned NumParams =
4716 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam;
4717
4718 std::optional<llvm::APSInt> IdxInt;
4719 if (IdxExpr->isTypeDependent() ||
4720 !(IdxInt = IdxExpr->getIntegerConstantExpr(Context))) {
4721 Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
4722 << &AI << AttrArgNum << AANT_ArgumentIntegerConstant
4723 << IdxExpr->getSourceRange();
4724 return false;
4725 }
4726
4727 unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX);
4728 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
4729 Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
4730 << &AI << AttrArgNum << IdxExpr->getSourceRange();
4731 return false;
4732 }
4733 if (HasImplicitThisParam && !CanIndexImplicitThis) {
4734 if (IdxSource == 1) {
4735 Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
4736 << &AI << IdxExpr->getSourceRange();
4737 return false;
4738 }
4739 }
4740
4741 Idx = ParamIdx(IdxSource, D);
4742 return true;
4743 }
4744
4745 ///@}
4746
4747 //
4748 //
4749 // -------------------------------------------------------------------------
4750 //
4751 //
4752
4753 /// \name C++ Declarations
4754 /// Implementations are in SemaDeclCXX.cpp
4755 ///@{
4756
4757public:
4759
4760 /// Called before parsing a function declarator belonging to a function
4761 /// declaration.
4763 unsigned TemplateParameterDepth);
4764
4765 /// Called after parsing a function declarator belonging to a function
4766 /// declaration.
4768
4769 // Act on C++ namespaces
4771 SourceLocation NamespaceLoc,
4772 SourceLocation IdentLoc, IdentifierInfo *Ident,
4773 SourceLocation LBrace,
4774 const ParsedAttributesView &AttrList,
4775 UsingDirectiveDecl *&UsingDecl, bool IsNested);
4776
4777 /// ActOnFinishNamespaceDef - This callback is called after a namespace is
4778 /// exited. Decl is the DeclTy returned by ActOnStartNamespaceDef.
4779 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
4780
4782
4783 /// Retrieve the special "std" namespace, which may require us to
4784 /// implicitly define the namespace.
4786
4788 EnumDecl *getStdAlignValT() const;
4789
4791 const IdentifierInfo *MemberOrBase);
4792
4794 /// The '<=>' operator was used in an expression and a builtin operator
4795 /// was selected.
4797 /// A defaulted 'operator<=>' needed the comparison category. This
4798 /// typically only applies to 'std::strong_ordering', due to the implicit
4799 /// fallback return value.
4801 };
4802
4803 /// Lookup the specified comparison category types in the standard
4804 /// library, an check the VarDecls possibly returned by the operator<=>
4805 /// builtins for that type.
4806 ///
4807 /// \return The type of the comparison category type corresponding to the
4808 /// specified Kind, or a null type if an error occurs
4812
4813 /// Tests whether Ty is an instance of std::initializer_list and, if
4814 /// it is and Element is not NULL, assigns the element type to Element.
4815 bool isStdInitializerList(QualType Ty, QualType *Element);
4816
4817 /// Looks for the std::initializer_list template and instantiates it
4818 /// with Element, or emits an error if it's not found.
4819 ///
4820 /// \returns The instantiated template, or null on error.
4822
4823 /// Determine whether Ctor is an initializer-list constructor, as
4824 /// defined in [dcl.init.list]p2.
4825 bool isInitListConstructor(const FunctionDecl *Ctor);
4826
4827 Decl *ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc,
4828 SourceLocation NamespcLoc, CXXScopeSpec &SS,
4829 SourceLocation IdentLoc,
4830 IdentifierInfo *NamespcName,
4831 const ParsedAttributesView &AttrList);
4832
4834
4835 Decl *ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc,
4836 SourceLocation AliasLoc, IdentifierInfo *Alias,
4837 CXXScopeSpec &SS, SourceLocation IdentLoc,
4838 IdentifierInfo *Ident);
4839
4840 /// Remove decls we can't actually see from a lookup being used to declare
4841 /// shadow using decls.
4842 ///
4843 /// \param S - The scope of the potential shadow decl
4844 /// \param Previous - The lookup of a potential shadow decl's name.
4845 void FilterUsingLookup(Scope *S, LookupResult &lookup);
4846
4847 /// Hides a using shadow declaration. This is required by the current
4848 /// using-decl implementation when a resolvable using declaration in a
4849 /// class is followed by a declaration which would hide or override
4850 /// one or more of the using decl's targets; for example:
4851 ///
4852 /// struct Base { void foo(int); };
4853 /// struct Derived : Base {
4854 /// using Base::foo;
4855 /// void foo(int);
4856 /// };
4857 ///
4858 /// The governing language is C++03 [namespace.udecl]p12:
4859 ///
4860 /// When a using-declaration brings names from a base class into a
4861 /// derived class scope, member functions in the derived class
4862 /// override and/or hide member functions with the same name and
4863 /// parameter types in a base class (rather than conflicting).
4864 ///
4865 /// There are two ways to implement this:
4866 /// (1) optimistically create shadow decls when they're not hidden
4867 /// by existing declarations, or
4868 /// (2) don't create any shadow decls (or at least don't make them
4869 /// visible) until we've fully parsed/instantiated the class.
4870 /// The problem with (1) is that we might have to retroactively remove
4871 /// a shadow decl, which requires several O(n) operations because the
4872 /// decl structures are (very reasonably) not designed for removal.
4873 /// (2) avoids this but is very fiddly and phase-dependent.
4874 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
4875
4876 /// Determines whether to create a using shadow decl for a particular
4877 /// decl, given the set of decls existing prior to this using lookup.
4879 const LookupResult &PreviousDecls,
4880 UsingShadowDecl *&PrevShadow);
4881
4882 /// Builds a shadow declaration corresponding to a 'using' declaration.
4885 UsingShadowDecl *PrevDecl);
4886
4887 /// Checks that the given using declaration is not an invalid
4888 /// redeclaration. Note that this is checking only for the using decl
4889 /// itself, not for any ill-formedness among the UsingShadowDecls.
4891 bool HasTypenameKeyword,
4892 const CXXScopeSpec &SS,
4893 SourceLocation NameLoc,
4894 const LookupResult &Previous);
4895
4896 /// Checks that the given nested-name qualifier used in a using decl
4897 /// in the current context is appropriately related to the current
4898 /// scope. If an error is found, diagnoses it and returns true.
4899 /// R is nullptr, if the caller has not (yet) done a lookup, otherwise it's
4900 /// the result of that lookup. UD is likewise nullptr, except when we have an
4901 /// already-populated UsingDecl whose shadow decls contain the same
4902 /// information (i.e. we're instantiating a UsingDecl with non-dependent
4903 /// scope).
4904 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename,
4905 const CXXScopeSpec &SS,
4906 const DeclarationNameInfo &NameInfo,
4907 SourceLocation NameLoc,
4908 const LookupResult *R = nullptr,
4909 const UsingDecl *UD = nullptr);
4910
4911 /// Builds a using declaration.
4912 ///
4913 /// \param IsInstantiation - Whether this call arises from an
4914 /// instantiation of an unresolved using declaration. We treat
4915 /// the lookup differently for these declarations.
4917 SourceLocation UsingLoc,
4918 bool HasTypenameKeyword,
4919 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4920 DeclarationNameInfo NameInfo,
4921 SourceLocation EllipsisLoc,
4922 const ParsedAttributesView &AttrList,
4923 bool IsInstantiation, bool IsUsingIfExists);
4925 SourceLocation UsingLoc,
4926 SourceLocation EnumLoc,
4927 SourceLocation NameLoc,
4929 NamedDecl *BuildUsingPackDecl(NamedDecl *InstantiatedFrom,
4930 ArrayRef<NamedDecl *> Expansions);
4931
4932 /// Additional checks for a using declaration referring to a constructor name.
4934
4935 /// Given a derived-class using shadow declaration for a constructor and the
4936 /// correspnding base class constructor, find or create the implicit
4937 /// synthesized derived class constructor to use for this initialization.
4940 ConstructorUsingShadowDecl *DerivedShadow);
4941
4943 SourceLocation UsingLoc,
4944 SourceLocation TypenameLoc, CXXScopeSpec &SS,
4945 UnqualifiedId &Name, SourceLocation EllipsisLoc,
4946 const ParsedAttributesView &AttrList);
4948 SourceLocation UsingLoc,
4949 SourceLocation EnumLoc, SourceRange TyLoc,
4950 const IdentifierInfo &II, ParsedType Ty,
4951 CXXScopeSpec *SS = nullptr);
4953 MultiTemplateParamsArg TemplateParams,
4954 SourceLocation UsingLoc, UnqualifiedId &Name,
4955 const ParsedAttributesView &AttrList,
4956 TypeResult Type, Decl *DeclFromDeclSpec);
4957
4958 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
4959 /// including handling of its default argument expressions.
4960 ///
4961 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
4963 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4964 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
4965 bool HadMultipleCandidates, bool IsListInitialization,
4966 bool IsStdInitListInitialization, bool RequiresZeroInit,
4967 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4968
4969 /// Build a CXXConstructExpr whose constructor has already been resolved if
4970 /// it denotes an inherited constructor.
4972 SourceLocation ConstructLoc, QualType DeclInitType,
4973 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4974 bool HadMultipleCandidates, bool IsListInitialization,
4975 bool IsStdInitListInitialization, bool RequiresZeroInit,
4976 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4977
4978 // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if
4979 // the constructor can be elidable?
4981 SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl,
4982 CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs,
4983 bool HadMultipleCandidates, bool IsListInitialization,
4984 bool IsStdInitListInitialization, bool RequiresZeroInit,
4985 CXXConstructionKind ConstructKind, SourceRange ParenRange);
4986
4988 SourceLocation InitLoc);
4989
4990 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
4991 /// constructed variable.
4992 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
4993
4994 /// Helper class that collects exception specifications for
4995 /// implicitly-declared special member functions.
4997 // Pointer to allow copying
4998 Sema *Self;
4999 // We order exception specifications thus:
5000 // noexcept is the most restrictive, but is only used in C++11.
5001 // throw() comes next.
5002 // Then a throw(collected exceptions)
5003 // Finally no specification, which is expressed as noexcept(false).
5004 // throw(...) is used instead if any called function uses it.
5005 ExceptionSpecificationType ComputedEST;
5006 llvm::SmallPtrSet<CanQualType, 4> ExceptionsSeen;
5007 SmallVector<QualType, 4> Exceptions;
5008
5009 void ClearExceptions() {
5010 ExceptionsSeen.clear();
5011 Exceptions.clear();
5012 }
5013
5014 public:
5016 : Self(&Self), ComputedEST(EST_BasicNoexcept) {
5017 if (!Self.getLangOpts().CPlusPlus11)
5018 ComputedEST = EST_DynamicNone;
5019 }
5020
5021 /// Get the computed exception specification type.
5023 assert(!isComputedNoexcept(ComputedEST) &&
5024 "noexcept(expr) should not be a possible result");
5025 return ComputedEST;
5026 }
5027
5028 /// The number of exceptions in the exception specification.
5029 unsigned size() const { return Exceptions.size(); }
5030
5031 /// The set of exceptions in the exception specification.
5032 const QualType *data() const { return Exceptions.data(); }
5033
5034 /// Integrate another called method into the collected data.
5035 void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method);
5036
5037 /// Integrate an invoked expression into the collected data.
5038 void CalledExpr(Expr *E) { CalledStmt(E); }
5039
5040 /// Integrate an invoked statement into the collected data.
5041 void CalledStmt(Stmt *S);
5042
5043 /// Overwrite an EPI's exception specification with this
5044 /// computed exception specification.
5047 ESI.Type = getExceptionSpecType();
5048 if (ESI.Type == EST_Dynamic) {
5049 ESI.Exceptions = Exceptions;
5050 } else if (ESI.Type == EST_None) {
5051 /// C++11 [except.spec]p14:
5052 /// The exception-specification is noexcept(false) if the set of
5053 /// potential exceptions of the special member function contains "any"
5054 ESI.Type = EST_NoexceptFalse;
5055 ESI.NoexceptExpr =
5056 Self->ActOnCXXBoolLiteral(SourceLocation(), tok::kw_false).get();
5057 }
5058 return ESI;
5059 }
5060 };
5061
5062 /// Evaluate the implicit exception specification for a defaulted
5063 /// special member function.
5065
5066 /// Check the given exception-specification and update the
5067 /// exception specification information with the results.
5068 void checkExceptionSpecification(bool IsTopLevel,
5070 ArrayRef<ParsedType> DynamicExceptions,
5071 ArrayRef<SourceRange> DynamicExceptionRanges,
5072 Expr *NoexceptExpr,
5073 SmallVectorImpl<QualType> &Exceptions,
5075
5076 /// Add an exception-specification to the given member or friend function
5077 /// (or function template). The exception-specification was parsed
5078 /// after the function itself was declared.
5080 Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange,
5081 ArrayRef<ParsedType> DynamicExceptions,
5082 ArrayRef<SourceRange> DynamicExceptionRanges, Expr *NoexceptExpr);
5083
5084 class InheritedConstructorInfo;
5085
5086 /// Determine if a special member function should have a deleted
5087 /// definition when it is defaulted.
5089 InheritedConstructorInfo *ICI = nullptr,
5090 bool Diagnose = false);
5091
5092 /// Produce notes explaining why a defaulted function was defined as deleted.
5094
5095 /// Declare the implicit default constructor for the given class.
5096 ///
5097 /// \param ClassDecl The class declaration into which the implicit
5098 /// default constructor will be added.
5099 ///
5100 /// \returns The implicitly-declared default constructor.
5103
5104 /// DefineImplicitDefaultConstructor - Checks for feasibility of
5105 /// defining this constructor as the default constructor.
5107 CXXConstructorDecl *Constructor);
5108
5109 /// Declare the implicit destructor for the given class.
5110 ///
5111 /// \param ClassDecl The class declaration into which the implicit
5112 /// destructor will be added.
5113 ///
5114 /// \returns The implicitly-declared destructor.
5116
5117 /// DefineImplicitDestructor - Checks for feasibility of
5118 /// defining this destructor as the default destructor.
5119 void DefineImplicitDestructor(SourceLocation CurrentLocation,
5121
5122 /// Build an exception spec for destructors that don't have one.
5123 ///
5124 /// C++11 says that user-defined destructors with no exception spec get one
5125 /// that looks as if the destructor was implicitly declared.
5127
5128 /// Define the specified inheriting constructor.
5130 CXXConstructorDecl *Constructor);
5131
5132 /// Declare the implicit copy constructor for the given class.
5133 ///
5134 /// \param ClassDecl The class declaration into which the implicit
5135 /// copy constructor will be added.
5136 ///
5137 /// \returns The implicitly-declared copy constructor.
5139
5140 /// DefineImplicitCopyConstructor - Checks for feasibility of
5141 /// defining this constructor as the copy constructor.
5142 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
5143 CXXConstructorDecl *Constructor);
5144
5145 /// Declare the implicit move constructor for the given class.
5146 ///
5147 /// \param ClassDecl The Class declaration into which the implicit
5148 /// move constructor will be added.
5149 ///
5150 /// \returns The implicitly-declared move constructor, or NULL if it wasn't
5151 /// declared.
5153
5154 /// DefineImplicitMoveConstructor - Checks for feasibility of
5155 /// defining this constructor as the move constructor.
5156 void DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
5157 CXXConstructorDecl *Constructor);
5158
5159 /// Declare the implicit copy assignment operator for the given class.
5160 ///
5161 /// \param ClassDecl The class declaration into which the implicit
5162 /// copy assignment operator will be added.
5163 ///
5164 /// \returns The implicitly-declared copy assignment operator.
5166
5167 /// Defines an implicitly-declared copy assignment operator.
5168 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
5169 CXXMethodDecl *MethodDecl);
5170
5171 /// Declare the implicit move assignment operator for the given class.
5172 ///
5173 /// \param ClassDecl The Class declaration into which the implicit
5174 /// move assignment operator will be added.
5175 ///
5176 /// \returns The implicitly-declared move assignment operator, or NULL if it
5177 /// wasn't declared.
5179
5180 /// Defines an implicitly-declared move assignment operator.
5181 void DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
5182 CXXMethodDecl *MethodDecl);
5183
5184 /// Check a completed declaration of an implicit special member.
5186
5187 /// Determine whether the given function is an implicitly-deleted
5188 /// special member function.
5190
5191 /// Check whether 'this' shows up in the type of a static member
5192 /// function after the (naturally empty) cv-qualifier-seq would be.
5193 ///
5194 /// \returns true if an error occurred.
5196
5197 /// Whether this' shows up in the exception specification of a static
5198 /// member function.
5200
5201 /// Check whether 'this' shows up in the attributes of the given
5202 /// static member function.
5203 ///
5204 /// \returns true if an error occurred.
5206
5208 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI);
5209
5211
5212 /// Given a constructor and the set of arguments provided for the
5213 /// constructor, convert the arguments and add any required default arguments
5214 /// to form a proper call to this constructor.
5215 ///
5216 /// \returns true if an error occurred, false otherwise.
5218 QualType DeclInitType, MultiExprArg ArgsPtr,
5220 SmallVectorImpl<Expr *> &ConvertedArgs,
5221 bool AllowExplicit = false,
5222 bool IsListInitialization = false);
5223
5224 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
5225 /// initializer for the declaration 'Dcl'.
5226 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
5227 /// static data member of class X, names should be looked up in the scope of
5228 /// class X.
5230
5231 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
5232 /// initializer for the declaration 'Dcl'.
5233 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
5234
5235 /// Define the "body" of the conversion from a lambda object to a
5236 /// function pointer.
5237 ///
5238 /// This routine doesn't actually define a sensible body; rather, it fills
5239 /// in the initialization expression needed to copy the lambda object into
5240 /// the block, and IR generation actually generates the real body of the
5241 /// block pointer conversion.
5242 void
5244 CXXConversionDecl *Conv);
5245
5246 /// Define the "body" of the conversion from a lambda object to a
5247 /// block pointer.
5248 ///
5249 /// This routine doesn't actually define a sensible body; rather, it fills
5250 /// in the initialization expression needed to copy the lambda object into
5251 /// the block, and IR generation actually generates the real body of the
5252 /// block pointer conversion.
5254 CXXConversionDecl *Conv);
5255
5256 /// ActOnStartLinkageSpecification - Parsed the beginning of a C++
5257 /// linkage specification, including the language and (if present)
5258 /// the '{'. ExternLoc is the location of the 'extern', Lang is the
5259 /// language string literal. LBraceLoc, if valid, provides the location of
5260 /// the '{' brace. Otherwise, this linkage specification does not
5261 /// have any braces.
5263 Expr *LangStr, SourceLocation LBraceLoc);
5264
5265 /// ActOnFinishLinkageSpecification - Complete the definition of
5266 /// the C++ linkage specification LinkageSpec. If RBraceLoc is
5267 /// valid, it's the position of the closing '}' brace in a linkage
5268 /// specification that uses braces.
5270 SourceLocation RBraceLoc);
5271
5272 //===--------------------------------------------------------------------===//
5273 // C++ Classes
5274 //
5275
5276 /// Get the class that is directly named by the current context. This is the
5277 /// class for which an unqualified-id in this scope could name a constructor
5278 /// or destructor.
5279 ///
5280 /// If the scope specifier denotes a class, this will be that class.
5281 /// If the scope specifier is empty, this will be the class whose
5282 /// member-specification we are currently within. Otherwise, there
5283 /// is no such class.
5285
5286 /// isCurrentClassName - Determine whether the identifier II is the
5287 /// name of the class type currently being defined. In the case of
5288 /// nested classes, this will only return true if II is the name of
5289 /// the innermost class.
5290 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
5291 const CXXScopeSpec *SS = nullptr);
5292
5293 /// Determine whether the identifier II is a typo for the name of
5294 /// the class type currently being defined. If so, update it to the identifier
5295 /// that should have been used.
5297
5298 /// ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
5300 SourceLocation ColonLoc,
5301 const ParsedAttributesView &Attrs);
5302
5303 /// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
5304 /// declarator is parsed. 'AS' is the access specifier, 'BW' specifies the
5305 /// bitfield width if there is one, 'InitExpr' specifies the initializer if
5306 /// one has been parsed, and 'InitStyle' is set if an in-class initializer is
5307 /// present (but parsing it has been deferred).
5308 NamedDecl *
5310 MultiTemplateParamsArg TemplateParameterLists,
5311 Expr *BitfieldWidth, const VirtSpecifiers &VS,
5312 InClassInitStyle InitStyle);
5313
5314 /// Enter a new C++ default initializer scope. After calling this, the
5315 /// caller must call \ref ActOnFinishCXXInClassMemberInitializer, even if
5316 /// parsing or instantiating the initializer failed.
5318
5319 /// This is invoked after parsing an in-class initializer for a
5320 /// non-static C++ class member, and after instantiating an in-class
5321 /// initializer in a class template. Such actions are deferred until the class
5322 /// is complete.
5324 SourceLocation EqualLoc,
5326
5327 /// Handle a C++ member initializer using parentheses syntax.
5329 ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS,
5330 IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy,
5331 const DeclSpec &DS, SourceLocation IdLoc,
5332 SourceLocation LParenLoc, ArrayRef<Expr *> Args,
5333 SourceLocation RParenLoc, SourceLocation EllipsisLoc);
5334
5335 /// Handle a C++ member initializer using braced-init-list syntax.
5336 MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S,
5337 CXXScopeSpec &SS,
5338 IdentifierInfo *MemberOrBase,
5339 ParsedType TemplateTypeTy,
5340 const DeclSpec &DS, SourceLocation IdLoc,
5341 Expr *InitList, SourceLocation EllipsisLoc);
5342
5343 /// Handle a C++ member initializer.
5344 MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S,
5345 CXXScopeSpec &SS,
5346 IdentifierInfo *MemberOrBase,
5347 ParsedType TemplateTypeTy,
5348 const DeclSpec &DS, SourceLocation IdLoc,
5349 Expr *Init, SourceLocation EllipsisLoc);
5350
5352 SourceLocation IdLoc);
5353
5355 TypeSourceInfo *BaseTInfo, Expr *Init,
5356 CXXRecordDecl *ClassDecl,
5357 SourceLocation EllipsisLoc);
5358
5360 CXXRecordDecl *ClassDecl);
5361
5364
5365 bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
5366 ArrayRef<CXXCtorInitializer *> Initializers = {});
5367
5368 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
5369 /// mark all the non-trivial destructors of its members and bases as
5370 /// referenced.
5371 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
5372 CXXRecordDecl *Record);
5373
5374 /// Mark destructors of virtual bases of this class referenced. In the Itanium
5375 /// C++ ABI, this is done when emitting a destructor for any non-abstract
5376 /// class. In the Microsoft C++ ABI, this is done any time a class's
5377 /// destructor is referenced.
5379 SourceLocation Location, CXXRecordDecl *ClassDecl,
5380 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases = nullptr);
5381
5382 /// Do semantic checks to allow the complete destructor variant to be emitted
5383 /// when the destructor is defined in another translation unit. In the Itanium
5384 /// C++ ABI, destructor variants are emitted together. In the MS C++ ABI, they
5385 /// can be emitted in separate TUs. To emit the complete variant, run a subset
5386 /// of the checks performed when emitting a regular destructor.
5387 void CheckCompleteDestructorVariant(SourceLocation CurrentLocation,
5388 CXXDestructorDecl *Dtor);
5389
5390 /// The list of classes whose vtables have been used within
5391 /// this translation unit, and the source locations at which the
5392 /// first use occurred.
5393 typedef std::pair<CXXRecordDecl *, SourceLocation> VTableUse;
5394
5395 /// The list of vtables that are required but have not yet been
5396 /// materialized.
5398
5399 /// The set of classes whose vtables have been used within
5400 /// this translation unit, and a bit that will be true if the vtable is
5401 /// required to be emitted (otherwise, it should be emitted only if needed
5402 /// by code generation).
5403 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
5404
5405 /// Load any externally-stored vtable uses.
5407
5408 /// Note that the vtable for the given class was used at the
5409 /// given location.
5411 bool DefinitionRequired = false);
5412
5413 /// Mark the exception specifications of all virtual member functions
5414 /// in the given class as needed.
5416 const CXXRecordDecl *RD);
5417
5418 /// MarkVirtualMembersReferenced - Will mark all members of the given
5419 /// CXXRecordDecl referenced.
5421 bool ConstexprOnly = false);
5422
5423 /// Define all of the vtables that have been used in this
5424 /// translation unit and reference any virtual members used by those
5425 /// vtables.
5426 ///
5427 /// \returns true if any work was done, false otherwise.
5428 bool DefineUsedVTables();
5429
5430 /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
5431 /// special functions, such as the default constructor, copy
5432 /// constructor, or destructor, to the given C++ class (C++
5433 /// [special]p1). This routine can only be executed just before the
5434 /// definition of the class is complete.
5436
5437 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5438 void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc,
5440 bool AnyErrors);
5441
5442 /// Check class-level dllimport/dllexport attribute. The caller must
5443 /// ensure that referenceDLLExportedClassMethods is called some point later
5444 /// when all outer classes of Class are complete.
5447
5449
5450 /// Perform propagation of DLL attributes from a derived class to a
5451 /// templated base class for MS compatibility.
5453 CXXRecordDecl *Class, Attr *ClassAttr,
5454 ClassTemplateSpecializationDecl *BaseTemplateSpec,
5455 SourceLocation BaseLoc);
5456
5457 /// Perform semantic checks on a class definition that has been
5458 /// completing, introducing implicitly-declared members, checking for
5459 /// abstract types, etc.
5460 ///
5461 /// \param S The scope in which the class was parsed. Null if we didn't just
5462 /// parse a class definition.
5463 /// \param Record The completed class.
5465
5466 /// Check that the C++ class annoated with "trivial_abi" satisfies all the
5467 /// conditions that are needed for the attribute to have an effect.
5469
5470 /// Check that VTable Pointer authentication is only being set on the first
5471 /// first instantiation of the vtable
5473
5475 Decl *TagDecl, SourceLocation LBrac,
5476 SourceLocation RBrac,
5477 const ParsedAttributesView &AttrList);
5478
5479 /// Perform any semantic analysis which needs to be delayed until all
5480 /// pending class member declarations have been parsed.
5483
5484 /// This is used to implement the constant expression evaluation part of the
5485 /// attribute enable_if extension. There is nothing in standard C++ which
5486 /// would require reentering parameters.
5488 unsigned ActOnReenterTemplateScope(Decl *Template,
5489 llvm::function_ref<Scope *()> EnterScope);
5491
5492 /// ActOnStartDelayedCXXMethodDeclaration - We have completed
5493 /// parsing a top-level (non-nested) C++ class, and we are now
5494 /// parsing those parts of the given Method declaration that could
5495 /// not be parsed earlier (C++ [class.mem]p2), such as default
5496 /// arguments. This action should enter the scope of the given
5497 /// Method declaration as if we had just parsed the qualified method
5498 /// name. However, it should not bring the parameters into scope;
5499 /// that will be performed by ActOnDelayedCXXMethodParameter.
5501 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
5503
5504 /// ActOnFinishDelayedCXXMethodDeclaration - We have finished
5505 /// processing the delayed method declaration for Method. The method
5506 /// declaration is now considered finished. There may be a separate
5507 /// ActOnStartOfFunctionDef action later (not necessarily
5508 /// immediately!) for this method, if it was also defined inside the
5509 /// class body.
5512
5513 bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result,
5514 ASTContext &Ctx,
5515 bool ErrorOnInvalidMessage);
5517 Expr *AssertExpr, Expr *AssertMessageExpr,
5518 SourceLocation RParenLoc);
5520 Expr *AssertExpr, Expr *AssertMessageExpr,
5521 SourceLocation RParenLoc, bool Failed);
5522
5523 /// Try to print more useful information about a failed static_assert
5524 /// with expression \E
5525 void DiagnoseStaticAssertDetails(const Expr *E);
5526
5527 /// Handle a friend type declaration. This works in tandem with
5528 /// ActOnTag.
5529 ///
5530 /// Notes on friend class templates:
5531 ///
5532 /// We generally treat friend class declarations as if they were
5533 /// declaring a class. So, for example, the elaborated type specifier
5534 /// in a friend declaration is required to obey the restrictions of a
5535 /// class-head (i.e. no typedefs in the scope chain), template
5536 /// parameters are required to match up with simple template-ids, &c.
5537 /// However, unlike when declaring a template specialization, it's
5538 /// okay to refer to a template specialization without an empty
5539 /// template parameter declaration, e.g.
5540 /// friend class A<T>::B<unsigned>;
5541 /// We permit this as a special case; if there are any template
5542 /// parameters present at all, require proper matching, i.e.
5543 /// template <> template <class T> friend class A<int>::B;
5544 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
5545 MultiTemplateParamsArg TemplateParams,
5546 SourceLocation EllipsisLoc);
5548 MultiTemplateParamsArg TemplateParams);
5549
5550 /// CheckConstructorDeclarator - Called by ActOnDeclarator to check
5551 /// the well-formedness of the constructor declarator @p D with type @p
5552 /// R. If there are any errors in the declarator, this routine will
5553 /// emit diagnostics and set the invalid bit to true. In any case, the type
5554 /// will be updated to reflect a well-formed type for the constructor and
5555 /// returned.
5557 StorageClass &SC);
5558
5559 /// CheckConstructor - Checks a fully-formed constructor for
5560 /// well-formedness, issuing any diagnostics required. Returns true if
5561 /// the constructor declarator is invalid.
5562 void CheckConstructor(CXXConstructorDecl *Constructor);
5563
5564 /// CheckDestructorDeclarator - Called by ActOnDeclarator to check
5565 /// the well-formednes of the destructor declarator @p D with type @p
5566 /// R. If there are any errors in the declarator, this routine will
5567 /// emit diagnostics and set the declarator to invalid. Even if this happens,
5568 /// will be updated to reflect a well-formed type for the destructor and
5569 /// returned.
5571 StorageClass &SC);
5572
5573 /// CheckDestructor - Checks a fully-formed destructor definition for
5574 /// well-formedness, issuing any diagnostics required. Returns true
5575 /// on error.
5577
5578 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the
5579 /// well-formednes of the conversion function declarator @p D with
5580 /// type @p R. If there are any errors in the declarator, this routine
5581 /// will emit diagnostics and return true. Otherwise, it will return
5582 /// false. Either way, the type @p R will be updated to reflect a
5583 /// well-formed type for the conversion operator.
5585
5586 /// ActOnConversionDeclarator - Called by ActOnDeclarator to complete
5587 /// the declaration of the given C++ conversion function. This routine
5588 /// is responsible for recording the conversion function in the C++
5589 /// class, if possible.
5591
5592 /// Check the validity of a declarator that we parsed for a deduction-guide.
5593 /// These aren't actually declarators in the grammar, so we need to check that
5594 /// the user didn't specify any pieces that are not part of the
5595 /// deduction-guide grammar. Return true on invalid deduction-guide.
5597 StorageClass &SC);
5598
5600
5603 SourceLocation DefaultLoc);
5605
5606 /// Kinds of defaulted comparison operator functions.
5607 enum class DefaultedComparisonKind : unsigned char {
5608 /// This is not a defaultable comparison operator.
5609 None,
5610 /// This is an operator== that should be implemented as a series of
5611 /// subobject comparisons.
5612 Equal,
5613 /// This is an operator<=> that should be implemented as a series of
5614 /// subobject comparisons.
5615 ThreeWay,
5616 /// This is an operator!= that should be implemented as a rewrite in terms
5617 /// of a == comparison.
5618 NotEqual,
5619 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
5620 /// terms of a <=> comparison.
5621 Relational,
5622 };
5623
5627 FunctionDecl *Spaceship);
5630
5632 QualType R, bool IsLambda,
5633 DeclContext *DC = nullptr);
5635 DeclarationName Name, QualType R);
5637
5638 //===--------------------------------------------------------------------===//
5639 // C++ Derived Classes
5640 //
5641
5642 /// Check the validity of a C++ base class specifier.
5643 ///
5644 /// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
5645 /// and returns NULL otherwise.
5647 SourceRange SpecifierRange, bool Virtual,
5648 AccessSpecifier Access,
5649 TypeSourceInfo *TInfo,
5650 SourceLocation EllipsisLoc);
5651
5652 /// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
5653 /// one entry in the base class list of a class specifier, for
5654 /// example:
5655 /// class foo : public bar, virtual private baz {
5656 /// 'public bar' and 'virtual private baz' are each base-specifiers.
5657 BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
5658 const ParsedAttributesView &Attrs, bool Virtual,
5659 AccessSpecifier Access, ParsedType basetype,
5660 SourceLocation BaseLoc,
5661 SourceLocation EllipsisLoc);
5662
5663 /// Performs the actual work of attaching the given base class
5664 /// specifiers to a C++ class.
5667
5668 /// ActOnBaseSpecifiers - Attach the given base specifiers to the
5669 /// class, after checking whether there are any duplicate base
5670 /// classes.
5671 void ActOnBaseSpecifiers(Decl *ClassDecl,
5673
5674 /// Determine whether the type \p Derived is a C++ class that is
5675 /// derived from the type \p Base.
5677
5678 /// Determine whether the type \p Derived is a C++ class that is
5679 /// derived from the type \p Base.
5681 CXXBasePaths &Paths);
5682
5683 // FIXME: I don't like this name.
5684 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
5685
5688 CXXCastPath *BasePath = nullptr,
5689 bool IgnoreAccess = false);
5690
5691 /// CheckDerivedToBaseConversion - Check whether the Derived-to-Base
5692 /// conversion (where Derived and Base are class types) is
5693 /// well-formed, meaning that the conversion is unambiguous (and
5694 /// that all of the base classes are accessible). Returns true
5695 /// and emits a diagnostic if the code is ill-formed, returns false
5696 /// otherwise. Loc is the location where this routine should point to
5697 /// if there is an error, and Range is the source range to highlight
5698 /// if there is an error.
5699 ///
5700 /// If either InaccessibleBaseID or AmbiguousBaseConvID are 0, then the
5701 /// diagnostic for the respective type of error will be suppressed, but the
5702 /// check for ill-formed code will still be performed.
5704 unsigned InaccessibleBaseID,
5705 unsigned AmbiguousBaseConvID,
5707 DeclarationName Name, CXXCastPath *BasePath,
5708 bool IgnoreAccess = false);
5709
5710 /// Builds a string representing ambiguous paths from a
5711 /// specific derived class to different subobjects of the same base
5712 /// class.
5713 ///
5714 /// This function builds a string that can be used in error messages
5715 /// to show the different paths that one can take through the
5716 /// inheritance hierarchy to go from the derived class to different
5717 /// subobjects of a base class. The result looks something like this:
5718 /// @code
5719 /// struct D -> struct B -> struct A
5720 /// struct D -> struct C -> struct A
5721 /// @endcode
5722 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
5723
5725 const CXXMethodDecl *Old);
5726
5727 /// CheckOverridingFunctionReturnType - Checks whether the return types are
5728 /// covariant, according to C++ [class.virtual]p5.
5730 const CXXMethodDecl *Old);
5731
5732 // Check that the overriding method has no explicit object parameter.
5734 const CXXMethodDecl *Old);
5735
5736 /// Mark the given method pure.
5737 ///
5738 /// \param Method the method to be marked pure.
5739 ///
5740 /// \param InitRange the source range that covers the "0" initializer.
5741 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
5742
5743 /// CheckOverrideControl - Check C++11 override control semantics.
5745
5746 /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
5747 /// not used in the declaration of an overriding method.
5749
5750 /// CheckIfOverriddenFunctionIsMarkedFinal - Checks whether a virtual member
5751 /// function overrides a virtual member function marked 'final', according to
5752 /// C++11 [class.virtual]p4.
5754 const CXXMethodDecl *Old);
5755
5766
5767 struct TypeDiagnoser;
5768
5771 TypeDiagnoser &Diagnoser);
5772 template <typename... Ts>
5774 const Ts &...Args) {
5775 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
5776 return RequireNonAbstractType(Loc, T, Diagnoser);
5777 }
5778
5779 void DiagnoseAbstractType(const CXXRecordDecl *RD);
5780
5781 //===--------------------------------------------------------------------===//
5782 // C++ Overloaded Operators [C++ 13.5]
5783 //
5784
5785 /// CheckOverloadedOperatorDeclaration - Check whether the declaration
5786 /// of this overloaded operator is well-formed. If so, returns false;
5787 /// otherwise, emits appropriate diagnostics and returns true.
5789
5790 /// CheckLiteralOperatorDeclaration - Check whether the declaration
5791 /// of this literal operator function is well-formed. If so, returns
5792 /// false; otherwise, emits appropriate diagnostics and returns true.
5794
5795 /// ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression
5796 /// found in an explicit(bool) specifier.
5798
5799 /// tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
5800 /// Returns true if the explicit specifier is now resolved.
5802
5803 /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a
5804 /// C++ if/switch/while/for statement.
5805 /// e.g: "if (int x = f()) {...}"
5807
5808 // Emitting members of dllexported classes is delayed until the class
5809 // (including field initializers) is fully parsed.
5812
5813 /// Merge the exception specifications of two variable declarations.
5814 ///
5815 /// This is called when there's a redeclaration of a VarDecl. The function
5816 /// checks if the redeclaration might have an exception specification and
5817 /// validates compatibility and merges the specs if necessary.
5819
5820 /// MergeCXXFunctionDecl - Merge two declarations of the same C++
5821 /// function, once we already know that they have the same
5822 /// type. Subroutine of MergeFunctionDecl. Returns true if there was an
5823 /// error, false otherwise.
5825
5826 /// Helpers for dealing with blocks and functions.
5828
5829 /// CheckExtraCXXDefaultArguments - Check for any extra default
5830 /// arguments in the declarator, which is not a function declaration
5831 /// or definition and therefore is not permitted to have default
5832 /// arguments. This routine should be invoked for every declarator
5833 /// that is not a function declaration or definition.
5835
5838 }
5839
5840 /// Perform semantic analysis for the variable declaration that
5841 /// occurs within a C++ catch clause, returning the newly-created
5842 /// variable.
5844 SourceLocation StartLoc,
5845 SourceLocation IdLoc,
5846 const IdentifierInfo *Id);
5847
5848 /// ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch
5849 /// handler.
5851
5853
5854 /// Handle a friend tag declaration where the scope specifier was
5855 /// templated.
5857 unsigned TagSpec, SourceLocation TagLoc,
5858 CXXScopeSpec &SS, IdentifierInfo *Name,
5859 SourceLocation NameLoc,
5860 SourceLocation EllipsisLoc,
5862 MultiTemplateParamsArg TempParamLists);
5863
5865 SourceLocation DeclStart, Declarator &D,
5866 Expr *BitfieldWidth,
5867 InClassInitStyle InitStyle,
5868 AccessSpecifier AS,
5869 const ParsedAttr &MSPropertyAttr);
5870
5871 /// Diagnose why the specified class does not have a trivial special member of
5872 /// the given kind.
5875
5877 /// The triviality of a method unaffected by "trivial_abi".
5879
5880 /// The triviality of a method affected by "trivial_abi".
5883
5884 /// Determine whether a defaulted or deleted special member function is
5885 /// trivial, as specified in C++11 [class.ctor]p5, C++11 [class.copy]p12,
5886 /// C++11 [class.copy]p25, and C++11 [class.dtor]p5.
5889 bool Diagnose = false);
5890
5891 /// For a defaulted function, the kind of defaulted function that it is.
5893 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
5894 unsigned SpecialMember : 8;
5895 unsigned Comparison : 8;
5896
5897 public:
5899 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5900 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5902 : SpecialMember(llvm::to_underlying(CSM)),
5903 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)) {}
5905 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
5906 Comparison(llvm::to_underlying(Comp)) {}
5907
5908 bool isSpecialMember() const {
5909 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
5910 CXXSpecialMemberKind::Invalid;
5911 }
5912 bool isComparison() const {
5913 return static_cast<DefaultedComparisonKind>(Comparison) !=
5914 DefaultedComparisonKind::None;
5915 }
5916
5917 explicit operator bool() const {
5918 return isSpecialMember() || isComparison();
5919 }
5920
5922 return static_cast<CXXSpecialMemberKind>(SpecialMember);
5923 }
5925 return static_cast<DefaultedComparisonKind>(Comparison);
5926 }
5927
5928 /// Get the index of this function kind for use in diagnostics.
5929 unsigned getDiagnosticIndex() const {
5930 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
5931 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
5932 "invalid should have highest index");
5933 static_assert((unsigned)DefaultedComparisonKind::None == 0,
5934 "none should be equal to zero");
5935 return SpecialMember + Comparison;
5936 }
5937 };
5938
5939 /// Determine the kind of defaulting that would be done for a given function.
5940 ///
5941 /// If the function is both a default constructor and a copy / move
5942 /// constructor (due to having a default argument for the first parameter),
5943 /// this picks CXXSpecialMemberKind::DefaultConstructor.
5944 ///
5945 /// FIXME: Check that case is properly handled by all callers.
5946 DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD);
5947
5948 /// Handle a C++11 empty-declaration and attribute-declaration.
5950 SourceLocation SemiLoc);
5951
5953 /// Diagnose issues that are non-constant or that are extensions.
5954 Diagnose,
5955 /// Identify whether this function satisfies the formal rules for constexpr
5956 /// functions in the current lanugage mode (with no extensions).
5958 };
5959
5960 // Check whether a function declaration satisfies the requirements of a
5961 // constexpr function definition or a constexpr constructor definition. If so,
5962 // return true. If not, produce appropriate diagnostics (unless asked not to
5963 // by Kind) and return false.
5964 //
5965 // This implements C++11 [dcl.constexpr]p3,4, as amended by DR1360.
5968
5969 /// Diagnose methods which overload virtual methods in a base class
5970 /// without overriding any.
5972
5973 /// Check if a method overloads virtual methods in a base class without
5974 /// overriding any.
5975 void
5977 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5978 void
5980 SmallVectorImpl<CXXMethodDecl *> &OverloadedMethods);
5981
5982 /// ActOnParamDefaultArgument - Check whether the default argument
5983 /// provided for a function parameter is well-formed. If so, attach it
5984 /// to the parameter declaration.
5985 void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
5986 Expr *defarg);
5987
5988 /// ActOnParamUnparsedDefaultArgument - We've seen a default
5989 /// argument for a function parameter, but we can't parse it yet
5990 /// because we're inside a class definition. Note that this default
5991 /// argument will be parsed later.
5993 SourceLocation ArgLoc);
5994
5995 /// ActOnParamDefaultArgumentError - Parsing or semantic analysis of
5996 /// the default argument for the parameter param failed.
5998 Expr *DefaultArg);
6000 SourceLocation EqualLoc);
6001 void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
6002 SourceLocation EqualLoc);
6003
6004 void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
6005 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc,
6006 StringLiteral *Message = nullptr);
6007 void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc);
6008
6010 StringLiteral *DeletedMessage = nullptr);
6014
6015 NamedDecl *
6017 MultiTemplateParamsArg TemplateParamLists);
6020 RecordDecl *ClassDecl,
6021 const IdentifierInfo *Name);
6022
6024
6025 /// Stack containing information needed when in C++2a an 'auto' is encountered
6026 /// in a function declaration parameter type specifier in order to invent a
6027 /// corresponding template parameter in the enclosing abbreviated function
6028 /// template. This information is also present in LambdaScopeInfo, stored in
6029 /// the FunctionScopes stack.
6031
6032 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
6033 std::unique_ptr<CXXFieldCollector> FieldCollector;
6034
6036 /// Set containing all declared private fields that are not used.
6038
6040
6041 /// PureVirtualClassDiagSet - a set of class declarations which we have
6042 /// emitted a list of pure virtual functions. Used to prevent emitting the
6043 /// same list more than once.
6044 std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet;
6045
6049
6050 /// All the delegating constructors seen so far in the file, used for
6051 /// cycle detection at the end of the TU.
6053
6054 /// The C++ "std" namespace, where the standard library resides.
6056
6057 /// The C++ "std::initializer_list" template, which is defined in
6058 /// <initializer_list>.
6060
6061 // Contains the locations of the beginning of unparsed default
6062 // argument locations.
6063 llvm::DenseMap<ParmVarDecl *, SourceLocation> UnparsedDefaultArgLocs;
6064
6065 /// UndefinedInternals - all the used, undefined objects which require a
6066 /// definition in this translation unit.
6067 llvm::MapVector<NamedDecl *, SourceLocation> UndefinedButUsed;
6068
6069 typedef llvm::PointerIntPair<CXXRecordDecl *, 3, CXXSpecialMemberKind>
6071
6072 /// The C++ special members which we are currently in the process of
6073 /// declaring. If this process recursively triggers the declaration of the
6074 /// same special member, we should act as if it is not yet declared.
6076
6078
6079 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
6080
6083 ParsingClassDepth++;
6085 }
6087 ParsingClassDepth--;
6089 }
6090
6092 CXXScopeSpec &SS,
6093 ParsedType TemplateTypeTy,
6094 IdentifierInfo *MemberOrBase);
6095
6096private:
6097 void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
6098 QualType ResultTy,
6099 ArrayRef<QualType> Args);
6100
6101 // A cache representing if we've fully checked the various comparison category
6102 // types stored in ASTContext. The bit-index corresponds to the integer value
6103 // of a ComparisonCategoryType enumerator.
6104 llvm::SmallBitVector FullyCheckedComparisonCategories;
6105
6106 /// Check if there is a field shadowing.
6107 void CheckShadowInheritedFields(const SourceLocation &Loc,
6108 DeclarationName FieldName,
6109 const CXXRecordDecl *RD,
6110 bool DeclIsField = true);
6111
6112 ///@}
6113
6114 //
6115 //
6116 // -------------------------------------------------------------------------
6117 //
6118 //
6119
6120 /// \name C++ Exception Specifications
6121 /// Implementations are in SemaExceptionSpec.cpp
6122 ///@{
6123
6124public:
6125 /// All the overriding functions seen during a class definition
6126 /// that had their exception spec checks delayed, plus the overridden
6127 /// function.
6130
6131 /// All the function redeclarations seen during a class definition that had
6132 /// their exception spec checks delayed, plus the prior declaration they
6133 /// should be checked against. Except during error recovery, the new decl
6134 /// should always be a friend declaration, as that's the only valid way to
6135 /// redeclare a special member before its class is complete.
6138
6139 /// Determine if we're in a case where we need to (incorrectly) eagerly
6140 /// parse an exception specification to work around a libstdc++ bug.
6142
6143 /// Check the given noexcept-specifier, convert its expression, and compute
6144 /// the appropriate ExceptionSpecificationType.
6145 ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr,
6147
6148 CanThrowResult canThrow(const Stmt *E);
6149 /// Determine whether the callee of a particular function call can throw.
6150 /// E, D and Loc are all optional.
6151 static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
6154 const FunctionProtoType *FPT);
6157
6158 /// CheckSpecifiedExceptionType - Check if the given type is valid in an
6159 /// exception specification. Incomplete types, or pointers to incomplete types
6160 /// other than void are not allowed.
6161 ///
6162 /// \param[in,out] T The exception type. This will be decayed to a pointer
6163 /// type
6164 /// when the input is an array or a function type.
6166
6167 /// CheckDistantExceptionSpec - Check if the given type is a pointer or
6168 /// pointer to member to a function with an exception specification. This
6169 /// means that it is invalid to add another level of indirection.
6172
6173 /// CheckEquivalentExceptionSpec - Check if the two types have equivalent
6174 /// exception specifications. Exception specifications are equivalent if
6175 /// they allow exactly the same set of exception types. It does not matter how
6176 /// that is achieved. See C++ [except.spec]p2.
6178 SourceLocation OldLoc,
6179 const FunctionProtoType *New,
6180 SourceLocation NewLoc);
6182 const PartialDiagnostic &NoteID,
6183 const FunctionProtoType *Old,
6184 SourceLocation OldLoc,
6185 const FunctionProtoType *New,
6186 SourceLocation NewLoc);
6187 bool handlerCanCatch(QualType HandlerType, QualType ExceptionType);
6188
6189 /// CheckExceptionSpecSubset - Check whether the second function type's
6190 /// exception specification is a subset (or equivalent) of the first function
6191 /// type. This is used by override and pointer assignment checks.
6193 const PartialDiagnostic &DiagID, const PartialDiagnostic &NestedDiagID,
6194 const PartialDiagnostic &NoteID, const PartialDiagnostic &NoThrowDiagID,
6195 const FunctionProtoType *Superset, bool SkipSupersetFirstParameter,
6196 SourceLocation SuperLoc, const FunctionProtoType *Subset,
6197 bool SkipSubsetFirstParameter, SourceLocation SubLoc);
6198
6199 /// CheckParamExceptionSpec - Check if the parameter and return types of the
6200 /// two functions have equivalent exception specs. This is part of the
6201 /// assignment and override compatibility check. We do not check the
6202 /// parameters of parameter function pointers recursively, as no sane
6203 /// programmer would even be able to write such a function type.
6205 const PartialDiagnostic &NestedDiagID, const PartialDiagnostic &NoteID,
6206 const FunctionProtoType *Target, bool SkipTargetFirstParameter,
6207 SourceLocation TargetLoc, const FunctionProtoType *Source,
6208 bool SkipSourceFirstParameter, SourceLocation SourceLoc);
6209
6210 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
6211
6212 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
6213 /// spec is a subset of base spec.
6215 const CXXMethodDecl *Old);
6216
6217 ///@}
6218
6219 //
6220 //
6221 // -------------------------------------------------------------------------
6222 //
6223 //
6224
6225 /// \name Expressions
6226 /// Implementations are in SemaExpr.cpp
6227 ///@{
6228
6229public:
6230 /// Describes how the expressions currently being parsed are
6231 /// evaluated at run-time, if at all.
6233 /// The current expression and its subexpressions occur within an
6234 /// unevaluated operand (C++11 [expr]p7), such as the subexpression of
6235 /// \c sizeof, where the type of the expression may be significant but
6236 /// no code will be generated to evaluate the value of the expression at
6237 /// run time.
6239
6240 /// The current expression occurs within a braced-init-list within
6241 /// an unevaluated operand. This is mostly like a regular unevaluated
6242 /// context, except that we still instantiate constexpr functions that are
6243 /// referenced here so that we can perform narrowing checks correctly.
6245
6246 /// The current expression occurs within a discarded statement.
6247 /// This behaves largely similarly to an unevaluated operand in preventing
6248 /// definitions from being required, but not in other ways.
6250
6251 /// The current expression occurs within an unevaluated
6252 /// operand that unconditionally permits abstract references to
6253 /// fields, such as a SIZE operator in MS-style inline assembly.
6255
6256 /// The current context is "potentially evaluated" in C++11 terms,
6257 /// but the expression is evaluated at compile-time (like the values of
6258 /// cases in a switch statement).
6260
6261 /// In addition of being constant evaluated, the current expression
6262 /// occurs in an immediate function context - either a consteval function
6263 /// or a consteval if statement.
6265
6266 /// The current expression is potentially evaluated at run time,
6267 /// which means that code may be generated to evaluate the value of the
6268 /// expression at run time.
6270
6271 /// The current expression is potentially evaluated, but any
6272 /// declarations referenced inside that expression are only used if
6273 /// in fact the current expression is used.
6274 ///
6275 /// This value is used when parsing default function arguments, for which
6276 /// we would like to provide diagnostics (e.g., passing non-POD arguments
6277 /// through varargs) but do not want to mark declarations as "referenced"
6278 /// until the default argument is used.
6280 };
6281
6282 /// Store a set of either DeclRefExprs or MemberExprs that contain a reference
6283 /// to a variable (constant) that may or may not be odr-used in this Expr, and
6284 /// we won't know until all lvalue-to-rvalue and discarded value conversions
6285 /// have been applied to all subexpressions of the enclosing full expression.
6286 /// This is cleared at the end of each full expression.
6289
6290 using ImmediateInvocationCandidate = llvm::PointerIntPair<ConstantExpr *, 1>;
6291
6292 /// Data structure used to record current or nested
6293 /// expression evaluation contexts.
6295 /// The expression evaluation context.
6297
6298 /// Whether the enclosing context needed a cleanup.
6300
6301 /// The number of active cleanup objects when we entered
6302 /// this expression evaluation context.
6304
6305 /// The number of typos encountered during this expression evaluation
6306 /// context (i.e. the number of TypoExprs created).
6307 unsigned NumTypos;
6308
6310
6311 /// The lambdas that are present within this context, if it
6312 /// is indeed an unevaluated context.
6314
6315 /// The declaration that provides context for lambda expressions
6316 /// and block literals if the normal declaration context does not
6317 /// suffice, e.g., in a default function argument.
6319
6320 /// If we are processing a decltype type, a set of call expressions
6321 /// for which we have deferred checking the completeness of the return type.
6323
6324 /// If we are processing a decltype type, a set of temporary binding
6325 /// expressions for which we have deferred checking the destructor.
6327
6329
6330 /// Expressions appearing as the LHS of a volatile assignment in this
6331 /// context. We produce a warning for these when popping the context if
6332 /// they are not discarded-value expressions nor unevaluated operands.
6334
6335 /// Set of candidates for starting an immediate invocation.
6338
6339 /// Set of DeclRefExprs referencing a consteval function when used in a
6340 /// context not already known to be immediately invoked.
6342
6343 /// P2718R0 - Lifetime extension in range-based for loops.
6344 /// MaterializeTemporaryExprs in for-range-init expressions which need to
6345 /// extend lifetime. Add MaterializeTemporaryExpr* if the value of
6346 /// InLifetimeExtendingContext is true.
6348
6349 /// \brief Describes whether we are in an expression constext which we have
6350 /// to handle differently.
6355 EK_Other
6356 } ExprContext;
6357
6358 // A context can be nested in both a discarded statement context and
6359 // an immediate function context, so they need to be tracked independently.
6363
6364 bool IsCurrentlyCheckingDefaultArgumentOrInitializer = false;
6365
6366 // We are in a constant context, but we also allow
6367 // non constant expressions, for example for array bounds (which may be
6368 // VLAs).
6369 bool InConditionallyConstantEvaluateContext = false;
6370
6371 /// Whether we are currently in a context in which all temporaries must be
6372 /// lifetime-extended, even if they're not bound to a reference (for
6373 /// example, in a for-range initializer).
6374 bool InLifetimeExtendingContext = false;
6375
6376 /// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
6377 bool RebuildDefaultArgOrDefaultInit = false;
6378
6379 // When evaluating immediate functions in the initializer of a default
6380 // argument or default member initializer, this is the declaration whose
6381 // default initializer is being evaluated and the location of the call
6382 // or constructor definition.
6385 DeclContext *Context)
6386 : Loc(Loc), Decl(Decl), Context(Context) {
6387 assert(Decl && Context && "invalid initialization context");
6388 }
6389
6391 ValueDecl *Decl = nullptr;
6392 DeclContext *Context = nullptr;
6393 };
6394 std::optional<InitializationContext> DelayedDefaultInitializationContext;
6395
6397 unsigned NumCleanupObjects,
6398 CleanupInfo ParentCleanup,
6399 Decl *ManglingContextDecl,
6400 ExpressionKind ExprContext)
6401 : Context(Context), ParentCleanup(ParentCleanup),
6402 NumCleanupObjects(NumCleanupObjects), NumTypos(0),
6403 ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext),
6404 InDiscardedStatement(false), InImmediateFunctionContext(false),
6405 InImmediateEscalatingFunctionContext(false) {}
6406
6407 bool isUnevaluated() const {
6408 return Context == ExpressionEvaluationContext::Unevaluated ||
6409 Context == ExpressionEvaluationContext::UnevaluatedAbstract ||
6410 Context == ExpressionEvaluationContext::UnevaluatedList;
6411 }
6412
6414 return Context == ExpressionEvaluationContext::PotentiallyEvaluated ||
6415 Context ==
6416 ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed ||
6417 Context == ExpressionEvaluationContext::ConstantEvaluated;
6418 }
6419
6420 bool isConstantEvaluated() const {
6421 return Context == ExpressionEvaluationContext::ConstantEvaluated ||
6422 Context == ExpressionEvaluationContext::ImmediateFunctionContext;
6423 }
6424
6426 return Context == ExpressionEvaluationContext::ImmediateFunctionContext ||
6427 (Context == ExpressionEvaluationContext::DiscardedStatement &&
6428 InImmediateFunctionContext) ||
6429 // C++23 [expr.const]p14:
6430 // An expression or conversion is in an immediate function
6431 // context if it is potentially evaluated and either:
6432 // * its innermost enclosing non-block scope is a function
6433 // parameter scope of an immediate function, or
6434 // * its enclosing statement is enclosed by the compound-
6435 // statement of a consteval if statement.
6436 (Context == ExpressionEvaluationContext::PotentiallyEvaluated &&
6437 InImmediateFunctionContext);
6438 }
6439
6441 return Context == ExpressionEvaluationContext::DiscardedStatement ||
6442 (Context ==
6443 ExpressionEvaluationContext::ImmediateFunctionContext &&
6444 InDiscardedStatement);
6445 }
6446 };
6447
6449 assert(!ExprEvalContexts.empty() &&
6450 "Must be in an expression evaluation context");
6451 return ExprEvalContexts.back();
6452 };
6453
6455 assert(!ExprEvalContexts.empty() &&
6456 "Must be in an expression evaluation context");
6457 return ExprEvalContexts.back();
6458 };
6459
6461 assert(ExprEvalContexts.size() >= 2 &&
6462 "Must be in an expression evaluation context");
6463 return ExprEvalContexts[ExprEvalContexts.size() - 2];
6464 };
6465
6467 return const_cast<Sema *>(this)->parentEvaluationContext();
6468 };
6469
6470 bool isAttrContext() const {
6471 return ExprEvalContexts.back().ExprContext ==
6473 }
6474
6475 /// Increment when we find a reference; decrement when we find an ignored
6476 /// assignment. Ultimately the value is 0 if every reference is an ignored
6477 /// assignment.
6478 llvm::DenseMap<const VarDecl *, int> RefsMinusAssignments;
6479
6480 /// Used to control the generation of ExprWithCleanups.
6482
6483 /// ExprCleanupObjects - This is the stack of objects requiring
6484 /// cleanup that are created by the current full expression.
6486
6487 /// Determine whether the use of this declaration is valid, without
6488 /// emitting diagnostics.
6489 bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
6490 // A version of DiagnoseUseOfDecl that should be used if overload resolution
6491 // has been used to find this declaration, which means we don't have to bother
6492 // checking the trailing requires clause.
6494 return DiagnoseUseOfDecl(
6495 D, Loc, /*UnknownObjCClass=*/nullptr, /*ObjCPropertyAccess=*/false,
6496 /*AvoidPartialAvailabilityChecks=*/false, /*ClassReceiver=*/nullptr,
6497 /*SkipTrailingRequiresClause=*/true);
6498 }
6499
6500 /// Determine whether the use of this declaration is valid, and
6501 /// emit any corresponding diagnostics.
6502 ///
6503 /// This routine diagnoses various problems with referencing
6504 /// declarations that can occur when using a declaration. For example,
6505 /// it might warn if a deprecated or unavailable declaration is being
6506 /// used, or produce an error (and return true) if a C++0x deleted
6507 /// function is being used.
6508 ///
6509 /// \returns true if there was an error (this declaration cannot be
6510 /// referenced), false otherwise.
6512 const ObjCInterfaceDecl *UnknownObjCClass = nullptr,
6513 bool ObjCPropertyAccess = false,
6514 bool AvoidPartialAvailabilityChecks = false,
6515 ObjCInterfaceDecl *ClassReciever = nullptr,
6516 bool SkipTrailingRequiresClause = false);
6517
6518 /// Emit a note explaining that this function is deleted.
6520
6521 /// DiagnoseSentinelCalls - This routine checks whether a call or
6522 /// message-send is to a declaration with the sentinel attribute, and
6523 /// if so, it checks that the requirements of the sentinel are
6524 /// satisfied.
6526 ArrayRef<Expr *> Args);
6527
6529 ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl = nullptr,
6538
6540
6544
6545 /// Check whether E, which is either a discarded-value expression or an
6546 /// unevaluated operand, is a simple-assignment to a volatlie-qualified
6547 /// lvalue, and if so, remove it from the list of volatile-qualified
6548 /// assignments that we are going to warn are deprecated.
6550
6552
6553 // Functions for marking a declaration referenced. These functions also
6554 // contain the relevant logic for marking if a reference to a function or
6555 // variable is an odr-use (in the C++11 sense). There are separate variants
6556 // for expressions referring to a decl; these exist because odr-use marking
6557 // needs to be delayed for some constant variables when we build one of the
6558 // named expressions.
6559 //
6560 // MightBeOdrUse indicates whether the use could possibly be an odr-use, and
6561 // should usually be true. This only needs to be set to false if the lack of
6562 // odr-use cannot be determined from the current context (for instance,
6563 // because the name denotes a virtual function and was written without an
6564 // explicit nested-name-specifier).
6565 void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse);
6566
6567 /// Mark a function referenced, and check whether it is odr-used
6568 /// (C++ [basic.def.odr]p2, C99 6.9p3)
6570 bool MightBeOdrUse = true);
6571
6572 /// Mark a variable referenced, and check whether it is odr-used
6573 /// (C++ [basic.def.odr]p2, C99 6.9p3). Note that this should not be
6574 /// used directly for normal expressions referring to VarDecl.
6576
6577 /// Perform reference-marking and odr-use handling for a DeclRefExpr.
6578 ///
6579 /// Note, this may change the dependence of the DeclRefExpr, and so needs to
6580 /// be handled with care if the DeclRefExpr is not newly-created.
6581 void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base = nullptr);
6582
6583 /// Perform reference-marking and odr-use handling for a MemberExpr.
6585
6586 /// Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
6589 unsigned CapturingScopeIndex);
6590
6592 void CleanupVarDeclMarking();
6593
6599
6600 /// Try to capture the given variable.
6601 ///
6602 /// \param Var The variable to capture.
6603 ///
6604 /// \param Loc The location at which the capture occurs.
6605 ///
6606 /// \param Kind The kind of capture, which may be implicit (for either a
6607 /// block or a lambda), or explicit by-value or by-reference (for a lambda).
6608 ///
6609 /// \param EllipsisLoc The location of the ellipsis, if one is provided in
6610 /// an explicit lambda capture.
6611 ///
6612 /// \param BuildAndDiagnose Whether we are actually supposed to add the
6613 /// captures or diagnose errors. If false, this routine merely check whether
6614 /// the capture can occur without performing the capture itself or complaining
6615 /// if the variable cannot be captured.
6616 ///
6617 /// \param CaptureType Will be set to the type of the field used to capture
6618 /// this variable in the innermost block or lambda. Only valid when the
6619 /// variable can be captured.
6620 ///
6621 /// \param DeclRefType Will be set to the type of a reference to the capture
6622 /// from within the current scope. Only valid when the variable can be
6623 /// captured.
6624 ///
6625 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
6626 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
6627 /// This is useful when enclosing lambdas must speculatively capture
6628 /// variables that may or may not be used in certain specializations of
6629 /// a nested generic lambda.
6630 ///
6631 /// \returns true if an error occurred (i.e., the variable cannot be
6632 /// captured) and false if the capture succeeded.
6634 TryCaptureKind Kind, SourceLocation EllipsisLoc,
6635 bool BuildAndDiagnose, QualType &CaptureType,
6636 QualType &DeclRefType,
6637 const unsigned *const FunctionScopeIndexToStopAt);
6638
6639 /// Try to capture the given variable.
6642 SourceLocation EllipsisLoc = SourceLocation());
6643
6644 /// Checks if the variable must be captured.
6646
6647 /// Given a variable, determine the type that a reference to that
6648 /// variable will have in the given scope.
6650
6651 /// Mark all of the declarations referenced within a particular AST node as
6652 /// referenced. Used when template instantiation instantiates a non-dependent
6653 /// type -- entities referenced by the type are now referenced.
6655
6656 /// Mark any declarations that appear within this expression or any
6657 /// potentially-evaluated subexpressions as "referenced".
6658 ///
6659 /// \param SkipLocalVariables If true, don't mark local variables as
6660 /// 'referenced'.
6661 /// \param StopAt Subexpressions that we shouldn't recurse into.
6663 bool SkipLocalVariables = false,
6664 ArrayRef<const Expr *> StopAt = {});
6665
6666 /// Try to convert an expression \p E to type \p Ty. Returns the result of the
6667 /// conversion.
6668 ExprResult tryConvertExprToType(Expr *E, QualType Ty);
6669
6670 /// Conditionally issue a diagnostic based on the statements's reachability
6671 /// analysis.
6672 ///
6673 /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until
6674 /// the function body is parsed, and then do a basic reachability analysis to
6675 /// determine if the statement is reachable. If it is unreachable, the
6676 /// diagnostic will not be emitted.
6677 bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
6678 const PartialDiagnostic &PD);
6679
6680 /// Conditionally issue a diagnostic based on the current
6681 /// evaluation context.
6682 ///
6683 /// \param Statement If Statement is non-null, delay reporting the
6684 /// diagnostic until the function body is parsed, and then do a basic
6685 /// reachability analysis to determine if the statement is reachable.
6686 /// If it is unreachable, the diagnostic will not be emitted.
6687 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
6688 const PartialDiagnostic &PD);
6689 /// Similar, but diagnostic is only produced if all the specified statements
6690 /// are reachable.
6691 bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
6692 const PartialDiagnostic &PD);
6693
6694 // Primary Expressions.
6695 SourceRange getExprRange(Expr *E) const;
6696
6697 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
6698 SourceLocation TemplateKWLoc, UnqualifiedId &Id,
6699 bool HasTrailingLParen, bool IsAddressOfOperand,
6700 CorrectionCandidateCallback *CCC = nullptr,
6701 bool IsInlineAsmIdentifier = false,
6702 Token *KeywordReplacement = nullptr);
6703
6704 /// Decomposes the given name into a DeclarationNameInfo, its location, and
6705 /// possibly a list of template arguments.
6706 ///
6707 /// If this produces template arguments, it is permitted to call
6708 /// DecomposeTemplateName.
6709 ///
6710 /// This actually loses a lot of source location information for
6711 /// non-standard name kinds; we should consider preserving that in
6712 /// some way.
6713 void DecomposeUnqualifiedId(const UnqualifiedId &Id,
6714 TemplateArgumentListInfo &Buffer,
6715 DeclarationNameInfo &NameInfo,
6716 const TemplateArgumentListInfo *&TemplateArgs);
6717
6718 /// Diagnose a lookup that found results in an enclosing class during error
6719 /// recovery. This usually indicates that the results were found in a
6720 /// dependent base class that could not be searched as part of a template
6721 /// definition. Always issues a diagnostic (though this may be only a warning
6722 /// in MS compatibility mode).
6723 ///
6724 /// Return \c true if the error is unrecoverable, or \c false if the caller
6725 /// should attempt to recover using these lookup results.
6726 bool DiagnoseDependentMemberLookup(const LookupResult &R);
6727
6728 /// Diagnose an empty lookup.
6729 ///
6730 /// \return false if new lookup candidates were found
6731 bool
6732 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
6733 CorrectionCandidateCallback &CCC,
6734 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
6735 ArrayRef<Expr *> Args = {},
6736 DeclContext *LookupCtx = nullptr,
6737 TypoExpr **Out = nullptr);
6738
6739 /// If \p D cannot be odr-used in the current expression evaluation context,
6740 /// return a reason explaining why. Otherwise, return NOUR_None.
6742
6743 DeclRefExpr *BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6744 SourceLocation Loc,
6745 const CXXScopeSpec *SS = nullptr);
6746 DeclRefExpr *
6747 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6748 const DeclarationNameInfo &NameInfo,
6749 const CXXScopeSpec *SS = nullptr,
6750 NamedDecl *FoundD = nullptr,
6751 SourceLocation TemplateKWLoc = SourceLocation(),
6752 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6753
6754 /// BuildDeclRefExpr - Build an expression that references a
6755 /// declaration that does not require a closure capture.
6756 DeclRefExpr *
6757 BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
6758 const DeclarationNameInfo &NameInfo,
6759 NestedNameSpecifierLoc NNS, NamedDecl *FoundD = nullptr,
6760 SourceLocation TemplateKWLoc = SourceLocation(),
6761 const TemplateArgumentListInfo *TemplateArgs = nullptr);
6762
6763 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R,
6764 bool HasTrailingLParen);
6765
6766 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
6767 /// declaration name, generally during template instantiation.
6768 /// There's a large number of things which don't need to be done along
6769 /// this path.
6771 CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
6772 bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
6773
6774 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
6775 bool NeedsADL,
6776 bool AcceptInvalidDecl = false);
6777
6778 /// Complete semantic analysis for a reference to the given declaration.
6780 const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D,
6781 NamedDecl *FoundD = nullptr,
6782 const TemplateArgumentListInfo *TemplateArgs = nullptr,
6783 bool AcceptInvalidDecl = false);
6784
6785 // ExpandFunctionLocalPredefinedMacros - Returns a new vector of Tokens,
6786 // where Tokens representing function local predefined macros (such as
6787 // __FUNCTION__) are replaced (expanded) with string-literal Tokens.
6788 std::vector<Token> ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks);
6789
6792 ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val);
6793
6794 bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero);
6795
6796 ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr);
6797 ExprResult ActOnCharacterConstant(const Token &Tok,
6798 Scope *UDLScope = nullptr);
6799 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E);
6800 ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R,
6801 MultiExprArg Val);
6802
6803 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
6804 /// fragments (e.g. "foo" "bar" L"baz"). The result string has to handle
6805 /// string concatenation ([C99 5.1.1.2, translation phase #6]), so it may come
6806 /// from multiple tokens. However, the common case is that StringToks points
6807 /// to one string.
6808 ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks,
6809 Scope *UDLScope = nullptr);
6810
6811 ExprResult ActOnUnevaluatedStringLiteral(ArrayRef<Token> StringToks);
6812
6813 /// ControllingExprOrType is either an opaque pointer coming out of a
6814 /// ParsedType or an Expr *. FIXME: it'd be better to split this interface
6815 /// into two so we don't take a void *, but that's awkward because one of
6816 /// the operands is either a ParsedType or an Expr *, which doesn't lend
6817 /// itself to generic code very well.
6818 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc,
6819 SourceLocation DefaultLoc,
6820 SourceLocation RParenLoc,
6821 bool PredicateIsExpr,
6822 void *ControllingExprOrType,
6823 ArrayRef<ParsedType> ArgTypes,
6824 ArrayRef<Expr *> ArgExprs);
6825 /// ControllingExprOrType is either a TypeSourceInfo * or an Expr *. FIXME:
6826 /// it'd be better to split this interface into two so we don't take a
6827 /// void *, but see the FIXME on ActOnGenericSelectionExpr as to why that
6828 /// isn't a trivial change.
6829 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
6830 SourceLocation DefaultLoc,
6831 SourceLocation RParenLoc,
6832 bool PredicateIsExpr,
6833 void *ControllingExprOrType,
6834 ArrayRef<TypeSourceInfo *> Types,
6835 ArrayRef<Expr *> Exprs);
6836
6837 // Binary/Unary Operators. 'Tok' is the token for the operator.
6838 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
6839 Expr *InputExpr, bool IsAfterAmp = false);
6840 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc,
6841 Expr *Input, bool IsAfterAmp = false);
6842
6843 /// Unary Operators. 'Tok' is the token for the operator.
6844 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op,
6845 Expr *Input, bool IsAfterAmp = false);
6846
6847 /// Determine whether the given expression is a qualified member
6848 /// access expression, of a form that could be turned into a pointer to member
6849 /// with the address-of operator.
6850 bool isQualifiedMemberAccess(Expr *E);
6851 bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
6852 const Expr *Op,
6853 const CXXMethodDecl *MD);
6854
6855 /// CheckAddressOfOperand - The operand of & must be either a function
6856 /// designator or an lvalue designating an object. If it is an lvalue, the
6857 /// object cannot be declared with storage class register or be a bit field.
6858 /// Note: The usual conversions are *not* applied to the operand of the &
6859 /// operator (C99 6.3.2.1p[2-4]), and its result is never an lvalue.
6860 /// In C++, the operand might be an overloaded function name, in which case
6861 /// we allow the '&' but retain the overloaded-function type.
6862 QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc);
6863
6864 /// ActOnAlignasTypeArgument - Handle @c alignas(type-id) and @c
6865 /// _Alignas(type-name) .
6866 /// [dcl.align] An alignment-specifier of the form
6867 /// alignas(type-id) has the same effect as alignas(alignof(type-id)).
6868 ///
6869 /// [N1570 6.7.5] _Alignas(type-name) is equivalent to
6870 /// _Alignas(_Alignof(type-name)).
6871 bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,
6872 SourceLocation OpLoc, SourceRange R);
6873 bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo,
6874 SourceLocation OpLoc, SourceRange R);
6875
6876 /// Build a sizeof or alignof expression given a type operand.
6877 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
6878 SourceLocation OpLoc,
6879 UnaryExprOrTypeTrait ExprKind,
6880 SourceRange R);
6881
6882 /// Build a sizeof or alignof expression given an expression
6883 /// operand.
6884 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
6885 UnaryExprOrTypeTrait ExprKind);
6886
6887 /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c
6888 /// expr and the same for @c alignof and @c __alignof
6889 /// Note that the ArgRange is invalid if isType is false.
6890 ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
6891 UnaryExprOrTypeTrait ExprKind,
6892 bool IsType, void *TyOrEx,
6893 SourceRange ArgRange);
6894
6895 /// Check for operands with placeholder types and complain if found.
6896 /// Returns ExprError() if there was an error and no recovery was possible.
6898 bool CheckVecStepExpr(Expr *E);
6899
6900 /// Check the constraints on expression operands to unary type expression
6901 /// and type traits.
6902 ///
6903 /// Completes any types necessary and validates the constraints on the operand
6904 /// expression. The logic mostly mirrors the type-based overload, but may
6905 /// modify the expression as it completes the type for that expression through
6906 /// template instantiation, etc.
6908
6909 /// Check the constraints on operands to unary expression and type
6910 /// traits.
6911 ///
6912 /// This will complete any types necessary, and validate the various
6913 /// constraints on those operands.
6914 ///
6915 /// The UsualUnaryConversions() function is *not* called by this routine.
6916 /// C99 6.3.2.1p[2-4] all state:
6917 /// Except when it is the operand of the sizeof operator ...
6918 ///
6919 /// C++ [expr.sizeof]p4
6920 /// The lvalue-to-rvalue, array-to-pointer, and function-to-pointer
6921 /// standard conversions are not applied to the operand of sizeof.
6922 ///
6923 /// This policy is followed for all of the unary trait expressions.
6924 bool CheckUnaryExprOrTypeTraitOperand(QualType ExprType, SourceLocation OpLoc,
6925 SourceRange ExprRange,
6926 UnaryExprOrTypeTrait ExprKind,
6927 StringRef KWName);
6928
6929 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
6930 tok::TokenKind Kind, Expr *Input);
6931
6932 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
6933 MultiExprArg ArgExprs,
6934 SourceLocation RLoc);
6935 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
6936 Expr *Idx, SourceLocation RLoc);
6937
6939 Expr *ColumnIdx,
6940 SourceLocation RBLoc);
6941
6942 /// ConvertArgumentsForCall - Converts the arguments specified in
6943 /// Args/NumArgs to the parameter types of the function FDecl with
6944 /// function prototype Proto. Call is the call expression itself, and
6945 /// Fn is the function expression. For a C++ member function, this
6946 /// routine does not attempt to convert the object argument. Returns
6947 /// true if the call is ill-formed.
6948 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl,
6949 const FunctionProtoType *Proto,
6950 ArrayRef<Expr *> Args, SourceLocation RParenLoc,
6951 bool ExecConfig = false);
6952
6953 /// CheckStaticArrayArgument - If the given argument corresponds to a static
6954 /// array parameter, check that it is non-null, and that if it is formed by
6955 /// array-to-pointer decay, the underlying array is sufficiently large.
6956 ///
6957 /// C99 6.7.5.3p7: If the keyword static also appears within the [ and ] of
6958 /// the array type derivation, then for each call to the function, the value
6959 /// of the corresponding actual argument shall provide access to the first
6960 /// element of an array with at least as many elements as specified by the
6961 /// size expression.
6962 void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
6963 const Expr *ArgExpr);
6964
6965 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
6966 /// This provides the location of the left/right parens and a list of comma
6967 /// locations.
6968 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
6969 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6970 Expr *ExecConfig = nullptr);
6971
6972 /// BuildCallExpr - Handle a call to Fn with the specified array of arguments.
6973 /// This provides the location of the left/right parens and a list of comma
6974 /// locations.
6975 ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
6976 MultiExprArg ArgExprs, SourceLocation RParenLoc,
6977 Expr *ExecConfig = nullptr,
6978 bool IsExecConfig = false,
6979 bool AllowRecovery = false);
6980
6981 /// BuildBuiltinCallExpr - Create a call to a builtin function specified by Id
6982 // with the specified CallArgs
6983 Expr *BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id,
6984 MultiExprArg CallArgs);
6985
6987
6988 /// BuildResolvedCallExpr - Build a call to a resolved expression,
6989 /// i.e. an expression not of \p OverloadTy. The expression should
6990 /// unary-convert to an expression of function-pointer or
6991 /// block-pointer type.
6992 ///
6993 /// \param NDecl the declaration being called, if available
6995 BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc,
6996 ArrayRef<Expr *> Arg, SourceLocation RParenLoc,
6997 Expr *Config = nullptr, bool IsExecConfig = false,
6998 ADLCallKind UsesADL = ADLCallKind::NotADL);
6999
7001 ParsedType &Ty, SourceLocation RParenLoc,
7002 Expr *CastExpr);
7003
7004 /// Prepares for a scalar cast, performing all the necessary stages
7005 /// except the final cast and returning the kind required.
7007
7008 /// Build an altivec or OpenCL literal.
7010 SourceLocation RParenLoc, Expr *E,
7011 TypeSourceInfo *TInfo);
7012
7013 /// This is not an AltiVec-style cast or or C++ direct-initialization, so turn
7014 /// the ParenListExpr into a sequence of comma binary operators.
7016
7018 SourceLocation RParenLoc, Expr *InitExpr);
7019
7021 TypeSourceInfo *TInfo,
7022 SourceLocation RParenLoc,
7023 Expr *LiteralExpr);
7024
7025 ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7026 SourceLocation RBraceLoc);
7027
7028 ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
7029 SourceLocation RBraceLoc);
7030
7031 /// Binary Operators. 'Tok' is the token for the operator.
7033 Expr *LHSExpr, Expr *RHSExpr);
7035 Expr *LHSExpr, Expr *RHSExpr);
7036
7037 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
7038 /// operator @p Opc at location @c TokLoc. This routine only supports
7039 /// built-in operations; ActOnBinOp handles overloaded operators.
7041 Expr *LHSExpr, Expr *RHSExpr);
7043 UnresolvedSetImpl &Functions);
7044
7045 /// Look for instances where it is likely the comma operator is confused with
7046 /// another operator. There is an explicit list of acceptable expressions for
7047 /// the left hand side of the comma operator, otherwise emit a warning.
7048 void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc);
7049
7050 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
7051 /// in the case of a the GNU conditional expr extension.
7053 SourceLocation ColonLoc, Expr *CondExpr,
7054 Expr *LHSExpr, Expr *RHSExpr);
7055
7056 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
7058 LabelDecl *TheDecl);
7059
7060 void ActOnStartStmtExpr();
7061 ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
7062 SourceLocation RPLoc);
7064 SourceLocation RPLoc, unsigned TemplateDepth);
7065 // Handle the final expression in a statement expression.
7067 void ActOnStmtExprError();
7068
7069 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
7072 bool isBrackets; // true if [expr], false if .ident
7073 union {
7076 } U;
7077 };
7078
7079 /// __builtin_offsetof(type, a.b[123][456].c)
7081 TypeSourceInfo *TInfo,
7082 ArrayRef<OffsetOfComponent> Components,
7083 SourceLocation RParenLoc);
7086 ParsedType ParsedArgTy,
7087 ArrayRef<OffsetOfComponent> Components,
7088 SourceLocation RParenLoc);
7089
7090 // __builtin_choose_expr(constExpr, expr1, expr2)
7091 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
7092 Expr *LHSExpr, Expr *RHSExpr,
7093 SourceLocation RPLoc);
7094
7095 // __builtin_va_arg(expr, type)
7097 SourceLocation RPLoc);
7099 TypeSourceInfo *TInfo, SourceLocation RPLoc);
7100
7101 // __builtin_LINE(), __builtin_FUNCTION(), __builtin_FUNCSIG(),
7102 // __builtin_FILE(), __builtin_COLUMN(), __builtin_source_location()
7104 SourceLocation BuiltinLoc,
7105 SourceLocation RPLoc);
7106
7107 // #embed
7109 StringLiteral *BinaryData);
7110
7111 // Build a potentially resolved SourceLocExpr.
7113 SourceLocation BuiltinLoc, SourceLocation RPLoc,
7114 DeclContext *ParentContext);
7115
7116 // __null
7118
7119 bool CheckCaseExpression(Expr *E);
7120
7121 //===------------------------- "Block" Extension ------------------------===//
7122
7123 /// ActOnBlockStart - This callback is invoked when a block literal is
7124 /// started.
7125 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
7126
7127 /// ActOnBlockArguments - This callback allows processing of block arguments.
7128 /// If there are no arguments, this is still invoked.
7129 void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
7130 Scope *CurScope);
7131
7132 /// ActOnBlockError - If there is an error parsing a block, this callback
7133 /// is invoked to pop the information about the block from the action impl.
7134 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
7135
7136 /// ActOnBlockStmtExpr - This is called when the body of a block statement
7137 /// literal was successfully completed. ^(int x){...}
7139 Scope *CurScope);
7140
7141 //===---------------------------- Clang Extensions ----------------------===//
7142
7143 /// ActOnConvertVectorExpr - create a new convert-vector expression from the
7144 /// provided arguments.
7145 ///
7146 /// __builtin_convertvector( value, dst type )
7147 ///
7149 SourceLocation BuiltinLoc,
7150 SourceLocation RParenLoc);
7151
7152 //===---------------------------- OpenCL Features -----------------------===//
7153
7154 /// Parse a __builtin_astype expression.
7155 ///
7156 /// __builtin_astype( value, dst type )
7157 ///
7159 SourceLocation BuiltinLoc,
7160 SourceLocation RParenLoc);
7161
7162 /// Create a new AsTypeExpr node (bitcast) from the arguments.
7164 SourceLocation BuiltinLoc,
7165 SourceLocation RParenLoc);
7166
7167 /// Attempts to produce a RecoveryExpr after some AST node cannot be created.
7169 ArrayRef<Expr *> SubExprs,
7170 QualType T = QualType());
7171
7172 /// Cast a base object to a member's actual type.
7173 ///
7174 /// There are two relevant checks:
7175 ///
7176 /// C++ [class.access.base]p7:
7177 ///
7178 /// If a class member access operator [...] is used to access a non-static
7179 /// data member or non-static member function, the reference is ill-formed
7180 /// if the left operand [...] cannot be implicitly converted to a pointer to
7181 /// the naming class of the right operand.
7182 ///
7183 /// C++ [expr.ref]p7:
7184 ///
7185 /// If E2 is a non-static data member or a non-static member function, the
7186 /// program is ill-formed if the class of which E2 is directly a member is
7187 /// an ambiguous base (11.8) of the naming class (11.9.3) of E2.
7188 ///
7189 /// Note that the latter check does not consider access; the access of the
7190 /// "real" base class is checked as appropriate when checking the access of
7191 /// the member name.
7193 NestedNameSpecifier *Qualifier,
7194 NamedDecl *FoundDecl,
7195 NamedDecl *Member);
7196
7197 /// CheckCallReturnType - Checks that a call expression's return type is
7198 /// complete. Returns true on failure. The location passed in is the location
7199 /// that best represents the call.
7201 CallExpr *CE, FunctionDecl *FD);
7202
7203 /// Emit a warning for all pending noderef expressions that we recorded.
7204 void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec);
7205
7207
7208 /// Instantiate or parse a C++ default argument expression as necessary.
7209 /// Return true on error.
7211 ParmVarDecl *Param, Expr *Init = nullptr,
7212 bool SkipImmediateInvocations = true);
7213
7214 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
7215 /// the default expr if needed.
7217 ParmVarDecl *Param, Expr *Init = nullptr);
7218
7219 /// Wrap the expression in a ConstantExpr if it is a potential immediate
7220 /// invocation.
7222
7224
7225 // Check that the SME attributes for PSTATE.ZA and PSTATE.SM are compatible.
7226 bool IsInvalidSMECallConversion(QualType FromType, QualType ToType);
7227
7228 /// Abstract base class used for diagnosing integer constant
7229 /// expression violations.
7231 public:
7233
7234 VerifyICEDiagnoser(bool Suppress = false) : Suppress(Suppress) {}
7235
7236 virtual SemaDiagnosticBuilder
7237 diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T);
7239 SourceLocation Loc) = 0;
7240 virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc);
7242 };
7243
7247 };
7248
7249 /// VerifyIntegerConstantExpression - Verifies that an expression is an ICE,
7250 /// and reports the appropriate diagnostics. Returns false on success.
7251 /// Can optionally return the value of the expression.
7253 VerifyICEDiagnoser &Diagnoser,
7254 AllowFoldKind CanFold = NoFold);
7256 unsigned DiagID,
7257 AllowFoldKind CanFold = NoFold);
7259 llvm::APSInt *Result = nullptr,
7260 AllowFoldKind CanFold = NoFold);
7262 AllowFoldKind CanFold = NoFold) {
7263 return VerifyIntegerConstantExpression(E, nullptr, CanFold);
7264 }
7265
7266 /// DiagnoseAssignmentAsCondition - Given that an expression is
7267 /// being used as a boolean condition, warn if it's an assignment.
7269
7270 /// Redundant parentheses over an equality comparison can indicate
7271 /// that the user intended an assignment used as condition.
7273
7275 public:
7276 FullExprArg() : E(nullptr) {}
7277 FullExprArg(Sema &actions) : E(nullptr) {}
7278
7279 ExprResult release() { return E; }
7280
7281 Expr *get() const { return E; }
7282
7283 Expr *operator->() { return E; }
7284
7285 private:
7286 // FIXME: No need to make the entire Sema class a friend when it's just
7287 // Sema::MakeFullExpr that needs access to the constructor below.
7288 friend class Sema;
7289
7290 explicit FullExprArg(Expr *expr) : E(expr) {}
7291
7292 Expr *E;
7293 };
7294
7296 return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation());
7297 }
7299 return FullExprArg(
7300 ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get());
7301 }
7303 ExprResult FE =
7304 ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(),
7305 /*DiscardedValue*/ true);
7306 return FullExprArg(FE.get());
7307 }
7308
7310 Decl *ConditionVar;
7312 bool Invalid;
7313 std::optional<bool> KnownValue;
7314
7315 friend class Sema;
7316 ConditionResult(Sema &S, Decl *ConditionVar, FullExprArg Condition,
7317 bool IsConstexpr)
7318 : ConditionVar(ConditionVar), Condition(Condition), Invalid(false) {
7319 if (IsConstexpr && Condition.get()) {
7320 if (std::optional<llvm::APSInt> Val =
7321 Condition.get()->getIntegerConstantExpr(S.Context)) {
7322 KnownValue = !!(*Val);
7323 }
7324 }
7325 }
7326 explicit ConditionResult(bool Invalid)
7327 : ConditionVar(nullptr), Condition(nullptr), Invalid(Invalid),
7328 KnownValue(std::nullopt) {}
7329
7330 public:
7332 bool isInvalid() const { return Invalid; }
7333 std::pair<VarDecl *, Expr *> get() const {
7334 return std::make_pair(cast_or_null<VarDecl>(ConditionVar),
7335 Condition.get());
7336 }
7337 std::optional<bool> getKnownValue() const { return KnownValue; }
7338 };
7340
7341 /// CheckBooleanCondition - Diagnose problems involving the use of
7342 /// the given expression as a boolean condition (e.g. in an if
7343 /// statement). Also performs the standard function and array
7344 /// decays, possibly changing the input variable.
7345 ///
7346 /// \param Loc - A location associated with the condition, e.g. the
7347 /// 'if' keyword.
7348 /// \return true iff there were any errors
7350 bool IsConstexpr = false);
7351
7352 enum class ConditionKind {
7353 Boolean, ///< A boolean condition, from 'if', 'while', 'for', or 'do'.
7354 ConstexprIf, ///< A constant boolean condition from 'if constexpr'.
7355 Switch ///< An integral condition for a 'switch' statement.
7356 };
7357
7358 ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr,
7359 ConditionKind CK, bool MissingOK = false);
7360
7361 QualType CheckConditionalOperands( // C99 6.5.15
7362 ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK,
7363 ExprObjectKind &OK, SourceLocation QuestionLoc);
7364
7365 /// Emit a specialized diagnostic when one expression is a null pointer
7366 /// constant and the other is not a pointer. Returns true if a diagnostic is
7367 /// emitted.
7368 bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
7369 SourceLocation QuestionLoc);
7370
7371 /// type checking for vector binary operators.
7373 SourceLocation Loc, bool IsCompAssign,
7374 bool AllowBothBool, bool AllowBoolConversion,
7375 bool AllowBoolOperation, bool ReportInvalid);
7376
7377 /// Return a signed ext_vector_type that is of identical size and number of
7378 /// elements. For floating point vectors, return an integer type of identical
7379 /// size and number of elements. In the non ext_vector_type case, search from
7380 /// the largest type to the smallest type to avoid cases where long long ==
7381 /// long, where long gets picked over long long.
7384
7385 /// CheckVectorCompareOperands - vector comparisons are a clang extension that
7386 /// operates on extended vector types. Instead of producing an IntTy result,
7387 /// like a scalar comparison, a vector comparison produces a vector of integer
7388 /// types.
7391 BinaryOperatorKind Opc);
7394 BinaryOperatorKind Opc);
7397 BinaryOperatorKind Opc);
7398
7399 /// Context in which we're performing a usual arithmetic conversion.
7401 /// An arithmetic operation.
7403 /// A bitwise operation.
7405 /// A comparison.
7407 /// A conditional (?:) operator.
7409 /// A compound assignment expression.
7411 };
7412
7413 // type checking for sizeless vector binary operators.
7415 SourceLocation Loc, bool IsCompAssign,
7416 ArithConvKind OperationKind);
7417
7418 /// Type checking for matrix binary operators.
7421 bool IsCompAssign);
7423 SourceLocation Loc, bool IsCompAssign);
7424
7425 /// Are the two types SVE-bitcast-compatible types? I.e. is bitcasting from
7426 /// the first SVE type (e.g. an SVE VLAT) to the second type (e.g. an SVE
7427 /// VLST) allowed?
7428 ///
7429 /// This will also return false if the two given types do not make sense from
7430 /// the perspective of SVE bitcasts.
7431 bool isValidSveBitcast(QualType srcType, QualType destType);
7432
7433 /// Are the two types matrix types and do they have the same dimensions i.e.
7434 /// do they have the same number of rows and the same number of columns?
7436
7437 bool areVectorTypesSameSize(QualType srcType, QualType destType);
7438
7439 /// Are the two types lax-compatible vector types? That is, given
7440 /// that one of them is a vector, do they have equal storage sizes,
7441 /// where the storage size is the number of elements times the element
7442 /// size?
7443 ///
7444 /// This will also return false if either of the types is neither a
7445 /// vector nor a real type.
7446 bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
7447
7448 /// Is this a legal conversion between two types, one of which is
7449 /// known to be a vector type?
7450 bool isLaxVectorConversion(QualType srcType, QualType destType);
7451
7452 // This returns true if at least one of the types is an altivec vector.
7453 bool anyAltivecTypes(QualType srcType, QualType destType);
7454
7455 // type checking C++ declaration initializers (C++ [dcl.init]).
7456
7457 /// Check a cast of an unknown-any type. We intentionally only
7458 /// trigger this for C-style casts.
7462
7463 /// Force an expression with unknown-type to an expression of the
7464 /// given type.
7466
7467 /// Type-check an expression that's being passed to an
7468 /// __unknown_anytype parameter.
7470 QualType &paramType);
7471
7472 // CheckMatrixCast - Check type constraints for matrix casts.
7473 // We allow casting between matrixes of the same dimensions i.e. when they
7474 // have the same number of rows and column. Returns true if the cast is
7475 // invalid.
7476 bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy,
7477 CastKind &Kind);
7478
7479 // CheckVectorCast - check type constraints for vectors.
7480 // Since vectors are an extension, there are no C standard reference for this.
7481 // We allow casting between vectors and integer datatypes of the same size.
7482 // returns true if the cast is invalid
7483 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
7484 CastKind &Kind);
7485
7486 /// Prepare `SplattedExpr` for a vector splat operation, adding
7487 /// implicit casts if necessary.
7488 ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);
7489
7490 // CheckExtVectorCast - check type constraints for extended vectors.
7491 // Since vectors are an extension, there are no C standard reference for this.
7492 // We allow casting between vectors and integer datatypes of the same size,
7493 // or vectors and the element type of that vector.
7494 // returns the cast expr
7496 CastKind &Kind);
7497
7500 }
7501
7502 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
7503 // functions and arrays to their respective pointers (C99 6.3.2.1).
7505
7506 /// CallExprUnaryConversions - a special case of an unary conversion
7507 /// performed on a function designator of a call expression.
7509
7510 // DefaultFunctionArrayConversion - converts functions and arrays
7511 // to their respective pointers (C99 6.3.2.1).
7513
7514 // DefaultFunctionArrayLvalueConversion - converts functions and
7515 // arrays to their respective pointers and performs the
7516 // lvalue-to-rvalue conversion.
7518 bool Diagnose = true);
7519
7520 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
7521 // the operand. This function is a no-op if the operand has a function type
7522 // or an array type.
7524
7525 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
7526 // do not have a prototype. Integer promotions are performed on each
7527 // argument, and arguments that have type float are promoted to double.
7529
7531 const FunctionProtoType *Proto,
7532 Expr *Fn);
7533
7534 // Used for determining in which context a type is allowed to be passed to a
7535 // vararg function.
7543
7544 /// Determine the degree of POD-ness for an expression.
7545 /// Incomplete types are considered POD, since this check can be performed
7546 /// when we're in an unevaluated context.
7548
7549 /// Check to see if the given expression is a valid argument to a variadic
7550 /// function, issuing a diagnostic if not.
7552
7553 /// GatherArgumentsForCall - Collector argument expressions for various
7554 /// form of call prototypes.
7556 const FunctionProtoType *Proto,
7557 unsigned FirstParam, ArrayRef<Expr *> Args,
7558 SmallVectorImpl<Expr *> &AllArgs,
7560 bool AllowExplicit = false,
7561 bool IsListInitialization = false);
7562
7563 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
7564 // will create a runtime trap if the resulting type is not a POD type.
7566 FunctionDecl *FDecl);
7567
7568 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
7569 // operands and then handles various conversions that are common to binary
7570 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
7571 // routine returns the first non-arithmetic type found. The client is
7572 // responsible for emitting appropriate error diagnostics.
7575
7576 /// AssignConvertType - All of the 'assignment' semantic checks return this
7577 /// enum to indicate whether the assignment was allowed. These checks are
7578 /// done for simple assignments, as well as initialization, return from
7579 /// function, argument passing, etc. The query is phrased in terms of a
7580 /// source and destination type.
7582 /// Compatible - the types are compatible according to the standard.
7584
7585 /// PointerToInt - The assignment converts a pointer to an int, which we
7586 /// accept as an extension.
7588
7589 /// IntToPointer - The assignment converts an int to a pointer, which we
7590 /// accept as an extension.
7592
7593 /// FunctionVoidPointer - The assignment is between a function pointer and
7594 /// void*, which the standard doesn't allow, but we accept as an extension.
7596
7597 /// IncompatiblePointer - The assignment is between two pointers types that
7598 /// are not compatible, but we accept them as an extension.
7600
7601 /// IncompatibleFunctionPointer - The assignment is between two function
7602 /// pointers types that are not compatible, but we accept them as an
7603 /// extension.
7605
7606 /// IncompatibleFunctionPointerStrict - The assignment is between two
7607 /// function pointer types that are not identical, but are compatible,
7608 /// unless compiled with -fsanitize=cfi, in which case the type mismatch
7609 /// may trip an indirect call runtime check.
7611
7612 /// IncompatiblePointerSign - The assignment is between two pointers types
7613 /// which point to integers which have a different sign, but are otherwise
7614 /// identical. This is a subset of the above, but broken out because it's by
7615 /// far the most common case of incompatible pointers.
7617
7618 /// CompatiblePointerDiscardsQualifiers - The assignment discards
7619 /// c/v/r qualifiers, which we accept as an extension.
7621
7622 /// IncompatiblePointerDiscardsQualifiers - The assignment
7623 /// discards qualifiers that we don't permit to be discarded,
7624 /// like address spaces.
7626
7627 /// IncompatibleNestedPointerAddressSpaceMismatch - The assignment
7628 /// changes address spaces in nested pointer types which is not allowed.
7629 /// For instance, converting __private int ** to __generic int ** is
7630 /// illegal even though __private could be converted to __generic.
7632
7633 /// IncompatibleNestedPointerQualifiers - The assignment is between two
7634 /// nested pointer types, and the qualifiers other than the first two
7635 /// levels differ e.g. char ** -> const char **, but we accept them as an
7636 /// extension.
7638
7639 /// IncompatibleVectors - The assignment is between two vector types that
7640 /// have the same size, which we accept as an extension.
7642
7643 /// IntToBlockPointer - The assignment converts an int to a block
7644 /// pointer. We disallow this.
7646
7647 /// IncompatibleBlockPointer - The assignment is between two block
7648 /// pointers types that are not compatible.
7650
7651 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
7652 /// id type and something else (that is incompatible with it). For example,
7653 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
7655
7656 /// IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an
7657 /// object with __weak qualifier.
7659
7660 /// Incompatible - We reject this conversion outright, it is invalid to
7661 /// represent it in the AST.
7664
7665 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
7666 /// assignment conversion type specified by ConvTy. This returns true if the
7667 /// conversion was invalid or false if the conversion was accepted.
7669 QualType DstType, QualType SrcType,
7670 Expr *SrcExpr, AssignmentAction Action,
7671 bool *Complained = nullptr);
7672
7673 /// CheckAssignmentConstraints - Perform type checking for assignment,
7674 /// argument passing, variable initialization, and function return values.
7675 /// C99 6.5.16.
7677 QualType LHSType,
7678 QualType RHSType);
7679
7680 /// Check assignment constraints and optionally prepare for a conversion of
7681 /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
7682 /// is true.
7684 ExprResult &RHS, CastKind &Kind,
7685 bool ConvertRHS = true);
7686
7687 /// Check assignment constraints for an assignment of RHS to LHSType.
7688 ///
7689 /// \param LHSType The destination type for the assignment.
7690 /// \param RHS The source expression for the assignment.
7691 /// \param Diagnose If \c true, diagnostics may be produced when checking
7692 /// for assignability. If a diagnostic is produced, \p RHS will be
7693 /// set to ExprError(). Note that this function may still return
7694 /// without producing a diagnostic, even for an invalid assignment.
7695 /// \param DiagnoseCFAudited If \c true, the target is a function parameter
7696 /// in an audited Core Foundation API and does not need to be checked
7697 /// for ARC retain issues.
7698 /// \param ConvertRHS If \c true, \p RHS will be updated to model the
7699 /// conversions necessary to perform the assignment. If \c false,
7700 /// \p Diagnose must also be \c false.
7702 QualType LHSType, ExprResult &RHS, bool Diagnose = true,
7703 bool DiagnoseCFAudited = false, bool ConvertRHS = true);
7704
7705 // If the lhs type is a transparent union, check whether we
7706 // can initialize the transparent union with the given expression.
7708 ExprResult &RHS);
7709
7710 /// the following "Check" methods will return a valid/converted QualType
7711 /// or a null QualType (indicating an error diagnostic was issued).
7712
7713 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
7715 ExprResult &RHS);
7716
7717 /// Diagnose cases where a scalar was implicitly converted to a vector and
7718 /// diagnose the underlying types. Otherwise, diagnose the error
7719 /// as invalid vector logical operands for non-C++ cases.
7721 ExprResult &RHS);
7722
7724 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign,
7725 bool IsDivide);
7726 QualType CheckRemainderOperands( // C99 6.5.5
7728 bool IsCompAssign = false);
7729 QualType CheckAdditionOperands( // C99 6.5.6
7731 BinaryOperatorKind Opc, QualType *CompLHSTy = nullptr);
7734 QualType *CompLHSTy = nullptr);
7735 QualType CheckShiftOperands( // C99 6.5.7
7737 BinaryOperatorKind Opc, bool IsCompAssign = false);
7739 QualType CheckCompareOperands( // C99 6.5.8/9
7741 BinaryOperatorKind Opc);
7742 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
7744 BinaryOperatorKind Opc);
7745 QualType CheckLogicalOperands( // C99 6.5.[13,14]
7747 BinaryOperatorKind Opc);
7748 // CheckAssignmentOperands is used for both simple and compound assignment.
7749 // For simple assignment, pass both expressions and a null converted type.
7750 // For compound assignment, pass both expressions and the converted type.
7751 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
7752 Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType,
7753 BinaryOperatorKind Opc);
7754
7755 /// To be used for checking whether the arguments being passed to
7756 /// function exceeds the number of parameters expected for it.
7757 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
7758 bool PartialOverloading = false) {
7759 // We check whether we're just after a comma in code-completion.
7760 if (NumArgs > 0 && PartialOverloading)
7761 return NumArgs + 1 > NumParams; // If so, we view as an extra argument.
7762 return NumArgs > NumParams;
7763 }
7764
7765 /// Whether the AST is currently being rebuilt to correct immediate
7766 /// invocations. Immediate invocation candidates and references to consteval
7767 /// functions aren't tracked when this is set.
7769
7772 return (Ctx.isConstantEvaluated() || isConstantEvaluatedOverride) &&
7773 !Ctx.InConditionallyConstantEvaluateContext;
7774 }
7775
7776 /// Determines whether we are currently in a context that
7777 /// is not evaluated as per C++ [expr] p5.
7780 }
7781
7784 }
7785
7788 }
7789
7792 }
7793
7796 return (Ctx.Context ==
7798 Ctx.IsCurrentlyCheckingDefaultArgumentOrInitializer;
7799 }
7800
7801 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7803 assert(!ExprEvalContexts.empty() &&
7804 "Must be in an expression evaluation context");
7805 for (const auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7807 Ctx.DelayedDefaultInitializationContext)
7808 return Ctx.DelayedDefaultInitializationContext;
7809 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7810 Ctx.isUnevaluated())
7811 break;
7812 }
7813 return std::nullopt;
7814 }
7815
7816 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
7818 assert(!ExprEvalContexts.empty() &&
7819 "Must be in an expression evaluation context");
7820 std::optional<ExpressionEvaluationContextRecord::InitializationContext> Res;
7821 for (auto &Ctx : llvm::reverse(ExprEvalContexts)) {
7823 !Ctx.DelayedDefaultInitializationContext && Res)
7824 break;
7825 if (Ctx.isConstantEvaluated() || Ctx.isImmediateFunctionContext() ||
7826 Ctx.isUnevaluated())
7827 break;
7828 Res = Ctx.DelayedDefaultInitializationContext;
7829 }
7830 return Res;
7831 }
7832
7835 }
7836
7837 /// Returns a field in a CXXRecordDecl that has the same name as the decl \p
7838 /// SelfAssigned when inside a CXXMethodDecl.
7839 const FieldDecl *
7841
7843
7844 template <typename... Ts>
7846 const Ts &...Args) {
7847 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7849 }
7850
7851 template <typename... Ts>
7852 bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID,
7853 const Ts &...Args) {
7854 SizelessTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
7856 }
7857
7858 /// Abstract class used to diagnose incomplete types.
7861
7862 virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) = 0;
7863 virtual ~TypeDiagnoser() {}
7864 };
7865
7866 template <typename... Ts> class BoundTypeDiagnoser : public TypeDiagnoser {
7867 protected:
7868 unsigned DiagID;
7869 std::tuple<const Ts &...> Args;
7870
7871 template <std::size_t... Is>
7873 std::index_sequence<Is...>) const {
7874 // Apply all tuple elements to the builder in order.
7875 bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
7876 (void)Dummy;
7877 }
7878
7879 public:
7880 BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7881 : TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
7882 assert(DiagID != 0 && "no diagnostic for type diagnoser");
7883 }
7884
7885 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7886 const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
7887 emit(DB, std::index_sequence_for<Ts...>());
7888 DB << T;
7889 }
7890 };
7891
7892 /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
7893 /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
7894 /// For example, a diagnostic with no other parameters would generally have
7895 /// the form "...%select{incomplete|sizeless}0 type %1...".
7896 template <typename... Ts>
7898 public:
7899 SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
7900 : BoundTypeDiagnoser<Ts...>(DiagID, Args...) {}
7901
7902 void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
7903 const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
7904 this->emit(DB, std::index_sequence_for<Ts...>());
7905 DB << T->isSizelessType() << T;
7906 }
7907 };
7908
7909 /// Check an argument list for placeholders that we won't try to
7910 /// handle later.
7912
7913 /// The C++ "std::source_location::__impl" struct, defined in
7914 /// <source_location>.
7916
7917 /// A stack of expression evaluation contexts.
7919
7920 // Set of failed immediate invocations to avoid double diagnosing.
7922
7923 /// List of SourceLocations where 'self' is implicitly retained inside a
7924 /// block.
7927
7928 /// Do an explicit extend of the given block pointer if we're in ARC.
7930
7931 std::vector<std::pair<QualType, unsigned>> ExcessPrecisionNotSatisfied;
7934
7935private:
7936 static BinaryOperatorKind ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind);
7937
7938 /// Methods for marking which expressions involve dereferencing a pointer
7939 /// marked with the 'noderef' attribute. Expressions are checked bottom up as
7940 /// they are parsed, meaning that a noderef pointer may not be accessed. For
7941 /// example, in `&*p` where `p` is a noderef pointer, we will first parse the
7942 /// `*p`, but need to check that `address of` is called on it. This requires
7943 /// keeping a container of all pending expressions and checking if the address
7944 /// of them are eventually taken.
7945 void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E);
7946 void CheckAddressOfNoDeref(const Expr *E);
7947
7948 ///@}
7949
7950 //
7951 //
7952 // -------------------------------------------------------------------------
7953 //
7954 //
7955
7956 /// \name C++ Expressions
7957 /// Implementations are in SemaExprCXX.cpp
7958 ///@{
7959
7960public:
7961 /// The C++ "std::bad_alloc" class, which is defined by the C++
7962 /// standard library.
7964
7965 /// The C++ "std::align_val_t" enum class, which is defined by the C++
7966 /// standard library.
7968
7969 /// The C++ "type_info" declaration, which is defined in <typeinfo>.
7971
7972 /// A flag to remember whether the implicit forms of operator new and delete
7973 /// have been declared.
7975
7976 /// Delete-expressions to be analyzed at the end of translation unit
7977 ///
7978 /// This list contains class members, and locations of delete-expressions
7979 /// that could not be proven as to whether they mismatch with new-expression
7980 /// used in initializer of the field.
7981 llvm::MapVector<FieldDecl *, DeleteLocs> DeleteExprs;
7982
7983 /// Handle the result of the special case name lookup for inheriting
7984 /// constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as
7985 /// constructor names in member using declarations, even if 'X' is not the
7986 /// name of the corresponding type.
7988 SourceLocation NameLoc,
7989 const IdentifierInfo &Name);
7990
7992 SourceLocation NameLoc, Scope *S,
7993 CXXScopeSpec &SS, bool EnteringContext);
7995 Scope *S, CXXScopeSpec &SS,
7996 ParsedType ObjectType, bool EnteringContext);
7997
7999 ParsedType ObjectType);
8000
8001 /// Build a C++ typeid expression with a type operand.
8002 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8003 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8004
8005 /// Build a C++ typeid expression with an expression operand.
8006 ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc,
8007 Expr *Operand, SourceLocation RParenLoc);
8008
8009 /// ActOnCXXTypeid - Parse typeid( something ).
8011 bool isType, void *TyOrExpr,
8012 SourceLocation RParenLoc);
8013
8014 /// Build a Microsoft __uuidof expression with a type operand.
8015 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8016 TypeSourceInfo *Operand, SourceLocation RParenLoc);
8017
8018 /// Build a Microsoft __uuidof expression with an expression operand.
8019 ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc,
8020 Expr *Operand, SourceLocation RParenLoc);
8021
8022 /// ActOnCXXUuidof - Parse __uuidof( something ).
8024 bool isType, void *TyOrExpr,
8025 SourceLocation RParenLoc);
8026
8027 //// ActOnCXXThis - Parse 'this' pointer.
8029
8030 /// Check whether the type of 'this' is valid in the current context.
8032
8033 /// Build a CXXThisExpr and mark it referenced in the current context.
8035 void MarkThisReferenced(CXXThisExpr *This);
8036
8037 /// Try to retrieve the type of the 'this' pointer.
8038 ///
8039 /// \returns The type of 'this', if possible. Otherwise, returns a NULL type.
8041
8042 /// When non-NULL, the C++ 'this' expression is allowed despite the
8043 /// current context not being a non-static member function. In such cases,
8044 /// this provides the type used for 'this'.
8046
8047 /// RAII object used to temporarily allow the C++ 'this' expression
8048 /// to be used, with the given qualifiers on the current class type.
8050 Sema &S;
8051 QualType OldCXXThisTypeOverride;
8052 bool Enabled;
8053
8054 public:
8055 /// Introduce a new scope where 'this' may be allowed (when enabled),
8056 /// using the given declaration (which is either a class template or a
8057 /// class) along with the given qualifiers.
8058 /// along with the qualifiers placed on '*this'.
8059 CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals,
8060 bool Enabled = true);
8061
8063 };
8064
8065 /// Make sure the value of 'this' is actually available in the current
8066 /// context, if it is a potentially evaluated context.
8067 ///
8068 /// \param Loc The location at which the capture of 'this' occurs.
8069 ///
8070 /// \param Explicit Whether 'this' is explicitly captured in a lambda
8071 /// capture list.
8072 ///
8073 /// \param FunctionScopeIndexToStopAt If non-null, it points to the index
8074 /// of the FunctionScopeInfo stack beyond which we do not attempt to capture.
8075 /// This is useful when enclosing lambdas must speculatively capture
8076 /// 'this' that may or may not be used in certain specializations of
8077 /// a nested generic lambda (depending on whether the name resolves to
8078 /// a non-static member function or a static function).
8079 /// \return returns 'true' if failed, 'false' if success.
8081 SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true,
8082 const unsigned *const FunctionScopeIndexToStopAt = nullptr,
8083 bool ByCopy = false);
8084
8085 /// Determine whether the given type is the type of *this that is used
8086 /// outside of the body of a member function for a type that is currently
8087 /// being defined.
8089
8090 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
8092
8093 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
8095
8096 //// ActOnCXXThrow - Parse throw expressions.
8099 bool IsThrownVarInScope);
8100
8101 /// CheckCXXThrowOperand - Validate the operand of a throw.
8102 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E);
8103
8104 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
8105 /// Can be interpreted either as function-style casting ("int(x)")
8106 /// or class type construction ("ClassType(x,y,z)")
8107 /// or creation of a value-initialized type ("int()").
8109 SourceLocation LParenOrBraceLoc,
8110 MultiExprArg Exprs,
8111 SourceLocation RParenOrBraceLoc,
8112 bool ListInitialization);
8113
8115 SourceLocation LParenLoc,
8116 MultiExprArg Exprs,
8117 SourceLocation RParenLoc,
8118 bool ListInitialization);
8119
8120 /// Parsed a C++ 'new' expression (C++ 5.3.4).
8121 ///
8122 /// E.g.:
8123 /// @code new (memory) int[size][4] @endcode
8124 /// or
8125 /// @code ::new Foo(23, "hello") @endcode
8126 ///
8127 /// \param StartLoc The first location of the expression.
8128 /// \param UseGlobal True if 'new' was prefixed with '::'.
8129 /// \param PlacementLParen Opening paren of the placement arguments.
8130 /// \param PlacementArgs Placement new arguments.
8131 /// \param PlacementRParen Closing paren of the placement arguments.
8132 /// \param TypeIdParens If the type is in parens, the source range.
8133 /// \param D The type to be allocated, as well as array dimensions.
8134 /// \param Initializer The initializing expression or initializer-list, or
8135 /// null if there is none.
8136 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
8137 SourceLocation PlacementLParen,
8138 MultiExprArg PlacementArgs,
8139 SourceLocation PlacementRParen,
8140 SourceRange TypeIdParens, Declarator &D,
8141 Expr *Initializer);
8143 BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen,
8144 MultiExprArg PlacementArgs, SourceLocation PlacementRParen,
8145 SourceRange TypeIdParens, QualType AllocType,
8146 TypeSourceInfo *AllocTypeInfo, std::optional<Expr *> ArraySize,
8147 SourceRange DirectInitRange, Expr *Initializer);
8148
8149 /// Determine whether \p FD is an aligned allocation or deallocation
8150 /// function that is unavailable.
8152
8153 /// Produce diagnostics if \p FD is an aligned allocation or deallocation
8154 /// function that is unavailable.
8157
8158 /// Checks that a type is suitable as the allocated type
8159 /// in a new-expression.
8161 SourceRange R);
8162
8163 /// The scope in which to find allocation functions.
8165 /// Only look for allocation functions in the global scope.
8167 /// Only look for allocation functions in the scope of the
8168 /// allocated class.
8170 /// Look for allocation functions in both the global scope
8171 /// and in the scope of the allocated class.
8172 AFS_Both
8174
8175 /// Finds the overloads of operator new and delete that are appropriate
8176 /// for the allocation.
8178 AllocationFunctionScope NewScope,
8179 AllocationFunctionScope DeleteScope,
8180 QualType AllocType, bool IsArray,
8181 bool &PassAlignment, MultiExprArg PlaceArgs,
8182 FunctionDecl *&OperatorNew,
8183 FunctionDecl *&OperatorDelete,
8184 bool Diagnose = true);
8185
8186 /// DeclareGlobalNewDelete - Declare the global forms of operator new and
8187 /// delete. These are:
8188 /// @code
8189 /// // C++03:
8190 /// void* operator new(std::size_t) throw(std::bad_alloc);
8191 /// void* operator new[](std::size_t) throw(std::bad_alloc);
8192 /// void operator delete(void *) throw();
8193 /// void operator delete[](void *) throw();
8194 /// // C++11:
8195 /// void* operator new(std::size_t);
8196 /// void* operator new[](std::size_t);
8197 /// void operator delete(void *) noexcept;
8198 /// void operator delete[](void *) noexcept;
8199 /// // C++1y:
8200 /// void* operator new(std::size_t);
8201 /// void* operator new[](std::size_t);
8202 /// void operator delete(void *) noexcept;
8203 /// void operator delete[](void *) noexcept;
8204 /// void operator delete(void *, std::size_t) noexcept;
8205 /// void operator delete[](void *, std::size_t) noexcept;
8206 /// @endcode
8207 /// Note that the placement and nothrow forms of new are *not* implicitly
8208 /// declared. Their use requires including <new>.
8211 ArrayRef<QualType> Params);
8212
8214 DeclarationName Name, FunctionDecl *&Operator,
8215 bool Diagnose = true, bool WantSize = false,
8216 bool WantAligned = false);
8218 bool CanProvideSize,
8219 bool Overaligned,
8220 DeclarationName Name);
8222 CXXRecordDecl *RD);
8223
8224 /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
8225 /// @code ::delete ptr; @endcode
8226 /// or
8227 /// @code delete [] ptr; @endcode
8228 ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
8229 bool ArrayForm, Expr *Operand);
8231 bool IsDelete, bool CallCanBeVirtual,
8232 bool WarnOnNonAbstractTypes,
8233 SourceLocation DtorLoc);
8234
8236 Expr *Operand, SourceLocation RParen);
8238 SourceLocation RParen);
8239
8241 SourceLocation OpLoc,
8242 tok::TokenKind OpKind,
8243 ParsedType &ObjectType,
8244 bool &MayBePseudoDestructor);
8245
8247 Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8248 const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc,
8249 SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType);
8250
8252 Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind,
8253 CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc,
8254 SourceLocation TildeLoc, UnqualifiedId &SecondTypeName);
8255
8257 SourceLocation OpLoc,
8258 tok::TokenKind OpKind,
8259 SourceLocation TildeLoc,
8260 const DeclSpec &DS);
8261
8262 /// MaybeCreateExprWithCleanups - If the current full-expression
8263 /// requires any cleanups, surround it with a ExprWithCleanups node.
8264 /// Otherwise, just returns the passed-in expression.
8268
8269 ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) {
8270 return ActOnFinishFullExpr(
8271 Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue);
8272 }
8274 bool DiscardedValue, bool IsConstexpr = false,
8275 bool IsTemplateArgument = false);
8277
8278 /// Process the expression contained within a decltype. For such expressions,
8279 /// certain semantic checks on temporaries are delayed until this point, and
8280 /// are omitted for the 'topmost' call in the decltype expression. If the
8281 /// topmost call bound a temporary, strip that temporary off the expression.
8283
8284 bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id,
8285 bool IsUDSuffix);
8286
8288
8289 ConditionResult ActOnConditionVariable(Decl *ConditionVar,
8290 SourceLocation StmtLoc,
8291 ConditionKind CK);
8292
8293 /// Check the use of the given variable as a C++ condition in an if,
8294 /// while, do-while, or switch statement.
8296 SourceLocation StmtLoc, ConditionKind CK);
8297
8298 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
8299 ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr = false);
8300
8301 /// Helper function to determine whether this is the (deprecated) C++
8302 /// conversion from a string literal to a pointer to non-const char or
8303 /// non-const wchar_t (for narrow and wide string literals,
8304 /// respectively).
8306
8307 /// PerformImplicitConversion - Perform an implicit conversion of the
8308 /// expression From to the type ToType using the pre-computed implicit
8309 /// conversion sequence ICS. Returns the converted
8310 /// expression. Action is the kind of conversion we're performing,
8311 /// used in the error message.
8313 Expr *From, QualType ToType, const ImplicitConversionSequence &ICS,
8314 AssignmentAction Action,
8316
8317 /// PerformImplicitConversion - Perform an implicit conversion of the
8318 /// expression From to the type ToType by following the standard
8319 /// conversion sequence SCS. Returns the converted
8320 /// expression. Flavor is the context in which we're performing this
8321 /// conversion, for use in error messages.
8323 const StandardConversionSequence &SCS,
8324 AssignmentAction Action,
8326
8327 bool CheckTypeTraitArity(unsigned Arity, SourceLocation Loc, size_t N);
8328
8329 /// Parsed one of the type trait support pseudo-functions.
8332 SourceLocation RParenLoc);
8335 SourceLocation RParenLoc);
8336
8337 /// ActOnArrayTypeTrait - Parsed one of the binary type trait support
8338 /// pseudo-functions.
8340 ParsedType LhsTy, Expr *DimExpr,
8341 SourceLocation RParen);
8342
8344 TypeSourceInfo *TSInfo, Expr *DimExpr,
8345 SourceLocation RParen);
8346
8347 /// ActOnExpressionTrait - Parsed one of the unary type trait support
8348 /// pseudo-functions.
8350 Expr *Queried, SourceLocation RParen);
8351
8353 Expr *Queried, SourceLocation RParen);
8354
8356 ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc,
8357 bool isIndirect);
8359 ExprResult &RHS,
8360 SourceLocation QuestionLoc);
8361
8363 ExprResult &LHS, ExprResult &RHS,
8364 SourceLocation QuestionLoc);
8365
8366 /// Check the operands of ?: under C++ semantics.
8367 ///
8368 /// See C++ [expr.cond]. Note that LHS is never null, even for the GNU x ?: y
8369 /// extension. In this case, LHS == Cond. (But they're not aliases.)
8370 ///
8371 /// This function also implements GCC's vector extension and the
8372 /// OpenCL/ext_vector_type extension for conditionals. The vector extensions
8373 /// permit the use of a?b:c where the type of a is that of a integer vector
8374 /// with the same number of elements and size as the vectors of b and c. If
8375 /// one of either b or c is a scalar it is implicitly converted to match the
8376 /// type of the vector. Otherwise the expression is ill-formed. If both b and
8377 /// c are scalars, then b and c are checked and converted to the type of a if
8378 /// possible.
8379 ///
8380 /// The expressions are evaluated differently for GCC's and OpenCL's
8381 /// extensions. For the GCC extension, the ?: operator is evaluated as
8382 /// (a[0] != 0 ? b[0] : c[0], .. , a[n] != 0 ? b[n] : c[n]).
8383 /// For the OpenCL extensions, the ?: operator is evaluated as
8384 /// (most-significant-bit-set(a[0]) ? b[0] : c[0], .. ,
8385 /// most-significant-bit-set(a[n]) ? b[n] : c[n]).
8387 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK,
8388 ExprObjectKind &OK, SourceLocation questionLoc);
8389
8390 /// Find a merged pointer type and convert the two expressions to it.
8391 ///
8392 /// This finds the composite pointer type for \p E1 and \p E2 according to
8393 /// C++2a [expr.type]p3. It converts both expressions to this type and returns
8394 /// it. It does not emit diagnostics (FIXME: that's not true if \p
8395 /// ConvertArgs is \c true).
8396 ///
8397 /// \param Loc The location of the operator requiring these two expressions to
8398 /// be converted to the composite pointer type.
8399 ///
8400 /// \param ConvertArgs If \c false, do not convert E1 and E2 to the target
8401 /// type.
8403 bool ConvertArgs = true);
8405 ExprResult &E2, bool ConvertArgs = true) {
8406 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
8407 QualType Composite =
8408 FindCompositePointerType(Loc, E1Tmp, E2Tmp, ConvertArgs);
8409 E1 = E1Tmp;
8410 E2 = E2Tmp;
8411 return Composite;
8412 }
8413
8414 /// MaybeBindToTemporary - If the passed in expression has a record type with
8415 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
8416 /// it simply returns the passed in expression.
8418
8419 /// IgnoredValueConversions - Given that an expression's result is
8420 /// syntactically ignored, perform any conversions that are
8421 /// required.
8423
8425
8426 /// Process any TypoExprs in the given Expr and its children,
8427 /// generating diagnostics as appropriate and returning a new Expr if there
8428 /// were typos that were all successfully corrected and ExprError if one or
8429 /// more typos could not be corrected.
8430 ///
8431 /// \param E The Expr to check for TypoExprs.
8432 ///
8433 /// \param InitDecl A VarDecl to avoid because the Expr being corrected is its
8434 /// initializer.
8435 ///
8436 /// \param RecoverUncorrectedTypos If true, when typo correction fails, it
8437 /// will rebuild the given Expr with all TypoExprs degraded to RecoveryExprs.
8438 ///
8439 /// \param Filter A function applied to a newly rebuilt Expr to determine if
8440 /// it is an acceptable/usable result from a single combination of typo
8441 /// corrections. As long as the filter returns ExprError, different
8442 /// combinations of corrections will be tried until all are exhausted.
8444 Expr *E, VarDecl *InitDecl = nullptr,
8445 bool RecoverUncorrectedTypos = false,
8446 llvm::function_ref<ExprResult(Expr *)> Filter =
8447 [](Expr *E) -> ExprResult { return E; });
8448
8450 ExprResult ER, VarDecl *InitDecl = nullptr,
8451 bool RecoverUncorrectedTypos = false,
8452 llvm::function_ref<ExprResult(Expr *)> Filter =
8453 [](Expr *E) -> ExprResult { return E; }) {
8454 return ER.isInvalid()
8455 ? ER
8456 : CorrectDelayedTyposInExpr(ER.get(), InitDecl,
8457 RecoverUncorrectedTypos, Filter);
8458 }
8459
8460 /// Describes the result of an "if-exists" condition check.
8462 /// The symbol exists.
8464
8465 /// The symbol does not exist.
8467
8468 /// The name is a dependent name, so the results will differ
8469 /// from one instantiation to the next.
8471
8472 /// An error occurred.
8473 IER_Error
8475
8478 const DeclarationNameInfo &TargetNameInfo);
8479
8481 SourceLocation KeywordLoc,
8482 bool IsIfExists, CXXScopeSpec &SS,
8483 UnqualifiedId &Name);
8484
8487 ArrayRef<ParmVarDecl *> LocalParameters,
8488 Scope *BodyScope);
8492 CXXScopeSpec &SS,
8493 SourceLocation NameLoc,
8494 const IdentifierInfo *TypeName,
8495 TemplateIdAnnotation *TemplateId);
8497 SourceLocation NoexceptLoc);
8499 Expr *E, SourceLocation NoexceptLoc, CXXScopeSpec &SS,
8500 TemplateIdAnnotation *TypeConstraint, unsigned Depth);
8503 Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc,
8507 bool IsSatisfied, SourceLocation NoexceptLoc,
8514 BuildNestedRequirement(StringRef InvalidConstraintEntity,
8515 const ASTConstraintSatisfaction &Satisfaction);
8518 SourceLocation LParenLoc,
8519 ArrayRef<ParmVarDecl *> LocalParameters,
8520 SourceLocation RParenLoc,
8522 SourceLocation ClosingBraceLoc);
8523
8524private:
8525 ExprResult BuiltinOperatorNewDeleteOverloaded(ExprResult TheCallResult,
8526 bool IsDelete);
8527
8528 void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
8529 void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,
8530 bool DeleteWasArrayForm);
8531
8532 ///@}
8533
8534 //
8535 //
8536 // -------------------------------------------------------------------------
8537 //
8538 //
8539
8540 /// \name Member Access Expressions
8541 /// Implementations are in SemaExprMember.cpp
8542 ///@{
8543
8544public:
8545 /// Check whether an expression might be an implicit class member access.
8547 bool IsAddressOfOperand);
8548
8549 /// Builds an expression which might be an implicit member expression.
8551 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R,
8552 const TemplateArgumentListInfo *TemplateArgs, const Scope *S);
8553
8554 /// Builds an implicit member access expression. The current context
8555 /// is known to be an instance method, and the given unqualified lookup
8556 /// set is known to contain only instance members, at least one of which
8557 /// is from an appropriate type.
8559 BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8560 LookupResult &R,
8561 const TemplateArgumentListInfo *TemplateArgs,
8562 bool IsDefiniteInstance, const Scope *S);
8563
8565 Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc,
8566 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8567 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8568 const TemplateArgumentListInfo *TemplateArgs);
8569
8570 /// The main callback when the parser finds something like
8571 /// expression . [nested-name-specifier] identifier
8572 /// expression -> [nested-name-specifier] identifier
8573 /// where 'identifier' encompasses a fairly broad spectrum of
8574 /// possibilities, including destructor and operator references.
8575 ///
8576 /// \param OpKind either tok::arrow or tok::period
8577 /// \param ObjCImpDecl the current Objective-C \@implementation
8578 /// decl; this is an ugly hack around the fact that Objective-C
8579 /// \@implementations aren't properly put in the context chain
8581 tok::TokenKind OpKind, CXXScopeSpec &SS,
8582 SourceLocation TemplateKWLoc,
8583 UnqualifiedId &Member, Decl *ObjCImpDecl);
8584
8585 MemberExpr *
8586 BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
8587 NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
8588 ValueDecl *Member, DeclAccessPair FoundDecl,
8589 bool HadMultipleCandidates,
8590 const DeclarationNameInfo &MemberNameInfo, QualType Ty,
8592 const TemplateArgumentListInfo *TemplateArgs = nullptr);
8593
8594 // Check whether the declarations we found through a nested-name
8595 // specifier in a member expression are actually members of the base
8596 // type. The restriction here is:
8597 //
8598 // C++ [expr.ref]p2:
8599 // ... In these cases, the id-expression shall name a
8600 // member of the class or of one of its base classes.
8601 //
8602 // So it's perfectly legitimate for the nested-name specifier to name
8603 // an unrelated class, and for us to find an overload set including
8604 // decls from classes which are not superclasses, as long as the decl
8605 // we actually pick through overload resolution is from a superclass.
8606 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
8607 const CXXScopeSpec &SS,
8608 const LookupResult &R);
8609
8610 // This struct is for use by ActOnMemberAccess to allow
8611 // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after
8612 // changing the access operator from a '.' to a '->' (to see if that is the
8613 // change needed to fix an error about an unknown member, e.g. when the class
8614 // defines a custom operator->).
8619 };
8620
8622 Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow,
8623 CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
8624 NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
8625 const TemplateArgumentListInfo *TemplateArgs, const Scope *S,
8626 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8627
8630 bool IsArrow, const CXXScopeSpec &SS,
8631 SourceLocation TemplateKWLoc,
8632 NamedDecl *FirstQualifierInScope, LookupResult &R,
8633 const TemplateArgumentListInfo *TemplateArgs,
8634 const Scope *S, bool SuppressQualifierCheck = false,
8635 ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
8636
8637 ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
8638 SourceLocation OpLoc,
8639 const CXXScopeSpec &SS, FieldDecl *Field,
8640 DeclAccessPair FoundDecl,
8641 const DeclarationNameInfo &MemberNameInfo);
8642
8643 /// Perform conversions on the LHS of a member access expression.
8645
8647 const CXXScopeSpec &SS, SourceLocation nameLoc,
8648 IndirectFieldDecl *indirectField,
8649 DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none),
8650 Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation());
8651
8652private:
8653 void CheckMemberAccessOfNoDeref(const MemberExpr *E);
8654
8655 ///@}
8656
8657 //
8658 //
8659 // -------------------------------------------------------------------------
8660 //
8661 //
8662
8663 /// \name Initializers
8664 /// Implementations are in SemaInit.cpp
8665 ///@{
8666
8667public:
8668 /// Stack of types that correspond to the parameter entities that are
8669 /// currently being copy-initialized. Can be empty.
8671
8672 llvm::DenseMap<unsigned, CXXDeductionGuideDecl *>
8674
8675 bool IsStringInit(Expr *Init, const ArrayType *AT);
8676
8677 /// Determine whether we can perform aggregate initialization for the purposes
8678 /// of overload resolution.
8680 const InitializedEntity &Entity, InitListExpr *From);
8681
8683 SourceLocation EqualOrColonLoc,
8684 bool GNUSyntax, ExprResult Init);
8685
8686 /// Check that the lifetime of the initializer (and its subobjects) is
8687 /// sufficient for initializing the entity, and perform lifetime extension
8688 /// (when permitted) if not.
8690
8693 bool BoundToLvalueReference);
8694
8695 /// If \p E is a prvalue denoting an unmaterialized temporary, materialize
8696 /// it as an xvalue. In C++98, the result will still be a prvalue, because
8697 /// we don't have xvalues there.
8699
8703
8707 SourceLocation EqualLoc, ExprResult Init,
8708 bool TopLevelOfInitList = false,
8709 bool AllowExplicit = false);
8710
8712 TypeSourceInfo *TInfo, const InitializedEntity &Entity,
8714
8715 ///@}
8716
8717 //
8718 //
8719 // -------------------------------------------------------------------------
8720 //
8721 //
8722
8723 /// \name C++ Lambda Expressions
8724 /// Implementations are in SemaLambda.cpp
8725 ///@{
8726
8727public:
8728 /// Create a new lambda closure type.
8730 TypeSourceInfo *Info,
8731 unsigned LambdaDependencyKind,
8732 LambdaCaptureDefault CaptureDefault);
8733
8734 /// Number lambda for linkage purposes if necessary.
8736 std::optional<CXXRecordDecl::LambdaNumbering>
8737 NumberingOverride = std::nullopt);
8738
8739 /// Endow the lambda scope info with the relevant properties.
8740 void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator,
8741 SourceRange IntroducerRange,
8742 LambdaCaptureDefault CaptureDefault,
8743 SourceLocation CaptureDefaultLoc, bool ExplicitParams,
8744 bool Mutable);
8745
8748
8750 CXXMethodDecl *CallOperator, CXXRecordDecl *Class,
8751 TemplateParameterList *TemplateParams);
8752
8754 CXXMethodDecl *Method, SourceLocation LambdaLoc,
8755 SourceLocation CallOperatorLoc, Expr *TrailingRequiresClause,
8756 TypeSourceInfo *MethodTyInfo, ConstexprSpecKind ConstexprKind,
8758 bool HasExplicitResultType);
8759
8760 /// Returns true if the explicit object parameter was invalid.
8762 SourceLocation CallLoc);
8763
8764 /// Perform initialization analysis of the init-capture and perform
8765 /// any implicit conversions such as an lvalue-to-rvalue conversion if
8766 /// not being used to initialize a reference.
8768 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8771 Loc, ByRef, EllipsisLoc, std::nullopt, Id,
8773 }
8775 SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc,
8776 std::optional<unsigned> NumExpansions, IdentifierInfo *Id,
8777 bool DirectInit, Expr *&Init);
8778
8779 /// Create a dummy variable within the declcontext of the lambda's
8780 /// call operator, for name lookup purposes for a lambda init capture.
8781 ///
8782 /// CodeGen handles emission of lambda captures, ignoring these dummy
8783 /// variables appropriately.
8785 SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc,
8786 IdentifierInfo *Id, unsigned InitStyle, Expr *Init, DeclContext *DeclCtx);
8787
8788 /// Add an init-capture to a lambda scope.
8789 void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var, bool ByRef);
8790
8791 /// Note that we have finished the explicit captures for the
8792 /// given lambda.
8794
8795 /// Deduce a block or lambda's return type based on the return
8796 /// statements present in the body.
8798
8799 /// Once the Lambdas capture are known, we can start to create the closure,
8800 /// call operator method, and keep track of the captures.
8801 /// We do the capture lookup here, but they are not actually captured until
8802 /// after we know what the qualifiers of the call operator are.
8804 Scope *CurContext);
8805
8806 /// This is called after parsing the explicit template parameter list
8807 /// on a lambda (if it exists) in C++2a.
8809 SourceLocation LAngleLoc,
8810 ArrayRef<NamedDecl *> TParams,
8811 SourceLocation RAngleLoc,
8812 ExprResult RequiresClause);
8813
8815 SourceLocation MutableLoc);
8816
8818 Scope *LambdaScope,
8820
8821 /// ActOnStartOfLambdaDefinition - This is called just before we start
8822 /// parsing the body of a lambda; it analyzes the explicit captures and
8823 /// arguments, and sets up various data-structures for the body of the
8824 /// lambda.
8826 Declarator &ParamInfo, const DeclSpec &DS);
8827
8828 /// ActOnLambdaError - If there is an error parsing a lambda, this callback
8829 /// is invoked to pop the information about the lambda.
8830 void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
8831 bool IsInstantiation = false);
8832
8833 /// ActOnLambdaExpr - This is called when the body of a lambda expression
8834 /// was successfully completed.
8836
8837 /// Does copying/destroying the captured variable have side effects?
8838 bool CaptureHasSideEffects(const sema::Capture &From);
8839
8840 /// Diagnose if an explicit lambda capture is unused. Returns true if a
8841 /// diagnostic is emitted.
8842 bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange,
8843 const sema::Capture &From);
8844
8845 /// Build a FieldDecl suitable to hold the given capture.
8847
8848 /// Initialize the given capture with a suitable expression.
8850 SourceLocation ImplicitCaptureLoc,
8851 bool IsOpenMPMapping = false);
8852
8853 /// Complete a lambda-expression having processed and attached the
8854 /// lambda body.
8857
8858 /// Get the return type to use for a lambda's conversion function(s) to
8859 /// function pointer type, given the type of the call operator.
8860 QualType
8862 CallingConv CC);
8863
8865 SourceLocation ConvLocation,
8866 CXXConversionDecl *Conv, Expr *Src);
8867
8869 : private FunctionScopeRAII {
8870 public:
8872 Sema &SemasRef, FunctionDecl *FD, MultiLevelTemplateArgumentList MLTAL,
8874 bool ShouldAddDeclsFromParentScope = true);
8875 };
8876
8877 /// Compute the mangling number context for a lambda expression or
8878 /// block literal. Also return the extra mangling decl if any.
8879 ///
8880 /// \param DC - The DeclContext containing the lambda expression or
8881 /// block literal.
8882 std::tuple<MangleNumberingContext *, Decl *>
8884
8885 ///@}
8886
8887 //
8888 //
8889 // -------------------------------------------------------------------------
8890 //
8891 //
8892
8893 /// \name Name Lookup
8894 ///
8895 /// These routines provide name lookup that is used during semantic
8896 /// analysis to resolve the various kinds of names (identifiers,
8897 /// overloaded operator names, constructor names, etc.) into zero or
8898 /// more declarations within a particular scope. The major entry
8899 /// points are LookupName, which performs unqualified name lookup,
8900 /// and LookupQualifiedName, which performs qualified name lookup.
8901 ///
8902 /// All name lookup is performed based on some specific criteria,
8903 /// which specify what names will be visible to name lookup and how
8904 /// far name lookup should work. These criteria are important both
8905 /// for capturing language semantics (certain lookups will ignore
8906 /// certain names, for example) and for performance, since name
8907 /// lookup is often a bottleneck in the compilation of C++. Name
8908 /// lookup criteria is specified via the LookupCriteria enumeration.
8909 ///
8910 /// The results of name lookup can vary based on the kind of name
8911 /// lookup performed, the current language, and the translation
8912 /// unit. In C, for example, name lookup will either return nothing
8913 /// (no entity found) or a single declaration. In C++, name lookup
8914 /// can additionally refer to a set of overloaded functions or
8915 /// result in an ambiguity. All of the possible results of name
8916 /// lookup are captured by the LookupResult class, which provides
8917 /// the ability to distinguish among them.
8918 ///
8919 /// Implementations are in SemaLookup.cpp
8920 ///@{
8921
8922public:
8923 /// Tracks whether we are in a context where typo correction is
8924 /// disabled.
8926
8927 /// The number of typos corrected by CorrectTypo.
8929
8930 typedef llvm::SmallSet<SourceLocation, 2> SrcLocSet;
8931 typedef llvm::DenseMap<IdentifierInfo *, SrcLocSet> IdentifierSourceLocations;
8932
8933 /// A cache containing identifiers for which typo correction failed and
8934 /// their locations, so that repeated attempts to correct an identifier in a
8935 /// given location are ignored if typo correction already failed for it.
8937
8938 /// SpecialMemberOverloadResult - The overloading result for a special member
8939 /// function.
8940 ///
8941 /// This is basically a wrapper around PointerIntPair. The lowest bits of the
8942 /// integer are used to determine whether overload resolution succeeded.
8944 public:
8945 enum Kind { NoMemberOrDeleted, Ambiguous, Success };
8946
8947 private:
8948 llvm::PointerIntPair<CXXMethodDecl *, 2> Pair;
8949
8950 public:
8953 : Pair(MD, MD->isDeleted() ? NoMemberOrDeleted : Success) {}
8954
8955 CXXMethodDecl *getMethod() const { return Pair.getPointer(); }
8956 void setMethod(CXXMethodDecl *MD) { Pair.setPointer(MD); }
8957
8958 Kind getKind() const { return static_cast<Kind>(Pair.getInt()); }
8959 void setKind(Kind K) { Pair.setInt(K); }
8960 };
8961
8962 class SpecialMemberOverloadResultEntry : public llvm::FastFoldingSetNode,
8964 public:
8965 SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
8966 : FastFoldingSetNode(ID) {}
8967 };
8968
8969 /// A cache of special member function overload resolution results
8970 /// for C++ records.
8971 llvm::FoldingSet<SpecialMemberOverloadResultEntry> SpecialMemberCache;
8972
8973 /// Holds TypoExprs that are created from `createDelayedTypo`. This is used by
8974 /// `TransformTypos` in order to keep track of any TypoExprs that are created
8975 /// recursively during typo correction and wipe them away if the correction
8976 /// fails.
8978
8980
8981 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
8982 // TODO: make this is a typesafe union.
8985
8986 /// Describes the kind of name lookup to perform.
8988 /// Ordinary name lookup, which finds ordinary names (functions,
8989 /// variables, typedefs, etc.) in C and most kinds of names
8990 /// (functions, variables, members, types, etc.) in C++.
8992 /// Tag name lookup, which finds the names of enums, classes,
8993 /// structs, and unions.
8995 /// Label name lookup.
8997 /// Member name lookup, which finds the names of
8998 /// class/struct/union members.
9000 /// Look up of an operator name (e.g., operator+) for use with
9001 /// operator overloading. This lookup is similar to ordinary name
9002 /// lookup, but will ignore any declarations that are class members.
9004 /// Look up a name following ~ in a destructor name. This is an ordinary
9005 /// lookup, but prefers tags to typedefs.
9007 /// Look up of a name that precedes the '::' scope resolution
9008 /// operator in C++. This lookup completely ignores operator, object,
9009 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
9011 /// Look up a namespace name within a C++ using directive or
9012 /// namespace alias definition, ignoring non-namespace names (C++
9013 /// [basic.lookup.udir]p1).
9015 /// Look up all declarations in a scope with the given name,
9016 /// including resolved using declarations. This is appropriate
9017 /// for checking redeclarations for a using declaration.
9019 /// Look up an ordinary name that is going to be redeclared as a
9020 /// name with linkage. This lookup ignores any declarations that
9021 /// are outside of the current scope unless they have linkage. See
9022 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
9024 /// Look up a friend of a local class. This lookup does not look
9025 /// outside the innermost non-class scope. See C++11 [class.friend]p11.
9027 /// Look up the name of an Objective-C protocol.
9029 /// Look up implicit 'self' parameter of an objective-c method.
9031 /// Look up the name of an OpenMP user-defined reduction operation.
9033 /// Look up the name of an OpenMP user-defined mapper.
9035 /// Look up any declaration with any name.
9038
9039 /// The possible outcomes of name lookup for a literal operator.
9041 /// The lookup resulted in an error.
9043 /// The lookup found no match but no diagnostic was issued.
9045 /// The lookup found a single 'cooked' literal operator, which
9046 /// expects a normal literal to be built and passed to it.
9048 /// The lookup found a single 'raw' literal operator, which expects
9049 /// a string literal containing the spelling of the literal token.
9051 /// The lookup found an overload set of literal operator templates,
9052 /// which expect the characters of the spelling of the literal token to be
9053 /// passed as a non-type template argument pack.
9055 /// The lookup found an overload set of literal operator templates,
9056 /// which expect the character type and characters of the spelling of the
9057 /// string literal token to be passed as template arguments.
9059 };
9060
9061 SpecialMemberOverloadResult
9063 bool VolatileArg, bool RValueThis, bool ConstThis,
9064 bool VolatileThis);
9065
9066 typedef std::function<void(const TypoCorrection &)> TypoDiagnosticGenerator;
9067 typedef std::function<ExprResult(Sema &, TypoExpr *, TypoCorrection)>
9069
9071
9072 /// Look up a name, looking for a single declaration. Return
9073 /// null if the results were absent, ambiguous, or overloaded.
9074 ///
9075 /// It is preferable to use the elaborated form and explicitly handle
9076 /// ambiguity and overloaded.
9079 LookupNameKind NameKind,
9080 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
9081
9082 /// Lookup a builtin function, when name lookup would otherwise
9083 /// fail.
9084 bool LookupBuiltin(LookupResult &R);
9085 void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID);
9086
9087 /// Perform unqualified name lookup starting from a given
9088 /// scope.
9089 ///
9090 /// Unqualified name lookup (C++ [basic.lookup.unqual], C99 6.2.1) is
9091 /// used to find names within the current scope. For example, 'x' in
9092 /// @code
9093 /// int x;
9094 /// int f() {
9095 /// return x; // unqualified name look finds 'x' in the global scope
9096 /// }
9097 /// @endcode
9098 ///
9099 /// Different lookup criteria can find different names. For example, a
9100 /// particular scope can have both a struct and a function of the same
9101 /// name, and each can be found by certain lookup criteria. For more
9102 /// information about lookup criteria, see the documentation for the
9103 /// class LookupCriteria.
9104 ///
9105 /// @param S The scope from which unqualified name lookup will
9106 /// begin. If the lookup criteria permits, name lookup may also search
9107 /// in the parent scopes.
9108 ///
9109 /// @param [in,out] R Specifies the lookup to perform (e.g., the name to
9110 /// look up and the lookup kind), and is updated with the results of lookup
9111 /// including zero or more declarations and possibly additional information
9112 /// used to diagnose ambiguities.
9113 ///
9114 /// @returns \c true if lookup succeeded and false otherwise.
9115 bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation = false,
9116 bool ForceNoCPlusPlus = false);
9117
9118 /// Perform qualified name lookup into a given context.
9119 ///
9120 /// Qualified name lookup (C++ [basic.lookup.qual]) is used to find
9121 /// names when the context of those names is explicit specified, e.g.,
9122 /// "std::vector" or "x->member", or as part of unqualified name lookup.
9123 ///
9124 /// Different lookup criteria can find different names. For example, a
9125 /// particular scope can have both a struct and a function of the same
9126 /// name, and each can be found by certain lookup criteria. For more
9127 /// information about lookup criteria, see the documentation for the
9128 /// class LookupCriteria.
9129 ///
9130 /// \param R captures both the lookup criteria and any lookup results found.
9131 ///
9132 /// \param LookupCtx The context in which qualified name lookup will
9133 /// search. If the lookup criteria permits, name lookup may also search
9134 /// in the parent contexts or (for C++ classes) base classes.
9135 ///
9136 /// \param InUnqualifiedLookup true if this is qualified name lookup that
9137 /// occurs as part of unqualified name lookup.
9138 ///
9139 /// \returns true if lookup succeeded, false if it failed.
9140 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9141 bool InUnqualifiedLookup = false);
9142
9143 /// Performs qualified name lookup or special type of lookup for
9144 /// "__super::" scope specifier.
9145 ///
9146 /// This routine is a convenience overload meant to be called from contexts
9147 /// that need to perform a qualified name lookup with an optional C++ scope
9148 /// specifier that might require special kind of lookup.
9149 ///
9150 /// \param R captures both the lookup criteria and any lookup results found.
9151 ///
9152 /// \param LookupCtx The context in which qualified name lookup will
9153 /// search.
9154 ///
9155 /// \param SS An optional C++ scope-specifier.
9156 ///
9157 /// \returns true if lookup succeeded, false if it failed.
9158 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
9159 CXXScopeSpec &SS);
9160
9161 /// Performs name lookup for a name that was parsed in the
9162 /// source code, and may contain a C++ scope specifier.
9163 ///
9164 /// This routine is a convenience routine meant to be called from
9165 /// contexts that receive a name and an optional C++ scope specifier
9166 /// (e.g., "N::M::x"). It will then perform either qualified or
9167 /// unqualified name lookup (with LookupQualifiedName or LookupName,
9168 /// respectively) on the given name and return those results. It will
9169 /// perform a special type of lookup for "__super::" scope specifier.
9170 ///
9171 /// @param S The scope from which unqualified name lookup will
9172 /// begin.
9173 ///
9174 /// @param SS An optional C++ scope-specifier, e.g., "::N::M".
9175 ///
9176 /// @param EnteringContext Indicates whether we are going to enter the
9177 /// context of the scope-specifier SS (if present).
9178 ///
9179 /// @returns True if any decls were found (but possibly ambiguous)
9181 QualType ObjectType, bool AllowBuiltinCreation = false,
9182 bool EnteringContext = false);
9183
9184 /// Perform qualified name lookup into all base classes of the given
9185 /// class.
9186 ///
9187 /// \param R captures both the lookup criteria and any lookup results found.
9188 ///
9189 /// \param Class The context in which qualified name lookup will
9190 /// search. Name lookup will search in all base classes merging the results.
9191 ///
9192 /// @returns True if any decls were found (but possibly ambiguous)
9194
9196 UnresolvedSetImpl &Functions);
9197
9198 /// LookupOrCreateLabel - Do a name lookup of a label with the specified name.
9199 /// If GnuLabelLoc is a valid source location, then this is a definition
9200 /// of an __label__ label name, otherwise it is a normal label definition
9201 /// or use.
9203 SourceLocation GnuLabelLoc = SourceLocation());
9204
9205 /// Look up the constructors for the given class.
9207
9208 /// Look up the default constructor for the given class.
9210
9211 /// Look up the copying constructor for the given class.
9213 unsigned Quals);
9214
9215 /// Look up the copying assignment operator for the given class.
9217 bool RValueThis, unsigned ThisQuals);
9218
9219 /// Look up the moving constructor for the given class.
9221 unsigned Quals);
9222
9223 /// Look up the moving assignment operator for the given class.
9225 bool RValueThis, unsigned ThisQuals);
9226
9227 /// Look for the destructor of the given class.
9228 ///
9229 /// During semantic analysis, this routine should be used in lieu of
9230 /// CXXRecordDecl::getDestructor().
9231 ///
9232 /// \returns The destructor for this class.
9234
9235 /// Force the declaration of any implicitly-declared members of this
9236 /// class.
9238
9239 /// Make a merged definition of an existing hidden definition \p ND
9240 /// visible at the specified location.
9242
9243 /// Check ODR hashes for C/ObjC when merging types from modules.
9244 /// Differently from C++, actually parse the body and reject in case
9245 /// of a mismatch.
9246 template <typename T,
9247 typename = std::enable_if_t<std::is_base_of<NamedDecl, T>::value>>
9249 if (Duplicate->getODRHash() != Previous->getODRHash())
9250 return false;
9251
9252 // Make the previous decl visible.
9254 return true;
9255 }
9256
9257 /// Get the set of additional modules that should be checked during
9258 /// name lookup. A module and its imports become visible when instanting a
9259 /// template defined within it.
9260 llvm::DenseSet<Module *> &getLookupModules();
9261
9262 bool hasVisibleMergedDefinition(const NamedDecl *Def);
9264
9265 /// Determine if the template parameter \p D has a visible default argument.
9266 bool
9268 llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9269 /// Determine if the template parameter \p D has a reachable default argument.
9271 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9272 /// Determine if the template parameter \p D has a reachable default argument.
9276
9277 /// Determine if there is a visible declaration of \p D that is an explicit
9278 /// specialization declaration for a specialization of a template. (For a
9279 /// member specialization, use hasVisibleMemberSpecialization.)
9281 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9282 /// Determine if there is a reachable declaration of \p D that is an explicit
9283 /// specialization declaration for a specialization of a template. (For a
9284 /// member specialization, use hasReachableMemberSpecialization.)
9286 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9287
9288 /// Determine if there is a visible declaration of \p D that is a member
9289 /// specialization declaration (as opposed to an instantiated declaration).
9291 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9292 /// Determine if there is a reachable declaration of \p D that is a member
9293 /// specialization declaration (as opposed to an instantiated declaration).
9295 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9296
9297 bool isModuleVisible(const Module *M, bool ModulePrivate = false);
9298
9299 /// Determine whether any declaration of an entity is visible.
9300 bool
9302 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9303 return isVisible(D) || hasVisibleDeclarationSlow(D, Modules);
9304 }
9305
9308 /// Determine whether any declaration of an entity is reachable.
9309 bool
9311 llvm::SmallVectorImpl<Module *> *Modules = nullptr) {
9312 return isReachable(D) || hasReachableDeclarationSlow(D, Modules);
9313 }
9315 const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules = nullptr);
9316
9317 void diagnoseTypo(const TypoCorrection &Correction,
9318 const PartialDiagnostic &TypoDiag,
9319 bool ErrorRecovery = true);
9320
9321 /// Diagnose a successfully-corrected typo. Separated from the correction
9322 /// itself to allow external validation of the result, etc.
9323 ///
9324 /// \param Correction The result of performing typo correction.
9325 /// \param TypoDiag The diagnostic to produce. This will have the corrected
9326 /// string added to it (and usually also a fixit).
9327 /// \param PrevNote A note to use when indicating the location of the entity
9328 /// to which we are correcting. Will have the correction string added
9329 /// to it.
9330 /// \param ErrorRecovery If \c true (the default), the caller is going to
9331 /// recover from the typo as if the corrected string had been typed.
9332 /// In this case, \c PDiag must be an error, and we will attach a fixit
9333 /// to it.
9334 void diagnoseTypo(const TypoCorrection &Correction,
9335 const PartialDiagnostic &TypoDiag,
9336 const PartialDiagnostic &PrevNote,
9337 bool ErrorRecovery = true);
9338
9339 /// Find the associated classes and namespaces for
9340 /// argument-dependent lookup for a call with the given set of
9341 /// arguments.
9342 ///
9343 /// This routine computes the sets of associated classes and associated
9344 /// namespaces searched by argument-dependent lookup
9345 /// (C++ [basic.lookup.argdep]) for a given set of arguments.
9347 SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
9348 AssociatedNamespaceSet &AssociatedNamespaces,
9349 AssociatedClassSet &AssociatedClasses);
9350
9351 /// Produce a diagnostic describing the ambiguity that resulted
9352 /// from name lookup.
9353 ///
9354 /// \param Result The result of the ambiguous lookup to be diagnosed.
9356
9357 /// LookupLiteralOperator - Determine which literal operator should be used
9358 /// for a user-defined literal, per C++11 [lex.ext].
9359 ///
9360 /// Normal overload resolution is not used to select which literal operator to
9361 /// call for a user-defined literal. Look up the provided literal operator
9362 /// name, and filter the results to the appropriate set for the given argument
9363 /// types.
9366 bool AllowRaw, bool AllowTemplate,
9367 bool AllowStringTemplate, bool DiagnoseMissing,
9368 StringLiteral *StringLit = nullptr);
9369
9371 ArrayRef<Expr *> Args, ADLResult &Functions);
9372
9375 bool IncludeGlobalScope = true,
9376 bool LoadExternal = true);
9379 bool IncludeGlobalScope = true,
9380 bool IncludeDependentBases = false,
9381 bool LoadExternal = true);
9382
9384 CTK_NonError, // CorrectTypo used in a non error recovery situation.
9385 CTK_ErrorRecovery // CorrectTypo used in normal error recovery.
9387
9388 /// Try to "correct" a typo in the source code by finding
9389 /// visible declarations whose names are similar to the name that was
9390 /// present in the source code.
9391 ///
9392 /// \param TypoName the \c DeclarationNameInfo structure that contains
9393 /// the name that was present in the source code along with its location.
9394 ///
9395 /// \param LookupKind the name-lookup criteria used to search for the name.
9396 ///
9397 /// \param S the scope in which name lookup occurs.
9398 ///
9399 /// \param SS the nested-name-specifier that precedes the name we're
9400 /// looking for, if present.
9401 ///
9402 /// \param CCC A CorrectionCandidateCallback object that provides further
9403 /// validation of typo correction candidates. It also provides flags for
9404 /// determining the set of keywords permitted.
9405 ///
9406 /// \param MemberContext if non-NULL, the context in which to look for
9407 /// a member access expression.
9408 ///
9409 /// \param EnteringContext whether we're entering the context described by
9410 /// the nested-name-specifier SS.
9411 ///
9412 /// \param OPT when non-NULL, the search for visible declarations will
9413 /// also walk the protocols in the qualified interfaces of \p OPT.
9414 ///
9415 /// \returns a \c TypoCorrection containing the corrected name if the typo
9416 /// along with information such as the \c NamedDecl where the corrected name
9417 /// was declared, and any additional \c NestedNameSpecifier needed to access
9418 /// it (C++ only). The \c TypoCorrection is empty if there is no correction.
9420 Sema::LookupNameKind LookupKind, Scope *S,
9422 CorrectTypoKind Mode,
9423 DeclContext *MemberContext = nullptr,
9424 bool EnteringContext = false,
9425 const ObjCObjectPointerType *OPT = nullptr,
9426 bool RecordFailure = true);
9427
9428 /// Try to "correct" a typo in the source code by finding
9429 /// visible declarations whose names are similar to the name that was
9430 /// present in the source code.
9431 ///
9432 /// \param TypoName the \c DeclarationNameInfo structure that contains
9433 /// the name that was present in the source code along with its location.
9434 ///
9435 /// \param LookupKind the name-lookup criteria used to search for the name.
9436 ///
9437 /// \param S the scope in which name lookup occurs.
9438 ///
9439 /// \param SS the nested-name-specifier that precedes the name we're
9440 /// looking for, if present.
9441 ///
9442 /// \param CCC A CorrectionCandidateCallback object that provides further
9443 /// validation of typo correction candidates. It also provides flags for
9444 /// determining the set of keywords permitted.
9445 ///
9446 /// \param TDG A TypoDiagnosticGenerator functor that will be used to print
9447 /// diagnostics when the actual typo correction is attempted.
9448 ///
9449 /// \param TRC A TypoRecoveryCallback functor that will be used to build an
9450 /// Expr from a typo correction candidate.
9451 ///
9452 /// \param MemberContext if non-NULL, the context in which to look for
9453 /// a member access expression.
9454 ///
9455 /// \param EnteringContext whether we're entering the context described by
9456 /// the nested-name-specifier SS.
9457 ///
9458 /// \param OPT when non-NULL, the search for visible declarations will
9459 /// also walk the protocols in the qualified interfaces of \p OPT.
9460 ///
9461 /// \returns a new \c TypoExpr that will later be replaced in the AST with an
9462 /// Expr representing the result of performing typo correction, or nullptr if
9463 /// typo correction is not possible. If nullptr is returned, no diagnostics
9464 /// will be emitted and it is the responsibility of the caller to emit any
9465 /// that are needed.
9467 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9470 CorrectTypoKind Mode, DeclContext *MemberContext = nullptr,
9471 bool EnteringContext = false, const ObjCObjectPointerType *OPT = nullptr);
9472
9473 /// Kinds of missing import. Note, the values of these enumerators correspond
9474 /// to %select values in diagnostics.
9477 Definition,
9481 };
9482
9483 /// Diagnose that the specified declaration needs to be visible but
9484 /// isn't, and suggest a module import that would resolve the problem.
9486 MissingImportKind MIK, bool Recover = true);
9488 SourceLocation DeclLoc, ArrayRef<Module *> Modules,
9489 MissingImportKind MIK, bool Recover);
9490
9492 std::unique_ptr<TypoCorrectionConsumer> Consumer;
9495 TypoExprState();
9496 TypoExprState(TypoExprState &&other) noexcept;
9497 TypoExprState &operator=(TypoExprState &&other) noexcept;
9498 };
9499
9500 const TypoExprState &getTypoExprState(TypoExpr *TE) const;
9501
9502 /// Clears the state of the given TypoExpr.
9503 void clearDelayedTypo(TypoExpr *TE);
9504
9505 /// Called on #pragma clang __debug dump II
9507
9508 /// Called on #pragma clang __debug dump E
9509 void ActOnPragmaDump(Expr *E);
9510
9511private:
9512 // The set of known/encountered (unique, canonicalized) NamespaceDecls.
9513 //
9514 // The boolean value will be true to indicate that the namespace was loaded
9515 // from an AST/PCH file, or false otherwise.
9516 llvm::MapVector<NamespaceDecl *, bool> KnownNamespaces;
9517
9518 /// Whether we have already loaded known namespaces from an extenal
9519 /// source.
9520 bool LoadedExternalKnownNamespaces;
9521
9522 bool CppLookupName(LookupResult &R, Scope *S);
9523
9524 /// Determine if we could use all the declarations in the module.
9525 bool isUsableModule(const Module *M);
9526
9527 /// Helper for CorrectTypo and CorrectTypoDelayed used to create and
9528 /// populate a new TypoCorrectionConsumer. Returns nullptr if typo correction
9529 /// should be skipped entirely.
9530 std::unique_ptr<TypoCorrectionConsumer> makeTypoCorrectionConsumer(
9531 const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind,
9533 DeclContext *MemberContext, bool EnteringContext,
9534 const ObjCObjectPointerType *OPT, bool ErrorRecovery);
9535
9536 /// The set of unhandled TypoExprs and their associated state.
9537 llvm::MapVector<TypoExpr *, TypoExprState> DelayedTypos;
9538
9539 /// Creates a new TypoExpr AST node.
9540 TypoExpr *createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
9543
9544 /// Cache for module units which is usable for current module.
9545 llvm::DenseSet<const Module *> UsableModuleUnitsCache;
9546
9547 /// Record the typo correction failure and return an empty correction.
9548 TypoCorrection FailedCorrection(IdentifierInfo *Typo, SourceLocation TypoLoc,
9549 bool RecordFailure = true) {
9550 if (RecordFailure)
9551 TypoCorrectionFailures[Typo].insert(TypoLoc);
9552 return TypoCorrection();
9553 }
9554
9555 bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
9556
9557 /// Determine whether two declarations should be linked together, given that
9558 /// the old declaration might not be visible and the new declaration might
9559 /// not have external linkage.
9560 bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
9561 const NamedDecl *New) {
9562 if (isVisible(Old))
9563 return true;
9564 // See comment in below overload for why it's safe to compute the linkage
9565 // of the new declaration here.
9566 if (New->isExternallyDeclarable()) {
9567 assert(Old->isExternallyDeclarable() &&
9568 "should not have found a non-externally-declarable previous decl");
9569 return true;
9570 }
9571 return false;
9572 }
9573 bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);
9574
9575 ///@}
9576
9577 //
9578 //
9579 // -------------------------------------------------------------------------
9580 //
9581 //
9582
9583 /// \name Modules
9584 /// Implementations are in SemaModule.cpp
9585 ///@{
9586
9587public:
9588 /// Get the module unit whose scope we are currently within.
9590 return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module;
9591 }
9592
9593 /// Is the module scope we are an implementation unit?
9595 return ModuleScopes.empty()
9596 ? false
9597 : ModuleScopes.back().Module->isModuleImplementation();
9598 }
9599
9600 // When loading a non-modular PCH files, this is used to restore module
9601 // visibility.
9603 VisibleModules.setVisible(Mod, ImportLoc);
9604 }
9605
9606 enum class ModuleDeclKind {
9607 Interface, ///< 'export module X;'
9608 Implementation, ///< 'module X;'
9609 PartitionInterface, ///< 'export module X:Y;'
9610 PartitionImplementation, ///< 'module X:Y;'
9611 };
9612
9613 /// An enumeration to represent the transition of states in parsing module
9614 /// fragments and imports. If we are not parsing a C++20 TU, or we find
9615 /// an error in state transition, the state is set to NotACXX20Module.
9617 FirstDecl, ///< Parsing the first decl in a TU.
9618 GlobalFragment, ///< after 'module;' but before 'module X;'
9619 ImportAllowed, ///< after 'module X;' but before any non-import decl.
9620 ImportFinished, ///< after any non-import decl.
9621 PrivateFragmentImportAllowed, ///< after 'module :private;' but before any
9622 ///< non-import decl.
9623 PrivateFragmentImportFinished, ///< after 'module :private;' but a
9624 ///< non-import decl has already been seen.
9625 NotACXX20Module ///< Not a C++20 TU, or an invalid state was found.
9626 };
9627
9628 /// The parser has processed a module-declaration that begins the definition
9629 /// of a module interface or implementation.
9631 SourceLocation ModuleLoc, ModuleDeclKind MDK,
9632 ModuleIdPath Path, ModuleIdPath Partition,
9633 ModuleImportState &ImportState);
9634
9635 /// The parser has processed a global-module-fragment declaration that begins
9636 /// the definition of the global module fragment of the current module unit.
9637 /// \param ModuleLoc The location of the 'module' keyword.
9639
9640 /// The parser has processed a private-module-fragment declaration that begins
9641 /// the definition of the private module fragment of the current module unit.
9642 /// \param ModuleLoc The location of the 'module' keyword.
9643 /// \param PrivateLoc The location of the 'private' keyword.
9645 SourceLocation PrivateLoc);
9646
9647 /// The parser has processed a module import declaration.
9648 ///
9649 /// \param StartLoc The location of the first token in the declaration. This
9650 /// could be the location of an '@', 'export', or 'import'.
9651 /// \param ExportLoc The location of the 'export' keyword, if any.
9652 /// \param ImportLoc The location of the 'import' keyword.
9653 /// \param Path The module toplevel name as an access path.
9654 /// \param IsPartition If the name is for a partition.
9656 SourceLocation ExportLoc,
9657 SourceLocation ImportLoc, ModuleIdPath Path,
9658 bool IsPartition = false);
9660 SourceLocation ExportLoc,
9661 SourceLocation ImportLoc, Module *M,
9662 ModuleIdPath Path = {});
9663
9664 /// The parser has processed a module import translated from a
9665 /// #include or similar preprocessing directive.
9666 void ActOnAnnotModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9667 void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod);
9668
9669 /// The parsed has entered a submodule.
9670 void ActOnAnnotModuleBegin(SourceLocation DirectiveLoc, Module *Mod);
9671 /// The parser has left a submodule.
9672 void ActOnAnnotModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
9673
9674 /// Create an implicit import of the given module at the given
9675 /// source location, for error recovery, if possible.
9676 ///
9677 /// This routine is typically used when an entity found by name lookup
9678 /// is actually hidden within a module that we know about but the user
9679 /// has forgotten to import.
9681 Module *Mod);
9682
9683 /// We have parsed the start of an export declaration, including the '{'
9684 /// (if present).
9685 Decl *ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
9686 SourceLocation LBraceLoc);
9687
9688 /// Complete the definition of an export declaration.
9689 Decl *ActOnFinishExportDecl(Scope *S, Decl *ExportDecl,
9690 SourceLocation RBraceLoc);
9691
9692private:
9693 /// The parser has begun a translation unit to be compiled as a C++20
9694 /// Header Unit, helper for ActOnStartOfTranslationUnit() only.
9695 void HandleStartOfHeaderUnit();
9696
9697 struct ModuleScope {
9698 SourceLocation BeginLoc;
9699 clang::Module *Module = nullptr;
9700 VisibleModuleSet OuterVisibleModules;
9701 };
9702 /// The modules we're currently parsing.
9704
9705 /// For an interface unit, this is the implicitly imported interface unit.
9706 clang::Module *ThePrimaryInterface = nullptr;
9707
9708 /// The explicit global module fragment of the current translation unit.
9709 /// The explicit Global Module Fragment, as specified in C++
9710 /// [module.global.frag].
9711 clang::Module *TheGlobalModuleFragment = nullptr;
9712
9713 /// The implicit global module fragments of the current translation unit.
9714 ///
9715 /// The contents in the implicit global module fragment can't be discarded.
9716 clang::Module *TheImplicitGlobalModuleFragment = nullptr;
9717
9718 /// Namespace definitions that we will export when they finish.
9719 llvm::SmallPtrSet<const NamespaceDecl *, 8> DeferredExportedNamespaces;
9720
9721 /// In a C++ standard module, inline declarations require a definition to be
9722 /// present at the end of a definition domain. This set holds the decls to
9723 /// be checked at the end of the TU.
9724 llvm::SmallPtrSet<const FunctionDecl *, 8> PendingInlineFuncDecls;
9725
9726 /// Helper function to judge if we are in module purview.
9727 /// Return false if we are not in a module.
9728 bool isCurrentModulePurview() const;
9729
9730 /// Enter the scope of the explicit global module fragment.
9731 Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
9732 /// Leave the scope of the explicit global module fragment.
9733 void PopGlobalModuleFragment();
9734
9735 /// Enter the scope of an implicit global module fragment.
9736 Module *PushImplicitGlobalModuleFragment(SourceLocation BeginLoc);
9737 /// Leave the scope of an implicit global module fragment.
9738 void PopImplicitGlobalModuleFragment();
9739
9740 VisibleModuleSet VisibleModules;
9741
9742 ///@}
9743
9744 //
9745 //
9746 // -------------------------------------------------------------------------
9747 //
9748 //
9749
9750 /// \name C++ Overloading
9751 /// Implementations are in SemaOverload.cpp
9752 ///@{
9753
9754public:
9755 /// Whether deferrable diagnostics should be deferred.
9756 bool DeferDiags = false;
9757
9758 /// RAII class to control scope of DeferDiags.
9760 Sema &S;
9761 bool SavedDeferDiags = false;
9762
9763 public:
9764 DeferDiagsRAII(Sema &S, bool DeferDiags)
9765 : S(S), SavedDeferDiags(S.DeferDiags) {
9766 S.DeferDiags = DeferDiags;
9767 }
9768 ~DeferDiagsRAII() { S.DeferDiags = SavedDeferDiags; }
9769 };
9770
9771 /// Flag indicating if Sema is building a recovery call expression.
9772 ///
9773 /// This flag is used to avoid building recovery call expressions
9774 /// if Sema is already doing so, which would cause infinite recursions.
9776
9778 /// This is a legitimate overload: the existing declarations are
9779 /// functions or function templates with different signatures.
9781
9782 /// This is not an overload because the signature exactly matches
9783 /// an existing declaration.
9785
9786 /// This is not an overload because the lookup results contain a
9787 /// non-function.
9790
9791 /// Determine whether the given New declaration is an overload of the
9792 /// declarations in Old. This routine returns Ovl_Match or Ovl_NonFunction if
9793 /// New and Old cannot be overloaded, e.g., if New has the same signature as
9794 /// some function in Old (C++ 1.3.10) or if the Old declarations aren't
9795 /// functions (or function templates) at all. When it does return Ovl_Match or
9796 /// Ovl_NonFunction, MatchedDecl will point to the decl that New cannot be
9797 /// overloaded with. This decl may be a UsingShadowDecl on top of the
9798 /// underlying declaration.
9799 ///
9800 /// Example: Given the following input:
9801 ///
9802 /// void f(int, float); // #1
9803 /// void f(int, int); // #2
9804 /// int f(int, int); // #3
9805 ///
9806 /// When we process #1, there is no previous declaration of "f", so IsOverload
9807 /// will not be used.
9808 ///
9809 /// When we process #2, Old contains only the FunctionDecl for #1. By
9810 /// comparing the parameter types, we see that #1 and #2 are overloaded (since
9811 /// they have different signatures), so this routine returns Ovl_Overload;
9812 /// MatchedDecl is unchanged.
9813 ///
9814 /// When we process #3, Old is an overload set containing #1 and #2. We
9815 /// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
9816 /// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
9817 /// types of functions are not part of the signature), IsOverload returns
9818 /// Ovl_Match and MatchedDecl will be set to point to the FunctionDecl for #2.
9819 ///
9820 /// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
9821 /// class by a using declaration. The rules for whether to hide shadow
9822 /// declarations ignore some properties which otherwise figure into a function
9823 /// template's signature.
9825 const LookupResult &OldDecls, NamedDecl *&OldDecl,
9826 bool UseMemberUsingDeclRules);
9827 bool IsOverload(FunctionDecl *New, FunctionDecl *Old,
9828 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9829
9830 // Checks whether MD constitutes an override the base class method BaseMD.
9831 // When checking for overrides, the object object members are ignored.
9832 bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
9833 bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs = true);
9834
9835 enum class AllowedExplicit {
9836 /// Allow no explicit functions to be used.
9837 None,
9838 /// Allow explicit conversion functions but not explicit constructors.
9840 /// Allow both explicit conversion functions and explicit constructors.
9841 All
9842 };
9843
9845 Expr *From, QualType ToType, bool SuppressUserConversions,
9846 AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
9847 bool AllowObjCWritebackConversion);
9848
9849 /// PerformImplicitConversion - Perform an implicit conversion of the
9850 /// expression From to the type ToType. Returns the
9851 /// converted expression. Flavor is the kind of conversion we're
9852 /// performing, used in the error message. If @p AllowExplicit,
9853 /// explicit user-defined conversions are permitted.
9855 AssignmentAction Action,
9856 bool AllowExplicit = false);
9857
9858 /// IsIntegralPromotion - Determines whether the conversion from the
9859 /// expression From (whose potentially-adjusted type is FromType) to
9860 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
9861 /// sets PromotedType to the promoted type.
9862 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
9863
9864 /// IsFloatingPointPromotion - Determines whether the conversion from
9865 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
9866 /// returns true and sets PromotedType to the promoted type.
9867 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
9868
9869 /// Determine if a conversion is a complex promotion.
9870 ///
9871 /// A complex promotion is defined as a complex -> complex conversion
9872 /// where the conversion between the underlying real types is a
9873 /// floating-point or integral promotion.
9874 bool IsComplexPromotion(QualType FromType, QualType ToType);
9875
9876 /// IsPointerConversion - Determines whether the conversion of the
9877 /// expression From, which has the (possibly adjusted) type FromType,
9878 /// can be converted to the type ToType via a pointer conversion (C++
9879 /// 4.10). If so, returns true and places the converted type (that
9880 /// might differ from ToType in its cv-qualifiers at some level) into
9881 /// ConvertedType.
9882 ///
9883 /// This routine also supports conversions to and from block pointers
9884 /// and conversions with Objective-C's 'id', 'id<protocols...>', and
9885 /// pointers to interfaces. FIXME: Once we've determined the
9886 /// appropriate overloading rules for Objective-C, we may want to
9887 /// split the Objective-C checks into a different routine; however,
9888 /// GCC seems to consider all of these conversions to be pointer
9889 /// conversions, so for now they live here. IncompatibleObjC will be
9890 /// set if the conversion is an allowed Objective-C conversion that
9891 /// should result in a warning.
9892 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
9893 bool InOverloadResolution, QualType &ConvertedType,
9894 bool &IncompatibleObjC);
9895
9896 /// isObjCPointerConversion - Determines whether this is an
9897 /// Objective-C pointer conversion. Subroutine of IsPointerConversion,
9898 /// with the same arguments and return values.
9899 bool isObjCPointerConversion(QualType FromType, QualType ToType,
9900 QualType &ConvertedType, bool &IncompatibleObjC);
9901 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
9902 QualType &ConvertedType);
9903
9904 /// FunctionParamTypesAreEqual - This routine checks two function proto types
9905 /// for equality of their parameter types. Caller has already checked that
9906 /// they have same number of parameters. If the parameters are different,
9907 /// ArgPos will have the parameter index of the first different parameter.
9908 /// If `Reversed` is true, the parameters of `NewType` will be compared in
9909 /// reverse order. That's useful if one of the functions is being used as a
9910 /// C++20 synthesized operator overload with a reversed parameter order.
9913 unsigned *ArgPos = nullptr,
9914 bool Reversed = false);
9915
9917 const FunctionProtoType *NewType,
9918 unsigned *ArgPos = nullptr,
9919 bool Reversed = false);
9920
9921 bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
9922 const FunctionDecl *NewFunction,
9923 unsigned *ArgPos = nullptr,
9924 bool Reversed = false);
9925
9926 /// HandleFunctionTypeMismatch - Gives diagnostic information for differeing
9927 /// function types. Catches different number of parameter, mismatch in
9928 /// parameter types, and different return types.
9930 QualType ToType);
9931
9932 /// CheckPointerConversion - Check the pointer conversion from the
9933 /// expression From to the type ToType. This routine checks for
9934 /// ambiguous or inaccessible derived-to-base pointer
9935 /// conversions for which IsPointerConversion has already returned
9936 /// true. It returns true and produces a diagnostic if there was an
9937 /// error, or returns false otherwise.
9938 bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
9939 CXXCastPath &BasePath, bool IgnoreBaseAccess,
9940 bool Diagnose = true);
9941
9942 /// IsMemberPointerConversion - Determines whether the conversion of the
9943 /// expression From, which has the (possibly adjusted) type FromType, can be
9944 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
9945 /// If so, returns true and places the converted type (that might differ from
9946 /// ToType in its cv-qualifiers at some level) into ConvertedType.
9947 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
9948 bool InOverloadResolution,
9949 QualType &ConvertedType);
9950
9951 /// CheckMemberPointerConversion - Check the member pointer conversion from
9952 /// the expression From to the type ToType. This routine checks for ambiguous
9953 /// or virtual or inaccessible base-to-derived member pointer conversions for
9954 /// which IsMemberPointerConversion has already returned true. It returns true
9955 /// and produces a diagnostic if there was an error, or returns false
9956 /// otherwise.
9958 CXXCastPath &BasePath,
9959 bool IgnoreBaseAccess);
9960
9961 /// IsQualificationConversion - Determines whether the conversion from
9962 /// an rvalue of type FromType to ToType is a qualification conversion
9963 /// (C++ 4.4).
9964 ///
9965 /// \param ObjCLifetimeConversion Output parameter that will be set to
9966 /// indicate when the qualification conversion involves a change in the
9967 /// Objective-C object lifetime.
9968 bool IsQualificationConversion(QualType FromType, QualType ToType,
9969 bool CStyle, bool &ObjCLifetimeConversion);
9970
9971 /// Determine whether the conversion from FromType to ToType is a valid
9972 /// conversion that strips "noexcept" or "noreturn" off the nested function
9973 /// type.
9974 bool IsFunctionConversion(QualType FromType, QualType ToType,
9975 QualType &ResultTy);
9978 DeclarationName Name,
9979 OverloadCandidateSet &CandidateSet,
9980 FunctionDecl *Fn, MultiExprArg Args,
9981 bool IsMember = false);
9982
9984 FunctionDecl *Fun);
9986 Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl,
9987 CXXMethodDecl *Method);
9988
9989 /// PerformContextuallyConvertToBool - Perform a contextual conversion
9990 /// of the expression From to bool (C++0x [conv]p3).
9992
9993 /// PerformContextuallyConvertToObjCPointer - Perform a contextual
9994 /// conversion of the expression From to an Objective-C pointer type.
9995 /// Returns a valid but null ExprResult if no conversion sequence exists.
9997
9998 /// Contexts in which a converted constant expression is required.
9999 enum CCEKind {
10000 CCEK_CaseValue, ///< Expression in a case label.
10001 CCEK_Enumerator, ///< Enumerator value with fixed underlying type.
10002 CCEK_TemplateArg, ///< Value of a non-type template parameter.
10003 CCEK_ArrayBound, ///< Array bound in array declarator or new-expression.
10004 CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier.
10005 CCEK_Noexcept, ///< Condition in a noexcept(bool) specifier.
10006 CCEK_StaticAssertMessageSize, ///< Call to size() in a static assert
10007 ///< message.
10008 CCEK_StaticAssertMessageData, ///< Call to data() in a static assert
10009 ///< message.
10010 };
10011
10013 CCEKind CCE,
10014 NamedDecl *Dest = nullptr);
10015
10017 llvm::APSInt &Value, CCEKind CCE);
10019 APValue &Value, CCEKind CCE,
10020 NamedDecl *Dest = nullptr);
10021
10022 /// EvaluateConvertedConstantExpression - Evaluate an Expression
10023 /// That is a converted constant expression
10024 /// (which was built with BuildConvertedConstantExpression)
10027 CCEKind CCE, bool RequireInt,
10028 const APValue &PreNarrowingValue);
10029
10030 /// Abstract base class used to perform a contextual implicit
10031 /// conversion from an expression to any type passing a filter.
10033 public:
10036
10037 ContextualImplicitConverter(bool Suppress = false,
10038 bool SuppressConversion = false)
10039 : Suppress(Suppress), SuppressConversion(SuppressConversion) {}
10040
10041 /// Determine whether the specified type is a valid destination type
10042 /// for this conversion.
10043 virtual bool match(QualType T) = 0;
10044
10045 /// Emits a diagnostic complaining that the expression does not have
10046 /// integral or enumeration type.
10048 QualType T) = 0;
10049
10050 /// Emits a diagnostic when the expression has incomplete class type.
10051 virtual SemaDiagnosticBuilder
10053
10054 /// Emits a diagnostic when the only matching conversion function
10055 /// is explicit.
10058 QualType T,
10059 QualType ConvTy) = 0;
10060
10061 /// Emits a note for the explicit conversion function.
10062 virtual SemaDiagnosticBuilder
10064
10065 /// Emits a diagnostic when there are multiple possible conversion
10066 /// functions.
10068 QualType T) = 0;
10069
10070 /// Emits a note for one of the candidate conversions.
10071 virtual SemaDiagnosticBuilder
10073
10074 /// Emits a diagnostic when we picked a conversion function
10075 /// (for cases when we are not allowed to pick a conversion function).
10078 QualType T,
10079 QualType ConvTy) = 0;
10080
10082 };
10083
10085 bool AllowScopedEnumerations;
10086
10087 public:
10088 ICEConvertDiagnoser(bool AllowScopedEnumerations, bool Suppress,
10089 bool SuppressConversion)
10090 : ContextualImplicitConverter(Suppress, SuppressConversion),
10091 AllowScopedEnumerations(AllowScopedEnumerations) {}
10092
10093 /// Match an integral or (possibly scoped) enumeration type.
10094 bool match(QualType T) override;
10095
10097 QualType T) override {
10098 return diagnoseNotInt(S, Loc, T);
10099 }
10100
10101 /// Emits a diagnostic complaining that the expression does not have
10102 /// integral or enumeration type.
10104 QualType T) = 0;
10105 };
10106
10107 /// Perform a contextual implicit conversion.
10110 ContextualImplicitConverter &Converter);
10111
10112 /// ReferenceCompareResult - Expresses the result of comparing two
10113 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
10114 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
10116 /// Ref_Incompatible - The two types are incompatible, so direct
10117 /// reference binding is not possible.
10119 /// Ref_Related - The two types are reference-related, which means
10120 /// that their unqualified forms (T1 and T2) are either the same
10121 /// or T1 is a base class of T2.
10123 /// Ref_Compatible - The two types are reference-compatible.
10126
10127 // Fake up a scoped enumeration that still contextually converts to bool.
10129 /// The conversions that would be performed on an lvalue of type T2 when
10130 /// binding a reference of type T1 to it, as determined when evaluating
10131 /// whether T1 is reference-compatible with T2.
10133 Qualification = 0x1,
10134 NestedQualification = 0x2,
10136 DerivedToBase = 0x8,
10137 ObjC = 0x10,
10138 ObjCLifetime = 0x20,
10139
10140 LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/ObjCLifetime)
10141 };
10142 };
10144
10145 /// CompareReferenceRelationship - Compare the two types T1 and T2 to
10146 /// determine whether they are reference-compatible,
10147 /// reference-related, or incompatible, for use in C++ initialization by
10148 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
10149 /// type, and the first type (T1) is the pointee type of the reference
10150 /// type being initialized.
10153 ReferenceConversions *Conv = nullptr);
10154
10155 /// AddOverloadCandidate - Adds the given function to the set of
10156 /// candidate functions, using the given function call arguments. If
10157 /// @p SuppressUserConversions, then don't allow user-defined
10158 /// conversions via constructors or conversion operators.
10159 ///
10160 /// \param PartialOverloading true if we are performing "partial" overloading
10161 /// based on an incomplete set of function arguments. This feature is used by
10162 /// code completion.
10164 ArrayRef<Expr *> Args,
10165 OverloadCandidateSet &CandidateSet,
10166 bool SuppressUserConversions = false,
10167 bool PartialOverloading = false,
10168 bool AllowExplicit = true,
10169 bool AllowExplicitConversion = false,
10170 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10171 ConversionSequenceList EarlyConversions = {},
10173 bool AggregateCandidateDeduction = false,
10174 bool HasMatchedPackOnParmToNonPackOnArg = false);
10175
10176 /// Add all of the function declarations in the given function set to
10177 /// the overload candidate set.
10179 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10180 OverloadCandidateSet &CandidateSet,
10181 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr,
10182 bool SuppressUserConversions = false, bool PartialOverloading = false,
10183 bool FirstArgumentIsBase = false);
10184
10185 /// AddMethodCandidate - Adds a named decl (which is some kind of
10186 /// method) as a method candidate to the given overload set.
10187 void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType,
10188 Expr::Classification ObjectClassification,
10189 ArrayRef<Expr *> Args,
10190 OverloadCandidateSet &CandidateSet,
10191 bool SuppressUserConversion = false,
10193
10194 /// AddMethodCandidate - Adds the given C++ member function to the set
10195 /// of candidate functions, using the given function call arguments
10196 /// and the object argument (@c Object). For example, in a call
10197 /// @c o.f(a1,a2), @c Object will contain @c o and @c Args will contain
10198 /// both @c a1 and @c a2. If @p SuppressUserConversions, then don't
10199 /// allow user-defined conversions via constructors or conversion
10200 /// operators.
10201 void AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
10202 CXXRecordDecl *ActingContext, QualType ObjectType,
10203 Expr::Classification ObjectClassification,
10204 ArrayRef<Expr *> Args,
10205 OverloadCandidateSet &CandidateSet,
10206 bool SuppressUserConversions = false,
10207 bool PartialOverloading = false,
10208 ConversionSequenceList EarlyConversions = {},
10210 bool HasMatchedPackOnParmToNonPackOnArg = false);
10211
10212 /// Add a C++ member function template as a candidate to the candidate
10213 /// set, using template argument deduction to produce an appropriate member
10214 /// function template specialization.
10216 FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl,
10217 CXXRecordDecl *ActingContext,
10218 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType,
10219 Expr::Classification ObjectClassification, ArrayRef<Expr *> Args,
10220 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10221 bool PartialOverloading = false, OverloadCandidateParamOrder PO = {});
10222
10223 /// Add a C++ function template specialization as a candidate
10224 /// in the candidate set, using template argument deduction to produce
10225 /// an appropriate function template specialization.
10227 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10228 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
10229 OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false,
10230 bool PartialOverloading = false, bool AllowExplicit = true,
10231 ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
10233 bool AggregateCandidateDeduction = false);
10234
10235 /// Check that implicit conversion sequences can be formed for each argument
10236 /// whose corresponding parameter has a non-dependent type, per DR1391's
10237 /// [temp.deduct.call]p10.
10239 FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes,
10240 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet,
10241 ConversionSequenceList &Conversions, bool SuppressUserConversions,
10242 CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
10243 Expr::Classification ObjectClassification = {},
10245
10246 /// AddConversionCandidate - Add a C++ conversion function as a
10247 /// candidate in the candidate set (C++ [over.match.conv],
10248 /// C++ [over.match.copy]). From is the expression we're converting from,
10249 /// and ToType is the type that we're eventually trying to convert to
10250 /// (which may or may not be the same type as the type that the
10251 /// conversion function produces).
10253 CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
10254 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10255 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10256 bool AllowExplicit, bool AllowResultConversion = true,
10257 bool HasMatchedPackOnParmToNonPackOnArg = false);
10258
10259 /// Adds a conversion function template specialization
10260 /// candidate to the overload set, using template argument deduction
10261 /// to deduce the template arguments of the conversion function
10262 /// template from the type that we are converting to (C++
10263 /// [temp.deduct.conv]).
10265 FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl,
10266 CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
10267 OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10268 bool AllowExplicit, bool AllowResultConversion = true);
10269
10270 /// AddSurrogateCandidate - Adds a "surrogate" candidate function that
10271 /// converts the given @c Object to a function pointer via the
10272 /// conversion function @c Conversion, and then attempts to call it
10273 /// with the given arguments (C++ [over.call.object]p2-4). Proto is
10274 /// the type of function that we'll eventually be calling.
10275 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
10276 DeclAccessPair FoundDecl,
10277 CXXRecordDecl *ActingContext,
10278 const FunctionProtoType *Proto, Expr *Object,
10279 ArrayRef<Expr *> Args,
10280 OverloadCandidateSet &CandidateSet);
10281
10282 /// Add all of the non-member operator function declarations in the given
10283 /// function set to the overload candidate set.
10285 const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args,
10286 OverloadCandidateSet &CandidateSet,
10287 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10288
10289 /// Add overload candidates for overloaded operators that are
10290 /// member functions.
10291 ///
10292 /// Add the overloaded operator candidates that are member functions
10293 /// for the operator Op that was used in an operator expression such
10294 /// as "x Op y". , Args/NumArgs provides the operator arguments, and
10295 /// CandidateSet will store the added overload candidates. (C++
10296 /// [over.match.oper]).
10298 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10299 OverloadCandidateSet &CandidateSet,
10301
10302 /// AddBuiltinCandidate - Add a candidate for a built-in
10303 /// operator. ResultTy and ParamTys are the result and parameter types
10304 /// of the built-in candidate, respectively. Args and NumArgs are the
10305 /// arguments being passed to the candidate. IsAssignmentOperator
10306 /// should be true when this built-in candidate is an assignment
10307 /// operator. NumContextualBoolArguments is the number of arguments
10308 /// (at the beginning of the argument list) that will be contextually
10309 /// converted to bool.
10310 void AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
10311 OverloadCandidateSet &CandidateSet,
10312 bool IsAssignmentOperator = false,
10313 unsigned NumContextualBoolArguments = 0);
10314
10315 /// AddBuiltinOperatorCandidates - Add the appropriate built-in
10316 /// operator overloads to the candidate set (C++ [over.built]), based
10317 /// on the operator @p Op and the arguments given. For example, if the
10318 /// operator is a binary '+', this routine might add "int
10319 /// operator+(int, int)" to cover integer addition.
10321 SourceLocation OpLoc, ArrayRef<Expr *> Args,
10322 OverloadCandidateSet &CandidateSet);
10323
10324 /// Add function candidates found via argument-dependent lookup
10325 /// to the set of overloading candidates.
10326 ///
10327 /// This routine performs argument-dependent name lookup based on the
10328 /// given function name (which may also be an operator name) and adds
10329 /// all of the overload candidates found by ADL to the overload
10330 /// candidate set (C++ [basic.lookup.argdep]).
10332 DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
10333 TemplateArgumentListInfo *ExplicitTemplateArgs,
10334 OverloadCandidateSet &CandidateSet, bool PartialOverloading = false);
10335
10336 /// Check the enable_if expressions on the given function. Returns the first
10337 /// failing attribute, or NULL if they were all successful.
10338 EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
10339 ArrayRef<Expr *> Args,
10340 bool MissingImplicitThis = false);
10341
10342 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10343 /// non-ArgDependent DiagnoseIfAttrs.
10344 ///
10345 /// Argument-dependent diagnose_if attributes should be checked each time a
10346 /// function is used as a direct callee of a function call.
10347 ///
10348 /// Returns true if any errors were emitted.
10349 bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
10350 const Expr *ThisArg,
10351 ArrayRef<const Expr *> Args,
10352 SourceLocation Loc);
10353
10354 /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
10355 /// ArgDependent DiagnoseIfAttrs.
10356 ///
10357 /// Argument-independent diagnose_if attributes should be checked on every use
10358 /// of a function.
10359 ///
10360 /// Returns true if any errors were emitted.
10361 bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
10362 SourceLocation Loc);
10363
10364 /// Determine if \p A and \p B are equivalent internal linkage declarations
10365 /// from different modules, and thus an ambiguity error can be downgraded to
10366 /// an extension warning.
10367 bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
10368 const NamedDecl *B);
10370 SourceLocation Loc, const NamedDecl *D,
10371 ArrayRef<const NamedDecl *> Equiv);
10372
10373 // Emit as a 'note' the specific overload candidate
10375 const NamedDecl *Found, const FunctionDecl *Fn,
10377 QualType DestType = QualType(), bool TakingAddress = false);
10378
10379 // Emit as a series of 'note's all template and non-templates identified by
10380 // the expression Expr
10381 void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
10382 bool TakingAddress = false);
10383
10384 /// Returns whether the given function's address can be taken or not,
10385 /// optionally emitting a diagnostic if the address can't be taken.
10386 ///
10387 /// Returns false if taking the address of the function is illegal.
10388 bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function,
10389 bool Complain = false,
10390 SourceLocation Loc = SourceLocation());
10391
10392 // [PossiblyAFunctionType] --> [Return]
10393 // NonFunctionType --> NonFunctionType
10394 // R (A) --> R(A)
10395 // R (*)(A) --> R (A)
10396 // R (&)(A) --> R (A)
10397 // R (S::*)(A) --> R (A)
10398 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
10399
10400 /// ResolveAddressOfOverloadedFunction - Try to resolve the address of
10401 /// an overloaded function (C++ [over.over]), where @p From is an
10402 /// expression with overloaded function type and @p ToType is the type
10403 /// we're trying to resolve to. For example:
10404 ///
10405 /// @code
10406 /// int f(double);
10407 /// int f(int);
10408 ///
10409 /// int (*pfd)(double) = f; // selects f(double)
10410 /// @endcode
10411 ///
10412 /// This routine returns the resulting FunctionDecl if it could be
10413 /// resolved, and NULL otherwise. When @p Complain is true, this
10414 /// routine will emit diagnostics if there is an error.
10415 FunctionDecl *
10416 ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
10417 bool Complain, DeclAccessPair &Found,
10418 bool *pHadMultipleCandidates = nullptr);
10419
10420 /// Given an expression that refers to an overloaded function, try to
10421 /// resolve that function to a single function that can have its address
10422 /// taken. This will modify `Pair` iff it returns non-null.
10423 ///
10424 /// This routine can only succeed if from all of the candidates in the
10425 /// overload set for SrcExpr that can have their addresses taken, there is one
10426 /// candidate that is more constrained than the rest.
10427 FunctionDecl *
10428 resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult);
10429
10430 /// Given an overloaded function, tries to turn it into a non-overloaded
10431 /// function reference using resolveAddressOfSingleOverloadCandidate. This
10432 /// will perform access checks, diagnose the use of the resultant decl, and,
10433 /// if requested, potentially perform a function-to-pointer decay.
10434 ///
10435 /// Returns false if resolveAddressOfSingleOverloadCandidate fails.
10436 /// Otherwise, returns true. This may emit diagnostics and return true.
10438 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
10439
10440 /// Given an expression that refers to an overloaded function, try to
10441 /// resolve that overloaded function expression down to a single function.
10442 ///
10443 /// This routine can only resolve template-ids that refer to a single function
10444 /// template, where that template-id refers to a single template whose
10445 /// template arguments are either provided by the template-id or have
10446 /// defaults, as described in C++0x [temp.arg.explicit]p3.
10447 ///
10448 /// If no template-ids are found, no diagnostics are emitted and NULL is
10449 /// returned.
10451 OverloadExpr *ovl, bool Complain = false, DeclAccessPair *Found = nullptr,
10452 TemplateSpecCandidateSet *FailedTSC = nullptr);
10453
10454 // Resolve and fix an overloaded expression that can be resolved
10455 // because it identifies a single function template specialization.
10456 //
10457 // Last three arguments should only be supplied if Complain = true
10458 //
10459 // Return true if it was logically possible to so resolve the
10460 // expression, regardless of whether or not it succeeded. Always
10461 // returns true if 'complain' is set.
10463 ExprResult &SrcExpr, bool DoFunctionPointerConversion = false,
10464 bool Complain = false, SourceRange OpRangeForComplaining = SourceRange(),
10465 QualType DestTypeForComplaining = QualType(),
10466 unsigned DiagIDForComplaining = 0);
10467
10468 /// Add the overload candidates named by callee and/or found by argument
10469 /// dependent lookup to the given overload set.
10470 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
10471 ArrayRef<Expr *> Args,
10472 OverloadCandidateSet &CandidateSet,
10473 bool PartialOverloading = false);
10474
10475 /// Add the call candidates from the given set of lookup results to the given
10476 /// overload set. Non-function lookup results are ignored.
10478 LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs,
10479 ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet);
10480
10481 // An enum used to represent the different possible results of building a
10482 // range-based for loop.
10488
10489 /// Build a call to 'begin' or 'end' for a C++11 for-range statement. If the
10490 /// given LookupResult is non-empty, it is assumed to describe a member which
10491 /// will be invoked. Otherwise, the function will be found via argument
10492 /// dependent lookup.
10493 /// CallExpr is set to a valid expression and FRS_Success returned on success,
10494 /// otherwise CallExpr is set to ExprError() and some non-success value
10495 /// is returned.
10497 SourceLocation RangeLoc,
10498 const DeclarationNameInfo &NameInfo,
10499 LookupResult &MemberLookup,
10500 OverloadCandidateSet *CandidateSet,
10502
10503 /// BuildOverloadedCallExpr - Given the call expression that calls Fn
10504 /// (which eventually refers to the declaration Func) and the call
10505 /// arguments Args/NumArgs, attempt to resolve the function call down
10506 /// to a specific function. If overload resolution succeeds, returns
10507 /// the call expression produced by overload resolution.
10508 /// Otherwise, emits diagnostics and returns ExprError.
10510 Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
10511 MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
10512 bool AllowTypoCorrection = true, bool CalleesAddressIsTaken = false);
10513
10514 /// Constructs and populates an OverloadedCandidateSet from
10515 /// the given function.
10516 /// \returns true when an the ExprResult output parameter has been set.
10518 MultiExprArg Args, SourceLocation RParenLoc,
10519 OverloadCandidateSet *CandidateSet,
10521
10525 const UnresolvedSetImpl &Fns,
10526 bool PerformADL = true);
10527
10528 /// Create a unary operation that may resolve to an overloaded
10529 /// operator.
10530 ///
10531 /// \param OpLoc The location of the operator itself (e.g., '*').
10532 ///
10533 /// \param Opc The UnaryOperatorKind that describes this operator.
10534 ///
10535 /// \param Fns The set of non-member functions that will be
10536 /// considered by overload resolution. The caller needs to build this
10537 /// set based on the context using, e.g.,
10538 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10539 /// set should not contain any member functions; those will be added
10540 /// by CreateOverloadedUnaryOp().
10541 ///
10542 /// \param Input The input argument.
10545 const UnresolvedSetImpl &Fns, Expr *input,
10546 bool RequiresADL = true);
10547
10548 /// Perform lookup for an overloaded binary operator.
10551 const UnresolvedSetImpl &Fns,
10552 ArrayRef<Expr *> Args, bool RequiresADL = true);
10553
10554 /// Create a binary operation that may resolve to an overloaded
10555 /// operator.
10556 ///
10557 /// \param OpLoc The location of the operator itself (e.g., '+').
10558 ///
10559 /// \param Opc The BinaryOperatorKind that describes this operator.
10560 ///
10561 /// \param Fns The set of non-member functions that will be
10562 /// considered by overload resolution. The caller needs to build this
10563 /// set based on the context using, e.g.,
10564 /// LookupOverloadedOperatorName() and ArgumentDependentLookup(). This
10565 /// set should not contain any member functions; those will be added
10566 /// by CreateOverloadedBinOp().
10567 ///
10568 /// \param LHS Left-hand argument.
10569 /// \param RHS Right-hand argument.
10570 /// \param PerformADL Whether to consider operator candidates found by ADL.
10571 /// \param AllowRewrittenCandidates Whether to consider candidates found by
10572 /// C++20 operator rewrites.
10573 /// \param DefaultedFn If we are synthesizing a defaulted operator function,
10574 /// the function in question. Such a function is never a candidate in
10575 /// our overload resolution. This also enables synthesizing a three-way
10576 /// comparison from < and == as described in C++20 [class.spaceship]p1.
10578 const UnresolvedSetImpl &Fns, Expr *LHS,
10579 Expr *RHS, bool RequiresADL = true,
10580 bool AllowRewrittenCandidates = true,
10581 FunctionDecl *DefaultedFn = nullptr);
10583 const UnresolvedSetImpl &Fns,
10584 Expr *LHS, Expr *RHS,
10585 FunctionDecl *DefaultedFn);
10586
10588 SourceLocation RLoc, Expr *Base,
10589 MultiExprArg Args);
10590
10591 /// BuildCallToMemberFunction - Build a call to a member
10592 /// function. MemExpr is the expression that refers to the member
10593 /// function (and includes the object parameter), Args/NumArgs are the
10594 /// arguments to the function call (not including the object
10595 /// parameter). The caller needs to validate that the member
10596 /// expression refers to a non-static member function or an overloaded
10597 /// member function.
10599 Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args,
10600 SourceLocation RParenLoc, Expr *ExecConfig = nullptr,
10601 bool IsExecConfig = false, bool AllowRecovery = false);
10602
10603 /// BuildCallToObjectOfClassType - Build a call to an object of class
10604 /// type (C++ [over.call.object]), which can end up invoking an
10605 /// overloaded function call operator (@c operator()) or performing a
10606 /// user-defined conversion on the object argument.
10608 SourceLocation LParenLoc,
10609 MultiExprArg Args,
10610 SourceLocation RParenLoc);
10611
10612 /// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
10613 /// (if one exists), where @c Base is an expression of class type and
10614 /// @c Member is the name of the member we're trying to find.
10616 SourceLocation OpLoc,
10617 bool *NoArrowOperatorFound = nullptr);
10618
10620 CXXConversionDecl *Method,
10621 bool HadMultipleCandidates);
10622
10623 /// BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call
10624 /// to a literal operator described by the provided lookup results.
10627 SourceLocation LitEndLoc,
10628 TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
10629
10630 /// FixOverloadedFunctionReference - E is an expression that refers to
10631 /// a C++ overloaded function (possibly with some parentheses and
10632 /// perhaps a '&' around it). We have resolved the overloaded function
10633 /// to the function declaration Fn, so patch up the expression E to
10634 /// refer (possibly indirectly) to Fn. Returns the new expr.
10636 FunctionDecl *Fn);
10638 DeclAccessPair FoundDecl,
10639 FunctionDecl *Fn);
10640
10641 /// - Returns a selector which best matches given argument list or
10642 /// nullptr if none could be found
10644 bool IsInstance,
10646
10647 ///@}
10648
10649 //
10650 //
10651 // -------------------------------------------------------------------------
10652 //
10653 //
10654
10655 /// \name Statements
10656 /// Implementations are in SemaStmt.cpp
10657 ///@{
10658
10659public:
10660 /// Stack of active SEH __finally scopes. Can be empty.
10662
10663 StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true);
10665
10667 bool HasLeadingEmptyMacro = false);
10668
10670 SourceLocation EndLoc);
10672
10673 /// DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is
10674 /// semantically a discarded-value expression, diagnose if any [[nodiscard]]
10675 /// value has been discarded.
10677
10678 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
10679 /// whose result is unused, warn.
10680 void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID);
10681
10682 void ActOnStartOfCompoundStmt(bool IsStmtExpr);
10686 ArrayRef<Stmt *> Elts, bool isStmtExpr);
10687
10689
10692 SourceLocation DotDotDotLoc, ExprResult RHS,
10693 SourceLocation ColonLoc);
10694
10695 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
10696 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
10697
10699 SourceLocation ColonLoc, Stmt *SubStmt,
10700 Scope *CurScope);
10702 SourceLocation ColonLoc, Stmt *SubStmt);
10703
10705 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
10707 Stmt *SubStmt);
10708
10709 /// Check whether the given statement can have musttail applied to it,
10710 /// issuing a diagnostic and returning false if not. In the success case,
10711 /// the statement is rewritten to remove implicit nodes from the return
10712 /// value.
10713 bool checkAndRewriteMustTailAttr(Stmt *St, const Attr &MTA);
10714
10716 SourceLocation LParenLoc, Stmt *InitStmt,
10717 ConditionResult Cond, SourceLocation RParenLoc,
10718 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10720 SourceLocation LParenLoc, Stmt *InitStmt,
10721 ConditionResult Cond, SourceLocation RParenLoc,
10722 Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal);
10723
10725
10727 SourceLocation LParenLoc, Stmt *InitStmt,
10728 ConditionResult Cond,
10729 SourceLocation RParenLoc);
10731 Stmt *Body);
10732
10733 /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant
10734 /// integer not in the range of enum values.
10735 void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
10736 Expr *SrcExpr);
10737
10739 ConditionResult Cond, SourceLocation RParenLoc,
10740 Stmt *Body);
10742 SourceLocation WhileLoc, SourceLocation CondLParen,
10743 Expr *Cond, SourceLocation CondRParen);
10744
10746 Stmt *First, ConditionResult Second,
10747 FullExprArg Third, SourceLocation RParenLoc,
10748 Stmt *Body);
10749
10750 /// In an Objective C collection iteration statement:
10751 /// for (x in y)
10752 /// x can be an arbitrary l-value expression. Bind it up as a
10753 /// full-expression.
10755
10757 /// Initial building of a for-range statement.
10759 /// Instantiation or recovery rebuild of a for-range statement. Don't
10760 /// attempt any typo-correction.
10762 /// Determining whether a for-range statement could be built. Avoid any
10763 /// unnecessary or irreversible actions.
10766
10767 /// ActOnCXXForRangeStmt - Check and build a C++11 for-range statement.
10768 ///
10769 /// C++11 [stmt.ranged]:
10770 /// A range-based for statement is equivalent to
10771 ///
10772 /// {
10773 /// auto && __range = range-init;
10774 /// for ( auto __begin = begin-expr,
10775 /// __end = end-expr;
10776 /// __begin != __end;
10777 /// ++__begin ) {
10778 /// for-range-declaration = *__begin;
10779 /// statement
10780 /// }
10781 /// }
10782 ///
10783 /// The body of the loop is not available yet, since it cannot be analysed
10784 /// until we have determined the type of the for-range-declaration.
10786 Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc,
10787 Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection,
10789 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10790
10791 /// BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
10793 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt,
10794 SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End,
10795 Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc,
10797 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
10798
10799 /// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
10800 /// This is a separate step from ActOnCXXForRangeStmt because analysis of the
10801 /// body cannot be performed until after the type of the range variable is
10802 /// determined.
10803 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body);
10804
10805 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
10806 LabelDecl *TheDecl);
10807 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
10808 SourceLocation StarLoc, Expr *DestExp);
10809 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
10810 StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope);
10811
10814
10815 enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
10817
10818 bool isMoveEligible() const { return S != None; };
10819 bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
10820 };
10822
10823 /// Determine whether the given expression might be move-eligible or
10824 /// copy-elidable in either a (co_)return statement or throw expression,
10825 /// without considering function return type, if applicable.
10826 ///
10827 /// \param E The expression being returned from the function or block,
10828 /// being thrown, or being co_returned from a coroutine. This expression
10829 /// might be modified by the implementation.
10830 ///
10831 /// \param Mode Overrides detection of current language mode
10832 /// and uses the rules for C++23.
10833 ///
10834 /// \returns An aggregate which contains the Candidate and isMoveEligible
10835 /// and isCopyElidable methods. If Candidate is non-null, it means
10836 /// isMoveEligible() would be true under the most permissive language
10837 /// standard.
10838 NamedReturnInfo getNamedReturnInfo(
10840
10841 /// Determine whether the given NRVO candidate variable is move-eligible or
10842 /// copy-elidable, without considering function return type.
10843 ///
10844 /// \param VD The NRVO candidate variable.
10845 ///
10846 /// \returns An aggregate which contains the Candidate and isMoveEligible
10847 /// and isCopyElidable methods. If Candidate is non-null, it means
10848 /// isMoveEligible() would be true under the most permissive language
10849 /// standard.
10850 NamedReturnInfo getNamedReturnInfo(const VarDecl *VD);
10851
10852 /// Updates given NamedReturnInfo's move-eligible and
10853 /// copy-elidable statuses, considering the function
10854 /// return type criteria as applicable to return statements.
10855 ///
10856 /// \param Info The NamedReturnInfo object to update.
10857 ///
10858 /// \param ReturnType This is the return type of the function.
10859 /// \returns The copy elision candidate, in case the initial return expression
10860 /// was copy elidable, or nullptr otherwise.
10861 const VarDecl *getCopyElisionCandidate(NamedReturnInfo &Info,
10862 QualType ReturnType);
10863
10864 /// Perform the initialization of a potentially-movable value, which
10865 /// is the result of return value.
10866 ///
10867 /// This routine implements C++20 [class.copy.elision]p3, which attempts to
10868 /// treat returned lvalues as rvalues in certain cases (to prefer move
10869 /// construction), then falls back to treating them as lvalues if that failed.
10872 const NamedReturnInfo &NRInfo, Expr *Value,
10873 bool SupressSimplerImplicitMoves = false);
10874
10876
10877 /// Deduce the return type for a function from a returned expression, per
10878 /// C++1y [dcl.spec.auto]p6.
10880 SourceLocation ReturnLoc, Expr *RetExpr,
10881 const AutoType *AT);
10882
10883 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10884 Scope *CurScope);
10885 StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
10886 bool AllowRecovery = false);
10887
10888 /// ActOnCapScopeReturnStmt - Utility routine to type-check return statements
10889 /// for capturing scopes.
10891 NamedReturnInfo &NRInfo,
10892 bool SupressSimplerImplicitMoves);
10893
10894 /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
10895 /// and creates a proper catch handler from them.
10897 Stmt *HandlerBlock);
10898
10899 /// ActOnCXXTryBlock - Takes a try compound-statement and a number of
10900 /// handlers and creates a try statement from them.
10902 ArrayRef<Stmt *> Handlers);
10903
10904 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ?
10905 SourceLocation TryLoc, Stmt *TryBlock,
10906 Stmt *Handler);
10908 Stmt *Block);
10913
10915 bool IsIfExists,
10916 NestedNameSpecifierLoc QualifierLoc,
10917 DeclarationNameInfo NameInfo,
10918 Stmt *Nested);
10920 bool IsIfExists, CXXScopeSpec &SS,
10921 UnqualifiedId &Name, Stmt *Nested);
10922
10924 CapturedRegionKind Kind, unsigned NumParams);
10925 typedef std::pair<StringRef, QualType> CapturedParamNameType;
10929 unsigned OpenMPCaptureLevel = 0);
10934 unsigned NumParams);
10935
10936private:
10937 /// Check whether the given statement can have musttail applied to it,
10938 /// issuing a diagnostic and returning false if not.
10939 bool checkMustTailAttr(const Stmt *St, const Attr &MTA);
10940
10941 /// Check if the given expression contains 'break' or 'continue'
10942 /// statement that produces control flow different from GCC.
10943 void CheckBreakContinueBinding(Expr *E);
10944
10945 ///@}
10946
10947 //
10948 //
10949 // -------------------------------------------------------------------------
10950 //
10951 //
10952
10953 /// \name `inline asm` Statement
10954 /// Implementations are in SemaStmtAsm.cpp
10955 ///@{
10956
10957public:
10958 StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
10959 bool IsVolatile, unsigned NumOutputs,
10960 unsigned NumInputs, IdentifierInfo **Names,
10961 MultiExprArg Constraints, MultiExprArg Exprs,
10962 Expr *AsmString, MultiExprArg Clobbers,
10963 unsigned NumLabels, SourceLocation RParenLoc);
10964
10966 llvm::InlineAsmIdentifierInfo &Info);
10968 SourceLocation TemplateKWLoc,
10970 bool IsUnevaluatedContext);
10971 bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset,
10972 SourceLocation AsmLoc);
10974 SourceLocation AsmLoc);
10976 ArrayRef<Token> AsmToks, StringRef AsmString,
10977 unsigned NumOutputs, unsigned NumInputs,
10978 ArrayRef<StringRef> Constraints,
10979 ArrayRef<StringRef> Clobbers,
10980 ArrayRef<Expr *> Exprs, SourceLocation EndLoc);
10981 LabelDecl *GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
10982 SourceLocation Location, bool AlwaysCreate);
10983
10984 ///@}
10985
10986 //
10987 //
10988 // -------------------------------------------------------------------------
10989 //
10990 //
10991
10992 /// \name Statement Attribute Handling
10993 /// Implementations are in SemaStmtAttr.cpp
10994 ///@{
10995
10996public:
10997 bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
10998 const AttributeCommonInfo &A);
10999 bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt,
11000 const AttributeCommonInfo &A);
11001
11002 CodeAlignAttr *BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E);
11004
11005 /// Process the attributes before creating an attributed statement. Returns
11006 /// the semantic attributes that have been processed.
11007 void ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributes &InAttrs,
11009
11013 const IdentifierInfo *AttrName,
11015
11016 ///@}
11017
11018 //
11019 //
11020 // -------------------------------------------------------------------------
11021 //
11022 //
11023
11024 /// \name C++ Templates
11025 /// Implementations are in SemaTemplate.cpp
11026 ///@{
11027
11028public:
11029 // Saves the current floating-point pragma stack and clear it in this Sema.
11031 public:
11033 : S(S), SavedStack(std::move(S.FpPragmaStack)) {
11034 S.FpPragmaStack.Stack.clear();
11035 }
11036 ~FpPragmaStackSaveRAII() { S.FpPragmaStack = std::move(SavedStack); }
11037
11038 private:
11039 Sema &S;
11041 };
11042
11044 CurFPFeatures = FPO;
11045 FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
11046 }
11047
11049 return llvm::ArrayRef(InventedParameterInfos.begin() +
11052 }
11053
11054 /// The number of SFINAE diagnostics that have been trapped.
11056
11059 FunctionScopes.end());
11060 }
11061
11062 typedef llvm::MapVector<const FunctionDecl *,
11063 std::unique_ptr<LateParsedTemplate>>
11066
11067 /// Determine the number of levels of enclosing template parameters. This is
11068 /// only usable while parsing. Note that this does not include dependent
11069 /// contexts in which no template parameters have yet been declared, such as
11070 /// in a terse function template or generic lambda before the first 'auto' is
11071 /// encountered.
11072 unsigned getTemplateDepth(Scope *S) const;
11073
11075 bool AllowFunctionTemplates = true,
11076 bool AllowDependent = true);
11078 bool AllowFunctionTemplates = true,
11079 bool AllowDependent = true,
11080 bool AllowNonTemplateFunctions = false);
11081 /// Try to interpret the lookup result D as a template-name.
11082 ///
11083 /// \param D A declaration found by name lookup.
11084 /// \param AllowFunctionTemplates Whether function templates should be
11085 /// considered valid results.
11086 /// \param AllowDependent Whether unresolved using declarations (that might
11087 /// name templates) should be considered valid results.
11089 bool AllowFunctionTemplates = true,
11090 bool AllowDependent = true);
11091
11093 /// Whether and why a template name is required in this lookup.
11095 public:
11096 /// Template name is required if TemplateKWLoc is valid.
11098 : TemplateKW(TemplateKWLoc) {}
11099 /// Template name is unconditionally required.
11101
11103 return TemplateKW.value_or(SourceLocation());
11104 }
11105 bool hasTemplateKeyword() const {
11106 return getTemplateKeywordLoc().isValid();
11107 }
11108 bool isRequired() const { return TemplateKW != SourceLocation(); }
11109 explicit operator bool() const { return isRequired(); }
11110
11111 private:
11112 std::optional<SourceLocation> TemplateKW;
11113 };
11114
11116 /// This is not assumed to be a template name.
11117 None,
11118 /// This is assumed to be a template name because lookup found nothing.
11120 /// This is assumed to be a template name because lookup found one or more
11121 /// functions (but no function templates).
11123 };
11124
11125 bool
11127 QualType ObjectType, bool EnteringContext,
11128 RequiredTemplateKind RequiredTemplate = SourceLocation(),
11129 AssumedTemplateKind *ATK = nullptr,
11130 bool AllowTypoCorrection = true);
11131
11133 bool hasTemplateKeyword,
11134 const UnqualifiedId &Name,
11135 ParsedType ObjectType, bool EnteringContext,
11136 TemplateTy &Template,
11137 bool &MemberOfUnknownSpecialization,
11138 bool Disambiguation = false);
11139
11140 /// Try to resolve an undeclared template name as a type template.
11141 ///
11142 /// Sets II to the identifier corresponding to the template name, and updates
11143 /// Name to a corresponding (typo-corrected) type template name and TNK to
11144 /// the corresponding kind, if possible.
11146 TemplateNameKind &TNK,
11147 SourceLocation NameLoc,
11148 IdentifierInfo *&II);
11149
11151 SourceLocation NameLoc,
11152 bool Diagnose = true);
11153
11154 /// Determine whether a particular identifier might be the name in a C++1z
11155 /// deduction-guide declaration.
11156 bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
11157 SourceLocation NameLoc, CXXScopeSpec &SS,
11158 ParsedTemplateTy *Template = nullptr);
11159
11161 SourceLocation IILoc, Scope *S,
11162 const CXXScopeSpec *SS,
11163 TemplateTy &SuggestedTemplate,
11164 TemplateNameKind &SuggestedKind);
11165
11166 /// Determine whether we would be unable to instantiate this template (because
11167 /// it either has no definition, or is in the process of being instantiated).
11168 bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
11169 NamedDecl *Instantiation,
11170 bool InstantiatedFromMember,
11171 const NamedDecl *Pattern,
11172 const NamedDecl *PatternDef,
11174 bool Complain = true);
11175
11176 /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining
11177 /// that the template parameter 'PrevDecl' is being shadowed by a new
11178 /// declaration at location Loc. Returns true to indicate that this is
11179 /// an error, and false otherwise.
11180 ///
11181 /// \param Loc The location of the declaration that shadows a template
11182 /// parameter.
11183 ///
11184 /// \param PrevDecl The template parameter that the declaration shadows.
11185 ///
11186 /// \param SupportedForCompatibility Whether to issue the diagnostic as
11187 /// a warning for compatibility with older versions of clang.
11188 /// Ignored when MSVC compatibility is enabled.
11190 bool SupportedForCompatibility = false);
11191
11192 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
11193 /// the parameter D to reference the templated declaration and return a
11194 /// pointer to the template declaration. Otherwise, do nothing to D and return
11195 /// null.
11197
11198 /// ActOnTypeParameter - Called when a C++ template type parameter
11199 /// (e.g., "typename T") has been parsed. Typename specifies whether
11200 /// the keyword "typename" was used to declare the type parameter
11201 /// (otherwise, "class" was used), and KeyLoc is the location of the
11202 /// "class" or "typename" keyword. ParamName is the name of the
11203 /// parameter (NULL indicates an unnamed template parameter) and
11204 /// ParamNameLoc is the location of the parameter name (if any).
11205 /// If the type parameter has a default argument, it will be added
11206 /// later via ActOnTypeParameterDefault.
11208 SourceLocation EllipsisLoc,
11209 SourceLocation KeyLoc,
11210 IdentifierInfo *ParamName,
11211 SourceLocation ParamNameLoc, unsigned Depth,
11212 unsigned Position, SourceLocation EqualLoc,
11213 ParsedType DefaultArg, bool HasTypeConstraint);
11214
11216
11217 bool ActOnTypeConstraint(const CXXScopeSpec &SS,
11219 TemplateTypeParmDecl *ConstrainedParameter,
11220 SourceLocation EllipsisLoc);
11221 bool BuildTypeConstraint(const CXXScopeSpec &SS,
11223 TemplateTypeParmDecl *ConstrainedParameter,
11224 SourceLocation EllipsisLoc,
11225 bool AllowUnexpandedPack);
11226
11227 /// Attach a type-constraint to a template parameter.
11228 /// \returns true if an error occurred. This can happen if the
11229 /// immediately-declared constraint could not be formed (e.g. incorrect number
11230 /// of arguments for the named concept).
11232 DeclarationNameInfo NameInfo,
11233 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
11234 const TemplateArgumentListInfo *TemplateArgs,
11235 TemplateTypeParmDecl *ConstrainedParameter,
11236 QualType ConstrainedType,
11237 SourceLocation EllipsisLoc);
11238
11240 NonTypeTemplateParmDecl *NewConstrainedParm,
11241 NonTypeTemplateParmDecl *OrigConstrainedParm,
11242 SourceLocation EllipsisLoc);
11243
11244 /// Require the given type to be a structural type, and diagnose if it is not.
11245 ///
11246 /// \return \c true if an error was produced.
11248
11249 /// Check that the type of a non-type template parameter is
11250 /// well-formed.
11251 ///
11252 /// \returns the (possibly-promoted) parameter type if valid;
11253 /// otherwise, produces a diagnostic and returns a NULL type.
11257
11259 unsigned Depth, unsigned Position,
11260 SourceLocation EqualLoc,
11261 Expr *DefaultArg);
11262
11263 /// ActOnTemplateTemplateParameter - Called when a C++ template template
11264 /// parameter (e.g. T in template <template <typename> class T> class array)
11265 /// has been parsed. S is the current scope.
11267 Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params,
11268 bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName,
11269 SourceLocation ParamNameLoc, unsigned Depth, unsigned Position,
11270 SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg);
11271
11272 /// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
11273 /// constrained by RequiresClause, that contains the template parameters in
11274 /// Params.
11276 unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
11277 SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
11278 SourceLocation RAngleLoc, Expr *RequiresClause);
11279
11280 /// The context in which we are checking a template parameter list.
11291
11292 /// Checks the validity of a template parameter list, possibly
11293 /// considering the template parameter list from a previous
11294 /// declaration.
11295 ///
11296 /// If an "old" template parameter list is provided, it must be
11297 /// equivalent (per TemplateParameterListsAreEqual) to the "new"
11298 /// template parameter list.
11299 ///
11300 /// \param NewParams Template parameter list for a new template
11301 /// declaration. This template parameter list will be updated with any
11302 /// default arguments that are carried through from the previous
11303 /// template parameter list.
11304 ///
11305 /// \param OldParams If provided, template parameter list from a
11306 /// previous declaration of the same template. Default template
11307 /// arguments will be merged from the old template parameter list to
11308 /// the new template parameter list.
11309 ///
11310 /// \param TPC Describes the context in which we are checking the given
11311 /// template parameter list.
11312 ///
11313 /// \param SkipBody If we might have already made a prior merged definition
11314 /// of this template visible, the corresponding body-skipping information.
11315 /// Default argument redefinition is not an error when skipping such a body,
11316 /// because (under the ODR) we can assume the default arguments are the same
11317 /// as the prior merged definition.
11318 ///
11319 /// \returns true if an error occurred, false otherwise.
11321 TemplateParameterList *OldParams,
11323 SkipBodyInfo *SkipBody = nullptr);
11324
11325 /// Match the given template parameter lists to the given scope
11326 /// specifier, returning the template parameter list that applies to the
11327 /// name.
11328 ///
11329 /// \param DeclStartLoc the start of the declaration that has a scope
11330 /// specifier or a template parameter list.
11331 ///
11332 /// \param DeclLoc The location of the declaration itself.
11333 ///
11334 /// \param SS the scope specifier that will be matched to the given template
11335 /// parameter lists. This scope specifier precedes a qualified name that is
11336 /// being declared.
11337 ///
11338 /// \param TemplateId The template-id following the scope specifier, if there
11339 /// is one. Used to check for a missing 'template<>'.
11340 ///
11341 /// \param ParamLists the template parameter lists, from the outermost to the
11342 /// innermost template parameter lists.
11343 ///
11344 /// \param IsFriend Whether to apply the slightly different rules for
11345 /// matching template parameters to scope specifiers in friend
11346 /// declarations.
11347 ///
11348 /// \param IsMemberSpecialization will be set true if the scope specifier
11349 /// denotes a fully-specialized type, and therefore this is a declaration of
11350 /// a member specialization.
11351 ///
11352 /// \returns the template parameter list, if any, that corresponds to the
11353 /// name that is preceded by the scope specifier @p SS. This template
11354 /// parameter list may have template parameters (if we're declaring a
11355 /// template) or may have no template parameters (if we're declaring a
11356 /// template specialization), or may be NULL (if what we're declaring isn't
11357 /// itself a template).
11359 SourceLocation DeclStartLoc, SourceLocation DeclLoc,
11360 const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId,
11361 ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend,
11362 bool &IsMemberSpecialization, bool &Invalid,
11363 bool SuppressDiagnostic = false);
11364
11365 /// Returns the template parameter list with all default template argument
11366 /// information.
11368
11370 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11371 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
11372 const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams,
11373 AccessSpecifier AS, SourceLocation ModulePrivateLoc,
11374 SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists,
11375 TemplateParameterList **OuterTemplateParamLists,
11376 SkipBodyInfo *SkipBody = nullptr);
11377
11378 /// Translates template arguments as provided by the parser
11379 /// into template arguments used by semantic analysis.
11382
11383 /// Convert a parsed type into a parsed template argument. This is mostly
11384 /// trivial, except that we may have parsed a C++17 deduced class template
11385 /// specialization type, in which case we should form a template template
11386 /// argument instead of a type template argument.
11388
11390
11392 SourceLocation TemplateLoc,
11393 TemplateArgumentListInfo &TemplateArgs);
11394
11397 TemplateTy Template, const IdentifierInfo *TemplateII,
11398 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11399 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc,
11400 bool IsCtorOrDtorName = false, bool IsClassName = false,
11401 ImplicitTypenameContext AllowImplicitTypename =
11403
11404 /// Parsed an elaborated-type-specifier that refers to a template-id,
11405 /// such as \c class T::template apply<U>.
11407 TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
11408 CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
11409 SourceLocation TemplateLoc, SourceLocation LAngleLoc,
11410 ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc);
11411
11414 SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
11416
11417 /// Get the specialization of the given variable template corresponding to
11418 /// the specified argument list, or a null-but-valid result if the arguments
11419 /// are dependent.
11421 SourceLocation TemplateLoc,
11422 SourceLocation TemplateNameLoc,
11423 const TemplateArgumentListInfo &TemplateArgs);
11424
11425 /// Form a reference to the specialization of the given variable template
11426 /// corresponding to the specified argument list, or a null-but-valid result
11427 /// if the arguments are dependent.
11429 const DeclarationNameInfo &NameInfo,
11430 VarTemplateDecl *Template, NamedDecl *FoundD,
11431 SourceLocation TemplateLoc,
11432 const TemplateArgumentListInfo *TemplateArgs);
11433
11435 CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11436 const DeclarationNameInfo &ConceptNameInfo,
11437 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
11438 const TemplateArgumentListInfo *TemplateArgs);
11439
11442 bool TemplateKeyword, TemplateDecl *TD,
11444
11446 SourceLocation TemplateKWLoc, LookupResult &R,
11447 bool RequiresADL,
11448 const TemplateArgumentListInfo *TemplateArgs);
11449
11450 // We actually only call this from template instantiation.
11453 const DeclarationNameInfo &NameInfo,
11454 const TemplateArgumentListInfo *TemplateArgs,
11455 bool IsAddressOfOperand);
11456
11457 /// Form a template name from a name that is syntactically required to name a
11458 /// template, either due to use of the 'template' keyword or because a name in
11459 /// this syntactic context is assumed to name a template (C++
11460 /// [temp.names]p2-4).
11461 ///
11462 /// This action forms a template name given the name of the template and its
11463 /// optional scope specifier. This is used when the 'template' keyword is used
11464 /// or when the parsing context unambiguously treats a following '<' as
11465 /// introducing a template argument list. Note that this may produce a
11466 /// non-dependent template name if we can perform the lookup now and identify
11467 /// the named template.
11468 ///
11469 /// For example, given "x.MetaFun::template apply", the scope specifier
11470 /// \p SS will be "MetaFun::", \p TemplateKWLoc contains the location
11471 /// of the "template" keyword, and "apply" is the \p Name.
11473 SourceLocation TemplateKWLoc,
11474 const UnqualifiedId &Name,
11475 ParsedType ObjectType,
11476 bool EnteringContext, TemplateTy &Template,
11477 bool AllowInjectedClassName = false);
11478
11480 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
11481 SourceLocation ModulePrivateLoc, CXXScopeSpec &SS,
11483 MultiTemplateParamsArg TemplateParameterLists,
11484 SkipBodyInfo *SkipBody = nullptr);
11485
11486 /// Check the non-type template arguments of a class template
11487 /// partial specialization according to C++ [temp.class.spec]p9.
11488 ///
11489 /// \param TemplateNameLoc the location of the template name.
11490 /// \param PrimaryTemplate the template parameters of the primary class
11491 /// template.
11492 /// \param NumExplicit the number of explicitly-specified template arguments.
11493 /// \param TemplateArgs the template arguments of the class template
11494 /// partial specialization.
11495 ///
11496 /// \returns \c true if there was an error, \c false otherwise.
11498 TemplateDecl *PrimaryTemplate,
11499 unsigned NumExplicitArgs,
11505
11507 MultiTemplateParamsArg TemplateParameterLists,
11508 Declarator &D);
11509
11510 /// Diagnose cases where we have an explicit template specialization
11511 /// before/after an explicit template instantiation, producing diagnostics
11512 /// for those cases where they are required and determining whether the
11513 /// new specialization/instantiation will have any effect.
11514 ///
11515 /// \param NewLoc the location of the new explicit specialization or
11516 /// instantiation.
11517 ///
11518 /// \param NewTSK the kind of the new explicit specialization or
11519 /// instantiation.
11520 ///
11521 /// \param PrevDecl the previous declaration of the entity.
11522 ///
11523 /// \param PrevTSK the kind of the old explicit specialization or
11524 /// instantiatin.
11525 ///
11526 /// \param PrevPointOfInstantiation if valid, indicates where the previous
11527 /// declaration was instantiated (either implicitly or explicitly).
11528 ///
11529 /// \param HasNoEffect will be set to true to indicate that the new
11530 /// specialization or instantiation has no effect and should be ignored.
11531 ///
11532 /// \returns true if there was an error that should prevent the introduction
11533 /// of the new declaration into the AST, false otherwise.
11535 SourceLocation NewLoc,
11536 TemplateSpecializationKind ActOnExplicitInstantiationNewTSK,
11537 NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
11538 SourceLocation PrevPtOfInstantiation, bool &SuppressNew);
11539
11540 /// Perform semantic analysis for the given dependent function
11541 /// template specialization.
11542 ///
11543 /// The only possible way to get a dependent function template specialization
11544 /// is with a friend declaration, like so:
11545 ///
11546 /// \code
11547 /// template <class T> void foo(T);
11548 /// template <class T> class A {
11549 /// friend void foo<>(T);
11550 /// };
11551 /// \endcode
11552 ///
11553 /// There really isn't any useful analysis we can do here, so we
11554 /// just store the information.
11556 FunctionDecl *FD, const TemplateArgumentListInfo *ExplicitTemplateArgs,
11558
11559 /// Perform semantic analysis for the given function template
11560 /// specialization.
11561 ///
11562 /// This routine performs all of the semantic analysis required for an
11563 /// explicit function template specialization. On successful completion,
11564 /// the function declaration \p FD will become a function template
11565 /// specialization.
11566 ///
11567 /// \param FD the function declaration, which will be updated to become a
11568 /// function template specialization.
11569 ///
11570 /// \param ExplicitTemplateArgs the explicitly-provided template arguments,
11571 /// if any. Note that this may be valid info even when 0 arguments are
11572 /// explicitly provided as in, e.g., \c void sort<>(char*, char*);
11573 /// as it anyway contains info on the angle brackets locations.
11574 ///
11575 /// \param Previous the set of declarations that may be specialized by
11576 /// this function specialization.
11577 ///
11578 /// \param QualifiedFriend whether this is a lookup for a qualified friend
11579 /// declaration with no explicit template argument list that might be
11580 /// befriending a function template specialization.
11582 FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs,
11583 LookupResult &Previous, bool QualifiedFriend = false);
11584
11585 /// Perform semantic analysis for the given non-template member
11586 /// specialization.
11587 ///
11588 /// This routine performs all of the semantic analysis required for an
11589 /// explicit member function specialization. On successful completion,
11590 /// the function declaration \p FD will become a member function
11591 /// specialization.
11592 ///
11593 /// \param Member the member declaration, which will be updated to become a
11594 /// specialization.
11595 ///
11596 /// \param Previous the set of declarations, one of which may be specialized
11597 /// by this function specialization; the set will be modified to contain the
11598 /// redeclared member.
11601
11602 // Explicit instantiation of a class template specialization
11604 Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc,
11605 unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS,
11606 TemplateTy Template, SourceLocation TemplateNameLoc,
11607 SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs,
11608 SourceLocation RAngleLoc, const ParsedAttributesView &Attr);
11609
11610 // Explicit instantiation of a member class of a class template.
11612 SourceLocation TemplateLoc,
11613 unsigned TagSpec, SourceLocation KWLoc,
11614 CXXScopeSpec &SS, IdentifierInfo *Name,
11615 SourceLocation NameLoc,
11616 const ParsedAttributesView &Attr);
11617
11619 SourceLocation TemplateLoc,
11620 Declarator &D);
11621
11622 /// If the given template parameter has a default template
11623 /// argument, substitute into that default template argument and
11624 /// return the corresponding template argument.
11626 TemplateDecl *Template, SourceLocation TemplateLoc,
11627 SourceLocation RAngleLoc, Decl *Param,
11628 ArrayRef<TemplateArgument> SugaredConverted,
11629 ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg);
11630
11631 /// Returns the top most location responsible for the definition of \p N.
11632 /// If \p N is a a template specialization, this is the location
11633 /// of the top of the instantiation stack.
11634 /// Otherwise, the location of \p N is returned.
11636
11637 /// Specifies the context in which a particular template
11638 /// argument is being checked.
11640 /// The template argument was specified in the code or was
11641 /// instantiated with some deduced template arguments.
11643
11644 /// The template argument was deduced via template argument
11645 /// deduction.
11647
11648 /// The template argument was deduced from an array bound
11649 /// via template argument deduction.
11652
11653 /// Check that the given template argument corresponds to the given
11654 /// template parameter.
11655 ///
11656 /// \param Param The template parameter against which the argument will be
11657 /// checked.
11658 ///
11659 /// \param Arg The template argument, which may be updated due to conversions.
11660 ///
11661 /// \param Template The template in which the template argument resides.
11662 ///
11663 /// \param TemplateLoc The location of the template name for the template
11664 /// whose argument list we're matching.
11665 ///
11666 /// \param RAngleLoc The location of the right angle bracket ('>') that closes
11667 /// the template argument list.
11668 ///
11669 /// \param ArgumentPackIndex The index into the argument pack where this
11670 /// argument will be placed. Only valid if the parameter is a parameter pack.
11671 ///
11672 /// \param Converted The checked, converted argument will be added to the
11673 /// end of this small vector.
11674 ///
11675 /// \param CTAK Describes how we arrived at this particular template argument:
11676 /// explicitly written, deduced, etc.
11677 ///
11678 /// \returns true on error, false otherwise.
11679 bool
11681 NamedDecl *Template, SourceLocation TemplateLoc,
11682 SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
11683 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11684 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11686 bool *MatchedPackOnParmToNonPackOnArg);
11687
11688 /// Check that the given template arguments can be provided to
11689 /// the given template, converting the arguments along the way.
11690 ///
11691 /// \param Template The template to which the template arguments are being
11692 /// provided.
11693 ///
11694 /// \param TemplateLoc The location of the template name in the source.
11695 ///
11696 /// \param TemplateArgs The list of template arguments. If the template is
11697 /// a template template parameter, this function may extend the set of
11698 /// template arguments to also include substituted, defaulted template
11699 /// arguments.
11700 ///
11701 /// \param PartialTemplateArgs True if the list of template arguments is
11702 /// intentionally partial, e.g., because we're checking just the initial
11703 /// set of template arguments.
11704 ///
11705 /// \param Converted Will receive the converted, canonicalized template
11706 /// arguments.
11707 ///
11708 /// \param UpdateArgsWithConversions If \c true, update \p TemplateArgs to
11709 /// contain the converted forms of the template arguments as written.
11710 /// Otherwise, \p TemplateArgs will not be modified.
11711 ///
11712 /// \param ConstraintsNotSatisfied If provided, and an error occurred, will
11713 /// receive true if the cause for the error is the associated constraints of
11714 /// the template not being satisfied by the template arguments.
11715 ///
11716 /// \param DefaultArgs any default arguments from template specialization
11717 /// deduction.
11718 ///
11719 /// \param PartialOrderingTTP If true, assume these template arguments are
11720 /// the injected template arguments for a template template parameter.
11721 /// This will relax the requirement that all its possible uses are valid:
11722 /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11723 /// during instantiation.
11724 ///
11725 /// \returns true if an error occurred, false otherwise.
11727 TemplateDecl *Template, SourceLocation TemplateLoc,
11728 TemplateArgumentListInfo &TemplateArgs,
11729 const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
11730 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11731 SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11732 bool UpdateArgsWithConversions = true,
11733 bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false,
11734 bool *MatchedPackOnParmToNonPackOnArg = nullptr);
11735
11738 SmallVectorImpl<TemplateArgument> &SugaredConverted,
11739 SmallVectorImpl<TemplateArgument> &CanonicalConverted);
11740
11741 /// Check a template argument against its corresponding
11742 /// template type parameter.
11743 ///
11744 /// This routine implements the semantics of C++ [temp.arg.type]. It
11745 /// returns true if an error occurred, and false otherwise.
11747
11748 /// Check a template argument against its corresponding
11749 /// non-type template parameter.
11750 ///
11751 /// This routine implements the semantics of C++ [temp.arg.nontype].
11752 /// If an error occurred, it returns ExprError(); otherwise, it
11753 /// returns the converted template argument. \p ParamType is the
11754 /// type of the non-type template parameter after it has been instantiated.
11756 QualType InstantiatedParamType, Expr *Arg,
11757 TemplateArgument &SugaredConverted,
11758 TemplateArgument &CanonicalConverted,
11760
11761 /// Check a template argument against its corresponding
11762 /// template template parameter.
11763 ///
11764 /// This routine implements the semantics of C++ [temp.arg.template].
11765 /// It returns true if an error occurred, and false otherwise.
11767 TemplateParameterList *Params,
11769 bool PartialOrdering,
11770 bool *MatchedPackOnParmToNonPackOnArg);
11771
11773 std::optional<SourceRange> ParamRange = {});
11774 void NoteTemplateParameterLocation(const NamedDecl &Decl);
11775
11776 /// Given a non-type template argument that refers to a
11777 /// declaration and the type of its corresponding non-type template
11778 /// parameter, produce an expression that properly refers to that
11779 /// declaration.
11781 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
11782 NamedDecl *TemplateParam = nullptr);
11784 BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg,
11785 SourceLocation Loc);
11786
11787 /// Enumeration describing how template parameter lists are compared
11788 /// for equality.
11790 /// We are matching the template parameter lists of two templates
11791 /// that might be redeclarations.
11792 ///
11793 /// \code
11794 /// template<typename T> struct X;
11795 /// template<typename T> struct X;
11796 /// \endcode
11798
11799 /// We are matching the template parameter lists of two template
11800 /// template parameters as part of matching the template parameter lists
11801 /// of two templates that might be redeclarations.
11802 ///
11803 /// \code
11804 /// template<template<int I> class TT> struct X;
11805 /// template<template<int Value> class Other> struct X;
11806 /// \endcode
11808
11809 /// We are matching the template parameter lists of a template
11810 /// template argument against the template parameter lists of a template
11811 /// template parameter.
11812 ///
11813 /// \code
11814 /// template<template<int Value> class Metafun> struct X;
11815 /// template<int Value> struct integer_c;
11816 /// X<integer_c> xic;
11817 /// \endcode
11819
11820 /// We are determining whether the template-parameters are equivalent
11821 /// according to C++ [temp.over.link]/6. This comparison does not consider
11822 /// constraints.
11823 ///
11824 /// \code
11825 /// template<C1 T> void f(T);
11826 /// template<C2 T> void f(T);
11827 /// \endcode
11829 };
11830
11831 // A struct to represent the 'new' declaration, which is either itself just
11832 // the named decl, or the important information we need about it in order to
11833 // do constraint comparisons.
11835 const NamedDecl *ND = nullptr;
11836 const DeclContext *DC = nullptr;
11837 const DeclContext *LexicalDC = nullptr;
11839
11840 public:
11843 const DeclContext *LexicalDeclCtx,
11845
11846 : DC(DeclCtx), LexicalDC(LexicalDeclCtx), Loc(Loc) {
11847 assert(DC && LexicalDC &&
11848 "Constructor only for cases where we have the information to put "
11849 "in here");
11850 }
11851
11852 // If this was constructed with no information, we cannot do substitution
11853 // for constraint comparison, so make sure we can check that.
11854 bool isInvalid() const { return !ND && !DC; }
11855
11856 const NamedDecl *getDecl() const { return ND; }
11857
11858 bool ContainsDecl(const NamedDecl *ND) const { return this->ND == ND; }
11859
11861 return ND ? ND->getLexicalDeclContext() : LexicalDC;
11862 }
11863
11865 return ND ? ND->getDeclContext() : DC;
11866 }
11867
11868 SourceLocation getLocation() const { return ND ? ND->getLocation() : Loc; }
11869 };
11870
11871 /// Determine whether the given template parameter lists are
11872 /// equivalent.
11873 ///
11874 /// \param New The new template parameter list, typically written in the
11875 /// source code as part of a new template declaration.
11876 ///
11877 /// \param Old The old template parameter list, typically found via
11878 /// name lookup of the template declared with this template parameter
11879 /// list.
11880 ///
11881 /// \param Complain If true, this routine will produce a diagnostic if
11882 /// the template parameter lists are not equivalent.
11883 ///
11884 /// \param Kind describes how we are to match the template parameter lists.
11885 ///
11886 /// \param TemplateArgLoc If this source location is valid, then we
11887 /// are actually checking the template parameter list of a template
11888 /// argument (New) against the template parameter list of its
11889 /// corresponding template template parameter (Old). We produce
11890 /// slightly different diagnostics in this scenario.
11891 ///
11892 /// \returns True if the template parameter lists are equal, false
11893 /// otherwise.
11895 const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New,
11896 const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain,
11898 SourceLocation TemplateArgLoc = SourceLocation());
11899
11901 TemplateParameterList *New, TemplateParameterList *Old, bool Complain,
11903 SourceLocation TemplateArgLoc = SourceLocation()) {
11904 return TemplateParameterListsAreEqual(nullptr, New, nullptr, Old, Complain,
11905 Kind, TemplateArgLoc);
11906 }
11907
11908 /// Check whether a template can be declared within this scope.
11909 ///
11910 /// If the template declaration is valid in this scope, returns
11911 /// false. Otherwise, issues a diagnostic and returns true.
11912 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
11913
11914 /// Called when the parser has parsed a C++ typename
11915 /// specifier, e.g., "typename T::type".
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 II the identifier we're retrieving (e.g., 'type' in the example).
11921 /// \param IdLoc the location of the identifier.
11922 /// \param IsImplicitTypename context where T::type refers to a type.
11924 Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS,
11925 const IdentifierInfo &II, SourceLocation IdLoc,
11927
11928 /// Called when the parser has parsed a C++ typename
11929 /// specifier that ends in a template-id, e.g.,
11930 /// "typename MetaFun::template apply<T1, T2>".
11931 ///
11932 /// \param S The scope in which this typename type occurs.
11933 /// \param TypenameLoc the location of the 'typename' keyword
11934 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
11935 /// \param TemplateLoc the location of the 'template' keyword, if any.
11936 /// \param TemplateName The template name.
11937 /// \param TemplateII The identifier used to name the template.
11938 /// \param TemplateIILoc The location of the template name.
11939 /// \param LAngleLoc The location of the opening angle bracket ('<').
11940 /// \param TemplateArgs The template arguments.
11941 /// \param RAngleLoc The location of the closing angle bracket ('>').
11943 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
11944 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
11945 TemplateTy TemplateName, const IdentifierInfo *TemplateII,
11946 SourceLocation TemplateIILoc, SourceLocation LAngleLoc,
11947 ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc);
11948
11950 SourceLocation KeywordLoc,
11951 NestedNameSpecifierLoc QualifierLoc,
11952 const IdentifierInfo &II, SourceLocation IILoc,
11953 TypeSourceInfo **TSI, bool DeducedTSTContext);
11954
11956 SourceLocation KeywordLoc,
11957 NestedNameSpecifierLoc QualifierLoc,
11958 const IdentifierInfo &II, SourceLocation IILoc,
11959 bool DeducedTSTContext = true);
11960
11961 /// Rebuilds a type within the context of the current instantiation.
11962 ///
11963 /// The type \p T is part of the type of an out-of-line member definition of
11964 /// a class template (or class template partial specialization) that was
11965 /// parsed and constructed before we entered the scope of the class template
11966 /// (or partial specialization thereof). This routine will rebuild that type
11967 /// now that we have entered the declarator's scope, which may produce
11968 /// different canonical types, e.g.,
11969 ///
11970 /// \code
11971 /// template<typename T>
11972 /// struct X {
11973 /// typedef T* pointer;
11974 /// pointer data();
11975 /// };
11976 ///
11977 /// template<typename T>
11978 /// typename X<T>::pointer X<T>::data() { ... }
11979 /// \endcode
11980 ///
11981 /// Here, the type "typename X<T>::pointer" will be created as a
11982 /// DependentNameType, since we do not know that we can look into X<T> when we
11983 /// parsed the type. This function will rebuild the type, performing the
11984 /// lookup of "pointer" in X<T> and returning an ElaboratedType whose
11985 /// canonical type is the same as the canonical type of T*, allowing the
11986 /// return types of the out-of-line definition and the declaration to match.
11989 DeclarationName Name);
11991
11993
11994 /// Rebuild the template parameters now that we know we're in a current
11995 /// instantiation.
11996 bool
11998
11999 /// Produces a formatted string that describes the binding of
12000 /// template parameters to template arguments.
12001 std::string
12003 const TemplateArgumentList &Args);
12004
12005 std::string
12007 const TemplateArgument *Args,
12008 unsigned NumArgs);
12009
12013
12014 /// ActOnDependentIdExpression - Handle a dependent id-expression that
12015 /// was just parsed. This is only possible with an explicit scope
12016 /// specifier naming a dependent type.
12018 const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
12019 const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
12020 const TemplateArgumentListInfo *TemplateArgs);
12021
12024 SourceLocation TemplateKWLoc,
12025 const DeclarationNameInfo &NameInfo,
12026 const TemplateArgumentListInfo *TemplateArgs);
12027
12028 // Calculates whether the expression Constraint depends on an enclosing
12029 // template, for the purposes of [temp.friend] p9.
12030 // TemplateDepth is the 'depth' of the friend function, which is used to
12031 // compare whether a declaration reference is referring to a containing
12032 // template, or just the current friend function. A 'lower' TemplateDepth in
12033 // the AST refers to a 'containing' template. As the constraint is
12034 // uninstantiated, this is relative to the 'top' of the TU.
12035 bool
12037 unsigned TemplateDepth,
12038 const Expr *Constraint);
12039
12040 /// Find the failed Boolean condition within a given Boolean
12041 /// constant expression, and describe it with a string.
12042 std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
12043
12045
12047 Scope *S, MultiTemplateParamsArg TemplateParameterLists,
12048 const IdentifierInfo *Name, SourceLocation NameLoc);
12049
12051 Expr *ConstraintExpr,
12052 const ParsedAttributesView &Attrs);
12053
12055 bool &AddToScope);
12057
12058 TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
12059 const CXXScopeSpec &SS,
12060 const IdentifierInfo *Name,
12061 SourceLocation TagLoc, SourceLocation NameLoc);
12062
12064 CachedTokens &Toks);
12067
12068 /// We've found a use of a templated declaration that would trigger an
12069 /// implicit instantiation. Check that any relevant explicit specializations
12070 /// and partial specializations are visible/reachable, and diagnose if not.
12073
12074 ///@}
12075
12076 //
12077 //
12078 // -------------------------------------------------------------------------
12079 //
12080 //
12081
12082 /// \name C++ Template Argument Deduction
12083 /// Implementations are in SemaTemplateDeduction.cpp
12084 ///@{
12085
12086public:
12087 /// When true, access checking violations are treated as SFINAE
12088 /// failures rather than hard errors.
12090
12091 /// RAII class used to determine whether SFINAE has
12092 /// trapped any errors that occur during template argument
12093 /// deduction.
12095 Sema &SemaRef;
12096 unsigned PrevSFINAEErrors;
12097 bool PrevInNonInstantiationSFINAEContext;
12098 bool PrevAccessCheckingSFINAE;
12099 bool PrevLastDiagnosticIgnored;
12100
12101 public:
12102 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
12103 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
12104 PrevInNonInstantiationSFINAEContext(
12105 SemaRef.InNonInstantiationSFINAEContext),
12106 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
12107 PrevLastDiagnosticIgnored(
12108 SemaRef.getDiagnostics().isLastDiagnosticIgnored()) {
12109 if (!SemaRef.isSFINAEContext())
12110 SemaRef.InNonInstantiationSFINAEContext = true;
12111 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
12112 }
12113
12115 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
12117 PrevInNonInstantiationSFINAEContext;
12118 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
12120 PrevLastDiagnosticIgnored);
12121 }
12122
12123 /// Determine whether any SFINAE errors have been trapped.
12124 bool hasErrorOccurred() const {
12125 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
12126 }
12127 };
12128
12129 /// RAII class used to indicate that we are performing provisional
12130 /// semantic analysis to determine the validity of a construct, so
12131 /// typo-correction and diagnostics in the immediate context (not within
12132 /// implicitly-instantiated templates) should be suppressed.
12134 Sema &SemaRef;
12135 // FIXME: Using a SFINAETrap for this is a hack.
12136 SFINAETrap Trap;
12137 bool PrevDisableTypoCorrection;
12138
12139 public:
12140 explicit TentativeAnalysisScope(Sema &SemaRef)
12141 : SemaRef(SemaRef), Trap(SemaRef, true),
12142 PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12143 SemaRef.DisableTypoCorrection = true;
12144 }
12146 SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12147 }
12148 };
12149
12150 /// For each declaration that involved template argument deduction, the
12151 /// set of diagnostics that were suppressed during that template argument
12152 /// deduction.
12153 ///
12154 /// FIXME: Serialize this structure to the AST file.
12155 typedef llvm::DenseMap<Decl *, SmallVector<PartialDiagnosticAt, 1>>
12158
12159 /// Compare types for equality with respect to possibly compatible
12160 /// function types (noreturn adjustment, implicit calling conventions). If any
12161 /// of parameter and argument is not a function, just perform type comparison.
12162 ///
12163 /// \param P the template parameter type.
12164 ///
12165 /// \param A the argument type.
12167
12168 /// Allocate a TemplateArgumentLoc where all locations have
12169 /// been initialized to the given location.
12170 ///
12171 /// \param Arg The template argument we are producing template argument
12172 /// location information for.
12173 ///
12174 /// \param NTTPType For a declaration template argument, the type of
12175 /// the non-type template parameter that corresponds to this template
12176 /// argument. Can be null if no type sugar is available to add to the
12177 /// type from the template argument.
12178 ///
12179 /// \param Loc The source location to use for the resulting template
12180 /// argument.
12184 NamedDecl *TemplateParam = nullptr);
12185
12186 /// Get a template argument mapping the given template parameter to itself,
12187 /// e.g. for X in \c template<int X>, this would return an expression template
12188 /// argument referencing X.
12190 SourceLocation Location);
12191
12192 /// Adjust the type \p ArgFunctionType to match the calling convention,
12193 /// noreturn, and optionally the exception specification of \p FunctionType.
12194 /// Deduction often wants to ignore these properties when matching function
12195 /// types.
12197 bool AdjustExceptionSpec = false);
12198
12201 ArrayRef<TemplateArgument> TemplateArgs,
12203
12206 ArrayRef<TemplateArgument> TemplateArgs,
12208
12209 /// Deduce the template arguments of the given template from \p FromType.
12210 /// Used to implement the IsDeducible constraint for alias CTAD per C++
12211 /// [over.match.class.deduct]p4.
12212 ///
12213 /// It only supports class or type alias templates.
12217
12222 bool NumberOfArgumentsMustMatch);
12223
12224 /// Substitute the explicitly-provided template arguments into the
12225 /// given function template according to C++ [temp.arg.explicit].
12226 ///
12227 /// \param FunctionTemplate the function template into which the explicit
12228 /// template arguments will be substituted.
12229 ///
12230 /// \param ExplicitTemplateArgs the explicitly-specified template
12231 /// arguments.
12232 ///
12233 /// \param Deduced the deduced template arguments, which will be populated
12234 /// with the converted and checked explicit template arguments.
12235 ///
12236 /// \param ParamTypes will be populated with the instantiated function
12237 /// parameters.
12238 ///
12239 /// \param FunctionType if non-NULL, the result type of the function template
12240 /// will also be instantiated and the pointed-to value will be updated with
12241 /// the instantiated function type.
12242 ///
12243 /// \param Info if substitution fails for any reason, this object will be
12244 /// populated with more information about the failure.
12245 ///
12246 /// \returns TemplateDeductionResult::Success if substitution was successful,
12247 /// or some failure condition.
12250 TemplateArgumentListInfo &ExplicitTemplateArgs,
12254
12255 /// brief A function argument from which we performed template argument
12256 // deduction for a call.
12258 OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
12259 unsigned ArgIdx, QualType OriginalArgType)
12260 : OriginalParamType(OriginalParamType),
12261 DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
12262 OriginalArgType(OriginalArgType) {}
12263
12266 unsigned ArgIdx;
12268 };
12269
12270 /// Finish template argument deduction for a function template,
12271 /// checking the deduced template arguments for completeness and forming
12272 /// the function template specialization.
12273 ///
12274 /// \param OriginalCallArgs If non-NULL, the original call arguments against
12275 /// which the deduced argument types should be compared.
12279 unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
12281 SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12282 bool PartialOverloading, bool PartialOrdering,
12283 llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
12284
12285 /// Perform template argument deduction from a function call
12286 /// (C++ [temp.deduct.call]).
12287 ///
12288 /// \param FunctionTemplate the function template for which we are performing
12289 /// template argument deduction.
12290 ///
12291 /// \param ExplicitTemplateArgs the explicit template arguments provided
12292 /// for this call.
12293 ///
12294 /// \param Args the function call arguments
12295 ///
12296 /// \param Specialization if template argument deduction was successful,
12297 /// this will be set to the function template specialization produced by
12298 /// template argument deduction.
12299 ///
12300 /// \param Info the argument will be updated to provide additional information
12301 /// about template argument deduction.
12302 ///
12303 /// \param CheckNonDependent A callback to invoke to check conversions for
12304 /// non-dependent parameters, between deduction and substitution, per DR1391.
12305 /// If this returns true, substitution will be skipped and we return
12306 /// TemplateDeductionResult::NonDependentConversionFailure. The callback is
12307 /// passed the parameter types (after substituting explicit template
12308 /// arguments).
12309 ///
12310 /// \returns the result of template argument deduction.
12313 TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
12315 bool PartialOverloading, bool AggregateDeductionCandidate,
12316 bool PartialOrdering, QualType ObjectType,
12317 Expr::Classification ObjectClassification,
12318 llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
12319
12320 /// Deduce template arguments when taking the address of a function
12321 /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
12322 /// a template.
12323 ///
12324 /// \param FunctionTemplate the function template for which we are performing
12325 /// template argument deduction.
12326 ///
12327 /// \param ExplicitTemplateArgs the explicitly-specified template
12328 /// arguments.
12329 ///
12330 /// \param ArgFunctionType the function type that will be used as the
12331 /// "argument" type (A) when performing template argument deduction from the
12332 /// function template's function type. This type may be NULL, if there is no
12333 /// argument type to compare against, in C++0x [temp.arg.explicit]p3.
12334 ///
12335 /// \param Specialization if template argument deduction was successful,
12336 /// this will be set to the function template specialization produced by
12337 /// template argument deduction.
12338 ///
12339 /// \param Info the argument will be updated to provide additional information
12340 /// about template argument deduction.
12341 ///
12342 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12343 /// the address of a function template per [temp.deduct.funcaddr] and
12344 /// [over.over]. If \c false, we are looking up a function template
12345 /// specialization based on its signature, per [temp.deduct.decl].
12346 ///
12347 /// \returns the result of template argument deduction.
12350 TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ArgFunctionType,
12352 bool IsAddressOfFunction = false);
12353
12354 /// Deduce template arguments for a templated conversion
12355 /// function (C++ [temp.deduct.conv]) and, if successful, produce a
12356 /// conversion function template specialization.
12359 Expr::Classification ObjectClassification, QualType ToType,
12361
12362 /// Deduce template arguments for a function template when there is
12363 /// nothing to deduce against (C++0x [temp.arg.explicit]p3).
12364 ///
12365 /// \param FunctionTemplate the function template for which we are performing
12366 /// template argument deduction.
12367 ///
12368 /// \param ExplicitTemplateArgs the explicitly-specified template
12369 /// arguments.
12370 ///
12371 /// \param Specialization if template argument deduction was successful,
12372 /// this will be set to the function template specialization produced by
12373 /// template argument deduction.
12374 ///
12375 /// \param Info the argument will be updated to provide additional information
12376 /// about template argument deduction.
12377 ///
12378 /// \param IsAddressOfFunction If \c true, we are deducing as part of taking
12379 /// the address of a function template in a context where we do not have a
12380 /// target type, per [over.over]. If \c false, we are looking up a function
12381 /// template specialization based on its signature, which only happens when
12382 /// deducing a function parameter type from an argument that is a template-id
12383 /// naming a function template specialization.
12384 ///
12385 /// \returns the result of template argument deduction.
12388 TemplateArgumentListInfo *ExplicitTemplateArgs,
12391 bool IsAddressOfFunction = false);
12392
12393 /// Substitute Replacement for \p auto in \p TypeWithAuto
12394 QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement);
12395 /// Substitute Replacement for auto in TypeWithAuto
12397 QualType Replacement);
12398
12399 // Substitute auto in TypeWithAuto for a Dependent auto type
12401
12402 // Substitute auto in TypeWithAuto for a Dependent auto type
12405
12406 /// Completely replace the \c auto in \p TypeWithAuto by
12407 /// \p Replacement. This does not retain any \c auto type sugar.
12408 QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement);
12410 QualType Replacement);
12411
12412 /// Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
12413 ///
12414 /// Note that this is done even if the initializer is dependent. (This is
12415 /// necessary to support partial ordering of templates using 'auto'.)
12416 /// A dependent type will be produced when deducing from a dependent type.
12417 ///
12418 /// \param Type the type pattern using the auto type-specifier.
12419 /// \param Init the initializer for the variable whose type is to be deduced.
12420 /// \param Result if type deduction was successful, this will be set to the
12421 /// deduced type.
12422 /// \param Info the argument will be updated to provide additional information
12423 /// about template argument deduction.
12424 /// \param DependentDeduction Set if we should permit deduction in
12425 /// dependent cases. This is necessary for template partial ordering
12426 /// with 'auto' template parameters. The template parameter depth to be
12427 /// used should be specified in the 'Info' parameter.
12428 /// \param IgnoreConstraints Set if we should not fail if the deduced type
12429 /// does not satisfy the type-constraint in the auto
12430 /// type.
12434 bool DependentDeduction = false,
12435 bool IgnoreConstraints = false,
12436 TemplateSpecCandidateSet *FailedTSC = nullptr);
12437 void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init);
12439 bool Diagnose = true);
12440
12443
12444 /// Returns the more specialized class template partial specialization
12445 /// according to the rules of partial ordering of class template partial
12446 /// specializations (C++ [temp.class.order]).
12447 ///
12448 /// \param PS1 the first class template partial specialization
12449 ///
12450 /// \param PS2 the second class template partial specialization
12451 ///
12452 /// \returns the more specialized class template partial specialization. If
12453 /// neither partial specialization is more specialized, returns NULL.
12458
12461
12465
12468
12470 TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
12471 const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
12472 bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg);
12473
12474 /// Mark which template parameters are used in a given expression.
12475 ///
12476 /// \param E the expression from which template parameters will be deduced.
12477 ///
12478 /// \param Used a bit vector whose elements will be set to \c true
12479 /// to indicate when the corresponding template parameter will be
12480 /// deduced.
12481 void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12482 unsigned Depth, llvm::SmallBitVector &Used);
12483
12484 /// Mark which template parameters can be deduced from a given
12485 /// template argument list.
12486 ///
12487 /// \param TemplateArgs the template argument list from which template
12488 /// parameters will be deduced.
12489 ///
12490 /// \param Used a bit vector whose elements will be set to \c true
12491 /// to indicate when the corresponding template parameter will be
12492 /// deduced.
12493 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
12494 bool OnlyDeduced, unsigned Depth,
12495 llvm::SmallBitVector &Used);
12496 void
12498 llvm::SmallBitVector &Deduced) {
12500 }
12501
12502 /// Marks all of the template parameters that will be deduced by a
12503 /// call to the given function template.
12504 static void
12507 llvm::SmallBitVector &Deduced);
12508
12509 /// Returns the more specialized function template according
12510 /// to the rules of function template partial ordering (C++
12511 /// [temp.func.order]).
12512 ///
12513 /// \param FT1 the first function template
12514 ///
12515 /// \param FT2 the second function template
12516 ///
12517 /// \param TPOC the context in which we are performing partial ordering of
12518 /// function templates.
12519 ///
12520 /// \param NumCallArguments1 The number of arguments in the call to FT1, used
12521 /// only when \c TPOC is \c TPOC_Call. Does not include the object argument
12522 /// when calling a member function.
12523 ///
12524 /// \param RawObj1Ty The type of the object parameter of FT1 if a member
12525 /// function only used if \c TPOC is \c TPOC_Call and FT1 is a Function
12526 /// template from a member function
12527 ///
12528 /// \param RawObj2Ty The type of the object parameter of FT2 if a member
12529 /// function only used if \c TPOC is \c TPOC_Call and FT2 is a Function
12530 /// template from a member function
12531 ///
12532 /// \param Reversed If \c true, exactly one of FT1 and FT2 is an overload
12533 /// candidate with a reversed parameter order. In this case, the corresponding
12534 /// P/A pairs between FT1 and FT2 are reversed.
12535 ///
12536 /// \returns the more specialized function template. If neither
12537 /// template is more specialized, returns NULL.
12540 TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1,
12541 QualType RawObj1Ty = {}, QualType RawObj2Ty = {}, bool Reversed = false);
12542
12543 /// Retrieve the most specialized of the given function template
12544 /// specializations.
12545 ///
12546 /// \param SpecBegin the start iterator of the function template
12547 /// specializations that we will be comparing.
12548 ///
12549 /// \param SpecEnd the end iterator of the function template
12550 /// specializations, paired with \p SpecBegin.
12551 ///
12552 /// \param Loc the location where the ambiguity or no-specializations
12553 /// diagnostic should occur.
12554 ///
12555 /// \param NoneDiag partial diagnostic used to diagnose cases where there are
12556 /// no matching candidates.
12557 ///
12558 /// \param AmbigDiag partial diagnostic used to diagnose an ambiguity, if one
12559 /// occurs.
12560 ///
12561 /// \param CandidateDiag partial diagnostic used for each function template
12562 /// specialization that is a candidate in the ambiguous ordering. One
12563 /// parameter in this diagnostic should be unbound, which will correspond to
12564 /// the string describing the template arguments for the function template
12565 /// specialization.
12566 ///
12567 /// \returns the most specialized function template specialization, if
12568 /// found. Otherwise, returns SpecEnd.
12569 UnresolvedSetIterator
12570 getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd,
12571 TemplateSpecCandidateSet &FailedCandidates,
12572 SourceLocation Loc, const PartialDiagnostic &NoneDiag,
12573 const PartialDiagnostic &AmbigDiag,
12574 const PartialDiagnostic &CandidateDiag,
12575 bool Complain = true, QualType TargetType = QualType());
12576
12577 /// Returns the more constrained function according to the rules of
12578 /// partial ordering by constraints (C++ [temp.constr.order]).
12579 ///
12580 /// \param FD1 the first function
12581 ///
12582 /// \param FD2 the second function
12583 ///
12584 /// \returns the more constrained function. If neither function is
12585 /// more constrained, returns NULL.
12586 FunctionDecl *getMoreConstrainedFunction(FunctionDecl *FD1,
12587 FunctionDecl *FD2);
12588
12589 ///@}
12590
12591 //
12592 //
12593 // -------------------------------------------------------------------------
12594 //
12595 //
12596
12597 /// \name C++ Template Deduction Guide
12598 /// Implementations are in SemaTemplateDeductionGuide.cpp
12599 ///@{
12600
12601 /// Declare implicit deduction guides for a class template if we've
12602 /// not already done so.
12603 void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12604 SourceLocation Loc);
12605
12606 FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12607 TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12608 SourceLocation Loc);
12609
12610 ///@}
12611
12612 //
12613 //
12614 // -------------------------------------------------------------------------
12615 //
12616 //
12617
12618 /// \name C++ Template Instantiation
12619 /// Implementations are in SemaTemplateInstantiate.cpp
12620 ///@{
12621
12622public:
12623 /// A helper class for building up ExtParameterInfos.
12626 bool HasInteresting = false;
12627
12628 public:
12629 /// Set the ExtParameterInfo for the parameter at the given index,
12630 ///
12631 void set(unsigned index, FunctionProtoType::ExtParameterInfo info) {
12632 assert(Infos.size() <= index);
12633 Infos.resize(index);
12634 Infos.push_back(info);
12635
12636 if (!HasInteresting)
12637 HasInteresting = (info != FunctionProtoType::ExtParameterInfo());
12638 }
12639
12640 /// Return a pointer (suitable for setting in an ExtProtoInfo) to the
12641 /// ExtParameterInfo array we've built up.
12643 getPointerOrNull(unsigned numParams) {
12644 if (!HasInteresting)
12645 return nullptr;
12646 Infos.resize(numParams);
12647 return Infos.data();
12648 }
12649 };
12650
12651 /// The current instantiation scope used to store local
12652 /// variables.
12654
12655 typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>>
12657
12658 /// A mapping from parameters with unparsed default arguments to the
12659 /// set of instantiations of each parameter.
12660 ///
12661 /// This mapping is a temporary data structure used when parsing
12662 /// nested class templates or nested classes of class templates,
12663 /// where we might end up instantiating an inner class before the
12664 /// default arguments of its methods have been parsed.
12666
12667 /// A context in which code is being synthesized (where a source location
12668 /// alone is not sufficient to identify the context). This covers template
12669 /// instantiation and various forms of implicitly-generated functions.
12671 /// The kind of template instantiation we are performing
12673 /// We are instantiating a template declaration. The entity is
12674 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
12676
12677 /// We are instantiating a default argument for a template
12678 /// parameter. The Entity is the template parameter whose argument is
12679 /// being instantiated, the Template is the template, and the
12680 /// TemplateArgs/NumTemplateArguments provide the template arguments as
12681 /// specified.
12683
12684 /// We are instantiating a default argument for a function.
12685 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
12686 /// provides the template arguments as specified.
12688
12689 /// We are substituting explicit template arguments provided for
12690 /// a function template. The entity is a FunctionTemplateDecl.
12692
12693 /// We are substituting template argument determined as part of
12694 /// template argument deduction for either a class template
12695 /// partial specialization or a function template. The
12696 /// Entity is either a {Class|Var}TemplatePartialSpecializationDecl or
12697 /// a TemplateDecl.
12699
12700 /// We are substituting into a lambda expression.
12702
12703 /// We are substituting prior template arguments into a new
12704 /// template parameter. The template parameter itself is either a
12705 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
12707
12708 /// We are checking the validity of a default template argument that
12709 /// has been used when naming a template-id.
12711
12712 /// We are computing the exception specification for a defaulted special
12713 /// member function.
12715
12716 /// We are instantiating the exception specification for a function
12717 /// template which was deferred until it was needed.
12719
12720 /// We are instantiating a requirement of a requires expression.
12722
12723 /// We are checking the satisfaction of a nested requirement of a requires
12724 /// expression.
12726
12727 /// We are declaring an implicit special member function.
12729
12730 /// We are declaring an implicit 'operator==' for a defaulted
12731 /// 'operator<=>'.
12733
12734 /// We are defining a synthesized function (such as a defaulted special
12735 /// member).
12737
12738 // We are checking the constraints associated with a constrained entity or
12739 // the constraint expression of a concept. This includes the checks that
12740 // atomic constraints have the type 'bool' and that they can be constant
12741 // evaluated.
12743
12744 // We are substituting template arguments into a constraint expression.
12746
12747 // We are normalizing a constraint expression.
12749
12750 // Instantiating a Requires Expression parameter clause.
12752
12753 // We are substituting into the parameter mapping of an atomic constraint
12754 // during normalization.
12756
12757 /// We are rewriting a comparison operator in terms of an operator<=>.
12759
12760 /// We are initializing a structured binding.
12762
12763 /// We are marking a class as __dllexport.
12765
12766 /// We are building an implied call from __builtin_dump_struct. The
12767 /// arguments are in CallArgs.
12769
12770 /// Added for Template instantiation observation.
12771 /// Memoization means we are _not_ instantiating a template because
12772 /// it is already instantiated (but we entered a context where we
12773 /// would have had to if it was not already instantiated).
12775
12776 /// We are building deduction guides for a class.
12778
12779 /// We are instantiating a type alias template declaration.
12781
12782 /// We are performing partial ordering for template template parameters.
12785
12786 /// Was the enclosing context a non-instantiation SFINAE context?
12788
12789 /// The point of instantiation or synthesis within the source code.
12791
12792 /// The entity that is being synthesized.
12794
12795 /// The template (or partial specialization) in which we are
12796 /// performing the instantiation, for substitutions of prior template
12797 /// arguments.
12799
12800 union {
12801 /// The list of template arguments we are substituting, if they
12802 /// are not part of the entity.
12804
12805 /// The list of argument expressions in a synthesized call.
12806 const Expr *const *CallArgs;
12807 };
12808
12809 // FIXME: Wrap this union around more members, or perhaps store the
12810 // kind-specific members in the RAII object owning the context.
12811 union {
12812 /// The number of template arguments in TemplateArgs.
12814
12815 /// The number of expressions in CallArgs.
12816 unsigned NumCallArgs;
12817
12818 /// The special member being declared or defined.
12820 };
12821
12823 assert(Kind != DeclaringSpecialMember);
12824 return {TemplateArgs, NumTemplateArgs};
12825 }
12826
12827 /// The template deduction info object associated with the
12828 /// substitution or checking of explicit or deduced template arguments.
12830
12831 /// The source range that covers the construct that cause
12832 /// the instantiation, e.g., the template-id that causes a class
12833 /// template instantiation.
12835
12837 : Kind(TemplateInstantiation),
12838 SavedInNonInstantiationSFINAEContext(false), Entity(nullptr),
12839 Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
12840 DeductionInfo(nullptr) {}
12841
12842 /// Determines whether this template is an actual instantiation
12843 /// that should be counted toward the maximum instantiation depth.
12844 bool isInstantiationRecord() const;
12845 };
12846
12847 /// A stack object to be created when performing template
12848 /// instantiation.
12849 ///
12850 /// Construction of an object of type \c InstantiatingTemplate
12851 /// pushes the current instantiation onto the stack of active
12852 /// instantiations. If the size of this stack exceeds the maximum
12853 /// number of recursive template instantiations, construction
12854 /// produces an error and evaluates true.
12855 ///
12856 /// Destruction of this object will pop the named instantiation off
12857 /// the stack.
12859 /// Note that we are instantiating a class template,
12860 /// function template, variable template, alias template,
12861 /// or a member thereof.
12862 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12863 Decl *Entity,
12864 SourceRange InstantiationRange = SourceRange());
12865
12867 /// Note that we are instantiating an exception specification
12868 /// of a function template.
12869 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12871 SourceRange InstantiationRange = SourceRange());
12872
12873 /// Note that we are instantiating a type alias template declaration.
12874 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12875 TypeAliasTemplateDecl *Entity,
12876 ArrayRef<TemplateArgument> TemplateArgs,
12877 SourceRange InstantiationRange = SourceRange());
12878
12879 /// Note that we are instantiating a default argument in a
12880 /// template-id.
12881 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12882 TemplateParameter Param, TemplateDecl *Template,
12883 ArrayRef<TemplateArgument> TemplateArgs,
12884 SourceRange InstantiationRange = SourceRange());
12885
12886 /// Note that we are substituting either explicitly-specified or
12887 /// deduced template arguments during function template argument deduction.
12888 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12889 FunctionTemplateDecl *FunctionTemplate,
12890 ArrayRef<TemplateArgument> TemplateArgs,
12892 sema::TemplateDeductionInfo &DeductionInfo,
12893 SourceRange InstantiationRange = SourceRange());
12894
12895 /// Note that we are instantiating as part of template
12896 /// argument deduction for a class template declaration.
12897 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12898 TemplateDecl *Template,
12899 ArrayRef<TemplateArgument> TemplateArgs,
12900 sema::TemplateDeductionInfo &DeductionInfo,
12901 SourceRange InstantiationRange = SourceRange());
12902
12903 /// Note that we are instantiating as part of template
12904 /// argument deduction for a class template partial
12905 /// specialization.
12906 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12908 ArrayRef<TemplateArgument> TemplateArgs,
12909 sema::TemplateDeductionInfo &DeductionInfo,
12910 SourceRange InstantiationRange = SourceRange());
12911
12912 /// Note that we are instantiating as part of template
12913 /// argument deduction for a variable template partial
12914 /// specialization.
12915 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12917 ArrayRef<TemplateArgument> TemplateArgs,
12918 sema::TemplateDeductionInfo &DeductionInfo,
12919 SourceRange InstantiationRange = SourceRange());
12920
12921 /// Note that we are instantiating a default argument for a function
12922 /// parameter.
12923 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12924 ParmVarDecl *Param,
12925 ArrayRef<TemplateArgument> TemplateArgs,
12926 SourceRange InstantiationRange = SourceRange());
12927
12928 /// Note that we are substituting prior template arguments into a
12929 /// non-type parameter.
12930 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12931 NamedDecl *Template, NonTypeTemplateParmDecl *Param,
12932 ArrayRef<TemplateArgument> TemplateArgs,
12933 SourceRange InstantiationRange);
12934
12935 /// Note that we are substituting prior template arguments into a
12936 /// template template parameter.
12937 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12938 NamedDecl *Template, TemplateTemplateParmDecl *Param,
12939 ArrayRef<TemplateArgument> TemplateArgs,
12940 SourceRange InstantiationRange);
12941
12942 /// Note that we are checking the default template argument
12943 /// against the template parameter for a given template-id.
12944 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12945 TemplateDecl *Template, NamedDecl *Param,
12946 ArrayRef<TemplateArgument> TemplateArgs,
12947 SourceRange InstantiationRange);
12948
12950 /// \brief Note that we are checking the constraints associated with some
12951 /// constrained entity (a concept declaration or a template with associated
12952 /// constraints).
12953 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12954 ConstraintsCheck, NamedDecl *Template,
12955 ArrayRef<TemplateArgument> TemplateArgs,
12956 SourceRange InstantiationRange);
12957
12959 /// \brief Note that we are checking a constraint expression associated
12960 /// with a template declaration or as part of the satisfaction check of a
12961 /// concept.
12962 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12964 sema::TemplateDeductionInfo &DeductionInfo,
12965 SourceRange InstantiationRange);
12966
12968 /// \brief Note that we are normalizing a constraint expression.
12969 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12971 SourceRange InstantiationRange);
12972
12974 /// \brief Note that we are subtituting into the parameter mapping of an
12975 /// atomic constraint during constraint normalization.
12976 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12978 SourceRange InstantiationRange);
12979
12980 /// \brief Note that we are substituting template arguments into a part of
12981 /// a requirement of a requires expression.
12982 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12984 sema::TemplateDeductionInfo &DeductionInfo,
12985 SourceRange InstantiationRange = SourceRange());
12986
12987 /// \brief Note that we are checking the satisfaction of the constraint
12988 /// expression inside of a nested requirement.
12989 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12991 SourceRange InstantiationRange = SourceRange());
12992
12993 /// \brief Note that we are checking a requires clause.
12994 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
12995 const RequiresExpr *E,
12996 sema::TemplateDeductionInfo &DeductionInfo,
12997 SourceRange InstantiationRange);
12998
13000 /// \brief Note that we are building deduction guides.
13001 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
13003 SourceRange InstantiationRange = SourceRange());
13004
13006 /// \brief Note that we are partial ordering template template parameters.
13007 InstantiatingTemplate(Sema &SemaRef, SourceLocation ArgLoc,
13009 SourceRange InstantiationRange = SourceRange());
13010
13011 /// Note that we have finished instantiating this template.
13012 void Clear();
13013
13015
13016 /// Determines whether we have exceeded the maximum
13017 /// recursive template instantiations.
13018 bool isInvalid() const { return Invalid; }
13019
13020 /// Determine whether we are already instantiating this
13021 /// specialization in some surrounding active instantiation.
13022 bool isAlreadyInstantiating() const { return AlreadyInstantiating; }
13023
13024 private:
13025 Sema &SemaRef;
13026 bool Invalid;
13027 bool AlreadyInstantiating;
13028 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
13029 SourceRange InstantiationRange);
13030
13031 InstantiatingTemplate(Sema &SemaRef,
13033 SourceLocation PointOfInstantiation,
13034 SourceRange InstantiationRange, Decl *Entity,
13035 NamedDecl *Template = nullptr,
13036 ArrayRef<TemplateArgument> TemplateArgs = {},
13037 sema::TemplateDeductionInfo *DeductionInfo = nullptr);
13038
13039 InstantiatingTemplate(const InstantiatingTemplate &) = delete;
13040
13041 InstantiatingTemplate &operator=(const InstantiatingTemplate &) = delete;
13042 };
13043
13044 bool SubstTemplateArgument(const TemplateArgumentLoc &Input,
13045 const MultiLevelTemplateArgumentList &TemplateArgs,
13046 TemplateArgumentLoc &Output,
13047 SourceLocation Loc = {},
13048 const DeclarationName &Entity = {});
13049 bool
13050 SubstTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
13051 const MultiLevelTemplateArgumentList &TemplateArgs,
13052 TemplateArgumentListInfo &Outputs);
13053
13054 /// Retrieve the template argument list(s) that should be used to
13055 /// instantiate the definition of the given declaration.
13056 ///
13057 /// \param ND the declaration for which we are computing template
13058 /// instantiation arguments.
13059 ///
13060 /// \param DC In the event we don't HAVE a declaration yet, we instead provide
13061 /// the decl context where it will be created. In this case, the `Innermost`
13062 /// should likely be provided. If ND is non-null, this is ignored.
13063 ///
13064 /// \param Innermost if non-NULL, specifies a template argument list for the
13065 /// template declaration passed as ND.
13066 ///
13067 /// \param RelativeToPrimary true if we should get the template
13068 /// arguments relative to the primary template, even when we're
13069 /// dealing with a specialization. This is only relevant for function
13070 /// template specializations.
13071 ///
13072 /// \param Pattern If non-NULL, indicates the pattern from which we will be
13073 /// instantiating the definition of the given declaration, \p ND. This is
13074 /// used to determine the proper set of template instantiation arguments for
13075 /// friend function template specializations.
13076 ///
13077 /// \param ForConstraintInstantiation when collecting arguments,
13078 /// ForConstraintInstantiation indicates we should continue looking when
13079 /// encountering a lambda generic call operator, and continue looking for
13080 /// arguments on an enclosing class template.
13081 ///
13082 /// \param SkipForSpecialization when specified, any template specializations
13083 /// in a traversal would be ignored.
13084 /// \param ForDefaultArgumentSubstitution indicates we should continue looking
13085 /// when encountering a specialized member function template, rather than
13086 /// returning immediately.
13087 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
13088 const NamedDecl *D, const DeclContext *DC = nullptr, bool Final = false,
13089 std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13090 bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13091 bool ForConstraintInstantiation = false,
13092 bool SkipForSpecialization = false,
13093 bool ForDefaultArgumentSubstitution = false);
13094
13095 /// RAII object to handle the state changes required to synthesize
13096 /// a function body.
13098 Sema &S;
13099 Sema::ContextRAII SavedContext;
13100 bool PushedCodeSynthesisContext = false;
13101
13102 public:
13104 : S(S), SavedContext(S, DC) {
13105 auto *FD = dyn_cast<FunctionDecl>(DC);
13106 S.PushFunctionScope();
13107 S.PushExpressionEvaluationContext(
13108 (FD && FD->isImmediateFunction())
13109 ? ExpressionEvaluationContext::ImmediateFunctionContext
13110 : ExpressionEvaluationContext::PotentiallyEvaluated);
13111 if (FD) {
13112 auto &Current = S.currentEvaluationContext();
13113 const auto &Parent = S.parentEvaluationContext();
13114
13115 FD->setWillHaveBody(true);
13116 Current.InImmediateFunctionContext =
13117 FD->isImmediateFunction() ||
13118 (isLambdaMethod(FD) && (Parent.isConstantEvaluated() ||
13119 Parent.isImmediateFunctionContext()));
13120
13121 Current.InImmediateEscalatingFunctionContext =
13122 S.getLangOpts().CPlusPlus20 && FD->isImmediateEscalating();
13123 } else
13124 assert(isa<ObjCMethodDecl>(DC));
13125 }
13126
13128 assert(!PushedCodeSynthesisContext);
13129
13131 Ctx.Kind = Sema::CodeSynthesisContext::DefiningSynthesizedFunction;
13132 Ctx.PointOfInstantiation = UseLoc;
13133 Ctx.Entity = cast<Decl>(S.CurContext);
13134 S.pushCodeSynthesisContext(Ctx);
13135
13136 PushedCodeSynthesisContext = true;
13137 }
13138
13140 if (PushedCodeSynthesisContext)
13141 S.popCodeSynthesisContext();
13142 if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
13143 FD->setWillHaveBody(false);
13144 S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction());
13145 }
13146 S.PopExpressionEvaluationContext();
13147 S.PopFunctionScopeInfo();
13148 }
13149 };
13150
13151 /// List of active code synthesis contexts.
13152 ///
13153 /// This vector is treated as a stack. As synthesis of one entity requires
13154 /// synthesis of another, additional contexts are pushed onto the stack.
13156
13157 /// Specializations whose definitions are currently being instantiated.
13158 llvm::DenseSet<std::pair<Decl *, unsigned>> InstantiatingSpecializations;
13159
13160 /// Non-dependent types used in templates that have already been instantiated
13161 /// by some template instantiation.
13162 llvm::DenseSet<QualType> InstantiatedNonDependentTypes;
13163
13164 /// Extra modules inspected when performing a lookup during a template
13165 /// instantiation. Computed lazily.
13167
13168 /// Cache of additional modules that should be used for name lookup
13169 /// within the current template instantiation. Computed lazily; use
13170 /// getLookupModules() to get a complete set.
13171 llvm::DenseSet<Module *> LookupModulesCache;
13172
13173 /// Map from the most recent declaration of a namespace to the most
13174 /// recent visible declaration of that namespace.
13175 llvm::DenseMap<NamedDecl *, NamedDecl *> VisibleNamespaceCache;
13176
13177 /// Whether we are in a SFINAE context that is not associated with
13178 /// template instantiation.
13179 ///
13180 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
13181 /// of a template instantiation or template argument deduction.
13183
13184 /// The number of \p CodeSynthesisContexts that are not template
13185 /// instantiations and, therefore, should not be counted as part of the
13186 /// instantiation depth.
13187 ///
13188 /// When the instantiation depth reaches the user-configurable limit
13189 /// \p LangOptions::InstantiationDepth we will abort instantiation.
13190 // FIXME: Should we have a similar limit for other forms of synthesis?
13192
13193 /// The depth of the context stack at the point when the most recent
13194 /// error or warning was produced.
13195 ///
13196 /// This value is used to suppress printing of redundant context stacks
13197 /// when there are multiple errors or warnings in the same instantiation.
13198 // FIXME: Does this belong in Sema? It's tough to implement it anywhere else.
13200
13201 /// The template instantiation callbacks to trace or track
13202 /// instantiations (objects can be chained).
13203 ///
13204 /// This callbacks is used to print, trace or track template
13205 /// instantiations as they are being constructed.
13206 std::vector<std::unique_ptr<TemplateInstantiationCallback>>
13208
13209 /// The current index into pack expansion arguments that will be
13210 /// used for substitution of parameter packs.
13211 ///
13212 /// The pack expansion index will be -1 to indicate that parameter packs
13213 /// should be instantiated as themselves. Otherwise, the index specifies
13214 /// which argument within the parameter pack will be used for substitution.
13216
13217 /// RAII object used to change the argument pack substitution index
13218 /// within a \c Sema object.
13219 ///
13220 /// See \c ArgumentPackSubstitutionIndex for more information.
13222 Sema &Self;
13223 int OldSubstitutionIndex;
13224
13225 public:
13226 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
13227 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
13228 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
13229 }
13230
13232 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
13233 }
13234 };
13235
13237
13240
13242 if (!CodeSynthesisContexts.empty() &&
13246 }
13249 }
13250 /// Prints the current instantiation stack through a series of
13251 /// notes.
13253
13254 /// Determines whether we are currently in a context where
13255 /// template argument substitution failures are not considered
13256 /// errors.
13257 ///
13258 /// \returns An empty \c Optional if we're not in a SFINAE context.
13259 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
13260 /// template-deduction context object, which can be used to capture
13261 /// diagnostics that will be suppressed.
13262 std::optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
13263
13264 /// Perform substitution on the type T with a given set of template
13265 /// arguments.
13266 ///
13267 /// This routine substitutes the given template arguments into the
13268 /// type T and produces the instantiated type.
13269 ///
13270 /// \param T the type into which the template arguments will be
13271 /// substituted. If this type is not dependent, it will be returned
13272 /// immediately.
13273 ///
13274 /// \param Args the template arguments that will be
13275 /// substituted for the top-level template parameters within T.
13276 ///
13277 /// \param Loc the location in the source code where this substitution
13278 /// is being performed. It will typically be the location of the
13279 /// declarator (if we're instantiating the type of some declaration)
13280 /// or the location of the type in the source code (if, e.g., we're
13281 /// instantiating the type of a cast expression).
13282 ///
13283 /// \param Entity the name of the entity associated with a declaration
13284 /// being instantiated (if any). May be empty to indicate that there
13285 /// is no such entity (if, e.g., this is a type that occurs as part of
13286 /// a cast expression) or that the entity has no name (e.g., an
13287 /// unnamed function parameter).
13288 ///
13289 /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
13290 /// acceptable as the top level type of the result.
13291 ///
13292 /// \param IsIncompleteSubstitution If provided, the pointee will be set
13293 /// whenever substitution would perform a replacement with a null or
13294 /// non-existent template argument.
13295 ///
13296 /// \returns If the instantiation succeeds, the instantiated
13297 /// type. Otherwise, produces diagnostics and returns a NULL type.
13299 const MultiLevelTemplateArgumentList &TemplateArgs,
13301 bool AllowDeducedTST = false);
13302
13304 const MultiLevelTemplateArgumentList &TemplateArgs,
13306 bool *IsIncompleteSubstitution = nullptr);
13307
13309 const MultiLevelTemplateArgumentList &TemplateArgs,
13311
13312 /// A form of SubstType intended specifically for instantiating the
13313 /// type of a FunctionDecl. Its purpose is solely to force the
13314 /// instantiation of default-argument expressions and to avoid
13315 /// instantiating an exception-specification.
13317 TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
13318 SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
13319 Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
13320 void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
13321 const MultiLevelTemplateArgumentList &Args);
13324 SmallVectorImpl<QualType> &ExceptionStorage,
13325 const MultiLevelTemplateArgumentList &Args);
13326 ParmVarDecl *
13328 const MultiLevelTemplateArgumentList &TemplateArgs,
13329 int indexAdjustment, std::optional<unsigned> NumExpansions,
13330 bool ExpectParameterPack, bool EvaluateConstraints = true);
13331
13332 /// Substitute the given template arguments into the given set of
13333 /// parameters, producing the set of parameter types that would be generated
13334 /// from such a substitution.
13336 const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
13337 const MultiLevelTemplateArgumentList &TemplateArgs,
13338 SmallVectorImpl<QualType> &ParamTypes,
13340 ExtParameterInfoBuilder &ParamInfos);
13341
13342 /// Substitute the given template arguments into the default argument.
13344 const MultiLevelTemplateArgumentList &TemplateArgs,
13345 bool ForCallExpr = false);
13347 const MultiLevelTemplateArgumentList &TemplateArgs);
13348
13349 // A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
13350 // to disable constraint evaluation, then restore the state.
13351 template <typename InstTy> struct ConstraintEvalRAII {
13352 InstTy &TI;
13354
13356 : TI(TI), OldValue(TI.getEvaluateConstraints()) {
13357 TI.setEvaluateConstraints(false);
13358 }
13359 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
13360 };
13361
13362 // Must be used instead of SubstExpr at 'constraint checking' time.
13365 const MultiLevelTemplateArgumentList &TemplateArgs);
13366 // Unlike the above, this does not evaluates constraints.
13368 Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
13369
13370 /// Substitute the given template arguments into a list of
13371 /// expressions, expanding pack expansions if required.
13372 ///
13373 /// \param Exprs The list of expressions to substitute into.
13374 ///
13375 /// \param IsCall Whether this is some form of call, in which case
13376 /// default arguments will be dropped.
13377 ///
13378 /// \param TemplateArgs The set of template arguments to substitute.
13379 ///
13380 /// \param Outputs Will receive all of the substituted arguments.
13381 ///
13382 /// \returns true if an error occurred, false otherwise.
13383 bool SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
13384 const MultiLevelTemplateArgumentList &TemplateArgs,
13385 SmallVectorImpl<Expr *> &Outputs);
13386
13388 const MultiLevelTemplateArgumentList &TemplateArgs);
13389
13392 bool CXXDirectInit);
13393
13394 /// Perform substitution on the base class specifiers of the
13395 /// given class template specialization.
13396 ///
13397 /// Produces a diagnostic and returns true on error, returns false and
13398 /// attaches the instantiated base classes to the class template
13399 /// specialization if successful.
13400 bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13401 const MultiLevelTemplateArgumentList &TemplateArgs);
13402
13403 /// Instantiate the definition of a class from a given pattern.
13404 ///
13405 /// \param PointOfInstantiation The point of instantiation within the
13406 /// source code.
13407 ///
13408 /// \param Instantiation is the declaration whose definition is being
13409 /// instantiated. This will be either a class template specialization
13410 /// or a member class of a class template specialization.
13411 ///
13412 /// \param Pattern is the pattern from which the instantiation
13413 /// occurs. This will be either the declaration of a class template or
13414 /// the declaration of a member class of a class template.
13415 ///
13416 /// \param TemplateArgs The template arguments to be substituted into
13417 /// the pattern.
13418 ///
13419 /// \param TSK the kind of implicit or explicit instantiation to perform.
13420 ///
13421 /// \param Complain whether to complain if the class cannot be instantiated
13422 /// due to the lack of a definition.
13423 ///
13424 /// \returns true if an error occurred, false otherwise.
13425 bool InstantiateClass(SourceLocation PointOfInstantiation,
13426 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
13427 const MultiLevelTemplateArgumentList &TemplateArgs,
13428 TemplateSpecializationKind TSK, bool Complain = true);
13429
13430 /// Instantiate the definition of an enum from a given pattern.
13431 ///
13432 /// \param PointOfInstantiation The point of instantiation within the
13433 /// source code.
13434 /// \param Instantiation is the declaration whose definition is being
13435 /// instantiated. This will be a member enumeration of a class
13436 /// temploid specialization, or a local enumeration within a
13437 /// function temploid specialization.
13438 /// \param Pattern The templated declaration from which the instantiation
13439 /// occurs.
13440 /// \param TemplateArgs The template arguments to be substituted into
13441 /// the pattern.
13442 /// \param TSK The kind of implicit or explicit instantiation to perform.
13443 ///
13444 /// \return \c true if an error occurred, \c false otherwise.
13445 bool InstantiateEnum(SourceLocation PointOfInstantiation,
13446 EnumDecl *Instantiation, EnumDecl *Pattern,
13447 const MultiLevelTemplateArgumentList &TemplateArgs,
13449
13450 /// Instantiate the definition of a field from the given pattern.
13451 ///
13452 /// \param PointOfInstantiation The point of instantiation within the
13453 /// source code.
13454 /// \param Instantiation is the declaration whose definition is being
13455 /// instantiated. This will be a class of a class temploid
13456 /// specialization, or a local enumeration within a function temploid
13457 /// specialization.
13458 /// \param Pattern The templated declaration from which the instantiation
13459 /// occurs.
13460 /// \param TemplateArgs The template arguments to be substituted into
13461 /// the pattern.
13462 ///
13463 /// \return \c true if an error occurred, \c false otherwise.
13465 SourceLocation PointOfInstantiation, FieldDecl *Instantiation,
13466 FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs);
13467
13470
13472 SourceLocation PointOfInstantiation,
13473 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13474 TemplateSpecializationKind TSK, bool Complain = true,
13475 bool PrimaryHasMatchedPackOnParmToNonPackOnArg = false);
13476
13477 /// Instantiates the definitions of all of the member
13478 /// of the given class, which is an instantiation of a class template
13479 /// or a member class of a template.
13480 void
13481 InstantiateClassMembers(SourceLocation PointOfInstantiation,
13482 CXXRecordDecl *Instantiation,
13483 const MultiLevelTemplateArgumentList &TemplateArgs,
13485
13486 /// Instantiate the definitions of all of the members of the
13487 /// given class template specialization, which was named as part of an
13488 /// explicit instantiation.
13490 SourceLocation PointOfInstantiation,
13491 ClassTemplateSpecializationDecl *ClassTemplateSpec,
13493
13496 const MultiLevelTemplateArgumentList &TemplateArgs);
13497
13498 /// Do template substitution on declaration name info.
13501 const MultiLevelTemplateArgumentList &TemplateArgs);
13505 const MultiLevelTemplateArgumentList &TemplateArgs);
13506
13508 const MultiLevelTemplateArgumentList &TemplateArgs,
13509 bool EvaluateConstraint);
13510
13511 /// Determine whether we are currently performing template instantiation.
13514 }
13515
13516 using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
13517
13518 /// \brief create a Requirement::SubstitutionDiagnostic with only a
13519 /// SubstitutedEntity and DiagLoc using ASTContext's allocator.
13522
13523 ///@}
13524
13525 //
13526 //
13527 // -------------------------------------------------------------------------
13528 //
13529 //
13530
13531 /// \name C++ Template Declaration Instantiation
13532 /// Implementations are in SemaTemplateInstantiateDecl.cpp
13533 ///@{
13534
13535public:
13536 /// An entity for which implicit template instantiation is required.
13537 ///
13538 /// The source location associated with the declaration is the first place in
13539 /// the source code where the declaration was "used". It is not necessarily
13540 /// the point of instantiation (which will be either before or after the
13541 /// namespace-scope declaration that triggered this implicit instantiation),
13542 /// However, it is the location that diagnostics should generally refer to,
13543 /// because users will need to know what code triggered the instantiation.
13544 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
13545
13546 /// The queue of implicit template instantiations that are required
13547 /// but have not yet been performed.
13548 std::deque<PendingImplicitInstantiation> PendingInstantiations;
13549
13550 /// Queue of implicit template instantiations that cannot be performed
13551 /// eagerly.
13553
13557
13558 /// The queue of implicit template instantiations that are required
13559 /// and must be performed within the current local scope.
13560 ///
13561 /// This queue is only used for member functions of local classes in
13562 /// templates, which must be instantiated in the same scope as their
13563 /// enclosing function, so that they can reference function-local
13564 /// types, static variables, enumerators, etc.
13565 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
13566
13568 public:
13570 SavedPendingLocalImplicitInstantiations.swap(
13571 S.PendingLocalImplicitInstantiations);
13572 }
13573
13574 void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
13575
13577 assert(S.PendingLocalImplicitInstantiations.empty() &&
13578 "there shouldn't be any pending local implicit instantiations");
13579 SavedPendingLocalImplicitInstantiations.swap(
13580 S.PendingLocalImplicitInstantiations);
13581 }
13582
13583 private:
13584 Sema &S;
13585 std::deque<PendingImplicitInstantiation>
13586 SavedPendingLocalImplicitInstantiations;
13587 };
13588
13589 /// Records and restores the CurFPFeatures state on entry/exit of compound
13590 /// statements.
13592 public:
13595 FPOptionsOverride getOverrides() { return OldOverrides; }
13596
13597 private:
13598 Sema &S;
13599 FPOptions OldFPFeaturesState;
13600 FPOptionsOverride OldOverrides;
13601 LangOptions::FPEvalMethodKind OldEvalMethod;
13602 SourceLocation OldFPPragmaLocation;
13603 };
13604
13606 public:
13608 : S(S), Enabled(Enabled) {
13609 if (!Enabled)
13610 return;
13611
13612 S.SavedPendingInstantiations.emplace_back();
13613 S.SavedPendingInstantiations.back().swap(S.PendingInstantiations);
13614
13615 S.SavedVTableUses.emplace_back();
13616 S.SavedVTableUses.back().swap(S.VTableUses);
13617 }
13618
13619 void perform() {
13620 if (Enabled) {
13621 S.DefineUsedVTables();
13622 S.PerformPendingInstantiations();
13623 }
13624 }
13625
13627 if (!Enabled)
13628 return;
13629
13630 // Restore the set of pending vtables.
13631 assert(S.VTableUses.empty() &&
13632 "VTableUses should be empty before it is discarded.");
13633 S.VTableUses.swap(S.SavedVTableUses.back());
13634 S.SavedVTableUses.pop_back();
13635
13636 // Restore the set of pending implicit instantiations.
13637 if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
13638 assert(S.PendingInstantiations.empty() &&
13639 "PendingInstantiations should be empty before it is discarded.");
13640 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13641 S.SavedPendingInstantiations.pop_back();
13642 } else {
13643 // Template instantiations in the PCH may be delayed until the TU.
13644 S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
13645 S.PendingInstantiations.insert(
13646 S.PendingInstantiations.end(),
13647 S.SavedPendingInstantiations.back().begin(),
13648 S.SavedPendingInstantiations.back().end());
13649 S.SavedPendingInstantiations.pop_back();
13650 }
13651 }
13652
13653 private:
13654 Sema &S;
13655 bool Enabled;
13656 };
13657
13659 const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
13660
13665
13667 Decl *D)
13668 : TmplAttr(A), Scope(S), NewDecl(D) {}
13669 };
13671
13672 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
13673 const Decl *Pattern, Decl *Inst,
13674 LateInstantiatedAttrVec *LateAttrs = nullptr,
13675 LocalInstantiationScope *OuterMostScope = nullptr);
13676
13677 /// Update instantiation attributes after template was late parsed.
13678 ///
13679 /// Some attributes are evaluated based on the body of template. If it is
13680 /// late parsed, such attributes cannot be evaluated when declaration is
13681 /// instantiated. This function is used to update instantiation attributes
13682 /// when template definition is ready.
13683 void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst);
13684
13685 void
13687 const Decl *Pattern, Decl *Inst,
13688 LateInstantiatedAttrVec *LateAttrs = nullptr,
13689 LocalInstantiationScope *OuterMostScope = nullptr);
13690
13691 /// In the MS ABI, we need to instantiate default arguments of dllexported
13692 /// default constructors along with the constructor definition. This allows IR
13693 /// gen to emit a constructor closure which calls the default constructor with
13694 /// its default arguments.
13696
13698 ParmVarDecl *Param);
13699 void InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
13701
13702 /// Instantiate (or find existing instantiation of) a function template with a
13703 /// given set of template arguments.
13704 ///
13705 /// Usually this should not be used, and template argument deduction should be
13706 /// used in its place.
13712
13713 /// Instantiate the definition of the given function from its
13714 /// template.
13715 ///
13716 /// \param PointOfInstantiation the point at which the instantiation was
13717 /// required. Note that this is not precisely a "point of instantiation"
13718 /// for the function, but it's close.
13719 ///
13720 /// \param Function the already-instantiated declaration of a
13721 /// function template specialization or member function of a class template
13722 /// specialization.
13723 ///
13724 /// \param Recursive if true, recursively instantiates any functions that
13725 /// are required by this instantiation.
13726 ///
13727 /// \param DefinitionRequired if true, then we are performing an explicit
13728 /// instantiation where the body of the function is required. Complain if
13729 /// there is no such body.
13730 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
13732 bool Recursive = false,
13733 bool DefinitionRequired = false,
13734 bool AtEndOfTU = false);
13737 const TemplateArgumentList *PartialSpecArgs,
13738 const TemplateArgumentListInfo &TemplateArgsInfo,
13740 SourceLocation PointOfInstantiation,
13741 LateInstantiatedAttrVec *LateAttrs = nullptr,
13742 LocalInstantiationScope *StartingScope = nullptr);
13743
13744 /// Instantiates a variable template specialization by completing it
13745 /// with appropriate type information and initializer.
13747 VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl,
13748 const MultiLevelTemplateArgumentList &TemplateArgs);
13749
13750 /// BuildVariableInstantiation - Used after a new variable has been created.
13751 /// Sets basic variable data and decides whether to postpone the
13752 /// variable instantiation.
13753 void
13755 const MultiLevelTemplateArgumentList &TemplateArgs,
13756 LateInstantiatedAttrVec *LateAttrs,
13757 DeclContext *Owner,
13758 LocalInstantiationScope *StartingScope,
13759 bool InstantiatingVarTemplate = false,
13760 VarTemplateSpecializationDecl *PrevVTSD = nullptr);
13761
13762 /// Instantiate the initializer of a variable.
13764 VarDecl *Var, VarDecl *OldVar,
13765 const MultiLevelTemplateArgumentList &TemplateArgs);
13766
13767 /// Instantiate the definition of the given variable from its
13768 /// template.
13769 ///
13770 /// \param PointOfInstantiation the point at which the instantiation was
13771 /// required. Note that this is not precisely a "point of instantiation"
13772 /// for the variable, but it's close.
13773 ///
13774 /// \param Var the already-instantiated declaration of a templated variable.
13775 ///
13776 /// \param Recursive if true, recursively instantiates any functions that
13777 /// are required by this instantiation.
13778 ///
13779 /// \param DefinitionRequired if true, then we are performing an explicit
13780 /// instantiation where a definition of the variable is required. Complain
13781 /// if there is no such definition.
13782 void InstantiateVariableDefinition(SourceLocation PointOfInstantiation,
13783 VarDecl *Var, bool Recursive = false,
13784 bool DefinitionRequired = false,
13785 bool AtEndOfTU = false);
13786
13788 CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl,
13789 const MultiLevelTemplateArgumentList &TemplateArgs);
13790
13791 /// Find the instantiation of the given declaration within the
13792 /// current instantiation.
13793 ///
13794 /// This routine is intended to be used when \p D is a declaration
13795 /// referenced from within a template, that needs to mapped into the
13796 /// corresponding declaration within an instantiation. For example,
13797 /// given:
13798 ///
13799 /// \code
13800 /// template<typename T>
13801 /// struct X {
13802 /// enum Kind {
13803 /// KnownValue = sizeof(T)
13804 /// };
13805 ///
13806 /// bool getKind() const { return KnownValue; }
13807 /// };
13808 ///
13809 /// template struct X<int>;
13810 /// \endcode
13811 ///
13812 /// In the instantiation of X<int>::getKind(), we need to map the \p
13813 /// EnumConstantDecl for \p KnownValue (which refers to
13814 /// X<T>::<Kind>::KnownValue) to its instantiation
13815 /// (X<int>::<Kind>::KnownValue).
13816 /// \p FindInstantiatedDecl performs this mapping from within the
13817 /// instantiation of X<int>.
13818 NamedDecl *
13820 const MultiLevelTemplateArgumentList &TemplateArgs,
13821 bool FindingInstantiatedContext = false);
13822
13823 /// Finds the instantiation of the given declaration context
13824 /// within the current instantiation.
13825 ///
13826 /// \returns NULL if there was an error
13827 DeclContext *
13829 const MultiLevelTemplateArgumentList &TemplateArgs);
13830
13831 Decl *SubstDecl(Decl *D, DeclContext *Owner,
13832 const MultiLevelTemplateArgumentList &TemplateArgs);
13833
13834 /// Substitute the name and return type of a defaulted 'operator<=>' to form
13835 /// an implicit 'operator=='.
13837 FunctionDecl *Spaceship);
13838
13839 /// Performs template instantiation for all implicit template
13840 /// instantiations we have seen until this point.
13841 void PerformPendingInstantiations(bool LocalOnly = false);
13842
13845 const MultiLevelTemplateArgumentList &TemplateArgs,
13846 bool EvaluateConstraints = true);
13847
13849 const DeclContext *Pattern,
13850 const MultiLevelTemplateArgumentList &TemplateArgs);
13851
13852private:
13853 /// Introduce the instantiated local variables into the local
13854 /// instantiation scope.
13855 void addInstantiatedLocalVarsToScope(FunctionDecl *Function,
13856 const FunctionDecl *PatternDecl,
13858 /// Introduce the instantiated function parameters into the local
13859 /// instantiation scope, and set the parameter names to those used
13860 /// in the template.
13861 bool addInstantiatedParametersToScope(
13862 FunctionDecl *Function, const FunctionDecl *PatternDecl,
13864 const MultiLevelTemplateArgumentList &TemplateArgs);
13865
13866 /// Introduce the instantiated captures of the lambda into the local
13867 /// instantiation scope.
13868 bool addInstantiatedCapturesToScope(
13869 FunctionDecl *Function, const FunctionDecl *PatternDecl,
13871 const MultiLevelTemplateArgumentList &TemplateArgs);
13872
13873 int ParsingClassDepth = 0;
13874
13875 class SavePendingParsedClassStateRAII {
13876 public:
13877 SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
13878
13879 ~SavePendingParsedClassStateRAII() {
13880 assert(S.DelayedOverridingExceptionSpecChecks.empty() &&
13881 "there shouldn't be any pending delayed exception spec checks");
13882 assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
13883 "there shouldn't be any pending delayed exception spec checks");
13884 swapSavedState();
13885 }
13886
13887 private:
13888 Sema &S;
13889 decltype(DelayedOverridingExceptionSpecChecks)
13890 SavedOverridingExceptionSpecChecks;
13891 decltype(DelayedEquivalentExceptionSpecChecks)
13892 SavedEquivalentExceptionSpecChecks;
13893
13894 void swapSavedState() {
13895 SavedOverridingExceptionSpecChecks.swap(
13896 S.DelayedOverridingExceptionSpecChecks);
13897 SavedEquivalentExceptionSpecChecks.swap(
13898 S.DelayedEquivalentExceptionSpecChecks);
13899 }
13900 };
13901
13902 ///@}
13903
13904 //
13905 //
13906 // -------------------------------------------------------------------------
13907 //
13908 //
13909
13910 /// \name C++ Variadic Templates
13911 /// Implementations are in SemaTemplateVariadic.cpp
13912 ///@{
13913
13914public:
13915 /// Determine whether an unexpanded parameter pack might be permitted in this
13916 /// location. Useful for error recovery.
13918
13919 /// The context in which an unexpanded parameter pack is
13920 /// being diagnosed.
13921 ///
13922 /// Note that the values of this enumeration line up with the first
13923 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
13925 /// An arbitrary expression.
13927
13928 /// The base type of a class type.
13930
13931 /// The type of an arbitrary declaration.
13933
13934 /// The type of a data member.
13936
13937 /// The size of a bit-field.
13939
13940 /// The expression in a static assertion.
13942
13943 /// The fixed underlying type of an enumeration.
13945
13946 /// The enumerator value.
13948
13949 /// A using declaration.
13951
13952 /// A friend declaration.
13954
13955 /// A declaration qualifier.
13957
13958 /// An initializer.
13960
13961 /// A default argument.
13963
13964 /// The type of a non-type template parameter.
13966
13967 /// The type of an exception.
13969
13970 /// Explicit specialization.
13972
13973 /// Partial specialization.
13975
13976 /// Microsoft __if_exists.
13978
13979 /// Microsoft __if_not_exists.
13981
13982 /// Lambda expression.
13984
13985 /// Block expression.
13987
13988 /// A type constraint.
13990
13991 // A requirement in a requires-expression.
13993
13994 // A requires-clause.
13996 };
13997
13998 /// Diagnose unexpanded parameter packs.
13999 ///
14000 /// \param Loc The location at which we should emit the diagnostic.
14001 ///
14002 /// \param UPPC The context in which we are diagnosing unexpanded
14003 /// parameter packs.
14004 ///
14005 /// \param Unexpanded the set of unexpanded parameter packs.
14006 ///
14007 /// \returns true if an error occurred, false otherwise.
14011
14012 /// If the given type contains an unexpanded parameter pack,
14013 /// diagnose the error.
14014 ///
14015 /// \param Loc The source location where a diagnostc should be emitted.
14016 ///
14017 /// \param T The type that is being checked for unexpanded parameter
14018 /// packs.
14019 ///
14020 /// \returns true if an error occurred, false otherwise.
14023
14024 /// If the given expression contains an unexpanded parameter
14025 /// pack, diagnose the error.
14026 ///
14027 /// \param E The expression that is being checked for unexpanded
14028 /// parameter packs.
14029 ///
14030 /// \returns true if an error occurred, false otherwise.
14033
14034 /// If the given requirees-expression contains an unexpanded reference to one
14035 /// of its own parameter packs, diagnose the error.
14036 ///
14037 /// \param RE The requiress-expression that is being checked for unexpanded
14038 /// parameter packs.
14039 ///
14040 /// \returns true if an error occurred, false otherwise.
14042
14043 /// If the given nested-name-specifier contains an unexpanded
14044 /// parameter pack, diagnose the error.
14045 ///
14046 /// \param SS The nested-name-specifier that is being checked for
14047 /// unexpanded parameter packs.
14048 ///
14049 /// \returns true if an error occurred, false otherwise.
14052
14053 /// If the given name contains an unexpanded parameter pack,
14054 /// diagnose the error.
14055 ///
14056 /// \param NameInfo The name (with source location information) that
14057 /// is being checked for unexpanded parameter packs.
14058 ///
14059 /// \returns true if an error occurred, false otherwise.
14062
14063 /// If the given template name contains an unexpanded parameter pack,
14064 /// diagnose the error.
14065 ///
14066 /// \param Loc The location of the template name.
14067 ///
14068 /// \param Template The template name that is being checked for unexpanded
14069 /// parameter packs.
14070 ///
14071 /// \returns true if an error occurred, false otherwise.
14073 TemplateName Template,
14075
14076 /// If the given template argument contains an unexpanded parameter
14077 /// pack, diagnose the error.
14078 ///
14079 /// \param Arg The template argument that is being checked for unexpanded
14080 /// parameter packs.
14081 ///
14082 /// \returns true if an error occurred, false otherwise.
14085
14086 /// Collect the set of unexpanded parameter packs within the given
14087 /// template argument.
14088 ///
14089 /// \param Arg The template argument that will be traversed to find
14090 /// unexpanded parameter packs.
14092 TemplateArgument Arg,
14094
14095 /// Collect the set of unexpanded parameter packs within the given
14096 /// template argument.
14097 ///
14098 /// \param Arg The template argument that will be traversed to find
14099 /// unexpanded parameter packs.
14103
14104 /// Collect the set of unexpanded parameter packs within the given
14105 /// type.
14106 ///
14107 /// \param T The type that will be traversed to find
14108 /// unexpanded parameter packs.
14111
14112 /// Collect the set of unexpanded parameter packs within the given
14113 /// type.
14114 ///
14115 /// \param TL The type that will be traversed to find
14116 /// unexpanded parameter packs.
14119
14120 /// Collect the set of unexpanded parameter packs within the given
14121 /// nested-name-specifier.
14122 ///
14123 /// \param NNS The nested-name-specifier that will be traversed to find
14124 /// unexpanded parameter packs.
14128
14129 /// Collect the set of unexpanded parameter packs within the given
14130 /// name.
14131 ///
14132 /// \param NameInfo The name that will be traversed to find
14133 /// unexpanded parameter packs.
14135 const DeclarationNameInfo &NameInfo,
14137
14138 /// Collect the set of unexpanded parameter packs within the given
14139 /// expression.
14142
14143 /// Invoked when parsing a template argument followed by an
14144 /// ellipsis, which creates a pack expansion.
14145 ///
14146 /// \param Arg The template argument preceding the ellipsis, which
14147 /// may already be invalid.
14148 ///
14149 /// \param EllipsisLoc The location of the ellipsis.
14151 SourceLocation EllipsisLoc);
14152
14153 /// Invoked when parsing a type followed by an ellipsis, which
14154 /// creates a pack expansion.
14155 ///
14156 /// \param Type The type preceding the ellipsis, which will become
14157 /// the pattern of the pack expansion.
14158 ///
14159 /// \param EllipsisLoc The location of the ellipsis.
14161
14162 /// Construct a pack expansion type from the pattern of the pack
14163 /// expansion.
14165 SourceLocation EllipsisLoc,
14166 std::optional<unsigned> NumExpansions);
14167
14168 /// Construct a pack expansion type from the pattern of the pack
14169 /// expansion.
14170 QualType CheckPackExpansion(QualType Pattern, SourceRange PatternRange,
14171 SourceLocation EllipsisLoc,
14172 std::optional<unsigned> NumExpansions);
14173
14174 /// Invoked when parsing an expression followed by an ellipsis, which
14175 /// creates a pack expansion.
14176 ///
14177 /// \param Pattern The expression preceding the ellipsis, which will become
14178 /// the pattern of the pack expansion.
14179 ///
14180 /// \param EllipsisLoc The location of the ellipsis.
14181 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
14182
14183 /// Invoked when parsing an expression followed by an ellipsis, which
14184 /// creates a pack expansion.
14185 ///
14186 /// \param Pattern The expression preceding the ellipsis, which will become
14187 /// the pattern of the pack expansion.
14188 ///
14189 /// \param EllipsisLoc The location of the ellipsis.
14190 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
14191 std::optional<unsigned> NumExpansions);
14192
14193 /// Determine whether we could expand a pack expansion with the
14194 /// given set of parameter packs into separate arguments by repeatedly
14195 /// transforming the pattern.
14196 ///
14197 /// \param EllipsisLoc The location of the ellipsis that identifies the
14198 /// pack expansion.
14199 ///
14200 /// \param PatternRange The source range that covers the entire pattern of
14201 /// the pack expansion.
14202 ///
14203 /// \param Unexpanded The set of unexpanded parameter packs within the
14204 /// pattern.
14205 ///
14206 /// \param ShouldExpand Will be set to \c true if the transformer should
14207 /// expand the corresponding pack expansions into separate arguments. When
14208 /// set, \c NumExpansions must also be set.
14209 ///
14210 /// \param RetainExpansion Whether the caller should add an unexpanded
14211 /// pack expansion after all of the expanded arguments. This is used
14212 /// when extending explicitly-specified template argument packs per
14213 /// C++0x [temp.arg.explicit]p9.
14214 ///
14215 /// \param NumExpansions The number of separate arguments that will be in
14216 /// the expanded form of the corresponding pack expansion. This is both an
14217 /// input and an output parameter, which can be set by the caller if the
14218 /// number of expansions is known a priori (e.g., due to a prior substitution)
14219 /// and will be set by the callee when the number of expansions is known.
14220 /// The callee must set this value when \c ShouldExpand is \c true; it may
14221 /// set this value in other cases.
14222 ///
14223 /// \returns true if an error occurred (e.g., because the parameter packs
14224 /// are to be instantiated with arguments of different lengths), false
14225 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
14226 /// must be set.
14228 SourceLocation EllipsisLoc, SourceRange PatternRange,
14230 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
14231 bool &RetainExpansion, std::optional<unsigned> &NumExpansions);
14232
14233 /// Determine the number of arguments in the given pack expansion
14234 /// type.
14235 ///
14236 /// This routine assumes that the number of arguments in the expansion is
14237 /// consistent across all of the unexpanded parameter packs in its pattern.
14238 ///
14239 /// Returns an empty Optional if the type can't be expanded.
14240 std::optional<unsigned> getNumArgumentsInExpansion(
14241 QualType T, const MultiLevelTemplateArgumentList &TemplateArgs);
14242
14243 std::optional<unsigned> getNumArgumentsInExpansionFromUnexpanded(
14245 const MultiLevelTemplateArgumentList &TemplateArgs);
14246
14247 /// Determine whether the given declarator contains any unexpanded
14248 /// parameter packs.
14249 ///
14250 /// This routine is used by the parser to disambiguate function declarators
14251 /// with an ellipsis prior to the ')', e.g.,
14252 ///
14253 /// \code
14254 /// void f(T...);
14255 /// \endcode
14256 ///
14257 /// To determine whether we have an (unnamed) function parameter pack or
14258 /// a variadic function.
14259 ///
14260 /// \returns true if the declarator contains any unexpanded parameter packs,
14261 /// false otherwise.
14263
14264 /// Returns the pattern of the pack expansion for a template argument.
14265 ///
14266 /// \param OrigLoc The template argument to expand.
14267 ///
14268 /// \param Ellipsis Will be set to the location of the ellipsis.
14269 ///
14270 /// \param NumExpansions Will be set to the number of expansions that will
14271 /// be generated from this pack expansion, if known a priori.
14273 TemplateArgumentLoc OrigLoc, SourceLocation &Ellipsis,
14274 std::optional<unsigned> &NumExpansions) const;
14275
14276 /// Given a template argument that contains an unexpanded parameter pack, but
14277 /// which has already been substituted, attempt to determine the number of
14278 /// elements that will be produced once this argument is fully-expanded.
14279 ///
14280 /// This is intended for use when transforming 'sizeof...(Arg)' in order to
14281 /// avoid actually expanding the pack where possible.
14282 std::optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
14283
14284 /// Called when an expression computing the size of a parameter pack
14285 /// is parsed.
14286 ///
14287 /// \code
14288 /// template<typename ...Types> struct count {
14289 /// static const unsigned value = sizeof...(Types);
14290 /// };
14291 /// \endcode
14292 ///
14293 //
14294 /// \param OpLoc The location of the "sizeof" keyword.
14295 /// \param Name The name of the parameter pack whose size will be determined.
14296 /// \param NameLoc The source location of the name of the parameter pack.
14297 /// \param RParenLoc The location of the closing parentheses.
14299 IdentifierInfo &Name,
14300 SourceLocation NameLoc,
14301 SourceLocation RParenLoc);
14302
14303 ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
14304 SourceLocation EllipsisLoc,
14305 SourceLocation LSquareLoc, Expr *IndexExpr,
14306 SourceLocation RSquareLoc);
14307
14308 ExprResult BuildPackIndexingExpr(Expr *PackExpression,
14309 SourceLocation EllipsisLoc, Expr *IndexExpr,
14310 SourceLocation RSquareLoc,
14311 ArrayRef<Expr *> ExpandedExprs = {},
14312 bool FullySubstituted = false);
14313
14314 /// Handle a C++1z fold-expression: ( expr op ... op expr ).
14315 ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS,
14316 tok::TokenKind Operator,
14317 SourceLocation EllipsisLoc, Expr *RHS,
14318 SourceLocation RParenLoc);
14319 ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee,
14320 SourceLocation LParenLoc, Expr *LHS,
14321 BinaryOperatorKind Operator,
14322 SourceLocation EllipsisLoc, Expr *RHS,
14323 SourceLocation RParenLoc,
14324 std::optional<unsigned> NumExpansions);
14325 ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc,
14326 BinaryOperatorKind Operator);
14327
14328 ///@}
14329
14330 //
14331 //
14332 // -------------------------------------------------------------------------
14333 //
14334 //
14335
14336 /// \name Constraints and Concepts
14337 /// Implementations are in SemaConcept.cpp
14338 ///@{
14339
14340public:
14342 const llvm::FoldingSetNodeID &ID) {
14343 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14344 SatisfactionStack.emplace_back(Can, ID);
14345 }
14346
14347 void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
14348
14350 const llvm::FoldingSetNodeID &ID) const {
14351 const NamedDecl *Can = cast<NamedDecl>(D->getCanonicalDecl());
14352 return llvm::find(SatisfactionStack, SatisfactionStackEntryTy{Can, ID}) !=
14353 SatisfactionStack.end();
14354 }
14355
14357 std::pair<const NamedDecl *, llvm::FoldingSetNodeID>;
14358
14359 // Resets the current SatisfactionStack for cases where we are instantiating
14360 // constraints as a 'side effect' of normal instantiation in a way that is not
14361 // indicative of recursive definition.
14364 Sema &SemaRef;
14365
14366 public:
14368 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14369 }
14370
14372 SemaRef.SwapSatisfactionStack(BackupSatisfactionStack);
14373 }
14374 };
14375
14378 SatisfactionStack.swap(NewSS);
14379 }
14380
14381 /// Check whether the given expression is a valid constraint expression.
14382 /// A diagnostic is emitted if it is not, false is returned, and
14383 /// PossibleNonPrimary will be set to true if the failure might be due to a
14384 /// non-primary expression being used as an atomic constraint.
14385 bool CheckConstraintExpression(const Expr *CE, Token NextToken = Token(),
14386 bool *PossibleNonPrimary = nullptr,
14387 bool IsTrailingRequiresClause = false);
14388
14389 /// \brief Check whether the given list of constraint expressions are
14390 /// satisfied (as if in a 'conjunction') given template arguments.
14391 /// \param Template the template-like entity that triggered the constraints
14392 /// check (either a concept or a constrained entity).
14393 /// \param ConstraintExprs a list of constraint expressions, treated as if
14394 /// they were 'AND'ed together.
14395 /// \param TemplateArgLists the list of template arguments to substitute into
14396 /// the constraint expression.
14397 /// \param TemplateIDRange The source range of the template id that
14398 /// caused the constraints check.
14399 /// \param Satisfaction if true is returned, will contain details of the
14400 /// satisfaction, with enough information to diagnose an unsatisfied
14401 /// expression.
14402 /// \returns true if an error occurred and satisfaction could not be checked,
14403 /// false otherwise.
14405 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14406 const MultiLevelTemplateArgumentList &TemplateArgLists,
14407 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
14409 return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted,
14410 TemplateArgLists, TemplateIDRange,
14411 Satisfaction);
14412 }
14413
14414 /// \brief Check whether the given list of constraint expressions are
14415 /// satisfied (as if in a 'conjunction') given template arguments.
14416 /// Additionally, takes an empty list of Expressions which is populated with
14417 /// the instantiated versions of the ConstraintExprs.
14418 /// \param Template the template-like entity that triggered the constraints
14419 /// check (either a concept or a constrained entity).
14420 /// \param ConstraintExprs a list of constraint expressions, treated as if
14421 /// they were 'AND'ed together.
14422 /// \param ConvertedConstraints a out parameter that will get populated with
14423 /// the instantiated version of the ConstraintExprs if we successfully checked
14424 /// satisfaction.
14425 /// \param TemplateArgList the multi-level list of template arguments to
14426 /// substitute into the constraint expression. This should be relative to the
14427 /// top-level (hence multi-level), since we need to instantiate fully at the
14428 /// time of checking.
14429 /// \param TemplateIDRange The source range of the template id that
14430 /// caused the constraints check.
14431 /// \param Satisfaction if true is returned, will contain details of the
14432 /// satisfaction, with enough information to diagnose an unsatisfied
14433 /// expression.
14434 /// \returns true if an error occurred and satisfaction could not be checked,
14435 /// false otherwise.
14437 const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
14438 llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
14439 const MultiLevelTemplateArgumentList &TemplateArgList,
14440 SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
14441
14442 /// \brief Check whether the given non-dependent constraint expression is
14443 /// satisfied. Returns false and updates Satisfaction with the satisfaction
14444 /// verdict if successful, emits a diagnostic and returns true if an error
14445 /// occurred and satisfaction could not be determined.
14446 ///
14447 /// \returns true if an error occurred, false otherwise.
14448 bool CheckConstraintSatisfaction(const Expr *ConstraintExpr,
14449 ConstraintSatisfaction &Satisfaction);
14450
14451 /// Check whether the given function decl's trailing requires clause is
14452 /// satisfied, if any. Returns false and updates Satisfaction with the
14453 /// satisfaction verdict if successful, emits a diagnostic and returns true if
14454 /// an error occurred and satisfaction could not be determined.
14455 ///
14456 /// \returns true if an error occurred, false otherwise.
14458 ConstraintSatisfaction &Satisfaction,
14459 SourceLocation UsageLoc = SourceLocation(),
14460 bool ForOverloadResolution = false);
14461
14462 // Calculates whether two constraint expressions are equal irrespective of a
14463 // difference in 'depth'. This takes a pair of optional 'NamedDecl's 'Old' and
14464 // 'New', which are the "source" of the constraint, since this is necessary
14465 // for figuring out the relative 'depth' of the constraint. The depth of the
14466 // 'primary template' and the 'instantiated from' templates aren't necessarily
14467 // the same, such as a case when one is a 'friend' defined in a class.
14469 const Expr *OldConstr,
14470 const TemplateCompareNewDeclInfo &New,
14471 const Expr *NewConstr);
14472
14473 // Calculates whether the friend function depends on an enclosing template for
14474 // the purposes of [temp.friend] p9.
14476
14477 /// \brief Ensure that the given template arguments satisfy the constraints
14478 /// associated with the given template, emitting a diagnostic if they do not.
14479 ///
14480 /// \param Template The template to which the template arguments are being
14481 /// provided.
14482 ///
14483 /// \param TemplateArgs The converted, canonicalized template arguments.
14484 ///
14485 /// \param TemplateIDRange The source range of the template id that
14486 /// caused the constraints check.
14487 ///
14488 /// \returns true if the constrains are not satisfied or could not be checked
14489 /// for satisfaction, false if the constraints are satisfied.
14491 TemplateDecl *Template,
14492 const MultiLevelTemplateArgumentList &TemplateArgs,
14493 SourceRange TemplateIDRange);
14494
14496 SourceLocation PointOfInstantiation, FunctionDecl *Decl,
14497 ArrayRef<TemplateArgument> TemplateArgs,
14498 ConstraintSatisfaction &Satisfaction);
14499
14500 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14501 /// unsatisfied.
14502 /// \param First whether this is the first time an unsatisfied constraint is
14503 /// diagnosed for this error.
14505 bool First = true);
14506
14507 /// \brief Emit diagnostics explaining why a constraint expression was deemed
14508 /// unsatisfied.
14509 void
14511 bool First = true);
14512
14514 NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints);
14515
14516 /// \brief Check whether the given declaration's associated constraints are
14517 /// at least as constrained than another declaration's according to the
14518 /// partial ordering of constraints.
14519 ///
14520 /// \param Result If no error occurred, receives the result of true if D1 is
14521 /// at least constrained than D2, and false otherwise.
14522 ///
14523 /// \returns true if an error occurred, false otherwise.
14526 bool &Result);
14527
14528 /// If D1 was not at least as constrained as D2, but would've been if a pair
14529 /// of atomic constraints involved had been declared in a concept and not
14530 /// repeated in two separate places in code.
14531 /// \returns true if such a diagnostic was emitted, false otherwise.
14535
14536private:
14537 /// Caches pairs of template-like decls whose associated constraints were
14538 /// checked for subsumption and whether or not the first's constraints did in
14539 /// fact subsume the second's.
14540 llvm::DenseMap<std::pair<NamedDecl *, NamedDecl *>, bool> SubsumptionCache;
14541 /// Caches the normalized associated constraints of declarations (concepts or
14542 /// constrained declarations). If an error occurred while normalizing the
14543 /// associated constraints of the template or concept, nullptr will be cached
14544 /// here.
14545 llvm::DenseMap<NamedDecl *, NormalizedConstraint *> NormalizationCache;
14546
14547 llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
14548 SatisfactionCache;
14549
14550 // The current stack of constraint satisfactions, so we can exit-early.
14552
14553 /// Used by SetupConstraintCheckingTemplateArgumentsAndScope to set up the
14554 /// LocalInstantiationScope of the current non-lambda function. For lambdas,
14555 /// use LambdaScopeForCallOperatorInstantiationRAII.
14556 bool
14557 SetupConstraintScope(FunctionDecl *FD,
14558 std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14559 const MultiLevelTemplateArgumentList &MLTAL,
14561
14562 /// Used during constraint checking, sets up the constraint template argument
14563 /// lists, and calls SetupConstraintScope to set up the
14564 /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
14565 std::optional<MultiLevelTemplateArgumentList>
14566 SetupConstraintCheckingTemplateArgumentsAndScope(
14567 FunctionDecl *FD, std::optional<ArrayRef<TemplateArgument>> TemplateArgs,
14569
14570 ///@}
14571
14572 //
14573 //
14574 // -------------------------------------------------------------------------
14575 //
14576 //
14577
14578 /// \name Types
14579 /// Implementations are in SemaType.cpp
14580 ///@{
14581
14582public:
14583 /// A mapping that describes the nullability we've seen in each header file.
14585
14586 static int getPrintable(int I) { return I; }
14587 static unsigned getPrintable(unsigned I) { return I; }
14588 static bool getPrintable(bool B) { return B; }
14589 static const char *getPrintable(const char *S) { return S; }
14590 static StringRef getPrintable(StringRef S) { return S; }
14591 static const std::string &getPrintable(const std::string &S) { return S; }
14592 static const IdentifierInfo *getPrintable(const IdentifierInfo *II) {
14593 return II;
14594 }
14596 static QualType getPrintable(QualType T) { return T; }
14597 static SourceRange getPrintable(SourceRange R) { return R; }
14599 static SourceRange getPrintable(const Expr *E) { return E->getSourceRange(); }
14601
14602 enum class CompleteTypeKind {
14603 /// Apply the normal rules for complete types. In particular,
14604 /// treat all sizeless types as incomplete.
14605 Normal,
14606
14607 /// Relax the normal rules for complete types so that they include
14608 /// sizeless built-in types.
14610
14611 // FIXME: Eventually we should flip the default to Normal and opt in
14612 // to AcceptSizeless rather than opt out of it.
14614 };
14615
14617 const DeclSpec *DS = nullptr);
14619 const DeclSpec *DS = nullptr);
14620
14621 /// Build a pointer type.
14622 ///
14623 /// \param T The type to which we'll be building a pointer.
14624 ///
14625 /// \param Loc The location of the entity whose type involves this
14626 /// pointer type or, if there is no such entity, the location of the
14627 /// type that will have pointer type.
14628 ///
14629 /// \param Entity The name of the entity that involves the pointer
14630 /// type, if known.
14631 ///
14632 /// \returns A suitable pointer type, if there are no
14633 /// errors. Otherwise, returns a NULL type.
14635 DeclarationName Entity);
14636
14637 /// Build a reference type.
14638 ///
14639 /// \param T The type to which we'll be building a reference.
14640 ///
14641 /// \param Loc The location of the entity whose type involves this
14642 /// reference type or, if there is no such entity, the location of the
14643 /// type that will have reference type.
14644 ///
14645 /// \param Entity The name of the entity that involves the reference
14646 /// type, if known.
14647 ///
14648 /// \returns A suitable reference type, if there are no
14649 /// errors. Otherwise, returns a NULL type.
14651 DeclarationName Entity);
14652
14653 /// Build an array type.
14654 ///
14655 /// \param T The type of each element in the array.
14656 ///
14657 /// \param ASM C99 array size modifier (e.g., '*', 'static').
14658 ///
14659 /// \param ArraySize Expression describing the size of the array.
14660 ///
14661 /// \param Brackets The range from the opening '[' to the closing ']'.
14662 ///
14663 /// \param Entity The name of the entity that involves the array
14664 /// type, if known.
14665 ///
14666 /// \returns A suitable array type, if there are no errors. Otherwise,
14667 /// returns a NULL type.
14669 unsigned Quals, SourceRange Brackets,
14670 DeclarationName Entity);
14672
14673 /// Build an ext-vector type.
14674 ///
14675 /// Run the required checks for the extended vector type.
14677 SourceLocation AttrLoc);
14678 QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
14679 SourceLocation AttrLoc);
14680
14682 Expr *CountExpr,
14683 bool CountInBytes,
14684 bool OrNull);
14685
14686 /// BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an
14687 /// expression is uninstantiated. If instantiated it will apply the
14688 /// appropriate address space to the type. This function allows dependent
14689 /// template variables to be used in conjunction with the address_space
14690 /// attribute
14691 QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
14692 SourceLocation AttrLoc);
14693
14694 /// Same as above, but constructs the AddressSpace index if not provided.
14696 SourceLocation AttrLoc);
14697
14699
14701
14702 /// Build a function type.
14703 ///
14704 /// This routine checks the function type according to C++ rules and
14705 /// under the assumption that the result type and parameter types have
14706 /// just been instantiated from a template. It therefore duplicates
14707 /// some of the behavior of GetTypeForDeclarator, but in a much
14708 /// simpler form that is only suitable for this narrow use case.
14709 ///
14710 /// \param T The return type of the function.
14711 ///
14712 /// \param ParamTypes The parameter types of the function. This array
14713 /// will be modified to account for adjustments to the types of the
14714 /// function parameters.
14715 ///
14716 /// \param Loc The location of the entity whose type involves this
14717 /// function type or, if there is no such entity, the location of the
14718 /// type that will have function type.
14719 ///
14720 /// \param Entity The name of the entity that involves the function
14721 /// type, if known.
14722 ///
14723 /// \param EPI Extra information about the function type. Usually this will
14724 /// be taken from an existing function with the same prototype.
14725 ///
14726 /// \returns A suitable function type, if there are no errors. The
14727 /// unqualified type will always be a FunctionProtoType.
14728 /// Otherwise, returns a NULL type.
14732
14733 /// Build a member pointer type \c T Class::*.
14734 ///
14735 /// \param T the type to which the member pointer refers.
14736 /// \param Class the class type into which the member pointer points.
14737 /// \param Loc the location where this type begins
14738 /// \param Entity the name of the entity that will have this member pointer
14739 /// type
14740 ///
14741 /// \returns a member pointer type, if successful, or a NULL type if there was
14742 /// an error.
14745
14746 /// Build a block pointer type.
14747 ///
14748 /// \param T The type to which we'll be building a block pointer.
14749 ///
14750 /// \param Loc The source location, used for diagnostics.
14751 ///
14752 /// \param Entity The name of the entity that involves the block pointer
14753 /// type, if known.
14754 ///
14755 /// \returns A suitable block pointer type, if there are no
14756 /// errors. Otherwise, returns a NULL type.
14758 DeclarationName Entity);
14759
14760 /// Build a paren type including \p T.
14763
14764 /// Build a Read-only Pipe type.
14765 ///
14766 /// \param T The type to which we'll be building a Pipe.
14767 ///
14768 /// \param Loc We do not use it for now.
14769 ///
14770 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14771 /// a NULL type.
14773
14774 /// Build a Write-only Pipe type.
14775 ///
14776 /// \param T The type to which we'll be building a Pipe.
14777 ///
14778 /// \param Loc We do not use it for now.
14779 ///
14780 /// \returns A suitable pipe type, if there are no errors. Otherwise, returns
14781 /// a NULL type.
14783
14784 /// Build a bit-precise integer type.
14785 ///
14786 /// \param IsUnsigned Boolean representing the signedness of the type.
14787 ///
14788 /// \param BitWidth Size of this int type in bits, or an expression
14789 /// representing that.
14790 ///
14791 /// \param Loc Location of the keyword.
14792 QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc);
14793
14794 /// GetTypeForDeclarator - Convert the type for the specified
14795 /// declarator to Type instances.
14796 ///
14797 /// The result of this call will never be null, but the associated
14798 /// type may be a null type if there's an unrecoverable error.
14801
14802 /// Package the given type and TSI into a ParsedType.
14805 TypeSourceInfo **TInfo = nullptr);
14806
14808
14809 // Check whether the size of array element of type \p EltTy is a multiple of
14810 // its alignment and return false if it isn't.
14812
14813 void
14814 diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals,
14815 SourceLocation FallbackLoc,
14816 SourceLocation ConstQualLoc = SourceLocation(),
14817 SourceLocation VolatileQualLoc = SourceLocation(),
14818 SourceLocation RestrictQualLoc = SourceLocation(),
14819 SourceLocation AtomicQualLoc = SourceLocation(),
14820 SourceLocation UnalignedQualLoc = SourceLocation());
14821
14822 /// Retrieve the keyword associated
14824
14825 /// Adjust the calling convention of a method to be the ABI default if it
14826 /// wasn't specified explicitly. This handles method types formed from
14827 /// function type typedefs and typename template arguments.
14828 void adjustMemberFunctionCC(QualType &T, bool HasThisPointer,
14829 bool IsCtorOrDtor, SourceLocation Loc);
14830
14831 // Check if there is an explicit attribute, but only look through parens.
14832 // The intent is to look for an attribute on the current declarator, but not
14833 // one that came from a typedef.
14835
14836 /// Check whether a nullability type specifier can be added to the given
14837 /// type through some means not written in source (e.g. API notes).
14838 ///
14839 /// \param Type The type to which the nullability specifier will be
14840 /// added. On success, this type will be updated appropriately.
14841 ///
14842 /// \param Nullability The nullability specifier to add.
14843 ///
14844 /// \param DiagLoc The location to use for diagnostics.
14845 ///
14846 /// \param AllowArrayTypes Whether to accept nullability specifiers on an
14847 /// array type (e.g., because it will decay to a pointer).
14848 ///
14849 /// \param OverrideExisting Whether to override an existing, locally-specified
14850 /// nullability specifier rather than complaining about the conflict.
14851 ///
14852 /// \returns true if nullability cannot be applied, false otherwise.
14854 NullabilityKind Nullability,
14855 SourceLocation DiagLoc,
14856 bool AllowArrayTypes,
14857 bool OverrideExisting);
14858
14859 /// Get the type of expression E, triggering instantiation to complete the
14860 /// type if necessary -- that is, if the expression refers to a templated
14861 /// static data member of incomplete array type.
14862 ///
14863 /// May still return an incomplete type if instantiation was not possible or
14864 /// if the type is incomplete for a different reason. Use
14865 /// RequireCompleteExprType instead if a diagnostic is expected for an
14866 /// incomplete expression type.
14868
14870
14871 /// Ensure that the type of the given expression is complete.
14872 ///
14873 /// This routine checks whether the expression \p E has a complete type. If
14874 /// the expression refers to an instantiable construct, that instantiation is
14875 /// performed as needed to complete its type. Furthermore
14876 /// Sema::RequireCompleteType is called for the expression's type (or in the
14877 /// case of a reference type, the referred-to type).
14878 ///
14879 /// \param E The expression whose type is required to be complete.
14880 /// \param Kind Selects which completeness rules should be applied.
14881 /// \param Diagnoser The object that will emit a diagnostic if the type is
14882 /// incomplete.
14883 ///
14884 /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false
14885 /// otherwise.
14887 TypeDiagnoser &Diagnoser);
14888 bool RequireCompleteExprType(Expr *E, unsigned DiagID);
14889
14890 template <typename... Ts>
14891 bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args) {
14892 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14894 }
14895
14896 /// Retrieve a version of the type 'T' that is elaborated by Keyword,
14897 /// qualified by the nested-name-specifier contained in SS, and that is
14898 /// (re)declared by OwnedTagDecl, which is nullptr if this is not a
14899 /// (re)declaration.
14901 const CXXScopeSpec &SS, QualType T,
14902 TagDecl *OwnedTagDecl = nullptr);
14903
14904 // Returns the underlying type of a decltype with the given expression.
14906
14908 /// If AsUnevaluated is false, E is treated as though it were an evaluated
14909 /// context, such as when building a type for decltype(auto).
14910 QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true);
14911
14912 QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr,
14914 SourceLocation EllipsisLoc);
14915 QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr,
14916 SourceLocation Loc, SourceLocation EllipsisLoc,
14917 bool FullySubstituted = false,
14918 ArrayRef<QualType> Expansions = {});
14919
14937
14938 /// Ensure that the type T is a literal type.
14939 ///
14940 /// This routine checks whether the type @p T is a literal type. If @p T is an
14941 /// incomplete type, an attempt is made to complete it. If @p T is a literal
14942 /// type, or @p AllowIncompleteType is true and @p T is an incomplete type,
14943 /// returns false. Otherwise, this routine issues the diagnostic @p PD (giving
14944 /// it the type @p T), along with notes explaining why the type is not a
14945 /// literal type, and returns true.
14946 ///
14947 /// @param Loc The location in the source that the non-literal type
14948 /// diagnostic should refer to.
14949 ///
14950 /// @param T The type that this routine is examining for literalness.
14951 ///
14952 /// @param Diagnoser Emits a diagnostic if T is not a literal type.
14953 ///
14954 /// @returns @c true if @p T is not a literal type and a diagnostic was
14955 /// emitted, @c false otherwise.
14957 TypeDiagnoser &Diagnoser);
14958 bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID);
14959
14960 template <typename... Ts>
14962 const Ts &...Args) {
14963 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
14964 return RequireLiteralType(Loc, T, Diagnoser);
14965 }
14966
14969 return !RequireCompleteTypeImpl(Loc, T, Kind, nullptr);
14970 }
14971
14972 /// Ensure that the type T is a complete type.
14973 ///
14974 /// This routine checks whether the type @p T is complete in any
14975 /// context where a complete type is required. If @p T is a complete
14976 /// type, returns false. If @p T is a class template specialization,
14977 /// this routine then attempts to perform class template
14978 /// instantiation. If instantiation fails, or if @p T is incomplete
14979 /// and cannot be completed, issues the diagnostic @p diag (giving it
14980 /// the type @p T) and returns true.
14981 ///
14982 /// @param Loc The location in the source that the incomplete type
14983 /// diagnostic should refer to.
14984 ///
14985 /// @param T The type that this routine is examining for completeness.
14986 ///
14987 /// @param Kind Selects which completeness rules should be applied.
14988 ///
14989 /// @returns @c true if @p T is incomplete and a diagnostic was emitted,
14990 /// @c false otherwise.
14992 CompleteTypeKind Kind, TypeDiagnoser &Diagnoser);
14994 CompleteTypeKind Kind, unsigned DiagID);
14995
14997 TypeDiagnoser &Diagnoser) {
14999 }
15002 }
15003
15004 template <typename... Ts>
15006 const Ts &...Args) {
15007 BoundTypeDiagnoser<Ts...> Diagnoser(DiagID, Args...);
15008 return RequireCompleteType(Loc, T, Diagnoser);
15009 }
15010
15011 /// Determine whether a declaration is visible to name lookup.
15012 bool isVisible(const NamedDecl *D) {
15013 return D->isUnconditionallyVisible() ||
15014 isAcceptableSlow(D, AcceptableKind::Visible);
15015 }
15016
15017 /// Determine whether a declaration is reachable.
15018 bool isReachable(const NamedDecl *D) {
15019 // All visible declarations are reachable.
15020 return D->isUnconditionallyVisible() ||
15021 isAcceptableSlow(D, AcceptableKind::Reachable);
15022 }
15023
15024 /// Determine whether a declaration is acceptable (visible/reachable).
15027 }
15028
15029 /// Determine if \p D and \p Suggested have a structurally compatible
15030 /// layout as described in C11 6.2.7/1.
15031 bool hasStructuralCompatLayout(Decl *D, Decl *Suggested);
15032
15033 /// Determine if \p D has a visible definition. If not, suggest a declaration
15034 /// that should be made visible to expose the definition.
15035 bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested,
15036 bool OnlyNeedComplete = false);
15038 NamedDecl *Hidden;
15039 return hasVisibleDefinition(const_cast<NamedDecl *>(D), &Hidden);
15040 }
15041
15042 /// Determine if \p D has a reachable definition. If not, suggest a
15043 /// declaration that should be made reachable to expose the definition.
15044 bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
15045 bool OnlyNeedComplete = false);
15047 NamedDecl *Hidden;
15048 return hasReachableDefinition(D, &Hidden);
15049 }
15050
15051 bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested,
15053 bool OnlyNeedComplete = false);
15055 NamedDecl *Hidden;
15056 return hasAcceptableDefinition(D, &Hidden, Kind);
15057 }
15058
15059 /// Try to parse the conditional expression attached to an effect attribute
15060 /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty
15061 /// optional on error.
15062 std::optional<FunctionEffectMode>
15063 ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
15064
15065private:
15066 /// The implementation of RequireCompleteType
15067 bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
15068 CompleteTypeKind Kind, TypeDiagnoser *Diagnoser);
15069
15070 /// Nullability type specifiers.
15071 IdentifierInfo *Ident__Nonnull = nullptr;
15072 IdentifierInfo *Ident__Nullable = nullptr;
15073 IdentifierInfo *Ident__Nullable_result = nullptr;
15074 IdentifierInfo *Ident__Null_unspecified = nullptr;
15075
15076 ///@}
15077
15078 //
15079 //
15080 // -------------------------------------------------------------------------
15081 //
15082 //
15083
15084 /// \name FixIt Helpers
15085 /// Implementations are in SemaFixItUtils.cpp
15086 ///@{
15087
15088public:
15089 /// Get a string to suggest for zero-initialization of a type.
15091 SourceLocation Loc) const;
15093
15094 ///@}
15095
15096 //
15097 //
15098 // -------------------------------------------------------------------------
15099 //
15100 //
15101
15102 /// \name Function Effects
15103 /// Implementations are in SemaFunctionEffects.cpp
15104 ///@{
15105public:
15107 enum class Kind { Added, Removed, ConditionMismatch };
15108
15111 std::optional<FunctionEffectWithCondition>
15112 Old; // Invalid when 'Kind' is 'Added'.
15113 std::optional<FunctionEffectWithCondition>
15114 New; // Invalid when 'Kind' is 'Removed'.
15115
15116 StringRef effectName() const {
15117 if (Old)
15118 return Old.value().Effect.name();
15119 return New.value().Effect.name();
15120 }
15121
15122 /// Describes the result of effects differing between a base class's virtual
15123 /// method and an overriding method in a subclass.
15124 enum class OverrideResult {
15125 NoAction,
15126 Warn,
15127 Merge // Merge missing effect from base to derived.
15128 };
15129
15130 /// Return true if adding or removing the effect as part of a type
15131 /// conversion should generate a diagnostic.
15132 bool shouldDiagnoseConversion(QualType SrcType,
15133 const FunctionEffectsRef &SrcFX,
15134 QualType DstType,
15135 const FunctionEffectsRef &DstFX) const;
15136
15137 /// Return true if adding or removing the effect in a redeclaration should
15138 /// generate a diagnostic.
15139 bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
15140 const FunctionEffectsRef &OldFX,
15141 const FunctionDecl &NewFunction,
15142 const FunctionEffectsRef &NewFX) const;
15143
15144 /// Return true if adding or removing the effect in a C++ virtual method
15145 /// override should generate a diagnostic.
15146 OverrideResult shouldDiagnoseMethodOverride(
15147 const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
15148 const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
15149 };
15150
15151 struct FunctionEffectDiffVector : public SmallVector<FunctionEffectDiff> {
15152 /// Caller should short-circuit by checking for equality first.
15154 const FunctionEffectsRef &New);
15155 };
15156
15157 /// All functions/lambdas/blocks which have bodies and which have a non-empty
15158 /// FunctionEffectsRef to be verified.
15160
15161 /// The union of all effects present on DeclsWithEffectsToVerify. Conditions
15162 /// are all null.
15164
15165public:
15166 /// Warn and return true if adding a function effect to a set would create a
15167 /// conflict.
15170 SourceLocation NewAttrLoc);
15171
15172 // Report a failure to merge function effects between declarations due to a
15173 // conflict.
15174 void
15176 SourceLocation NewLoc,
15177 SourceLocation OldLoc);
15178
15179 /// Inline checks from the start of maybeAddDeclWithEffects, to
15180 /// minimize performance impact on code not using effects.
15181 template <class FuncOrBlockDecl>
15182 void maybeAddDeclWithEffects(FuncOrBlockDecl *D) {
15184 if (FunctionEffectsRef FX = D->getFunctionEffects(); !FX.empty())
15186 }
15187
15188 /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify.
15189 void maybeAddDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15190
15191 /// Unconditionally add a Decl to DeclsWithEfffectsToVerify.
15192 void addDeclWithEffects(const Decl *D, const FunctionEffectsRef &FX);
15193
15195
15196 ///@}
15197};
15198
15199DeductionFailureInfo
15201 sema::TemplateDeductionInfo &Info);
15202
15203/// Contains a late templated function.
15204/// Will be parsed at the end of the translation unit, used by Sema & Parser.
15207 /// The template function declaration to be late parsed.
15209 /// Floating-point options in the point of definition.
15211};
15212
15213template <>
15215 PragmaMsStackAction Action,
15216 llvm::StringRef StackSlotLabel,
15218} // end namespace clang
15219
15220#endif
#define V(N, I)
Definition: ASTContext.h:3460
NodeId Parent
Definition: ASTDiff.cpp:191
Forward declaration of all AST node types.
This file provides some common utility functions for processing Lambda related AST Constructs.
MatchType Type
StringRef P
static char ID
Definition: Arena.cpp:183
#define SM(sm)
Definition: Cuda.cpp:85
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
enum clang::sema::@1727::IndirectLocalPathEntry::EntryKind Kind
Expr * E
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:3060
StringRef Identifier
Definition: Format.cpp:3064
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:1136
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:4545
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:3021
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:384
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:3578
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:6133
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:6562
Represents a C++ declaration that introduces decls from somewhere else.
Definition: DeclCXX.h:3479
A binding in a decomposition declaration.
Definition: DeclCXX.h:4169
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4496
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:2592
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2924
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2357
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:2856
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2117
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:4772
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:3660
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:1372
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1439
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:911
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:4228
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:3291
Represents an enum.
Definition: Decl.h:3861
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Definition: Type.h:6104
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:276
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:979
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
Definition: LangOptions.h:1086
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:259
FileNullability & operator[](FileID file)
Definition: Sema.h:270
FileNullability Nullability
Definition: Sema.h:266
Represents a function declaration or definition.
Definition: Decl.h:1935
A mutable set of FunctionEffect::Kind.
Definition: Type.h:4963
Kind
Identifies the particular effect.
Definition: Type.h:4725
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition: Type.h:4909
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4652
Represents a prototype with parameter type info, e.g.
Definition: Type.h:5108
Declaration of a template function.
Definition: DeclTemplate.h:958
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition: Type.h:4348
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:4322
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:3335
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:442
FPEvalMethodKind
Possible float expression evaluation method choices.
Definition: LangOptions.h:300
FPExceptionModeKind
Possible floating point exception behavior.
Definition: LangOptions.h:288
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:500
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:4351
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4297
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4732
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:7586
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:1021
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:291
void enterFunctionArgument(SourceLocation Tok, llvm::function_ref< QualType()> ComputeType)
Computing a type for the function argument may require running overloading, so we postpone its comput...
void enterCondition(Sema &S, SourceLocation Tok)
void enterTypeCast(SourceLocation Tok, QualType CastType)
Handles all type casts, including C-style cast, C++ casts, etc.
void enterMemAccess(Sema &S, SourceLocation Tok, Expr *Base)
void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS)
void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc)
void enterReturn(Sema &S, SourceLocation Tok)
void enterDesignatedInitializer(SourceLocation Tok, QualType BaseType, const Designation &D)
Handles e.g. BaseType{ .D = Tok...
void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)
void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc)
PreferredTypeBuilder(bool Enabled)
Definition: Sema.h:293
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
Definition: Sema.h:328
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:4162
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:6078
Represents the body of a requires-expression.
Definition: DeclCXX.h:2086
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:1462
bool operator==(const AlignPackInfo &Info) const
Definition: Sema.h:1522
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:1494
unsigned getPackNumber() const
Definition: Sema.h:1512
bool IsXLStack() const
Definition: Sema.h:1520
bool IsPackSet() const
Definition: Sema.h:1514
AlignPackInfo(AlignPackInfo::Mode M, bool IsXL)
Definition: Sema.h:1468
bool IsAlignAttr() const
Definition: Sema.h:1508
bool IsPackAttr() const
Definition: Sema.h:1506
bool operator!=(const AlignPackInfo &Info) const
Definition: Sema.h:1528
AlignPackInfo(bool IsXL)
Definition: Sema.h:1472
static uint32_t getRawEncoding(const AlignPackInfo &Info)
Definition: Sema.h:1479
Mode getAlignMode() const
Definition: Sema.h:1510
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:13221
ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
Definition: Sema.h:13226
BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7880
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7885
void emit(const SemaDiagnosticBuilder &DB, std::index_sequence< Is... >) const
Definition: Sema.h:7872
std::tuple< const Ts &... > Args
Definition: Sema.h:7869
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:8049
A RAII object to enter scope of a compound statement.
Definition: Sema.h:917
CompoundScopeRAII(Sema &S, bool IsStmtExpr=false)
Definition: Sema.h:919
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:7333
bool isInvalid() const
Definition: Sema.h:7332
std::optional< bool > getKnownValue() const
Definition: Sema.h:7337
A RAII object to temporarily push a declaration context.
Definition: Sema.h:3011
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext=true)
Definition: Sema.h:3021
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Definition: Sema.h:10032
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:10037
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:5892
DefaultedComparisonKind asComparison() const
Definition: Sema.h:5924
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition: Sema.h:5901
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition: Sema.h:5929
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition: Sema.h:5904
CXXSpecialMemberKind asSpecialMember() const
Definition: Sema.h:5921
RAII class to control scope of DeferDiags.
Definition: Sema.h:9759
DeferDiagsRAII(Sema &S, bool DeferDiags)
Definition: Sema.h:9764
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
Definition: Sema.h:986
DelayedDiagnosticsState push(sema::DelayedDiagnosticPool &pool)
Enter a new scope.
Definition: Sema.h:1005
void popUndelayed(DelayedDiagnosticsState state)
Undo a previous pushUndelayed().
Definition: Sema.h:1029
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
Definition: Sema.h:998
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Definition: Sema.h:1001
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:1015
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
Definition: Sema.h:1021
A helper class for building up ExtParameterInfos.
Definition: Sema.h:12624
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:12643
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:12631
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:13591
FPOptionsOverride getOverrides()
Definition: Sema.h:13595
FullExprArg(Sema &actions)
Definition: Sema.h:7277
ExprResult release()
Definition: Sema.h:7279
Expr * get() const
Definition: Sema.h:7281
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
Definition: Sema.h:13607
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:10096
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:10088
Helper class that collects exception specifications for implicitly-declared special member functions.
Definition: Sema.h:4996
unsigned size() const
The number of exceptions in the exception specification.
Definition: Sema.h:5029
ExceptionSpecificationType getExceptionSpecType() const
Get the computed exception specification type.
Definition: Sema.h:5022
const QualType * data() const
The set of exceptions in the exception specification.
Definition: Sema.h:5032
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
Definition: Sema.h:5038
FunctionProtoType::ExceptionSpecInfo getExceptionSpec() const
Overwrite an EPI's exception specification with this computed exception specification.
Definition: Sema.h:5045
static NameClassification DependentNonType()
Definition: Sema.h:3255
static NameClassification VarTemplate(TemplateName Name)
Definition: Sema.h:3265
ExprResult getExpression() const
Definition: Sema.h:3291
NameClassification(const IdentifierInfo *Keyword)
Definition: Sema.h:3231
static NameClassification Unknown()
Definition: Sema.h:3235
static NameClassification OverloadSet(ExprResult E)
Definition: Sema.h:3239
NameClassificationKind getKind() const
Definition: Sema.h:3289
static NameClassification UndeclaredTemplate(TemplateName Name)
Definition: Sema.h:3283
static NameClassification FunctionTemplate(TemplateName Name)
Definition: Sema.h:3271
NamedDecl * getNonTypeDecl() const
Definition: Sema.h:3301
NameClassification(ParsedType Type)
Definition: Sema.h:3229
TemplateName getTemplateName() const
Definition: Sema.h:3306
ParsedType getType() const
Definition: Sema.h:3296
TemplateNameKind getTemplateNameKind() const
Definition: Sema.h:3313
static NameClassification NonType(NamedDecl *D)
Definition: Sema.h:3245
static NameClassification Concept(TemplateName Name)
Definition: Sema.h:3277
static NameClassification UndeclaredNonType()
Definition: Sema.h:3251
static NameClassification TypeTemplate(TemplateName Name)
Definition: Sema.h:3259
static NameClassification Error()
Definition: Sema.h:3233
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
Definition: Sema.h:664
void operator()(sema::FunctionScopeInfo *Scope) const
Definition: Sema.cpp:2315
Whether and why a template name is required in this lookup.
Definition: Sema.h:11094
RequiredTemplateKind(TemplateNameIsRequiredTag)
Template name is unconditionally required.
Definition: Sema.h:11100
SourceLocation getTemplateKeywordLoc() const
Definition: Sema.h:11102
RequiredTemplateKind(SourceLocation TemplateKWLoc=SourceLocation())
Template name is required if TemplateKWLoc is valid.
Definition: Sema.h:11097
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Definition: Sema.h:12094
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Definition: Sema.h:12124
SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE=false)
Definition: Sema.h:12102
A derivative of BoundTypeDiagnoser for which the diagnostic's type parameter is preceded by a 0/1 enu...
Definition: Sema.h:7897
void diagnose(Sema &S, SourceLocation Loc, QualType T) override
Definition: Sema.h:7902
SizelessTypeDiagnoser(unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7899
SpecialMemberOverloadResultEntry(const llvm::FoldingSetNodeID &ID)
Definition: Sema.h:8965
SpecialMemberOverloadResult - The overloading result for a special member function.
Definition: Sema.h:8943
SpecialMemberOverloadResult(CXXMethodDecl *MD)
Definition: Sema.h:8952
CXXMethodDecl * getMethod() const
Definition: Sema.h:8955
void setMethod(CXXMethodDecl *MD)
Definition: Sema.h:8956
RAII object to handle the state changes required to synthesize a function body.
Definition: Sema.h:13097
void addContextNote(SourceLocation UseLoc)
Definition: Sema.h:13127
SynthesizedFunctionScope(Sema &S, DeclContext *DC)
Definition: Sema.h:13103
SourceLocation getLocation() const
Definition: Sema.h:11868
bool ContainsDecl(const NamedDecl *ND) const
Definition: Sema.h:11858
const DeclContext * getDeclContext() const
Definition: Sema.h:11864
TemplateCompareNewDeclInfo(const DeclContext *DeclCtx, const DeclContext *LexicalDeclCtx, SourceLocation Loc)
Definition: Sema.h:11842
const NamedDecl * getDecl() const
Definition: Sema.h:11856
TemplateCompareNewDeclInfo(const NamedDecl *ND)
Definition: Sema.h:11841
const DeclContext * getLexicalDeclContext() const
Definition: Sema.h:11860
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Definition: Sema.h:12133
TentativeAnalysisScope(Sema &SemaRef)
Definition: Sema.h:12140
Abstract base class used for diagnosing integer constant expression violations.
Definition: Sema.h:7230
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
VerifyICEDiagnoser(bool Suppress=false)
Definition: Sema.h:7234
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:465
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:14566
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:14278
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:9259
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:11046
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:1675
SemaAMDGPU & AMDGPU()
Definition: Sema.h:1047
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:6395
SmallVector< DeclaratorDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
Definition: Sema.h:3103
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
Definition: SemaDecl.cpp:6716
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:13171
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:7802
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:13155
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:10661
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Definition: Sema.h:12653
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:2388
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:733
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:2471
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:9134
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:6636
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
SmallVector< SmallVector< VTableUse, 16 >, 8 > SavedVTableUses
Definition: Sema.h:13554
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Definition: SemaDecl.cpp:9816
void PopParsingClass(ParsingClassState state)
Definition: Sema.h:6086
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:9775
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
Definition: Sema.cpp:996
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:6075
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:2031
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:15832
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:7852
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:1561
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:15509
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:7770
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:870
bool isAttrContext() const
Definition: Sema.h:6470
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
Definition: SemaDecl.cpp:15171
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Definition: SemaStmt.cpp:4479
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:7845
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
Definition: Sema.cpp:2488
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
Definition: Sema.h:5836
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:8987
@ LookupLabel
Label name lookup.
Definition: Sema.h:8996
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:8991
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
Definition: Sema.h:9018
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
Definition: Sema.h:9010
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
Definition: Sema.h:9032
@ LookupLocalFriendName
Look up a friend of a local class.
Definition: Sema.h:9026
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
Definition: Sema.h:9028
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Definition: Sema.h:9023
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
Definition: Sema.h:9003
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
Definition: Sema.h:9030
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition: Sema.h:9014
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:8999
@ LookupDestructorName
Look up a name following ~ in a destructor name.
Definition: Sema.h:9006
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:8994
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
Definition: Sema.h:9034
@ LookupAnyName
Look up any declaration with any name.
Definition: Sema.h:9036
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:8931
LazyVector< TypedefNameDecl *, ExternalSemaSource, &ExternalSemaSource::ReadExtVectorDecls, 2, 2 > ExtVectorDeclsType
Definition: Sema.h:4468
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:6652
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
Definition: SemaType.cpp:6498
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:2182
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
Definition: SemaDecl.cpp:5345
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
ExprResult ActOnConstantExpression(ExprResult Res)
Definition: SemaExpr.cpp:19665
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:13169
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
Definition: SemaDecl.cpp:15870
bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:5773
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS=nullptr)
VariadicCallType
Definition: Sema.h:2316
@ VariadicDoesNotApply
Definition: Sema.h:2321
@ VariadicFunction
Definition: Sema.h:2317
@ VariadicMethod
Definition: Sema.h:2319
@ VariadicConstructor
Definition: Sema.h:2320
@ VariadicBlock
Definition: Sema.h:2318
SemaM68k & M68k()
Definition: Sema.h:1092
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
Definition: SemaDecl.cpp:12925
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)
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, CheckTemplateArgumentKind CTAK, bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg)
Check that the given template argument corresponds to the given template parameter.
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:7041
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:852
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:981
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:3625
@ NTCUC_CopyInit
Definition: Sema.h:3635
@ NTCUC_AutoVar
Definition: Sema.h:3633
@ NTCUC_CompoundLiteral
Definition: Sema.h:3639
@ NTCUC_DefaultInitializedObject
Definition: Sema.h:3631
@ NTCUC_Assignment
Definition: Sema.h:3637
@ NTCUC_BlockCapture
Definition: Sema.h:3641
@ NTCUC_FunctionReturn
Definition: Sema.h:3629
@ NTCUC_LValueToRValueVolatile
Definition: Sema.h:3643
@ NTCUC_FunctionParam
Definition: Sema.h:3627
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:1727
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:3558
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:9475
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:7545
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:6129
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:4413
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:4612
OpaquePtr< QualType > TypeTy
Definition: Sema.h:903
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
Definition: SemaDecl.cpp:18303
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:305
void PrintContextStack()
Definition: Sema.h:13241
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:2327
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:651
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:7470
SemaOpenMP & OpenMP()
Definition: Sema.h:1127
IfExistsResult
Describes the result of an "if-exists" condition check.
Definition: Sema.h:8461
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:8466
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:8470
@ IER_Error
An error occurred.
Definition: Sema.h:8473
@ IER_Exists
The symbol exists.
Definition: Sema.h:8463
void CheckDelegatingCtorCycles()
llvm::SmallSet< SourceLocation, 2 > SrcLocSet
Definition: Sema.h:8930
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:15851
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:5811
bool hasVisibleDeclaration(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine whether any declaration of an entity is visible.
Definition: Sema.h:9301
bool FormatStringHasSArg(const StringLiteral *FExpr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
Definition: SemaExpr.cpp:17470
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void ActOnStmtExprError()
Definition: SemaExpr.cpp:15857
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:20182
bool IsLastErrorImmediate
Is the last error level diagnostic immediate.
Definition: Sema.h:973
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope)
Definition: SemaStmt.cpp:4468
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:6114
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:14592
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:2313
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:868
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Definition: SemaDecl.cpp:18235
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
Definition: Sema.h:4326
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Definition: Sema.h:3085
PragmaClangSection PragmaClangRodataSection
Definition: Sema.h:1434
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:7625
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
Definition: SemaExpr.cpp:12178
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:251
bool hasVisibleDefinition(const NamedDecl *D)
Definition: Sema.h:15037
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:6052
void emitAndClearUnusedLocalTypedefWarnings()
Definition: Sema.cpp:1087
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:16441
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:6033
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:15037
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)
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true, bool HasMatchedPackOnParmToNonPackOnArg=false)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
unsigned CapturingFunctionScopes
Track the number of currently active capturing scopes.
Definition: Sema.h:857
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:1072
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:17405
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:1424
@ PCSA_Set
Definition: Sema.h:1424
@ PCSA_Clear
Definition: Sema.h:1424
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:20398
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:311
ConditionKind
Definition: Sema.h:7352
@ 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:950
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:14996
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
static SourceRange getPrintable(SourceLocation L)
Definition: Sema.h:14598
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:7790
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
ModuleDeclKind
Definition: Sema.h:9606
@ PartitionImplementation
'module X:Y;'
@ Interface
'export module X;'
@ PartitionInterface
'export module X:Y;'
SourceLocation LocationOfExcessPrecisionNotSatisfied
Definition: Sema.h:7932
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:850
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:1457
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
Definition: Sema.h:9248
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
Definition: Sema.h:10115
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
Definition: Sema.h:10118
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
Definition: Sema.h:10124
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
Definition: Sema.h:10122
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:1380
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:1268
@ AR_dependent
Definition: Sema.h:1271
@ AR_accessible
Definition: Sema.h:1269
@ AR_inaccessible
Definition: Sema.h:1270
@ AR_delayed
Definition: Sema.h:1272
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:2292
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:14602
@ 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:680
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
Definition: SemaCast.cpp:3381
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:532
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Definition: Sema.h:6448
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Definition: Sema.cpp:2161
QualType GetSignedSizelessVectorType(QualType V)
Definition: SemaExpr.cpp:12737
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
Definition: Sema.h:13158
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)
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:7921
void deduceOpenCLAddressSpace(ValueDecl *decl)
Definition: SemaDecl.cpp:6867
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
Definition: SemaExpr.cpp:3538
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3217
PragmaStack< FPOptionsOverride > FpPragmaStack
Definition: Sema.h:1665
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:7833
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind, StringLiteral *DeletedMessage=nullptr)
static SourceRange getPrintable(const Expr *E)
Definition: Sema.h:14599
PragmaStack< StringLiteral * > CodeSegStack
Definition: Sema.h:1659
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:3828
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:18448
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:15163
void setFunctionHasBranchIntoScope()
Definition: Sema.cpp:2341
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:4473
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:1736
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
Definition: SemaDecl.cpp:6257
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:17163
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:303
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Definition: SemaType.cpp:2393
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
Definition: SemaDecl.cpp:4844
SmallVector< AlignPackIncludeState, 8 > AlignPackIncludeStack
Definition: Sema.h:1654
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:10821
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
Definition: SemaExpr.cpp:6683
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
Definition: SemaAttr.cpp:53
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, bool *MatchedPackOnParmToNonPackOnArg=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
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:12339
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
Definition: SemaDecl.cpp:16642
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:2101
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:10149
void ActOnComment(SourceRange Comment)
Definition: Sema.cpp:2440
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3503
@ 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:18322
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
llvm::function_ref< void(llvm::raw_ostream &)> EntityPrinter
Definition: Sema.h:13516
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:18420
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Definition: Sema.cpp:1171
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:1666
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:1082
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
Definition: SemaExpr.cpp:7519
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:878
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:14651
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
Definition: SemaExpr.cpp:15870
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:149
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:1433
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
bool CheckConceptUseInDefinition(ConceptDecl *Concept, SourceLocation Loc)
SemaSYCL & SYCL()
Definition: Sema.h:1152
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:15506
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16513
IdentifierInfo * getSuperIdentifier() const
Definition: Sema.cpp:2715
StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:1044
ExpressionEvaluationContextRecord & parentEvaluationContext()
Definition: Sema.h:6460
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:1570
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:11065
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
Definition: SemaDecl.cpp:3436
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg, const DefaultArguments &DefaultArgs, SourceLocation ArgLoc, bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg)
CheckTemplateArgumentKind
Specifies the context in which a particular template argument is being checked.
Definition: Sema.h:11639
@ CTAK_DeducedFromArrayBound
The template argument was deduced from an array bound via template argument deduction.
Definition: Sema.h:11650
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
Definition: Sema.h:11642
@ CTAK_Deduced
The template argument was deduced via template argument deduction.
Definition: Sema.h:11646
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:643
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:1659
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:8925
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:1172
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:13890
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:13175
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
Definition: SemaExpr.cpp:4999
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
Definition: SemaDecl.cpp:20225
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:7629
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
Definition: SemaExpr.cpp:14170
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:15158
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
Definition: SemaStmt.cpp:1120
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
ASTContext & Context
Definition: Sema.h:910
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:7757
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:616
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
Definition: SemaCast.cpp:2704
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12973
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:9839
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:20193
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Definition: SemaDecl.cpp:14671
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:4660
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:8936
FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC)
Definition: Sema.h:7298
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
Definition: SemaType.cpp:2633
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:11515
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:5821
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:13182
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool HasMatchedPackOnParmToNonPackOnArg=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:530
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:7894
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
Definition: SemaDecl.cpp:20246
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:3950
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
bool RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14961
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool CheckCaseExpression(Expr *E)
Definition: SemaExpr.cpp:21171
void resetFPOptions(FPOptions FPO)
Definition: Sema.h:11043
bool hasAcceptableDefinition(NamedDecl *D, AcceptableKind Kind)
Definition: Sema.h:15054
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:9594
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:14588
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Definition: SemaLookup.cpp:916
SemaObjC & ObjC()
Definition: Sema.h:1112
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:5350
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
Definition: SemaDecl.cpp:4954
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
Definition: SemaExpr.cpp:13008
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:2670
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:1042
void CheckDelayedMemberExceptionSpecs()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
Definition: SemaDecl.cpp:72
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:7244
@ AllowFold
Definition: Sema.h:7246
@ NoFold
Definition: Sema.h:7245
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:1499
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:2684
PragmaStack< bool > StrictGuardStackCheckStack
Definition: Sema.h:1662
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:3093
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:19678
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:7782
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:2333
ASTContext & getASTContext() const
Definition: Sema.h:533
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:7261
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:15942
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:6059
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:15788
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool)
Definition: Sema.h:1035
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:18948
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:19926
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
Check the redefinition in C++20 Modules.
Definition: SemaDecl.cpp:1715
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:6137
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
Definition: SemaExpr.cpp:15306
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, TemplateParameterList *Params, TemplateArgumentLoc &Arg, bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg)
Check a template argument against its corresponding template template parameter.
NameClassificationKind
Describes the result of the name lookup and resolution performed by ClassifyName().
Definition: Sema.h:3178
@ NC_Unknown
This name is not a type or template in this context, but might be something else.
Definition: Sema.h:3181
@ NC_VarTemplate
The name was classified as a variable template name.
Definition: Sema.h:3208
@ NC_NonType
The name was classified as a specific non-type, non-template declaration.
Definition: Sema.h:3191
@ NC_TypeTemplate
The name was classified as a template whose specializations are types.
Definition: Sema.h:3206
@ NC_Error
Classification failed; an error has been produced.
Definition: Sema.h:3183
@ NC_FunctionTemplate
The name was classified as a function template name.
Definition: Sema.h:3210
@ NC_DependentNonType
The name denotes a member of a dependent type that could not be resolved.
Definition: Sema.h:3199
@ NC_UndeclaredNonType
The name was classified as an ADL-only function name.
Definition: Sema.h:3195
@ NC_UndeclaredTemplate
The name was classified as an ADL-only function template name.
Definition: Sema.h:3212
@ NC_Keyword
The name has been typo-corrected to a keyword.
Definition: Sema.h:3185
@ NC_Type
The name was classified as a type.
Definition: Sema.h:3187
@ NC_OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
Definition: Sema.h:3204
@ NC_Concept
The name was classified as a concept name.
Definition: Sema.h:3214
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:17838
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
Definition: SemaExpr.cpp:9582
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:1658
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: SemaStmt.cpp:4403
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:692
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.
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:667
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
Definition: Sema.h:2150
ParsingClassState PushParsingClass()
Definition: Sema.h:6082
ForRangeStatus
Definition: Sema.h:10483
@ FRS_Success
Definition: Sema.h:10484
@ FRS_DiagnosticIssued
Definition: Sema.h:10486
@ FRS_NoViableFunction
Definition: Sema.h:10485
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
Definition: SemaExpr.cpp:6200
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:7055
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:15838
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
llvm::SmallVector< DeleteExprLoc, 4 > DeleteLocs
Definition: Sema.h:575
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:8984
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:8928
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:4801
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition: Sema.h:5607
@ 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:7910
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:8670
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:9487
SmallVector< const Decl * > DeclsWithEffectsToVerify
All functions/lambdas/blocks which have bodies and which have a non-empty FunctionEffectsRef to be ve...
Definition: Sema.h:15159
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:9835
@ 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:9615
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
Definition: Sema.h:840
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMemberKind > SpecialMemberDecl
Definition: Sema.h:6070
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Definition: SemaExpr.cpp:13054
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:20392
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:818
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:5503
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:3116
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:1575
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:16977
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
Definition: Sema.cpp:2431
unsigned InventedParameterInfosStart
The index of the first InventedParameterInfo that refers to the current context.
Definition: Sema.h:3008
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
Definition: SemaDecl.cpp:9079
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:458
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
Definition: Sema.h:11055
void setFunctionHasIndirectGoto()
Definition: Sema.cpp:2351
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:1940
TemplateParameterListEqualKind
Enumeration describing how template parameter lists are compared for equality.
Definition: Sema.h:11789
@ TPL_TemplateTemplateParmMatch
We are matching the template parameter lists of two template template parameters as part of matching ...
Definition: Sema.h:11807
@ TPL_TemplateTemplateArgumentMatch
We are matching the template parameter lists of a template template argument against the template par...
Definition: Sema.h:11818
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
Definition: Sema.h:11797
@ TPL_TemplateParamsEquivalent
We are determining whether the template-parameters are equivalent according to C++ [temp....
Definition: Sema.h:11828
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16126
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:4464
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
Definition: Sema.cpp:1589
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9856
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:7963
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:11115
@ 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:4391
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Definition: SemaExpr.cpp:1969
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
Definition: SemaType.cpp:1581
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 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:1308
AtomicArgumentOrder
Definition: Sema.h:2258
void PushFunctionScope()
Enter a new function scope.
Definition: Sema.cpp:2180
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:1249
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:3329
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:2528
ArrayRef< InventedTemplateParameterInfo > getInventedParameterInfos() const
Definition: Sema.h:11048
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:673
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:3089
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
Definition: Sema.h:7817
static DeclarationName getPrintable(DeclarationName N)
Definition: Sema.h:14595
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
Definition: Sema.h:4165
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
Definition: SemaDecl.cpp:16876
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:528
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Definition: Sema.h:7915
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
Definition: Sema.h:956
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
Definition: SemaExpr.cpp:20429
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:82
sema::LambdaScopeInfo * PushLambdaScope()
Definition: Sema.cpp:2198
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:2330
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:15005
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:19761
UnexpandedParameterPackContext
The context in which an unexpanded parameter pack is being diagnosed.
Definition: Sema.h:13924
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
Definition: Sema.h:13944
@ UPPC_RequiresClause
Definition: Sema.h:13995
@ UPPC_UsingDeclaration
A using declaration.
Definition: Sema.h:13950
@ UPPC_IfExists
Microsoft __if_exists.
Definition: Sema.h:13977
@ UPPC_Requirement
Definition: Sema.h:13992
@ UPPC_ExceptionType
The type of an exception.
Definition: Sema.h:13968
@ UPPC_EnumeratorValue
The enumerator value.
Definition: Sema.h:13947
@ UPPC_Lambda
Lambda expression.
Definition: Sema.h:13983
@ UPPC_IfNotExists
Microsoft __if_not_exists.
Definition: Sema.h:13980
@ UPPC_PartialSpecialization
Partial specialization.
Definition: Sema.h:13974
@ UPPC_Initializer
An initializer.
Definition: Sema.h:13959
@ UPPC_BaseType
The base type of a class type.
Definition: Sema.h:13929
@ UPPC_FriendDeclaration
A friend declaration.
Definition: Sema.h:13953
@ UPPC_DefaultArgument
A default argument.
Definition: Sema.h:13962
@ UPPC_DeclarationType
The type of an arbitrary declaration.
Definition: Sema.h:13932
@ UPPC_Expression
An arbitrary expression.
Definition: Sema.h:13926
@ UPPC_ExplicitSpecialization
Explicit specialization.
Definition: Sema.h:13971
@ UPPC_DeclarationQualifier
A declaration qualifier.
Definition: Sema.h:13956
@ UPPC_DataMemberType
The type of a data member.
Definition: Sema.h:13935
@ UPPC_StaticAssertExpression
The expression in a static assertion.
Definition: Sema.h:13941
@ UPPC_Block
Block expression.
Definition: Sema.h:13986
@ UPPC_BitFieldWidth
The size of a bit-field.
Definition: Sema.h:13938
@ UPPC_NonTypeTemplateParameterType
The type of a non-type template parameter.
Definition: Sema.h:13965
@ UPPC_TypeConstraint
A type constraint.
Definition: Sema.h:13989
api_notes::APINotesManager APINotes
Definition: Sema.h:914
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:12156
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:525
const LangOptions & getLangOpts() const
Definition: Sema.h:526
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:9109
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:5397
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:1792
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:12205
SourceLocation CurInitSegLoc
Definition: Sema.h:1698
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:7293
void ActOnPragmaMSVtorDisp(PragmaMsStackAction Action, SourceLocation PragmaLoc, MSVtorDispMode Value)
Called on well formed #pragma vtordisp().
Definition: SemaAttr.cpp:721
SemaCodeCompletion & CodeCompletion()
Definition: Sema.h:1067
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:3110
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:1117
void SwapSatisfactionStack(llvm::SmallVectorImpl< SatisfactionStackEntryTy > &NewSS)
Definition: Sema.h:14376
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
Definition: SemaDecl.cpp:1390
ReuseLambdaContextDecl_t
Definition: Sema.h:6532
@ ReuseLambdaContextDecl
Definition: Sema.h:6532
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:6612
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:17501
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:6646
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
Definition: SemaDecl.cpp:1600
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:534
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:1062
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:20067
void * OpaqueParser
Definition: Sema.h:954
Preprocessor & PP
Definition: Sema.h:909
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:10950
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
Definition: SemaExpr.cpp:5711
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:6476
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
QualType BuiltinEnumUnderlyingType(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9781
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:14142
bool MSPragmaOptimizeIsOn
The "on" or "off" argument passed by #pragma optimize, that denotes whether the optimizations in the ...
Definition: Sema.h:1745
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:16794
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
Definition: SemaExpr.cpp:4712
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:947
SmallVector< PragmaAttributeGroup, 2 > PragmaAttributeStack
Definition: Sema.h:1723
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:8279
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:1980
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:7534
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:3097
llvm::SmallSetVector< const NamedDecl *, 16 > NamedDeclSetType
Definition: Sema.h:6035
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:1102
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:14404
const LangOptions & LangOpts
Definition: Sema.h:908
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:7618
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:15940
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
Definition: Sema.h:846
ExprResult CorrectDelayedTyposInExpr(ExprResult ER, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Definition: Sema.h:8449
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2406
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:6733
static const uint64_t MaximumAlignment
Definition: Sema.h:841
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
llvm::DenseMap< unsigned, CXXDeductionGuideDecl * > AggregateDeductionCandidates
Definition: Sema.h:8673
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:17522
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
Definition: SemaInit.cpp:7600
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:15018
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:15346
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall)
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
Definition: Sema.h:6037
SemaHLSL & HLSL()
Definition: Sema.h:1077
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:11064
bool CollectStats
Flag indicating whether or not to collect detailed statistics.
Definition: Sema.h:844
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
Definition: Sema.h:8983
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:1106
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Definition: SemaDecl.cpp:1832
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
Definition: SemaDecl.cpp:11956
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:18515
ExpressionEvaluationContextRecord & currentEvaluationContext()
Definition: Sema.h:6454
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
Definition: SemaExpr.cpp:17486
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:1435
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
SemaMIPS & MIPS()
Definition: Sema.h:1097
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
Definition: Sema.cpp:116
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:1142
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:15182
bool checkConstantPointerAuthKey(Expr *keyExpr, unsigned &key)
SourceLocation ImplicitMSInheritanceAttrLoc
Source location for newly created implicit MSInheritanceAttrs.
Definition: Sema.h:1412
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:5403
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:3717
QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions, IdentifierInfo *Id, bool DirectInit, Expr *&Init)
Definition: SemaLambda.cpp:786
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:4793
@ 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:13552
SmallVector< InventedTemplateParameterInfo, 4 > InventedParameterInfos
Stack containing information needed when in C++2a an 'auto' is encountered in a function declaration ...
Definition: Sema.h:6030
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:20077
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:9863
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:14590
SemaSwift & Swift()
Definition: Sema.h:1157
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:3710
PragmaStack< AlignPackInfo > AlignPackStack
Definition: Sema.h:1647
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:15828
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:6129
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Definition: Sema.h:6481
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Definition: Sema.h:13207
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
Definition: Sema.h:6063
StmtResult ActOnExprStmtError()
Definition: SemaStmt.cpp:66
AcceptableKind
Definition: Sema.h:8979
PragmaStack< StringLiteral * > BSSSegStack
Definition: Sema.h:1657
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:3407
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:9037
DeclContext * getCurLexicalContext() const
Definition: Sema.h:737
std::function< TypeResult(StringRef, StringRef, SourceLocation)> ParseTypeFromStringCallback
Callback to the parser to parse a type expressed as a string.
Definition: Sema.h:965
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:1701
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:1582
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:9583
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:8166
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:862
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:905
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:13556
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:16952
llvm::SmallSetVector< StringRef, 4 > MSFunctionNoBuiltins
Set of no-builtin functions listed by #pragma function.
Definition: Sema.h:1748
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
void ExitDeclaratorContext(Scope *S)
Definition: SemaDecl.cpp:1377
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
Definition: SemaExpr.cpp:15751
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:8426
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
Definition: Sema.cpp:784
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
RecordDecl * CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams)
Definition: SemaStmt.cpp:4503
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:3355
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:4571
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Definition: SemaDecl.cpp:12526
FileNullabilityMap NullabilityMap
A mapping that describes the nullability we've seen in each header file.
Definition: Sema.h:14584
ProcessingContextState ParsingClassState
Definition: Sema.h:6081
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:19787
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:941
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true, bool PrimaryHasMatchedPackOnParmToNonPackOnArg=false)
void PushCompoundScope(bool IsStmtExpr)
Definition: Sema.cpp:2325
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:14903
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Definition: SemaDecl.cpp:2289
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:2264
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:2759
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:1857
bool mightBeIntendedToBeTemplateName(ExprResult E, bool &Dependent)
Determine whether it's plausible that E was intended to be a template-name.
Definition: Sema.h:3390
std::pair< const IdentifierInfo *, uint64_t > TypeTagMagicValue
A pair of ArgumentKind identifier and magic value.
Definition: Sema.h:2236
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Definition: SemaDecl.cpp:20280
std::optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
TemplateDeductionResult FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, SmallVectorImpl< OriginalCallArg > const *OriginalCallArgs, bool PartialOverloading, bool PartialOrdering, llvm::function_ref< bool()> CheckNonDependent=[] { return false;})
Finish template argument deduction for a function template, checking the deduced template arguments f...
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
Definition: SemaExpr.cpp:10417
bool CheckNontrivialField(FieldDecl *FD)
Definition: SemaDecl.cpp:18713
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:9634
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:1736
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
Definition: Sema.h:6478
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:18193
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:2144
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:12665
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
Definition: SemaInit.cpp:9841
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:4424
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:8954
void LateTemplateParserCleanupCB(void *P)
Definition: Sema.h:951
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:5393
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:13215
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:15012
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Definition: Sema.h:7786
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
Definition: Sema.h:1697
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Definition: SemaDecl.cpp:20310
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
Definition: Sema.h:9589
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:8974
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:7280
static bool isCast(CheckedConversionKind CCK)
Definition: Sema.h:2085
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:16302
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
Definition: SemaExpr.cpp:7670
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:15452
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:2361
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
Definition: Sema.h:6493
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:6044
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:18184
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
Definition: SemaDecl.cpp:15376
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:1045
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:7583
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:9066
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:20892
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:14943
SuppressedDiagnosticsMap SuppressedDiagnostics
Definition: Sema.h:12157
@ VAK_Invalid
Definition: Sema.h:7541
@ VAK_Valid
Definition: Sema.h:7537
@ VAK_ValidInCXX11
Definition: Sema.h:7538
@ VAK_MSVCUndefined
Definition: Sema.h:7540
@ VAK_Undefined
Definition: Sema.h:7539
SemaOpenCL & OpenCL()
Definition: Sema.h:1122
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:5826
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Definition: Sema.h:13565
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:9817
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:16676
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
bool isPreciseFPEnabled()
Are precise floating point semantics currently enabled?
Definition: Sema.h:1837
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
Definition: SemaDecl.cpp:15213
IdentifierInfo * getNullabilityKeyword(NullabilityKind nullability)
Retrieve the keyword associated.
Definition: SemaType.cpp:3774
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:14600
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:7916
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:5876
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
Definition: Sema.h:5878
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
Definition: Sema.h:5881
FormatArgumentPassingKind
Definition: Sema.h:2160
@ FAPK_Fixed
Definition: Sema.h:2161
@ FAPK_Variadic
Definition: Sema.h:2162
@ FAPK_VAList
Definition: Sema.h:2163
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:20128
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:7778
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
llvm::DenseMap< ParmVarDecl *, llvm::TinyPtrVector< ParmVarDecl * > > UnparsedDefaultArgInstantiationsMap
Definition: Sema.h:12656
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Definition: Sema.cpp:1550
StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, NamedReturnInfo &NRInfo, bool SupressSimplerImplicitMoves)
ActOnCapScopeReturnStmt - Utility routine to type-check return statements for capturing scopes.
Definition: SemaStmt.cpp:3504
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:8977
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
Definition: Sema.h:7581
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
Definition: Sema.h:7625
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
Definition: Sema.h:7591
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Definition: Sema.h:7649
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
Definition: Sema.h:7654
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
Definition: Sema.h:7641
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
Definition: Sema.h:7620
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
Definition: Sema.h:7599
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
Definition: Sema.h:7658
@ Compatible
Compatible - the types are compatible according to the standard.
Definition: Sema.h:7583
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
Definition: Sema.h:7610
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
Definition: Sema.h:7662
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
Definition: Sema.h:7595
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
Definition: Sema.h:7604
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
Definition: Sema.h:7616
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
Definition: Sema.h:7637
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
Definition: Sema.h:7631
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
Definition: Sema.h:7587
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
Definition: Sema.h:7645
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:8467
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1291
StmtResult ActOnCapturedRegionEnd(Stmt *S)
Definition: SemaStmt.cpp:4675
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
Definition: Sema.h:7400
@ ACK_Arithmetic
An arithmetic operation.
Definition: Sema.h:7402
@ ACK_CompAssign
A compound assignment expression.
Definition: Sema.h:7410
@ ACK_BitwiseOp
A bitwise operation.
Definition: Sema.h:7404
@ ACK_Conditional
A conditional (?:) operator.
Definition: Sema.h:7408
@ ACK_Comparison
A comparison.
Definition: Sema.h:7406
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
Definition: SemaDecl.cpp:4746
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
Definition: SemaExpr.cpp:20026
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
Definition: SemaDecl.cpp:15803
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:15025
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:9632
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:2255
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:3232
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
Definition: Sema.h:7974
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:16761
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
Definition: Sema.h:3107
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
Definition: Sema.h:6290
bool MSStructPragmaOn
Definition: Sema.h:1409
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:20982
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Definition: SemaType.cpp:9242
ExprResult TransformToPotentiallyEvaluated(Expr *E)
Definition: SemaExpr.cpp:17385
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:13191
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:15852
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:11058
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:13512
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:3843
@ NTK_Typedef
Definition: Sema.h:3848
@ NTK_NonUnion
Definition: Sema.h:3846
@ NTK_TypeAlias
Definition: Sema.h:3849
@ NTK_NonClass
Definition: Sema.h:3845
@ NTK_NonEnum
Definition: Sema.h:3847
@ NTK_NonStruct
Definition: Sema.h:3844
@ NTK_TemplateTemplateArgument
Definition: Sema.h:3852
@ NTK_TypeAliasTemplate
Definition: Sema.h:3851
@ NTK_Template
Definition: Sema.h:3850
bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID)
Definition: Sema.h:15000
SourceManager & getSourceManager() const
Definition: Sema.h:531
void BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
Definition: SemaModule.cpp:734
TryCaptureKind
Definition: Sema.h:6594
@ TryCapture_Implicit
Definition: Sema.h:6595
@ TryCapture_ExplicitByVal
Definition: Sema.h:6596
@ TryCapture_ExplicitByRef
Definition: Sema.h:6597
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9833
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
Definition: Sema.h:8045
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:4402
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:6711
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:569
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:3060
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:4316
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:881
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
Definition: SemaDecl.cpp:20042
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:1342
void diagnoseFunctionEffectConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn when implicitly changing function effects.
Definition: Sema.cpp:632
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:11900
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:11234
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:3464
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:8782
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:12749
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:547
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
Definition: SemaExpr.cpp:10592
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:8971
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
Definition: SemaExpr.cpp:19642
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Definition: SemaType.cpp:9737
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
Definition: SemaExpr.cpp:13729
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:18170
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:12089
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:1436
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:6986
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:3653
@ NTCUK_Destruct
Definition: Sema.h:3655
@ NTCUK_Init
Definition: Sema.h:3654
@ NTCUK_Copy
Definition: Sema.h:3656
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:982
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:10020
std::vector< std::pair< QualType, unsigned > > ExcessPrecisionNotSatisfied
Definition: Sema.h:7931
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
PragmaClangSection PragmaClangDataSection
Definition: Sema.h:1433
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Definition: SemaExpr.cpp:20263
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Definition: SemaDecl.cpp:15880
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
Definition: SemaExpr.cpp:5488
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:8767
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
Definition: SemaDecl.cpp:13897
bool anyAltivecTypes(QualType srcType, QualType destType)
Definition: SemaExpr.cpp:7564
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:7601
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:1230
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:2425
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
Definition: Sema.cpp:2192
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:20253
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:1646
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:6414
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
MaybeODRUseExprSet MaybeODRUseExprs
Definition: Sema.h:6288
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
ExternalSemaSource * getExternalSource() const
Definition: Sema.h:536
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:854
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Definition: Sema.h:1704
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:8404
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:14597
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:20237
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:8302
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:14341
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:3883
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
Definition: Sema.h:14967
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, const PartialDiagnostic &PD, const FunctionDecl *FD=nullptr)
Definition: Sema.h:743
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:15282
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
Definition: Sema.cpp:2721
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:1876
void setFunctionHasMustTail()
Definition: Sema.cpp:2356
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:7703
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
Definition: Sema.h:7970
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
CorrectTypoKind
Definition: Sema.h:9383
@ CTK_NonError
Definition: Sema.h:9384
@ CTK_ErrorRecovery
Definition: Sema.h:9385
void CheckCompleteVariableDeclaration(VarDecl *VD)
Definition: SemaDecl.cpp:14307
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
Definition: SemaInit.cpp:3469
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
TUFragmentKind
Definition: Sema.h:614
@ Global
The global module fragment, between 'module;' and a module-declaration.
Definition: Sema.h:616
@ Private
The private module fragment, between 'module :private;' and the end of the translation unit.
Definition: Sema.h:623
@ Normal
A normal translation unit fragment.
Definition: Sema.h:620
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
void PopSatisfactionStackEntry()
Definition: Sema.h:14347
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
Definition: SemaType.cpp:1805
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:14828
void setFunctionHasBranchProtectedScope()
Definition: Sema.cpp:2346
RedeclarationKind forRedeclarationInCurContext() const
bool hasReachableDefinition(NamedDecl *D)
Definition: Sema.h:15046
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:4507
bool isConstantEvaluatedContext() const
Definition: Sema.h:2152
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
Definition: Sema.h:6055
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block)
Definition: SemaStmt.cpp:4461
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:594
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:14357
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:3273
QualType BuiltinAddPointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9800
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:1100
CCEKind
Contexts in which a converted constant expression is required.
Definition: Sema.h:9999
@ CCEK_StaticAssertMessageSize
Call to size() in a static assert message.
Definition: Sema.h:10006
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
Definition: Sema.h:10004
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
Definition: Sema.h:10005
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
Definition: Sema.h:10003
@ CCEK_CaseValue
Expression in a case label.
Definition: Sema.h:10000
@ CCEK_TemplateArg
Value of a non-type template parameter.
Definition: Sema.h:10002
@ CCEK_StaticAssertMessageData
Call to data() in a static assert message.
Definition: Sema.h:10008
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
Definition: Sema.h:10001
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:2683
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:1822
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:18776
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
std::pair< StringRef, QualType > CapturedParamNameType
Definition: Sema.h:10925
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:1184
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
Definition: SemaDecl.cpp:3095
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:1895
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
Definition: Sema.h:3081
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:288
ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
Definition: SemaDecl.cpp:19573
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
Definition: Sema.h:1178
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
Definition: SemaDecl.cpp:12561
ASTConsumer & Consumer
Definition: Sema.h:911
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:4228
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
OverloadKind
Definition: Sema.h:9777
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
Definition: Sema.h:9788
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
Definition: Sema.h:9780
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
Definition: Sema.h:9784
PragmaAlignPackDiagnoseKind
Definition: Sema.h:1815
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:6485
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:2052
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Definition: Sema.h:946
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
Definition: Sema.cpp:1686
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
Definition: Sema.h:13548
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Definition: SemaExpr.cpp:5121
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:7408
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:9616
@ 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:14596
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Definition: SemaExpr.cpp:3534
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData)
Definition: SemaExpr.cpp:16802
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
Definition: SemaExpr.cpp:12694
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Definition: Sema.cpp:86
StmtResult ActOnMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name, Stmt *Nested)
Definition: SemaStmt.cpp:4491
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void incrementMSManglingNumber() const
Definition: Sema.h:875
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:8409
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
Definition: SemaDecl.cpp:16573
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition: Sema.h:6232
@ 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:9705
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
Definition: Sema.h:13199
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:9964
AvailabilityPriority
Describes the kind of priority given to an availability attribute.
Definition: Sema.h:4387
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
Definition: Sema.h:4393
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
Definition: Sema.h:4397
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
Definition: Sema.h:4390
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
Definition: Sema.h:4044
@ AMK_None
Don't merge availability attributes at all.
Definition: Sema.h:4046
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
Definition: Sema.h:4052
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
Definition: Sema.h:4055
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
Definition: Sema.h:4058
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
Definition: Sema.h:4049
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
Definition: SemaDecl.cpp:14947
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Parse a __builtin_astype expression.
Definition: SemaExpr.cpp:6704
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4441
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:5704
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
Definition: SemaDecl.cpp:14614
ExprResult BuildOperatorCoawaitLookupExpr(Scope *S, SourceLocation Loc)
std::pair< SourceLocation, bool > DeleteExprLoc
Definition: Sema.h:574
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:20270
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:17161
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:4824
SemaPPC & PPC()
Definition: Sema.h:1132
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:2205
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16506
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:5817
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:4461
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Definition: SemaType.cpp:9120
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Definition: SemaDecl.cpp:15298
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:873
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:1338
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:14349
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
Definition: SemaExpr.cpp:20912
LateTemplateParserCB * LateTemplateParser
Definition: Sema.h:952
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:19021
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:19274
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
Definition: SemaExpr.cpp:7738
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC #pragma optimize in scope,...
Definition: SemaAttr.cpp:1291
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:7981
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:11082
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Definition: Sema.h:3100
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool DeferDiags
Whether deferrable diagnostics should be deferred.
Definition: Sema.h:9756
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:7456
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:7768
SemaSystemZ & SystemZ()
Definition: Sema.h:1162
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
Definition: Sema.cpp:100
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:2743
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:17915
QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9845
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
Definition: SemaExpr.cpp:19266
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:7918
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
Definition: SemaDecl.cpp:1310
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
Definition: SemaExpr.cpp:7650
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:9602
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
Definition: SemaType.cpp:9095
StmtResult ActOnAttributedStmt(const ParsedAttributes &AttrList, Stmt *SubStmt)
Definition: SemaStmt.cpp:668
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9871
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
Definition: Sema.h:913
TemplateNameIsRequiredTag
Definition: Sema.h:11092
@ TemplateNameIsRequired
Definition: Sema.h:11092
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:4704
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
Definition: SemaExpr.cpp:7811
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:5779
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:15937
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:6048
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:9068
DiagnosticsEngine & Diags
Definition: Sema.h:912
CXXMethodDecl * CreateLambdaCallOperator(SourceRange IntroducerRange, CXXRecordDecl *Class)
Definition: SemaLambda.cpp:975
void DiagnoseUnterminatedPragmaAlignPack()
Definition: SemaAttr.cpp:586
StmtResult ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope)
Definition: SemaStmt.cpp:3300
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
Definition: Sema.h:7302
OpenCLOptions & getOpenCLOptions()
Definition: Sema.h:527
FPOptions CurFPFeatures
Definition: Sema.h:906
void ActOnStartSEHFinallyBlock()
Definition: SemaStmt.cpp:4453
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
static bool CanBeGetReturnObject(const FunctionDecl *FD)
Definition: SemaDecl.cpp:15933
NamespaceDecl * getStdNamespace() const
QualType BuiltinRemovePointer(QualType BaseType, SourceLocation Loc)
Definition: SemaType.cpp:9809
llvm::SmallPtrSet< const CXXRecordDecl *, 8 > RecordDeclSetTy
Definition: Sema.h:6039
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:6669
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
Definition: SemaType.cpp:2048
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:1656
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:693
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Definition: Sema.h:953
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:7587
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:9771
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Definition: SemaDecl.cpp:7293
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:2782
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:14978
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:11281
@ TPC_ClassTemplate
Definition: Sema.h:11282
@ TPC_FriendFunctionTemplate
Definition: Sema.h:11287
@ TPC_ClassTemplateMember
Definition: Sema.h:11285
@ TPC_FunctionTemplate
Definition: Sema.h:11284
@ TPC_FriendClassTemplate
Definition: Sema.h:11286
@ TPC_FriendFunctionTemplateDefinition
Definition: Sema.h:11288
@ TPC_TypeAliasTemplate
Definition: Sema.h:11289
@ TPC_VarTemplate
Definition: Sema.h:11283
void ActOnPragmaVisibility(const IdentifierInfo *VisType, SourceLocation PragmaLoc)
ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
Definition: SemaAttr.cpp:1357
void ActOnAbortSEHFinallyBlock()
Definition: SemaStmt.cpp:4457
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:6753
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
Definition: SemaDecl.cpp:16428
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:1784
ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val)
Definition: SemaExpr.cpp:3598
SemaAVR & AVR()
Definition: Sema.h:1057
SmallVector< LateInstantiatedAttribute, 16 > LateInstantiatedAttrVec
Definition: Sema.h:13670
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5582
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:20313
SourceLocation OptimizeOffPragmaLocation
This represents the last location of a "#pragma clang optimize off" directive if such a directive has...
Definition: Sema.h:1732
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:2070
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
friend class ArgumentPackSubstitutionRAII
Definition: Sema.h:13236
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:1932
void PopDeclContext()
Definition: SemaDecl.cpp:1317
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:2871
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:13105
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:6067
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
Definition: Sema.h:13166
void PrintStats() const
Print out statistics about the semantic analysis.
Definition: Sema.cpp:608
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
Definition: SemaExpr.cpp:15865
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:14587
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:6075
FormatStringType
Definition: Sema.h:2189
@ FST_NSString
Definition: Sema.h:2192
@ FST_Syslog
Definition: Sema.h:2199
@ FST_Unknown
Definition: Sema.h:2200
@ FST_Strftime
Definition: Sema.h:2193
@ FST_Printf
Definition: Sema.h:2191
@ FST_FreeBSDKPrintf
Definition: Sema.h:2196
@ FST_Scanf
Definition: Sema.h:2190
@ FST_Strfmon
Definition: Sema.h:2194
@ FST_OSLog
Definition: Sema.h:2198
@ FST_Kprintf
Definition: Sema.h:2195
@ FST_OSTrace
Definition: Sema.h:2197
LangOptions::PragmaMSPointersToMembersKind MSPointerToMemberRepresentationMethod
Controls member pointer representation format under the MS ABI.
Definition: Sema.h:1407
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:1581
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:12810
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD)
llvm::BumpPtrAllocator BumpAlloc
Definition: Sema.h:859
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:1936
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:10756
@ BFRK_Check
Determining whether a for-range statement could be built.
Definition: Sema.h:10764
@ BFRK_Build
Initial building of a for-range statement.
Definition: Sema.h:10758
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:10761
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
Definition: SemaExpr.cpp:8885
SemaNVPTX & NVPTX()
Definition: Sema.h:1107
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:4170
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:13939
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:13107
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:1566
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
Definition: SemaDecl.cpp:16820
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:9719
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:16312
OffsetOfKind
Definition: Sema.h:3867
@ OOK_Outside
Definition: Sema.h:3869
@ OOK_Macro
Definition: Sema.h:3874
@ OOK_Builtin
Definition: Sema.h:3871
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
Definition: SemaDecl.cpp:13380
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
Definition: SemaType.cpp:9592
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
PragmaSectionKind
Definition: Sema.h:1676
@ PSK_ConstSeg
Definition: Sema.h:1679
@ PSK_DataSeg
Definition: Sema.h:1677
@ PSK_CodeSeg
Definition: Sema.h:1680
@ PSK_BSSSeg
Definition: Sema.h:1678
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:564
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Definition: SemaExpr.cpp:20048
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Definition: Sema.cpp:594
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:16830
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:5810
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:18412
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:18096
CodeAlignAttr * BuildCodeAlignAttr(const AttributeCommonInfo &CI, Expr *E)
ExprResult ActOnStmtExprResult(ExprResult E)
Definition: SemaExpr.cpp:15909
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:4757
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
Definition: SemaDecl.cpp:4352
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:14224
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:5954
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
Definition: SemaLambda.cpp:284
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
Definition: SemaType.cpp:2447
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
Definition: SemaExpr.cpp:20369
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:3075
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
Definition: Sema.cpp:1963
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:21179
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:4704
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:9149
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15356
PragmaClangSection PragmaClangBSSSection
Definition: Sema.h:1432
Decl * ActOnDeclarator(Scope *S, Declarator &D)
Definition: SemaDecl.cpp:6088
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:969
AbstractDiagSelID
Definition: Sema.h:5756
@ AbstractSynthesizedIvarType
Definition: Sema.h:5763
@ AbstractVariableType
Definition: Sema.h:5760
@ AbstractReturnType
Definition: Sema.h:5758
@ AbstractNone
Definition: Sema.h:5757
@ AbstractFieldType
Definition: Sema.h:5761
@ AbstractArrayType
Definition: Sema.h:5764
@ AbstractParamType
Definition: Sema.h:5759
@ AbstractIvarType
Definition: Sema.h:5762
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:962
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:7255
PragmaOptionsAlignKind
Definition: Sema.h:1785
@ POAK_Power
Definition: Sema.h:1789
@ POAK_Reset
Definition: Sema.h:1791
@ POAK_Packed
Definition: Sema.h:1788
@ POAK_Mac68k
Definition: Sema.h:1790
@ POAK_Natural
Definition: Sema.h:1787
@ POAK_Native
Definition: Sema.h:1786
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:16164
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)
SemaSPIRV & SPIRV()
Definition: Sema.h:1147
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:4830
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:1705
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
Definition: Sema.h:7967
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:1239
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:14779
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:543
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9938
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
Definition: SemaExpr.cpp:9160
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:8180
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:6438
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:4687
QualType PreferredConditionType(ConditionKind K) const
Definition: Sema.h:7498
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:9040
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
Definition: Sema.h:9044
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
Definition: Sema.h:9050
@ LOLR_Error
The lookup resulted in an error.
Definition: Sema.h:9042
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
Definition: Sema.h:9047
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
Definition: Sema.h:9058
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
Definition: Sema.h:9054
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Definition: SemaDecl.cpp:20292
sema::FunctionScopeInfo * getEnclosingFunction() const
Definition: Sema.cpp:2376
const ExpressionEvaluationContextRecord & parentEvaluationContext() const
Definition: Sema.h:6466
SemaLoongArch & LoongArch()
Definition: Sema.h:1087
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Definition: SemaExpr.cpp:16193
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
Definition: SemaExpr.cpp:10631
CheckConstexprKind
Definition: Sema.h:5952
@ 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:13544
void CheckVariableDeclarationType(VarDecl *NewVD)
Definition: SemaDecl.cpp:8638
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:2735
OpaquePtr< TemplateName > TemplateTy
Definition: Sema.h:902
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
Definition: SemaInit.cpp:9756
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:395
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
Definition: SemaDecl.cpp:1324
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
Definition: Sema.cpp:644
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:13073
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:2437
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:2751
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:3056
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:1595
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:15817
bool RequireCompleteExprType(Expr *E, unsigned DiagID, const Ts &...Args)
Definition: Sema.h:14891
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:13359
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
Definition: SemaExpr.cpp:11073
static ConditionResult ConditionError()
Definition: Sema.h:7339
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:1167
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
Definition: SemaExpr.cpp:6725
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:3004
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:13162
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType &paramType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
Definition: SemaExpr.cpp:20916
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:20013
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:5814
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
Definition: SemaExpr.cpp:16107
SemaPseudoObject & PseudoObject()
Definition: Sema.h:1137
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Definition: Sema.cpp:2337
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:608
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
Definition: Sema.h:11057
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:4290
FullExprArg MakeFullExpr(Expr *Arg)
Definition: Sema.h:7295
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:683
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:15187
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:7926
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: Sema.h:901
static int getPrintable(int I)
Definition: Sema.h:14586
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:9310
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
Definition: Sema.h:12497
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:3376
bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, QualType SrcTy)
Definition: SemaCast.cpp:2717
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:17923
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:14591
PragmaClangSectionKind
pragma clang section kind
Definition: Sema.h:1415
@ PCSK_Invalid
Definition: Sema.h:1416
@ PCSK_BSS
Definition: Sema.h:1417
@ PCSK_Data
Definition: Sema.h:1418
@ PCSK_Text
Definition: Sema.h:1420
@ PCSK_Relro
Definition: Sema.h:1421
@ PCSK_Rodata
Definition: Sema.h:1419
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7187
void warnOnReservedIdentifier(const NamedDecl *D)
Definition: SemaDecl.cpp:6075
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition: SemaStmt.cpp:552
bool isCheckingDefaultArgumentOrInitializer() const
Definition: Sema.h:7794
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:16893
SemaARM & ARM()
Definition: Sema.h:1052
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:14589
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:2682
AllocationFunctionScope
The scope in which to find allocation functions.
Definition: Sema.h:8164
@ AFS_Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
Definition: Sema.h:8172
@ AFS_Class
Only look for allocation functions in the scope of the allocated class.
Definition: Sema.h:8169
@ AFS_Global
Only look for allocation functions in the global scope.
Definition: Sema.h:8166
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:5333
ValueDecl * tryLookupUnambiguousFieldDecl(RecordDecl *ClassDecl, const IdentifierInfo *MemberOrBase)
ASTMutationListener * getASTMutationListener() const
Definition: Sema.cpp:590
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Definition: SemaType.cpp:2734
PragmaMsStackAction
Definition: Sema.h:1438
@ PSK_Push_Set
Definition: Sema.h:1444
@ PSK_Reset
Definition: Sema.h:1439
@ PSK_Pop_Set
Definition: Sema.h:1445
@ PSK_Show
Definition: Sema.h:1443
@ PSK_Pop
Definition: Sema.h:1442
@ PSK_Set
Definition: Sema.h:1440
@ PSK_Push
Definition: Sema.h:1441
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3199
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:8269
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:5007
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Definition: SemaDecl.cpp:1266
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 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:334
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:3578
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:398
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:4459
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:3384
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:7908
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:3528
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3427
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:3574
Represents C++ using-directive.
Definition: DeclCXX.h:3077
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3382
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:4035
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:456
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:147
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:3575
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isFunctionOrMethodVariadic(const Decl *D)
Definition: Attr.h:112
TagUseKind
Definition: Sema.h:448
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
Definition: LangOptions.h:36
UnaryOperatorKind
ActionResult< Expr * > ExprResult
Definition: Ownership.h:248
TagTypeKind
The kind of a tag type.
Definition: Type.h:6877
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:1097
@ TU_Complete
The translation unit is a complete translation unit.
Definition: LangOptions.h:1099
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:1103
ComparisonCategoryType
An enumeration representing the different comparison categories types.
PragmaMSStructKind
Definition: PragmaKinds.h:23
AssignmentAction
Definition: Sema.h:212
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:249
CXXSpecialMemberKind
Kinds of C++ special members.
Definition: Sema.h:424
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:237
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:366
@ 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:6852
@ 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.
bool isLambdaMethod(const DeclContext *DC)
Definition: ASTLambda.h:39
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:435
@ 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:241
SourceLocation PointerEndLoc
The end location for the first pointer declarator in the file.
Definition: Sema.h:248
SourceLocation PointerLoc
The first pointer declarator (of any pointer kind) in the file that does not have a corresponding nul...
Definition: Sema.h:244
bool SawTypeNullability
Whether we saw any type nullability annotations in the given file.
Definition: Sema.h:254
uint8_t PointerKind
Which kind of pointer declarator we saw.
Definition: Sema.h:251
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition: Type.h:4846
Holds information about the various types of exception specification.
Definition: Type.h:5165
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:5167
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:5170
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:5173
Extra information about a function prototype.
Definition: Type.h:5193
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:15205
CachedTokens Toks
Definition: Sema.h:15206
FPOptions FPO
Floating-point options in the point of definition.
Definition: Sema.h:15210
Decl * D
The template function declaration to be late parsed.
Definition: Sema.h:15208
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:1651
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:12670
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
Definition: Sema.h:12834
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
Definition: Sema.h:12787
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Definition: Sema.h:12803
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Definition: Sema.h:12829
ArrayRef< TemplateArgument > template_arguments() const
Definition: Sema.h:12822
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
Definition: Sema.h:12798
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
Definition: Sema.h:12790
unsigned NumCallArgs
The number of expressions in CallArgs.
Definition: Sema.h:12816
const Expr *const * CallArgs
The list of argument expressions in a synthesized call.
Definition: Sema.h:12806
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
Definition: Sema.h:12813
SynthesisKind
The kind of template instantiation we are performing.
Definition: Sema.h:12672
@ MarkingClassDllexported
We are marking a class as __dllexport.
Definition: Sema.h:12764
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
Definition: Sema.h:12682
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
Definition: Sema.h:12691
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Definition: Sema.h:12710
@ InitializingStructuredBinding
We are initializing a structured binding.
Definition: Sema.h:12761
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Definition: Sema.h:12718
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
Definition: Sema.h:12725
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Definition: Sema.h:12768
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
Definition: Sema.h:12736
@ Memoization
Added for Template instantiation observation.
Definition: Sema.h:12774
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition: Sema.h:12701
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
Definition: Sema.h:12780
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition: Sema.h:12777
@ PartialOrderingTTP
We are performing partial ordering for template template parameters.
Definition: Sema.h:12783
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
Definition: Sema.h:12698
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
Definition: Sema.h:12706
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
Definition: Sema.h:12714
@ TemplateInstantiation
We are instantiating a template declaration.
Definition: Sema.h:12675
@ DeclaringSpecialMember
We are declaring an implicit special member function.
Definition: Sema.h:12728
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Definition: Sema.h:12732
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Definition: Sema.h:12687
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Definition: Sema.h:12758
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Definition: Sema.h:12721
Decl * Entity
The entity that is being synthesized.
Definition: Sema.h:12793
CXXSpecialMemberKind SpecialMember
The special member being declared or defined.
Definition: Sema.h:12819
ConstraintEvalRAII(InstTy &TI)
Definition: Sema.h:13355
InitializationContext(SourceLocation Loc, ValueDecl *Decl, DeclContext *Context)
Definition: Sema.h:6384
Data structure used to record current or nested expression evaluation contexts.
Definition: Sema.h:6294
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:6326
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
Definition: Sema.h:6328
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Definition: Sema.h:6374
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
Definition: Sema.h:6318
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:6322
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Definition: Sema.h:6333
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:6341
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
Definition: Sema.h:6337
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
Definition: Sema.h:6347
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
Definition: Sema.h:6313
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:6351
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
Definition: Sema.h:6377
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Definition: Sema.h:6299
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Definition: Sema.h:6307
std::optional< InitializationContext > DelayedDefaultInitializationContext
Definition: Sema.h:6394
ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
Definition: Sema.h:6396
ExpressionEvaluationContext Context
The expression evaluation context.
Definition: Sema.h:6296
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Definition: Sema.h:6303
FormatArgumentPassingKind ArgPassingKind
Definition: Sema.h:2171
std::optional< FunctionEffectWithCondition > Old
Definition: Sema.h:15112
StringRef effectName() const
Definition: Sema.h:15116
OverrideResult
Describes the result of effects differing between a base class's virtual method and an overriding met...
Definition: Sema.h:15124
std::optional< FunctionEffectWithCondition > New
Definition: Sema.h:15114
FunctionEffect::Kind EffectKind
Definition: Sema.h:15109
An RAII helper that pops function a function scope on exit.
Definition: Sema.h:930
A stack object to be created when performing template instantiation.
Definition: Sema.h:12858
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
Definition: Sema.h:13018
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
Definition: Sema.h:13022
LocalInstantiationScope * Scope
Definition: Sema.h:13663
LateInstantiatedAttribute(const Attr *A, LocalInstantiationScope *S, Decl *D)
Definition: Sema.h:13666
bool isMoveEligible() const
Definition: Sema.h:10818
bool isCopyElidable() const
Definition: Sema.h:10819
const VarDecl * Candidate
Definition: Sema.h:10813
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2811
IdentifierInfo * Identifier
The identifier preceding the '::'.
Definition: Sema.h:2817
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, ParsedType ObjectType=ParsedType())
Creates info object for the most typical case.
Definition: Sema.h:2826
SourceLocation IdentifierLoc
The location of the identifier.
Definition: Sema.h:2820
SourceLocation CCLoc
The location of the '::'.
Definition: Sema.h:2823
ParsedType ObjectType
The type of the object, if we're parsing nested-name-specifier in a member access expression.
Definition: Sema.h:2814
NestedNameSpecInfo(IdentifierInfo *II, SourceLocation IdLoc, SourceLocation ColonColonLoc, QualType ObjectType)
Definition: Sema.h:2832
SourceLocation LocEnd
Definition: Sema.h:7071
IdentifierInfo * IdentInfo
Definition: Sema.h:7074
brief A function argument from which we performed template argument
Definition: Sema.h:12257
OriginalCallArg(QualType OriginalParamType, bool DecomposedParam, unsigned ArgIdx, QualType OriginalArgType)
Definition: Sema.h:12258
This an attribute introduced by #pragma clang attribute.
Definition: Sema.h:1707
SmallVector< attr::SubjectMatchRule, 4 > MatchRules
Definition: Sema.h:1710
A push'd group of PragmaAttributeEntries.
Definition: Sema.h:1715
SourceLocation Loc
The location of the push attribute.
Definition: Sema.h:1717
SmallVector< PragmaAttributeEntry, 2 > Entries
Definition: Sema.h:1720
const IdentifierInfo * Namespace
The namespace of this push group.
Definition: Sema.h:1719
SourceLocation PragmaLocation
Definition: Sema.h:1429
PragmaMsStackAction Action
Definition: Sema.h:1449
Slot(llvm::StringRef StackSlotLabel, ValueType Value, SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
Definition: Sema.h:1562
llvm::StringRef StackSlotLabel
Definition: Sema.h:1558
SourceLocation PragmaLocation
Definition: Sema.h:1560
SourceLocation PragmaPushLocation
Definition: Sema.h:1561
ValueType CurrentValue
Definition: Sema.h:1632
void SentinelAction(PragmaMsStackAction Action, StringRef Label)
Definition: Sema.h:1618
bool hasValue() const
Definition: Sema.h:1628
SmallVector< Slot, 2 > Stack
Definition: Sema.h:1630
ValueType DefaultValue
Definition: Sema.h:1631
SourceLocation CurrentPragmaLocation
Definition: Sema.h:1633
PragmaStack(const ValueType &Default)
Definition: Sema.h:1625
void Act(SourceLocation PragmaLocation, PragmaMsStackAction Action, llvm::StringRef StackSlotLabel, ValueType Value)
Definition: Sema.h:1569
ProcessDeclAttributeOptions WithIgnoreTypeAttributes(bool Val)
Definition: Sema.h:4646
ProcessDeclAttributeOptions WithIncludeCXX11Attributes(bool Val)
Definition: Sema.h:4640
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Definition: Sema.h:10132
Abstract class used to diagnose incomplete types.
Definition: Sema.h:7859
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
virtual ~TypeDiagnoser()
Definition: Sema.h:7863
TypeTagData(QualType Type, bool LayoutCompatible, bool MustBeNull)
Definition: Sema.h:2220
unsigned LayoutCompatible
If true, Type should be compared with other expression's types for layout-compatibility.
Definition: Sema.h:2229
std::unique_ptr< TypoCorrectionConsumer > Consumer
Definition: Sema.h:9492
TypoDiagnosticGenerator DiagHandler
Definition: Sema.h:9493
TypoRecoveryCallback RecoveryHandler
Definition: Sema.h:9494
bool CheckSameAsPrevious
Definition: Sema.h:352
NamedDecl * Previous
Definition: Sema.h:353
SkipBodyInfo()=default
NamedDecl * New
Definition: Sema.h:354
Information about a template-id annotation token.